This commit is contained in:
parent
d702695b3b
commit
300323853b
4 changed files with 210 additions and 4 deletions
106
buba/__main__.py
106
buba/__main__.py
|
@ -1,9 +1,113 @@
|
|||
|
||||
from time import sleep
|
||||
|
||||
from pyfis.aegmis import MIS1TextDisplay
|
||||
from pyfis.utils import debug_hex
|
||||
|
||||
|
||||
display = MIS1TextDisplay("/dev/ttyUSB3",)
|
||||
def receive(display):
|
||||
if display.use_rts:
|
||||
display.port.setRTS(1)
|
||||
display.port.write([0x04, 0x81, 0x05])
|
||||
if display.use_rts:
|
||||
display.port.setRTS(0)
|
||||
return display.read_response(True)
|
||||
|
||||
def decode(display):
|
||||
r = receive(display)
|
||||
if r[0] != 0x02:
|
||||
print("Invalid byte {r[0]:02x}, expected EOT")
|
||||
d = {
|
||||
'code': r[1],
|
||||
'subcode': r[2],
|
||||
}
|
||||
m = []
|
||||
esc = False
|
||||
for i in range(3, len(r)-1):
|
||||
if esc:
|
||||
m.append(r[i])
|
||||
erc = False
|
||||
elif r[i] == 0x10:
|
||||
esc = True
|
||||
else:
|
||||
if r[i] == 0x03:
|
||||
# compute checksum
|
||||
next
|
||||
m.append(r[i])
|
||||
m = m[0:-1]
|
||||
print(f"m({len(m)}): {debug_hex(m)}")
|
||||
return m
|
||||
|
||||
|
||||
def reset_and_get_config(display):
|
||||
display.send_command(0x31, 0x00, [])
|
||||
r = decode(display)
|
||||
return {
|
||||
'type': r[0],
|
||||
'control-units': r[1],
|
||||
'digits-a': r[2] * 256 + r[3],
|
||||
'lines-a': r[4],
|
||||
'digits-b': r[5] * 256 + r[6],
|
||||
'lines-b': r[7],
|
||||
'timeout': r[8] * 128.0 + r[9] * 0.5,
|
||||
}
|
||||
|
||||
def get_config(display):
|
||||
display.send_command(0x38, 0x00, [])
|
||||
r = decode(display)
|
||||
return r
|
||||
|
||||
def text_raw(display, page, row, text):
|
||||
data = [display.ALIGN_LEFT, page, row, 0] + text
|
||||
return display.send_command(0x11, 0x00, data, expect_response=False)
|
||||
|
||||
|
||||
print("Opening serial port")
|
||||
display = MIS1TextDisplay("/dev/ttyUSB0")
|
||||
|
||||
print("Sending text")
|
||||
display.debug = True
|
||||
#r = display.send_command(0x31, 0x00, []) # reset
|
||||
#r = display.send_command(0x32, 0x01, []) # test
|
||||
#r = display.send_command(0x38, 0x01, []) # read config
|
||||
#r = display.read_response()
|
||||
#print(f"Response: {r}")
|
||||
#r = display.send_command(0x52, 0x01, []) # read config
|
||||
#display.send_raw_telegram([0xff])
|
||||
#display.send_raw_data([0x04, 0x81, 0x02, 0x03, 0x00])
|
||||
#print(f"response: {display.read_response()}")
|
||||
#r = reset_and_get_config(display)
|
||||
r = get_config(display)
|
||||
print(f"reply {len(r)}: {r}")
|
||||
|
||||
display.simple_text(page=1, row=0, col=0, text="MEOW MEOW MEOW MEOW MEOW MEOW MEOW MEOW", align=display.ALIGN_CENTER)
|
||||
display.simple_text(page=1, row=1, col=0, text="MEOW MEOW MEOW MEOW MEOW MEOW MEOW MEOW", align=display.ALIGN_CENTER)
|
||||
display.simple_text(page=1, row=2, col=0, text="MEOW MEOW MEOW MEOW MEOW MEOW MEOW MEOW", align=display.ALIGN_CENTER)
|
||||
display.simple_text(page=1, row=3, col=0, text="MEOW MEOW MEOW MEOW MEOW MEOW MEOW MEOW", align=display.ALIGN_CENTER)
|
||||
|
||||
display.simple_text(page=0, row=3, col=0, text="MEOW MEOW MEOW MEOW MEOW MEOW", align=display.ALIGN_CENTER)
|
||||
|
||||
#print("page 1")
|
||||
#display.set_page(1)
|
||||
#sleep(10)
|
||||
|
||||
#for l in range(0,4):
|
||||
# display.simple_text(page=0, row=l, col=0, text="")
|
||||
#print("page 0")
|
||||
#display.set_page(0)
|
||||
#sleep(10)
|
||||
|
||||
#print("page 1")
|
||||
#display.set_page(1)
|
||||
#sleep(10)
|
||||
|
||||
display.set_pages(((0,5), (1,5), (2,5), (3,5), (4,5), (5,5)))
|
||||
for p in range(0,6):
|
||||
for l in range(0,4):
|
||||
b = []
|
||||
for c in range(0,16):
|
||||
b.append(((((l+p) % 6) + 2) * 16) + c)
|
||||
text_raw(display, p, l, b)
|
||||
|
||||
|
||||
print("Thats all, folks!")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue