BigW Consortium Gitlab

Commit f3e1df39 by Gabor Kiss-Vamosi

add LV_GROUP_KEY_ENETER_LONG to trigger long press evets of the objects

parent b2f72d3f
...@@ -25,11 +25,13 @@ extern "C" { ...@@ -25,11 +25,13 @@ extern "C" {
#define LV_GROUP_KEY_DOWN 18 /*0x12*/ #define LV_GROUP_KEY_DOWN 18 /*0x12*/
#define LV_GROUP_KEY_RIGHT 19 /*0x13*/ #define LV_GROUP_KEY_RIGHT 19 /*0x13*/
#define LV_GROUP_KEY_LEFT 20 /*0x14*/ #define LV_GROUP_KEY_LEFT 20 /*0x14*/
#define LV_GROUP_KEY_ESC 33 /*0x1B*/ #define LV_GROUP_KEY_ESC 27 /*0x1B*/
#define LV_GROUP_KEY_ENTER 10 /*0x0A, '\n'*/ #define LV_GROUP_KEY_ENTER 10 /*0x0A, '\n'*/
#define LV_GROUP_KEY_NEXT 9 /*0x09, '\t'*/ #define LV_GROUP_KEY_NEXT 9 /*0x09, '\t'*/
#define LV_GROUP_KEY_PREV 11 /*0x0B, '*/ #define LV_GROUP_KEY_PREV 11 /*0x0B, '*/
#define LV_GROUP_KEY_ENTER_LONG 14 /*0x0E, Sent by the library if ENTER is long pressed*/
#if USE_LV_GROUP != 0 #if USE_LV_GROUP != 0
/********************** /**********************
* TYPEDEFS * TYPEDEFS
......
...@@ -349,11 +349,34 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data) ...@@ -349,11 +349,34 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data)
static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
{ {
#if USE_LV_GROUP #if USE_LV_GROUP
if(i->group != NULL && data->key != 0 && if(i->group == NULL) return;
data->state == LV_INDEV_STATE_PR && i->proc.last_state == LV_INDEV_STATE_REL)
/*Key press happened*/
if(data->state == LV_INDEV_STATE_PR &&
i->proc.last_state == LV_INDEV_STATE_REL)
{
i->proc.pr_timestamp = lv_tick_get();
}
/*Pressing*/
else if(data->state == LV_INDEV_STATE_PR && i->proc.last_state == LV_INDEV_STATE_PR) {
if(data->key == LV_GROUP_KEY_ENTER &&
i->proc.long_pr_sent == 0 &&
lv_tick_elaps(i->proc.pr_timestamp) > LV_INDEV_LONG_PRESS_TIME)
{
lv_group_send_data(i->group, LV_GROUP_KEY_ENTER_LONG);
i->proc.long_pr_sent = 1;
}
}
/*Release happened*/
else if(data->state == LV_INDEV_STATE_REL && i->proc.last_state == LV_INDEV_STATE_PR)
{ {
/*The user might clear the key it was released. Always release the pressed key*/
data->key = i->proc.last_key;
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);
} }
else if(data->key == LV_GROUP_KEY_PREV) { else if(data->key == LV_GROUP_KEY_PREV) {
lv_group_focus_prev(i->group); lv_group_focus_prev(i->group);
...@@ -361,8 +384,13 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) ...@@ -361,8 +384,13 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
else { else {
lv_group_send_data(i->group, data->key); lv_group_send_data(i->group, data->key);
} }
i->proc.pr_timestamp = 0;
i->proc.long_pr_sent = 0;
} }
i->proc.last_state = data->state; i->proc.last_state = data->state;
i->proc.last_key = data->key;
#endif #endif
} }
......
...@@ -61,12 +61,14 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t *driver) ...@@ -61,12 +61,14 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t *driver)
node = lv_mem_alloc(sizeof(lv_indev_t)); node = lv_mem_alloc(sizeof(lv_indev_t));
if (!node) return NULL; if (!node) return NULL;
memset(node, 0, sizeof(lv_indev_t));
memcpy(&node->driver, driver, sizeof(lv_indev_drv_t)); memcpy(&node->driver, driver, sizeof(lv_indev_drv_t));
node->next = NULL; node->next = NULL;
node->proc.reset_query = 1; node->proc.reset_query = 1;
node->cursor = NULL; node->cursor = NULL;
node->group = NULL; node->group = NULL;
node->btn_points = NULL;
if (indev_list == NULL) { if (indev_list == NULL) {
indev_list = node; indev_list = node;
......
...@@ -81,6 +81,7 @@ typedef struct _lv_indev_proc_t { ...@@ -81,6 +81,7 @@ typedef struct _lv_indev_proc_t {
}; };
struct { /*Keypad data*/ struct { /*Keypad data*/
lv_indev_state_t last_state; lv_indev_state_t last_state;
uint32_t last_key;
}; };
}; };
......
...@@ -368,14 +368,23 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param) ...@@ -368,14 +368,23 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
res = ext->actions[LV_BTN_ACTION_CLICK](btn); res = ext->actions[LV_BTN_ACTION_CLICK](btn);
} }
} else if(c == LV_GROUP_KEY_ENTER) { } else if(c == LV_GROUP_KEY_ENTER) {
if(lv_btn_get_toggle(btn) != false) { if(!ext->long_pr_action_executed) {
if(state == LV_BTN_STATE_REL) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL); if(lv_btn_get_toggle(btn)) {
else if(state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_TGL_PR); if(state == LV_BTN_STATE_REL) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
else if(state == LV_BTN_STATE_TGL_REL) lv_btn_set_state(btn, LV_BTN_STATE_REL); else if(state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_TGL_PR);
else if(state == LV_BTN_STATE_TGL_PR) lv_btn_set_state(btn, LV_BTN_STATE_PR); else if(state == LV_BTN_STATE_TGL_REL) lv_btn_set_state(btn, LV_BTN_STATE_REL);
else if(state == LV_BTN_STATE_TGL_PR) lv_btn_set_state(btn, LV_BTN_STATE_PR);
}
if(ext->actions[LV_BTN_ACTION_CLICK] && state != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_CLICK](btn);
}
} }
if(ext->actions[LV_BTN_ACTION_CLICK] && state != LV_BTN_STATE_INA) { ext->long_pr_action_executed = 0;
res = ext->actions[LV_BTN_ACTION_CLICK](btn); }
else if(c == LV_GROUP_KEY_ENTER_LONG) {
if(ext->actions[LV_BTN_ACTION_LONG_PR] && state != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_LONG_PR](btn);
ext->long_pr_action_executed = 1;
} }
} }
} }
......
...@@ -516,6 +516,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par ...@@ -516,6 +516,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
if(ext->sel_opt_id + 1 < ext->option_cnt) { if(ext->sel_opt_id + 1 < ext->option_cnt) {
ext->sel_opt_id ++; ext->sel_opt_id ++;
lv_ddlist_pos_current_option(ddlist); lv_ddlist_pos_current_option(ddlist);
lv_obj_invalidate(ddlist);
if(ext->action != NULL) { if(ext->action != NULL) {
ext->action(ddlist); ext->action(ddlist);
} }
...@@ -524,6 +525,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par ...@@ -524,6 +525,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
if(ext->sel_opt_id > 0) { if(ext->sel_opt_id > 0) {
ext->sel_opt_id --; ext->sel_opt_id --;
lv_ddlist_pos_current_option(ddlist); lv_ddlist_pos_current_option(ddlist);
lv_obj_invalidate(ddlist);
if(ext->action != NULL) { if(ext->action != NULL) {
ext->action(ddlist); ext->action(ddlist);
} }
......
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