Add flag for checking if task was initialized #1
@ -21,9 +21,9 @@ SchedulerTask::SchedulerTask(const char *name, void (&setupCallback)(), void (&l
|
||||
|
||||
void SchedulerTask::loop()
|
||||
{
|
||||
if (m_lastUpdate && espchrono::ago(*m_lastUpdate) < m_loopInterval)
|
||||
if (!m_wasInitialized || (m_lastUpdate && espchrono::ago(*m_lastUpdate) < m_loopInterval))
|
||||
return;
|
||||
|
||||
|
||||
ESP_LOGV(TAG, "start %s", m_name);
|
||||
|
||||
if (m_intervalImportant)
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
const std::chrono::milliseconds &maxElapsed() const { return m_maxElapsed; }
|
||||
int callCount() const { return m_callCount; }
|
||||
|
||||
void setup() const { m_setupCallback(); }
|
||||
void setup() const { m_setupCallback(); m_wasInitialized = true; }
|
||||
void loop();
|
||||
void pushStats(bool printTask);
|
||||
|
||||
@ -47,5 +47,6 @@ private:
|
||||
std::chrono::milliseconds m_totalElapsedTemp;
|
||||
std::chrono::milliseconds m_maxElapsedTemp;
|
||||
int m_callCountTemp{};
|
||||
bool m_wasInitialized{};
|
||||
};
|
||||
} // namespace espcpputils
|
||||
|
Reference in New Issue
Block a user