feat(st7789): add data endian config

Closes https://github.com/espressif/esp-idf/issues/11416
This commit is contained in:
Planck (Lu Zeyu)
2023-08-22 17:54:09 +08:00
parent b1e85404f1
commit 6f55f76344
13 changed files with 62 additions and 30 deletions

View File

@@ -25,6 +25,9 @@
#include "esp_log.h"
#include "esp_check.h"
#define ST7789_CMD_RAMCTRL 0xb0
#define ST7789_DATA_LITTLE_ENDIAN_BIT (1 << 3)
static const char *TAG = "lcd_panel.st7789";
static esp_err_t panel_st7789_del(esp_lcd_panel_t *panel);
@@ -46,8 +49,10 @@ typedef struct {
int x_gap;
int y_gap;
uint8_t fb_bits_per_pixel;
uint8_t madctl_val; // save current value of LCD_CMD_MADCTL register
uint8_t colmod_cal; // save surrent value of LCD_CMD_COLMOD register
uint8_t madctl_val; // save current value of LCD_CMD_MADCTL register
uint8_t colmod_cal; // save surrent value of LCD_CMD_COLMOD register
uint8_t ramctl_val_1;
uint8_t ramctl_val_2;
} st7789_panel_t;
esp_err_t
@@ -99,6 +104,13 @@ esp_lcd_new_panel_st7789(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel
break;
}
st7789->ramctl_val_1 = 0x00;
st7789->ramctl_val_2 = 0xf0; // Use big endian by default
if((panel_dev_config->data_endian) == LCD_RGB_DATA_ENDIAN_LITTLE) {
// Use little endian
st7789->ramctl_val_2 |= ST7789_DATA_LITTLE_ENDIAN_BIT;
}
st7789->io = io;
st7789->fb_bits_per_pixel = fb_bits_per_pixel;
st7789->reset_gpio_num = panel_dev_config->reset_gpio_num;
@@ -173,6 +185,9 @@ static esp_err_t panel_st7789_init(esp_lcd_panel_t *panel)
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_COLMOD, (uint8_t[]) {
st7789->colmod_cal,
}, 1), TAG, "io tx param LCD_CMD_COLMOD failed");
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, ST7789_CMD_RAMCTRL, (uint8_t[]) {
st7789->ramctl_val_1, st7789->ramctl_val_2
}, 2), TAG, "io tx param RAMCTRL failed");
return ESP_OK;
}