Skip to content
Prev Previous commit
Fix missing button up unregister
  • Loading branch information
Jared-Is-Coding committed Oct 9, 2025
commit d7c7334a5d7294073e4683a721e435df8cb6a0c0
6 changes: 6 additions & 0 deletions firmware/src/screens/menu_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ void add_main_menu_navigation_buttons(lv_obj_t *body_item) {

for (uint32_t i = 0; i < total_buttons; i++) {
lv_obj_t *item = NULL;

if (lv_obj_get_child_cnt(body_item) > i) {
item = lv_obj_get_child(body_item, i);

if (item == NULL) {
item = lv_btn_create(body_item);
}
Expand All @@ -104,20 +106,24 @@ void add_main_menu_navigation_buttons(lv_obj_t *body_item) {
if (button_entries[i].short_press) {
lv_obj_add_event_cb(item, button_entries[i].short_press, LV_EVENT_CLICKED, NULL);
}

if (button_entries[i].long_press) {
lv_obj_add_event_cb(item, button_entries[i].long_press, LV_EVENT_LONG_PRESSED, NULL);
}

if (button_entries[i].down) {
lv_obj_add_event_cb(item, button_entries[i].down, LV_EVENT_PRESSED, NULL);
}

lv_obj_t *label = NULL;

if (lv_obj_get_child_cnt(item) > 0) {
label = lv_obj_get_child(item, 0);
}
else {
label = lv_label_create(item);
}

lv_obj_set_width(label, LV_SIZE_CONTENT);
lv_obj_set_height(label, LV_SIZE_CONTENT);
lv_obj_set_align(label, LV_ALIGN_CENTER);
Expand Down
5 changes: 5 additions & 0 deletions firmware/src/screens/stats_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,9 @@ static bool button_long_press_handler() {

static bool button_up_handler() {
ESP_LOGI(TAG, "Stats screen button up");

long_press_handled = false;

return true;
}

Expand Down Expand Up @@ -645,10 +647,13 @@ void stats_screen_loaded(lv_event_t *e) {

void stats_screen_unload_start(lv_event_t *e) {
ESP_LOGI(TAG, "Stats screen unload start");

stats_unregister_update_cb(stats_update_screen_display);

unregister_primary_button_cb(BUTTON_EVENT_PRESS);
unregister_primary_button_cb(BUTTON_EVENT_DOUBLE_PRESS);
unregister_primary_button_cb(BUTTON_EVENT_LONG_PRESS_HOLD);
unregister_primary_button_cb(BUTTON_EVENT_UP);
}

bool proceed_with_gesture() {
Expand Down
Loading