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