From c14dbe8a2eda81ef0da10bb6c2a725b328cd431a Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 9 May 2022 13:31:31 -0400 Subject: [PATCH] [lvgl] beautify code --- .../applications/lvgl/lv_port_indev.c | 16 ++++++++-------- .../applications/lvgl/lv_port_indev.h | 4 ---- .../applications/lvgl/lv_port_indev.c | 5 ++--- .../applications/lvgl/lv_port_indev.h | 4 ---- .../applications/lvgl/lv_port_indev.c | 6 +++--- .../applications/lvgl/lv_port_indev.h | 4 ---- .../applications/lvgl/lv_port_indev.c | 5 ++--- .../applications/lvgl/lv_port_indev.h | 4 ---- 8 files changed, 15 insertions(+), 33 deletions(-) diff --git a/bsp/imxrt/imxrt1060-nxp-evk/applications/lvgl/lv_port_indev.c b/bsp/imxrt/imxrt1060-nxp-evk/applications/lvgl/lv_port_indev.c index e873af6552..6eef6b78d7 100644 --- a/bsp/imxrt/imxrt1060-nxp-evk/applications/lvgl/lv_port_indev.c +++ b/bsp/imxrt/imxrt1060-nxp-evk/applications/lvgl/lv_port_indev.c @@ -8,13 +8,14 @@ * 2021-10-18 Meco Man The first version */ #include -#include #include static lv_indev_state_t last_state = LV_INDEV_STATE_REL; static rt_int16_t last_x = 0; static rt_int16_t last_y = 0; +lv_indev_t * touch_indev; + static void input_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data) { data->point.x = last_x; @@ -29,16 +30,15 @@ void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state) last_y = LV_HOR_RES_MAX - y; } -lv_indev_t * button_indev; - void lv_port_indev_init(void) { static lv_indev_drv_t indev_drv; - lv_indev_drv_init(&indev_drv); /*Basic initialization*/ - indev_drv.type = LV_INDEV_TYPE_POINTER; - indev_drv.read_cb = input_read; + /* Has not supported touch sensor! */ + // lv_indev_drv_init(&indev_drv); /*Basic initialization*/ + // indev_drv.type = LV_INDEV_TYPE_POINTER; + // indev_drv.read_cb = input_read; - /*Register the driver in LVGL and save the created input device object*/ - button_indev = lv_indev_drv_register(&indev_drv); + // /*Register the driver in LVGL and save the created input device object*/ + // touch_indev = lv_indev_drv_register(&indev_drv); } diff --git a/bsp/imxrt/imxrt1060-nxp-evk/applications/lvgl/lv_port_indev.h b/bsp/imxrt/imxrt1060-nxp-evk/applications/lvgl/lv_port_indev.h index bc5238123f..0764bb014e 100644 --- a/bsp/imxrt/imxrt1060-nxp-evk/applications/lvgl/lv_port_indev.h +++ b/bsp/imxrt/imxrt1060-nxp-evk/applications/lvgl/lv_port_indev.h @@ -14,10 +14,6 @@ extern "C" { #endif -#include - -extern lv_indev_t * button_indev; - void lv_port_indev_init(void); void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state); diff --git a/bsp/raspberry-pico/applications/lvgl/lv_port_indev.c b/bsp/raspberry-pico/applications/lvgl/lv_port_indev.c index 0beae12763..cb791e5ca6 100644 --- a/bsp/raspberry-pico/applications/lvgl/lv_port_indev.c +++ b/bsp/raspberry-pico/applications/lvgl/lv_port_indev.c @@ -22,6 +22,8 @@ #define BUTTON2_PIN 16 #define BUTTON_WKUP_PIN 20 +lv_indev_t * button_indev; + /*Test if `id` button is pressed or not*/ static bool button_is_pressed(uint8_t id) { @@ -83,9 +85,6 @@ void button_read(lv_indev_drv_t * drv, lv_indev_data_t*data) data->btn_id = last_btn; /*Save the last button*/ } - -lv_indev_t * button_indev; - void lv_port_indev_init(void) { static lv_indev_drv_t indev_drv; diff --git a/bsp/raspberry-pico/applications/lvgl/lv_port_indev.h b/bsp/raspberry-pico/applications/lvgl/lv_port_indev.h index d15f0e5cfa..3fa1766800 100644 --- a/bsp/raspberry-pico/applications/lvgl/lv_port_indev.h +++ b/bsp/raspberry-pico/applications/lvgl/lv_port_indev.h @@ -14,10 +14,6 @@ extern "C" { #endif -#include - -extern lv_indev_t * button_indev; - void lv_port_indev_init(void); void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state); diff --git a/bsp/stm32/stm32f469-st-disco/applications/lvgl/lv_port_indev.c b/bsp/stm32/stm32f469-st-disco/applications/lvgl/lv_port_indev.c index 50022c4edb..8014b183e4 100644 --- a/bsp/stm32/stm32f469-st-disco/applications/lvgl/lv_port_indev.c +++ b/bsp/stm32/stm32f469-st-disco/applications/lvgl/lv_port_indev.c @@ -17,6 +17,8 @@ static lv_indev_state_t last_state = LV_INDEV_STATE_REL; static rt_int16_t last_x = 0; static rt_int16_t last_y = 0; +lv_indev_t * touch_indev; + static void input_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data) { data->point.x = last_x; @@ -31,8 +33,6 @@ void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state) last_y = LCD_HEIGHT - y; } -lv_indev_t * button_indev; - void lv_port_indev_init(void) { static lv_indev_drv_t indev_drv; @@ -42,5 +42,5 @@ void lv_port_indev_init(void) indev_drv.read_cb = input_read; /*Register the driver in LVGL and save the created input device object*/ - button_indev = lv_indev_drv_register(&indev_drv); + touch_indev = lv_indev_drv_register(&indev_drv); } diff --git a/bsp/stm32/stm32f469-st-disco/applications/lvgl/lv_port_indev.h b/bsp/stm32/stm32f469-st-disco/applications/lvgl/lv_port_indev.h index d15f0e5cfa..3fa1766800 100644 --- a/bsp/stm32/stm32f469-st-disco/applications/lvgl/lv_port_indev.h +++ b/bsp/stm32/stm32f469-st-disco/applications/lvgl/lv_port_indev.h @@ -14,10 +14,6 @@ extern "C" { #endif -#include - -extern lv_indev_t * button_indev; - void lv_port_indev_init(void); void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state); diff --git a/bsp/stm32/stm32l475-atk-pandora/applications/lvgl/lv_port_indev.c b/bsp/stm32/stm32l475-atk-pandora/applications/lvgl/lv_port_indev.c index 2f24642b8a..26f509efaf 100644 --- a/bsp/stm32/stm32l475-atk-pandora/applications/lvgl/lv_port_indev.c +++ b/bsp/stm32/stm32l475-atk-pandora/applications/lvgl/lv_port_indev.c @@ -17,6 +17,8 @@ #define BUTTON2_PIN GET_PIN(D, 8) #define BUTTON_WKUP_PIN GET_PIN(C, 13) +lv_indev_t * button_indev; + /*Test if `id` button is pressed or not*/ static bool button_is_pressed(uint8_t id) { @@ -78,9 +80,6 @@ void button_read(lv_indev_drv_t * drv, lv_indev_data_t*data) data->btn_id = last_btn; /*Save the last button*/ } - -lv_indev_t * button_indev; - void lv_port_indev_init(void) { static lv_indev_drv_t indev_drv; diff --git a/bsp/stm32/stm32l475-atk-pandora/applications/lvgl/lv_port_indev.h b/bsp/stm32/stm32l475-atk-pandora/applications/lvgl/lv_port_indev.h index f604e3c5b1..7599bb899d 100644 --- a/bsp/stm32/stm32l475-atk-pandora/applications/lvgl/lv_port_indev.h +++ b/bsp/stm32/stm32l475-atk-pandora/applications/lvgl/lv_port_indev.h @@ -14,10 +14,6 @@ extern "C" { #endif -#include - -extern lv_indev_t * button_indev; - void lv_port_indev_init(void); #ifdef __cplusplus