ESPHome  2024.6.1
debug_component.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/defines.h"
5 #include "esphome/core/macros.h"
6 #include "esphome/core/helpers.h"
7 
8 #ifdef USE_SENSOR
10 #endif
11 #ifdef USE_TEXT_SENSOR
13 #endif
14 
15 namespace esphome {
16 namespace debug {
17 
19  public:
20  void loop() override;
21  void update() override;
22  float get_setup_priority() const override;
23  void dump_config() override;
24 
25 #ifdef USE_TEXT_SENSOR
26  void set_device_info_sensor(text_sensor::TextSensor *device_info) { device_info_ = device_info; }
27  void set_reset_reason_sensor(text_sensor::TextSensor *reset_reason) { reset_reason_ = reset_reason; }
28 #endif // USE_TEXT_SENSOR
29 #ifdef USE_SENSOR
30  void set_free_sensor(sensor::Sensor *free_sensor) { free_sensor_ = free_sensor; }
31  void set_block_sensor(sensor::Sensor *block_sensor) { block_sensor_ = block_sensor; }
32 #if defined(USE_ESP8266) && USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 5, 2)
33  void set_fragmentation_sensor(sensor::Sensor *fragmentation_sensor) { fragmentation_sensor_ = fragmentation_sensor; }
34 #endif
35  void set_loop_time_sensor(sensor::Sensor *loop_time_sensor) { loop_time_sensor_ = loop_time_sensor; }
36 #ifdef USE_ESP32
37  void set_psram_sensor(sensor::Sensor *psram_sensor) { this->psram_sensor_ = psram_sensor; }
38 #endif // USE_ESP32
39 #endif // USE_SENSOR
40  protected:
41  uint32_t free_heap_{};
42 
43 #ifdef USE_SENSOR
44  uint32_t last_loop_timetag_{0};
45  uint32_t max_loop_time_{0};
46 
49 #if defined(USE_ESP8266) && USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 5, 2)
51 #endif
53 #ifdef USE_ESP32
55 #endif // USE_ESP32
56 #endif // USE_SENSOR
57 
58 #ifdef USE_TEXT_SENSOR
61 #endif // USE_TEXT_SENSOR
62 
63  std::string get_reset_reason_();
64  uint32_t get_free_heap_();
65  void get_device_info_(std::string &device_info);
66  void update_platform_();
67 };
68 
69 } // namespace debug
70 } // namespace esphome
void get_device_info_(std::string &device_info)
void set_device_info_sensor(text_sensor::TextSensor *device_info)
void set_loop_time_sensor(sensor::Sensor *loop_time_sensor)
text_sensor::TextSensor * device_info_
This class simplifies creating components that periodically check a state.
Definition: component.h:283
void set_fragmentation_sensor(sensor::Sensor *fragmentation_sensor)
void set_block_sensor(sensor::Sensor *block_sensor)
sensor::Sensor * loop_time_sensor_
float get_setup_priority() const override
sensor::Sensor * fragmentation_sensor_
void set_reset_reason_sensor(text_sensor::TextSensor *reset_reason)
text_sensor::TextSensor * reset_reason_
void set_psram_sensor(sensor::Sensor *psram_sensor)
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
Base-class for all sensors.
Definition: sensor.h:57
void set_free_sensor(sensor::Sensor *free_sensor)