1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-16 18:22:22 +01:00

Calculate PWM wrap dynamically whenever the frequency is changed (#4294)

fixes https://github.com/esphome/issues/issues/3841
This commit is contained in:
tradeJmark
2023-01-15 21:17:57 -04:00
committed by GitHub
parent 27185265f6
commit a45646af1b
2 changed files with 11 additions and 3 deletions

View File

@@ -34,6 +34,7 @@ class RP2040PWM : public output::FloatOutput, public Component {
InternalGPIOPin *pin_;
float frequency_{1000.0};
uint16_t wrap_{65535};
/// Cache last output level for dynamic frequency updating
float last_output_{0.0};
bool frequency_changed_{false};