diff --git a/Firmware/menu.cpp b/Firmware/menu.cpp index 9c7704e6..efa88073 100755 --- a/Firmware/menu.cpp +++ b/Firmware/menu.cpp @@ -252,8 +252,7 @@ static void menu_draw_item_puts_P(char type_char, const char* str, char num) lcd_set_cursor(0, menu_row); lcd_printf_P(PSTR("%c%-.16S "), menu_selection_mark(), str); lcd_putc(num); - lcd_set_cursor(19, menu_row); - lcd_putc(type_char); + lcd_putc_at(19, menu_row, type_char); } /* @@ -312,7 +311,7 @@ uint8_t menu_item_submenu_E(const Sheet &sheet, menu_func_t submenu) return 0; } -uint8_t menu_item_function_E(const Sheet &sheet, menu_func_t func) +uint8_t __attribute__((noinline)) menu_item_function_E(const Sheet &sheet, menu_func_t func) { if (menu_item == menu_line) { @@ -346,6 +345,10 @@ uint8_t menu_item_back_P(const char* str) return 0; } +bool __attribute__((noinline)) menu_item_leave(){ + return ((menu_item == menu_line) && menu_clicked && (lcd_encoder == menu_item)) || menu_leaving; +} + uint8_t menu_item_function_P(const char* str, menu_func_t func) { if (menu_item == menu_line) diff --git a/Firmware/menu.h b/Firmware/menu.h index 88363359..c255393d 100755 --- a/Firmware/menu.h +++ b/Firmware/menu.h @@ -112,7 +112,8 @@ extern uint8_t menu_item_function_E(const Sheet &sheet, menu_func_t func); extern uint8_t menu_item_back_P(const char* str); // leaving menu - this condition must be immediately before MENU_ITEM_BACK_P -#define ON_MENU_LEAVE(func) do { if (((menu_item == menu_line) && menu_clicked && (lcd_encoder == menu_item)) || menu_leaving){ func } } while (0) +#define ON_MENU_LEAVE(func) do { if (menu_item_leave()){ func } } while (0) +extern bool menu_item_leave(); #define MENU_ITEM_FUNCTION_P(str, func) do { if (menu_item_function_P(str, func)) return; } while (0) extern uint8_t menu_item_function_P(const char* str, menu_func_t func);