|
@@ -17,6 +17,8 @@
|
|
|
#include "esp_log.h"
|
|
|
#include "lvgl.h"
|
|
|
#include "ui.h"
|
|
|
+#include "component/CST816D.h"
|
|
|
+
|
|
|
#if CONFIG_EXAMPLE_LCD_CONTROLLER_ILI9341
|
|
|
#include "esp_lcd_ili9341.h"
|
|
|
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_GC9A01
|
|
@@ -47,6 +49,17 @@ static const char *TAG = "example";
|
|
|
#define EXAMPLE_PIN_NUM_BK_LIGHT 3
|
|
|
#define EXAMPLE_PIN_NUM_TOUCH_CS 1
|
|
|
|
|
|
+#define I2C_SDA 4
|
|
|
+#define I2C_SCL 5
|
|
|
+#define TP_INT 0
|
|
|
+#define TP_RST -1
|
|
|
+CST816D_t CST816D = {
|
|
|
+ .int_pin = TP_INT,
|
|
|
+ .rst_pin= TP_RST,
|
|
|
+ .scl_pin = I2C_SCL,
|
|
|
+ .sda_pin = I2C_SDA,
|
|
|
+ .i2c_port = I2C_NUM_0
|
|
|
+ };
|
|
|
// The pixel number in horizontal and vertical
|
|
|
#if CONFIG_EXAMPLE_LCD_CONTROLLER_ILI9341
|
|
|
#define EXAMPLE_LCD_H_RES 240
|
|
@@ -90,6 +103,7 @@ static void example_lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_
|
|
|
/* Rotate display and touch, when rotated screen in LVGL. Called when driver parameters are updated. */
|
|
|
static void example_lvgl_port_update_callback(lv_disp_drv_t *drv)
|
|
|
{
|
|
|
+ printf("vao\n");
|
|
|
esp_lcd_panel_handle_t panel_handle = (esp_lcd_panel_handle_t) drv->user_data;
|
|
|
|
|
|
switch (drv->rotated) {
|
|
@@ -164,9 +178,32 @@ static void example_increase_lvgl_tick(void *arg)
|
|
|
/* Tell LVGL how many milliseconds has elapsed */
|
|
|
lv_tick_inc(EXAMPLE_LVGL_TICK_PERIOD_MS);
|
|
|
}
|
|
|
+void my_touchpad_read( lv_indev_drv_t * indev_driver, lv_indev_data_t * data )
|
|
|
+{
|
|
|
+ uint16_t touchX = 0, touchY = 0;
|
|
|
+ uint8_t gesture;
|
|
|
+
|
|
|
+ bool touched = CST816D_getTouch( &CST816D,&touchX, &touchY, &gesture );
|
|
|
+ printf("my touch read\n");
|
|
|
+ if( !touched )
|
|
|
+ {
|
|
|
+ data->state = LV_INDEV_STATE_REL;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data->state = LV_INDEV_STATE_PR;
|
|
|
|
|
|
+ /*Set the coordinates*/
|
|
|
+ data->point.x = touchX;
|
|
|
+ data->point.y = touchY;
|
|
|
+
|
|
|
+ printf( "Data x : %d\n", touchX );
|
|
|
+ printf( "Data y : %d\n", touchY );
|
|
|
+ }
|
|
|
+}
|
|
|
void app_main(void)
|
|
|
{
|
|
|
+
|
|
|
static lv_disp_draw_buf_t disp_buf; // contains internal graphic buffer(s) called draw buffer(s)
|
|
|
static lv_disp_drv_t disp_drv; // contains callback functions
|
|
|
|
|
@@ -248,10 +285,10 @@ void app_main(void)
|
|
|
|
|
|
#if CONFIG_EXAMPLE_LCD_TOUCH_CONTROLLER_STMPE610
|
|
|
ESP_LOGI(TAG, "Initialize touch controller STMPE610");
|
|
|
- ESP_ERROR_CHECK(esp_lcd_touch_new_spi_stmpe610(tp_io_handle, &tp_cfg, &tp));
|
|
|
+ // ESP_ERROR_CHECK(esp_lcd_touch_new_spi_stmpe610(tp_io_handle, &tp_cfg, &tp));
|
|
|
#endif // CONFIG_EXAMPLE_LCD_TOUCH_CONTROLLER_STMPE610
|
|
|
#endif // CONFIG_EXAMPLE_LCD_TOUCH_ENABLED
|
|
|
-
|
|
|
+
|
|
|
ESP_LOGI(TAG, "Turn on LCD backlight");
|
|
|
gpio_set_level(EXAMPLE_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_ON_LEVEL);
|
|
|
|
|
@@ -287,21 +324,37 @@ void app_main(void)
|
|
|
ESP_ERROR_CHECK(esp_timer_start_periodic(lvgl_tick_timer, EXAMPLE_LVGL_TICK_PERIOD_MS * 1000));
|
|
|
|
|
|
#if CONFIG_EXAMPLE_LCD_TOUCH_ENABLED
|
|
|
+ CST816D_init(&CST816D);
|
|
|
static lv_indev_drv_t indev_drv; // Input device driver (Touch)
|
|
|
lv_indev_drv_init(&indev_drv);
|
|
|
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
|
|
indev_drv.disp = disp;
|
|
|
- indev_drv.read_cb = example_lvgl_touch_cb;
|
|
|
+ indev_drv.read_cb = my_touchpad_read;
|
|
|
indev_drv.user_data = tp;
|
|
|
|
|
|
lv_indev_drv_register(&indev_drv);
|
|
|
#endif
|
|
|
+ CST816D_init(&CST816D);
|
|
|
+ static lv_indev_drv_t indev_drv; // Input device driver (Touch)
|
|
|
+ lv_indev_drv_init(&indev_drv);
|
|
|
+ indev_drv.type = LV_INDEV_TYPE_POINTER;
|
|
|
+ indev_drv.disp = disp;
|
|
|
+ indev_drv.read_cb = my_touchpad_read;
|
|
|
+ indev_drv.user_data =NULL;
|
|
|
|
|
|
+ lv_indev_drv_register(&indev_drv);
|
|
|
+ // static lv_indev_drv_t indev_drv;
|
|
|
+ // lv_indev_drv_init( &indev_drv );
|
|
|
+ // indev_drv.type = LV_INDEV_TYPE_POINTER;
|
|
|
+ // indev_drv.disp = disp;
|
|
|
+ // indev_drv.read_cb = my_touchpad_read;
|
|
|
+ // indev_drv.user_data = NULL;
|
|
|
+ // lv_indev_drv_register( &indev_drv );
|
|
|
ESP_LOGI(TAG, "Display LVGL Meter Widget");
|
|
|
- // example_lvgl_demo_ui(disp);
|
|
|
+ example_lvgl_demo_ui(disp);
|
|
|
// ui_Screen1_screen_init();
|
|
|
// lv_example_1();
|
|
|
- ui_init();
|
|
|
+ // ui_init();
|
|
|
while (1) {
|
|
|
// raise the task priority of LVGL and/or reduce the handler period can improve the performance
|
|
|
vTaskDelay(pdMS_TO_TICKS(10));
|