ESPHome 2025.5.0
Loading...
Searching...
No Matches
libretiny_pwm.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/hal.h"
7
8#ifdef USE_LIBRETINY
9
10namespace esphome {
11namespace libretiny_pwm {
12
14 public:
15 explicit LibreTinyPWM(InternalGPIOPin *pin) : pin_(pin) {}
16
19 void update_frequency(float frequency) override;
20
22 void setup() override;
23 void dump_config() override;
25 float get_setup_priority() const override { return setup_priority::HARDWARE; }
26
28 void write_state(float state) override;
29
30 protected:
32 uint8_t bit_depth_{10};
33 float frequency_{};
34 float duty_{0.0f};
35 bool initialized_ = false;
36};
37
38template<typename... Ts> class SetFrequencyAction : public Action<Ts...> {
39 public:
42
43 void play(Ts... x) {
44 float freq = this->frequency_.value(x...);
45 this->parent_->update_frequency(freq);
46 }
47
48 protected:
50};
51
52} // namespace libretiny_pwm
53} // namespace esphome
54
55#endif
uint16_le_t frequency
Definition bl0942.h:6
float get_setup_priority() const override
HARDWARE setup priority.
void update_frequency(float frequency) override
Dynamically change frequency at runtime.
void set_frequency(float frequency)
void write_state(float state) override
Override FloatOutput's write_state.
void setup() override
Setup LibreTinyPWM.
Base class for all output components that can output a variable level, like PWM.
bool state
Definition fan.h:0
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.cpp:18
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5