StreamDock Base Class
The control classes of all specific device models need to inherit the StreamDock base class, which provides the following methods:
Open the device
def open(self):
self.transport.open(bytes(self.path,'utf-8'))
Turn off the device
def close(self):
self.disconnected()
## self.transport.close()
Disconnect Clear all displays
def disconnected(self):
self.transport.disconnected()
Clear a button's icon
def cleaerIcon(self,index):
self.transport.keyClear(index)
Clear all button icons
def clearAllIcon(self):
self.transport.keyAllClear()
Wake up the screen
def wakeScreen(self):
self.transport.wakeScreen()
Refresh device display
def refresh(self):
self.transport.refresh()
Get device path
def getPath(self):
return self.path
Get information from device feedback
def read(self):
"""
:argtypes:Byte array for storing information.
The recommended length of the byte array is 512
"""
arr=self.transport.read()
return arr
Keep checking whether the device has any information feedback. It is recommended to start another thread to use
def whileread(self):
while 1:
arr=self.read()
if len(arr)>=10:
if arr[9]==0xFF:
print("Write Success")
else:
print("Button{}".format(arr[9]))
if arr[10]==0x01:
print("Pressed")
else:
print("Up")
else:
print(arr)
del arr
Get the device serial number
@abstractmethod
def get_serial_number(self):
pass
Set button icon
@abstractmethod
def set_key_image(self, key, image):
pass
Setting Brightness
@abstractmethod
def set_brightness(self, percent):
pass
Setting the touch screen image
@abstractmethod
def set_touchscreen_image(self, image):
pass
Set the button icon through imagedata
@abstractmethod
def set_key_imagedata(self, key, image,width=126,height=126):
pass