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

Reduce number of calls to fetch time in the main loop (#8804)

This commit is contained in:
J. Nick Koston
2025-05-18 15:48:57 -04:00
committed by GitHub
parent e47741d471
commit 574aabdede
36 changed files with 107 additions and 53 deletions

View File

@@ -217,6 +217,9 @@ class Application {
std::string get_compilation_time() const { return this->compilation_time_; }
/// Get the cached time in milliseconds from when the current component started its loop execution
inline uint32_t IRAM_ATTR HOT get_loop_component_start_time() const { return this->loop_component_start_time_; }
/** Set the target interval with which to run the loop() calls.
* If the loop() method takes longer than the target interval, ESPHome won't
* sleep in loop(), but if the time spent in loop() is small than the target, ESPHome
@@ -236,7 +239,7 @@ class Application {
void schedule_dump_config() { this->dump_config_at_ = 0; }
void feed_wdt();
void feed_wdt(uint32_t time = 0);
void reboot();
@@ -551,6 +554,7 @@ class Application {
size_t dump_config_at_{SIZE_MAX};
uint32_t app_state_{0};
Component *current_component_{nullptr};
uint32_t loop_component_start_time_{0};
};
/// Global storage of Application pointer - only one Application can exist.