From 0c4d885d5b2590e6db37d5ed81ef7df4df23c028 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Thu, 19 May 2016 15:41:09 +0200 Subject: [PATCH] Speedup sreen update delay Speedup sreen update delay and correct a comment. A module division by 10 is slooooow. (powers of 2 are fast - but then you can AND a bitmask with the same result) --- Marlin/ultralcd.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 7f0b9a271..4d7f80b95 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -282,7 +282,6 @@ menuPosition menu_history[10]; uint8_t menu_history_depth = 0; millis_t next_lcd_update_ms; -uint8_t lcd_status_update_delay; bool ignore_click = false; bool wait_for_unclick; bool defer_return_to_status = false; @@ -2248,9 +2247,13 @@ void lcd_update() { } #endif //ULTIPANEL - // Simply redraw the Info Screen 10 times a second - if (currentMenu == lcd_status_screen && !(++lcd_status_update_delay % 10)) + // Here we arrive every ~100ms when ideling often enough. + // Instead of tracking the changes simply redraw the Info Screen ~1 time a second. + static int8_t lcd_status_update_delay = 1; // first update one loop delayed + if (currentMenu == lcd_status_screen && !lcd_status_update_delay--) { + lcd_status_update_delay = 9; lcdDrawUpdate = LCDVIEW_REDRAW_NOW; + } if (lcdDrawUpdate) {