render speed
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
#pragma once
|
||||
|
||||
// Runs the render loop: reads UART, animates, and draws output
|
||||
void render_loop();
|
||||
void render_loop(int speed);
|
||||
|
||||
Reference in New Issue
Block a user