From a27db526afd51f3b2c1caa9751f83a08a7944b91 Mon Sep 17 00:00:00 2001 From: Alvin Wong Date: Mon, 3 May 2021 16:53:45 +0800 Subject: [PATCH] Remove the scroll indicator when scrolling menu --- source/Core/Drivers/OLED.cpp | 30 ++++++++++++++++++++++++++++++ source/Core/Drivers/OLED.hpp | 1 + source/Core/Src/gui.cpp | 3 ++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index 65dce02b..fc8ef266 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -211,6 +211,36 @@ void OLED::drawScrollIndicator(uint8_t y, uint8_t height) { fillArea(OLED_WIDTH - 1, 8, 1, 8, column.strips[1]); } +/** + * Masks (removes) the scrolling indicator, i.e. clears the rightmost column + * on the screen. This operates directly on the OLED graphics RAM, as this + * is intended to be used before calling `OLED::transitionScrollDown()`. + */ +void OLED::maskScrollIndicatorOnOLED() { + // The right-most column depends on the screen rotation, so just take + // it from the screen buffer which is updated by `OLED::setRotation`. + uint8_t rightmostColumn = screenBuffer[7]; + uint8_t maskCommands[] = { + // Set column address: + // A[6:0] - Column start address = rightmost column + // B[6:0] - Column end address = rightmost column + 0x80, + 0x21, // cmd + 0x80, + rightmostColumn, // A + 0x80, + rightmostColumn, // B + + // Start of data + 0x40, + + // Clears two 8px strips + 0x00, + 0x00, + }; + FRToSI2C::Transmit(DEVICEADDR_OLED, maskCommands, sizeof(maskCommands)); +} + /** * Plays a transition animation between two framebuffers. * @param forwardNavigation Direction of the navigation animation. diff --git a/source/Core/Drivers/OLED.hpp b/source/Core/Drivers/OLED.hpp index 7d88ac96..c108dcf7 100644 --- a/source/Core/Drivers/OLED.hpp +++ b/source/Core/Drivers/OLED.hpp @@ -79,6 +79,7 @@ public: static void drawFilledRect(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, bool clear); static void drawHeatSymbol(uint8_t state); static void drawScrollIndicator(uint8_t p, uint8_t h); // Draws a scrolling position indicator + static void maskScrollIndicatorOnOLED(); static void transitionSecondaryFramebuffer(bool forwardNavigation); static void useSecondaryFramebuffer(bool useSecondary); static void transitionScrollDown(); diff --git a/source/Core/Src/gui.cpp b/source/Core/Src/gui.cpp index 15a6a82e..63eb711f 100644 --- a/source/Core/Src/gui.cpp +++ b/source/Core/Src/gui.cpp @@ -1086,7 +1086,7 @@ void gui_Menu(const menuitem *menu) { uint8_t position = OLED_HEIGHT * currentScreen / scrollContentSize; if (lastValue) scrollBlink = !scrollBlink; - if (!lastValue || !scrollBlink) + if ((!lastValue || !scrollBlink) && !scrollingDown) OLED::drawScrollIndicator(position, indicatorHeight); } else { // Draw description @@ -1096,6 +1096,7 @@ void gui_Menu(const menuitem *menu) { if (lcdRefresh) { if (scrollingDown) { + OLED::maskScrollIndicatorOnOLED(); OLED::transitionScrollDown(); scrollingDown = false; animOpenState = false;