fix(simulator): sample LCD at a fixed cadence so the final frame is always painted (#7504)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Raphael Coeffic
2026-06-30 11:49:11 +10:00
committed by GitHub
co-authored by Claude Opus 4.8
parent 3d189a901c
commit f67d1665ea
2 changed files with 24 additions and 7 deletions
+16 -4
View File
@@ -71,14 +71,26 @@ void LcdWidget::makeScreenshot(const QString &fileName)
void LcdWidget::onLcdChanged(uint8_t* lcdBuf, bool light)
{
// Ingest only: store the latest frame and let frameTimer drive the repaint.
// Sampling on a fixed cadence caps the repaint rate without dropping the
// final frame of a burst, regardless of how frames are delivered.
QMutexLocker locker(&lcdMtx);
lightEnable = light;
if (lcdBuf) memcpy(localBuf, lcdBuf, lcdSize);
if (!redrawTimer.isValid() ||
redrawTimer.hasExpired(LCD_WIDGET_REFRESH_PERIOD)) {
update();
redrawTimer.start();
dirty = true;
if (!frameTimer.isActive())
frameTimer.start();
}
void LcdWidget::onFrameTick()
{
QMutexLocker locker(&lcdMtx);
if (!dirty) { // idle: stop until the next frame arrives
frameTimer.stop();
return;
}
dirty = false;
update();
}
void LcdWidget::doPaint(QPainter &p)