fix ILI9225 set window
This commit is contained in:
parent
f3d3049115
commit
bb51cdab3e
|
|
@ -48,19 +48,3 @@
|
|||
|
||||
// Delay between some initialisation commands
|
||||
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
|
||||
|
||||
// autoincrement modes (register ILI9225_ENTRY_MODE, bit 5..3 )
|
||||
enum autoIncMode_t { R2L_BottomUp, BottomUp_R2L, L2R_BottomUp, BottomUp_L2R, R2L_TopDown, TopDown_R2L, L2R_TopDown, TopDown_L2R };
|
||||
|
||||
// correspondig modes if orientation changed:
|
||||
const autoIncMode_t modeTab [3][8] = {
|
||||
// { R2L_BottomUp, BottomUp_R2L, L2R_BottomUp, BottomUp_L2R, R2L_TopDown, TopDown_R2L, L2R_TopDown, TopDown_L2R }//
|
||||
/* 90° */ { BottomUp_L2R, L2R_BottomUp, TopDown_L2R, L2R_TopDown, BottomUp_R2L, R2L_BottomUp, TopDown_R2L, R2L_TopDown },
|
||||
/*180° */ { L2R_TopDown , TopDown_L2R, R2L_TopDown, TopDown_R2L, L2R_BottomUp, BottomUp_L2R, R2L_BottomUp, BottomUp_R2L},
|
||||
/*270° */ { TopDown_R2L , R2L_TopDown, BottomUp_R2L, R2L_BottomUp, TopDown_L2R, L2R_TopDown, BottomUp_L2R, L2R_BottomUp}
|
||||
};
|
||||
|
||||
#define TFT_CASET 0x20
|
||||
#define TFT_PASET 0x21
|
||||
#define TFT_RAMWR 0x22
|
||||
#define TFT_RAMRD 0x23
|
||||
|
|
|
|||
129
TFT_eSPI.cpp
129
TFT_eSPI.cpp
|
|
@ -2690,6 +2690,43 @@ inline void TFT_eSPI::setAddrWindow(int32_t x0, int32_t y0, int32_t x1, int32_t
|
|||
y1+=rowstart;
|
||||
#endif
|
||||
|
||||
#ifdef ILI9225_DRIVER
|
||||
// Column addr set
|
||||
DC_C;
|
||||
CS_L;
|
||||
|
||||
tft_Write_8(ILI9225_HORIZONTAL_WINDOW_ADDR1);
|
||||
DC_D;
|
||||
tft_Write_16(x1);
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_HORIZONTAL_WINDOW_ADDR2);
|
||||
DC_D;
|
||||
tft_Write_16(x0);
|
||||
|
||||
// Row addr set
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_VERTICAL_WINDOW_ADDR1);
|
||||
DC_D;
|
||||
tft_Write_16(y1);
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_VERTICAL_WINDOW_ADDR2);
|
||||
DC_D;
|
||||
tft_Write_16(y0);
|
||||
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_RAM_ADDR_SET1);
|
||||
DC_D;
|
||||
tft_Write_16(x1);
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_RAM_ADDR_SET2);
|
||||
DC_D;
|
||||
tft_Write_16(y1);
|
||||
|
||||
// write to RAM
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_GRAM_DATA_REG);
|
||||
DC_D;
|
||||
#else
|
||||
#if !defined (RPI_ILI9486_DRIVER)
|
||||
uint32_t xaw = ((uint32_t)x0 << 16) | x1;
|
||||
uint32_t yaw = ((uint32_t)y0 << 16) | y1;
|
||||
|
|
@ -2731,6 +2768,7 @@ inline void TFT_eSPI::setAddrWindow(int32_t x0, int32_t y0, int32_t x1, int32_t
|
|||
DC_D;
|
||||
|
||||
//spi_end();
|
||||
#endif // end ILI9225_DRIVER check
|
||||
}
|
||||
#endif // end RPI_ILI9486_DRIVER check
|
||||
#endif // end ESP32 check
|
||||
|
|
@ -2822,6 +2860,43 @@ void TFT_eSPI::readAddrWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
|
|||
y1+=rowstart;
|
||||
#endif
|
||||
|
||||
#ifdef ILI9225_DRIVER
|
||||
// Column addr set
|
||||
DC_C;
|
||||
CS_L;
|
||||
|
||||
tft_Write_8(ILI9225_HORIZONTAL_WINDOW_ADDR1);
|
||||
DC_D;
|
||||
tft_Write_16(x1);
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_HORIZONTAL_WINDOW_ADDR2);
|
||||
DC_D;
|
||||
tft_Write_16(x0);
|
||||
|
||||
// Row addr set
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_VERTICAL_WINDOW_ADDR1);
|
||||
DC_D;
|
||||
tft_Write_16(y1);
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_VERTICAL_WINDOW_ADDR2);
|
||||
DC_D;
|
||||
tft_Write_16(y0);
|
||||
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_RAM_ADDR_SET1);
|
||||
DC_D;
|
||||
tft_Write_16(x1);
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_RAM_ADDR_SET1);
|
||||
DC_D;
|
||||
tft_Write_16(y1);
|
||||
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_GRAM_DATA_REG); // Read CGRAM command
|
||||
|
||||
DC_D;
|
||||
#else
|
||||
uint32_t xaw = ((uint32_t)x0 << 16) | x1;
|
||||
uint32_t yaw = ((uint32_t)y0 << 16) | y1;
|
||||
|
||||
|
|
@ -2831,7 +2906,6 @@ void TFT_eSPI::readAddrWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
|
|||
|
||||
tft_Write_8(TFT_CASET);
|
||||
|
||||
|
||||
DC_D;
|
||||
|
||||
tft_Write_32(xaw);
|
||||
|
|
@ -2849,7 +2923,7 @@ void TFT_eSPI::readAddrWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
|
|||
tft_Write_8(TFT_RAMRD); // Read CGRAM command
|
||||
|
||||
DC_D;
|
||||
|
||||
#endif
|
||||
//spi_end();
|
||||
}
|
||||
|
||||
|
|
@ -3045,7 +3119,7 @@ void TFT_eSPI::drawPixel(uint32_t x, uint32_t y, uint32_t color)
|
|||
|
||||
#else // ESP32
|
||||
|
||||
void TFT_eSPI::drawPixel(uint32_t x, uint32_t y, uint32_t color)
|
||||
void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color)
|
||||
{
|
||||
// Faster range checking, possible because x and y are unsigned
|
||||
if ((x >= _width) || (y >= _height)) return;
|
||||
|
|
@ -3056,6 +3130,54 @@ void TFT_eSPI::drawPixel(uint32_t x, uint32_t y, uint32_t color)
|
|||
y+=rowstart;
|
||||
#endif
|
||||
|
||||
#ifdef ILI9225_DRIVER
|
||||
// Column addr set
|
||||
CS_L;
|
||||
|
||||
// No need to send x if it has not changed (speeds things up)
|
||||
if (addr_col != x) {
|
||||
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_HORIZONTAL_WINDOW_ADDR1);
|
||||
DC_D;
|
||||
tft_Write_16(x);
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_HORIZONTAL_WINDOW_ADDR2);
|
||||
DC_D;
|
||||
tft_Write_16(x);
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_RAM_ADDR_SET1);
|
||||
DC_D;
|
||||
tft_Write_16(x);
|
||||
|
||||
addr_col = x;
|
||||
}
|
||||
|
||||
// No need to send y if it has not changed (speeds things up)
|
||||
if (addr_row != y) {
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_VERTICAL_WINDOW_ADDR1);
|
||||
DC_D;
|
||||
tft_Write_16(y);
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_VERTICAL_WINDOW_ADDR2);
|
||||
DC_D;
|
||||
tft_Write_16(y);
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_RAM_ADDR_SET2);
|
||||
DC_D;
|
||||
tft_Write_16(y);
|
||||
|
||||
addr_row = y;
|
||||
}
|
||||
|
||||
DC_C;
|
||||
tft_Write_8(ILI9225_GRAM_DATA_REG);
|
||||
DC_D;
|
||||
tft_Write_16(color);
|
||||
|
||||
CS_H;
|
||||
#else
|
||||
#if !defined (RPI_ILI9486_DRIVER)
|
||||
uint32_t xaw = ((uint32_t)x << 16) | x;
|
||||
uint32_t yaw = ((uint32_t)y << 16) | y;
|
||||
|
|
@ -3111,6 +3233,7 @@ void TFT_eSPI::drawPixel(uint32_t x, uint32_t y, uint32_t color)
|
|||
|
||||
CS_H;
|
||||
|
||||
#endif
|
||||
spi_end();
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -529,7 +529,7 @@ class TFT_eSPI : public Print {
|
|||
void init(uint8_t tc = TAB_COLOUR), begin(uint8_t tc = TAB_COLOUR); // Same - begin included for backwards compatibility
|
||||
|
||||
// These are virtual so the TFT_eSprite class can override them with sprite specific functions
|
||||
virtual void drawPixel(uint32_t x, uint32_t y, uint32_t color),
|
||||
virtual void drawPixel(int32_t x, int32_t y, uint32_t color),
|
||||
drawChar(int32_t x, int32_t y, unsigned char c, uint32_t color, uint32_t bg, uint8_t size),
|
||||
drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t color),
|
||||
drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color),
|
||||
|
|
|
|||
Loading…
Reference in New Issue