-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommandline.py
More file actions
84 lines (71 loc) · 2.32 KB
/
Copy pathcommandline.py
File metadata and controls
84 lines (71 loc) · 2.32 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import raspberryfun
import cmd
class CommandLine(cmd.Cmd):
""" Class for ease the use of raspberryfun classes """
intro = "RaspberryFun commandline"
prompt = '# '
ruler = '-'
def do_lights(self, line):
"""Commands for Lights class"""
LightsCommand().cmdloop()
def do_exit(self, line):
""" Exit cmd """
return True
def do_EOF(self, line):
return True
class SubCommand(cmd.Cmd):
""" Base class for raspberryfun class commands"""
def do_exit(self, line):
""" Exit cmd """
return True
def do_EOF(self, line):
return True
class LightsCommand(SubCommand):
""" Class for raspberryfun Lights commands """
prompt = "lights# "
def do_all(self, line):
""" LightUpAll """
with raspberryfun.Lights() as program:
print("Press CTRL+C to stop")
program.LightUpAll()
def do_basic(self, line):
"""
Basic one direction running light
time -- timestep between leds [sec]
"""
with raspberryfun.Lights() as program:
if time == "":
time = 1.0
else:
try:
time = float(line)
except:
print("Invalid value, using default")
time = 1.0
print("Press CTRL+C to stop")
program.BasicRunningLight(time)
def do_twoway(self, line):
"""
Two way running light
time -- timestep between leds [sec]
tail -- how much led should be lit
"""
args = line.split()
if len(args) != 2:
print("Invalid number of arguments should be two: time tail")
with raspberryfun.Lights() as program:
try:
time = float(args[0])
except:
print("Invalid value, using default")
time = 1.0
try:
tail = int(args[1])
except:
print("Invalid value, using default")
tail = 2
print("Press CTRL+C to stop")
program.BasicTwoWayRunningLight(time,tail)
def do_music(self, line):
with raspberryfun.Lights() as program:
program.music(line)