perf(DisplayDriverTFT): Throttle alert redraws to prevent tearing

This commit is contained in:
2026-02-20 02:41:04 -08:00
parent ba8789797c
commit b68d36bb85
2 changed files with 11 additions and 1 deletions

View File

@@ -193,8 +193,16 @@ void DisplayDriverTFT::drawBoot(const ScreenState& st) {
} }
void DisplayDriverTFT::drawAlert(const ScreenState& st) { void DisplayDriverTFT::drawAlert(const ScreenState& st) {
// Throttle redraws to ~24fps to prevent tearing
uint32_t now = millis();
if(now - _lastAlertDrawMs < ALERT_DRAW_INTERVAL_MS) {
return;
}
_lastAlertDrawMs = now;
uint32_t elapsed = millis() - st.alertStartMs; uint32_t elapsed = millis() - st.alertStartMs;
uint8_t pulse = 180 + (uint8_t)(75.0f * sinf(elapsed / 300.0f)); // Slower pulse - divide by 1500 for ~9.4 second cycle (was 300 for ~1.9s)
uint8_t pulse = 180 + (uint8_t)(75.0f * sinf(elapsed / 1500.0f));
uint16_t bg = _tft.color565(pulse, 0, 0); uint16_t bg = _tft.color565(pulse, 0, 0);
_tft.fillScreen(bg); _tft.fillScreen(bg);

View File

@@ -44,7 +44,9 @@ private:
// Touch hint for alert - progressive fill from bottom // Touch hint for alert - progressive fill from bottom
bool _alertTouchDown = false; bool _alertTouchDown = false;
uint32_t _alertTouchStartMs = 0; uint32_t _alertTouchStartMs = 0;
uint32_t _lastAlertDrawMs = 0;
static constexpr uint32_t ALERT_FILL_DURATION_MS = 3000; static constexpr uint32_t ALERT_FILL_DURATION_MS = 3000;
static constexpr uint32_t ALERT_DRAW_INTERVAL_MS = 333; // ~3fps
// Touch tracking for press/release detection // Touch tracking for press/release detection
bool _touchWasPressed = false; bool _touchWasPressed = false;