Skip to content

Commit b730115

Browse files
committed
Avoid division by zero
Fixes ThingPulse#317
1 parent 78bdcfb commit b730115

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/OLEDDisplayUi.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void LoadingDrawDefault(OLEDDisplay *display, LoadingStage* stage, uint8_t progr
4141

4242
OLEDDisplayUi::OLEDDisplayUi(OLEDDisplay *display) {
4343
this->display = display;
44-
44+
4545
indicatorPosition = BOTTOM;
4646
indicatorDirection = LEFT_RIGHT;
4747
activeSymbol = ANIMATION_activeSymbol;
@@ -300,7 +300,10 @@ void OLEDDisplayUi::resetState() {
300300
void OLEDDisplayUi::drawFrame(){
301301
switch (this->state.frameState){
302302
case IN_TRANSITION: {
303-
float progress = (float) this->state.ticksSinceLastStateSwitch / (float) this->ticksPerTransition;
303+
float progress = 0.f;
304+
if (this->ticksPerTransition > 0u) {
305+
progress = (float) this->state.ticksSinceLastStateSwitch / (float) this->ticksPerTransition;
306+
}
304307
int16_t x = 0, y = 0, x1 = 0, y1 = 0;
305308
switch(this->frameAnimationDirection){
306309
case SLIDE_LEFT:

0 commit comments

Comments
 (0)