perf(DisplayDriverTFT): Throttle alert redraws to prevent tearing
This commit is contained in:
@@ -193,8 +193,16 @@ void DisplayDriverTFT::drawBoot(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;
|
||||
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);
|
||||
|
||||
_tft.fillScreen(bg);
|
||||
|
||||
@@ -44,7 +44,9 @@ private:
|
||||
// Touch hint for alert - progressive fill from bottom
|
||||
bool _alertTouchDown = false;
|
||||
uint32_t _alertTouchStartMs = 0;
|
||||
uint32_t _lastAlertDrawMs = 0;
|
||||
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
|
||||
bool _touchWasPressed = false;
|
||||
|
||||
Reference in New Issue
Block a user