Scroll speeds below 1 dot per second

scroll_speed is now a float (0.05-30 dots per second, e.g. 0.25 = one dot
every 4 s). Page format 5; version 4 pages are converted, version 3 goes
through version 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-10-16 16:23:16 +02:00
1 parent 1282d16c0b
commit e0a89cec99
17 files changed
+148 -21

No files matched your search

+6 -3
View File
@@ -1,5 +1,6 @@
#include "logic/page_render.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
@@ -157,13 +158,15 @@ static uint32_t drawTextElement(const PageElement &e, const char *text, uint32_t
// Scrolls from right to left, the next round follows after SCROLL_GAP dots
uint32_t period = width + SCROLL_GAP;
uint64_t steps = (uint64_t)now_ms * e.scroll_speed / 1000;
// Step n starts at n * 1000 / speed ms (the speed can be below 1 dot per second)
double ms_per_step = 1000.0 / e.scroll_speed;
uint64_t steps = (uint64_t)(now_ms / ms_per_step);
int offset = (int)(steps % period);
drawText(bitmap, font, left - offset, e.y, text, mode, left, left + area);
drawText(bitmap, font, left - offset + (int)period, e.y, text, mode, left, left + area);
// Until the next step
uint64_t next_step_ms = ((steps + 1) * 1000 + e.scroll_speed - 1) / e.scroll_speed;
uint32_t wait = (uint32_t)(next_step_ms - now_ms);
uint64_t next_step_ms = (uint64_t)ceil((steps + 1) * ms_per_step);
uint32_t wait = next_step_ms > now_ms ? (uint32_t)(next_step_ms - now_ms) : 0;
return wait ? wait : 1;
}