donut: remove time-based degradation for consistent animation
Remove three mechanisms that intentionally degraded the screensaver over time, causing it to appear frozen after extended runtime: - Brightness dimming curve (faded palette to 30% over ~15min) - Projection framerate skip (reduced 3D updates from 24fps to 6fps) - Deep sleep after 2hr (dropped to 1fps) The clock drift and matrix text changes already provide adequate OLED burn-in protection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -296,11 +296,9 @@ int main(int argc, char **argv) {
|
|||||||
int drift_ox = 0, drift_oy = 0;
|
int drift_ox = 0, drift_oy = 0;
|
||||||
int clk_dx = 0, clk_dy = 0;
|
int clk_dx = 0, clk_dy = 0;
|
||||||
int drift_tick = 0;
|
int drift_tick = 0;
|
||||||
float last_dim = 1.0f;
|
|
||||||
struct timeval tv_prev;
|
struct timeval tv_prev;
|
||||||
gettimeofday(&tv_prev, NULL);
|
gettimeofday(&tv_prev, NULL);
|
||||||
float dt_scale = 1.0f;
|
float dt_scale = 1.0f;
|
||||||
int frame_count = 0;
|
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
gettimeofday(&tv_start, NULL);
|
gettimeofday(&tv_start, NULL);
|
||||||
@@ -323,12 +321,6 @@ int main(int argc, char **argv) {
|
|||||||
float elapsed_s = (tv_start.tv_sec - tv_boot.tv_sec)
|
float elapsed_s = (tv_start.tv_sec - tv_boot.tv_sec)
|
||||||
+ (tv_start.tv_usec - tv_boot.tv_usec) / 1e6f;
|
+ (tv_start.tv_usec - tv_boot.tv_usec) / 1e6f;
|
||||||
|
|
||||||
float dim = 0.3f + 0.7f / (1.0f + elapsed_s / 900.0f);
|
|
||||||
if (fabsf(dim - last_dim) > 0.005f) {
|
|
||||||
init_palette(dim);
|
|
||||||
last_dim = dim;
|
|
||||||
}
|
|
||||||
|
|
||||||
int new_tick = (int)(elapsed_s / 180.0f);
|
int new_tick = (int)(elapsed_s / 180.0f);
|
||||||
if (new_tick != drift_tick) {
|
if (new_tick != drift_tick) {
|
||||||
drift_tick = new_tick;
|
drift_tick = new_tick;
|
||||||
@@ -350,12 +342,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
int sz = W * H;
|
int sz = W * H;
|
||||||
|
|
||||||
/* Projection rate follows dim curve: bright=24fps → dim=6fps */
|
/* 3D projection */
|
||||||
int proj_skip = (int)((1.0f - dim) * 4.0f) + 1;
|
{
|
||||||
if (proj_skip > 4) proj_skip = 4;
|
|
||||||
|
|
||||||
/* 3D projection at reduced rate — sbuf cached between updates */
|
|
||||||
if (frame_count % proj_skip == 0) {
|
|
||||||
float K2 = 5.0f;
|
float K2 = 5.0f;
|
||||||
/* Cap projection to reference size — donut stays same size on any screen */
|
/* Cap projection to reference size — donut stays same size on any screen */
|
||||||
int proj_w = W < 160 ? W : 160;
|
int proj_w = W < 160 ? W : 160;
|
||||||
@@ -454,7 +442,6 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
frame_count++;
|
|
||||||
|
|
||||||
/* Clock setup */
|
/* Clock setup */
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
@@ -642,12 +629,9 @@ int main(int argc, char **argv) {
|
|||||||
if (B > 6.2832f) B -= 6.2832f;
|
if (B > 6.2832f) B -= 6.2832f;
|
||||||
if (B < 0.0f) B += 6.2832f;
|
if (B < 0.0f) B += 6.2832f;
|
||||||
|
|
||||||
/* Fixed 24fps target — projection skip handles CPU curve */
|
/* Fixed 24fps target */
|
||||||
float target_ms = 41.6f;
|
float target_ms = 41.6f;
|
||||||
|
|
||||||
/* Deep sleep after 2hr — dim bottomed out, select() blocks until keypress */
|
|
||||||
if (elapsed_s > 7200.0f) target_ms = 1000.0f; /* 1fps */
|
|
||||||
|
|
||||||
/* Sleep until deadline or keypress via select() */
|
/* Sleep until deadline or keypress via select() */
|
||||||
gettimeofday(&tv_end, NULL);
|
gettimeofday(&tv_end, NULL);
|
||||||
float spent = (tv_end.tv_sec - tv_start.tv_sec) * 1000.0f
|
float spent = (tv_end.tv_sec - tv_start.tv_sec) * 1000.0f
|
||||||
|
|||||||
Reference in New Issue
Block a user