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