Skip to content

Commit ac169f3

Browse files
committed
On macOS, flush serial buffer regularly to avoid bitmap corruption
1 parent 74a49da commit ac169f3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library/lcd/lcd_comm.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import copy
2020
import math
2121
import os
22+
import platform
2223
import queue
2324
import sys
2425
import threading
@@ -139,6 +140,10 @@ def SendLine(self, line: bytes):
139140
def WriteLine(self, line: bytes):
140141
try:
141142
self.serial_write(line)
143+
if platform.system() == "Darwin":
144+
# macOS needs the serial buffer to be flushed regularly to avoid bitmap corruption on the display
145+
# See https://github.com/mathoudebine/turing-smart-screen-python/issues/7
146+
self.lcd_serial.flush()
142147
except serial.SerialTimeoutException:
143148
# We timed-out trying to write to our device, slow things down.
144149
logger.warning("(Write line) Too fast! Slow down!")

0 commit comments

Comments
 (0)