render speed

This commit is contained in:
Priec
2025-11-14 11:08:33 +01:00
parent a1c742c1cd
commit ebe03f42b6
5 changed files with 14 additions and 534 deletions

View File

@@ -22,5 +22,5 @@ int main(void) {
printf("Baud: %d, Format: 8-N-1\r\n", BAUD_RATE);
// Just call into render feature
render_loop();
render_loop(4);
}

View File

@@ -5,7 +5,7 @@
#include <cstring>
void draw_mask(const char *unused_filename, int shift, const char *text) {
const int view_width = 50;
const int view_width = 90;
const int view_height = 16;
// Terminal clear + home

View File

@@ -1,4 +1,4 @@
// src/render/loop.c
// src/render/loop.cpp
#include "loop.h"
#include "mbed.h"
@@ -15,7 +15,7 @@ static bool message_active = false;
void draw_mask(const char *unused_filename, int shift, const char *text = nullptr);
void render_loop() {
void render_loop(int speed) {
Timer msg_timer;
Timer anim_timer;
msg_timer.start();
@@ -49,8 +49,9 @@ void render_loop() {
}
// Animation tick
if (anim_timer.elapsed_time() >= 80ms) {
shift++;
if (anim_timer.elapsed_time() >= 200ms) {
// speed determines scroll steps per tick
shift += speed;
anim_timer.reset();
need_redraw = true;
}
@@ -59,9 +60,9 @@ void render_loop() {
if (need_redraw) {
draw_mask(bg_file, shift, message_active ? message : nullptr);
need_redraw = false;
ThisThread::sleep_for(60ms);
ThisThread::sleep_for(50ms);
}
ThisThread::sleep_for(20ms);
ThisThread::sleep_for(25ms);
}
}

View File

@@ -3,4 +3,4 @@
#pragma once
// Runs the render loop: reads UART, animates, and draws output
void render_loop();
void render_loop(int speed);