From fe9f25c856165a153f174f7fb953d90dd255a5dd Mon Sep 17 00:00:00 2001 From: Dirk Jahnke Date: Fri, 1 Feb 2019 15:20:56 +0100 Subject: [PATCH] Made call to IAS.loop less often. Added some debug outputs. Moved some config parameters out of the code to platformio.ini --- src/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4e503e1..60abd71 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -149,7 +149,7 @@ void setupIAS(void) { // Call home interval in seconds, use 60s only for development. // Please change it to at least 2 hours in production IAS.setCallHomeInterval(120); - IAS.callHome(true /*SPIFFS-check*/); + // IAS.callHome(true /*SPIFFS-check*/); modelTime.setSpeed_modelMsPerRealSecond(atoi(clockSpeed_modelMsPerRealSec_String)); relay1Pin = IAS.dPinConv(relay1Pin_String); relay2Pin = IAS.dPinConv(relay2Pin_String); @@ -198,6 +198,8 @@ static unsigned long lastTimeOutput_ms = 0; void loop(void) { static unsigned int lastMinutes = 0; + static unsigned long lastIASLoop_ts = 0; + #define CALL_IAS_EVERY_ms 100 static unsigned long firstLoop_ts = 0; if (firstLoop_ts == 0) firstLoop_ts = millis(); @@ -209,10 +211,14 @@ void loop(void) Serial.println(timeClient.getFormattedTime()); lastTimeOutput_ms = millis(); } - IAS.loop(); + if (millis() - lastIASLoop_ts > CALL_IAS_EVERY_ms) { + IAS.loop(); + lastIASLoop_ts = millis(); + } if (timeClientInitialized && millis()-lastTimeOutput_ms > TIME_BETWEEN_REALTIME_UPDATE_ms) { timeClient.update(); + Serial.print("t-update: "); Serial.println(timeClient.getFormattedTime()); lastTimeOutput_ms = millis(); }