Commit 188a0bf3 authored by Eric Duminil's avatar Eric Duminil
Browse files

ampel.max_loop_duration

parent 9a47750c
...@@ -162,10 +162,10 @@ void loop() { ...@@ -162,10 +162,10 @@ void loop() {
} }
uint32_t duration = millis() - t0; uint32_t duration = millis() - t0;
if (duration > max_loop_duration) { if (duration > ampel.max_loop_duration) {
max_loop_duration = duration; ampel.max_loop_duration = duration;
Serial.print(F("Debug - Max loop duration : ")); Serial.print(F("Debug - Max loop duration : "));
Serial.print(max_loop_duration); Serial.print(ampel.max_loop_duration);
Serial.println(F(" ms.")); Serial.println(F(" ms."));
} }
} }
......
...@@ -51,10 +51,8 @@ namespace ntp { ...@@ -51,10 +51,8 @@ namespace ntp {
} }
} }
uint32_t max_loop_duration = 0;
Ampel::Ampel() : Ampel::Ampel() :
sensorId("ESP" + macToID()) { sensorId("ESP" + macToID()), max_loop_duration(0) {
sensor_console::defineIntCommand("set_time", ntp::setLocalTime, " 1618829570 (Sets time to the given UNIX time)"); sensor_console::defineIntCommand("set_time", ntp::setLocalTime, " 1618829570 (Sets time to the given UNIX time)");
sensor_console::defineCommand("free", []() { sensor_console::defineCommand("free", []() {
Serial.print(F("Free heap space : ")); Serial.print(F("Free heap space : "));
...@@ -63,4 +61,4 @@ Ampel::Ampel() : ...@@ -63,4 +61,4 @@ Ampel::Ampel() :
}, " (Displays available heap space)"); }, " (Displays available heap space)");
} }
const Ampel ampel; Ampel ampel;
...@@ -39,12 +39,12 @@ namespace util { ...@@ -39,12 +39,12 @@ namespace util {
class Ampel { class Ampel {
public: public:
const String sensorId; const String sensorId;
uint32_t max_loop_duration;
Ampel(); Ampel();
}; };
//NOTE: Only use seconds() for duration comparison, not timestamps comparison. Otherwise, problems happen when millis roll over. //NOTE: Only use seconds() for duration comparison, not timestamps comparison. Otherwise, problems happen when millis roll over.
#define seconds() (millis() / 1000UL) #define seconds() (millis() / 1000UL)
extern uint32_t max_loop_duration; extern Ampel ampel;
extern const Ampel ampel;
#endif #endif
...@@ -239,7 +239,7 @@ namespace web_server { ...@@ -239,7 +239,7 @@ namespace web_server {
#endif #endif
config::temperature_offset, config::auto_calibrate_sensor ? "Yes" : "No", ampel.sensorId.c_str(), config::temperature_offset, config::auto_calibrate_sensor ? "Yes" : "No", ampel.sensorId.c_str(),
ampel.sensorId.c_str(), WiFi.localIP().toString().c_str(), WiFi.localIP().toString().c_str(), ampel.sensorId.c_str(), WiFi.localIP().toString().c_str(), WiFi.localIP().toString().c_str(),
get_free_heap_size(), max_loop_duration, BOARD, dd, hh, mm, ss); get_free_heap_size(), ampel.max_loop_duration, BOARD, dd, hh, mm, ss);
Serial.print(F(" - Body size : ")); Serial.print(F(" - Body size : "));
http.sendContent(content); http.sendContent(content);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment