lv_hal_indev and tick updates
This commit is contained in:
@@ -31,25 +31,23 @@ extern "C" {
|
|||||||
/*Possible input device types*/
|
/*Possible input device types*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LV_INDEV_TYPE_NONE, /*Show uninitialized state*/
|
LV_INDEV_TYPE_NONE, /*Show uninitialized state*/
|
||||||
LV_INDEV_TYPE_TOUCHPAD, /*Touch pad*/
|
LV_INDEV_TYPE_POINTER, /*Touch pad, mouse, external button*/
|
||||||
LV_INDEV_TYPE_MOUSE, /*Mouse or similar pointer device*/
|
|
||||||
LV_INDEV_TYPE_KEYPAD, /*Keypad or keyboard*/
|
LV_INDEV_TYPE_KEYPAD, /*Keypad or keyboard*/
|
||||||
LV_INDEV_TYPE_BUTTON, /*External (hardware) button assigned to a point on the screen*/
|
|
||||||
} lv_hal_indev_type_t;
|
} lv_hal_indev_type_t;
|
||||||
|
|
||||||
/*States for input devices*/
|
/*States for input devices*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LV_INDEV_EVENT_REL,
|
LV_INDEV_STATE_REL,
|
||||||
LV_INDEV_EVENT_PR
|
LV_INDEV_STATE_PR
|
||||||
}lv_indev_event_t;
|
}lv_indev_state_t;
|
||||||
|
|
||||||
/*Data type when an input device is read */
|
/*Data type when an input device is read */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
union {
|
union {
|
||||||
lv_point_t point; /*For INDEV_TYPE_TOUCHPAD, INDEV_TYPE_POINTER, LV_INDEV_TYPE_BUTTON*/
|
lv_point_t point; /*For INDEV_TYPE_POINTER*/
|
||||||
uint32_t key; /*For INDEV_TYPE_KEYPAD*/
|
uint32_t key; /*For INDEV_TYPE_KEYPAD*/
|
||||||
};
|
};
|
||||||
lv_indev_event_t state; /*LV_INDEV_EVENT_REL or LV_INDEV_EVENT_PR*/
|
lv_indev_state_t state; /*LV_INDEV_EVENT_REL or LV_INDEV_EVENT_PR*/
|
||||||
}lv_indev_data_t;
|
}lv_indev_data_t;
|
||||||
|
|
||||||
/*Initialized by the user and registered by 'lv_indev_add()'*/
|
/*Initialized by the user and registered by 'lv_indev_add()'*/
|
||||||
@@ -61,9 +59,9 @@ typedef struct {
|
|||||||
struct _lv_obj_t;
|
struct _lv_obj_t;
|
||||||
|
|
||||||
typedef struct _lv_indev_state_t {
|
typedef struct _lv_indev_state_t {
|
||||||
lv_indev_event_t event;
|
lv_indev_state_t event;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct { /*Pointer data*/
|
||||||
lv_point_t act_point;
|
lv_point_t act_point;
|
||||||
lv_point_t last_point;
|
lv_point_t last_point;
|
||||||
lv_point_t vect;
|
lv_point_t vect;
|
||||||
@@ -76,7 +74,9 @@ typedef struct _lv_indev_state_t {
|
|||||||
uint8_t drag_in_prog :1;
|
uint8_t drag_in_prog :1;
|
||||||
uint8_t wait_unil_release :1;
|
uint8_t wait_unil_release :1;
|
||||||
};
|
};
|
||||||
uint32_t last_key;
|
struct { /*Keypad data*/
|
||||||
|
lv_indev_state_t last_state;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t pr_timestamp; /*Pressed time stamp*/
|
uint32_t pr_timestamp; /*Pressed time stamp*/
|
||||||
@@ -86,7 +86,7 @@ typedef struct _lv_indev_state_t {
|
|||||||
uint8_t long_pr_sent :1;
|
uint8_t long_pr_sent :1;
|
||||||
uint8_t reset_query :1;
|
uint8_t reset_query :1;
|
||||||
uint8_t disabled :1;
|
uint8_t disabled :1;
|
||||||
}lv_indev_state_t;
|
}lv_indev_proc_t;
|
||||||
|
|
||||||
|
|
||||||
struct _lv_obj_t;
|
struct _lv_obj_t;
|
||||||
@@ -94,7 +94,7 @@ struct _lv_group_t;
|
|||||||
|
|
||||||
typedef struct _lv_indev_t {
|
typedef struct _lv_indev_t {
|
||||||
lv_indev_drv_t driver;
|
lv_indev_drv_t driver;
|
||||||
lv_indev_state_t state;
|
lv_indev_proc_t proc;
|
||||||
union {
|
union {
|
||||||
struct _lv_obj_t *cursor;
|
struct _lv_obj_t *cursor;
|
||||||
struct _lv_group_t *group; /*Keypad destination group*/
|
struct _lv_group_t *group; /*Keypad destination group*/
|
||||||
|
|||||||
@@ -39,20 +39,12 @@ static void (*tick_callbacks[LV_HAL_TICK_CALLBACK_NUM])(void);
|
|||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You have to call this function in every milliseconds in a timer interrupt
|
* You have to call this function in every milliseconds
|
||||||
*/
|
*/
|
||||||
void lv_tick_handler(void)
|
void lv_tick_inc(void)
|
||||||
{
|
{
|
||||||
|
tick_irq_flag = 0;
|
||||||
sys_time++;
|
sys_time++;
|
||||||
|
|
||||||
/*Run the callback functions*/
|
|
||||||
uint8_t i;
|
|
||||||
for (i = 0; i < LV_HAL_TICK_CALLBACK_NUM; i++) {
|
|
||||||
if (tick_callbacks[i] != NULL) {
|
|
||||||
tick_callbacks[i]();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tick_irq_flag = 0; /*lv_hal_systick_get set it to know there was an IRQ*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,7 +57,7 @@ uint32_t lv_tick_get(void)
|
|||||||
do {
|
do {
|
||||||
tick_irq_flag = 1;
|
tick_irq_flag = 1;
|
||||||
result = sys_time;
|
result = sys_time;
|
||||||
} while(!tick_irq_flag); /*Systick IRQ clears this flag. Continue until make a non interrupted cycle */
|
} while(!tick_irq_flag); /*'lv_tick_inc()' clears this flag which can be in an interrupt. Continue until make a non interrupted cycle */
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -90,62 +82,6 @@ uint32_t lv_tick_elaps(uint32_t prev_tick)
|
|||||||
return prev_tick;
|
return prev_tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a callback function to the systick interrupt
|
|
||||||
* @param cb a function pointer
|
|
||||||
* @return true: 'cb' added to the systick callbacks, false: 'cb' not added
|
|
||||||
*/
|
|
||||||
bool lv_tick_add_callback(void (*cb) (void))
|
|
||||||
{
|
|
||||||
bool suc = false;
|
|
||||||
|
|
||||||
/*Take the semaphore. Be sure it is set*/
|
|
||||||
do {
|
|
||||||
tick_cb_sem = 1;
|
|
||||||
} while(!tick_cb_sem);
|
|
||||||
|
|
||||||
uint8_t i;
|
|
||||||
for (i = 0; i < LV_HAL_TICK_CALLBACK_NUM; i++) {
|
|
||||||
if (tick_callbacks[i] == NULL) {
|
|
||||||
tick_callbacks[i] = cb;
|
|
||||||
suc = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Release the semaphore. Be sure it is cleared*/
|
|
||||||
do {
|
|
||||||
tick_cb_sem = 0;
|
|
||||||
} while(tick_cb_sem);
|
|
||||||
|
|
||||||
return suc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a callback function from the tick callbacks
|
|
||||||
* @param cb a function pointer (added with 'lv_hal_tick_add_callback')
|
|
||||||
*/
|
|
||||||
void lv_tick_rem_callback(void (*cb) (void))
|
|
||||||
{
|
|
||||||
/*Take the semaphore. Be sure it is set*/
|
|
||||||
do {
|
|
||||||
tick_cb_sem = 1;
|
|
||||||
} while(!tick_cb_sem);
|
|
||||||
|
|
||||||
uint8_t i;
|
|
||||||
for (i = 0; i < LV_HAL_TICK_CALLBACK_NUM; i++) {
|
|
||||||
if (tick_callbacks[i] == cb) {
|
|
||||||
tick_callbacks[i] = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Release the semaphore. Be sure it is cleared*/
|
|
||||||
do {
|
|
||||||
tick_cb_sem = 0;
|
|
||||||
} while(tick_cb_sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC FUNCTIONS
|
* STATIC FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|||||||
@@ -28,11 +28,10 @@ extern "C" {
|
|||||||
* GLOBAL PROTOTYPES
|
* GLOBAL PROTOTYPES
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You have to call this function in every milliseconds in a timer interrupt
|
* You have to call this function in every milliseconds
|
||||||
*/
|
*/
|
||||||
void lv_tick_handler(void);
|
void lv_tick_inc(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the elapsed milliseconds since start up
|
* Get the elapsed milliseconds since start up
|
||||||
@@ -47,19 +46,6 @@ uint32_t lv_tick_get(void);
|
|||||||
*/
|
*/
|
||||||
uint32_t lv_tick_elaps(uint32_t prev_tick);
|
uint32_t lv_tick_elaps(uint32_t prev_tick);
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a callback function to the systick interrupt
|
|
||||||
* @param cb a function pointer
|
|
||||||
* @return true: 'cb' added to the systick callbacks, false: 'cb' not added
|
|
||||||
*/
|
|
||||||
bool lv_tick_add_callback(void (*cb) (void));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a callback function from the tick callbacks
|
|
||||||
* @param cb a function pointer (added with 'lv_hal_tick_add_callback')
|
|
||||||
*/
|
|
||||||
void lv_tick_rem_callback(void (*cb) (void));
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
|
|||||||
@@ -28,12 +28,12 @@
|
|||||||
* STATIC PROTOTYPES
|
* STATIC PROTOTYPES
|
||||||
**********************/
|
**********************/
|
||||||
static void indev_proc_task(void * param);
|
static void indev_proc_task(void * param);
|
||||||
static void indev_proc_point(lv_indev_state_t * indev);
|
static void indev_proc_point(lv_indev_proc_t * indev);
|
||||||
static void indev_proc_press(lv_indev_state_t * state);
|
static void indev_proc_press(lv_indev_proc_t * info);
|
||||||
static void disi_proc_release(lv_indev_state_t * state);
|
static void indev_proc_release(lv_indev_proc_t * state);
|
||||||
static lv_obj_t * indev_search_obj(const lv_indev_state_t * indev, lv_obj_t * obj);
|
static lv_obj_t * indev_search_obj(const lv_indev_proc_t * indev, lv_obj_t * obj);
|
||||||
static void indev_drag(lv_indev_state_t * state);
|
static void indev_drag(lv_indev_proc_t * state);
|
||||||
static void indev_drag_throw(lv_indev_state_t * state);
|
static void indev_drag_throw(lv_indev_proc_t * state);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
@@ -78,11 +78,11 @@ lv_indev_t * lv_indev_get_act(void)
|
|||||||
*/
|
*/
|
||||||
void lv_indev_reset(lv_indev_t * indev)
|
void lv_indev_reset(lv_indev_t * indev)
|
||||||
{
|
{
|
||||||
if(indev) indev->state.reset_query = 1;
|
if(indev) indev->proc.reset_query = 1;
|
||||||
else {
|
else {
|
||||||
lv_indev_t * i = lv_indev_next(NULL);
|
lv_indev_t * i = lv_indev_next(NULL);
|
||||||
while(i) {
|
while(i) {
|
||||||
i->state.reset_query = 1;
|
i->proc.reset_query = 1;
|
||||||
i = lv_indev_next(i);
|
i = lv_indev_next(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,9 +94,9 @@ void lv_indev_reset(lv_indev_t * indev)
|
|||||||
*/
|
*/
|
||||||
void lv_indev_reset_lpr(lv_indev_t * indev_proc)
|
void lv_indev_reset_lpr(lv_indev_t * indev_proc)
|
||||||
{
|
{
|
||||||
indev_proc->state.long_pr_sent = 0;
|
indev_proc->proc.long_pr_sent = 0;
|
||||||
indev_proc->state.longpr_rep_timestamp = lv_tick_get();
|
indev_proc->proc.longpr_rep_timestamp = lv_tick_get();
|
||||||
indev_proc->state.pr_timestamp = lv_tick_get();
|
indev_proc->proc.pr_timestamp = lv_tick_get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,7 +109,7 @@ void lv_indev_enable(lv_hal_indev_type_t type, bool enable)
|
|||||||
lv_indev_t *i = lv_indev_next(NULL);
|
lv_indev_t *i = lv_indev_next(NULL);
|
||||||
|
|
||||||
while (i) {
|
while (i) {
|
||||||
if (i->driver.type == type) i->state.disabled = enable == false ? 1 : 0;
|
if (i->driver.type == type) i->proc.disabled = enable == false ? 1 : 0;
|
||||||
i = lv_indev_next(i);
|
i = lv_indev_next(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ void lv_indev_enable(lv_hal_indev_type_t type, bool enable)
|
|||||||
*/
|
*/
|
||||||
void lv_indev_set_cursor(lv_indev_t *indev, lv_obj_t *cur_obj)
|
void lv_indev_set_cursor(lv_indev_t *indev, lv_obj_t *cur_obj)
|
||||||
{
|
{
|
||||||
if(indev->driver.type != LV_INDEV_TYPE_MOUSE) return;
|
if(indev->driver.type != LV_INDEV_TYPE_POINTER) return;
|
||||||
|
|
||||||
indev->cursor = cur_obj;
|
indev->cursor = cur_obj;
|
||||||
lv_obj_set_parent(indev->cursor, lv_layer_sys());
|
lv_obj_set_parent(indev->cursor, lv_layer_sys());
|
||||||
lv_obj_set_pos(indev->cursor, indev->state.act_point.x, indev->state.act_point.y);
|
lv_obj_set_pos(indev->cursor, indev->proc.act_point.x, indev->proc.act_point.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LV_OBJ_GROUP
|
#if LV_OBJ_GROUP
|
||||||
@@ -147,8 +147,8 @@ void lv_indev_set_group(lv_indev_t *indev, lv_group_t *group)
|
|||||||
*/
|
*/
|
||||||
void lv_indev_get_point(lv_indev_t * indev, lv_point_t * point)
|
void lv_indev_get_point(lv_indev_t * indev, lv_point_t * point)
|
||||||
{
|
{
|
||||||
point->x = indev->state.act_point.x;
|
point->x = indev->proc.act_point.x;
|
||||||
point->y = indev->state.act_point.y;
|
point->y = indev->proc.act_point.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,7 +159,7 @@ void lv_indev_get_point(lv_indev_t * indev, lv_point_t * point)
|
|||||||
bool lv_indev_is_dragging(lv_indev_t * indev)
|
bool lv_indev_is_dragging(lv_indev_t * indev)
|
||||||
{
|
{
|
||||||
if(indev == NULL) return false;
|
if(indev == NULL) return false;
|
||||||
return indev->state.drag_in_prog == 0 ? false : true;
|
return indev->proc.drag_in_prog == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,8 +169,8 @@ bool lv_indev_is_dragging(lv_indev_t * indev)
|
|||||||
*/
|
*/
|
||||||
void lv_indev_get_vect(lv_indev_t * indev, lv_point_t * point)
|
void lv_indev_get_vect(lv_indev_t * indev, lv_point_t * point)
|
||||||
{
|
{
|
||||||
point->x = indev->state.vect.x;
|
point->x = indev->proc.vect.x;
|
||||||
point->y = indev->state.vect.y;
|
point->y = indev->proc.vect.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,7 +179,7 @@ void lv_indev_get_vect(lv_indev_t * indev, lv_point_t * point)
|
|||||||
*/
|
*/
|
||||||
void lv_indev_wait_release(lv_indev_t * indev)
|
void lv_indev_wait_release(lv_indev_t * indev)
|
||||||
{
|
{
|
||||||
indev->state.wait_unil_release = 1;
|
indev->proc.wait_unil_release = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@@ -201,46 +201,46 @@ static void indev_proc_task(void * param)
|
|||||||
indev_act = i;
|
indev_act = i;
|
||||||
|
|
||||||
/*Handle reset query before processing the point*/
|
/*Handle reset query before processing the point*/
|
||||||
if(i->state.reset_query) {
|
if(i->proc.reset_query) {
|
||||||
i->state.act_obj = NULL;
|
i->proc.act_obj = NULL;
|
||||||
i->state.last_obj = NULL;
|
i->proc.last_obj = NULL;
|
||||||
i->state.drag_range_out = 0;
|
i->proc.drag_range_out = 0;
|
||||||
i->state.drag_in_prog = 0;
|
i->proc.drag_in_prog = 0;
|
||||||
i->state.long_pr_sent = 0;
|
i->proc.long_pr_sent = 0;
|
||||||
i->state.pr_timestamp = 0;
|
i->proc.pr_timestamp = 0;
|
||||||
i->state.longpr_rep_timestamp = 0;
|
i->proc.longpr_rep_timestamp = 0;
|
||||||
i->state.drag_sum.x = 0;
|
i->proc.drag_sum.x = 0;
|
||||||
i->state.drag_sum.y = 0;
|
i->proc.drag_sum.y = 0;
|
||||||
i->state.reset_query = 0;
|
i->proc.reset_query = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i->state.disabled == 0) {
|
if(i->proc.disabled == 0) {
|
||||||
/*Read the data*/
|
/*Read the data*/
|
||||||
lv_indev_read(i, &data);
|
lv_indev_read(i, &data);
|
||||||
i->state.event = data.state;
|
i->proc.event = data.state;
|
||||||
|
|
||||||
/*Move the cursor if set and moved*/
|
/*Move the cursor if set and moved*/
|
||||||
if(i->driver.type == LV_INDEV_TYPE_MOUSE &&
|
if(i->driver.type == LV_INDEV_TYPE_POINTER &&
|
||||||
i->cursor != NULL &&
|
i->cursor != NULL &&
|
||||||
(i->state.last_point.x != data.point.x ||
|
(i->proc.last_point.x != data.point.x ||
|
||||||
i->state.last_point.y != data.point.y))
|
i->proc.last_point.y != data.point.y))
|
||||||
{
|
{
|
||||||
lv_obj_set_pos_scale(i->cursor, data.point.x, data.point.y);
|
lv_obj_set_pos_scale(i->cursor, data.point.x, data.point.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i->driver.type == LV_INDEV_TYPE_MOUSE ||
|
if(i->driver.type == LV_INDEV_TYPE_POINTER)
|
||||||
i->driver.type == LV_INDEV_TYPE_TOUCHPAD ||
|
|
||||||
i->driver.type == LV_INDEV_TYPE_BUTTON)
|
|
||||||
{
|
{
|
||||||
i->state.act_point.x = data.point.x << LV_ANTIALIAS;
|
i->proc.act_point.x = data.point.x << LV_ANTIALIAS;
|
||||||
i->state.act_point.y = data.point.y << LV_ANTIALIAS;
|
i->proc.act_point.y = data.point.y << LV_ANTIALIAS;
|
||||||
|
|
||||||
/*Process the current point*/
|
/*Process the current point*/
|
||||||
indev_proc_point(&i->state);
|
indev_proc_point(&i->proc);
|
||||||
}
|
}
|
||||||
else if (i->driver.type == LV_INDEV_TYPE_KEYPAD) {
|
else if (i->driver.type == LV_INDEV_TYPE_KEYPAD) {
|
||||||
#if LV_OBJ_GROUP != 0
|
#if LV_OBJ_GROUP != 0
|
||||||
if(i->group != NULL && data.state == LV_INDEV_EVENT_PR && data.key != 0) {
|
if(i->group != NULL && data.key != 0 &&
|
||||||
|
data.state == LV_INDEV_STATE_PR && i->proc.last_state == LV_INDEV_STATE_REL)
|
||||||
|
{
|
||||||
if(data.key == LV_GROUP_KEY_NEXT) {
|
if(data.key == LV_GROUP_KEY_NEXT) {
|
||||||
lv_group_focus_next(i->group);
|
lv_group_focus_next(i->group);
|
||||||
}
|
}
|
||||||
@@ -251,22 +251,23 @@ static void indev_proc_task(void * param)
|
|||||||
lv_group_send_data(i->group, data.key);
|
lv_group_send_data(i->group, data.key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
i->proc.last_state = data.state;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Handle reset query if it happened in during processing*/
|
/*Handle reset query if it happened in during processing*/
|
||||||
if(i->state.reset_query) {
|
if(i->proc.reset_query) {
|
||||||
i->state.act_obj = NULL;
|
i->proc.act_obj = NULL;
|
||||||
i->state.last_obj = NULL;
|
i->proc.last_obj = NULL;
|
||||||
i->state.drag_range_out = 0;
|
i->proc.drag_range_out = 0;
|
||||||
i->state.drag_in_prog = 0;
|
i->proc.drag_in_prog = 0;
|
||||||
i->state.long_pr_sent = 0;
|
i->proc.long_pr_sent = 0;
|
||||||
i->state.pr_timestamp = 0;
|
i->proc.pr_timestamp = 0;
|
||||||
i->state.longpr_rep_timestamp = 0;
|
i->proc.longpr_rep_timestamp = 0;
|
||||||
i->state.drag_sum.x = 0;
|
i->proc.drag_sum.x = 0;
|
||||||
i->state.drag_sum.y = 0;
|
i->proc.drag_sum.y = 0;
|
||||||
i->state.reset_query = 0;
|
i->proc.reset_query = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = lv_indev_next(i); /*Go to the next indev*/
|
i = lv_indev_next(i); /*Go to the next indev*/
|
||||||
@@ -281,9 +282,9 @@ static void indev_proc_task(void * param)
|
|||||||
* @param x x coordinate of the next point
|
* @param x x coordinate of the next point
|
||||||
* @param y y coordinate of the next point
|
* @param y y coordinate of the next point
|
||||||
*/
|
*/
|
||||||
static void indev_proc_point(lv_indev_state_t * indev)
|
static void indev_proc_point(lv_indev_proc_t * indev)
|
||||||
{
|
{
|
||||||
if(indev->event == LV_INDEV_EVENT_PR){
|
if(indev->event == LV_INDEV_STATE_PR){
|
||||||
#if LV_INDEV_POINT_MARKER != 0
|
#if LV_INDEV_POINT_MARKER != 0
|
||||||
area_t area;
|
area_t area;
|
||||||
area.x1 = (indev->act_point.x >> LV_ANTIALIAS) - (LV_INDEV_POINT_MARKER >> 1);
|
area.x1 = (indev->act_point.x >> LV_ANTIALIAS) - (LV_INDEV_POINT_MARKER >> 1);
|
||||||
@@ -294,7 +295,7 @@ static void indev_proc_point(lv_indev_state_t * indev)
|
|||||||
#endif
|
#endif
|
||||||
indev_proc_press(indev);
|
indev_proc_press(indev);
|
||||||
} else {
|
} else {
|
||||||
disi_proc_release(indev);
|
indev_proc_release(indev);
|
||||||
}
|
}
|
||||||
|
|
||||||
indev->last_point.x = indev->act_point.x;
|
indev->last_point.x = indev->act_point.x;
|
||||||
@@ -305,21 +306,21 @@ static void indev_proc_point(lv_indev_state_t * indev)
|
|||||||
* Process the pressed state
|
* Process the pressed state
|
||||||
* @param indev pointer to an input device state
|
* @param indev pointer to an input device state
|
||||||
*/
|
*/
|
||||||
static void indev_proc_press(lv_indev_state_t * state)
|
static void indev_proc_press(lv_indev_proc_t * info)
|
||||||
{
|
{
|
||||||
lv_obj_t * pr_obj = state->act_obj;
|
lv_obj_t * pr_obj = info->act_obj;
|
||||||
|
|
||||||
if(state->wait_unil_release != 0) return;
|
if(info->wait_unil_release != 0) return;
|
||||||
|
|
||||||
/*If there is no last object then search*/
|
/*If there is no last object then search*/
|
||||||
if(state->act_obj == NULL) {
|
if(info->act_obj == NULL) {
|
||||||
pr_obj = indev_search_obj(state, lv_layer_top());
|
pr_obj = indev_search_obj(info, lv_layer_top());
|
||||||
if(pr_obj == NULL) pr_obj = indev_search_obj(state, lv_scr_act());
|
if(pr_obj == NULL) pr_obj = indev_search_obj(info, lv_scr_act());
|
||||||
}
|
}
|
||||||
/*If there is last object but it is not dragged also search*/
|
/*If there is last object but it is not dragged also search*/
|
||||||
else if(state->drag_in_prog == 0) {/*Now act_obj != NULL*/
|
else if(info->drag_in_prog == 0) {/*Now act_obj != NULL*/
|
||||||
pr_obj = indev_search_obj(state, lv_layer_top());
|
pr_obj = indev_search_obj(info, lv_layer_top());
|
||||||
if(pr_obj == NULL) pr_obj = indev_search_obj(state, lv_scr_act());
|
if(pr_obj == NULL) pr_obj = indev_search_obj(info, lv_scr_act());
|
||||||
}
|
}
|
||||||
/*If a dragable object was the last then keep it*/
|
/*If a dragable object was the last then keep it*/
|
||||||
else {
|
else {
|
||||||
@@ -327,26 +328,26 @@ static void indev_proc_press(lv_indev_state_t * state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*If a new object was found reset some variables and send a pressed signal*/
|
/*If a new object was found reset some variables and send a pressed signal*/
|
||||||
if(pr_obj != state->act_obj) {
|
if(pr_obj != info->act_obj) {
|
||||||
|
|
||||||
state->last_point.x = state->act_point.x;
|
info->last_point.x = info->act_point.x;
|
||||||
state->last_point.y = state->act_point.y;
|
info->last_point.y = info->act_point.y;
|
||||||
|
|
||||||
/*If a new object found the previous was lost, so send a signal*/
|
/*If a new object found the previous was lost, so send a signal*/
|
||||||
if(state->act_obj != NULL) {
|
if(info->act_obj != NULL) {
|
||||||
state->act_obj->signal_func(state->act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
|
info->act_obj->signal_func(info->act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
|
||||||
if(state->reset_query != 0) return;
|
if(info->reset_query != 0) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pr_obj != NULL) {
|
if(pr_obj != NULL) {
|
||||||
/* Save the time when the obj pressed.
|
/* Save the time when the obj pressed.
|
||||||
* It is necessary to count the long press time.*/
|
* It is necessary to count the long press time.*/
|
||||||
state->pr_timestamp = lv_tick_get();
|
info->pr_timestamp = lv_tick_get();
|
||||||
state->long_pr_sent = 0;
|
info->long_pr_sent = 0;
|
||||||
state->drag_range_out = 0;
|
info->drag_range_out = 0;
|
||||||
state->drag_in_prog = 0;
|
info->drag_in_prog = 0;
|
||||||
state->drag_sum.x = 0;
|
info->drag_sum.x = 0;
|
||||||
state->drag_sum.y = 0;
|
info->drag_sum.y = 0;
|
||||||
|
|
||||||
/*Search for 'top' attribute*/
|
/*Search for 'top' attribute*/
|
||||||
lv_obj_t * i = pr_obj;
|
lv_obj_t * i = pr_obj;
|
||||||
@@ -366,46 +367,46 @@ static void indev_proc_press(lv_indev_state_t * state)
|
|||||||
|
|
||||||
/*Send a signal about the press*/
|
/*Send a signal about the press*/
|
||||||
pr_obj->signal_func(pr_obj, LV_SIGNAL_PRESSED, indev_act);
|
pr_obj->signal_func(pr_obj, LV_SIGNAL_PRESSED, indev_act);
|
||||||
if(state->reset_query != 0) return;
|
if(info->reset_query != 0) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state->act_obj = pr_obj; /*Save the pressed object*/
|
info->act_obj = pr_obj; /*Save the pressed object*/
|
||||||
state->last_obj = state->act_obj; /*Refresh the last_obj*/
|
info->last_obj = info->act_obj; /*Refresh the last_obj*/
|
||||||
|
|
||||||
/*Calculate the vector*/
|
/*Calculate the vector*/
|
||||||
state->vect.x = state->act_point.x - state->last_point.x;
|
info->vect.x = info->act_point.x - info->last_point.x;
|
||||||
state->vect.y = state->act_point.y - state->last_point.y;
|
info->vect.y = info->act_point.y - info->last_point.y;
|
||||||
|
|
||||||
/*If there is active object and it can be dragged run the drag*/
|
/*If there is active object and it can be dragged run the drag*/
|
||||||
if(state->act_obj != NULL) {
|
if(info->act_obj != NULL) {
|
||||||
state->act_obj->signal_func(state->act_obj, LV_SIGNAL_PRESSING, indev_act);
|
info->act_obj->signal_func(info->act_obj, LV_SIGNAL_PRESSING, indev_act);
|
||||||
if(state->reset_query != 0) return;
|
if(info->reset_query != 0) return;
|
||||||
|
|
||||||
indev_drag(state);
|
indev_drag(info);
|
||||||
if(state->reset_query != 0) return;
|
if(info->reset_query != 0) return;
|
||||||
|
|
||||||
/*If there is no drag then check for long press time*/
|
/*If there is no drag then check for long press time*/
|
||||||
if(state->drag_in_prog == 0 && state->long_pr_sent == 0) {
|
if(info->drag_in_prog == 0 && info->long_pr_sent == 0) {
|
||||||
/*Send a signal about the long press if enough time elapsed*/
|
/*Send a signal about the long press if enough time elapsed*/
|
||||||
if(lv_tick_elaps(state->pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) {
|
if(lv_tick_elaps(info->pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) {
|
||||||
pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS, indev_act);
|
pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS, indev_act);
|
||||||
if(state->reset_query != 0) return;
|
if(info->reset_query != 0) return;
|
||||||
|
|
||||||
/*Mark the signal sending to do not send it again*/
|
/*Mark the signal sending to do not send it again*/
|
||||||
state->long_pr_sent = 1;
|
info->long_pr_sent = 1;
|
||||||
|
|
||||||
/*Save the long press time stamp for the long press repeat handler*/
|
/*Save the long press time stamp for the long press repeat handler*/
|
||||||
state->longpr_rep_timestamp = lv_tick_get();
|
info->longpr_rep_timestamp = lv_tick_get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*Send long press repeated signal*/
|
/*Send long press repeated signal*/
|
||||||
if(state->drag_in_prog == 0 && state->long_pr_sent == 1) {
|
if(info->drag_in_prog == 0 && info->long_pr_sent == 1) {
|
||||||
/*Send a signal about the long press repeate if enough time elapsed*/
|
/*Send a signal about the long press repeate if enough time elapsed*/
|
||||||
if(lv_tick_elaps(state->longpr_rep_timestamp) > LV_INDEV_LONG_PRESS_REP_TIME) {
|
if(lv_tick_elaps(info->longpr_rep_timestamp) > LV_INDEV_LONG_PRESS_REP_TIME) {
|
||||||
pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS_REP, indev_act);
|
pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS_REP, indev_act);
|
||||||
if(state->reset_query != 0) return;
|
if(info->reset_query != 0) return;
|
||||||
state->longpr_rep_timestamp = lv_tick_get();
|
info->longpr_rep_timestamp = lv_tick_get();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -416,7 +417,7 @@ static void indev_proc_press(lv_indev_state_t * state)
|
|||||||
* Process the released state
|
* Process the released state
|
||||||
* @param indev_proc_p pointer to an input device state
|
* @param indev_proc_p pointer to an input device state
|
||||||
*/
|
*/
|
||||||
static void disi_proc_release(lv_indev_state_t * state)
|
static void indev_proc_release(lv_indev_proc_t * state)
|
||||||
{
|
{
|
||||||
if(state->wait_unil_release != 0) {
|
if(state->wait_unil_release != 0) {
|
||||||
state->act_obj = NULL;
|
state->act_obj = NULL;
|
||||||
@@ -449,7 +450,7 @@ static void disi_proc_release(lv_indev_state_t * state)
|
|||||||
* @param obj pointer to a start object, typically the screen
|
* @param obj pointer to a start object, typically the screen
|
||||||
* @return pointer to the found object or NULL if there was no suitable object
|
* @return pointer to the found object or NULL if there was no suitable object
|
||||||
*/
|
*/
|
||||||
static lv_obj_t * indev_search_obj(const lv_indev_state_t * indev, lv_obj_t * obj)
|
static lv_obj_t * indev_search_obj(const lv_indev_proc_t * indev, lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
lv_obj_t * found_p = NULL;
|
lv_obj_t * found_p = NULL;
|
||||||
|
|
||||||
@@ -488,7 +489,7 @@ static lv_obj_t * indev_search_obj(const lv_indev_state_t * indev, lv_obj_t * ob
|
|||||||
* Handle the dragging of indev_proc_p->act_obj
|
* Handle the dragging of indev_proc_p->act_obj
|
||||||
* @param indev pointer to a input device state
|
* @param indev pointer to a input device state
|
||||||
*/
|
*/
|
||||||
static void indev_drag(lv_indev_state_t * state)
|
static void indev_drag(lv_indev_proc_t * state)
|
||||||
{
|
{
|
||||||
lv_obj_t * drag_obj = state->act_obj;
|
lv_obj_t * drag_obj = state->act_obj;
|
||||||
|
|
||||||
@@ -543,7 +544,7 @@ static void indev_drag(lv_indev_state_t * state)
|
|||||||
* Handle throwing by drag if the drag is ended
|
* Handle throwing by drag if the drag is ended
|
||||||
* @param indev pointer to an input device state
|
* @param indev pointer to an input device state
|
||||||
*/
|
*/
|
||||||
static void indev_drag_throw(lv_indev_state_t * state)
|
static void indev_drag_throw(lv_indev_proc_t * state)
|
||||||
{
|
{
|
||||||
if(state->drag_in_prog == 0) return;
|
if(state->drag_in_prog == 0) return;
|
||||||
|
|
||||||
|
|||||||
@@ -307,8 +307,8 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
|
|||||||
while(indev) {
|
while(indev) {
|
||||||
dpar = obj;
|
dpar = obj;
|
||||||
while(dpar != NULL) {
|
while(dpar != NULL) {
|
||||||
if(indev->state.act_obj == dpar ||
|
if(indev->proc.act_obj == dpar ||
|
||||||
indev->state.last_obj == dpar) {
|
indev->proc.last_obj == dpar) {
|
||||||
lv_indev_reset(indev);
|
lv_indev_reset(indev);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user