Impl. menu item scroll down animation

This commit is contained in:
Alvin Wong
2021-05-02 21:36:06 +08:00
parent 969cadc3eb
commit 82c985d785
3 changed files with 94 additions and 7 deletions

View File

@@ -1043,6 +1043,7 @@ void gui_Menu(const menuitem *menu) {
uint8_t scrollContentSize = 0;
bool scrollBlink = false;
bool lastValue = false;
bool scrollingDown = false;
ScrollMessage scrollMessage;
@@ -1068,6 +1069,10 @@ void gui_Menu(const menuitem *menu) {
while ((menu[currentScreen].draw != nullptr) && earlyExit == false) {
OLED::setCursor(0, 0);
if (scrollingDown) {
animOpenState = true;
}
// If the user has hesitated for >=3 seconds, show the long text
// Otherwise "draw" the option
if ((xTaskGetTickCount() - lastButtonTime < (TICKS_SECOND * 3)) || menu[currentScreen].description == 0) {
@@ -1089,6 +1094,18 @@ void gui_Menu(const menuitem *menu) {
lcdRefresh |= scrollMessage.drawUpdate(description, xTaskGetTickCount());
}
if (lcdRefresh) {
if (scrollingDown) {
OLED::transitionScrollDown();
scrollingDown = false;
animOpenState = false;
} else {
OLED::refresh(); // update the LCD
osDelay(40);
}
lcdRefresh = false;
}
ButtonState buttons = getButtonState();
if (buttons != lastButtonState) {
@@ -1115,7 +1132,8 @@ void gui_Menu(const menuitem *menu) {
case BUTTON_B_SHORT:
if (scrollMessage.isReset()) {
currentScreen++;
lastValue = false;
scrollingDown = true;
lastValue = false;
} else
scrollMessage.reset();
break;
@@ -1136,6 +1154,7 @@ void gui_Menu(const menuitem *menu) {
case BUTTON_B_LONG:
if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration > PRESS_ACCEL_INTERVAL_MAX) {
currentScreen++;
scrollingDown = true;
autoRepeatTimer = xTaskGetTickCount();
scrollMessage.reset();
@@ -1151,11 +1170,6 @@ void gui_Menu(const menuitem *menu) {
autoRepeatAcceleration = PRESS_ACCEL_INTERVAL_MAX - PRESS_ACCEL_INTERVAL_MIN;
}
if (lcdRefresh) {
OLED::refresh(); // update the LCD
osDelay(40);
lcdRefresh = false;
}
if ((xTaskGetTickCount() - lastButtonTime) > (TICKS_SECOND * 30)) {
// If user has not pressed any buttons in 30 seconds, exit back a menu layer
// This will trickle the user back to the main screen eventually
@@ -1163,6 +1177,8 @@ void gui_Menu(const menuitem *menu) {
scrollMessage.reset();
}
}
animOpenState = false;
}
void enterSettingsMenu() {