fixed the broken fade out when the watchdog kicks in

This commit is contained in:
2026-01-18 06:06:57 +01:00
parent a9957bc695
commit c1d7ba4b3d

View File

@@ -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) --------