diff --git a/src/patrix/PWMOutput.h b/src/patrix/PWMOutput.h index b30dac3..b11b910 100644 --- a/src/patrix/PWMOutput.h +++ b/src/patrix/PWMOutput.h @@ -10,18 +10,21 @@ class PWMOutput { String name; + uint32_t frequency = 0; + int value = 0; double percent = 0; public: - explicit PWMOutput(const uint8_t gpio, String name): gpio(gpio), name(std::move(name)) { + explicit PWMOutput(const uint8_t gpio, String name, uint32_t frequency) : gpio(gpio), name(std::move(name)), frequency(frequency) { // } void setup() { analogWriteResolution(CONTROL_PWM_BITS); + analogWriteFreq(frequency); setValue(0); } @@ -31,8 +34,8 @@ public: analogWrite(gpio, value); } - void setPercent(const double percent) { - setValue(static_cast(percent / 100.0 * CONTROL_PWM_MAX)); + void setPercent(const double newPercent) { + setValue(static_cast(newPercent / 100.0 * CONTROL_PWM_MAX)); } [[nodiscard]] double getPercent() const {