@@ -63,7 +63,7 @@ uint32_t TFT_SPI::getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
uint32_t TFT_SPI::readID(uint16_t reg) {
|
||||
uint32_t TFT_SPI::readID(const uint16_t inReg) {
|
||||
uint32_t data = 0;
|
||||
|
||||
#if PIN_EXISTS(TFT_MISO)
|
||||
@@ -72,7 +72,7 @@ uint32_t TFT_SPI::readID(uint16_t reg) {
|
||||
SPIx.setClock(SPI_CLOCK_DIV64);
|
||||
SPIx.begin();
|
||||
WRITE(TFT_CS_PIN, LOW);
|
||||
writeReg(reg);
|
||||
writeReg(inReg);
|
||||
|
||||
for (uint8_t i = 0; i < 4; ++i) {
|
||||
SPIx.read((uint8_t*)&d, 1);
|
||||
|
@@ -56,7 +56,7 @@
|
||||
|
||||
class TFT_SPI {
|
||||
private:
|
||||
static uint32_t readID(uint16_t reg);
|
||||
static uint32_t readID(const uint16_t inReg);
|
||||
static void transmit(uint16_t data);
|
||||
static void transmit(uint32_t memoryIncrease, uint16_t *data, uint16_t count);
|
||||
static void transmitDMA(uint32_t memoryIncrease, uint16_t *data, uint16_t count);
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
static void dataTransferAbort();
|
||||
|
||||
static void writeData(uint16_t data) { transmit(data); }
|
||||
static void writeReg(uint16_t reg) { WRITE(TFT_DC_PIN, LOW); transmit(reg); WRITE(TFT_DC_PIN, HIGH); }
|
||||
static void writeReg(const uint16_t inReg) { WRITE(TFT_DC_PIN, LOW); transmit(inReg); WRITE(TFT_DC_PIN, HIGH); }
|
||||
|
||||
static void writeSequence_DMA(uint16_t *data, uint16_t count) { transmitDMA(DMA_MINC_ENABLE, data, count); }
|
||||
static void writeMultiple_DMA(uint16_t color, uint16_t count) { static uint16_t data; data = color; transmitDMA(DMA_MINC_DISABLE, &data, count); }
|
||||
|
@@ -40,7 +40,7 @@
|
||||
|
||||
class TFT_SPI {
|
||||
private:
|
||||
static uint32_t readID(uint16_t reg);
|
||||
static uint32_t readID(const uint16_t inReg);
|
||||
static void transmit(uint16_t data);
|
||||
static void transmitDMA(uint32_t memoryIncrease, uint16_t *data, uint16_t count);
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
static void dataTransferAbort();
|
||||
|
||||
static void writeData(uint16_t data);
|
||||
static void writeReg(uint16_t reg);
|
||||
static void writeReg(const uint16_t inReg);
|
||||
|
||||
static void writeSequence_DMA(uint16_t *data, uint16_t count) { writeSequence(data, count); }
|
||||
static void writeMultiple_DMA(uint16_t color, uint16_t count) { writeMultiple(color, count); }
|
||||
|
@@ -135,11 +135,11 @@ uint32_t TFT_FSMC::getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
uint32_t TFT_FSMC::readID(tft_data_t reg) {
|
||||
uint32_t TFT_FSMC::readID(const tft_data_t inReg) {
|
||||
uint32_t id;
|
||||
writeReg(reg);
|
||||
writeReg(inReg);
|
||||
id = LCD->RAM; // dummy read
|
||||
id = reg << 24;
|
||||
id = inReg << 24;
|
||||
id |= (LCD->RAM & 0x00FF) << 16;
|
||||
id |= (LCD->RAM & 0x00FF) << 8;
|
||||
id |= LCD->RAM & 0x00FF;
|
||||
|
@@ -62,7 +62,7 @@ class TFT_FSMC {
|
||||
|
||||
static LCD_CONTROLLER_TypeDef *LCD;
|
||||
|
||||
static uint32_t readID(tft_data_t reg);
|
||||
static uint32_t readID(const tft_data_t reg);
|
||||
static void transmit(tft_data_t data) { LCD->RAM = data; __DSB(); }
|
||||
static void transmit(uint32_t memoryIncrease, uint16_t *data, uint16_t count);
|
||||
static void transmitDMA(uint32_t memoryIncrease, uint16_t *data, uint16_t count);
|
||||
@@ -77,7 +77,7 @@ class TFT_FSMC {
|
||||
static void dataTransferEnd() {}
|
||||
|
||||
static void writeData(uint16_t data) { transmit(tft_data_t(data)); }
|
||||
static void writeReg(uint16_t reg) { LCD->REG = tft_data_t(reg); __DSB(); }
|
||||
static void writeReg(const uint16_t inReg) { LCD->REG = tft_data_t(inReg); __DSB(); }
|
||||
|
||||
static void writeSequence_DMA(uint16_t *data, uint16_t count) { transmitDMA(DMA_PINC_ENABLE, data, count); }
|
||||
static void writeMultiple_DMA(uint16_t color, uint16_t count) { static uint16_t data; data = color; transmitDMA(DMA_PINC_DISABLE, &data, count); }
|
||||
|
@@ -267,7 +267,7 @@ uint32_t TFT_LTDC::getID() {
|
||||
return 0xABAB;
|
||||
}
|
||||
|
||||
uint32_t TFT_LTDC::readID(tft_data_t reg) {
|
||||
uint32_t TFT_LTDC::readID(const tft_data_t inReg) {
|
||||
return 0xABAB;
|
||||
}
|
||||
|
||||
@@ -352,10 +352,6 @@ void TFT_LTDC::transmit(tft_data_t data) {
|
||||
}
|
||||
}
|
||||
|
||||
void TFT_LTDC::writeReg(uint16_t reg) {
|
||||
reg = reg;
|
||||
}
|
||||
|
||||
void TFT_LTDC::transmit(uint32_t memoryIncrease, uint16_t *data, uint16_t count) {
|
||||
|
||||
while (x_cur != x_min && count) {
|
||||
|
@@ -43,7 +43,7 @@ class TFT_LTDC {
|
||||
static uint16_t x_min, x_max, y_min, y_max, x_cur, y_cur;
|
||||
static uint8_t reg;
|
||||
|
||||
static uint32_t readID(tft_data_t reg);
|
||||
static uint32_t readID(const tft_data_t inReg);
|
||||
|
||||
static uint16_t readPoint(uint16_t x, uint16_t y);
|
||||
static void drawPoint(uint16_t x, uint16_t y, uint16_t color);
|
||||
@@ -62,7 +62,7 @@ class TFT_LTDC {
|
||||
static void dataTransferEnd() {};
|
||||
|
||||
static void writeData(uint16_t data);
|
||||
static void writeReg(uint16_t reg);
|
||||
static void writeReg(const uint16_t inReg) { reg = inReg; }
|
||||
|
||||
// Non-blocking DMA data transfer is not implemented for LTDC interface
|
||||
inline static void writeSequence_DMA(uint16_t *data, uint16_t count) { writeSequence(data, count); }
|
||||
|
@@ -145,7 +145,7 @@ uint32_t TFT_SPI::getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
uint32_t TFT_SPI::readID(uint16_t reg) {
|
||||
uint32_t TFT_SPI::readID(const uint16_t inReg) {
|
||||
uint32_t data = 0;
|
||||
#if PIN_EXISTS(TFT_MISO)
|
||||
uint32_t BaudRatePrescaler = SPIx.Init.BaudRatePrescaler;
|
||||
@@ -153,7 +153,7 @@ uint32_t TFT_SPI::readID(uint16_t reg) {
|
||||
|
||||
SPIx.Init.BaudRatePrescaler = SPIx.Instance == SPI1 ? SPI_BAUDRATEPRESCALER_8 : SPI_BAUDRATEPRESCALER_4;
|
||||
dataTransferBegin(DATASIZE_8BIT);
|
||||
writeReg(reg);
|
||||
writeReg(inReg);
|
||||
|
||||
if (SPIx.Init.Direction == SPI_DIRECTION_1LINE) SPI_1LINE_RX(&SPIx);
|
||||
__HAL_SPI_ENABLE(&SPIx);
|
||||
|
@@ -46,7 +46,7 @@ private:
|
||||
static SPI_HandleTypeDef SPIx;
|
||||
static DMA_HandleTypeDef DMAtx;
|
||||
|
||||
static uint32_t readID(uint16_t reg);
|
||||
static uint32_t readID(const uint16_t inReg);
|
||||
static void transmit(uint16_t data);
|
||||
static void transmit(uint32_t memoryIncrease, uint16_t *data, uint16_t count);
|
||||
static void transmitDMA(uint32_t memoryIncrease, uint16_t *data, uint16_t count);
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
static void dataTransferAbort();
|
||||
|
||||
static void writeData(uint16_t data) { transmit(data); }
|
||||
static void writeReg(uint16_t reg) { WRITE(TFT_A0_PIN, LOW); transmit(reg); WRITE(TFT_A0_PIN, HIGH); }
|
||||
static void writeReg(const uint16_t inReg) { WRITE(TFT_A0_PIN, LOW); transmit(inReg); WRITE(TFT_A0_PIN, HIGH); }
|
||||
|
||||
static void writeSequence_DMA(uint16_t *data, uint16_t count) { transmitDMA(DMA_MINC_ENABLE, data, count); }
|
||||
static void writeMultiple_DMA(uint16_t color, uint16_t count) { static uint16_t data; data = color; transmitDMA(DMA_MINC_DISABLE, &data, count); }
|
||||
|
@@ -186,8 +186,8 @@ void TFT_FSMC::transmit(uint16_t data) {
|
||||
__DSB();
|
||||
}
|
||||
|
||||
void TFT_FSMC::writeReg(uint16_t reg) {
|
||||
LCD->REG = reg;
|
||||
void TFT_FSMC::writeReg(const uint16_t inReg) {
|
||||
LCD->REG = inReg;
|
||||
__DSB();
|
||||
}
|
||||
|
||||
@@ -205,11 +205,11 @@ uint32_t TFT_FSMC::getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
uint32_t TFT_FSMC::readID(uint16_t reg) {
|
||||
uint32_t TFT_FSMC::readID(const uint16_t inReg) {
|
||||
uint32_t id;
|
||||
writeReg(reg);
|
||||
writeReg(inReg);
|
||||
id = LCD->RAM; // dummy read
|
||||
id = reg << 24;
|
||||
id = inReg << 24;
|
||||
id |= (LCD->RAM & 0x00FF) << 16;
|
||||
id |= (LCD->RAM & 0x00FF) << 8;
|
||||
id |= LCD->RAM & 0x00FF;
|
||||
|
@@ -54,7 +54,7 @@ class TFT_FSMC {
|
||||
private:
|
||||
static LCD_CONTROLLER_TypeDef *LCD;
|
||||
|
||||
static uint32_t readID(uint16_t reg);
|
||||
static uint32_t readID(const uint16_t inReg);
|
||||
static void transmit(uint16_t data);
|
||||
static void transmit(uint32_t memoryIncrease, uint16_t *data, uint16_t count);
|
||||
static void transmitDMA(uint32_t memoryIncrease, uint16_t *data, uint16_t count);
|
||||
@@ -69,7 +69,7 @@ class TFT_FSMC {
|
||||
static void dataTransferEnd() {};
|
||||
|
||||
static void writeData(uint16_t data) { transmit(data); }
|
||||
static void writeReg(uint16_t reg);
|
||||
static void writeReg(const uint16_t inReg);
|
||||
|
||||
static void writeSequence_DMA(uint16_t *data, uint16_t count) { transmitDMA(DMA_PINC_ENABLE, data, count); }
|
||||
static void writeMultiple_DMA(uint16_t color, uint16_t count) { static uint16_t data; data = color; transmitDMA(DMA_PINC_DISABLE, &data, count); }
|
||||
|
@@ -93,13 +93,13 @@ uint32_t TFT_SPI::getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
uint32_t TFT_SPI::readID(uint16_t reg) {
|
||||
uint32_t TFT_SPI::readID(const uint16_t inReg) {
|
||||
uint32_t data = 0;
|
||||
|
||||
#if PIN_EXISTS(TFT_MISO)
|
||||
SPIx.setClockDivider(SPI_CLOCK_DIV16);
|
||||
dataTransferBegin(DATASIZE_8BIT);
|
||||
writeReg(reg);
|
||||
writeReg(inReg);
|
||||
|
||||
for (uint8_t i = 0; i < 4; ++i) {
|
||||
uint8_t d;
|
||||
|
@@ -63,7 +63,7 @@
|
||||
|
||||
class TFT_SPI {
|
||||
private:
|
||||
static uint32_t readID(uint16_t reg);
|
||||
static uint32_t readID(const uint16_t inReg);
|
||||
static void transmit(uint16_t data);
|
||||
static void transmit(uint32_t memoryIncrease, uint16_t *data, uint16_t count);
|
||||
static void transmitDMA(uint32_t memoryIncrease, uint16_t *data, uint16_t count);
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
static void dataTransferAbort();
|
||||
|
||||
static void writeData(uint16_t data) { transmit(data); }
|
||||
static void writeReg(uint16_t reg) { WRITE(TFT_DC_PIN, LOW); transmit(reg); WRITE(TFT_DC_PIN, HIGH); }
|
||||
static void writeReg(const uint16_t inReg) { WRITE(TFT_DC_PIN, LOW); transmit(inReg); WRITE(TFT_DC_PIN, HIGH); }
|
||||
|
||||
static void writeSequence_DMA(uint16_t *data, uint16_t count) { transmitDMA(DMA_MINC_ENABLE, data, count); }
|
||||
static void writeMultiple_DMA(uint16_t color, uint16_t count) { static uint16_t data; data = color; transmitDMA(DMA_MINC_DISABLE, &data, count); }
|
||||
|
@@ -136,8 +136,8 @@ TFT_IO tftio;
|
||||
#define TFT_BTOKMENU_COLOR COLOR_RED
|
||||
#endif
|
||||
|
||||
static void setWindow(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
|
||||
tftio.set_window(Xmin, Ymin, Xmax, Ymax);
|
||||
static void setWindow(u8g_t *u8g, u8g_dev_t *dev, uint16_t xMin, uint16_t yMin, uint16_t xMax, uint16_t yMax) {
|
||||
tftio.set_window(xMin, yMin, xMax, yMax);
|
||||
}
|
||||
|
||||
#if HAS_TOUCH_BUTTONS
|
||||
|
@@ -72,7 +72,7 @@ class TFT {
|
||||
static void abort() { io.abort(); }
|
||||
static void write_multiple(uint16_t data, uint16_t count) { io.WriteMultipleDMA(data, count); }
|
||||
static void write_sequence(uint16_t *data, uint16_t count) { io.writeSequenceDMA(data, count); }
|
||||
static void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { io.set_window(Xmin, Ymin, Xmax, Ymax); }
|
||||
static void set_window(uint16_t xMin, uint16_t yMin, uint16_t xMax, uint16_t yMax) { io.set_window(xMin, yMin, xMax, yMax); }
|
||||
|
||||
static void fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.fill(x, y, width, height, color); }
|
||||
static void canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height) { queue.canvas(x, y, width, height); }
|
||||
|
@@ -64,7 +64,7 @@ public:
|
||||
inline static void dataTransferEnd() { io.dataTransferEnd(); }
|
||||
|
||||
inline static void writeData(uint16_t data) { io.writeData(data); }
|
||||
inline static void writeReg(uint16_t reg) { io.writeReg(reg); }
|
||||
inline static void writeReg(const uint16_t inReg) { io.writeReg(inReg); }
|
||||
|
||||
// Blocking IO used by TFT_CLASSIC_UI and TFT_LVGL_UI
|
||||
// These functions start data transfer and WAIT for data transfer completion
|
||||
|
Reference in New Issue
Block a user