-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtext3.py
44 lines (35 loc) · 1.45 KB
/
runtext3.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
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
#-*- coding: utf-8 -*-
# 위 주석은 한글을 위해 반드시 추가해 주어야 한다.
# 파이썬 Samples/runtext.py 수정
# Display a runtext with double-buffering.
from samplebase import SampleBase
from rgbmatrix import graphics
import time
import scrolldata
class RunText2(SampleBase):
def __init__(self, *args, **kwargs):
super(RunText2, self).__init__(*args, **kwargs) # class: RunText2
self.parser.add_argument("-t", "--text", help="The text to scroll on the RGB LED panel", default="Hello world!")
def run(self):
offscreen_canvas = self.matrix.CreateFrameCanvas()
font = graphics.Font()
# font.LoadFont("../../../fonts/7x13.bdf") # default
font.LoadFont("../../../fonts/NanumGothic-Regular.bdf")
textColor = graphics.Color(255, 255, 0)
pos = offscreen_canvas.width
vpos = font.baseline + 1
my_text = scrolldata.getdata('koreaData_All_2020-11-26.js')
while True:
offscreen_canvas.Clear()
len = graphics.DrawText(offscreen_canvas, font, pos, vpos, textColor, my_text)
pos -= 1
if (pos + len < 0):
pos = offscreen_canvas.width
time.sleep(0.05)
offscreen_canvas = self.matrix.SwapOnVSync(offscreen_canvas)
# Main function
if __name__ == "__main__":
run_text = RunText2()
if (not run_text.process()):
run_text.print_help()