From 9a1eb7b2395a05e182340bad0b6808b02da0fa93 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Mon, 10 Apr 2023 12:58:38 +0200 Subject: [PATCH] Prevent rendering of the remaining menu items if the menu is clicked Also prevent clicking --- Firmware/menu.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Firmware/menu.cpp b/Firmware/menu.cpp index ee7d147b1..c76c0ce23 100755 --- a/Firmware/menu.cpp +++ b/Firmware/menu.cpp @@ -77,6 +77,11 @@ void menu_start(void) void menu_end(void) { + if (menu_row >= LCD_HEIGHT) + { + // Early abort if the menu was clicked. The current menu might have changed because of the click event + return; + } if (lcd_encoder >= menu_item) { lcd_encoder = menu_item - 1; @@ -141,6 +146,11 @@ uint8_t menu_item_ret(void) { lcd_draw_update = 2; menu_item++; + + //prevent the rest of the menu items from rendering or getting clicked + menu_row = LCD_HEIGHT; // early exit from the MENU_BEGIN() for loop at the end of the current cycle + menu_line = 0; // prevent subsequent menu items from rendering at all in the current MENU_BEGIN() for loop cycle + menu_clicked = 0; // prevent subsequent items from being able to be clicked in case the current menu or position was changed by the clicked menu item return 1; }