Add invert_display runtime option

This commit is contained in:
fvanroie 2021-01-13 00:11:30 +01:00
parent 755b3ea825
commit ea8ac442ab
2 changed files with 59 additions and 54 deletions

View File

@ -32,6 +32,7 @@
* STATIC PROTOTYPES
**********************/
static void tftShowConfig(TFT_eSPI & tft);
static void tftShowLogo(TFT_eSPI & tft);
/**********************
* STATIC VARIABLES
@ -50,30 +51,27 @@ static TFT_eSPI tft;
* Initialize the R61581 display controller
* @return HW_RES_OK or any error from hw_res_t enum
*/
void tft_espi_init(uint8_t rotation)
void tft_espi_init(uint8_t rotation, bool invert_display)
{
/* TFT init */
tft.begin();
tft.setSwapBytes(true); /* set endianess */
tft.setRotation(rotation);
tft.fillScreen(TFT_DARKCYAN);
int x = (tft.width() - logoWidth) / 2;
int y = (tft.height() - logoHeight) / 2;
tft.drawXBitmap(x, y, bootscreen, logoWidth, logoHeight, TFT_WHITE);
#ifdef USE_DMA_TO_TFT
// DMA - should work with STM32F2xx/F4xx/F7xx processors
// NOTE: >>>>>> DMA IS FOR SPI DISPLAYS ONLY <<<<<<
tft.initDMA(); // Initialise the DMA engine (tested with STM32F446 and STM32F767)
#endif
/* TFT init */
tft.begin();
tft.setSwapBytes(true); /* set endianess */
tft.setRotation(rotation);
tft.invertDisplay(invert_display);
tftShowLogo(tft);
tftShowConfig(tft);
}
void tft_espi_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p)
{
size_t len = lv_area_get_size(area);
// size_t len = (x2 - x1 + 1) * (y2 - y1 + 1); /* Number of pixels */
/* Update TFT */
tft.startWrite(); /* Start new TFT transaction */
@ -243,4 +241,11 @@ static void tftShowConfig(TFT_eSPI & tft)
}
}
static void tftShowLogo(TFT_eSPI & tft)
{
tft.fillScreen(TFT_DARKCYAN);
int x = (tft.width() - logoWidth) / 2;
int y = (tft.height() - logoHeight) / 2;
tft.drawXBitmap(x, y, bootscreen, logoWidth, logoHeight, TFT_WHITE);
}
#endif

View File

@ -40,7 +40,7 @@ extern "C" {
/**********************
* GLOBAL PROTOTYPES
**********************/
void tft_espi_init(uint8_t rotation);
void tft_espi_init(uint8_t rotation, bool invert_display=false);
void tft_espi_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p);
// void tft_espi_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p);
void tft_espi_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);