From 2debafab1e2ec1bee8ab3d7d8013a6cf4ec40caf Mon Sep 17 00:00:00 2001 From: Fabrice Weinberg <Fabrice@weinberg.me> Date: Sat, 9 Jan 2016 18:10:33 +0100 Subject: [PATCH] use a signed int in the getNextFrameNumber function --- SSD1306Ui.cpp | 4 ++-- SSD1306Ui.h | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/SSD1306Ui.cpp b/SSD1306Ui.cpp index 8754d78..44cc87f 100644 --- a/SSD1306Ui.cpp +++ b/SSD1306Ui.cpp @@ -303,7 +303,7 @@ void SSD1306Ui::drawIndicator() { posOfHighlightFrame = frameToHighlight; break; case RIGHT_LEFT: - posOfHighlightFrame = (this->frameCount - 1) - frameToHighlight; + posOfHighlightFrame = this->frameCount - frameToHighlight; break; } @@ -359,7 +359,7 @@ void SSD1306Ui::drawOverlays() { } uint8_t SSD1306Ui::getNextFrameNumber(){ - uint8_t nextFrame = (this->state.currentFrame + this->state.frameTransitionDirection) % this->frameCount; + int8_t nextFrame = (this->state.currentFrame + this->state.frameTransitionDirection) % this->frameCount; if (nextFrame < 0){ nextFrame = this->frameCount + nextFrame; } diff --git a/SSD1306Ui.h b/SSD1306Ui.h index b95a5ed..bdf218f 100644 --- a/SSD1306Ui.h +++ b/SSD1306Ui.h @@ -29,6 +29,12 @@ #include <Arduino.h> #include "SSD1306.h" +//#define DEBUG_SSD1306Ui(...) Serial.printf( __VA_ARGS__ ) + +#ifndef DEBUG_SSD1306Ui +#define DEBUG_SSD1306Ui(...) +#endif + enum AnimationDirection { SLIDE_UP, SLIDE_DOWN, -- GitLab