Add invert_display runtime option

This commit is contained in:
fvanroie 2021-01-13 00:10:22 +01:00
parent 724317c6ca
commit 755b3ea825
2 changed files with 62 additions and 62 deletions

View File

@ -11,57 +11,57 @@
#if USE_FSMC_ILI9341 > 0 #if USE_FSMC_ILI9341 > 0
#include "fsmc_ili9341.h" #include "fsmc_ili9341.h"
#include <stdbool.h> #include <stdbool.h>
#include <Arduino.h> #include <Arduino.h>
#include <SPI.h> #include <SPI.h>
//#include <XPT2046_Touchscreen.h> //#include <XPT2046_Touchscreen.h>
#include <Wire.h> #include <Wire.h>
#include "GxTFT_GFX.h" // Hardware-specific library #include "GxTFT_GFX.h" // Hardware-specific library
#include "GxTFT.h" // Hardware-specific library #include "GxTFT.h" // Hardware-specific library
#define TFT_Class GxTFT #define TFT_Class GxTFT
#include "GxIO/GxIO.h" #include "GxIO/GxIO.h"
// select one GxIO class, // select one GxIO class,
// note: "error: 'GxIO_Class' does not name a type": indicates target board selection mismatch // note: "error: 'GxIO_Class' does not name a type": indicates target board selection mismatch
// this version is for use with Arduino package STM32GENERIC, board "BLACK F407VE/ZE/ZG boards". // this version is for use with Arduino package STM32GENERIC, board "BLACK F407VE/ZE/ZG boards".
// Specific Board "BLACK F407ZG (M4 DEMO)" // Specific Board "BLACK F407ZG (M4 DEMO)"
// I use it with ST-LINK-V2, Upload method "STLink[Automatic serial = SerialUSB]", USB disabled. // I use it with ST-LINK-V2, Upload method "STLink[Automatic serial = SerialUSB]", USB disabled.
// For Serial I use a Serial to USB converter on PA9, PA10, "SerialUART1". // For Serial I use a Serial to USB converter on PA9, PA10, "SerialUART1".
// https://github.com/danieleff/STM32GENERIC // https://github.com/danieleff/STM32GENERIC
#if defined(STM32F407ZG) #if defined(STM32F407ZG)
#include "GxIO/STM32GENERIC/GxIO_STM32F407ZGx_FSMC/GxIO_STM32F407ZGx_FSMC.h" #include "GxIO/STM32GENERIC/GxIO_STM32F407ZGx_FSMC/GxIO_STM32F407ZGx_FSMC.h"
#else #else
#include "GxIO/STM32DUINO/GxIO_STM32F4_FSMC/GxIO_STM32F4_FSMC.h" #include "GxIO/STM32DUINO/GxIO_STM32F4_FSMC/GxIO_STM32F4_FSMC.h"
//#include "myTFTs/my_3.2_TFT_320x240_ILI9341_STM32F407ZGM4_FSMC.h" //#include "myTFTs/my_3.2_TFT_320x240_ILI9341_STM32F407ZGM4_FSMC.h"
#endif #endif
// #include "../GxIO/STM32GENERIC/GxIO_STM32F407ZGM4_FSMC/GxIO_STM32F407ZGM4_FSMC.h" // #include "../GxIO/STM32GENERIC/GxIO_STM32F407ZGM4_FSMC/GxIO_STM32F407ZGM4_FSMC.h"
//#include "../GxIO/STM32DUINO/GxIO_STM32F4_FSMC/GxIO_STM32F4_FSMC.h" //#include "../GxIO/STM32DUINO/GxIO_STM32F4_FSMC/GxIO_STM32F4_FSMC.h"
#include "GxCTRL/GxCTRL_ILI9341/GxCTRL_ILI9341.h" // 240x320 #include "GxCTRL/GxCTRL_ILI9341/GxCTRL_ILI9341.h" // 240x320
GxIO_Class io; // #define GxIO_Class is in the selected header file GxIO_Class io; // #define GxIO_Class is in the selected header file
GxCTRL_Class controller(io); // #define GxCTRL_Class is in the selected header file GxCTRL_Class controller(io); // #define GxCTRL_Class is in the selected header file
TFT_Class tft(io, controller, TFT_WIDTH, TFT_HEIGHT); TFT_Class tft(io, controller, TFT_WIDTH, TFT_HEIGHT);
#include LV_DRV_DISP_INCLUDE #include LV_DRV_DISP_INCLUDE
#include LV_DRV_DELAY_INCLUDE #include LV_DRV_DELAY_INCLUDE
// For 3.2" TFT of bundle 1 of: // For 3.2" TFT of bundle 1 of:
// https://www.aliexpress.com/item/STM32F407ZGT6-Development-Board-ARM-M4-STM32F4-cortex-M4-core-Board-Compatibility-Multiple-Extension/32795142050.html // https://www.aliexpress.com/item/STM32F407ZGT6-Development-Board-ARM-M4-STM32F4-cortex-M4-core-Board-Compatibility-Multiple-Extension/32795142050.html
// select one GxCTRL class // select one GxCTRL class
#include <GxCTRL/GxCTRL_ILI9341/GxCTRL_ILI9341.h> // 240x320 #include <GxCTRL/GxCTRL_ILI9341/GxCTRL_ILI9341.h> // 240x320
#include "GxReadRegisters.h" #include "GxReadRegisters.h"
#include "bootscreen.h" // Sketch tab header for xbm images #include "bootscreen.h" // Sketch tab header for xbm images
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
#if !defined(ESP8266) #if !defined(ESP8266)
#define yield() #define yield()
#endif #endif
/********************** /**********************
* TYPEDEFS * TYPEDEFS
@ -86,11 +86,11 @@ TFT_Class tft(io, controller, TFT_WIDTH, TFT_HEIGHT);
/** /**
* Initialize the ILI9341 display controller * Initialize the ILI9341 display controller
*/ */
void fsmc_ili9341_init(uint8_t rotation) void fsmc_ili9341_init(uint8_t rotation, bool invert_display)
{ {
tft.init(); tft.init();
tft.setRotation(rotation); tft.setRotation(rotation);
tft.setRotation(rotation); tft.invertDisplay(invert_display);
tft.fillScreen(TFT_DARKCYAN); tft.fillScreen(TFT_DARKCYAN);
int x = (tft.width() - logoWidth) / 2; int x = (tft.width() - logoWidth) / 2;
int y = (tft.height() - logoHeight) / 2; int y = (tft.height() - logoHeight) / 2;

View File

@ -14,20 +14,20 @@ extern "C" {
* INCLUDES * INCLUDES
*********************/ *********************/
#ifndef LV_DRV_NO_CONF #ifndef LV_DRV_NO_CONF
#ifdef LV_CONF_INCLUDE_SIMPLE #ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_drv_conf.h" #include "lv_drv_conf.h"
#else #else
#include "../../lv_drv_conf.h" #include "../../lv_drv_conf.h"
#endif #endif
#endif #endif
#if USE_FSMC_ILI9341>0 #if USE_FSMC_ILI9341 > 0
#ifdef LV_LVGL_H_INCLUDE_SIMPLE #ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h" #include "lvgl.h"
#else #else
#include "lvgl/lvgl.h" #include "lvgl/lvgl.h"
#endif #endif
/********************* /*********************
* DEFINES * DEFINES
@ -40,14 +40,14 @@ extern "C" {
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES
**********************/ **********************/
void fsmc_ili9341_init(uint8_t rotation); void fsmc_ili9341_init(uint8_t rotation, bool invert_display);
void fsmc_ili9341_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p); void fsmc_ili9341_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p);
//void fsmc_ili9341_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t * color_p); // void fsmc_ili9341_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t * color_p);
//void fsmc_ili9341_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color); // void fsmc_ili9341_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);
//void fsmc_ili9341_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t * color_p); // void fsmc_ili9341_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t * color_p);
/********************** /**********************
* MACROS * MACROS
**********************/ **********************/
#endif /* USE_FSMC_ILI9341 */ #endif /* USE_FSMC_ILI9341 */