fix: kick-start fan on every 0→on transition

Previous kick-start only fired when duty < 200, but all level duties are
≥230, so L1 starts from rest at PWM 230 and the rotor can't break static
friction. Now we briefly drive 100% on any off→on transition before
dropping to the target duty.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-29 23:05:33 +02:00
parent 5e1f284c1c
commit 3c874914ef

View File

@@ -55,16 +55,21 @@ int yOffset = 30;
uint8_t fanLevel = 0; // 0 = off, 1..NUM_LEVELS uint8_t fanLevel = 0; // 0 = off, 1..NUM_LEVELS
void applyFan() { void applyFan() {
static uint8_t lastDuty = 0;
if (fanLevel == 0) { if (fanLevel == 0) {
ledcWrite(FAN_PIN, 0); ledcWrite(FAN_PIN, 0);
lastDuty = 0;
return; return;
} }
uint8_t duty = LEVELS[fanLevel - 1].duty; uint8_t duty = LEVELS[fanLevel - 1].duty;
if (duty > 0 && duty < 200) { // Kick-start whenever spinning up from stopped — full duty briefly so the
ledcWrite(FAN_PIN, 255); // kick-start // rotor breaks static friction, then drop to the target.
delay(300); if (lastDuty == 0) {
ledcWrite(FAN_PIN, 255);
delay(400);
} }
ledcWrite(FAN_PIN, duty); ledcWrite(FAN_PIN, duty);
lastDuty = duty;
} }
void publishFan() { void publishFan() {