ESPHome 2026.5.0b1
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::libretiny_pwm {
11
13 public:
14 explicit LibreTinyPWM(InternalGPIOPin *pin) : pin_(pin) {}
15
18 void update_frequency(float frequency) override;
19
21 void setup() override;
22 void dump_config() override;
24 float get_setup_priority() const override { return setup_priority::HARDWARE; }
25
27 void write_state(float state) override;
28
29 protected:
31 uint8_t bit_depth_{10};
32 float frequency_{};
33 float duty_{0.0f};
34 bool initialized_ = false;
35};
36
37template<typename... Ts> class SetFrequencyAction : public Action<Ts...> {
38 public:
41
42 void play(const Ts &...x) {
43 float freq = this->frequency_.value(x...);
44 this->parent_->update_frequency(freq);
45 }
46
47 protected:
49};
50
51} // namespace esphome::libretiny_pwm
52
53#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:2
constexpr float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.h:41
uint16_t x
Definition tt21100.cpp:5