Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rzeldent committed Mar 9, 2024
1 parent 79e9cfc commit 0fbb2a9
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 61 deletions.
109 changes: 58 additions & 51 deletions src/esp_touch_cst816s.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,55 @@
#include <esp32-hal-log.h>

// Registers
const uint8_t CST816S_GESTURE_REG = 0x01;
const uint8_t CST816S_FINGERNUM_REG = 0x02;
const uint8_t CST816S_XPOSH_REG = 0x03;
const uint8_t CST816S_XPOSL_REG = 0x04;
const uint8_t CST816S_YPOSH_REG = 0x05;
const uint8_t CST816S_YPOSL_REG = 0x06;

const uint8_t CST816S_BC0H_REG = 0xB0;
const uint8_t CST816S_BC0L_REG = 0xB1;
const uint8_t CST816S_BC1H_REG = 0xB2;
const uint8_t CST816S_BC1L_REG = 0xB3;

const uint8_t CST816S_SLEEP_REG = 0xA5;
const uint8_t CST816S_CHIPID_REG = 0xA7;
const uint8_t CST816S_PROJID_REG = 0xA8;
const uint8_t CST816S_FWVERSION_REG = 0xA9;

const uint8_t CST816S_MOTIONMASK_REG = 0xEC;
const uint8_t CST816S_IRQPULSEWIDTH_REG = 0xED;
const uint8_t CST816S_NORSCANPER_REG = 0xEE;
const uint8_t CST816S_MOTIONSIANGLE_REG = 0xEF;
const uint8_t CST816S_LPSCANRAW1H_REG = 0xF0;
const uint8_t CST816S_LPSCANRAW1L_REG = 0xF1;
const uint8_t CST816S_LPSCANRAW2H_REG = 0xF2;
const uint8_t CST816S_LPSCANRAW2L_REG = 0xF3;
const uint8_t CST816S_LPAUTOWAKEUPTIME_REG = 0xF4;
const uint8_t CST816S_LPSCANTH_REG = 0xF5;
const uint8_t CST816S_LPSCANWIN_REG = 0xF6;
const uint8_t CST816S_LPSCANFREQ_REG = 0xF7;
const uint8_t CST816S_LPSCANIDAC_REG = 0xF8;
const uint8_t CST816S_AUTOSLEEPTIME_REG = 0xF9;
const uint8_t CST816S_IRQCTL_REG = 0xFA;
const uint8_t CST816S_AUTORESET_REG = 0xFB;
const uint8_t CST816S_LONGPRESSTIME_REG = 0xFC;
const uint8_t CST816S_IOCTL_REG = 0xFD;
const uint8_t CST816S_AUTOSLEEP_REG = 0xFE;
#define CST816S_GESTURE_REG 0x01
#define CST816S_FINGERNUM_REG 0x02
#define CST816S_XPOSH_REG 0x03
#define CST816S_XPOSL_REG 0x04
#define CST816S_YPOSH_REG 0x05
#define CST816S_YPOSL_REG 0x06

#define CST816S_BC0H_REG 0xB0
#define CST816S_BC0L_REG 0xB1
#define CST816S_BC1H_REG 0xB2
#define CST816S_BC1L_REG 0xB3

#define CST816S_SLEEP_REG 0xA5
#define CST816S_CHIPID_REG 0xA7
#define CST816S_PROJID_REG 0xA8
#define CST816S_FWVERSION_REG 0xA9

#define CST816S_MOTIONMASK_REG 0xEC
#define CST816S_IRQPULSEWIDTH_REG 0xED
#define CST816S_NORSCANPER_REG 0xEE
#define CST816S_MOTIONSIANGLE_REG 0xEF
#define CST816S_LPSCANRAW1H_REG 0xF0
#define CST816S_LPSCANRAW1L_REG 0xF1
#define CST816S_LPSCANRAW2H_REG 0xF2
#define CST816S_LPSCANRAW2L_REG 0xF3
#define CST816S_LPAUTOWAKEUPTIME_REG 0xF4
#define CST816S_LPSCANTH_REG 0xF5
#define CST816S_LPSCANWIN_REG 0xF6
#define CST816S_LPSCANFREQ_REG 0xF7
#define CST816S_LPSCANIDAC_REG 0xF8
#define CST816S_AUTOSLEEPTIME_REG 0xF9
#define CST816S_IRQCTL_REG 0xFA
#define CST816S_AUTORESET_REG 0xFB
#define CST816S_LONGPRESSTIME_REG 0xFC
#define CST816S_IOCTL_REG 0xFD
#define CST816S_AUTOSLEEP_REG 0xFE

// Touch events
const uint8_t CST816S_TOUCH_EVENT_NONE = 0x0;
const uint8_t CST816S_TOUCH_EVENT_SLIDE_DOWN = 0x1;
const uint8_t CST816S_TOUCH_EVENT_SLIDE_UP = 0x2;
const uint8_t CST816S_TOUCH_EVENT_SLIDE_LEFT = 0x3;
const uint8_t CST816S_TOUCH_EVENT_SLIDE_RIGHT = 0x4;
const uint8_t CST816S_TOUCH_EVENT_CLICK = 0x5;
const uint8_t CST816S_TOUCH_EVENT_DOUBLE_CLICK = 0xB;
const uint8_t CST816S_TOUCH_EVENT_PRESS = 0xC;
enum cst816s_touch_event
{
none = 0,
down = 1,
up = 2,
slide_left = 3,
slide_right = 4,
click = 5,
double_click = 11,
press = 12
};

typedef struct __attribute__((packed))
{
Expand All @@ -62,8 +65,12 @@ typedef struct __attribute__((packed))

typedef struct __attribute__((packed))
{
uint16_t x;
uint16_t y;
uint8_t x_h : 4;
uint8_t : 4;
uint8_t x_l;
uint8_t y_h : 4;
uint8_t : 4;
uint8_t y_l;
} cst816s_point;

typedef struct __attribute__((packed))
Expand Down Expand Up @@ -157,8 +164,8 @@ esp_err_t cst816s_read_data(esp_lcd_touch_handle_t th)
portENTER_CRITICAL(&th->data.lock);
if ((th->data.points = buffer.fingerNum) > 0)
{
th->data.coords[0].x = buffer.point.x;
th->data.coords[0].y = buffer.point.y;
th->data.coords[0].x = (buffer.point.x_h << 8) | buffer.point.x_l;
th->data.coords[0].y = (buffer.point.y_h << 8) | buffer.point.y_l;
th->data.coords[0].strength = 0;
}

Expand All @@ -177,8 +184,8 @@ bool cst816s_get_xy(esp_lcd_touch_handle_t th, uint16_t *x, uint16_t *y, uint16_
*point_num = th->data.points > max_point_num ? max_point_num : th->data.points;
for (uint8_t i = 0; i < *point_num; i++)
{
x[i] = th->data.coords[i].y;
y[i] = th->data.coords[i].x;
x[i] = th->data.coords[i].x;
y[i] = th->data.coords[i].y;
if (strength != NULL)
strength[i] = th->data.coords[i].strength;
}
Expand Down Expand Up @@ -317,7 +324,7 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons
}
}

log_d("handle: 0x%08x", th);
log_d("handle:0x%08x", th);
*handle = th;

return ESP_OK;
Expand Down
2 changes: 1 addition & 1 deletion src/esp_touch_gt911.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const
return res;
}

log_d("handle: 0x%08x", th);
log_d("handle:0x%08x", th);
*handle = th;

return ESP_OK;
Expand Down
1 change: 1 addition & 0 deletions src/esp_touch_xpt2046.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ esp_err_t esp_lcd_touch_new_spi_xpt2046(const esp_lcd_panel_io_handle_t io, cons
if (config->rst_gpio_num != GPIO_NUM_NC)
log_w("RST pin defined but is not available on the XPT2046");

log_d("handle:0x%08x", th);
*handle = th;

return ESP_OK;
Expand Down
1 change: 1 addition & 0 deletions src/lvgl_panel_st7262_par.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void lvgl_lcd_init(lv_disp_drv_t *drv)
.flags = {.disp_active_low = ST7262_PANEL_CONFIG_FLAGS_DISP_ACTIVE_LOW, .relax_on_idle = ST7262_PANEL_CONFIG_FLAGS_RELAX_ON_IDLE, .fb_in_psram = ST7262_PANEL_CONFIG_FLAGS_FB_IN_PSRAM}
};
log_d("rgb_panel_config: clk_src:%d, timings:{pclk_hz:%d, h_res:%d, v_res:%d, hsync_pulse_width:%d, hsync_back_porch:%d, hsync_front_porch:%d, vsync_pulse_width:%d, vsync_back_porch:%d, vsync_front_porch:%d, flags:{hsync_idle_low:%d, vsync_idle_low:%d, de_idle_high:%d, pclk_active_neg:%d, pclk_idle_high:%d}}, data_width:%d, sram_trans_align:%d, psram_trans_align:%d, hsync_gpio_num:%d, vsync_gpio_num:%d, de_gpio_num:%d, pclk_gpio_num:%d, data_gpio_nums:[%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,], disp_gpio_num:%d, on_frame_trans_done:0x%08x, user_ctx:0x%08x, flags:{disp_active_low:%d, relax_on_idle:%d, fb_in_psram:%d}", rgb_panel_config.clk_src, rgb_panel_config.timings.pclk_hz, rgb_panel_config.timings.h_res, rgb_panel_config.timings.v_res, rgb_panel_config.timings.hsync_pulse_width, rgb_panel_config.timings.hsync_back_porch, rgb_panel_config.timings.hsync_front_porch, rgb_panel_config.timings.vsync_pulse_width, rgb_panel_config.timings.vsync_back_porch, rgb_panel_config.timings.vsync_front_porch, rgb_panel_config.timings.flags.hsync_idle_low, rgb_panel_config.timings.flags.vsync_idle_low, rgb_panel_config.timings.flags.de_idle_high, rgb_panel_config.timings.flags.pclk_active_neg, rgb_panel_config.timings.flags.pclk_idle_high, rgb_panel_config.data_width, rgb_panel_config.sram_trans_align, rgb_panel_config.psram_trans_align, rgb_panel_config.hsync_gpio_num, rgb_panel_config.vsync_gpio_num, rgb_panel_config.de_gpio_num, rgb_panel_config.pclk_gpio_num, rgb_panel_config.data_gpio_nums[0], rgb_panel_config.data_gpio_nums[1], rgb_panel_config.data_gpio_nums[2], rgb_panel_config.data_gpio_nums[3], rgb_panel_config.data_gpio_nums[4], rgb_panel_config.data_gpio_nums[5], rgb_panel_config.data_gpio_nums[6], rgb_panel_config.data_gpio_nums[7], rgb_panel_config.data_gpio_nums[8], rgb_panel_config.data_gpio_nums[9], rgb_panel_config.data_gpio_nums[10], rgb_panel_config.data_gpio_nums[11], rgb_panel_config.data_gpio_nums[12], rgb_panel_config.data_gpio_nums[13], rgb_panel_config.data_gpio_nums[14], rgb_panel_config.data_gpio_nums[15], rgb_panel_config.disp_gpio_num, rgb_panel_config.on_frame_trans_done, rgb_panel_config.user_ctx, rgb_panel_config.flags.disp_active_low, rgb_panel_config.flags.relax_on_idle, rgb_panel_config.flags.fb_in_psram);
log_d("refresh rate: %d Hz", (ST7262_PANEL_CONFIG_TIMINGS_PCLK_HZ * ST7262_PANEL_CONFIG_DATA_WIDTH) / (ST7262_PANEL_CONFIG_TIMINGS_H_RES + ST7262_PANEL_CONFIG_TIMINGS_HSYNC_PULSE_WIDTH + ST7262_PANEL_CONFIG_TIMINGS_HSYNC_BACK_PORCH + ST7262_PANEL_CONFIG_TIMINGS_HSYNC_FRONT_PORCH) / (ST7262_PANEL_CONFIG_TIMINGS_V_RES + ST7262_PANEL_CONFIG_TIMINGS_VSYNC_PULSE_WIDTH + ST7262_PANEL_CONFIG_TIMINGS_VSYNC_BACK_PORCH + ST7262_PANEL_CONFIG_TIMINGS_VSYNC_FRONT_PORCH) / SOC_LCD_RGB_DATA_WIDTH);
esp_lcd_panel_handle_t panel_handle;
ESP_ERROR_CHECK(esp_lcd_new_rgb_panel(&rgb_panel_config, &panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
Expand Down
4 changes: 2 additions & 2 deletions src/lvgl_panel_st7701_par.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void lvgl_lcd_init(lv_disp_drv_t *drv)
.lcd_cmd_bytes = ST7701_IO_3WIRE_SPI_LCD_CMD_BYTES,
.lcd_param_bytes = ST7701_IO_3WIRE_SPI_LCD_PARAM_BYTES,
.flags = {.use_dc_bit = ST7701_IO_3WIRE_SPI_FLAGS_USE_DC_BIT, .dc_zero_on_data = ST7701_IO_3WIRE_SPI_FLAGS_DC_ZERO_ON_DATA, .lsb_first = ST7701_IO_3WIRE_SPI_FLAGS_LSB_FIRST, .cs_high_active = ST7701_IO_3WIRE_SPI_FLAGS_CS_HIGH_ACTIVE, .del_keep_cs_inactive = ST7701_IO_3WIRE_SPI_FLAGS_DEL_KEEP_CS_INACTIVE}};
log_d("io_3wire_spi_config: line_config:{cs_io_type: %d, cs_gpio_num: %d, scl_io_type: %d, scl_gpio_num: %d, sda_io_type: %d, sda_gpio_num: %d}, expect_clk_speed: %d, spi_mode: %d, lcd_cmd_bytes: %d, lcd_param_bytes: %d, flags:{use_dc_bit: %d, dc_zero_on_data: %d, lsb_first: %d, cs_high_active: %d, del_keep_cs_inactive: %d}", io_3wire_spi_config.line_config.cs_io_type, io_3wire_spi_config.line_config.cs_gpio_num, io_3wire_spi_config.line_config.scl_io_type, io_3wire_spi_config.line_config.scl_gpio_num, io_3wire_spi_config.line_config.sda_io_type, io_3wire_spi_config.line_config.sda_gpio_num, io_3wire_spi_config.expect_clk_speed, io_3wire_spi_config.spi_mode, io_3wire_spi_config.lcd_cmd_bytes, io_3wire_spi_config.lcd_param_bytes, io_3wire_spi_config.flags.use_dc_bit, io_3wire_spi_config.flags.dc_zero_on_data, io_3wire_spi_config.flags.lsb_first, io_3wire_spi_config.flags.cs_high_active, io_3wire_spi_config.flags.del_keep_cs_inactive);
log_d("io_3wire_spi_config: line_config:{cs_io_type:%d, cs_gpio_num:%d, scl_io_type:%d, scl_gpio_num:%d, sda_io_type:%d, sda_gpio_num:%d}, expect_clk_speed:%d, spi_mode:%d, lcd_cmd_bytes:%d, lcd_param_bytes:%d, flags:{use_dc_bit:%d, dc_zero_on_data:%d, lsb_first:%d, cs_high_active:%d, del_keep_cs_inactive:%d}", io_3wire_spi_config.line_config.cs_io_type, io_3wire_spi_config.line_config.cs_gpio_num, io_3wire_spi_config.line_config.scl_io_type, io_3wire_spi_config.line_config.scl_gpio_num, io_3wire_spi_config.line_config.sda_io_type, io_3wire_spi_config.line_config.sda_gpio_num, io_3wire_spi_config.expect_clk_speed, io_3wire_spi_config.spi_mode, io_3wire_spi_config.lcd_cmd_bytes, io_3wire_spi_config.lcd_param_bytes, io_3wire_spi_config.flags.use_dc_bit, io_3wire_spi_config.flags.dc_zero_on_data, io_3wire_spi_config.flags.lsb_first, io_3wire_spi_config.flags.cs_high_active, io_3wire_spi_config.flags.del_keep_cs_inactive);
esp_lcd_panel_io_handle_t io_handle;
ESP_ERROR_CHECK(esp_lcd_new_panel_io_3wire_spi(&io_3wire_spi_config, &io_handle));

Expand Down Expand Up @@ -82,7 +82,7 @@ void lvgl_lcd_init(lv_disp_drv_t *drv)
.user_ctx = drv,
.flags = {.disp_active_low = ST7701_PANEL_CONFIG_FLAGS_DISP_ACTIVE_LOW, .relax_on_idle = ST7701_PANEL_CONFIG_FLAGS_RELAX_ON_IDLE, .fb_in_psram = ST7701_PANEL_CONFIG_FLAGS_FB_IN_PSRAM}
};
log_d("rgb_panel_config: clk_src:%d, timings:{pclk_hz:%d, h_res:%d, v_res:%d, hsync_pulse_width:%d, hsync_back_porch:%d, hsync_front_porch:%d, vsync_pulse_width:%d, vsync_back_porch:%d, vsync_front_porch:%d, flags:{hsync_idle_low:%d, vsync_idle_low:%d, de_idle_high:%d, pclk_active_neg:%d, pclk_idle_high:%d}}, data_width:%d, sram_trans_align:%d, psram_trans_align:%d, hsync_gpio_num:%d, vsync_gpio_num:%d, de_gpio_num:%d, pclk_gpio_num:%d, data_gpio_nums:[%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,], disp_gpio_num:%d, on_frame_trans_done:0x%08x, user_ctx:0x%08x, flags:{disp_active_low:%d, relax_on_idle:%d, fb_in_psram:%d}", rgb_panel_config.clk_src, rgb_panel_config.timings.pclk_hz, rgb_panel_config.timings.h_res, rgb_panel_config.timings.v_res, rgb_panel_config.timings.hsync_pulse_width, rgb_panel_config.timings.hsync_back_porch, rgb_panel_config.timings.hsync_front_porch, rgb_panel_config.timings.vsync_pulse_width, rgb_panel_config.timings.vsync_back_porch, rgb_panel_config.timings.vsync_front_porch, rgb_panel_config.timings.flags.hsync_idle_low, rgb_panel_config.timings.flags.vsync_idle_low, rgb_panel_config.timings.flags.de_idle_high, rgb_panel_config.timings.flags.pclk_active_neg, rgb_panel_config.timings.flags.pclk_idle_high, rgb_panel_config.data_width, rgb_panel_config.sram_trans_align, rgb_panel_config.psram_trans_align, rgb_panel_config.hsync_gpio_num, rgb_panel_config.vsync_gpio_num, rgb_panel_config.de_gpio_num, rgb_panel_config.pclk_gpio_num, rgb_panel_config.data_gpio_nums[0], rgb_panel_config.data_gpio_nums[1], rgb_panel_config.data_gpio_nums[2], rgb_panel_config.data_gpio_nums[3], rgb_panel_config.data_gpio_nums[4], rgb_panel_config.data_gpio_nums[5], rgb_panel_config.data_gpio_nums[6], rgb_panel_config.data_gpio_nums[7], rgb_panel_config.data_gpio_nums[8], rgb_panel_config.data_gpio_nums[9], rgb_panel_config.data_gpio_nums[10], rgb_panel_config.data_gpio_nums[11], rgb_panel_config.data_gpio_nums[12], rgb_panel_config.data_gpio_nums[13], rgb_panel_config.data_gpio_nums[14], rgb_panel_config.data_gpio_nums[15], rgb_panel_config.disp_gpio_num, rgb_panel_config.on_frame_trans_done, rgb_panel_config.user_ctx, rgb_panel_config.flags.disp_active_low, rgb_panel_config.flags.relax_on_idle, rgb_panel_config.flags.fb_in_psram);
log_d("rgb_panel_config: clk_src:%d, timings:{pclk_hz:%d, h_res:%d, v_res:%d, hsync_pulse_width:%d, hsync_back_porch:%d, hsync_front_porch:%d, vsync_pulse_width:%d, vsync_back_porch:%d, vsync_front_porch:%d, flags:{hsync_idle_low:%d, vsync_idle_low:%d, de_idle_high:%d, pclk_active_neg:%d, pclk_idle_high:%d}}, data_width:%d, sram_trans_align:%d, psram_trans_align:%d, hsync_gpio_num:%d, vsync_gpio_num:%d, de_gpio_num:%d, pclk_gpio_num:%d, data_gpio_nums:[%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d], disp_gpio_num:%d, on_frame_trans_done:0x%08x, user_ctx:0x%08x, flags:{disp_active_low:%d, relax_on_idle:%d, fb_in_psram:%d}", rgb_panel_config.clk_src, rgb_panel_config.timings.pclk_hz, rgb_panel_config.timings.h_res, rgb_panel_config.timings.v_res, rgb_panel_config.timings.hsync_pulse_width, rgb_panel_config.timings.hsync_back_porch, rgb_panel_config.timings.hsync_front_porch, rgb_panel_config.timings.vsync_pulse_width, rgb_panel_config.timings.vsync_back_porch, rgb_panel_config.timings.vsync_front_porch, rgb_panel_config.timings.flags.hsync_idle_low, rgb_panel_config.timings.flags.vsync_idle_low, rgb_panel_config.timings.flags.de_idle_high, rgb_panel_config.timings.flags.pclk_active_neg, rgb_panel_config.timings.flags.pclk_idle_high, rgb_panel_config.data_width, rgb_panel_config.sram_trans_align, rgb_panel_config.psram_trans_align, rgb_panel_config.hsync_gpio_num, rgb_panel_config.vsync_gpio_num, rgb_panel_config.de_gpio_num, rgb_panel_config.pclk_gpio_num, rgb_panel_config.data_gpio_nums[0], rgb_panel_config.data_gpio_nums[1], rgb_panel_config.data_gpio_nums[2], rgb_panel_config.data_gpio_nums[3], rgb_panel_config.data_gpio_nums[4], rgb_panel_config.data_gpio_nums[5], rgb_panel_config.data_gpio_nums[6], rgb_panel_config.data_gpio_nums[7], rgb_panel_config.data_gpio_nums[8], rgb_panel_config.data_gpio_nums[9], rgb_panel_config.data_gpio_nums[10], rgb_panel_config.data_gpio_nums[11], rgb_panel_config.data_gpio_nums[12], rgb_panel_config.data_gpio_nums[13], rgb_panel_config.data_gpio_nums[14], rgb_panel_config.data_gpio_nums[15], rgb_panel_config.disp_gpio_num, rgb_panel_config.on_frame_trans_done, rgb_panel_config.user_ctx, rgb_panel_config.flags.disp_active_low, rgb_panel_config.flags.relax_on_idle, rgb_panel_config.flags.fb_in_psram);
log_d("refresh rate: %d Hz", (ST7701_PANEL_CONFIG_TIMINGS_PCLK_HZ * ST7701_PANEL_CONFIG_DATA_WIDTH) / (ST7701_PANEL_CONFIG_TIMINGS_H_RES + ST7701_PANEL_CONFIG_TIMINGS_HSYNC_PULSE_WIDTH + ST7701_PANEL_CONFIG_TIMINGS_HSYNC_BACK_PORCH + ST7701_PANEL_CONFIG_TIMINGS_HSYNC_FRONT_PORCH) / (ST7701_PANEL_CONFIG_TIMINGS_V_RES + ST7701_PANEL_CONFIG_TIMINGS_VSYNC_PULSE_WIDTH + ST7701_PANEL_CONFIG_TIMINGS_VSYNC_BACK_PORCH + ST7701_PANEL_CONFIG_TIMINGS_VSYNC_FRONT_PORCH) / SOC_LCD_RGB_DATA_WIDTH);
const esp_lcd_panel_dev_config_t panel_dev_config = {
.reset_gpio_num = ST7701_DEV_CONFIG_RESET_GPIO_NUM,
Expand Down
6 changes: 3 additions & 3 deletions src/lvgl_touch_cst816s_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void lvgl_touch_init(lv_indev_drv_t *drv)
.master = {
.clk_speed = CST816S_I2C_CONFIG_MASTER_CLK_SPEED},
.clk_flags = CST816S_I2C_CONFIG_CLK_FLAGS};
log_d("i2c_config: mode:%d, sda_io_num:%d, scl_io_num:%d, sda_pullup_en:%d, scl_pullup_en:%d, master: {clk_speed:%d}, clk_flags:%d", i2c_config.mode, i2c_config.sda_io_num, i2c_config.scl_io_num, i2c_config.sda_pullup_en, i2c_config.scl_pullup_en, i2c_config.master.clk_speed, i2c_config.clk_flags);
log_d("i2c_config: mode:%d, sda_io_num:%d, scl_io_num:%d, sda_pullup_en:%d, scl_pullup_en:%d, master:{clk_speed:%d}, clk_flags:%d", i2c_config.mode, i2c_config.sda_io_num, i2c_config.scl_io_num, i2c_config.sda_pullup_en, i2c_config.scl_pullup_en, i2c_config.master.clk_speed, i2c_config.clk_flags);
ESP_ERROR_CHECK(i2c_param_config(CST816S_I2C_HOST, &i2c_config));
ESP_ERROR_CHECK(i2c_driver_install(CST816S_I2C_HOST, i2c_config.mode, 0, 0, 0));

Expand All @@ -57,7 +57,7 @@ void lvgl_touch_init(lv_indev_drv_t *drv)
.flags = {
.dc_low_on_data = CST816S_IO_I2C_CONFIG_FLAGS_DC_LOW_ON_DATA,
.disable_control_phase = CST816S_IO_I2C_CONFIG_FLAGS_DISABLE_CONTROL_PHASE}};
log_d("io_i2c_config: dev_addr:0x%02x, control_phase_bytes:%d, user_ctx:0x%08x, dc_bit_offset:%d, lcd_cmd_bits:%d, lcd_param_bits:%d, flags: {.dc_low_on_data:%d, disable_control_phase:%d}", io_i2c_config.dev_addr, io_i2c_config.control_phase_bytes, io_i2c_config.user_ctx, io_i2c_config.dc_bit_offset, io_i2c_config.lcd_cmd_bits, io_i2c_config.lcd_param_bits, io_i2c_config.flags.dc_low_on_data, io_i2c_config.flags.disable_control_phase);
log_d("io_i2c_config: dev_addr:0x%02x, control_phase_bytes:%d, user_ctx:0x%08x, dc_bit_offset:%d, lcd_cmd_bits:%d, lcd_param_bits:%d, flags:{.dc_low_on_data:%d, disable_control_phase:%d}", io_i2c_config.dev_addr, io_i2c_config.control_phase_bytes, io_i2c_config.user_ctx, io_i2c_config.dc_bit_offset, io_i2c_config.lcd_cmd_bits, io_i2c_config.lcd_param_bits, io_i2c_config.flags.dc_low_on_data, io_i2c_config.flags.disable_control_phase);
esp_lcd_panel_io_handle_t io_handle;
ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)CST816S_I2C_HOST, &io_i2c_config, &io_handle));

Expand All @@ -73,7 +73,7 @@ void lvgl_touch_init(lv_indev_drv_t *drv)
// Unfortunately not supported
//.flags = {.swap_xy = CST816S_TOUCH_CONFIG_FLAGS_SWAP_XY, .mirror_x = CST816S_TOUCH_CONFIG_FLAGS_MIRROR_X, .mirror_y = CST816S_TOUCH_CONFIG_FLAGS_MIRROR_Y},
.user_data = io_handle};
log_d("touch_config: x_max:%d, y_max:%d, rst_gpio_num:%d, int_gpio_num:%d, levels: {reset:%d, interrupt:%d}, flags:{swap_xy:%d, mirror_x:%d, mirror_y:%d}, user_data:0x%08x", touch_config.x_max, touch_config.y_max, touch_config.rst_gpio_num, touch_config.int_gpio_num, touch_config.levels.reset, touch_config.levels.interrupt, touch_config.flags.swap_xy, touch_config.flags.mirror_x, touch_config.flags.mirror_y, touch_config.user_data);
log_d("touch_config: x_max:%d, y_max:%d, rst_gpio_num:%d, int_gpio_num:%d, levels:{reset:%d, interrupt:%d}, flags:{swap_xy:%d, mirror_x:%d, mirror_y:%d}, user_data:0x%08x", touch_config.x_max, touch_config.y_max, touch_config.rst_gpio_num, touch_config.int_gpio_num, touch_config.levels.reset, touch_config.levels.interrupt, touch_config.flags.swap_xy, touch_config.flags.mirror_x, touch_config.flags.mirror_y, touch_config.user_data);
esp_lcd_touch_handle_t touch_handle;
ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_cst816s(io_handle, &touch_config, &touch_handle));

Expand Down
Loading

0 comments on commit 0fbb2a9

Please sign in to comment.