ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
sigma_delta_output.cpp
Go to the documentation of this file.
2#include "esphome/core/log.h"
3
5
6static const char *const TAG = "output.sigma_delta";
7
9 if (this->pin_)
10 this->pin_->setup();
11}
12
14 ESP_LOGCONFIG(TAG, "Sigma Delta Output:");
15 LOG_PIN(" Pin: ", this->pin_);
16 if (this->state_change_trigger_) {
17 ESP_LOGCONFIG(TAG, " State change automation configured");
18 }
19 if (this->turn_on_trigger_) {
20 ESP_LOGCONFIG(TAG, " Turn on automation configured");
21 }
22 if (this->turn_off_trigger_) {
23 ESP_LOGCONFIG(TAG, " Turn off automation configured");
24 }
25 LOG_UPDATE_INTERVAL(this);
26 LOG_FLOAT_OUTPUT(this);
27}
28
30 this->accum_ += this->state_;
31 const bool next_value = this->accum_ > 0;
32
33 if (next_value) {
34 this->accum_ -= 1.;
35 }
36
37 if (next_value != this->value_) {
38 this->value_ = next_value;
39 if (this->pin_) {
40 this->pin_->digital_write(next_value);
41 }
42
43 if (this->state_change_trigger_) {
44 this->state_change_trigger_->trigger(next_value);
45 }
46
47 if (next_value && this->turn_on_trigger_) {
48 this->turn_on_trigger_->trigger();
49 } else if (!next_value && this->turn_off_trigger_) {
50 this->turn_off_trigger_->trigger();
51 }
52 }
53}
54
55} // namespace esphome::sigma_delta_output
virtual void setup()=0
virtual void digital_write(bool value)=0
std::unique_ptr< Trigger< bool > > state_change_trigger_