Expose lambda action to reset a cycle in slow_pwm (#4158)

This commit is contained in:
John Britton 2022-12-07 01:27:14 -05:00 committed by GitHub
parent 34387adbcd
commit 92e44b8238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View file

@ -70,7 +70,7 @@ void SlowPWMOutput::dump_config() {
void SlowPWMOutput::write_state(float state) {
this->state_ = state;
if (this->restart_cycle_on_state_change_)
this->period_start_time_ = millis();
this->restart_cycle();
}
} // namespace slow_pwm

View file

@ -14,6 +14,7 @@ class SlowPWMOutput : public output::FloatOutput, public Component {
void set_restart_cycle_on_state_change(bool restart_cycle_on_state_change) {
restart_cycle_on_state_change_ = restart_cycle_on_state_change;
}
void restart_cycle() { this->period_start_time_ = millis(); }
/// Initialize pin
void setup() override;