ESPHome 2025.5.0
Loading...
Searching...
No Matches
sigma_delta_output.cpp
Go to the documentation of this file.
2#include "esphome/core/log.h"
3
4namespace esphome {
5namespace sigma_delta_output {
6
7static 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 setup()=0
virtual void digital_write(bool value)=0
std::unique_ptr< Trigger< bool > > state_change_trigger_
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7