ESPHome  2024.11.2
sigma_delta_output.h
Go to the documentation of this file.
1 #pragma once
4 #include "esphome/core/hal.h"
6 
7 namespace esphome {
8 namespace sigma_delta_output {
9 
11  public:
13  if (!this->turn_on_trigger_)
14  this->turn_on_trigger_ = make_unique<Trigger<>>();
15  return this->turn_on_trigger_.get();
16  }
18  if (!this->turn_off_trigger_)
19  this->turn_off_trigger_ = make_unique<Trigger<>>();
20  return this->turn_off_trigger_.get();
21  }
22 
24  if (!this->state_change_trigger_)
25  this->state_change_trigger_ = make_unique<Trigger<bool>>();
26  return this->state_change_trigger_.get();
27  }
28 
29  void set_pin(GPIOPin *pin) { this->pin_ = pin; };
30  void write_state(float state) override { this->state_ = state; }
31  void setup() override;
32  void dump_config() override;
33  void update() override;
34 
35  protected:
36  GPIOPin *pin_{nullptr};
37 
38  std::unique_ptr<Trigger<>> turn_on_trigger_{nullptr};
39  std::unique_ptr<Trigger<>> turn_off_trigger_{nullptr};
40  std::unique_ptr<Trigger<bool>> state_change_trigger_{nullptr};
41 
42  float accum_{0};
43  float state_{0.};
44  bool value_{false};
45 };
46 } // namespace sigma_delta_output
47 } // namespace esphome
std::unique_ptr< Trigger< bool > > state_change_trigger_
Base class for all output components that can output a variable level, like PWM.
Definition: float_output.h:31
std::unique_ptr< Trigger<> > turn_off_trigger_
This class simplifies creating components that periodically check a state.
Definition: component.h:283
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
bool state
Definition: fan.h:34