-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscreen.py
32 lines (29 loc) · 835 Bytes
/
screen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import mtimage
import minitel
import json
class Screen:
def __init__(self,text):
self.contents = json.loads(text)
def render(self,m):
m.clearScreen()
for element in self.contents:
t = element['type']
if t == 'text':
self.renderText(m,element)
elif t == 'image':
self.renderImage(m,element)
def renderText(self,m,e):
x = e.get('x',0)
y = e.get('y',0)
text = e.get('text','')
fg = e.get('fg',7)
bg = e.get('bg',0)
m.moveCursor(x,y)
m.setVTMode(minitel.VT_TEXT)
m.setColors(fg,bg)
m.send(text)
if __name__ == '__main__':
m = minitel.Minitel('/dev/ttyUSB0')
m.clearScreen()
s = Screen('{}')
s.renderText(m,{'x':14,'y':13,'text':'hello world'})