9 #include <core_esp8266_waveform.h> 12 namespace esp8266_pwm {
14 static const char *
const TAG =
"esp8266_pwm";
17 ESP_LOGCONFIG(TAG,
"Setting up ESP8266 PWM Output...");
22 ESP_LOGCONFIG(TAG,
"ESP8266 PWM:");
23 LOG_PIN(
" Pin: ", this->
pin_);
24 ESP_LOGCONFIG(TAG,
" Frequency: %.1f Hz", this->
frequency_);
25 LOG_FLOAT_OUTPUT(
this);
35 auto total_time_us =
static_cast<uint32_t
>(roundf(1e6f / this->
frequency_));
36 auto duty_on =
static_cast<uint32_t
>(roundf(total_time_us * state));
37 uint32_t duty_off = total_time_us - duty_on;
47 }
else if (duty_off == 0) {
51 startWaveform(this->
pin_->
get_pin(), duty_on, duty_off, 0);
virtual void digital_write(bool value)=0
void dump_config() override
virtual void turn_off()
Disable this binary output.
void write_state(float state) override
float last_output_
Cache last output level for dynamic frequency updating.
virtual uint8_t get_pin() const =0
void setup() override
Initialize pin.
virtual bool digital_read()=0
Implementation of SPI Controller mode.
virtual bool is_inverted() const =0
void IRAM_ATTR HOT delay(uint32_t ms)