From 1418d519d52ce582285e34f8377c7647c8a9390f Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Fri, 18 Oct 2019 17:03:48 +0200 Subject: [PATCH] Better frametime calculation in pitrix.cpp --- src/pitrix.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pitrix.cpp b/src/pitrix.cpp index 6a74bfa..050c301 100644 --- a/src/pitrix.cpp +++ b/src/pitrix.cpp @@ -100,8 +100,17 @@ void loop() { last_loop_ago = 0; } + #ifdef MQTT_REPORT_METRICS + unsigned long effect_loop_started = millis(); + #endif + current_effect->loop(last_loop_ago); + #ifdef MQTT_REPORT_METRICS + metrics_frame_count++; + metrics_frame_time += (millis() - effect_loop_started); + #endif + // Save the time for the next run. _last_effect_loop_finished_at = now; @@ -109,10 +118,7 @@ void loop() { effect_clock.loop_with_invert(current_effect->clock_as_mask()); } FastLED.show(); - #ifdef MQTT_REPORT_METRICS - metrics_frame_count++; - metrics_frame_time += (millis() - loop_started_at); - #endif + #ifdef RECORDER_ENABLE recorder->loop();