Change button animations

This commit is contained in:
Andreas committed 2026-04-13 16:58:57 +02:00
1 parent bf27305563
commit 08e4f6c5cc
3 files changed
+72 -84

No files matched your search

+10 -9
View File
@@ -46,9 +46,11 @@ All buttons wired with `INPUT_PULLUP`: connect each button between its pin and G
| Button type | LED feedback | Temperature |
|---|---|---|
| Correct | Blinks **green** | −1 section |
| Half-correct | Glows **orange/yellow** | +1 section |
| Wrong | Blinks **red** | +1 section |
| Correct | Affected sections light up **green** bottom→top, then fade out | −1 section (−2 if switching from wrong) |
| Half-correct | Affected sections light up **yellow** bottom→top, then fade out | +1 section |
| Wrong | Affected sections light up **red** bottom→top, then fade out | +1 section |
The animation always plays on every button press, even if the temperature doesn't change (re-press). If switching from a wrong answer to correct, 14 LEDs (2 sections) are animated.
- You can change an answer at any time by pressing a different button in the same group.
- **Win condition**: all 4 correct answers selected → thermometer reaches 0 → rainbow win animation plays → game automatically resets and starts over.
@@ -164,13 +166,12 @@ Each value (0, 1, or 2) is the button index within that question's group. The re
### Feedback animations
| Type | Animation | Temp effect |
|---|---|---|
| `ANSWER_CORRECT` | Green blink × 3 | −1 section |
| `ANSWER_HALF` | Orange/yellow steady glow (700 ms) | +1 section |
| `ANSWER_WRONG` | Red blink × 3 | +1 section |
All three types share `playTempAnimation(fromSections, toSections, color)`:
- **Dropping** (correct): animates sections `toSections..fromSections-1` in green
- **Rising** (wrong/half): animates sections `fromSections..toSections-1` in red/yellow
- **Re-press** (no change): animates one section at the current boundary for feedback
After any feedback animation, the thermometer is immediately redrawn before the slide animation runs.
The preview temp is computed before state is updated, so the animation always targets the right LEDs.
### Win animation