aboutsummaryrefslogtreecommitdiff
path: root/src/splitscreen_duo/serial.py
diff options
context:
space:
mode:
authorZoltan Szabatin <[email protected]>2025-02-25 16:12:49 -0800
committerZoltan Szabatin <[email protected]>2025-02-25 16:12:49 -0800
commitbdcc991a5a3bec5e136be97b14de8e51939f3652 (patch)
tree9433cf8c24a447d88ec19077c4a2966ef511783c /src/splitscreen_duo/serial.py
parentfeat: Add Pygame menu (diff)
downloadsplitscreen-duo-bdcc991a5a3bec5e136be97b14de8e51939f3652.tar.xz
splitscreen-duo-bdcc991a5a3bec5e136be97b14de8e51939f3652.zip
feat: Add serial interface
Diffstat (limited to 'src/splitscreen_duo/serial.py')
-rw-r--r--src/splitscreen_duo/serial.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/splitscreen_duo/serial.py b/src/splitscreen_duo/serial.py
new file mode 100644
index 0000000..bc9caec
--- /dev/null
+++ b/src/splitscreen_duo/serial.py
@@ -0,0 +1,21 @@
+import serial
+
+
+class Serial:
+ def __init__(self, port, baudrate=115200):
+ self.port = port
+ self.baudrate = baudrate
+ self.serial = serial.Serial(port, baudrate, timeout=0.1)
+
+ def read(self):
+ return self.serial.read()
+
+ def write(self, data):
+ self.serial.write(data)
+
+ def readline(self):
+ return self.serial.readline()
+
+ def in_waiting(self):
+ return self.serial.in_waiting
+