Skip to content

Commit

Permalink
VendorConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
rzeldent committed Mar 7, 2024
1 parent 42b5398 commit 25a00cf
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
8 changes: 7 additions & 1 deletion include/esp_lcd_panel_gc9a01.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ extern "C"
{
#endif

esp_err_t esp_lcd_new_panel_gc9a01(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *config, esp_lcd_panel_handle_t *handle);
typedef struct
{
const lcd_init_cmd_t *init_cmds;
uint16_t init_cmds_size;
} gc9a01_vendor_config_t;

esp_err_t esp_lcd_new_panel_gc9a01(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *config, esp_lcd_panel_handle_t *handle);

#ifdef __cplusplus
}
Expand Down
8 changes: 7 additions & 1 deletion include/esp_lcd_panel_st7796.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ extern "C"
{
#endif

esp_err_t esp_lcd_new_panel_st7796(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *config, esp_lcd_panel_handle_t *handle);
typedef struct
{
const lcd_init_cmd_t *init_cmds;
uint16_t init_cmds_size;
} st7796_vendor_config_t;

esp_err_t esp_lcd_new_panel_st7796(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *config, esp_lcd_panel_handle_t *handle);

#ifdef __cplusplus
}
Expand Down
9 changes: 4 additions & 5 deletions src/esp_lcd_panel_gc9a01.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ const lcd_init_cmd_t gc9a01_vendor_specific_init_default[] = {
{0x67, (const uint8_t[]){0x00, 0x3C, 0x00, 0x00, 0x00, 0x01, 0x54, 0x10, 0x32, 0x98}, 10, 0},
{0x74, (const uint8_t[]){0x10, 0x45, 0x80, 0x00, 0x00, 0x4E, 0x00}, 7, 0},
{0x98, (const uint8_t[]){0x3e, 0x07}, 2, 0},
{0x99, (const uint8_t[]){0x3e, 0x07}, 2, 0}
};
{0x99, (const uint8_t[]){0x3e, 0x07}, 2, 0}};

esp_err_t gc9a01_reset(esp_lcd_panel_t *panel)
{
Expand Down Expand Up @@ -141,10 +140,10 @@ esp_err_t gc9a01_init(esp_lcd_panel_t *panel)

const lcd_init_cmd_t *cmd = gc9a01_vendor_specific_init_default;
uint16_t cmds_size = sizeof(gc9a01_vendor_specific_init_default) / sizeof(lcd_init_cmd_t);
if (ph->cmd)
if (ph->config.vendor_config != NULL)
{
cmd = ph->cmd;
cmds_size = ph->cmds_size;
cmd = ((gc9a01_vendor_config_t *)ph->config.vendor_config)->init_cmds;
cmds_size = ((gc9a01_vendor_config_t *)ph->config.vendor_config)->init_cmds_size;
}

while (cmds_size-- > 0)
Expand Down
14 changes: 6 additions & 8 deletions src/esp_lcd_panel_st7796.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ typedef struct
int x_gap;
int y_gap;
uint8_t madctl;
const lcd_init_cmd_t *cmd;
const uint16_t cmds_size;
} st7796_panel_t;

const lcd_init_cmd_t st7796_vendor_specific_init_default[] = {
Expand Down Expand Up @@ -64,7 +62,7 @@ esp_err_t st7796_reset(esp_lcd_panel_t *panel)
}
}

vTaskDelay(pdMS_TO_TICKS(120));
vTaskDelay(pdMS_TO_TICKS(5));

return ESP_OK;
}
Expand Down Expand Up @@ -112,10 +110,10 @@ esp_err_t st7796_init(esp_lcd_panel_t *panel)

const lcd_init_cmd_t *cmd = st7796_vendor_specific_init_default;
uint16_t cmds_size = sizeof(st7796_vendor_specific_init_default) / sizeof(lcd_init_cmd_t);
if (ph->cmd)
if (ph->config.vendor_config != NULL)
{
cmd = ph->cmd;
cmds_size = ph->cmds_size;
cmd = ((st7796_vendor_config_t *)ph->config.vendor_config)->init_cmds;
cmds_size = ((st7796_vendor_config_t *)ph->config.vendor_config)->init_cmds_size;
}

while (cmds_size-- > 0)
Expand Down Expand Up @@ -160,8 +158,8 @@ esp_err_t st7796_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, i
y_end += ph->y_gap;

esp_err_t res;
const uint8_t caset[4] = {x_start >> 8, x_start & 0xff, (x_end - 1) >> 8, (x_end - 1) & 0xff};
const uint8_t raset[4] = {y_start >> 8, y_start & 0xff, (y_end - 1) >> 8, (y_end - 1) & 0xff};
const uint8_t caset[4] = {x_start >> 8, x_start, (x_end - 1) >> 8, (x_end - 1)};
const uint8_t raset[4] = {y_start >> 8, y_start, (y_end - 1) >> 8, (y_end - 1)};
if ((res = esp_lcd_panel_io_tx_param(ph->io, LCD_CMD_CASET, caset, sizeof(caset))) != ESP_OK ||
(res = esp_lcd_panel_io_tx_param(ph->io, LCD_CMD_RASET, raset, sizeof(raset))) != ESP_OK)
{
Expand Down

0 comments on commit 25a00cf

Please sign in to comment.