|
1 | 1 | /* |
2 | | - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD |
| 2 | + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: Apache-2.0 |
5 | 5 | */ |
@@ -65,17 +65,43 @@ esp_err_t esp_lcd_new_panel_st7796_mipi(const esp_lcd_panel_io_handle_t io, cons |
65 | 65 | ESP_GOTO_ON_ERROR(gpio_config(&io_conf), err, TAG, "configure GPIO for RST line failed"); |
66 | 66 | } |
67 | 67 |
|
| 68 | +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) |
68 | 69 | switch (panel_dev_config->color_space) { |
| 70 | + case ESP_LCD_COLOR_SPACE_RGB: |
| 71 | + st7796->madctl_val = 0; |
| 72 | + break; |
| 73 | + case ESP_LCD_COLOR_SPACE_BGR: |
| 74 | + st7796->madctl_val |= LCD_CMD_BGR_BIT; |
| 75 | + break; |
| 76 | + default: |
| 77 | + ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported color space"); |
| 78 | + break; |
| 79 | + } |
| 80 | +#elif ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0) |
| 81 | + switch (panel_dev_config->rgb_endian) { |
| 82 | + case LCD_RGB_ENDIAN_RGB: |
| 83 | + st7796->madctl_val = 0; |
| 84 | + break; |
| 85 | + case LCD_RGB_ENDIAN_BGR: |
| 86 | + st7796->madctl_val |= LCD_CMD_BGR_BIT; |
| 87 | + break; |
| 88 | + default: |
| 89 | + ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported rgb endian"); |
| 90 | + break; |
| 91 | + } |
| 92 | +#else |
| 93 | + switch (panel_dev_config->rgb_ele_order) { |
69 | 94 | case LCD_RGB_ELEMENT_ORDER_RGB: |
70 | 95 | st7796->madctl_val = 0; |
71 | 96 | break; |
72 | 97 | case LCD_RGB_ELEMENT_ORDER_BGR: |
73 | 98 | st7796->madctl_val |= LCD_CMD_BGR_BIT; |
74 | 99 | break; |
75 | 100 | default: |
76 | | - ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported color space"); |
| 101 | + ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported rgb element order"); |
77 | 102 | break; |
78 | 103 | } |
| 104 | +#endif |
79 | 105 |
|
80 | 106 | switch (panel_dev_config->bits_per_pixel) { |
81 | 107 | case 16: // RGB565 |
|
0 commit comments