optimize loop entry

This commit is contained in:
Carsten Schmiemann 2022-11-13 22:59:17 +01:00
parent 32256bf77a
commit e0dea35efe

View file

@ -122,6 +122,8 @@ char msg[50];
float pv_v = 0, pv_w = 0, pv_i = 0, pv_kwh = 0, inv_p = 0, inv_i = 0, batt_v = 0, batt_i = 0, batt_p = 0, batt_c_min = 0, batt_c_max = 0, grid_p = 0, batt_soc = 0, load_ph1 = 0, load_ph2 = 0, load_ph3 = 0; float pv_v = 0, pv_w = 0, pv_i = 0, pv_kwh = 0, inv_p = 0, inv_i = 0, batt_v = 0, batt_i = 0, batt_p = 0, batt_c_min = 0, batt_c_max = 0, grid_p = 0, batt_soc = 0, load_ph1 = 0, load_ph2 = 0, load_ph3 = 0;
bool lastButtonRotationState = HIGH, lastButtonSetupState = HIGH; bool lastButtonRotationState = HIGH, lastButtonSetupState = HIGH;
bool currentButtonRotationState, currentButtonSetupState; bool currentButtonRotationState, currentButtonSetupState;
static unsigned long lastDispRefreshTime = 0;
static unsigned long lastScreenChangeTime = 0;
int display_screen = 0; int display_screen = 0;
//MQTT topics //MQTT topics
@ -597,12 +599,11 @@ void setup() {
delay(3000); delay(3000);
display_text_fullscreen((char*)"Configuration summary", (char*)"Disp. Refresh:", disp_refresh_interval, (char*)"Disp. rotation:", disp_screen_interval, (char*)" 2/2"); display_text_fullscreen((char*)"Configuration summary", (char*)"Disp. Refresh:", disp_refresh_interval, (char*)"Disp. rotation:", disp_screen_interval, (char*)" 2/2");
delay(3000); delay(3000);
lastDispRefreshTime = millis();
lastScreenChangeTime = millis();
} }
void loop() { void loop() {
static unsigned long lastDispRefreshTime = 0;
static unsigned long lastScreenChangeTime = 0;
//Refresh display values //Refresh display values
if(millis() - lastDispRefreshTime >= DISPLAY_REFRESH_INTERVAL) if(millis() - lastDispRefreshTime >= DISPLAY_REFRESH_INTERVAL)
{ {