From b548813827eba177f7ad7e62ce6c482316068879 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 18 Jun 2023 21:37:08 +1000 Subject: [PATCH] High res capable scroll down --- source/Core/Drivers/OLED.cpp | 23 ++++++++++++++++++++++- source/Core/Drivers/OLED.hpp | 2 +- source/Core/Src/settingsGUI.cpp | 4 +--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index 9bcb1da5a6..de0ca49be2 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -336,7 +336,27 @@ void OLED::transitionScrollDown() { // For each line, we shuffle all bits up a row for (uint8_t xPos = 0; xPos < OLED_WIDTH; xPos++) { const uint16_t firstStripPos = FRAMEBUFFER_START + xPos; - const uint16_t secondStripPos = FRAMEBUFFER_START + xPos + OLED_WIDTH; + const uint16_t secondStripPos = firstStripPos + OLED_WIDTH; +#ifdef OLED_128x32 + // For 32 pixel high OLED's we have four strips to tailchain + const uint16_t thirdStripPos = secondStripPos + OLED_WIDTH; + const uint16_t fourthStripPos = thirdStripPos + OLED_WIDTH; + // Move the MSB off the first strip, and pop MSB from second strip onto the first strip + screenBuffer[firstStripPos] = (screenBuffer[firstStripPos] >> 1) | ((screenBuffer[secondStripPos] & 0x01) << 7); + // Now shuffle off the second strip + screenBuffer[secondStripPos] = (screenBuffer[secondStripPos] >> 1) | ((screenBuffer[thirdStripPos] & 0x01) << 7); + // Now shuffle off the third strip + screenBuffer[thirdStripPos] = (screenBuffer[thirdStripPos] >> 1) | ((screenBuffer[fourthStripPos] & 0x01) << 7); + // Now forth strip gets the start of the new buffer + screenBuffer[fourthStripPos] = (screenBuffer[fourthStripPos] >> 1) | ((secondFrameBuffer[firstStripPos] & 0x01) << 7); + // Now cycle all the secondary buffers + + secondFrameBuffer[firstStripPos] = (secondFrameBuffer[firstStripPos] >> 1) | ((secondFrameBuffer[secondStripPos] & 0x01) << 7); + secondFrameBuffer[secondStripPos] = (secondFrameBuffer[secondStripPos] >> 1) | ((secondFrameBuffer[thirdStripPos] & 0x01) << 7); + secondFrameBuffer[thirdStripPos] = (secondFrameBuffer[thirdStripPos] >> 1) | ((secondFrameBuffer[fourthStripPos] & 0x01) << 7); + // Finally on the bottom row; we shuffle it up ready + secondFrameBuffer[fourthStripPos] >>= 1; +#else // Move the MSB off the first strip, and pop MSB from second strip onto the first strip screenBuffer[firstStripPos] = (screenBuffer[firstStripPos] >> 1) | ((screenBuffer[secondStripPos] & 0x01) << 7); // Now shuffle off the second strip MSB, and replace it with the MSB of the secondary buffer @@ -345,6 +365,7 @@ void OLED::transitionScrollDown() { secondFrameBuffer[firstStripPos] = (secondFrameBuffer[firstStripPos] >> 1) | ((secondFrameBuffer[secondStripPos] & 0x01) << 7); // Finally on the bottom row; we shuffle it up ready secondFrameBuffer[secondStripPos] >>= 1; +#endif } refresh(); // Now refresh to write out the contents to the new page diff --git a/source/Core/Drivers/OLED.hpp b/source/Core/Drivers/OLED.hpp index 5cfc9ee0b0..eb71b86a27 100644 --- a/source/Core/Drivers/OLED.hpp +++ b/source/Core/Drivers/OLED.hpp @@ -77,7 +77,7 @@ class OLED { static void refresh() { if (checkDisplayBufferChecksum()) { - const int len = FRAMEBUFFER_START + (OLED_WIDTH * 2); + const int len = FRAMEBUFFER_START + (OLED_WIDTH * (OLED_HEIGHT / 8)); I2C_CLASS::Transmit(DEVICEADDR_OLED, screenBuffer, len); // DMA tx time is ~ 20mS Ensure after calling this you delay for at least 25ms // or we need to goto double buffering diff --git a/source/Core/Src/settingsGUI.cpp b/source/Core/Src/settingsGUI.cpp index c65596c408..f90af52017 100644 --- a/source/Core/Src/settingsGUI.cpp +++ b/source/Core/Src/settingsGUI.cpp @@ -1006,9 +1006,6 @@ void gui_Menu(const menuitem *menu) { animOpenState = true; // The menu entering/exiting transition uses the secondary framebuffer, // but the scroll down transition does not. - if (navState == NavState::ScrollingDown) { - OLED::useSecondaryFramebuffer(false); - } OLED::setCursor(0, 0); OLED::clearScreen(); if (menu[currentScreen].shortDescriptionSize > 0) { @@ -1019,6 +1016,7 @@ void gui_Menu(const menuitem *menu) { // Play the scroll down animation. OLED::maskScrollIndicatorOnOLED(); OLED::transitionScrollDown(); + OLED::useSecondaryFramebuffer(false); } else { // The menu was drawn in a secondary framebuffer. // Now we play a transition from the pre-drawn primary