1
0
forked from me/IronOS

Remove the scroll indicator when scrolling menu

This commit is contained in:
Alvin Wong
2021-05-03 16:53:45 +08:00
parent 82c985d785
commit a27db526af
3 changed files with 33 additions and 1 deletions

View File

@@ -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.

View File

@@ -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();

View File

@@ -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;