Fix scheduler first execution (#798)

* Fix scheduler first execution not immediately

* Also update sensor filters
This commit is contained in:
Otto Winter
2019-10-24 21:24:57 +02:00
parent 681dcb51da
commit 6b3c7b0854
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -57,7 +57,7 @@ void HOT Scheduler::set_interval(Component *component, const std::string &name,
item->name = name;
item->type = SchedulerItem::INTERVAL;
item->interval = interval;
item->last_execution = now - offset;
item->last_execution = now - offset - interval;
item->last_execution_major = this->millis_major_;
if (item->last_execution > now)
item->last_execution_major--;
@@ -106,7 +106,7 @@ void ICACHE_RAM_ATTR HOT Scheduler::call() {
// Not reached timeout yet, done for this call
break;
uint8_t major = item->last_execution_major;
if (item->last_execution + item->interval < item->last_execution)
if (item->last_execution > now)
major++;
if (major != this->millis_major_)
break;