From 4cb7dfc546c826c1f06555a7ed1f45b9ad7e140e Mon Sep 17 00:00:00 2001 From: AnHardt Date: Sat, 4 Apr 2015 17:34:28 +0200 Subject: [PATCH 1/5] Move the 'alive dot' in every displayloop Result see: https://www.youtube.com/watch?v=tdu7J0i-c4g Loop is executed several times per display update. --- Marlin/dogm_lcd_implementation.h | 4 ++-- Marlin/ultralcd.cpp | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index c057e5642..81234c0f0 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -318,9 +318,9 @@ static void lcd_implementation_status_screen() { lcd_setFont(FONT_STATUSMENU); #ifdef USE_SMALL_INFOFONT - u8g.drawBox(0,30,128,10); + u8g.drawBox(0,30,127,10); #else - u8g.drawBox(0,30,128,9); + u8g.drawBox(0,30,127,9); #endif u8g.setColorIndex(0); // white on black u8g.setPrintPos(2,XYZ_BASELINE); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 8aada85b0..64b91f699 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1299,6 +1299,8 @@ void lcd_update() { } #endif//CARDINSERTED + static uint8_t dotcounter = 63; + uint32_t ms = millis(); if (ms > lcd_next_update_millis) { @@ -1362,11 +1364,12 @@ void lcd_update() { blink++; // Variable for fan animation and alive dot u8g.firstPage(); do { + if (!dotcounter) dotcounter = 63; lcd_setFont(FONT_MENU); u8g.setPrintPos(125, 0); - if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot - u8g.drawPixel(127, 63); // draw alive dot - u8g.setColorIndex(1); // black on white +// if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot + u8g.drawPixel(127, dotcounter--); // draw alive dot +// u8g.setColorIndex(1); // black on white (*currentMenu)(); if (!lcdDrawUpdate) break; // Terminate display update, when nothing new to draw. This must be done before the last dogm.next() } while( u8g.nextPage() ); From 6d4b3f0d6a668f6c038c16cf9587f424f2968778 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Sat, 4 Apr 2015 17:49:39 +0200 Subject: [PATCH 2/5] Move the condition before the loop Result see: https://youtu.be/AEnBzdu9_tk Dot is moving not so fast -> less executed loops. --- Marlin/ultralcd.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 64b91f699..1c124a006 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1363,16 +1363,18 @@ void lcd_update() { #ifdef DOGLCD // Changes due to different driver architecture of the DOGM display blink++; // Variable for fan animation and alive dot u8g.firstPage(); - do { - if (!dotcounter) dotcounter = 63; - lcd_setFont(FONT_MENU); - u8g.setPrintPos(125, 0); -// if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot - u8g.drawPixel(127, dotcounter--); // draw alive dot -// u8g.setColorIndex(1); // black on white - (*currentMenu)(); - if (!lcdDrawUpdate) break; // Terminate display update, when nothing new to draw. This must be done before the last dogm.next() - } while( u8g.nextPage() ); + (*currentMenu)(); + if (lcdDrawUpdate) { + do { + if (!dotcounter) dotcounter = 63; + lcd_setFont(FONT_MENU); + u8g.setPrintPos(125, 0); + // if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot + u8g.drawPixel(127, dotcounter--); // draw alive dot + // u8g.setColorIndex(1); // black on white + (*currentMenu)(); + } while( u8g.nextPage() ); + } #else (*currentMenu)(); #endif From 6361404b91dcf8ba657b1f1e16d9717a8e280ae6 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Sat, 4 Apr 2015 17:56:13 +0200 Subject: [PATCH 3/5] Testloop cleanup Shifted condition should still be in. --- Marlin/dogm_lcd_implementation.h | 4 ++-- Marlin/ultralcd.cpp | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 81234c0f0..c057e5642 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -318,9 +318,9 @@ static void lcd_implementation_status_screen() { lcd_setFont(FONT_STATUSMENU); #ifdef USE_SMALL_INFOFONT - u8g.drawBox(0,30,127,10); + u8g.drawBox(0,30,128,10); #else - u8g.drawBox(0,30,127,9); + u8g.drawBox(0,30,128,9); #endif u8g.setColorIndex(0); // white on black u8g.setPrintPos(2,XYZ_BASELINE); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 1c124a006..a3413bfbe 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1299,8 +1299,6 @@ void lcd_update() { } #endif//CARDINSERTED - static uint8_t dotcounter = 63; - uint32_t ms = millis(); if (ms > lcd_next_update_millis) { @@ -1366,12 +1364,11 @@ void lcd_update() { (*currentMenu)(); if (lcdDrawUpdate) { do { - if (!dotcounter) dotcounter = 63; lcd_setFont(FONT_MENU); u8g.setPrintPos(125, 0); - // if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot - u8g.drawPixel(127, dotcounter--); // draw alive dot - // u8g.setColorIndex(1); // black on white + if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot + u8g.drawPixel(127, 63); // draw alive dot + u8g.setColorIndex(1); // black on white (*currentMenu)(); } while( u8g.nextPage() ); } From 418d22d7b3d7099aa3aeea79c3e901cb0e5a7f31 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Sat, 4 Apr 2015 18:33:36 +0200 Subject: [PATCH 4/5] Revert "Testloop cleanup" This reverts commit 6361404b91dcf8ba657b1f1e16d9717a8e280ae6. --- Marlin/dogm_lcd_implementation.h | 4 ++-- Marlin/ultralcd.cpp | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index c057e5642..81234c0f0 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -318,9 +318,9 @@ static void lcd_implementation_status_screen() { lcd_setFont(FONT_STATUSMENU); #ifdef USE_SMALL_INFOFONT - u8g.drawBox(0,30,128,10); + u8g.drawBox(0,30,127,10); #else - u8g.drawBox(0,30,128,9); + u8g.drawBox(0,30,127,9); #endif u8g.setColorIndex(0); // white on black u8g.setPrintPos(2,XYZ_BASELINE); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index a3413bfbe..1c124a006 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1299,6 +1299,8 @@ void lcd_update() { } #endif//CARDINSERTED + static uint8_t dotcounter = 63; + uint32_t ms = millis(); if (ms > lcd_next_update_millis) { @@ -1364,11 +1366,12 @@ void lcd_update() { (*currentMenu)(); if (lcdDrawUpdate) { do { + if (!dotcounter) dotcounter = 63; lcd_setFont(FONT_MENU); u8g.setPrintPos(125, 0); - if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot - u8g.drawPixel(127, 63); // draw alive dot - u8g.setColorIndex(1); // black on white + // if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot + u8g.drawPixel(127, dotcounter--); // draw alive dot + // u8g.setColorIndex(1); // black on white (*currentMenu)(); } while( u8g.nextPage() ); } From 340d165a9cb87dfbfbacc680989717c79b5bdffe Mon Sep 17 00:00:00 2001 From: AnHardt Date: Sat, 4 Apr 2015 22:02:24 +0200 Subject: [PATCH 5/5] Reduce display updates for dogm displays In 'if (encoderPastThreshold || LCD_CLICKED)' lcdDrawUpdate was not set. 'lcd_status_update_delay'-loop was not effective in function lcd_status_screen(). The loop prevented the update of the status screen but not the displays update. Shifted the loop into lcd_update(). --- Marlin/dogm_lcd_implementation.h | 4 ++-- Marlin/ultralcd.cpp | 37 ++++++++++++++------------------ 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 81234c0f0..c057e5642 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -318,9 +318,9 @@ static void lcd_implementation_status_screen() { lcd_setFont(FONT_STATUSMENU); #ifdef USE_SMALL_INFOFONT - u8g.drawBox(0,30,127,10); + u8g.drawBox(0,30,128,10); #else - u8g.drawBox(0,30,127,9); + u8g.drawBox(0,30,128,9); #endif u8g.setColorIndex(0); // white on black u8g.setPrintPos(2,XYZ_BASELINE); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 1c124a006..034adc394 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -262,8 +262,7 @@ static void lcd_goto_menu(menuFunc_t menu, const uint32_t encoder=0, const bool } /* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */ -static void lcd_status_screen() -{ +static void lcd_status_screen() { encoderRateMultiplierEnabled = false; #ifdef LCD_PROGRESS_BAR @@ -296,15 +295,7 @@ static void lcd_status_screen() #endif #endif //LCD_PROGRESS_BAR - if (lcd_status_update_delay) - lcd_status_update_delay--; - else - lcdDrawUpdate = 1; - - if (lcdDrawUpdate) { lcd_implementation_status_screen(); - 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 */ - } #ifdef ULTIPANEL @@ -1298,8 +1289,6 @@ void lcd_update() { } } #endif//CARDINSERTED - - static uint8_t dotcounter = 63; uint32_t ms = millis(); if (ms > lcd_next_update_millis) { @@ -1351,27 +1340,33 @@ void lcd_update() { } // encoderRateMultiplierEnabled #endif //ENCODER_RATE_MULTIPLIER - lcdDrawUpdate = 1; encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP; encoderDiff = 0; } timeoutToStatus = ms + LCD_TIMEOUT_TO_STATUS; + lcdDrawUpdate = 1; } - #endif //ULTIPANEL + if (currentMenu == lcd_status_screen) { + if (!lcd_status_update_delay) { + lcdDrawUpdate = 1; + 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 */ + } + else { + lcd_status_update_delay--; + } + } #ifdef DOGLCD // Changes due to different driver architecture of the DOGM display - blink++; // Variable for fan animation and alive dot - u8g.firstPage(); - (*currentMenu)(); if (lcdDrawUpdate) { + blink++; // Variable for fan animation and alive dot + u8g.firstPage(); do { - if (!dotcounter) dotcounter = 63; lcd_setFont(FONT_MENU); u8g.setPrintPos(125, 0); - // if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot - u8g.drawPixel(127, dotcounter--); // draw alive dot - // u8g.setColorIndex(1); // black on white + if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot + u8g.drawPixel(127, 63); // draw alive dot + u8g.setColorIndex(1); // black on white (*currentMenu)(); } while( u8g.nextPage() ); }