-
Notifications
You must be signed in to change notification settings - Fork 8
/
example.py
executable file
·65 lines (50 loc) · 2.01 KB
/
example.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
import time
from pybusylight import pybusylight
try:
print('Connect to the Busylight...')
bl=pybusylight.busylight()
except ValueError:
print('\nBusylight not found, is it connected?...')
exit(1)
print('\nSend the default color (white) for 5 seconds.')
bl.send()
time.sleep(5)
print('\nTurn Off All elements of the busylight (both light and sound) for 2 seconds.')
bl.turn_off()
time.sleep(2)
print('\nSet the light to a color (GREEN) via RGB (0,255,0).')
bl.set_rgb((0,255,0))
bl.send()
time.sleep(5)
print('\nSet the light to a named color "salmon".')
bl.set_color('salmon')
bl.send()
time.sleep(5)
print('List out all the available named colors...')
time.sleep(3)
print(bl.available_colors())
rgb_value=bl.get_rgb()
print('\nGet the RGB value for the color that is currently set --> R:%s,G:%s,B:%s'%(rgb_value[0],rgb_value[1],rgb_value[2]))
print('\nBlink the light 10 times with whatever color value is currently set using the default interval of 0.5 seconds.')
bl.blink(count=10)
print('\nBlink the light with and RGB color (255,0,0) 5 times waiting half a second between blinks.')
bl.blink(rgb=(255,0,0),interval=0.5,count=5)
print('\nBlink the light with a named color (orange) 10 times waiting 1/20th of a second between blinks')
bl.blink(color='orange',interval=0.05,count=5)
print('\nPulse the light 5 times with the current color. Each pulse cycle is about ~0.78 seconds.')
bl.pulse(count=5)
print('\nPulse the light 5 times with a named color (goldenrod).')
bl.pulse(count=5,color='goldenrod')
print('\nPulse the light 5 times with an RGB color (0,0,255).')
bl.pulse(count=5,rgb=(0,0,255))
print('\nPlaying each of the supported sounds for 5 seconds...')
for sound in pybusylight.sounds:
print('\n playing the "%s" at volume level 2 of 7'%sound)
bl.set_sound(sound=pybusylight.sounds[sound],volume=2)
bl.send()
time.sleep(5)
bl.turn_off()
print('\nSetting a named color "slateblue" letting the color time-out automatically (after 30 seconds).')
bl.set_color('slateblue')
bl.send()
exit(0)