Skip to content

Commit e3a5b65

Browse files
committed
Recalculate ticksPer* if target fps was changed
1 parent 27cf049 commit e3a5b65

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

SSD1306Ui.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ void SSD1306Ui::init() {
1010
}
1111

1212
void SSD1306Ui::setTargetFPS(byte fps){
13+
int oldInterval = this->updateInterval;
1314
this->updateInterval = ((float) 1.0 / (float) fps) * 1000;
14-
Serial.println(this->updateInterval);
15+
16+
// Calculate new ticksPerFrame
17+
float changeRatio = oldInterval / this->updateInterval;
18+
this->ticksPerFrame *= changeRatio;
19+
this->ticksPerTransition *= changeRatio;
1520
}
1621

1722
// -/------ Automatic controll ------\-

0 commit comments

Comments
 (0)