From 3c874914ef7c484ba8468f16bc4ff471cb224f3c Mon Sep 17 00:00:00 2001 From: dtoro Date: Wed, 29 Apr 2026 23:05:33 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20kick-start=20fan=20on=20every=200?= =?UTF-8?q?=E2=86=92on=20transition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- main/main.ino | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main/main.ino b/main/main.ino index 5f886f1..b7c67f4 100644 --- a/main/main.ino +++ b/main/main.ino @@ -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() {