@@ -150,6 +150,25 @@ void OLEDDisplayUi::previousFrame() {
150150 }
151151}
152152
153+ void OLEDDisplayUi::switchToFrame (uint8_t frame) {
154+ if (frame >= this ->frameCount || frame != this ->state .currentFrame ) return ;
155+ this ->state .lastUpdate = 0 ;
156+ this ->state .ticksSinceLastStateSwitch = 0 ;
157+ this ->state .frameState = FIXED;
158+ this ->state .currentFrame = frame;
159+ this ->state .isIndicatorDrawen = true ;
160+ }
161+
162+ void OLEDDisplayUi::transitionToFrame (uint8_t frame) {
163+ if (frame >= this ->frameCount || frame != this ->state .currentFrame ) return ;
164+ this ->nextFrameNumber = frame;
165+ this ->lastTransitionDirection = this ->state .frameTransitionDirection ;
166+ this ->state .manuelControll = true ;
167+ this ->state .frameState = IN_TRANSITION;
168+ this ->state .ticksSinceLastStateSwitch = 0 ;
169+ this ->state .frameTransitionDirection = frame < this ->state .currentFrame ? -1 : 1 ;
170+ }
171+
153172
154173// -/----- State information -----\-
155174OLEDDisplayUiState* OLEDDisplayUi::getUiState (){
@@ -180,6 +199,7 @@ void OLEDDisplayUi::tick() {
180199 this ->state .frameState = FIXED;
181200 this ->state .currentFrame = getNextFrameNumber ();
182201 this ->state .ticksSinceLastStateSwitch = 0 ;
202+ this ->nextFrameNumber = -1 ;
183203 }
184204 break ;
185205 case FIXED:
@@ -366,9 +386,6 @@ void OLEDDisplayUi::drawOverlays() {
366386}
367387
368388uint8_t OLEDDisplayUi::getNextFrameNumber (){
369- int8_t nextFrame = (this ->state .currentFrame + this ->state .frameTransitionDirection ) % this ->frameCount ;
370- if (nextFrame < 0 ){
371- nextFrame = this ->frameCount + nextFrame;
372- }
373- return nextFrame;
389+ if (this ->nextFrameNumber != -1 ) return this ->nextFrameNumber ;
390+ return (this ->state .currentFrame + this ->frameCount + this ->state .frameTransitionDirection ) % this ->frameCount ;
374391}
0 commit comments