From 595f28548751669aa31d36ee3c88e7b704dd5c74 Mon Sep 17 00:00:00 2001 From: Carsten Schmiemann Date: Sun, 20 Nov 2022 01:20:04 +0100 Subject: [PATCH] Add graph ringbuffer loop --- src/main.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 11cb1be..0cd1dd7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -128,6 +128,8 @@ bool lastButtonRotationState = HIGH, lastButtonSetupState = HIGH; bool currentButtonRotationState, currentButtonSetupState; static unsigned long lastDispRefreshTime = 0; static unsigned long lastScreenChangeTime = 0; +static unsigned long lastGraphRecord_1h = 0; +static unsigned long lastGraphRecord_24h = 0; int display_screen = 0; //Display graph ringbuffer @@ -615,6 +617,8 @@ void setup() { delay(3000); lastDispRefreshTime = millis(); lastScreenChangeTime = millis(); + lastGraphRecord_1h = millis(); + lastGraphRecord_24h = millis(); } void loop() { @@ -685,6 +689,30 @@ void loop() { } } + //Graph recorder - 1h + if (display_conf_graph_pv_present) + { + if(millis() - lastGraphRecord_1h >= 30000) //temporarily set to half minute + { + display_graph_ringbuffer_add(display_graph_ringbuffer_load_1h, grid_p); + if (display_conf_dc_pvcharger_present) + { + display_graph_ringbuffer_add(display_graph_ringbuffer_pv_1h, pv_w); + } + lastGraphRecord_1h += 30000; + Serial.println("Graph ringbuffer 1h - new value added"); + } + /*if(millis() - lastGraphRecord_24h >= 864000) + { + display_graph_ringbuffer_add(display_graph_ringbuffer_load_24h, grid_p); + if (display_conf_dc_pvcharger_present) + { + display_graph_ringbuffer_add(display_graph_ringbuffer_pv_24h, pv_w); + } + lastGraphRecord_24h += 864000; + Serial.println("Graph ringbuffer 24h - new value added"); + }*/ + } //Rotate screen if BUTTON_ROTATION is pressed currentButtonRotationState = digitalRead(BUTTON_ROTATION);