From 33a0a58810dd0873e0f992683e8484a60ef2862b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 30 Apr 2022 13:59:04 +0000 Subject: [PATCH 1/3] Optimise manage_inactivity call in loop() Saves 12 bytes of flash --- Firmware/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index e2069d20..7b423049 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1940,7 +1940,7 @@ void loop() } //check heater every n milliseconds manage_heater(); - isPrintPaused ? manage_inactivity(true) : manage_inactivity(false); + manage_inactivity(isPrintPaused); checkHitEndstops(); lcd_update(0); #ifdef TMC2130 From f6fd91a235f7cafab5164213687d62a840538676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 30 Apr 2022 14:12:24 +0000 Subject: [PATCH 2/3] Optimise lcd_status_screen Saves 20 bytes of flash --- Firmware/lcd.cpp | 1 - Firmware/lcd.h | 2 -- Firmware/ultralcd.cpp | 12 +++++------- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Firmware/lcd.cpp b/Firmware/lcd.cpp index 4220ad0a..7e8f6fda 100644 --- a/Firmware/lcd.cpp +++ b/Firmware/lcd.cpp @@ -638,7 +638,6 @@ uint8_t lcd_button_pressed = 0; uint8_t lcd_update_enabled = 1; uint32_t lcd_next_update_millis = 0; -uint8_t lcd_status_update_delay = 0; diff --git a/Firmware/lcd.h b/Firmware/lcd.h index e67715a3..c741fd70 100644 --- a/Firmware/lcd.h +++ b/Firmware/lcd.h @@ -107,8 +107,6 @@ extern LongTimer lcd_timeoutToStatus; extern uint32_t lcd_next_update_millis; -extern uint8_t lcd_status_update_delay; - extern lcd_longpress_func_t lcd_longpress_func; extern bool lcd_longpress_trigger; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 3ed89f9f..bf849ad8 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -758,6 +758,7 @@ void lcdui_print_status_screen(void) // Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent void lcd_status_screen() // NOT static due to using inside "Marlin_main" module ("manage_inactivity()") { + static uint8_t lcd_status_update_delay = 0; #ifdef ULTIPANEL_FEEDMULTIPLY // Dead zone at 100% feedrate if ((feedmultiply < 100 && (feedmultiply + int(lcd_encoder)) > 100) || @@ -791,11 +792,9 @@ void lcd_status_screen() // NOT static due to using ins if (lcd_status_update_delay) lcd_status_update_delay--; else - lcd_draw_update = 1; - - - if (lcd_draw_update) - { + { // Redraw the main screen every second (see LCD_UPDATE_INTERVAL). + // This is easier then trying keep track of all things that change on the screen + lcd_status_update_delay = 10; ReInitLCD++; if (ReInitLCD == 30) { @@ -832,10 +831,9 @@ void lcd_status_screen() // NOT static due to using ins } } // end of farm_mode - lcd_status_update_delay = 10; /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */ if (lcd_commands_type != LcdCommands::Idle) lcd_commands(); - } // end of lcd_draw_update + } bool current_click = LCD_CLICKED; From ca8d47a6da33e74b89a29b5c0a6bb1decac951bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Wed, 27 Jul 2022 11:55:08 +0000 Subject: [PATCH 3/3] If lcd_draw_update is set outside lcd_status_screen then render the sceen without delay This adds only 10 bytes of flash --- Firmware/ultralcd.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index bf849ad8..2d28c9f6 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -789,6 +789,11 @@ void lcd_status_screen() // NOT static due to using ins else if (feedmultiply > 999) feedmultiply = 999; + if (lcd_draw_update) { + // Update the status screen immediately + lcd_status_update_delay = 0; + } + if (lcd_status_update_delay) lcd_status_update_delay--; else