From 5a528a96c8c5d57aac35f2b7554ec399e98f18ff Mon Sep 17 00:00:00 2001 From: trepidacious <trepidacious@gmail.com> Date: Thu, 22 Dec 2016 09:16:30 +0000 Subject: [PATCH] Use screen geometry for transitions and indicators Also use closer indicator spacing when using indicators on left or right of screen with less than 64 height. --- OLEDDisplayUi.cpp | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/OLEDDisplayUi.cpp b/OLEDDisplayUi.cpp index e787442..1c306d5 100644 --- a/OLEDDisplayUi.cpp +++ b/OLEDDisplayUi.cpp @@ -250,28 +250,28 @@ void OLEDDisplayUi::drawFrame(){ int16_t x, y, x1, y1; switch(this->frameAnimationDirection){ case SLIDE_LEFT: - x = -128 * progress; + x = -(this->display->getWidth()) * progress; y = 0; - x1 = x + 128; + x1 = x + this->display->getWidth(); y1 = 0; break; case SLIDE_RIGHT: - x = 128 * progress; + x = this->display->getWidth() * progress; y = 0; - x1 = x - 128; + x1 = x - this->display->getWidth(); y1 = 0; break; case SLIDE_UP: x = 0; - y = -64 * progress; + y = -(this->display->getHeight()) * progress; x1 = 0; - y1 = y + 64; + y1 = y + (this->display->getHeight()); break; case SLIDE_DOWN: x = 0; - y = 64 * progress; + y = (this->display->getHeight()) * progress; x1 = 0; - y1 = y - 64; + y1 = y - (this->display->getHeight()); break; } @@ -356,7 +356,13 @@ void OLEDDisplayUi::drawIndicator() { break; } - uint16_t frameStartPos = (12 * frameCount / 2); + //Space between indicators - reduce for small screen sizes + uint16_t indicatorSpacing = 12; + if (this->display->getHeight() < 64 && (this->indicatorPosition == RIGHT || this->indicatorPosition == LEFT)) { + indicatorSpacing = 6; + } + + uint16_t frameStartPos = (indicatorSpacing * frameCount / 2); const char *image; uint16_t x,y; for (byte i = 0; i < this->frameCount; i++) { @@ -364,19 +370,19 @@ void OLEDDisplayUi::drawIndicator() { switch (this->indicatorPosition){ case TOP: y = 0 - (8 * indicatorFadeProgress); - x = 64 - frameStartPos + 12 * i; + x = (this->display->getWidth() / 2) - frameStartPos + indicatorSpacing * i; break; case BOTTOM: - y = 56 + (8 * indicatorFadeProgress); - x = 64 - frameStartPos + 12 * i; + y = (this->display->getHeight() - 8) + (8 * indicatorFadeProgress); + x = (this->display->getWidth() / 2) - frameStartPos + indicatorSpacing * i; break; case RIGHT: - x = 120 + (8 * indicatorFadeProgress); - y = 32 - frameStartPos + 12 * i; + x = (this->display->getWidth() - 8) + (8 * indicatorFadeProgress); + y = (this->display->getHeight() / 2) - frameStartPos + indicatorSpacing * i; break; case LEFT: x = 0 - (8 * indicatorFadeProgress); - y = 32 - frameStartPos + 12 * i; + y = (this->display->getHeight() / 2) - frameStartPos + indicatorSpacing * i; break; } -- GitLab