From 964499a06ff04aa7e1d7ae5cfa4646468b8f6412 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 20 Oct 2017 22:11:18 +0200 Subject: [PATCH] lv_hal: update function names and typedefs --- lv_hal/lv_hal_disp.c | 13 +++--- lv_hal/lv_hal_disp.h | 15 ++++--- lv_hal/lv_hal_indev.c | 12 +++--- lv_hal/lv_hal_indev.h | 48 ++++++++++----------- lv_obj/lv_indev.c | 97 ++++++++++++++++++++----------------------- lv_obj/lv_obj.c | 2 +- lv_obj/lv_obj.h | 4 +- 7 files changed, 93 insertions(+), 98 deletions(-) diff --git a/lv_hal/lv_hal_disp.c b/lv_hal/lv_hal_disp.c index 1dee80cae..762a97ceb 100644 --- a/lv_hal/lv_hal_disp.c +++ b/lv_hal/lv_hal_disp.c @@ -45,14 +45,14 @@ static lv_disp_t *active; * @param driver Display driver structure * @return pointer to the new display or NULL on error */ -lv_disp_t * lv_disp_drv_register(lv_hal_disp_drv_t *driver) +lv_disp_t * lv_disp_register(lv_disp_drv_t *driver) { lv_disp_t *node; node = dm_alloc(sizeof(lv_disp_t)); if (!node) return NULL; - memcpy(&node->drv,driver, sizeof(lv_hal_disp_drv_t)); + memcpy(&node->driver,driver, sizeof(lv_disp_drv_t)); node->next = NULL; /* Set first display as active by default */ @@ -66,6 +66,7 @@ lv_disp_t * lv_disp_drv_register(lv_hal_disp_drv_t *driver) return node; } + /** * Set Active Display by ID * @@ -111,7 +112,7 @@ lv_disp_t * lv_disp_next(lv_disp_t * disp) void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, color_t color) { if(active == NULL) return; - if(active->drv.fill != NULL) active->drv.fill(x1, y1, x2, y2, color); + if(active->driver.fill != NULL) active->driver.fill(x1, y1, x2, y2, color); } /** @@ -125,7 +126,7 @@ void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, color_t color) void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const color_t * color_map) { if(active == NULL) return; - if(active->drv.map != NULL) active->drv.map(x1, y1, x2, y2, color_map); + if(active->driver.map != NULL) active->driver.map(x1, y1, x2, y2, color_map); } @@ -139,12 +140,12 @@ void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const color_t * void lv_disp_copy(color_t * dest, const color_t * src, uint32_t length, opa_t opa) { if(active == NULL) return; - if(active->drv.copy != NULL) active->drv.copy(dest, src, length, opa); + if(active->driver.copy != NULL) active->driver.copy(dest, src, length, opa); } bool lv_disp_is_accelerated(void) { - if(active->drv.copy) return true; + if(active->driver.copy) return true; else return false; } diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index 8e2ce12e6..46d677767 100644 --- a/lv_hal/lv_hal_disp.h +++ b/lv_hal/lv_hal_disp.h @@ -32,17 +32,16 @@ extern "C" { * Display Driver structure to be registered by HAL */ typedef struct _disp_drv_t { - const char *name; - int32_t h_res; - int32_t v_res; + int32_t hor_res; + int32_t ver_res; void (*fill)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, color_t color); void (*map)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const color_t * color_p); void (*copy)(color_t * dest, const color_t * src, uint32_t length, opa_t opa); -} lv_hal_disp_drv_t; +} lv_disp_drv_t; -typedef struct _disp_drv_node_t { - lv_hal_disp_drv_t drv; - struct _disp_drv_node_t *next; +typedef struct _disp_t { + lv_disp_drv_t driver; + struct _disp_t *next; } lv_disp_t; /********************** @@ -55,7 +54,7 @@ typedef struct _disp_drv_node_t { * @param driver Display driver structure * @return 0 on success, -ve on error */ -lv_disp_t * lv_disp_drv_register(lv_hal_disp_drv_t *driver); +lv_disp_t * lv_disp_register(lv_disp_drv_t *driver); /** * Set Active Display by ID diff --git a/lv_hal/lv_hal_indev.c b/lv_hal/lv_hal_indev.c index 861ae8c42..0cba8e348 100644 --- a/lv_hal/lv_hal_indev.c +++ b/lv_hal/lv_hal_indev.c @@ -42,14 +42,14 @@ static lv_indev_t *indev_list = NULL; * @param driver Input Device driver structure * @return pointer to the new input device */ -lv_indev_t * lv_indev_register(lv_hal_indev_drv_t *driver) +lv_indev_t * lv_indev_register(lv_indev_drv_t *driver) { lv_indev_t *node; node = dm_alloc(sizeof(lv_indev_t)); if (!node) return NULL; - memcpy(&node->drv, driver, sizeof(lv_hal_indev_drv_t)); + memcpy(&node->driver, driver, sizeof(lv_indev_drv_t)); node->next = NULL; @@ -88,14 +88,14 @@ lv_indev_t * lv_indev_next(lv_indev_t * indev) * @param data input device will write its data here * @return false: no more data; true: there more data to read (buffered) */ -bool lv_indev_read(lv_indev_t * indev, lv_hal_indev_data_t *data) +bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t *data) { bool cont = false; - if(indev->drv.get_data) { - cont = indev->drv.get_data(data); + if(indev->driver.get_data) { + cont = indev->driver.get_data(data); } else { - memset(data, 0, sizeof(lv_hal_indev_data_t)); + memset(data, 0, sizeof(lv_indev_data_t)); } return cont; diff --git a/lv_hal/lv_hal_indev.h b/lv_hal/lv_hal_indev.h index 4b82f93ed..b70f7de38 100644 --- a/lv_hal/lv_hal_indev.h +++ b/lv_hal/lv_hal_indev.h @@ -30,17 +30,17 @@ extern "C" { /*Possible input device types*/ typedef enum { - LV_HAL_INDEV_TYPE_TOUCH, /*Touch pad*/ - LV_HAL_INDEV_TYPE_POINTER, /*Mouse or similar pointer device*/ - LV_HAL_INDEV_TYPE_KEYPAD, /*Keypad or keyboard*/ - LV_HAL_INDEV_TYPE_BUTTON, /*Hardware button assigned to a point on the screen*/ + LV_INDEV_TYPE_TOUCH, /*Touch pad*/ + LV_INDEV_TYPE_POINTER, /*Mouse or similar pointer device*/ + LV_INDEV_TYPE_KEYPAD, /*Keypad or keyboard*/ + LV_INDEV_TYPE_BUTTON, /*Hardware button assigned to a point on the screen*/ } lv_hal_indev_type_t; /*State for input devices*/ typedef enum { - LV_HAL_INDEV_STATE_PRESS, - LV_HAL_INDEV_STATE_RELEASE -}lv_hal_indev_state_t; + LV_INDEV_EVENT_RELEASED, + LV_INDEV_EVENT_PRESSED +}lv_indev_event_t; /*Data read from an input device. */ typedef struct { @@ -48,44 +48,44 @@ typedef struct { point_t point; /*For INDEV_TYPE_TOUCH, INDEV_TYPE_POINTER, INDEV_TYPE_BUTTON*/ uint32_t key; /*For INDEV_TYPE_BUTTON*/ }; - lv_hal_indev_state_t state; -}lv_hal_indev_data_t; + lv_indev_event_t state; +}lv_indev_data_t; /*Initialized by the user and registered by 'lv_hal_indev_drv_register'*/ typedef struct { const char * name; /*Input device name*/ lv_hal_indev_type_t type; /*Input device type*/ - bool (*get_data)(lv_hal_indev_data_t * data); /*Function pointer to read data. Return 'true' if there is still data to be read (buffered)*/ -}lv_hal_indev_drv_t; + bool (*get_data)(lv_indev_data_t * data); /*Function pointer to read data. Return 'true' if there is still data to be read (buffered)*/ +}lv_indev_drv_t; struct __LV_OBJ_T; typedef struct _lv_indev_state_t { - bool pressed; + lv_indev_event_t event; point_t act_point; point_t last_point; point_t vect; point_t vect_sum; struct __LV_OBJ_T * act_obj; struct __LV_OBJ_T * last_obj; - uint32_t press_time_stamp; - uint32_t lpr_rep_time_stamp; + uint32_t press_timestamp; + uint32_t longpress_repeat_timestamp; /*Flags*/ - uint8_t drag_range_out :1; - uint8_t drag_in_prog :1; - uint8_t long_press_sent :1; - uint8_t wait_release :1; - uint8_t reset_qry :1; - uint8_t disable :1; + uint8_t drag_range_out :1; + uint8_t drag_in_prog :1; + uint8_t long_press_sent :1; + uint8_t wait_unil_release :1; + uint8_t reset_query :1; + uint8_t disabled :1; }lv_indev_state_t; typedef struct _lv_indev_t { - lv_hal_indev_drv_t drv; + lv_indev_drv_t driver; lv_indev_state_t state; - struct __LV_OBJ_T * cursor; + struct __LV_OBJ_T *cursor; struct _lv_indev_t *next; } lv_indev_t; @@ -99,7 +99,7 @@ typedef struct _lv_indev_t { * @param driver Input Device driver structure * @return 0 on success, -ve on error */ -lv_indev_t * lv_indev_register(lv_hal_indev_drv_t *driver); +lv_indev_t * lv_indev_register(lv_indev_drv_t *driver); /** @@ -107,7 +107,7 @@ lv_indev_t * lv_indev_register(lv_hal_indev_drv_t *driver); * @param data input device data * @return false: no more data; true: there more data to read (buffered) */ -bool lv_indev_read(lv_indev_t * indev, lv_hal_indev_data_t *data); +bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t *data); /** * Get the next input device. diff --git a/lv_obj/lv_indev.c b/lv_obj/lv_indev.c index 7d23e8249..dd9f0176b 100644 --- a/lv_obj/lv_indev.c +++ b/lv_obj/lv_indev.c @@ -27,7 +27,7 @@ * STATIC PROTOTYPES **********************/ static void indev_proc_task(void * param); -static void indev_proc_point(lv_indev_state_t * indev, cord_t x, cord_t y); +static void indev_proc_point(lv_indev_state_t * indev); static void indev_proc_press(lv_indev_state_t * state); static void disi_proc_release(lv_indev_state_t * state); static lv_obj_t * indev_search_obj(const lv_indev_state_t * indev, lv_obj_t * obj); @@ -77,11 +77,11 @@ lv_indev_t * lv_indev_get_act(void) */ void lv_indev_reset(lv_indev_t * indev) { - if(indev) indev->state.reset_qry = 1; + if(indev) indev->state.reset_query = 1; else { lv_indev_t * i = lv_indev_next(NULL); while(i) { - i->state.reset_qry = 1; + i->state.reset_query = 1; i = lv_indev_next(i); } } @@ -94,8 +94,8 @@ void lv_indev_reset(lv_indev_t * indev) void lv_indev_reset_lpr(lv_indev_t * indev_proc) { indev_proc->state.long_press_sent = 0; - indev_proc->state.lpr_rep_time_stamp = lv_tick_get(); - indev_proc->state.press_time_stamp = lv_tick_get(); + indev_proc->state.longpress_repeat_timestamp = lv_tick_get(); + indev_proc->state.press_timestamp = lv_tick_get(); } /** @@ -108,7 +108,7 @@ void lv_indev_enable(lv_hal_indev_type_t type, bool enable) lv_indev_t *i = lv_indev_next(NULL); while (i) { - if (i->drv.type == type) i->state.disable = enable == false ? 1 : 0; + if (i->driver.type == type) i->state.disabled = enable == false ? 1 : 0; i = lv_indev_next(i); } } @@ -164,7 +164,7 @@ void lv_indev_get_vect(lv_indev_t * indev, point_t * point) */ void lv_indev_wait_release(lv_indev_t * indev) { - indev->state.wait_release = 1; + indev->state.wait_unil_release = 1; } /********************** @@ -177,7 +177,7 @@ void lv_indev_wait_release(lv_indev_t * indev) */ static void indev_proc_task(void * param) { - lv_hal_indev_data_t data; + lv_indev_data_t data; lv_indev_t * i; i = lv_indev_next(NULL); @@ -186,23 +186,23 @@ static void indev_proc_task(void * param) indev_act = i; /*Handle reset query before processing the point*/ - if(i->state.reset_qry) { + if(i->state.reset_query) { i->state.act_obj = NULL; i->state.last_obj = NULL; i->state.drag_range_out = 0; i->state.drag_in_prog = 0; i->state.long_press_sent = 0; - i->state.press_time_stamp = 0; - i->state.lpr_rep_time_stamp = 0; + i->state.press_timestamp = 0; + i->state.longpress_repeat_timestamp = 0; i->state.vect_sum.x = 0; i->state.vect_sum.y = 0; - i->state.reset_qry = 0; + i->state.reset_query = 0; } - if(i->state.disable == 0) { + if(i->state.disabled == 0) { /*Read the data*/ lv_indev_read(i, &data); - i->state.pressed = data.state; + i->state.event = data.state; /*Move the cursor if set and moved*/ if(i->cursor != NULL && @@ -212,22 +212,25 @@ static void indev_proc_task(void * param) lv_obj_set_pos_scale(i->cursor, data.point.x, data.point.y); } + i->state.act_point.x = data.point.x << LV_ANTIALIAS; + i->state.act_point.y = data.point.y << LV_ANTIALIAS; + /*Process the current point*/ - indev_proc_point(&i->state, data.point.x , data.point.y); + indev_proc_point(&i->state); } /*Handle reset query if it happened in during processing*/ - if(i->state.reset_qry) { + if(i->state.reset_query) { i->state.act_obj = NULL; i->state.last_obj = NULL; i->state.drag_range_out = 0; i->state.drag_in_prog = 0; i->state.long_press_sent = 0; - i->state.press_time_stamp = 0; - i->state.lpr_rep_time_stamp = 0; + i->state.press_timestamp = 0; + i->state.longpress_repeat_timestamp = 0; i->state.vect_sum.x = 0; i->state.vect_sum.y = 0; - i->state.reset_qry = 0; + i->state.reset_query = 0; } i = lv_indev_next(i); /*Go to the next indev*/ @@ -242,17 +245,9 @@ static void indev_proc_task(void * param) * @param x x coordinate of the next point * @param y y coordinate of the next point */ -static void indev_proc_point(lv_indev_state_t * indev, cord_t x, cord_t y) +static void indev_proc_point(lv_indev_state_t * indev) { -#if LV_ANTIALIAS != 0 && LV_VDB_SIZE != 0 - indev->act_point.x = x << LV_ANTIALIAS; - indev->act_point.y = y << LV_ANTIALIAS; -#else - indev->act_point.x = x; - indev->act_point.y = y; -#endif - - if(indev->pressed != false){ + if(indev->event == LV_INDEV_EVENT_PRESSED){ #if LV_INDEV_TP_MARKER != 0 area_t area; area.x1 = x - (LV_INDEV_TP_MARKER >> 1); @@ -278,7 +273,7 @@ static void indev_proc_press(lv_indev_state_t * state) { lv_obj_t * pr_obj = state->act_obj; - if(state->wait_release != 0) return; + if(state->wait_unil_release != 0) return; /*If there is no last object then search*/ if(state->act_obj == NULL) { @@ -304,13 +299,13 @@ static void indev_proc_press(lv_indev_state_t * state) /*If a new object found the previous was lost, so send a signal*/ if(state->act_obj != NULL) { state->act_obj->signal_func(state->act_obj, LV_SIGNAL_PRESS_LOST, indev_act); - if(state->reset_qry != 0) return; + if(state->reset_query != 0) return; } if(pr_obj != NULL) { /* Save the time when the obj pressed. * It is necessary to count the long press time.*/ - state->press_time_stamp = lv_tick_get(); + state->press_timestamp = lv_tick_get(); state->long_press_sent = 0; state->drag_range_out = 0; state->drag_in_prog = 0; @@ -335,7 +330,7 @@ static void indev_proc_press(lv_indev_state_t * state) /*Send a signal about the press*/ pr_obj->signal_func(pr_obj, LV_SIGNAL_PRESSED, indev_act); - if(state->reset_qry != 0) return; + if(state->reset_query != 0) return; } } @@ -349,32 +344,32 @@ static void indev_proc_press(lv_indev_state_t * state) /*If there is active object and it can be dragged run the drag*/ if(state->act_obj != NULL) { state->act_obj->signal_func(state->act_obj, LV_SIGNAL_PRESSING, indev_act); - if(state->reset_qry != 0) return; + if(state->reset_query != 0) return; indev_drag(state); - if(state->reset_qry != 0) return; + if(state->reset_query != 0) return; /*If there is no drag then check for long press time*/ if(state->drag_in_prog == 0 && state->long_press_sent == 0) { /*Send a signal about the long press if enough time elapsed*/ - if(lv_tick_elaps(state->press_time_stamp) > LV_INDEV_LONG_PRESS_TIME) { + if(lv_tick_elaps(state->press_timestamp) > LV_INDEV_LONG_PRESS_TIME) { pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS, indev_act); - if(state->reset_qry != 0) return; + if(state->reset_query != 0) return; /*Mark the signal sending to do not send it again*/ state->long_press_sent = 1; /*Save the long press time stamp for the long press repeat handler*/ - state->lpr_rep_time_stamp = lv_tick_get(); + state->longpress_repeat_timestamp = lv_tick_get(); } } /*Send long press repeated signal*/ if(state->drag_in_prog == 0 && state->long_press_sent == 1) { /*Send a signal about the long press repeate if enough time elapsed*/ - if(lv_tick_elaps(state->lpr_rep_time_stamp) > LV_INDEV_LONG_PRESS_REP_TIME) { + if(lv_tick_elaps(state->longpress_repeat_timestamp) > LV_INDEV_LONG_PRESS_REP_TIME) { pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS_REP, indev_act); - if(state->reset_qry != 0) return; - state->lpr_rep_time_stamp = lv_tick_get(); + if(state->reset_query != 0) return; + state->longpress_repeat_timestamp = lv_tick_get(); } } @@ -387,28 +382,28 @@ static void indev_proc_press(lv_indev_state_t * state) */ static void disi_proc_release(lv_indev_state_t * state) { - if(state->wait_release != 0) { + if(state->wait_unil_release != 0) { state->act_obj = NULL; state->last_obj = NULL; - state->press_time_stamp = 0; - state->lpr_rep_time_stamp = 0; - state->wait_release = 0; + state->press_timestamp = 0; + state->longpress_repeat_timestamp = 0; + state->wait_unil_release = 0; } /*Forgot the act obj and send a released signal */ if(state->act_obj != NULL) { state->act_obj->signal_func(state->act_obj, LV_SIGNAL_RELEASED, indev_act); - if(state->reset_qry != 0) return; + if(state->reset_query != 0) return; state->act_obj = NULL; - state->press_time_stamp = 0; - state->lpr_rep_time_stamp = 0; + state->press_timestamp = 0; + state->longpress_repeat_timestamp = 0; } /*The reset can be set in the signal function. * In case of reset query ignore the remaining parts.*/ - if(state->last_obj != NULL && state->reset_qry == 0) { + if(state->last_obj != NULL && state->reset_query == 0) { indev_drag_throw(state); - if(state->reset_qry != 0) return; + if(state->reset_query != 0) return; } } @@ -499,7 +494,7 @@ static void indev_drag(lv_indev_state_t * state) if(lv_obj_get_x(drag_obj) != act_x || lv_obj_get_y(drag_obj) != act_y) { if(state->drag_range_out != 0) { /*Send the drag begin signal on first move*/ drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_BEGIN, indev_act); - if(state->reset_qry != 0) return; + if(state->reset_query != 0) return; } state->drag_in_prog = 1; } diff --git a/lv_obj/lv_obj.c b/lv_obj/lv_obj.c index f96c20b28..d7ef549cd 100644 --- a/lv_obj/lv_obj.c +++ b/lv_obj/lv_obj.c @@ -196,7 +196,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy) #if LV_OBJ_FREE_NUM != 0 new_obj->free_num = 0; #endif -#if LV_OBJ_FREE_P != 0 +#if LV_OBJ_FREE_PTR != 0 new_obj->free_ptr = NULL; #endif #if LV_OBJ_GROUP != 0 diff --git a/lv_obj/lv_obj.h b/lv_obj/lv_obj.h index 1cc991004..3363d9395 100644 --- a/lv_obj/lv_obj.h +++ b/lv_obj/lv_obj.h @@ -110,7 +110,7 @@ typedef struct __LV_OBJ_T void * ext_attr; /*Object type specific extended data*/ lv_style_t * style_p; /*Pointer to the object's style*/ -#if LV_OBJ_FREE_POINTER != 0 +#if LV_OBJ_FREE_PTR != 0 void * free_ptr; /*Application specific pointer (set it freely)*/ #endif @@ -129,7 +129,7 @@ typedef struct __LV_OBJ_T cord_t ext_size; /*EXTtend the size of the object in every direction. E.g. for shadow drawing*/ -#if LV_OBJ_FREE_NUMBER != 0 +#if LV_OBJ_FREE_NUM != 0 uint8_t free_num; /*Application specific identifier (set it freely)*/ #endif }lv_obj_t;