fixed the broken fade out when the watchdog kicks in
This commit is contained in:
@@ -183,19 +183,22 @@ void loop() {
|
||||
}
|
||||
}
|
||||
|
||||
// -------- Slew-rate limiting (smooth 1-second transitions) --------
|
||||
unsigned long now = millis();
|
||||
float progress = (float)(now - slewStartTime) / (float)slewDuration;
|
||||
if (progress > 1.0f) progress = 1.0f;
|
||||
// -------- Slew-rate limiting (only when NOT in watchdog mode) --------
|
||||
if (millis() - lastPacketTime <= watchdogTimeout) {
|
||||
|
||||
for (int ch = 0; ch < NUM_CHANNELS; ch++) {
|
||||
float newDuty = slewStartDuty[ch] + (targetDuty[ch] - slewStartDuty[ch]) * progress;
|
||||
currentDuty[ch] = newDuty;
|
||||
unsigned long now = millis();
|
||||
float progress = (float)(now - slewStartTime) / (float)slewDuration;
|
||||
if (progress > 1.0f) progress = 1.0f;
|
||||
|
||||
float calibratedDuty = applyCalibration(ch, newDuty);
|
||||
int duty = (int)((calibratedDuty / 100.0f) * ((1 << pwmResolution) - 1));
|
||||
for (int ch = 0; ch < NUM_CHANNELS; ch++) {
|
||||
float newDuty = slewStartDuty[ch] + (targetDuty[ch] - slewStartDuty[ch]) * progress;
|
||||
currentDuty[ch] = newDuty;
|
||||
|
||||
ledcWrite(pwmPins[ch], duty);
|
||||
float calibratedDuty = applyCalibration(ch, newDuty);
|
||||
int duty = (int)((calibratedDuty / 100.0f) * ((1 << pwmResolution) - 1));
|
||||
|
||||
ledcWrite(pwmPins[ch], duty);
|
||||
}
|
||||
}
|
||||
|
||||
// -------- Watchdog fade-to-zero (UDP-based) --------
|
||||
|
||||
Reference in New Issue
Block a user