From 23613c7eb16b34756126604de2555b80e91d74c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Thu, 24 Nov 2022 19:00:33 +0000 Subject: [PATCH] optimisation: Stop print menu There is no need to manually track the cursor position. We can use the menu API: MENU_BEGIN() ... // menu items in between here ... MENU_END() Change in memory: Flash: -116 bytes SRAM: 0 bytes --- Firmware/ultralcd.cpp | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index abfdf3080..3d66d4814 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -5819,31 +5819,18 @@ void lcd_temp_model_cal() void lcd_sdcard_stop() { + // Show static message + lcd_puts_at_P(0, 0, _T(MSG_STOP_PRINT)); + lcd_putc_at(0, 1, '\n'); - lcd_puts_at_P(0, 0, _T(MSG_STOP_PRINT)); - lcd_puts_at_P(2, 2, _T(MSG_NO)); - lcd_puts_at_P(2, 3, _T(MSG_YES)); - lcd_putc_at(0, 2, ' '); - lcd_putc_at(0, 3, ' '); - - if ((int32_t)lcd_encoder > 2) { lcd_encoder = 2; } - if ((int32_t)lcd_encoder < 1) { lcd_encoder = 1; } - - lcd_putc_at(0, 1 + lcd_encoder, '>'); - - if (lcd_clicked()) - { - Sound_MakeSound(e_SOUND_TYPE_ButtonEcho); - if ((int32_t)lcd_encoder == 1) - { - lcd_return_to_status(); - } - if ((int32_t)lcd_encoder == 2) - { - lcd_print_stop(); - } - } + MENU_BEGIN(); + // Skip first two LCD rows used by static message + if(menu_row == 0) menu_row = 2; + // Show No options first, the default selection + MENU_ITEM_FUNCTION_P(_T(MSG_NO), lcd_return_to_status); + MENU_ITEM_FUNCTION_P(_T(MSG_YES), lcd_print_stop); + MENU_END(); } void lcd_sdcard_menu()