Skip to content

Commit b6c2873

Browse files
committed
Minor cleanup
1 parent e87ddb4 commit b6c2873

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

QuickPID.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**********************************************************************************
2-
QuickPID Library for Arduino - Version 2.2.1
2+
QuickPID Library for Arduino - Version 2.2.2
33
by dlloydev https://github.com/Dlloydev/QuickPID
44
Based on the Arduino PID Library by Brett Beauregard
55
@@ -147,7 +147,6 @@ void QuickPID::AutoTune(int inputPin, int outputPin, int tuningRule, int Print =
147147
ki = Rule[tuningRule][cki] / 1000.0 * Ku / Tu;
148148
kd = Rule[tuningRule][ckd] / 1000.0 * Ku * Tu;
149149
}
150-
151150
dispKp = kp;
152151
dispKi = ki;
153152
dispKd = kd;
@@ -362,7 +361,6 @@ void QuickPID::Stabilize(int inputPin, int outputPin, uint32_t timeout) {
362361
}
363362

364363
#if defined(ESP32)
365-
366364
// Adds support for analogWrite() for up to 9 PWM pins plus pins DAC1 and DAC2 which are 8-bit true analog outputs.
367365
// Also adds support for changing the PWM frequency (5000 Hz default) and timer resolution (13-bit default).
368366

@@ -416,7 +414,10 @@ void analogWrite(uint8_t pin, uint32_t value) {
416414
if (value > valueMax) value = valueMax;
417415
ledcWrite(i, value);
418416
}
419-
if (pin == DAC1 || pin == DAC2) dacWrite(pin, value & 255);
417+
if (pin == DAC1 || pin == DAC2) {
418+
if (value > 255) value = 255;
419+
dacWrite(pin, value);
420+
}
420421
}
421422
}
422423
#endif

QuickPID.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class QuickPID
110110
};
111111

112112
#if defined(ESP32)
113-
// Adds support for analogWrite() for up to 16 PWM pins plus pins DAC1 and DAC2 which are 8-bit true analog outputs.
113+
// Adds support for analogWrite() for up to 9 PWM pins plus pins DAC1 and DAC2 which are 8-bit true analog outputs.
114114
// Also adds support for changing the PWM frequency (5000 Hz default) and timer resolution (13-bit default).
115115

116116
typedef struct analog_write_channel {
@@ -125,5 +125,4 @@ void analogWriteResolution(uint8_t resolution = 13);
125125
void analogWriteResolution(uint8_t pin, uint8_t resolution = 13);
126126
void analogWrite(uint8_t pin, uint32_t value = 0);
127127
#endif
128-
129-
#endif
128+
#endif //QuickPID.h

0 commit comments

Comments
 (0)