diff --git a/SSD1306Ui.cpp b/SSD1306Ui.cpp index bcdb751355cef4eb88932f8f8538bb0695ae5b0f..018e2d9ee93f3e2d60d4c8ba4f333b91cf76a4d0 100644 --- a/SSD1306Ui.cpp +++ b/SSD1306Ui.cpp @@ -10,8 +10,13 @@ void SSD1306Ui::init() { } void SSD1306Ui::setTargetFPS(byte fps){ + int oldInterval = this->updateInterval; this->updateInterval = ((float) 1.0 / (float) fps) * 1000; - Serial.println(this->updateInterval); + + // Calculate new ticksPerFrame + float changeRatio = oldInterval / this->updateInterval; + this->ticksPerFrame *= changeRatio; + this->ticksPerTransition *= changeRatio; } // -/------ Automatic controll ------\-