ThingPulse / esp8266-oled-ssd1306

Driver for the SSD1306 and SH1106 based 128x64, 128x32, 64x48 pixel OLED display running on ESP8266/ESP32
https://thingpulse.com
Other
1.99k stars 637 forks source link

Fix problem of transitions getting faster with each call of setTargetFPS #275

Closed geeksville closed 4 years ago

geeksville commented 4 years ago
On my app I noticed that each time I called setTargetFPS the transitions
would become faster and faster, until finally they don't even take one
frame.  The problem was that the FP math for calculating changeRatio
would (because of rounding err) keep shrinking the number of ticksPerFrame.

This change instead computs ticksPerFrame/perTransition based on the
requested display time, so error can't accumulate from a series of calls.

(In my app I only bump up target FPS before each transition but then
I lower it down again afterwards to save CPU)