add TFT_CASET_CMD / TFT_PASET_CMD macros

This commit is contained in:
Mike 2020-07-09 19:01:24 +02:00
parent 603b0f5b59
commit d891a0b04e
3 changed files with 41 additions and 30 deletions

View File

@ -19,8 +19,8 @@
#define TFT_DISPOFF 0x28 #define TFT_DISPOFF 0x28
#define TFT_DISPON 0x29 #define TFT_DISPON 0x29
#define TFT_CASET 0x2A #define TFT_CASET 0x2A00
#define TFT_PASET 0x2B #define TFT_PASET 0x2B00
#define TFT_RAMWR 0x2C #define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E #define TFT_RAMRD 0x2E

View File

@ -5,16 +5,26 @@
#define Byte8H(ByteH) ((uint8_t)(((uint16_t)(ByteH)&0xFF00)>>8)) #define Byte8H(ByteH) ((uint8_t)(((uint16_t)(ByteH)&0xFF00)>>8))
#define Byte8L(ByteL) ((uint8_t)( (uint16_t)(ByteL)&0x00FF)) #define Byte8L(ByteL) ((uint8_t)( (uint16_t)(ByteL)&0x00FF))
#ifndef TFT_CASET_CMD #define TFT_CASET_CMD(x0, x1) \
#define TFT_CASET_CMD(x0, x1) \ DC_C; tft_Write_16(TFT_CASET); \
DC_C; tft_Write_8(TFT_CASET); \ DC_D; tft_Write_16(Byte8H(x0)); \
DC_D; tft_Write_32C(x0, x1) DC_C; tft_Write_16(TFT_CASET + 1); \
DC_D; tft_Write_16(Byte8L(x0)); \
DC_C; tft_Write_16(TFT_CASET + 2); \
DC_D; tft_Write_16(Byte8H(x1)); \
DC_C; tft_Write_16(TFT_CASET + 3); \
DC_D; tft_Write_16(Byte8L(x1))
#endif #endif
#ifndef TFT_PASET_CMD #define TFT_PASET_CMD(y0, y1) \
#define TFT_PASET_CMD(y0, y1) \ DC_C; tft_Write_16(TFT_PASET); \
DC_C; tft_Write_8(TFT_PASET); \ DC_D; tft_Write_16(Byte8H(y0)); \
DC_D; tft_Write_32C(y0, y1) DC_C; tft_Write_16(TFT_PASET + 1); \
DC_D; tft_Write_16(Byte8L(y0)); \
DC_C; tft_Write_16(TFT_PASET + 2); \
DC_D; tft_Write_16(Byte8H(y1)); \
DC_C; tft_Write_16(TFT_PASET + 3); \
DC_D; tft_Write_16(Byte8L(y1))
#endif #endif
#define writecommand16(cmd) \ #define writecommand16(cmd) \

View File

@ -497,6 +497,17 @@ void TFT_eSPI::setRotation(uint8_t m)
addr_col = 0xFFFF; addr_col = 0xFFFF;
} }
#ifndef TFT_CASET_CMD
#define TFT_CASET_CMD(x0, x1) \
DC_C; tft_Write_8(TFT_CASET); \
DC_D; tft_Write_32C(x0, x1)
#endif
#ifndef TFT_PASET_CMD
#define TFT_PASET_CMD(y0, y1) \
DC_C; tft_Write_8(TFT_PASET); \
DC_D; tft_Write_32C(y0, y1)
#endif
/*************************************************************************************** /***************************************************************************************
** Function name: commandList, used for FLASH based lists only (e.g. ST7735) ** Function name: commandList, used for FLASH based lists only (e.g. ST7735)
@ -2635,22 +2646,18 @@ void TFT_eSPI::setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
#ifdef MULTI_TFT_SUPPORT #ifdef MULTI_TFT_SUPPORT
// No optimisation to permit multiple screens // No optimisation to permit multiple screens
DC_C; tft_Write_8(TFT_CASET); TFT_CASET_CMD(x0, x1);
DC_D; tft_Write_32C(x0, x1); TFT_PASET_CMD(y0, y1);
DC_C; tft_Write_8(TFT_PASET);
DC_D; tft_Write_32C(y0, y1);
#else #else
// No need to send x if it has not changed (speeds things up) // No need to send x if it has not changed (speeds things up)
if (addr_col != (x0<<16 | x1)) { if (addr_col != (x0<<16 | x1)) {
DC_C; tft_Write_8(TFT_CASET); TFT_CASET_CMD(x0, x1);
DC_D; tft_Write_32C(x0, x1);
addr_col = (x0<<16 | x1); addr_col = (x0<<16 | x1);
} }
// No need to send y if it has not changed (speeds things up) // No need to send y if it has not changed (speeds things up)
if (addr_row != (y0<<16 | y1)) { if (addr_row != (y0<<16 | y1)) {
DC_C; tft_Write_8(TFT_PASET); TFT_PASET_CMD(y0, y1);
DC_D; tft_Write_32C(y0, y1);
addr_row = (y0<<16 | y1); addr_row = (y0<<16 | y1);
} }
#endif #endif
@ -2684,12 +2691,10 @@ void TFT_eSPI::readAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h)
#endif #endif
// Column addr set // Column addr set
DC_C; tft_Write_8(TFT_CASET); TFT_CASET_CMD(xs, xe);
DC_D; tft_Write_32C(xs, xe);
// Row addr set // Row addr set
DC_C; tft_Write_8(TFT_PASET); TFT_PASET_CMD(ys, ye);
DC_D; tft_Write_32C(ys, ye);
// Read CGRAM command // Read CGRAM command
DC_C; tft_Write_8(TFT_RAMRD); DC_C; tft_Write_8(TFT_RAMRD);
@ -2718,22 +2723,18 @@ void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color)
#ifdef MULTI_TFT_SUPPORT #ifdef MULTI_TFT_SUPPORT
// No optimisation // No optimisation
DC_C; tft_Write_8(TFT_CASET); TFT_CASET_CMD(x, x);
DC_D; tft_Write_32D(x); TFT_PASET_CMD(y, y);
DC_C; tft_Write_8(TFT_PASET);
DC_D; tft_Write_32D(y);
#else #else
// No need to send x if it has not changed (speeds things up) // No need to send x if it has not changed (speeds things up)
if (addr_col != (x<<16 | x)) { if (addr_col != (x<<16 | x)) {
DC_C; tft_Write_8(TFT_CASET); TFT_CASET_CMD(x, x);
DC_D; tft_Write_32D(x);
addr_col = (x<<16 | x); addr_col = (x<<16 | x);
} }
// No need to send y if it has not changed (speeds things up) // No need to send y if it has not changed (speeds things up)
if (addr_row != (y<<16 | y)) { if (addr_row != (y<<16 | y)) {
DC_C; tft_Write_8(TFT_PASET); TFT_PASET_CMD(y, y);
DC_D; tft_Write_32D(y);
addr_row = (y<<16 | y); addr_row = (y<<16 | y);
} }
#endif #endif