12 static const char *
const TAG =
"app";
15 if (comp ==
nullptr) {
16 ESP_LOGW(TAG,
"Tried to register null component!");
22 ESP_LOGW(TAG,
"Component %s already registered! (%p)", c->get_component_source(), c);
26 this->components_.push_back(comp);
29 ESP_LOGI(TAG,
"Running through setup()...");
30 ESP_LOGV(TAG,
"Sorting components by setup priority...");
35 for (uint32_t i = 0; i < this->
components_.size(); i++) {
45 [](
Component *a,
Component *b) {
return a->get_loop_priority() > b->get_loop_priority(); });
51 for (uint32_t j = 0; j <= i; j++) {
53 new_app_state |= this->
components_[j]->get_component_state();
62 ESP_LOGI(TAG,
"setup() finished successfully!");
67 uint32_t new_app_state = 0;
76 new_app_state |= component->get_component_state();
82 const uint32_t now =
millis();
92 next_schedule = std::max(next_schedule, delay_time / 2);
93 delay_time = std::min(next_schedule, delay_time);
96 this->last_loop_ = now;
98 if (this->dump_config_at_ < this->
components_.size()) {
100 ESP_LOGI(TAG,
"ESPHome version " ESPHOME_VERSION
" compiled on %s", this->
compilation_time_);
101 #ifdef ESPHOME_PROJECT_NAME 102 ESP_LOGI(TAG,
"Project " ESPHOME_PROJECT_NAME
" version " ESPHOME_PROJECT_VERSION);
112 static uint32_t last_feed = 0;
114 if (now - last_feed > 3000) {
117 #ifdef USE_STATUS_LED 125 ESP_LOGI(TAG,
"Forcing a reboot...");
127 (*it)->on_shutdown();
132 ESP_LOGI(TAG,
"Rebooting safely...");
139 (*it)->on_safe_shutdown();
142 (*it)->on_shutdown();
148 if (obj->has_overridden_loop())
static bool is_high_frequency()
Check whether the loop is running continuously.
void IRAM_ATTR HOT arch_feed_wdt()
float get_actual_setup_priority() const
void setup()
Set up all the registered components. Call this at the end of your setup() function.
uint32_t IRAM_ATTR HOT micros()
optional< uint32_t > next_schedule_in()
uint32_t IRAM_ATTR HOT millis()
void run_safe_shutdown_hooks()
void loop()
Make a loop iteration. Call this in your loop() function.
void schedule_dump_config()
void calculate_looping_components_()
Application App
Global storage of Application pointer - only one Application can exist.
virtual bool can_proceed()
std::vector< Component * > components_
std::vector< Component * > looping_components_
const uint32_t STATUS_LED_WARNING
StatusLED * global_status_led
const char * compilation_time_
void IRAM_ATTR HOT yield()
void register_component_(Component *comp)
Implementation of SPI Controller mode.
value_type value_or(U const &v) const
void IRAM_ATTR HOT delay(uint32_t ms)