mirror of
https://github.com/esphome/esphome.git
synced 2026-09-17 18:18:43 +00:00
[esp8266_pwm] Use a user provided default constructor for ESP8266PWM (#19198)
This commit is contained in:
@@ -11,6 +11,9 @@ namespace esphome::esp8266_pwm {
|
||||
|
||||
class ESP8266PWM final : public output::FloatOutput, public Component {
|
||||
public:
|
||||
// User provided, not "= default": `new(p) ESP8266PWM()` would zero-fill .bss that is already zero.
|
||||
ESP8266PWM() {}
|
||||
|
||||
void set_pin(InternalGPIOPin *pin) { pin_ = pin; }
|
||||
void set_frequency(float frequency) { this->frequency_ = frequency; }
|
||||
/// Dynamically update frequency
|
||||
@@ -28,7 +31,7 @@ class ESP8266PWM final : public output::FloatOutput, public Component {
|
||||
protected:
|
||||
void write_state(float state) override;
|
||||
|
||||
InternalGPIOPin *pin_;
|
||||
InternalGPIOPin *pin_{nullptr};
|
||||
float frequency_{1000.0}; // Keep in sync with DEFAULT_FREQUENCY in output.py
|
||||
/// Cache last output level for dynamic frequency updating
|
||||
float last_output_{0.0};
|
||||
|
||||
Reference in New Issue
Block a user