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] 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 4220ad0a9..7e8f6fda8 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 e67715a3c..c741fd700 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 3ed89f9f4..bf849ad89 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;