feat(display): add active state parameter to hint animation

1. **Added `active` parameter to hint animation**
   - `updateHint()` now accepts a boolean `active` parameter across both display drivers (TFT and GFX)
   - When `active=true`: faster pulse animation (500ms period) during active hold
   - When `active=false`: slower pulse animation (2000ms period) during idle state

2. **Improved animation calculations**
   - Replaced modulo operator with `fmodf()` for cleaner float calculations
   - Standardized to `static_cast<uint8_t>()` for type conversions
   - Fixed GFX driver to use `color565()` method instead of manual bit shifting

3. **Updated hint display logic**
   - Now differentiates between "holding" state (fast pulse) and "idle" state (slow pulse)
   - Hint draws at both states when `holdStartX >= 0` (touch position captured)

4. **Added code formatter task**
   - New `mise.toml` task for running clang-format across all source files

- Users get **visual feedback differentiation**: fast pulsing during active hold vs. slow pulsing when idle
- More intuitive UI that clearly indicates whether a long-press is in progress or just waiting
- Cleaner, more maintainable code with standardized calculations and type conversions
This commit is contained in:
2026-02-17 05:03:41 -08:00
parent ff073c762b
commit c4adb38576
6 changed files with 36 additions and 19 deletions

View File

@@ -239,21 +239,21 @@ void DisplayDriverGFX::drawDashboard(const ScreenState& state) {
}
}
void DisplayDriverGFX::updateHint(int x, int y) {
void DisplayDriverGFX::updateHint(int x, int y, bool active) {
if(!_gfx)
return;
static uint32_t lastTime = 0;
uint32_t now = millis();
// Fixed: throttle to 100ms instead of 50ms
if(now - lastTime < 100)
return;
lastTime = now;
float t = (now % 2000) / 2000.0f;
uint8_t v = static_cast<uint8_t>(30.0f + 30.0f * sinf(t * 2 * 3.14159f));
uint16_t col = ((v >> 3) << 11) | ((v >> 2) << 5) | (v >> 3);
// active=true: faster pulse (500ms), active=false: slower pulse (2000ms)
float period = active ? 500.0f : 2000.0f;
float t = fmodf(now, period) / period;
uint8_t v = static_cast<uint8_t>(30.0f + 30.0f * sinf(t * 2.0f * 3.14159f));
uint16_t col = _gfx->color565(v, v, v);
// Draw at touch position instead of center
_gfx->drawCircle(x, y, 50, col);
}