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

ampel.max_loop_duration

parent 9a47750c
......@@ -162,10 +162,10 @@ void loop() {
}
uint32_t duration = millis() - t0;
if (duration > max_loop_duration) {
max_loop_duration = duration;
if (duration > ampel.max_loop_duration) {
ampel.max_loop_duration = duration;
Serial.print(F("Debug - Max loop duration : "));
Serial.print(max_loop_duration);
Serial.print(ampel.max_loop_duration);
Serial.println(F(" ms."));
}
}
......
......@@ -51,10 +51,8 @@ namespace ntp {
}
}
uint32_t max_loop_duration = 0;
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::defineCommand("free", []() {
Serial.print(F("Free heap space : "));
......@@ -63,4 +61,4 @@ Ampel::Ampel() :
}, " (Displays available heap space)");
}
const Ampel ampel;
Ampel ampel;
......@@ -39,12 +39,12 @@ namespace util {
class Ampel {
public:
const String sensorId;
uint32_t max_loop_duration;
Ampel();
};
//NOTE: Only use seconds() for duration comparison, not timestamps comparison. Otherwise, problems happen when millis roll over.
#define seconds() (millis() / 1000UL)
extern uint32_t max_loop_duration;
extern const Ampel ampel;
extern Ampel ampel;
#endif
......@@ -239,7 +239,7 @@ namespace web_server {
#endif
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(),
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 : "));
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