From 2cb27c9b882e48e4341224e4fde83235872bd3e0 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 9 Apr 2024 20:27:57 +1000 Subject: [PATCH] Draw every other one on transitions --- source/Core/Drivers/OLED.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index b81a4c1c..7d641dbb 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -282,8 +282,10 @@ void OLED::transitionSecondaryFramebuffer(const bool forwardNavigation, const Ti TickType_t duration = 0; TickType_t start = xTaskGetTickCount(); uint8_t offset = 0; + uint32_t loopCounter = 0; TickType_t startDraw = xTaskGetTickCount(); while (duration <= totalDuration) { + loopCounter++; duration = xTaskGetTickCount() - start; uint16_t progress = ((duration * 100) / totalDuration); // Percentage of the period we are through for animation progress = easeInOutTiming(progress); @@ -321,7 +323,14 @@ void OLED::transitionSecondaryFramebuffer(const bool forwardNavigation, const Ti memmove(&stripPointers[3][newStart], &stripBackPointers[3][newEnd], progress); #endif /* OLED_128x32 */ +#ifdef OLED_128x32 + if (loopCounter % 2 == 0) { + refresh(); + } +#else refresh(); // Now refresh to write out the contents to the new page +#endif /* OLED_128x32 */ + vTaskDelayUntil(&startDraw, TICKS_100MS / 7); buttonsReleased |= getButtonState() == BUTTON_NONE; if (getButtonState() != BUTTON_NONE && buttonsReleased) { @@ -330,7 +339,7 @@ void OLED::transitionSecondaryFramebuffer(const bool forwardNavigation, const Ti return; } } - refresh(); // + refresh(); // redraw at the end if required } void OLED::useSecondaryFramebuffer(bool useSecondary) { @@ -455,7 +464,15 @@ void OLED::transitionScrollUp(const TickType_t viewEnterTime) { refresh(); // Now refresh to write out the contents to the new page return; } + +#ifdef OLED_128x32 + // To keep things faster, only redraw every second line + if (heightPos % 2 == 0) { + refresh(); // Now refresh to write out the contents to the new page + } +#else refresh(); // Now refresh to write out the contents to the new page +#endif vTaskDelayUntil(&startDraw, TICKS_100MS / 7); } }