-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtests.py
62 lines (45 loc) · 1.58 KB
/
tests.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
import time
import math
import ForthBBProtocol as bb
def led_test(badge, count=100):
strengths = list(range(0, 255, 5))
colors = ['redled', 'greenled', 'blueled']
for i in range(0, count):
for c in colors:
for b in strengths:
badge.forth_run(b, c)
strengths.reverse()
def led_test2(badge, count=100):
strengths = list(range(0, 255, 5))
colors = ['red', 'green', 'blue']
for i in range(0, count):
for c in colors:
for b in strengths:
badge.led(**{c:b})
strengths.reverse()
def draw_sin_test(badge, num_points=50, step_size=0.1):
x_vals = [i for i in range(0, num_points)]
y_vals = [math.ceil(10 + 10*math.sin(x*step_size)) for x in x_vals]
for x, y in zip(x_vals, y_vals):
#print("(%f, %f)" % (x, y))
badge.set_cursor(x, y)
badge.draw_rect(3, 3, filled=True)
time.sleep(0.01)
badge.swap_buffer()
def mon_sliders(badge, num_points=50):
for i in range(num_points):
vert_pos = badge.get_vertical_slider_pos()
print("Vert Pos: %s" % str(vert_pos))
badge = bb.ForthBadge()
#badge.set_draw_color('green')
#led_test2(badge, count=2)
#draw_sin_test(badge)
#badge.set_cursor(10, 10).draw_char('t')
#badge.set_cursor(25, 10).draw_char('e')
#badge.set_cursor(40, 10).draw_char('s')
#badge.set_cursor(55, 10).draw_char('t').swap_buffer()
badge.set_cursor(10, 10).draw_rect(10,12)
badge.set_cursor(25, 10).draw_rect(10,12)
badge.set_cursor(40, 10).draw_rect(10,12)
badge.set_cursor(55, 10).draw_rect(10,12).push_buffer()
mon_sliders(badge)