Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rzeldent committed Mar 5, 2024
1 parent b9df093 commit bc7a4ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions src/esp_lcd_gc9a01.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ typedef struct
esp_lcd_panel_io_handle_t io;
esp_lcd_panel_dev_config_t config;
// Data
ushort x_gap;
ushort y_gap;
int x_gap;
int y_gap;
uint8_t madctl; // MADCTL register
const lcd_init_cmd_t *cmd;
const uint16_t cmds_size;
Expand Down Expand Up @@ -162,11 +162,9 @@ esp_err_t gc9a01_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, i
{
log_v("gc9a01_draw_bitmap. panel:0x%08x, x_start:%d, y_start:%d, x_end:%d, y_end:%d, color_data:0x%08x", panel, x_start, y_start, x_end, y_end, color_data);

assert(panel != NULL);
gc9a01_panel_t *ph = (gc9a01_panel_t *)panel;

assert(panel != NULL);
assert(color_data != NULL);
gc9a01_panel_t *ph = (gc9a01_panel_t *)panel;

if (x_start >= x_end)
{
Expand All @@ -187,17 +185,17 @@ esp_err_t gc9a01_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, i
y_end += ph->y_gap;

esp_err_t res;
uint8_t caset[4] = {x_start >> 8, x_start & 0xff, (x_end - 1) >> 8, (x_end - 1) & 0xff};
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)
{
log_e("Sending CASET/RASET failed");
return res;
}

uint8_t bytes_per_pixel = (ph->config.bits_per_pixel + 0x7) >> 3;
size_t len = (x_end - x_start) * (y_end - y_start) * bytes_per_pixel;
const uint8_t bytes_per_pixel = ((ph->config.bits_per_pixel + 0x7) >> 3);
const size_t len = (x_end - x_start) * (y_end - y_start) * bytes_per_pixel;
if ((res = esp_lcd_panel_io_tx_param(ph->io, LCD_CMD_RAMWR, color_data, len)) != ESP_OK)
{
log_e("Sending RAMWR failed");
Expand Down
2 changes: 1 addition & 1 deletion src/lvgl_xpt2046_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void lvgl_touch_init(lv_indev_drv_t *drv)
.dc_low_on_data = XPT2046_SPI_CONFIG_FLAGS_DC_LOW_ON_DATA,
.octal_mode = XPT2046_SPI_CONFIG_FLAGS_OCTAL_MODE,
.lsb_first = XPT2046_SPI_CONFIG_FLAGS_LSB_FIRST}};
log_d("io_config: cs_gpio_num:%d, dc_gpio_num:%d, spi_mode:%d, pclk_hz:%d, trans_queue_depth:%d, user_ctx:0x%08x, on_color_trans_done:0x%08x, lcd_cmd_bits:%d, lcd_param_bits:%d, flags.dc_as_cmd_phase:%d, flags.dc_low_on_data:%d, flags.octal_mode:%d, flags.lsb_first:%d", io_config.cs_gpio_num, io_config.dc_gpio_num, io_config.spi_mode, io_config.pclk_hz, io_config.trans_queue_depth, io_config.user_ctx, io_config.on_color_trans_done, io_config.lcd_cmd_bits, io_config.lcd_param_bits, io_config.flags.dc_as_cmd_phase, io_config.flags.dc_low_on_data, io_config.flags.octal_mode, io_config.flags.lsb_first);
log_d("io_spi_config: cs_gpio_num:%d, dc_gpio_num:%d, spi_mode:%d, pclk_hz:%d, trans_queue_depth:%d, user_ctx:0x%08x, on_color_trans_done:0x%08x, lcd_cmd_bits:%d, lcd_param_bits:%d, flags.dc_as_cmd_phase:%d, flags.dc_low_on_data:%d, flags.octal_mode:%d, flags.lsb_first:%d", io_spi_config.cs_gpio_num, io_spi_config.dc_gpio_num, io_spi_config.spi_mode, io_spi_config.pclk_hz, io_spi_config.trans_queue_depth, io_spi_config.user_ctx, io_spi_config.on_color_trans_done, io_spi_config.lcd_cmd_bits, io_spi_config.lcd_param_bits, io_spi_config.flags.dc_as_cmd_phase, io_spi_config.flags.dc_low_on_data, io_spi_config.flags.octal_mode, io_spi_config.flags.lsb_first);
esp_lcd_panel_io_handle_t io_handle;
ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)XPT2046_SPI_HOST, &io_spi_config, &io_handle));

Expand Down

0 comments on commit bc7a4ae

Please sign in to comment.