From 5c7bfc223a912bcb3c9b33fcf788589cea12dd53 Mon Sep 17 00:00:00 2001 From: Th3maz1ng Date: Sat, 7 Jan 2023 23:16:31 +0100 Subject: [PATCH] Some refactoring --- .../lvgl/lvgl_port/lv_port_disp.c | 12 ++--- .../lvgl/lvgl_port/lv_port_indev.c | 2 +- .../lvgl/lvgl_port/lv_port_indev.c.bck | 52 ++----------------- .../lvgl/lvgl_port/lv_port_indev.h | 2 +- 4 files changed, 11 insertions(+), 57 deletions(-) diff --git a/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_disp.c b/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_disp.c index fab8804..7187ae8 100644 --- a/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_disp.c +++ b/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_disp.c @@ -63,12 +63,12 @@ void lv_port_disp_init(void) lcd_register_draw_finished_cb(&LCDConfig, &(lcd_draw_finished_cb), &display_driver); #if defined(W800) - LCDConfig.LCDPWMBacklightPin = WM_IO_PA_07; - LCDConfig.LCDClockPin = WM_IO_PB_06; - LCDConfig.LCDDataPin = WM_IO_PB_07; - LCDConfig.LCDChipSelectPin = WM_IO_PB_10; - LCDConfig.LCDDataCommandPin = WM_IO_PB_08; - LCDConfig.LCDResetPin = WM_IO_PB_09; + LCDConfig.LCDPWMBacklightPin = LCD_PWM_BACKLIGHT; + LCDConfig.LCDClockPin = LCD_CLOCK_CLOCK; + LCDConfig.LCDDataPin = LCD_DATA_LINE; + LCDConfig.LCDChipSelectPin = LCD_CHIP_SELECT; + LCDConfig.LCDDataCommandPin = LCD_DATA_COMMAND; + LCDConfig.LCDResetPin = LCD_RESET; #elif defined(W801) LCDConfig.LCDPWMBacklightPin = WM_IO_PA_08; LCDConfig.LCDClockPin = WM_IO_PA_09; diff --git a/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_indev.c b/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_indev.c index 0365cba..7cb1104 100644 --- a/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_indev.c +++ b/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_indev.c @@ -1,5 +1,5 @@ /** - * @file lv_port_indev_templ.c + * @file lv_port_indev.c * */ diff --git a/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_indev.c.bck b/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_indev.c.bck index 77d4f51..dd66b8f 100644 --- a/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_indev.c.bck +++ b/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_indev.c.bck @@ -11,7 +11,6 @@ *********************/ #include "lv_port_indev.h" #include "touchpad.h" -#include "i2c.h" /********************* * DEFINES @@ -68,18 +67,6 @@ lv_indev_t * indev_touchpad; * GLOBAL FUNCTIONS **********************/ -uint16_t x = 0, y = 0, action = 0; - -static void touch_screen_isr(void *arg) -{ - tls_clr_gpio_irq_status(WM_IO_PB_00); - uint8_t tc_data[9]; - i2c_read(0x15, 0x00, tc_data, sizeof tc_data); - x = ((tc_data[3] & 0x0f) << 8) | tc_data[4]; - y = ((tc_data[5] & 0x0f) << 8) | tc_data[6]; - action = tc_data[3] >> 6; -} - void lv_port_indev_init(void) { /** @@ -101,10 +88,7 @@ void lv_port_indev_init(void) * -----------------*/ /*Initialize your touchpad if you have*/ - //touchpad_init(); - tls_gpio_cfg(WM_IO_PB_00, WM_GPIO_DIR_INPUT, WM_GPIO_ATTR_PULLHIGH); - tls_gpio_isr_register(WM_IO_PB_00, &(touch_screen_isr), NULL); - tls_gpio_irq_enable(WM_IO_PB_00, WM_GPIO_IRQ_TRIG_FALLING_EDGE); + touchpad_init(); /*Register a touchpad input device*/ lv_indev_drv_init(&indev_drv); @@ -203,7 +187,7 @@ static void touchpad_init(void) } /*Will be called by the library to read the touchpad*/ -/*static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) +static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) { static lv_coord_t last_x = 0; static lv_coord_t last_y = 0; @@ -220,40 +204,15 @@ static void touchpad_init(void) // Set the last pressed coordinates data->point.x = 240-last_y; data->point.y = last_x; -}*/ - -static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) -{ - static lv_coord_t last_x = 0; - static lv_coord_t last_y = 0; - - // Save the pressed coordinates and the state - if(touchpad_is_pressed()) { - last_x = x; - last_y = y; - data->state = LV_INDEV_STATE_PR; - } - else { - data->state = LV_INDEV_STATE_REL; - } - - // Set the last pressed coordinates - data->point.x = 239-last_x; - data->point.y = 239-last_y; } /*Return true is the touchpad is pressed*/ -/*static bool touchpad_is_pressed(void) +static bool touchpad_is_pressed(void) { // Your code comes here bool val = bsp_touchpad_is_pressed(); // printf("---> %d\n",val); return val; -}*/ - -static bool touchpad_is_pressed(void) -{ - return action == 2; } /*Get the x and y coordinates if the touchpad is pressed*/ @@ -266,11 +225,6 @@ static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y) // printf("---> x:%d y:%d\n", (*x), (*y)); } -/*static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y) -{ - -}*/ - // /*------------------ // * Mouse // * -----------------*/ diff --git a/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_indev.h b/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_indev.h index 21f8b7b..2d2008b 100644 --- a/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_indev.h +++ b/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_port_indev.h @@ -1,6 +1,6 @@ /** - * @file lv_port_indev_templ.h + * @file lv_port_indev.h * */