aboutsummaryrefslogtreecommitdiff
path: root/serial_conn.py
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2025-07-20 21:46:40 +0200
committerSébastien Dailly <sebastien@dailly.me>2025-07-20 21:46:40 +0200
commit6de0aef90b5bb2c73fd0f192eb79bf81e2fb6715 (patch)
tree7e3c2ba0cc83796fd1d6729eac6e3d67fa207fc0 /serial_conn.py
parenta4382ed71254dfb8e5eed0a6849e7710e0367cb8 (diff)
Refresh the screen when receiving a change from the host
Diffstat (limited to 'serial_conn.py')
-rw-r--r--serial_conn.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/serial_conn.py b/serial_conn.py
index 0775ba0..a781d64 100644
--- a/serial_conn.py
+++ b/serial_conn.py
@@ -9,6 +9,9 @@ class Client(Module):
the json command.
"""
+ def __init__(self):
+ self.last_name = None
+
def during_bootup(self, keyboard):
try:
# Do not set any timeout, we check before reading a string if there
@@ -23,13 +26,17 @@ class Client(Module):
def before_hid_send(self, keyboard):
# Serial.data isn't initialized yet.
- if not data:
- return
-
- if not data.connected:
- keyboard.keymap[0].name = "Disconnected"
+ if not data or not data.connected:
+ current_name = keyboard.keymap[0].name
+ if current_name != "Disconnected":
+ self.last_name = current_name
+ keyboard.keymap[0].name = "Disconnected"
time.sleep(1)
return
+ if self.last_name is not None:
+ keyboard.keymap[0].name = self.last_name
+ self.last_name = None
+
# Nothing to parse.
if data.in_waiting <= 0: