Minor fix for hal indev module (#2124)
* fix(hal indev): correct the typo and adjust the alignment * fix(hal indev): remove the unnecessary forward declaration * fix(hal indev): relayout the bitfiled to save space * fix(hal indev): remove the unnecessary memory zero * fix(hal indev): remove the initial hardcode value for scroll_throw
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file hal_indev.c
|
||||
* @file lv_hal_indev.c
|
||||
*
|
||||
* @description Input device HAL interface
|
||||
*
|
||||
@@ -26,7 +26,6 @@
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void lv_indev_read_timer_cb(lv_timer_t * timer);
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
@@ -60,8 +59,8 @@ void lv_indev_drv_init(lv_indev_drv_t * driver)
|
||||
lv_memset_00(driver, sizeof(lv_indev_drv_t));
|
||||
|
||||
driver->type = LV_INDEV_TYPE_NONE;
|
||||
driver->scroll_limit = LV_INDEV_DEF_SCROLL_LIMIT;
|
||||
driver->scroll_throw = 3;//LV_INDEV_DEF_SCROLL_THROW;
|
||||
driver->scroll_limit = LV_INDEV_DEF_SCROLL_LIMIT;
|
||||
driver->scroll_throw = LV_INDEV_DEF_SCROLL_THROW;
|
||||
driver->long_press_time = LV_INDEV_DEF_LONG_PRESS_TIME;
|
||||
driver->long_press_rep_time = LV_INDEV_DEF_LONG_PRESS_REP_TIME;
|
||||
driver->gesture_limit = LV_INDEV_DEF_GESTURE_LIMIT;
|
||||
@@ -94,9 +93,6 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver)
|
||||
lv_memcpy(&indev->driver, driver, sizeof(lv_indev_drv_t));
|
||||
|
||||
indev->proc.reset_query = 1;
|
||||
indev->cursor = NULL;
|
||||
indev->group = NULL;
|
||||
indev->btn_points = NULL;
|
||||
indev->driver.read_timer = lv_timer_create(lv_indev_read_timer_cb, LV_INDEV_DEF_READ_PERIOD, indev);
|
||||
|
||||
return indev;
|
||||
@@ -138,7 +134,7 @@ bool _lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
|
||||
lv_memset_00(data, sizeof(lv_indev_data_t));
|
||||
|
||||
/* For touchpad sometimes users don't the last pressed coordinate on release.
|
||||
/* For touchpad sometimes users don't set the last pressed coordinate on release.
|
||||
* So be sure a coordinates are initialized to the last point */
|
||||
if(indev->driver.type == LV_INDEV_TYPE_POINTER) {
|
||||
data->point.x = indev->proc.types.pointer.act_point.x;
|
||||
@@ -151,7 +147,6 @@ bool _lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
/*For compatibility assume that used button was enter (encoder push) */
|
||||
else if(indev->driver.type == LV_INDEV_TYPE_ENCODER) {
|
||||
data->key = LV_KEY_ENTER;
|
||||
data->enc_diff = 0;
|
||||
}
|
||||
|
||||
if(indev->driver.read_cb) {
|
||||
|
||||
@@ -27,10 +27,10 @@ extern "C" {
|
||||
*********************/
|
||||
|
||||
/* Drag threshold in pixels */
|
||||
#define LV_INDEV_DEF_SCROLL_LIMIT 10
|
||||
#define LV_INDEV_DEF_SCROLL_LIMIT 10
|
||||
|
||||
/* Drag throw slow-down in [%]. Greater value -> faster slow-down */
|
||||
#define LV_INDEV_DEF_SCROLL_THROW 10
|
||||
#define LV_INDEV_DEF_SCROLL_THROW 10
|
||||
|
||||
/* Long press time in milliseconds.
|
||||
* Time to send `LV_EVENT_LONG_PRESSSED`) */
|
||||
@@ -54,6 +54,7 @@ extern "C" {
|
||||
|
||||
struct _lv_obj_t;
|
||||
struct _lv_disp_t;
|
||||
struct _lv_group_t;
|
||||
struct _lv_indev_t;
|
||||
struct _lv_indev_drv_t;
|
||||
|
||||
@@ -119,7 +120,7 @@ typedef struct _lv_indev_drv_t {
|
||||
/**< Pointer to the assigned display*/
|
||||
struct _lv_disp_t * disp;
|
||||
|
||||
/**< Task to read the periodically read the input device*/
|
||||
/**< Timer to periodically read the input device*/
|
||||
lv_timer_t * read_timer;
|
||||
|
||||
/**< Number of pixels to slide before actually drag the object*/
|
||||
@@ -146,25 +147,31 @@ typedef struct _lv_indev_drv_t {
|
||||
*/
|
||||
typedef struct _lv_indev_proc_t {
|
||||
lv_indev_state_t state; /**< Current state of the input device. */
|
||||
/*Flags*/
|
||||
uint8_t long_pr_sent : 1;
|
||||
uint8_t reset_query : 1;
|
||||
uint8_t disabled : 1;
|
||||
uint8_t wait_until_release : 1;
|
||||
|
||||
union {
|
||||
struct {
|
||||
/*Pointer and button data*/
|
||||
lv_point_t act_point; /**< Current point of input device. */
|
||||
lv_point_t last_point; /**< Last point of input device. */
|
||||
lv_point_t vect; /**< Difference between `act_point` and `last_point`. */
|
||||
lv_point_t scroll_sum; /*Count the dragged pixels to check LV_INDEV_DEF_DRAG_LIMIT*/
|
||||
lv_point_t scroll_sum; /*Count the dragged pixels to check LV_INDEV_DEF_SCROLL_LIMIT*/
|
||||
lv_point_t scroll_throw_vect;
|
||||
lv_point_t scroll_throw_vect_ori;
|
||||
struct _lv_obj_t * act_obj; /*The object being pressed*/
|
||||
struct _lv_obj_t * last_obj; /*The last object which was pressed*/
|
||||
struct _lv_obj_t * scroll_obj; /*The object being scrolled*/
|
||||
struct _lv_obj_t * scroll_obj; /*The object being scrolled*/
|
||||
struct _lv_obj_t * last_pressed; /*The lastly pressed object*/
|
||||
lv_area_t scroll_area;
|
||||
|
||||
lv_gesture_dir_t gesture_dir;
|
||||
lv_point_t gesture_sum; /*Count the gesture pixels to check LV_INDEV_DEF_GESTURE_LIMIT*/
|
||||
/*Flags*/
|
||||
lv_indev_scroll_dir_t scroll_dir : 2;
|
||||
lv_indev_scroll_dir_t scroll_dir : 2;
|
||||
lv_gesture_dir_t gesture_dir : 2;
|
||||
uint8_t gesture_sent : 1;
|
||||
} pointer;
|
||||
struct {
|
||||
@@ -176,17 +183,8 @@ typedef struct _lv_indev_proc_t {
|
||||
|
||||
uint32_t pr_timestamp; /**< Pressed time stamp*/
|
||||
uint32_t longpr_rep_timestamp; /**< Long press repeat time stamp*/
|
||||
|
||||
/*Flags*/
|
||||
uint8_t long_pr_sent : 1;
|
||||
uint8_t reset_query : 1;
|
||||
uint8_t disabled : 1;
|
||||
uint8_t wait_until_release : 1;
|
||||
} lv_indev_proc_t;
|
||||
|
||||
struct _lv_obj_t;
|
||||
struct _lv_group_t;
|
||||
|
||||
/** The main input device descriptor with driver, runtime data ('proc') and some additional
|
||||
* information*/
|
||||
typedef struct _lv_indev_t {
|
||||
|
||||
Reference in New Issue
Block a user