7 namespace libretiny_pwm {
9 static const char *
const TAG =
"libretiny.pwm";
13 ESP_LOGW(TAG,
"LibreTinyPWM output hasn't been initialized yet!");
21 const uint32_t max_duty = (uint32_t(1) << this->
bit_depth_) - 1;
22 const float duty_rounded = roundf(state * max_duty);
23 auto duty =
static_cast<uint32_t
>(duty_rounded);
34 ESP_LOGCONFIG(TAG,
"PWM Output:");
35 LOG_PIN(
" Pin ", this->
pin_);
36 ESP_LOGCONFIG(TAG,
" Frequency: %.1f Hz", this->
frequency_);
44 analogWriteFrequency(frequency);
void setup() override
Setup LibreTinyPWM.
virtual void turn_off()
Disable this binary output.
void dump_config() override
virtual void pin_mode(gpio::Flags flags)=0
void update_frequency(float frequency) override
Dynamically change frequency at runtime.
virtual uint8_t get_pin() const =0
void write_state(float state) override
Override FloatOutput's write_state.
Implementation of SPI Controller mode.
virtual bool is_inverted() const =0