-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
27 lines (20 loc) · 1.03 KB
/
main.py
File metadata and controls
27 lines (20 loc) · 1.03 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
import argparse
import time
from led import LEDStrip
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--color', help="Set color (RGB), e.g. 100,50,100")
parser.add_argument('--shift-start', help="Shift from color (RGB), e.g. 100,50,100")
parser.add_argument('--shift-end', help="Shift to color (RGB), e.g. 140,250,30")
parser.add_argument('--shift-cont', action='store_true', help="Continuous shifting, otherwise shift once", default=False)
parser.add_argument('--shift-period', help="Shifting period (seconds)", default=1)
args = parser.parse_args()
if args.shift_start and args.shift_end:
start_color = [int(c) for c in args.shift_start.rstrip().split(',')]
end_color = [int(c) for c in args.shift_end.rstrip().split(',')]
led_strip = LEDStrip(*start_color)
led_strip.shift(start_color, end_color, int(args.shift_period), args.shift_cont)
elif args.color:
color = [int(c) for c in args.color.split(',')]
led_strip = LEDStrip(*color)
main()