Fermenter PWM 100Hz
This commit is contained in:
parent
674fafc318
commit
c87c46ce9c
@ -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<int>(percent / 100.0 * CONTROL_PWM_MAX));
|
||||
void setPercent(const double newPercent) {
|
||||
setValue(static_cast<int>(newPercent / 100.0 * CONTROL_PWM_MAX));
|
||||
}
|
||||
|
||||
[[nodiscard]] double getPercent() const {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user