1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-20 12:12:24 +01:00

Optimize application loop speed (#860)

* Optimize application loop speed

* Also check call_loop

* Remove duplicate code

* Fixes
This commit is contained in:
Otto Winter
2019-12-04 16:03:37 +01:00
committed by GitHub
parent e86f2e993f
commit e9e92afc9e
5 changed files with 24 additions and 3 deletions

View File

@@ -57,13 +57,14 @@ void Application::setup() {
ESP_LOGI(TAG, "setup() finished successfully!");
this->schedule_dump_config();
this->calculate_looping_components_();
}
void Application::loop() {
uint32_t new_app_state = 0;
const uint32_t start = millis();
this->scheduler.call();
for (Component *component : this->components_) {
for (Component *component : this->looping_components_) {
component->call();
new_app_state |= component->get_component_state();
this->app_state_ |= new_app_state;
@@ -146,6 +147,13 @@ void Application::safe_reboot() {
}
}
void Application::calculate_looping_components_() {
for (auto *obj : this->components_) {
if (obj->has_overridden_loop())
this->looping_components_.push_back(obj);
}
}
Application App;
} // namespace esphome