#ifndef AMPEL_UTIL_H_INCLUDED #define AMPEL_UTIL_H_INCLUDED #include #include "config.h" #include "sensor_console.h" #include // required for NTP #include "src/lib/NTPClient-master/NTPClient.h" // NTP #if defined(ESP8266) # define BOARD "ESP8266" //TODO: Move to ampel.board? # include // required to get MAC address # define get_free_heap_size() system_get_free_heap_size() #elif defined(ESP32) # define BOARD "ESP32" # include // required to get MAC address # define get_free_heap_size() esp_get_free_heap_size() #else # define BOARD "Unknown" #endif namespace ntp { void initialize(); void update(); void getLocalTime(char *timestamp); } namespace util { template inline auto min(const Tpa &a, const Tpb &b) -> decltype(a < b ? a : b) { return b < a ? b : a; } template inline auto max(const Tpa &a, const Tpb &b) -> decltype(b > a ? b : a) { return b > a ? b : a; } } class Ampel { private: static void showFreeSpace(); 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 Ampel ampel; #endif