diff --git a/README.md b/README.md index 8e7e6cc..a93fb22 100644 --- a/README.md +++ b/README.md @@ -30,27 +30,27 @@ They can be bought in the [Sunton Store](https://www.aliexpress.com/store/110019 ## Supported boards -| Type | CPU | Display | Size | Controller | Rotate support | Touch | Audio | Flash | RGB LED | CDS | Link| -|--- |--- |--- |-- |--- |--- |--- |--- |--- |--- |--- |--- | -| ESP32_1732S019N | ESP32-S3 | 170x320 | 1.9" | [ST7796](assets/datasheets/ST7796.pdf) | yes | n/a | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005059421229.html) | -| ESP32_1732S019C | ESP32-S3 | 170x320 | 1.9" | [ST7796](assets/datasheets/ST7796.pdf) | yes | [GT911](assets/datasheets//GT911.pdf) | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005059421229.html) | -| ESP32-2424S012N | ESP32-C3 | 240x240 | 1.2" | [GC9A01A](assets/datasheets/GC9A01A.pdf) | yes | n/a | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005453515690.html) | -| ESP32-2424S012C | ESP32-C3 | 240x240 | 1.2" | [GC9A01A](assets/datasheets/GC9A01A.pdf) | yes | [CST816S](assets/datasheets/CST816S.pdf) | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005453515690.html) | -| ESP32-2432S024N | ESP32 | 240x320 | 2.4" | [ILI9341](assets/datasheets/ILI9341.pdf) | yes | n/a | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005005865107357.html) | -| ESP32-2432S024R | ESP32 | 240x320 | 2.4" | [ILI9341](assets/datasheets/ILI9341.pdf) | yes | [XPT2046](assets/datasheets/XPT2046.pdf) | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005005865107357.html) | -| ESP32-2432S024C | ESP32 | 240x320 | 2.4" | [ILI9341](assets/datasheets/ILI9341.pdf) | yes | [CST816S](assets/datasheets/CST816S.pdf) | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005005865107357.html) | -| ESP32-2432S028R | ESP32 | 240x320 | 2.8" | [ILI9341](assets/datasheets/ILI9341.pdf) | yes | [XPT2046](assets/datasheets/XPT2046.pdf) | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005004502250619.html) | -| ESP32-2432S032N | ESP32 | 240x320 | 3.2" | [ST7796](assets/datasheets/ST7796.pdf) | yes | n/a | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005006224494145.html) | -| ESP32-2432S032R | ESP32 | 240x320 | 3.2" | [ST7796](assets/datasheets/ST7796.pdf) | yes | [XPT2046](assets/datasheets/XPT2046.pdf) | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005006224494145.html) | -| ESP32-2432S032C | ESP32 | 240x320 | 3.2" | [ST7796](assets/datasheets/ST7796.pdf) | yes | [GT911](assets/datasheets//GT911.pdf) | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005006224494145.html) | -| ESP32-3248S035R | ESP32 | 320x480 | 3.5" | [ST7796](assets/datasheets/ST7796.pdf) | yes | [XPT2046](assets/datasheets/XPT2046.pdf) | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005004632953455.html) | -| ESP32-3248S035C | ESP32 | 320x480 | 3.5" | [ST7796](assets/datasheets/ST7796.pdf) | yes | [GT911](assets/datasheets//GT911.pdf) | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005004632953455.html) | -| ESP32-4827S043R | ESP32-S3 | 480x272 | 4.3" | n/a | no | [XPT2046](assets/datasheets/XPT2046.pdf) | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005006110360174.html) | -| ESP32-4827S043C | ESP32-S3 | 480x272 | 4.3" | n/a | no | [GT911](assets/datasheets//GT911.pdf) | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005006110360174.html) | -| ESP32-8048S050N | ESP32-S3 | 800x480 | 5.0" | n/a | no | n/a | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005938915207.html) | -| ESP32-8048S050C | ESP32-S3 | 800x480 | 5.0" | n/a | no | [GT911](assets/datasheets//GT911.pdf) | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005938915207.html) | -| ESP32-8048S070N | ESP32-S3 | 800x480 | 7.0" | n/a | no | n/a | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005928865239.html) | -| ESP32-8048S070C | ESP32-S3 | 800x480 | 7.0" | n/a | no | [GT911](assets/datasheets//GT911.pdf) | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005928865239.html) | +| Type | CPU | Display | Size | Controller | PSRAM | Rotate support | Touch | Audio | Flash | RGB LED | CDS | Link| +|--- |--- |--- |-- |--- | n/a |--- |--- |--- |--- |--- |--- |--- | +| ESP32_1732S019N | ESP32-S3 | 170x320 | 1.9" | [ST7796](assets/datasheets/ST7796.pdf) | n/a | yes | n/a | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005059421229.html) | +| ESP32_1732S019C | ESP32-S3 | 170x320 | 1.9" | [ST7796](assets/datasheets/ST7796.pdf) | n/a | yes | [GT911](assets/datasheets//GT911.pdf) | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005059421229.html) | +| ESP32-2424S012N | ESP32-C3 | 240x240 | 1.2" | [GC9A01A](assets/datasheets/GC9A01A.pdf) | n/a | yes | n/a | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005453515690.html) | +| ESP32-2424S012C | ESP32-C3 | 240x240 | 1.2" | [GC9A01A](assets/datasheets/GC9A01A.pdf) | n/a | yes | [CST816S](assets/datasheets/CST816S.pdf) | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005453515690.html) | +| ESP32-2432S024N | ESP32 | 240x320 | 2.4" | [ILI9341](assets/datasheets/ILI9341.pdf) | n/a | yes | n/a | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005005865107357.html) | +| ESP32-2432S024R | ESP32 | 240x320 | 2.4" | [ILI9341](assets/datasheets/ILI9341.pdf) | n/a | yes | [XPT2046](assets/datasheets/XPT2046.pdf) | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005005865107357.html) | +| ESP32-2432S024C | ESP32 | 240x320 | 2.4" | [ILI9341](assets/datasheets/ILI9341.pdf) | n/a | yes | [CST816S](assets/datasheets/CST816S.pdf) | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005005865107357.html) | +| ESP32-2432S028R | ESP32 | 240x320 | 2.8" | [ILI9341](assets/datasheets/ILI9341.pdf) | n/a | yes | [XPT2046](assets/datasheets/XPT2046.pdf) | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005004502250619.html) | +| ESP32-2432S032N | ESP32 | 240x320 | 3.2" | [ST7796](assets/datasheets/ST7796.pdf) | n/a | yes | n/a | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005006224494145.html) | +| ESP32-2432S032R | ESP32 | 240x320 | 3.2" | [ST7796](assets/datasheets/ST7796.pdf) | n/a | yes | [XPT2046](assets/datasheets/XPT2046.pdf) | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005006224494145.html) | +| ESP32-2432S032C | ESP32 | 240x320 | 3.2" | [ST7796](assets/datasheets/ST7796.pdf) | n/a | yes | [GT911](assets/datasheets//GT911.pdf) | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005006224494145.html) | +| ESP32-3248S035R | ESP32 | 320x480 | 3.5" | [ST7796](assets/datasheets/ST7796.pdf) | n/a | yes | [XPT2046](assets/datasheets/XPT2046.pdf) | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005004632953455.html) | +| ESP32-3248S035C | ESP32 | 320x480 | 3.5" | [ST7796](assets/datasheets/ST7796.pdf) | n/a | yes | [GT911](assets/datasheets//GT911.pdf) | yes | [W25Q32JV](assets/datasheets/25Q32JVSSIQ.pdf) | yes | yes | [Ali Express](https://www.aliexpress.com/item/1005004632953455.html) | +| ESP32-4827S043R | ESP32-S3 | 480x272 | 4.3" | Direct 16 bits parallel gpio | n/a | no | [XPT2046](assets/datasheets/XPT2046.pdf) | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005006110360174.html) | +| ESP32-4827S043C | ESP32-S3 | 480x272 | 4.3" | Direct 16 bits parallel gpio | n/a | no | [GT911](assets/datasheets//GT911.pdf) | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005006110360174.html) | +| ESP32-8048S050N | ESP32-S3 | 800x480 | 5.0" | Direct 16 bits parallel gpio | 8Mb | no | n/a | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005938915207.html) | +| ESP32-8048S050C | ESP32-S3 | 800x480 | 5.0" | Direct 16 bits parallel gpio | 8Mb | no | [GT911](assets/datasheets//GT911.pdf) | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005938915207.html) | +| ESP32-8048S070N | ESP32-S3 | 800x480 | 7.0" | Direct 16 bits parallel gpio | 8Mb | no | n/a | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005928865239.html) | +| ESP32-8048S070C | ESP32-S3 | 800x480 | 7.0" | Direct 16 bits parallel gpio | 8Mb | no | [GT911](assets/datasheets//GT911.pdf) | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005928865239.html) | Note: the additional flash chip (W25Q32JV) is not always mounted on the board. @@ -149,6 +149,8 @@ build_flags = board = esp32-s3-devkitc-1 build_flags = ${env.build_flags} + -D BOARD_HAS_PSRAM + -mfix-esp32-psram-cache-issue # Smartdisplay selection #-D ESP32_1732S019N #-D ESP32_1732S019C @@ -179,6 +181,16 @@ To include it globally, the define must be (for the include directory): The template for the `lv_conf.h` file can be found in the LVGL library at `.pio/libdeps/esp32dev/lvgl/lv_conf_template.h`. +## PSRAM + +At boot the ESP32 has approx 315Kb free memory. For displays wit a controller, no internal buffer to save the state of the display is required. +However, if the display is using the direct 16bits parallel connection, there is no controller and the contents of the RAM is copied to the display at a fast rate. +This buffer is allocated from the memory of the ESP32. + +For the ESP32_4827S043 this snoops away 480x270x2 = 261120 bytes, leaving only 54140 bytes for the application! +For a resolution of 800x480, 800x480x2 = 768000 bytes are required. This is more than the available RAM. +That is the reason that for these higher resolutions PSRAM is available and used to store this buffer. + ## LV_COLOR_16_SWAP The LVGL library has a define called **LV_COLOR_16_SWAP**. The value can be 1 (yes) or 0 (no). @@ -203,12 +215,12 @@ The library exposes the following functions. ### void smartdisplay_init() This is the first function that needs to be called. -It initializes the display controller and touch controller and will turn on the display. +It initializes the display controller and touch controller and will turn on the display at 50% brightness. -### void smartdisplay_tft_set_backlight(uint16_t duty) +### void smartdisplay_tft_set_backlight(float duty) Set the brightness of the backlight display. -The resolution is 12 bit so valid values are from 0-1023. +The range is from [0, 1] so 0 is off, 0.5 is half and 1 is full brightness. ## Rotation diff --git a/include/esp32_smartdisplay.h b/include/esp32_smartdisplay.h index a1341d9..345e0e1 100644 --- a/include/esp32_smartdisplay.h +++ b/include/esp32_smartdisplay.h @@ -273,7 +273,12 @@ #define PIN_BCKL 2 // LCD ILI6485 480x272 #define USES_LCD_RGB -#define RBG_PANEL_CONFIG {.clk_src=LCD_CLK_SRC_PLL160M,.timings={.pclk_hz=9000000,.h_res=TFT_WIDTH,.v_res=TFT_HEIGHT,.hsync_pulse_width=4,.hsync_back_porch=43,.hsync_front_porch=8,.vsync_pulse_width=4,.vsync_back_porch=12,.vsync_front_porch=8,.flags={.hsync_idle_low=1,.vsync_idle_low=1,.pclk_active_neg=1}},.data_width=16,.sram_trans_align=8,.hsync_gpio_num=39,.vsync_gpio_num=41,.de_gpio_num=40,.pclk_gpio_num=42,.data_gpio_nums={15, 16, 4, 45, 48, 47, 21, 14, 8, 3, 46, 9, 1, 5, 6, 7},.disp_gpio_num=-1} +#if LV_COLOR_16_SWAP != 0 +#define RBG_PANEL_GPIO {15,16,4,45,48,47,21,14,8,3,46,9,1,5,6,7} +#else +#define RBG_PANEL_GPIO {8,3,46,9,1,5,6,7,15,16,4,45,48,47,21,14} +#endif +#define RBG_PANEL_CONFIG {.clk_src=LCD_CLK_SRC_PLL160M,.timings={.pclk_hz=32000000,.h_res=TFT_WIDTH,.v_res=TFT_HEIGHT,.hsync_pulse_width=4,.hsync_back_porch=43,.hsync_front_porch=8,.vsync_pulse_width=4,.vsync_back_porch=12,.vsync_front_porch=8,.flags={.hsync_idle_low=1,.vsync_idle_low=1,.pclk_active_neg=1}},.data_width=16,.sram_trans_align=8,.psram_trans_align=64,.hsync_gpio_num=39,.vsync_gpio_num=41,.de_gpio_num=40,.pclk_gpio_num=42,.data_gpio_nums=RBG_PANEL_GPIO,.disp_gpio_num=-1,.flags={.fb_in_psram=1}} // Touch #ifdef ESP32_4827S043R #define USES_XPT2046 @@ -301,7 +306,13 @@ #define PIN_BCKL 2 // LCD 800x480 #define USES_LCD_RGB -#define RBG_PANEL_CONFIG {.clk_src=LCD_CLK_SRC_PLL160M,.timings={.pclk_hz=16000000,.h_res=TFT_WIDTH,.v_res=TFT_HEIGHT,.hsync_pulse_width=4,.hsync_back_porch=8,.hsync_front_porch=8,.vsync_pulse_width=4,.vsync_back_porch=8,.vsync_front_porch=8,.flags={.hsync_idle_low=1,.vsync_idle_low=1,.pclk_active_neg=1}},.data_width=16,.sram_trans_align=8,.hsync_gpio_num=39,.vsync_gpio_num=41,.de_gpio_num=40,.pclk_gpio_num=42,.data_gpio_nums={15, 16, 4, 45, 48, 47, 21, 14, 8, 3, 46, 9, 1, 5, 6, 7},.disp_gpio_num=-1} +#if LV_COLOR_16_SWAP != 0 +#define RBG_PANEL_GPIO {15,16,4,45,48,47,21,14,8,3,46,9,1,5,6,7} +#else +#define RBG_PANEL_GPIO {8,3,46,9,1,5,6,7,15,16,4,45,48,47,21,14} +#endif +#define RBG_PANEL_CONFIG {.clk_src=LCD_CLK_SRC_PLL160M,.timings={.pclk_hz=32000000,.h_res=TFT_WIDTH,.v_res=TFT_HEIGHT,.hsync_pulse_width=4,.hsync_back_porch=8,.hsync_front_porch=8,.vsync_pulse_width=4,.vsync_back_porch=8,.vsync_front_porch=8,.flags={.hsync_idle_low=1,.vsync_idle_low=1,.pclk_active_neg=1}},.data_width=16,.sram_trans_align=8,.psram_trans_align=64,.hsync_gpio_num=39,.vsync_gpio_num=41,.de_gpio_num=40,.pclk_gpio_num=42,.data_gpio_nums=RBG_PANEL_GPIO,.disp_gpio_num=-1,.flags={.fb_in_psram=1}} + // Touch #ifdef ESP32_8048S043R #define USES_XPT2046 @@ -329,7 +340,12 @@ #define PIN_BCKL 2 // LCD 800x480 #define USES_LCD_RGB -#define RBG_PANEL_CONFIG {.clk_src=LCD_CLK_SRC_PLL160M,.timings={.pclk_hz=16000000,.h_res=TFT_WIDTH,.v_res=TFT_HEIGHT,.hsync_pulse_width=4,.hsync_back_porch=8,.hsync_front_porch=8,.vsync_pulse_width=4,.vsync_back_porch=8,.vsync_front_porch=8,.flags={.hsync_idle_low=1,.vsync_idle_low=1,.pclk_active_neg=1,}},.data_width=16,.sram_trans_align=8,.hsync_gpio_num=39,.vsync_gpio_num=41,.de_gpio_num=40,.pclk_gpio_num=42,.data_gpio_nums={15, 16, 4, 45, 48, 47, 21, 14, 8, 3, 46, 9, 1, 5, 6, 7},.disp_gpio_num=-1} +#if LV_COLOR_16_SWAP != 0 +#define RBG_PANEL_GPIO {15,16,4,45,48,47,21,14,8,3,46,9,1,5,6,7} +#else +#define RBG_PANEL_GPIO {8,3,46,9,1,5,6,7,15,16,4,45,48,47,21,14} +#endif +#define RBG_PANEL_CONFIG {.clk_src=LCD_CLK_SRC_PLL160M,.timings={.pclk_hz=32000000,.h_res=TFT_WIDTH,.v_res=TFT_HEIGHT,.hsync_pulse_width=4,.hsync_back_porch=8,.hsync_front_porch=8,.vsync_pulse_width=4,.vsync_back_porch=8,.vsync_front_porch=8,.flags={.hsync_idle_low=1,.vsync_idle_low=1,.pclk_active_neg=1,}},.data_width=16,.sram_trans_align=8,.psram_trans_align=64,.hsync_gpio_num=39,.vsync_gpio_num=41,.de_gpio_num=40,.pclk_gpio_num=42,.data_gpio_nums=RBG_PANEL_GPIO,.disp_gpio_num=-1,.flags={.fb_in_psram=1}} // Touch #ifdef ESP32_8048S050R #define USES_XPT2046 @@ -357,7 +373,12 @@ #define PIN_BCKL 2 // LCD 800x480 #define USES_LCD_RGB -#define RBG_PANEL_CONFIG {.clk_src=LCD_CLK_SRC_PLL160M,.timings={.pclk_hz=16000000,.h_res=TFT_WIDTH,.v_res=TFT_HEIGHT,.hsync_pulse_width=30,.hsync_back_porch=16,.hsync_front_porch=210,.vsync_pulse_width=13,.vsync_back_porch=10,.vsync_front_porch=22,.flags={.hsync_idle_low=1,.vsync_idle_low=1,.pclk_active_neg=1,}},.data_width=16,.sram_trans_align=8,.hsync_gpio_num=39,.vsync_gpio_num=40,.de_gpio_num=41,.pclk_gpio_num=42,.data_gpio_nums={8, 16, 1, 14, 21, 47, 48, 45, 15, 7, 6, 5, 4, 9, 46, 3},.disp_gpio_num=-1} +#if LV_COLOR_16_SWAP != 0 +#define RBG_PANEL_GPIO {15,7,6,5,4,9,46,3,8,16,1,14,21,47,48,45} +#else +#define RBG_PANEL_GPIO {8,16,1,14,21,47,48,45,15,7,6,5,4,9,46,3} +#endif +#define RBG_PANEL_CONFIG {.clk_src=LCD_CLK_SRC_PLL160M,.timings={.pclk_hz=32000000,.h_res=TFT_WIDTH,.v_res=TFT_HEIGHT,.hsync_pulse_width=30,.hsync_back_porch=16,.hsync_front_porch=210,.vsync_pulse_width=13,.vsync_back_porch=10,.vsync_front_porch=22,.flags={.hsync_idle_low=1,.vsync_idle_low=1,.pclk_active_neg=1,}},.data_width=16,.sram_trans_align=8,.psram_trans_align=64,.hsync_gpio_num=39,.vsync_gpio_num=40,.de_gpio_num=41,.pclk_gpio_num=42,.data_gpio_nums={8, 16, 1, 14, 21, 47, 48, 45, 15, 7, 6, 5, 4, 9, 46, 3},.disp_gpio_num=-1,.flags={.fb_in_psram=1}} // Touch #ifdef ESP32_8048S070R #define USES_XPT2046 @@ -377,19 +398,11 @@ #endif #endif -#if defined(USES_ILI9341) || defined(USES_ST7796) -// These use an SPI interface. Because display is LSB first the option LV_COLOR_16_SWAP must be set -#if LV_COLOR_16_SWAP == 0 -#error "LV_COLOR_16_SWAP should be set to 1 in lv_conf.h because of SPI interface" -#endif -#endif - #if defined(USES_CST816S) || defined(USES_XPT2046) || defined(USES_GT911) #define USES_TOUCH #endif // Exported functions - #ifdef __cplusplus extern "C" { @@ -397,7 +410,7 @@ extern "C" // Initialize the display and touch void smartdisplay_init(); // Set the brightness of the backlight display - void smartdisplay_tft_set_backlight(uint16_t duty); // 0-1023 (12 bits) + void smartdisplay_tft_set_backlight(float duty); // [0, 1] #ifdef __cplusplus } #endif diff --git a/src/esp32_smartdisplay.c b/src/esp32_smartdisplay.c index 9cf4206..ae1bfc2 100644 --- a/src/esp32_smartdisplay.c +++ b/src/esp32_smartdisplay.c @@ -120,15 +120,15 @@ void smartdisplay_init() // Create drawBuffer disp_drv.draw_buf = (lv_disp_draw_buf_t *)malloc(sizeof(lv_disp_draw_buf_t)); uint drawBufferPixels = TFT_WIDTH * LVGL_PIXEL_BUFFER_LINES; - void *drawBuffer = heap_caps_malloc(sizeof(lv_color_t) * drawBufferPixels, MALLOC_CAP_DMA); + void *drawBuffer = heap_caps_malloc(sizeof(lv_color16_t) * drawBufferPixels, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); lv_disp_draw_buf_init(disp_drv.draw_buf, drawBuffer, NULL, drawBufferPixels); // Initialize specific driver lvgl_tft_init(&disp_drv); lv_disp_t *display = lv_disp_drv_register(&disp_drv); // Clear screen lv_obj_clean(lv_scr_act()); - // Turn backlight on - ledcWrite(PWM_CHANNEL_BCKL, PWM_MAX_BCKL); + // Turn backlight on (50%) + smartdisplay_tft_set_backlight(0.5f); // If there is a touch controller defined #ifdef USES_TOUCH @@ -145,11 +145,11 @@ void smartdisplay_init() lvgl_update_callback(&disp_drv); } -void smartdisplay_tft_set_backlight(uint16_t duty) +void smartdisplay_tft_set_backlight(float duty) { #if ESP_ARDUINO_VERSION_MAJOR >= 3 - ledcWrite(PIN_BCKL, duty); + ledcWrite(PIN_BCKL, dut * PWM_MAX_BCKL); #else - ledcWrite(PWM_CHANNEL_BCKL, duty); + ledcWrite(PWM_CHANNEL_BCKL, duty * PWM_MAX_BCKL); #endif } \ No newline at end of file diff --git a/src/smartdisplay_gc9a01.c b/src/smartdisplay_gc9a01.c index 3109480..c405cfb 100644 --- a/src/smartdisplay_gc9a01.c +++ b/src/smartdisplay_gc9a01.c @@ -16,7 +16,7 @@ bool gc9a01_color_trans_done(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_i return false; } -void gc9a01_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map) +void gc9a01_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color16_t *color_map) { esp_lcd_panel_handle_t panel_handle = drv->user_data; #if LV_COLOR_16_SWAP != 1 diff --git a/src/smartdisplay_rgb.c b/src/smartdisplay_rgb.c index 271ea81..c91eba6 100644 --- a/src/smartdisplay_rgb.c +++ b/src/smartdisplay_rgb.c @@ -12,16 +12,10 @@ static bool direct_io_frame_trans_done(esp_lcd_panel_handle_t panel, esp_lcd_rgb return false; } -static void direct_io_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map) +static void direct_io_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color16_t *color_map) { esp_lcd_panel_handle_t panel_handle = drv->user_data; -#if LV_COLOR_16_SWAP != 1 -#warning "LV_COLOR_16_SWAP should be 1 for max performance" - ushort pixels = lv_area_get_size(area); - lv_color16_t *p = color_map; - while (pixels--) - p++->full = (uint16_t)((p->full >> 8) | (p->full << 8)); -#endif + // LV_COLOR_16_SWAP is handled by mapping of the data ESP_ERROR_CHECK(esp_lcd_panel_draw_bitmap(panel_handle, area->x1, area->y1, area->x2 + 1, area->y2 + 1, color_map)); }; diff --git a/src/smartdisplay_st7789.c b/src/smartdisplay_st7789.c index b7842dc..343c929 100644 --- a/src/smartdisplay_st7789.c +++ b/src/smartdisplay_st7789.c @@ -14,7 +14,7 @@ static bool st7789_color_trans_done(esp_lcd_panel_io_handle_t panel_io, esp_lcd_ return false; } -static void st7789_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map) +static void st7789_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color16_t *color_map) { esp_lcd_panel_handle_t panel_handle = drv->user_data; #if LV_COLOR_16_SWAP != 1 diff --git a/src/smartdisplay_st7796.c b/src/smartdisplay_st7796.c index c006e7b..cb030d0 100644 --- a/src/smartdisplay_st7796.c +++ b/src/smartdisplay_st7796.c @@ -16,7 +16,7 @@ static bool st7796_color_trans_done(esp_lcd_panel_io_handle_t panel_io, esp_lcd_ return false; } -static void st7796_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map) +static void st7796_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color16_t *color_map) { esp_lcd_panel_handle_t panel_handle = drv->user_data; #if LV_COLOR_16_SWAP != 1