Fixes for some animations not running

Dont bail on animations if keypress is still held
This commit is contained in:
Ben V. Brown
2023-07-22 17:01:28 +10:00
parent bf00e1bc58
commit 86fed6bfbe
4 changed files with 58 additions and 55 deletions

View File

@@ -262,7 +262,8 @@ void OLED::maskScrollIndicatorOnOLED() {
* If forward is true, this displays a forward navigation to the second framebuffer contents.
* Otherwise a rewinding navigation animation is shown to the second framebuffer contents.
*/
void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
void OLED::transitionSecondaryFramebuffer(const bool forwardNavigation, const TickType_t viewEnterTime) {
bool buttonsReleased = getButtonState() == BUTTON_NONE;
uint8_t *stripBackPointers[4];
stripBackPointers[0] = &secondFrameBuffer[FRAMEBUFFER_START + 0];
stripBackPointers[1] = &secondFrameBuffer[FRAMEBUFFER_START + OLED_WIDTH];
@@ -317,7 +318,8 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
refresh(); // Now refresh to write out the contents to the new page
vTaskDelayUntil(&startDraw, TICKS_100MS / 7);
if (getButtonState() != BUTTON_NONE) {
buttonsReleased |= getButtonState() == BUTTON_NONE;
if (getButtonState() != BUTTON_NONE && buttonsReleased) {
memcpy(screenBuffer + FRAMEBUFFER_START, secondFrameBuffer + FRAMEBUFFER_START, sizeof(screenBuffer) - FRAMEBUFFER_START);
refresh(); // Now refresh to write out the contents to the new page
return;
@@ -340,8 +342,9 @@ void OLED::useSecondaryFramebuffer(bool useSecondary) {
*
* **This function blocks until the transition has completed or user presses button**
*/
void OLED::transitionScrollDown() {
TickType_t startDraw = xTaskGetTickCount();
void OLED::transitionScrollDown(const TickType_t viewEnterTime) {
TickType_t startDraw = xTaskGetTickCount();
bool buttonsReleased = getButtonState() == BUTTON_NONE;
for (uint8_t heightPos = 0; heightPos < OLED_HEIGHT; heightPos++) {
// For each line, we shuffle all bits up a row
@@ -378,7 +381,8 @@ void OLED::transitionScrollDown() {
secondFrameBuffer[secondStripPos] >>= 1;
#endif /* OLED_128x32 */
}
if (getButtonState() != BUTTON_NONE) {
buttonsReleased |= getButtonState() == BUTTON_NONE;
if (getButtonState() != BUTTON_NONE && buttonsReleased) {
// Exit early, but have to transition whole buffer
memcpy(screenBuffer + FRAMEBUFFER_START, secondFrameBuffer + FRAMEBUFFER_START, sizeof(screenBuffer) - FRAMEBUFFER_START);
refresh(); // Now refresh to write out the contents to the new page

View File

@@ -46,9 +46,9 @@ extern "C" {
#define OLED_GRAM_START_FLIP 0
#define OLED_GRAM_END_FLIP 0x7F
#define OLED_VCOM_LAYOUT 0x12
#define OLED_VCOM_LAYOUT 0x12
#define OLED_SEGMENT_MAP_REVERSED
#define OLED_DIVIDER 0xD3
#define OLED_DIVIDER 0xD3
#else
@@ -59,14 +59,14 @@ extern "C" {
#define OLED_GRAM_START_FLIP 0
#define OLED_GRAM_END_FLIP 95
#define OLED_VCOM_LAYOUT 0x02
#define OLED_SEGMENT_MAP 0xA0
#define OLED_DIVIDER 0xD5
#define OLED_VCOM_LAYOUT 0x02
#define OLED_SEGMENT_MAP 0xA0
#define OLED_DIVIDER 0xD5
#endif /* OLED_128x32 */
#define OLED_ON 0xAF
#define OLED_OFF 0xAE
#define OLED_ON 0xAF
#define OLED_OFF 0xAE
#define FRAMEBUFFER_START 17
@@ -78,7 +78,10 @@ enum class FontStyle {
class OLED {
public:
enum DisplayState : bool { OFF = false, ON = true };
enum DisplayState : bool {
OFF = false,
ON = true
};
static void initialize(); // Startup the I2C coms (brings screen out of reset etc)
static bool isInitDone();
@@ -117,10 +120,10 @@ public:
static void setInverseDisplay(bool inverted);
static int16_t getCursorX() { return cursor_x; }
// Draw a string to the current location, with selected font; optionally - with MAX length only
static void print(const char *string, FontStyle fontStyle, uint8_t length = 255);
static void printWholeScreen(const char *string);
static void print(const char *string, FontStyle fontStyle, uint8_t length = 255);
static void printWholeScreen(const char *string);
// Print *F or *C - in font style of Small, Large (by default) or Extra based on input arg
static void printSymbolDeg(FontStyle fontStyle = FontStyle::LARGE);
static void printSymbolDeg(FontStyle fontStyle = FontStyle::LARGE);
// Set the cursor location by pixels
static void setCursor(int16_t x, int16_t y) {
cursor_x = x;
@@ -146,9 +149,9 @@ public:
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 transitionSecondaryFramebuffer(const bool forwardNavigation, const TickType_t viewEnterTime);
static void useSecondaryFramebuffer(bool useSecondary);
static void transitionScrollDown();
static void transitionScrollDown(const TickType_t viewEnterTime);
private:
static bool checkDisplayBufferChecksum() {