-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·177 lines (162 loc) · 7.56 KB
/
main.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Trinket IO demo
# Welcome to CircuitPython 3.1.1 :)
import board
import busio
import time
import math
import as1130
import display
import random
# Font
font_5x5_data =[
[0b0,0b0,0b0,0b0,0b0], #
[0b10000000,0b10000000,0b10000000,0b0,0b10000000], # !
[0b10100000,0b0,0b0,0b0,0b0], # "
[0b1010000,0b11111000,0b1010000,0b11111000,0b1010000], # #
[0b11111000,0b10100000,0b11111000,0b101000,0b11111000], # $
[0b10001000,0b10000,0b100000,0b1000000,0b10001000], # %
[0b1100000,0b10000000,0b1101000,0b10010000,0b1101000], # &
[0b10000000,0b0,0b0,0b0,0b0], # '
[0b1000000,0b10000000,0b10000000,0b10000000,0b1000000], # (
[0b10000000,0b1000000,0b1000000,0b1000000,0b10000000], # )
[0b1000000,0b0,0b0,0b0,0b0], # *
[0b100000,0b100000,0b11111000,0b100000,0b100000], # +
[0b0,0b0,0b0,0b0,0b10000000], # ,
[0b0,0b0,0b11111000,0b0,0b0], # -
[0b0,0b0,0b0,0b0,0b10000000], # .
[0b100000,0b100000,0b1000000,0b10000000,0b10000000], # /
[0b11111000,0b10011000,0b10101000,0b11001000,0b11111000], # 0
[0b1000000,0b11000000,0b1000000,0b1000000,0b11100000], # 1
[0b11110000,0b1000,0b1110000,0b10000000,0b11111000], # 2
[0b11111000,0b1000,0b1110000,0b1000,0b11111000], # 3
[0b10000000,0b10000000,0b10100000,0b11111000,0b100000], # 4
[0b11111000,0b10000000,0b11110000,0b1000,0b11110000], # 5
[0b11111000,0b10000000,0b11111000,0b10001000,0b11111000], # 6
[0b11111000,0b1000,0b10000,0b100000,0b100000], # 7
[0b11111000,0b10001000,0b11111000,0b10001000,0b11111000], # 8
[0b11111000,0b10001000,0b11111000,0b1000,0b11111000], # 9
[0b10000000,0b0,0b0,0b0,0b10000000], # :
[0b10000000,0b0,0b0,0b0,0b10000000], # ;
[0b100000,0b1000000,0b10000000,0b1000000,0b100000], # <
[0b0,0b11111000,0b0,0b11111000,0b0], # =
[0b10000000,0b1000000,0b100000,0b1000000,0b10000000], # >
[0b1100000,0b10010000,0b100000,0b0,0b100000], # ?
[0b11111000,0b10001000,0b10111000,0b10000000,0b11111000], # @
[0b11111000,0b10001000,0b10001000,0b11111000,0b10001000], # A
[0b11111000,0b10001000,0b11110000,0b10001000,0b11111000], # B
[0b11111000,0b10000000,0b10000000,0b10000000,0b11111000], # C
[0b11110000,0b10001000,0b10001000,0b10001000,0b11110000], # D
[0b11111000,0b10000000,0b11110000,0b10000000,0b11111000], # E
[0b11111000,0b10000000,0b11110000,0b10000000,0b10000000], # F
[0b11111000,0b10000000,0b10011000,0b10001000,0b11111000], # G
[0b10001000,0b10001000,0b11111000,0b10001000,0b10001000], # H
[0b11111000,0b100000,0b100000,0b100000,0b11111000], # I
[0b11000,0b1000,0b1000,0b10001000,0b11111000], # J
[0b10001000,0b10010000,0b11100000,0b10010000,0b10001000], # K
[0b10000000,0b10000000,0b10000000,0b10000000,0b11111000], # L
[0b10001000,0b11011000,0b10101000,0b10001000,0b10001000], # M
[0b10001000,0b11001000,0b10101000,0b10011000,0b10001000], # N
[0b1110000,0b10001000,0b10001000,0b10001000,0b1110000], # O
[0b11110000,0b10001000,0b11110000,0b10000000,0b10000000], # P
[0b11111000,0b10001000,0b10001000,0b11111000,0b100000], # Q
[0b11110000,0b10001000,0b11110000,0b10001000,0b10001000], # R
[0b11111000,0b10000000,0b11111000,0b1000,0b11111000], # S
[0b11111000,0b100000,0b100000,0b100000,0b100000], # T
[0b10001000,0b10001000,0b10001000,0b10001000,0b11111000], # U
[0b10001000,0b10001000,0b1010000,0b1010000,0b100000], # V
[0b10001000,0b10001000,0b10101000,0b10101000,0b1010000], # W
[0b10001000,0b1010000,0b100000,0b1010000,0b10001000], # X
[0b10001000,0b10001000,0b1010000,0b100000,0b100000], # Y
[0b11111000,0b10000,0b100000,0b1000000,0b11111000], # Z
[0b11000000,0b10000000,0b10000000,0b10000000,0b11000000], # [
[0b10000000,0b10000000,0b1000000,0b100000,0b100000], # "\"
[0b11000000,0b1000000,0b1000000,0b1000000,0b11000000], # ]
[0b0,0b0,0b0,0b0,0b0], # ^
[0b0,0b0,0b0,0b0,0b11111000], # _
[0b0,0b0,0b0,0b0,0b0], # `
[0b11111000,0b10001000,0b10001000,0b11111000,0b10001000], # a
[0b11111000,0b10001000,0b11110000,0b10001000,0b11111000], # b
[0b11111000,0b10000000,0b10000000,0b10000000,0b11111000], # c
[0b11110000,0b10001000,0b10001000,0b10001000,0b11110000], # d
[0b11111000,0b10000000,0b11110000,0b10000000,0b11111000], # e
[0b11111000,0b10000000,0b11110000,0b10000000,0b10000000], # f
[0b11111000,0b10000000,0b10011000,0b10001000,0b11111000], # g
[0b10001000,0b10001000,0b11111000,0b10001000,0b10001000], # h
[0b11111000,0b100000,0b100000,0b100000,0b11111000], # i
[0b11000,0b1000,0b1000,0b10001000,0b11111000], # j
[0b10001000,0b10010000,0b11100000,0b10010000,0b10001000], # k
[0b10000000,0b10000000,0b10000000,0b10000000,0b11111000], # l
[0b10001000,0b11011000,0b10101000,0b10001000,0b10001000], # m
[0b10001000,0b11001000,0b10101000,0b10011000,0b10001000], # n
[0b1110000,0b10001000,0b10001000,0b10001000,0b1110000], # o
[0b11110000,0b10001000,0b11110000,0b10000000,0b10000000], # p
[0b11111000,0b10001000,0b10001000,0b11111000,0b100000], # q
[0b11110000,0b10001000,0b11110000,0b10001000,0b10001000], # r
[0b11111000,0b10000000,0b11111000,0b1000,0b11111000], # s
[0b11111000,0b100000,0b100000,0b100000,0b100000], # t
[0b10001000,0b10001000,0b10001000,0b10001000,0b11111000], # u
[0b10001000,0b10001000,0b1010000,0b1010000,0b100000], # v
[0b10001000,0b10001000,0b10101000,0b10101000,0b1010000], # w
[0b10001000,0b1010000,0b100000,0b1010000,0b10001000], # x
[0b10001000,0b10001000,0b1010000,0b100000,0b100000], # y
[0b11111000,0b10000,0b100000,0b1000000,0b11111000], # z
[0b1100000,0b1000000,0b11000000,0b1000000,0b1100000], # {
[0b10000000,0b10000000,0b0,0b10000000,0b10000000], # |
[0b11000000,0b1000000,0b1100000,0b1000000,0b11000000], # }
[0b0,0b0,0b0,0b0,0b0], # ~
]
# Start of application code
## Init the AS1130
i2c = busio.I2C(board.SCL, board.SDA)
time.sleep(0.5)
led = as1130.AS1130_I2C(i2c)
######################### MAIN LOOP ##############################
titlefile = open("/show_titles.txt", "r")
# Read first title
mode = 2
title = titlefile.readline()
init = False
while True:
# Draw Titles
if mode == 1:
if init == False:
fb = display.FrameBuffer(24*8, 5)
ledfont = display.font(5, 5, font_5x5_data)
fb.clear_buffer()
led.draw_framebuffer(fb, 0)
time.sleep(2)
play_movie(False)
led.set_scrolling(True)
led.play_movie(True)
init = True
fb.clear_buffer()
string_length = fb.draw_string(0, 0, title[:-1], ledfont) # remove CR
title = titlefile.readline()
if title == "":
titlefile.seek(0,0)
title = titlefile.readline()
led.draw_framebuffer(fb, string_length)
time.sleep(5)
else:
if init == False:
fb = display.FrameBuffer(24*1, 5)
fb.clear_buffer()
led.draw_framebuffer(fb, 0)
time.sleep(2)
led.set_scrolling(False)
led.play_movie(False)
# led.play_movie(True)
frame = 0
init = True
frame = (frame + 1) % 8
for x in range(0, 24):
xval = (x / 24) * 2
t = frame * 5
val = math.sin((xval) * 10 + t)
cx = xval + .5 * math.sin(t / 5)
for y in range (0, 5):
cy = y + .5 * math.cos(t / 3)
v = math.sin(10*(xval*math.sin(t / 2) + y*math.cos(t/3) + t))
v = val + v
fb.set_pixel_value(x, y, int((v + 2)/4.0 * 255.0))
led.draw_framebuffer(fb, 0, True)