BigW Consortium Gitlab

Commit 1a1840ae by Gabor Kiss-Vamosi

lv_hal_indev and tick updates

parent cc7128ce
......@@ -31,25 +31,23 @@ extern "C" {
/*Possible input device types*/
typedef enum {
LV_INDEV_TYPE_NONE, /*Show uninitialized state*/
LV_INDEV_TYPE_TOUCHPAD, /*Touch pad*/
LV_INDEV_TYPE_MOUSE, /*Mouse or similar pointer device*/
LV_INDEV_TYPE_POINTER, /*Touch pad, mouse, external button*/
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;
/*States for input devices*/
typedef enum {
LV_INDEV_EVENT_REL,
LV_INDEV_EVENT_PR
}lv_indev_event_t;
LV_INDEV_STATE_REL,
LV_INDEV_STATE_PR
}lv_indev_state_t;
/*Data type when an input device is read */
typedef struct {
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*/
};
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;
/*Initialized by the user and registered by 'lv_indev_add()'*/
......@@ -61,9 +59,9 @@ typedef struct {
struct _lv_obj_t;
typedef struct _lv_indev_state_t {
lv_indev_event_t event;
lv_indev_state_t event;
union {
struct {
struct { /*Pointer data*/
lv_point_t act_point;
lv_point_t last_point;
lv_point_t vect;
......@@ -76,7 +74,9 @@ typedef struct _lv_indev_state_t {
uint8_t drag_in_prog :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*/
......@@ -86,7 +86,7 @@ typedef struct _lv_indev_state_t {
uint8_t long_pr_sent :1;
uint8_t reset_query :1;
uint8_t disabled :1;
}lv_indev_state_t;
}lv_indev_proc_t;
struct _lv_obj_t;
......@@ -94,7 +94,7 @@ struct _lv_group_t;
typedef struct _lv_indev_t {
lv_indev_drv_t driver;
lv_indev_state_t state;
lv_indev_proc_t proc;
union {
struct _lv_obj_t *cursor;
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++;
/*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 {
tick_irq_flag = 1;
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;
}
......@@ -90,62 +82,6 @@ uint32_t lv_tick_elaps(uint32_t 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
**********************/
......
......@@ -28,11 +28,10 @@ extern "C" {
* 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
......@@ -47,19 +46,6 @@ uint32_t lv_tick_get(void);
*/
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
**********************/
......
......@@ -307,8 +307,8 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
while(indev) {
dpar = obj;
while(dpar != NULL) {
if(indev->state.act_obj == dpar ||
indev->state.last_obj == dpar) {
if(indev->proc.act_obj == dpar ||
indev->proc.last_obj == dpar) {
lv_indev_reset(indev);
break;
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment