Skip to content

Commit 5bd2a04

Browse files
authored
Merge pull request #614 from suda-morris/refactor/set_rgb_element_order
Refactor/set rgb element order
2 parents 16ba1a8 + 1e25912 commit 5bd2a04

File tree

12 files changed

+72
-52
lines changed

12 files changed

+72
-52
lines changed

components/lcd/esp_lcd_gc9a01/README.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ Implementation of the GC9A01 LCD controller with esp_lcd component.
1111
## Add to project
1212

1313
Packages from this repository are uploaded to [Espressif's component service](https://components.espressif.com/).
14-
You can add them to your project via `idf.py add-dependancy`, e.g.
15-
```
16-
idf.py add-dependency esp_lcd_gc9a01==1.0.0
14+
You can add them to your project via `idf.py add-dependency`, e.g.
15+
16+
```bash
17+
idf.py add-dependency "espressif/esp_lcd_gc9a01^2.0.0"
1718
```
1819

1920
Alternatively, you can create `idf_component.yml`. More is in [Espressif's documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html).
@@ -51,23 +52,15 @@ Alternatively, you can create `idf_component.yml`. More is in [Espressif's docum
5152
// .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(gc9a01_lcd_init_cmd_t),
5253
// };
5354
const esp_lcd_panel_dev_config_t panel_config = {
54-
.reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST, // Set to -1 if not use
55-
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
56-
.color_space = ESP_LCD_COLOR_SPACE_RGB,
57-
#else
58-
.rgb_endian = LCD_RGB_ENDIAN_RGB,
59-
#endif
60-
.bits_per_pixel = 16, // Implemented by LCD command `3Ah` (16/18)
61-
// .vendor_config = &vendor_config, // Uncomment this line if use custom initialization commands
55+
.reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST, // Set to -1 if not use
56+
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB, // RGB element order: R-G-B
57+
.bits_per_pixel = 16, // Implemented by LCD command `3Ah` (16/18)
58+
// .vendor_config = &vendor_config, // Uncomment this line if use custom initialization commands
6259
};
6360
ESP_ERROR_CHECK(esp_lcd_new_panel_gc9a01(io_handle, &panel_config, &panel_handle));
6461
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
6562
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
66-
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
67-
ESP_ERROR_CHECK(esp_lcd_panel_disp_off(panel_handle, false));
68-
#else
6963
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true));
70-
#endif
7164
```
7265
7366
There is an example in ESP-IDF with this LCD controller. Please follow this [link](https://github.com/espressif/esp-idf/tree/master/examples/peripherals/lcd/spi_lcd_touch).

components/lcd/esp_lcd_gc9a01/esp_lcd_gc9a01.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ esp_err_t esp_lcd_new_panel_gc9a01(const esp_lcd_panel_io_handle_t io, const esp
7373
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported color space");
7474
break;
7575
}
76-
#else
76+
#elif ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)
7777
switch (panel_dev_config->rgb_endian) {
7878
case LCD_RGB_ENDIAN_RGB:
7979
gc9a01->madctl_val = 0;
@@ -85,6 +85,18 @@ esp_err_t esp_lcd_new_panel_gc9a01(const esp_lcd_panel_io_handle_t io, const esp
8585
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported rgb endian");
8686
break;
8787
}
88+
#else
89+
switch (panel_dev_config->rgb_ele_order) {
90+
case LCD_RGB_ELEMENT_ORDER_RGB:
91+
gc9a01->madctl_val = 0;
92+
break;
93+
case LCD_RGB_ELEMENT_ORDER_BGR:
94+
gc9a01->madctl_val |= LCD_CMD_BGR_BIT;
95+
break;
96+
default:
97+
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported rgb element order");
98+
break;
99+
}
88100
#endif
89101

90102
switch (panel_dev_config->bits_per_pixel) {

components/lcd/esp_lcd_gc9a01/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "2.0.2"
1+
version: "2.0.3"
22
description: ESP LCD GC9A01
33
url: https://github.com/espressif/esp-bsp/tree/master/components/lcd/esp_lcd_gc9a01
44
dependencies:

components/lcd/esp_lcd_gc9a01/test_apps/main/test_esp_lcd_gc9a01.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ TEST_CASE("test gc9a01 to draw color bar with SPI interface", "[gc9a01][spi]")
8888
.reset_gpio_num = TEST_PIN_NUM_LCD_RST,
8989
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
9090
.color_space = ESP_LCD_COLOR_SPACE_BGR,
91-
#else
91+
#elif ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)
9292
.rgb_endian = LCD_RGB_ENDIAN_BGR,
93+
#else
94+
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR,
9395
#endif
9496
.bits_per_pixel = TEST_LCD_BIT_PER_PIXEL,
9597
};

components/lcd/esp_lcd_ili9341/README.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ Implementation of the ILI9341 LCD controller with esp_lcd component.
1111
## Add to project
1212

1313
Packages from this repository are uploaded to [Espressif's component service](https://components.espressif.com/).
14-
You can add them to your project via `idf.py add-dependancy`, e.g.
15-
```
16-
idf.py add-dependency esp_lcd_ili9341==1.0.0
14+
You can add them to your project via `idf.py add-dependency`, e.g.
15+
16+
```bash
17+
idf.py add-dependency "espressif/esp_lcd_ili9341^2.0.0"
1718
```
1819

1920
Alternatively, you can create `idf_component.yml`. More is in [Espressif's documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html).
@@ -51,23 +52,15 @@ Alternatively, you can create `idf_component.yml`. More is in [Espressif's docum
5152
// .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(ili9341_lcd_init_cmd_t),
5253
// };
5354
const esp_lcd_panel_dev_config_t panel_config = {
54-
.reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST, // Set to -1 if not use
55-
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) // Implemented by LCD command `36h`
56-
.color_space = ESP_LCD_COLOR_SPACE_RGB,
57-
#else
58-
.rgb_endian = LCD_RGB_ENDIAN_RGB,
59-
#endif
60-
.bits_per_pixel = 16, // Implemented by LCD command `3Ah` (16/18)
61-
// .vendor_config = &vendor_config, // Uncomment this line if use custom initialization commands
55+
.reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST, // Set to -1 if not use
56+
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB, // RGB element order: R-G-B
57+
.bits_per_pixel = 16, // Implemented by LCD command `3Ah` (16/18)
58+
// .vendor_config = &vendor_config, // Uncomment this line if use custom initialization commands
6259
};
6360
ESP_ERROR_CHECK(esp_lcd_new_panel_ili9341(io_handle, &panel_config, &panel_handle));
6461
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
6562
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
66-
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
67-
ESP_ERROR_CHECK(esp_lcd_panel_disp_off(panel_handle, false));
68-
#else
6963
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true));
70-
#endif
7164
```
7265
7366
There is an example in ESP-IDF with this LCD controller. Please follow this [link](https://github.com/espressif/esp-idf/tree/master/examples/peripherals/lcd/spi_lcd_touch).

components/lcd/esp_lcd_ili9341/esp_lcd_ili9341.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ esp_err_t esp_lcd_new_panel_ili9341(const esp_lcd_panel_io_handle_t io, const es
7373
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported color space");
7474
break;
7575
}
76-
#else
76+
#elif ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)
7777
switch (panel_dev_config->rgb_endian) {
7878
case LCD_RGB_ENDIAN_RGB:
7979
ili9341->madctl_val = 0;
@@ -85,6 +85,18 @@ esp_err_t esp_lcd_new_panel_ili9341(const esp_lcd_panel_io_handle_t io, const es
8585
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported rgb endian");
8686
break;
8787
}
88+
#else
89+
switch (panel_dev_config->rgb_ele_order) {
90+
case LCD_RGB_ELEMENT_ORDER_RGB:
91+
ili9341->madctl_val = 0;
92+
break;
93+
case LCD_RGB_ELEMENT_ORDER_BGR:
94+
ili9341->madctl_val |= LCD_CMD_BGR_BIT;
95+
break;
96+
default:
97+
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported rgb element order");
98+
break;
99+
}
88100
#endif
89101

90102
switch (panel_dev_config->bits_per_pixel) {

components/lcd/esp_lcd_ili9341/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "2.0.0"
1+
version: "2.0.1"
22
description: ESP LCD ILI9341
33
url: https://github.com/espressif/esp-bsp/tree/master/components/lcd/esp_lcd_ili9341
44
dependencies:

components/lcd/esp_lcd_ili9341/test_apps/main/test_esp_lcd_ili9341.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ TEST_CASE("test ili9341 to draw color bar with SPI interface", "[ili9341][spi]")
108108
.reset_gpio_num = TEST_PIN_NUM_LCD_RST, // Shared with Touch reset
109109
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
110110
.color_space = ESP_LCD_COLOR_SPACE_BGR,
111-
#else
111+
#elif ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)
112112
.rgb_endian = LCD_RGB_ENDIAN_BGR,
113+
#else
114+
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR,
113115
#endif
114116
.bits_per_pixel = TEST_LCD_BIT_PER_PIXEL,
115117
};

components/lcd/esp_lcd_st7796/README.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Packages from this repository are uploaded to [Espressif's component service](ht
1414
You can add them to your project via `idf.py add-dependency`, e.g.
1515

1616
```bash
17-
compote manifest add-dependency espressif/esp_lcd_st7796==1.0.0
17+
idf.py add-dependency "espressif/esp_lcd_st7796^1.3.0"
1818
```
1919

2020
Alternatively, you can create `idf_component.yml`. More is in [Espressif's documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html).
@@ -59,23 +59,15 @@ Alternatively, you can create `idf_component.yml`. More is in [Espressif's docum
5959
// .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(st7796_lcd_init_cmd_t),
6060
// };
6161
const esp_lcd_panel_dev_config_t panel_config = {
62-
.reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST, // Set to -1 if not use
63-
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) // Implemented by LCD command `36h`
64-
.color_space = ESP_LCD_COLOR_SPACE_RGB,
65-
#else
66-
.rgb_endian = LCD_RGB_ENDIAN_RGB,
67-
#endif
68-
.bits_per_pixel = EXAMPLE_LCD_BIT_PER_PIXEL, // Implemented by LCD command `3Ah` (16/18/24)
69-
// .vendor_config = &vendor_config, // Uncomment this line if use custom initialization commands
62+
.reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST, // Set to -1 if not use
63+
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB, // RGB element order: R-G-B
64+
.bits_per_pixel = EXAMPLE_LCD_BIT_PER_PIXEL, // Implemented by LCD command `3Ah` (16/18/24)
65+
// .vendor_config = &vendor_config, // Uncomment this line if use custom initialization commands
7066
};
7167
ESP_ERROR_CHECK(esp_lcd_new_panel_st7796(io_handle, &panel_config, &panel_handle));
7268
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
7369
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
74-
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
75-
ESP_ERROR_CHECK(esp_lcd_panel_disp_off(panel_handle, false));
76-
#else
7770
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true));
78-
#endif
7971
```
8072
8173
### MIPI Interface

components/lcd/esp_lcd_st7796/esp_lcd_st7796_general.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ esp_err_t esp_lcd_new_panel_st7796_general(const esp_lcd_panel_io_handle_t io, c
7474
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported color space");
7575
break;
7676
}
77-
#else
77+
#elif ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)
7878
switch (panel_dev_config->rgb_endian) {
7979
case LCD_RGB_ENDIAN_RGB:
8080
st7796->madctl_val = 0;
@@ -86,6 +86,18 @@ esp_err_t esp_lcd_new_panel_st7796_general(const esp_lcd_panel_io_handle_t io, c
8686
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported rgb endian");
8787
break;
8888
}
89+
#else
90+
switch (panel_dev_config->rgb_ele_order) {
91+
case LCD_RGB_ELEMENT_ORDER_RGB:
92+
st7796->madctl_val = 0;
93+
break;
94+
case LCD_RGB_ELEMENT_ORDER_BGR:
95+
st7796->madctl_val |= LCD_CMD_BGR_BIT;
96+
break;
97+
default:
98+
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported rgb element order");
99+
break;
100+
}
89101
#endif
90102

91103
switch (panel_dev_config->bits_per_pixel) {

0 commit comments

Comments
 (0)