Skip to content

Commit

Permalink
Swapped byte order for RGB panels
Browse files Browse the repository at this point in the history
  • Loading branch information
rzeldent committed Dec 9, 2023
1 parent 9b16a0f commit c2bc33e
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 38 deletions.
54 changes: 29 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | Color16 swap | Touch | Audio | Flash | RGB LED | CDS | Link|
|--- |--- |--- |-- |--- |--- |--- |--- |--- |--- |--- |--- |--- |
| ESP32_1732S019N | ESP32-S3 | 170x320 | 1.9" | [ST7796](assets/datasheets/ST7796.pdf) | yes | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | no | [GT911](assets/datasheets//GT911.pdf) | no | no | no | no | [Ali Express](https://www.aliexpress.com/item/1005005928865239.html) |
| 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) |

Note: the additional flash chip (W25Q32JV) is not always mounted on the board.

Expand Down Expand Up @@ -182,13 +182,17 @@ The template for the `lv_conf.h` file can be found in the LVGL library at `.pio/
## LV_COLOR_16_SWAP

The LVGL library has a define called **LV_COLOR_16_SWAP**. The value can be 1 (yes) or 0 (no).
This variable will swap the byte order of the lv_color16_t. This is required because the SPI is by default MSB first.
Swapping these bytes will undo this and creates a normal image.
This variable will swap the byte order of the lv_color16_t. This is required because the SPI is by default LSB first.

Setting this variable to true is required for the SPI interfaces: ST7789, GC9A01A, ILI9341 and ST7796 controllers but should be false for the oher interfaces.
Setting this variable to true is required for the SPI interfaces: ST7789, GC9A01A, ILI9341 and ST7796.
The choice has been made to also change the pin definition for the panel (rgb) interface so also here the bytes are swapped and behaves like SPI.
This makes it easier to have only one definition for lv_conf.h and SquareLine.

If this is not done, the code will run but swapping will be done runtime (and degrading the performance).
So for this library, **always set the LV_COLOR_16_SWAP to 1**.

Additionally, when using the [SquareLine Studio](https://squareline.io/) for designing the user interface, the display properties (under the project settings) must match this variable.
It needs to be set both in `lv_conf.h` configuration file and the corresponding display properties (16 bit swap or 16 bit) in [SquareLine Studio](https://squareline.io/). When using squareline, the UI has to be regenerated.
It needs to be set both in `lv_conf.h` configuration file and the corresponding display properties (16 bit swap) in [SquareLine Studio](https://squareline.io/).

![SquareLine display properties](assets/images/Squareline-display-properties.png)

Expand Down
8 changes: 4 additions & 4 deletions include/esp32_smartdisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
#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={8, 3, 46, 9, 1, 5, 6, 7, 15, 16, 4, 45, 48, 47, 21, 14},.disp_gpio_num=-1}
#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}
// Touch
#ifdef ESP32_4827S043R
#define USES_XPT2046
Expand Down Expand Up @@ -301,7 +301,7 @@
#define PIN_BCKL 2
// LCD 800x480
#define USES_LCD_RGB
#define RBG_PANEL_CONFIG {.clk_src=LCD_CLK_SRC_PLL160M,.timings={.pclk_hz=8000000,.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={8, 3, 46, 9, 1, 5, 6, 7, 15, 16, 4, 45, 48, 47, 21, 14},.disp_gpio_num=-1}
#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}
// Touch
#ifdef ESP32_8048S043R
#define USES_XPT2046
Expand Down Expand Up @@ -329,7 +329,7 @@
#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={8, 3, 46, 9, 1, 5, 6, 7, 15, 16, 4, 45, 48, 47, 21, 14},.disp_gpio_num=-1}
#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}
// Touch
#ifdef ESP32_8048S050R
#define USES_XPT2046
Expand Down Expand Up @@ -357,7 +357,7 @@
#define PIN_BCKL 2
// LCD 800x480
#define USES_LCD_RGB
#define RBG_PANEL_CONFIG {.clk_src=LCD_CLK_SRC_PLL160M,.timings={.pclk_hz=12000000,.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={15, 7, 6, 5, 4, 9, 46, 3, 8, 16, 1, 14, 21, 47, 48, 45},.disp_gpio_num=-1}
#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}
// Touch
#ifdef ESP32_8048S070R
#define USES_XPT2046
Expand Down
6 changes: 3 additions & 3 deletions src/smartdisplay_gc9a01.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void gc9a01_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *colo
#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;
lv_color16_t *p = color_map;
while (pixels--)
p++->full = (uint16_t)((p->full >> 8) | (p->full << 8));
#endif
Expand Down Expand Up @@ -51,9 +51,9 @@ void lvgl_tft_init(lv_disp_drv_t *drv)
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
drv->user_data = panel_handle;
drv->flush_cb = gc9a01_lv_flush;

// Colors are inverted
ESP_ERROR_CHECK(esp_lcd_panel_invert_color(panel_handle, true));
ESP_ERROR_CHECK(esp_lcd_panel_invert_color(panel_handle, true));

// Turn display on
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true));
Expand Down
Loading

0 comments on commit c2bc33e

Please sign in to comment.