-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblinkers.py
47 lines (38 loc) · 1.71 KB
/
blinkers.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
from uasyncio import sleep_ms
async def blink(badge, cycles=10, c1="red", c2="red", c3="red", msg="Connection error..."):
"""Used to blink error codes while waiting for issue to resolve"""
for second in range(0, cycles):
badge.set_pixels(c1, c2, c3, write=True, lock_override=True)
await sleep_ms(300)
badge.set_pixels("off", "off", "off", write=True, lock_override=True)
await sleep_ms(700)
if second == 0 or second % 5 == 0:
print(msg)
async def blink_off(badge, cycles=1, c1="teal", c2="teal", c3="teal"):
badge.set_lock_updates()
for second in range(0, cycles):
badge.set_pixels("off", "off", "off", write=True, lock_override=True)
await sleep_ms(300)
badge.set_pixels(c1, c2, c3, write=True, lock_override=True)
await sleep_ms(300)
badge.set_lock_updates(lock=False)
async def half_blink(badge, cycles=10, c1="red", c2="red", c3="red", msg="Connection error..."):
"""Used to blink error codes while waiting for issue to resolve"""
for second in range(0, cycles):
badge.set_pixels(c1, c2, c3, write=True, lock_override=True)
await sleep_ms(150)
badge.set_pixels("off", "off", "off", write=True, lock_override=True)
await sleep_ms(350)
if second == 0 or second % 5 == 0:
print(msg)
async def strobe(badge, cycles=50):
"""WARNING BRIGHT FLASHING LIGHTS. you have been warned."""
WHITE = (255, 255, 255)
OFF = (0, 0, 0)
for second in range(0, cycles):
badge.secret_write(WHITE, WHITE, WHITE)
await sleep_ms(50)
badge.secret_write(OFF, OFF, OFF)
await sleep_ms(100)
if second % 10 == 0:
print("blinking..")