From 7fcd2b7c5bb3af31a7e60ef99561a306a7f48845 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" <5425387+Ralim@users.noreply.github.com> Date: Fri, 12 Aug 2022 10:36:10 +1000 Subject: [PATCH] Animation non block (#1347) * Buttons cancel animation * Button cancels transition * Update OLED.cpp --- source/Core/Drivers/OLED.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index 0832c48f..60bad499 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -5,6 +5,7 @@ * Author: Ben V. Brown */ +#include "Buttons.hpp" #include "Translation.h" #include "cmsis_os.h" #include "configuration.h" @@ -285,7 +286,10 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) { memmove(&secondStripPtr[newStart], &secondBackStripPtr[newEnd], progress); refresh(); - osDelay(TICKS_100MS / 5); + osDelay(TICKS_100MS / 7); + if (getButtonState() != BUTTON_NONE) { + return; + } } } @@ -324,6 +328,10 @@ void OLED::transitionScrollDown() { // Scroll the screen by changing display start line. for (uint8_t current = startLine; current <= scrollTo; current++) { + if (getButtonState() != BUTTON_NONE) { + current = scrollTo; + } + // Set display start line (0x40~0x7F): // X[5:0] - display start line value uint8_t scrollCommandByte = 0b01000000 | (current & 0b00111111); @@ -332,7 +340,7 @@ void OLED::transitionScrollDown() { OLED_Setup_Array[8].val = scrollCommandByte; I2C_CLASS::I2C_RegisterWrite(DEVICEADDR_OLED, 0x80, scrollCommandByte); - osDelay(TICKS_100MS / 5); + osDelay(TICKS_100MS / 7); } }