Skip to content

Commit c8c5263

Browse files
miggazElqueznashif
authored andcommitted
drivers: display: st7789v: add support for BGR565
Add support for BGR565 pixel format in the st7789v driver. Signed-off-by: Miguel Gazquez <[email protected]>
1 parent 8d74553 commit c8c5263

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

drivers/display/Kconfig.st7789v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ config ST7789V_RGB888
2424
config ST7789V_RGB565
2525
bool "RGB565"
2626

27+
config ST7789V_BGR565
28+
bool "BGR565"
29+
2730
endchoice

drivers/display/display_st7789v.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ struct st7789v_data {
5252
uint16_t y_offset;
5353
};
5454

55-
#ifdef CONFIG_ST7789V_RGB565
56-
#define ST7789V_PIXEL_SIZE 2u
57-
#else
55+
#ifdef CONFIG_ST7789V_RGB888
5856
#define ST7789V_PIXEL_SIZE 3u
57+
#else
58+
#define ST7789V_PIXEL_SIZE 2u
5959
#endif
6060

6161
static void st7789v_set_lcd_margins(const struct device *dev,
@@ -164,6 +164,8 @@ static int st7789v_write(const struct device *dev,
164164
}
165165
if (IS_ENABLED(CONFIG_ST7789V_RGB565)) {
166166
pixfmt = PIXEL_FORMAT_RGB_565;
167+
} else if (IS_ENABLED(CONFIG_ST7789V_BGR565)) {
168+
pixfmt = PIXEL_FORMAT_BGR_565;
167169
} else {
168170
pixfmt = PIXEL_FORMAT_RGB_888;
169171
}
@@ -197,6 +199,9 @@ static void st7789v_get_capabilities(const struct device *dev,
197199
#ifdef CONFIG_ST7789V_RGB565
198200
capabilities->supported_pixel_formats = PIXEL_FORMAT_RGB_565;
199201
capabilities->current_pixel_format = PIXEL_FORMAT_RGB_565;
202+
#elif CONFIG_ST7789V_BGR565
203+
capabilities->supported_pixel_formats = PIXEL_FORMAT_BGR_565;
204+
capabilities->current_pixel_format = PIXEL_FORMAT_BGR_565;
200205
#else
201206
capabilities->supported_pixel_formats = PIXEL_FORMAT_RGB_888;
202207
capabilities->current_pixel_format = PIXEL_FORMAT_RGB_888;
@@ -209,6 +214,8 @@ static int st7789v_set_pixel_format(const struct device *dev,
209214
{
210215
#ifdef CONFIG_ST7789V_RGB565
211216
if (pixel_format == PIXEL_FORMAT_RGB_565) {
217+
#elif CONFIG_ST7789V_BGR565
218+
if (pixel_format == PIXEL_FORMAT_BGR_565) {
212219
#else
213220
if (pixel_format == PIXEL_FORMAT_RGB_888) {
214221
#endif

0 commit comments

Comments
 (0)