You've already forked TEF6686_Driver
Implement most 86 commands and move to struct
This commit is contained in:
17
base_tef.py
17
base_tef.py
@@ -1,3 +1,4 @@
|
||||
import struct
|
||||
from protocol import I2CPCClient, time
|
||||
from patches import *
|
||||
|
||||
@@ -40,22 +41,10 @@ class BaseTEF668X:
|
||||
time.sleep(0.01)
|
||||
return data[-1]
|
||||
|
||||
@staticmethod
|
||||
def _base_command_wrapper(func: Callable[Concatenate["BaseTEF668X", P], tuple[bytes, int | None, ABCCallable[[bytes], T] | None]]) -> Callable[Concatenate["BaseTEF668X", P], bytes | T]:
|
||||
def inner(self: "BaseTEF668X", *args: P.args, **kwargs: P.kwargs ) -> bytes | T:
|
||||
data, read_bytes, out_parser = func(self, *args, **kwargs)
|
||||
if read_bytes: data = self.p.write_read_i2c(self.address, data, read_bytes)
|
||||
else: data = self.p.write_i2c(self.address, data)
|
||||
if out_parser: return out_parser(data)
|
||||
return data
|
||||
return inner
|
||||
|
||||
@_base_command_wrapper
|
||||
def APPL_Set_ReferenceClock(self, clock: int, type_clock: bool):
|
||||
return b"\x40\x04\x01" + bytes(((clock >> 16) & 0xffff).to_bytes(2) + (clock & 0xffff).to_bytes(2) + bytes([0, int(type_clock)])), None, None
|
||||
@_base_command_wrapper
|
||||
return self.p.write_i2c(self.address, b"\x40\x04\x01" + struct.pack(">IH", clock, type_clock))
|
||||
def APPL_Activate(self):
|
||||
return b"\x40\x05\x01\x00\x01", None, None
|
||||
return self.p.write_i2c(self.address, b"\x40\x05\x01\x00\x01")
|
||||
|
||||
def init(self, patch = tef_102_patch, patch_lut = tef_102_patch_lut, clock: int = 9216000):
|
||||
self._reset()
|
||||
|
||||
Reference in New Issue
Block a user