adding files

This commit is contained in:
2026-03-21 23:51:53 +01:00
commit 8cb0240ca2
19 changed files with 2162 additions and 0 deletions

37
RPi/fake_smbus.py Normal file
View File

@@ -0,0 +1,37 @@
import tkinter as tk
encoders = []
class SMBus:
def __init__(self, bus):
print(f"fake SMBus initialized on bus {bus}")
self.bus = bus
def read_i2c_block_data(self, addr, cmd, length):
data = []
for encoder in encoders:
pos_as_byte_array = encoder.get_position().to_bytes(2, 'little', signed=True)
data.append(pos_as_byte_array[0])
data.append(pos_as_byte_array[1])
#print(f"SMBus data set to: {data}")
return data
def createTestEncoder():
encoder = TestEncoder()
encoders.append(encoder)
return encoder
class TestEncoder:
""" represent a test encoder controlled by keyboard input """
def __init__(self):
self._position = 0
def _rotate_cw(self, event=None):
self._position += 1
def _rotate_ccw(self, event=None):
self._position -= 1
def get_position(self) -> int:
return self._position