fw: Only update display if a full frame was received

Sometimes, the RPi fails to send out a message in time, leading
to two, back-to-back SPI transactions. The beginning of the second
is then lost in the long lcd_display() call. By applying this
patch, we now miss the incomplete frame entirely, but at least we
don't display garbage on the screen. Just looks like stutter.

The real solution would be to fix in on the Linux / Python side,
but this workaround is better than nothing for now.
This commit is contained in:
Markus Koch 2020-07-19 21:20:30 +02:00
parent 633d2d0fe2
commit f71c65106f

View File

@ -8,7 +8,7 @@
void spi_proc() void spi_proc()
{ {
static uint8_t spi_cs_last = 0; static uint8_t new_data = 0;
static uint8_t x = 0; static uint8_t x = 0;
static uint8_t y = DISPLAY_HEIGHT / 8 - 1; static uint8_t y = DISPLAY_HEIGHT / 8 - 1;
uint8_t spi_cs; uint8_t spi_cs;
@ -21,21 +21,22 @@ void spi_proc()
if (y == 0) { if (y == 0) {
y = DISPLAY_HEIGHT / 8 - 1; y = DISPLAY_HEIGHT / 8 - 1;
x++; x++;
if (x == DISPLAY_WIDTH) if (x == DISPLAY_WIDTH) {
x = 0; x = 0;
new_data = 1; // Only update the display if a full frame was received
}
} else { } else {
y--; y--;
} }
} }
} else { } else {
if (spi_cs_last) { if (new_data) {
lcd_display(); lcd_display();
new_data = 0;
} }
x = 0; x = 0;
y = DISPLAY_HEIGHT / 8 - 1; y = DISPLAY_HEIGHT / 8 - 1;
} }
spi_cs_last = spi_cs;
} }
int main() int main()