-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
38 lines (32 loc) · 860 Bytes
/
test.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
import math
import os
import time
import sys
# don't import the local raveberry_visualization folder
del sys.path[0]
import raveberry_visualization
BARS = 256
controller = raveberry_visualization.Controller()
controller.start("Circle", 30, 400, 20)
time_elapsed = 0
last_loop = time.time()
try:
while True:
if not controller.is_active():
break
current_frame = [
0.8
* 0.5
* (1 + math.sin(4 * time_elapsed))
* 0.5
* (1 + math.sin(-4 * time_elapsed + 0.2 * i * 200))
for i in range(BARS)
]
alarm_factor = -1
controller.set_parameters(alarm_factor, current_frame)
now = time.time()
time_elapsed += now - last_loop
last_loop = now
time.sleep(1 / 30)
except KeyboardInterrupt:
controller.stop()