PartialMode support for ILI9163

Support of partial mode, where only part of screen is active.  Can be use to reduce power consumption.
Based on ILI9163 datasheet:
https://www.rockbox.org/wiki/pub/Main/SonyNWZE370/ILI9163.pdf
This commit is contained in:
vanklompf 2018-02-01 23:14:16 +01:00
parent f3190fde71
commit 174fccf2bd
3 changed files with 43 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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),