ESPHome  2024.4.1
sigma_delta_output.cpp
Go to the documentation of this file.
1 #include "sigma_delta_output.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace sigma_delta_output {
6 
7 static const char *const TAG = "output.sigma_delta";
8 
10  if (this->pin_)
11  this->pin_->setup();
12 }
13 
15  ESP_LOGCONFIG(TAG, "Sigma Delta Output:");
16  LOG_PIN(" Pin: ", this->pin_);
17  if (this->state_change_trigger_) {
18  ESP_LOGCONFIG(TAG, " State change automation configured");
19  }
20  if (this->turn_on_trigger_) {
21  ESP_LOGCONFIG(TAG, " Turn on automation configured");
22  }
23  if (this->turn_off_trigger_) {
24  ESP_LOGCONFIG(TAG, " Turn off automation configured");
25  }
26  LOG_UPDATE_INTERVAL(this);
27  LOG_FLOAT_OUTPUT(this);
28 }
29 
31  this->accum_ += this->state_;
32  const bool next_value = this->accum_ > 0;
33 
34  if (next_value) {
35  this->accum_ -= 1.;
36  }
37 
38  if (next_value != this->value_) {
39  this->value_ = next_value;
40  if (this->pin_) {
41  this->pin_->digital_write(next_value);
42  }
43 
44  if (this->state_change_trigger_) {
45  this->state_change_trigger_->trigger(next_value);
46  }
47 
48  if (next_value && this->turn_on_trigger_) {
49  this->turn_on_trigger_->trigger();
50  } else if (!next_value && this->turn_off_trigger_) {
51  this->turn_off_trigger_->trigger();
52  }
53  }
54 }
55 
56 } // namespace sigma_delta_output
57 } // namespace esphome
virtual void digital_write(bool value)=0
std::unique_ptr< Trigger< bool > > state_change_trigger_
std::unique_ptr< Trigger<> > turn_off_trigger_
virtual void setup()=0
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7