Tidy up code

This commit is contained in:
fvanroie 2021-03-23 11:33:19 +01:00
parent 57435c6c33
commit e07857533a

View File

@ -24,6 +24,10 @@
#include "hasplib.h" #include "hasplib.h"
#define HASP_NUM_PAGE_PREV (HASP_NUM_PAGES + 1)
#define HASP_NUM_PAGE_BACK (HASP_NUM_PAGES + 2)
#define HASP_NUM_PAGE_NEXT (HASP_NUM_PAGES + 3)
const char** btnmatrix_default_map; // memory pointer to lvgl default btnmatrix map const char** btnmatrix_default_map; // memory pointer to lvgl default btnmatrix map
// static unsigned long last_change_event = 0; // static unsigned long last_change_event = 0;
static bool last_press_was_short = false; // Avoid SHORT + UP double events static bool last_press_was_short = false; // Avoid SHORT + UP double events
@ -370,13 +374,17 @@ void generic_event_handler(lv_obj_t* obj, lv_event_t event)
if(obj->user_data.actionid) { if(obj->user_data.actionid) {
if(eventid == HASP_EVENT_UP || eventid == HASP_EVENT_SHORT) { if(eventid == HASP_EVENT_UP || eventid == HASP_EVENT_SHORT) {
lv_scr_load_anim_t transitionid = (lv_scr_load_anim_t)obj->user_data.transitionid; lv_scr_load_anim_t transitionid = (lv_scr_load_anim_t)obj->user_data.transitionid;
if(obj->user_data.actionid == HASP_NUM_PAGES + 1) { switch(obj->user_data.actionid) {
case HASP_NUM_PAGE_PREV:
haspPages.prev(transitionid); haspPages.prev(transitionid);
} else if(obj->user_data.actionid == HASP_NUM_PAGES + 2) { break;
case HASP_NUM_PAGE_BACK:
haspPages.back(transitionid); haspPages.back(transitionid);
} else if(obj->user_data.actionid == HASP_NUM_PAGES + 3) { break;
case HASP_NUM_PAGE_NEXT:
haspPages.next(transitionid); haspPages.next(transitionid);
} else { break;
default:
haspPages.set(obj->user_data.actionid, transitionid); haspPages.set(obj->user_data.actionid, transitionid);
} }
dispatch_output_current_page(); dispatch_output_current_page();