Commit 9d1c951d authored by Eric Duminil's avatar Eric Duminil
Browse files

Some refactor

parent 188a0bf3
...@@ -79,10 +79,6 @@ namespace sensor { ...@@ -79,10 +79,6 @@ namespace sensor {
sensor_console::defineIntCommand("calibrate!", calibrateSensorRightNow, sensor_console::defineIntCommand("calibrate!", calibrateSensorRightNow,
" 600 (Calibrates right now, to given ppm)"); " 600 (Calibrates right now, to given ppm)");
sensor_console::defineIntCommand("auto_calibrate", setAutoCalibration, " 0/1 (Disables/enables autocalibration)"); sensor_console::defineIntCommand("auto_calibrate", setAutoCalibration, " 0/1 (Disables/enables autocalibration)");
sensor_console::defineCommand("reset", []() {
ESP.restart();
}, " (Restarts the sensor)");
} }
//NOTE: should timer deviation be used to adjust measurement_timestep? //NOTE: should timer deviation be used to adjust measurement_timestep?
......
...@@ -51,14 +51,19 @@ namespace ntp { ...@@ -51,14 +51,19 @@ namespace ntp {
} }
} }
void Ampel::showFreeSpace() {
Serial.print(F("Free heap space : "));
Serial.print(get_free_heap_size());
Serial.println(F(" bytes."));
}
Ampel::Ampel() : Ampel::Ampel() :
sensorId("ESP" + macToID()), max_loop_duration(0) { 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", Ampel::showFreeSpace, " (Displays available heap space)");
Serial.print(F("Free heap space : ")); sensor_console::defineCommand("reset", []() {
Serial.print(get_free_heap_size()); ESP.restart();
Serial.println(F(" bytes.")); }, " (Restarts the sensor)");
}, " (Displays available heap space)");
} }
Ampel ampel; Ampel ampel;
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "src/lib/NTPClient-master/NTPClient.h" // NTP #include "src/lib/NTPClient-master/NTPClient.h" // NTP
#if defined(ESP8266) #if defined(ESP8266)
# define BOARD "ESP8266" # define BOARD "ESP8266" //TODO: Move to ampel.board?
# include <ESP8266WiFi.h> // required to get MAC address # include <ESP8266WiFi.h> // required to get MAC address
# define get_free_heap_size() system_get_free_heap_size() # define get_free_heap_size() system_get_free_heap_size()
#elif defined(ESP32) #elif defined(ESP32)
...@@ -37,6 +37,8 @@ namespace util { ...@@ -37,6 +37,8 @@ namespace util {
} }
} }
class Ampel { class Ampel {
private:
static void showFreeSpace();
public: public:
const String sensorId; const String sensorId;
uint32_t max_loop_duration; uint32_t max_loop_duration;
......
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