-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcli_main.py
executable file
·53 lines (41 loc) · 1.24 KB
/
cli_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
import logging.config
import yaml
logging.config.dictConfig(yaml.load(open('logging_dev.yml', 'r')))
import time
from power import FixPowerSupply
from leds import LEDThread
logger = logging.getLogger(__name__)
logger.info('Starting ...')
led_thread = LEDThread(9)
power = FixPowerSupply(led_thread)
power.on()
time.sleep(1)
led_thread.start()
while led_thread.is_running():
try:
print '(d) darken'
print '(l) lighten'
print '(c) change color '
print '(C) change color back'
print '(<i>) change mode'
value = raw_input('Please choose: ')
try:
print " got " + value
mode = int(value)
led_thread.set_mode(mode)
except ValueError:
if(value == 'd'):
led_thread.light_down()
elif(value == 'l'):
led_thread.light_up()
elif(value == 'c'):
led_thread.next_color()
elif(value == 'C'):
led_thread.prev_color()
else:
print "'" + value + "' is not recognized"
except KeyboardInterrupt:
logger.info('Shutting all down ...')
led_thread.set_mode(1)
led_thread.shutdown()
led_thread.join()