diff --git a/TFT_Drivers/ILI9163_Defines.h b/TFT_Drivers/ILI9163_Defines.h index 4abaa1d..8c2e5c6 100644 --- a/TFT_Drivers/ILI9163_Defines.h +++ b/TFT_Drivers/ILI9163_Defines.h @@ -60,3 +60,7 @@ #define TFT_INVOFF 0x20 #define TFT_INVON 0x21 + +#define TFT_NORON 0x13 //normal mode +#define TFT_PTLON 0x12 //partial mode +#define TFT_PTLAR 0x30 //partial area diff --git a/TFT_eSPI.cpp b/TFT_eSPI.cpp index 184dbfe..92f7678 100644 --- a/TFT_eSPI.cpp +++ b/TFT_eSPI.cpp @@ -3223,7 +3223,6 @@ uint8_t TFT_eSPI::color332(uint16_t c) return ((c & 0xE000)>>8) | ((c & 0x0700)>>6) | ((c & 0x0018)>>3); } - /*************************************************************************************** ** Function name: invertDisplay ** Description: invert the display colours i = 1 invert, i = 0 normal @@ -3237,6 +3236,42 @@ void TFT_eSPI::invertDisplay(boolean i) spi_end(); } +/*************************************************************************************** +** Function name: setPartialMode +** Description: enables/disables "partial" mode, where only part of display is active +***************************************************************************************/ +void TFT_eSPI::setPartialMode(bool mode) +{ +#ifdef ILI9163_DRIVER + spi_begin(); + writecommand(mode ? TFT_PTLON : TFT_NORON); + spi_end(); +#endif +} + +/*************************************************************************************** +** Function name: setPartialWindow +** Description: sets active area for partial mode. Requires partial mode to be enabled. +** If endLine < startLine partial area will wrap at display edge +***************************************************************************************/ +void TFT_eSPI::setPartialArea(int16_t startLine, int16_t endLine) +{ +#ifdef ILI9163_DRIVER + if (rotation == 0 || rotation == 1) + { + startLine = _height_orig - startLine; + endLine = _height_orig - endLine; + } + + spi_begin(); + writecommand(TFT_PTLAR); + CS_L; + SPI.transfer16(startLine); + SPI.transfer16(endLine); + CS_H; + spi_end(); +#endif +} /*************************************************************************************** ** Function name: write diff --git a/TFT_eSPI.h b/TFT_eSPI.h index 2c54570..38b3382 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -355,6 +355,9 @@ class TFT_eSPI : public Print { setRotation(uint8_t r), invertDisplay(boolean i), + + setPartialMode(bool mode), + setPartialArea(int16_t startLine, int16_t endLine), drawCircle(int32_t x0, int32_t y0, int32_t r, uint32_t color), drawCircleHelper(int32_t x0, int32_t y0, int32_t r, uint8_t cornername, uint32_t color),