From f5d47fe7da73df097429d8f36aaf6055f390f864 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Wed, 23 Oct 2019 12:36:08 +0200 Subject: [PATCH] Keep track of the current frame number. --- include/prototypes.h | 1 + src/pitrix.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/prototypes.h b/include/prototypes.h index 0b24543..dfd87af 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -4,6 +4,7 @@ extern uint8_t baseHue; extern char hostname[30]; +extern uint16_t frame; typedef struct { uint8_t width; diff --git a/src/pitrix.cpp b/src/pitrix.cpp index 211f04b..1297a51 100644 --- a/src/pitrix.cpp +++ b/src/pitrix.cpp @@ -17,6 +17,7 @@ int loop_timeouts = 0; long loop_started_at = 0; uint8_t baseHue = 0; // defined as extern in prototypes.h char hostname[30]; // defined as extern in prototypes.h +uint16_t frame = 0; // defined as extern in prototypes.h unsigned long _last_effect_loop_finished_at = 0; #ifdef RECORDER_ENABLE Recorder* recorder; @@ -84,6 +85,7 @@ void loop() { } EVERY_N_MILLISECONDS(1000 / FPS) { + frame++; // Calculate the delay since the last time loop() was called. // This way, the effect can handle varying frame rates. uint16_t last_loop_ago;