forked from KLRTN/lights
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
132 lines (121 loc) · 4.02 KB
/
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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
def on_button_pressed_a():
global hour
if hour < 23:
hour += 1
else:
hour = 0
input.on_button_pressed(Button.A, on_button_pressed_a)
def on_button_pressed_b():
global minute
if minute < 59:
minute += 1
else:
minute = 0
input.on_button_pressed(Button.B, on_button_pressed_b)
def on_gesture_shake():
basic.show_string(time)
input.on_gesture(Gesture.SHAKE, on_gesture_shake)
hour = 0
minute = 0
time = ""
time = timeanddate.time(timeanddate.TimeFormat.HHMM2_4HR)
adjust = 0
minute = 0
hour = 0
strip = neopixel.create(DigitalPin.P0, 24, NeoPixelMode.RGB_RGB)
def on_forever():
global minute, hour
basic.pause(60000)
if minute < 59:
minute += 1
else:
minute = 0
if hour < 23:
hour += 1
else:
hour = 0
basic.forever(on_forever)
def on_forever2():
if time == "00:00":
strip.show_color(neopixel.colors(NeoPixelColors.RED))
if time == "8:56":
strip.show_color(neopixel.colors(NeoPixelColors.GREEN))
if time == "8:57":
strip.show_color(neopixel.colors(NeoPixelColors.YELLOW))
if time == "8:58":
strip.show_color(neopixel.colors(NeoPixelColors.ORANGE))
if time == "8:59":
strip.show_color(neopixel.colors(NeoPixelColors.RED))
basic.forever(on_forever2)
def on_forever3():
if time == "10:25":
strip.show_color(neopixel.colors(NeoPixelColors.BLUE))
if time == "10:26":
strip.show_color(neopixel.colors(NeoPixelColors.GREEN))
if time == "10:27":
strip.show_color(neopixel.colors(NeoPixelColors.YELLOW))
if time == "10:28":
strip.show_color(neopixel.colors(NeoPixelColors.ORANGE))
if time == "10:29":
strip.show_color(neopixel.colors(NeoPixelColors.RED))
basic.forever(on_forever3)
def on_forever4():
if time == "11:55":
strip.show_color(neopixel.colors(NeoPixelColors.BLUE))
if time == "11:56":
strip.show_color(neopixel.colors(NeoPixelColors.GREEN))
if time == "11:57":
strip.show_color(neopixel.colors(NeoPixelColors.YELLOW))
if time == "11:58":
strip.show_color(neopixel.colors(NeoPixelColors.ORANGE))
if time == "11:59":
strip.show_color(neopixel.colors(NeoPixelColors.RED))
basic.forever(on_forever4)
def on_forever5():
if time == "12:30":
strip.show_color(neopixel.colors(NeoPixelColors.BLUE))
if time == "12:31":
strip.show_color(neopixel.colors(NeoPixelColors.GREEN))
if time == "12:32":
strip.show_color(neopixel.colors(NeoPixelColors.YELLOW))
if time == "12:33":
strip.show_color(neopixel.colors(NeoPixelColors.ORANGE))
if time == "12:34":
strip.show_color(neopixel.colors(NeoPixelColors.RED))
basic.forever(on_forever5)
def on_forever6():
if time == "13:00":
strip.show_color(neopixel.colors(NeoPixelColors.BLUE))
if time == "13:01":
strip.show_color(neopixel.colors(NeoPixelColors.GREEN))
if time == "13:02":
strip.show_color(neopixel.colors(NeoPixelColors.YELLOW))
if time == "13:03":
strip.show_color(neopixel.colors(NeoPixelColors.ORANGE))
if time == "13:04":
strip.show_color(neopixel.colors(NeoPixelColors.RED))
basic.forever(on_forever6)
def on_forever7():
if time == "14:30":
strip.show_color(neopixel.colors(NeoPixelColors.BLUE))
if time == "14:31":
strip.show_color(neopixel.colors(NeoPixelColors.GREEN))
if time == "14:32":
strip.show_color(neopixel.colors(NeoPixelColors.YELLOW))
if time == "14:33":
strip.show_color(neopixel.colors(NeoPixelColors.ORANGE))
if time == "14:34":
strip.show_color(neopixel.colors(NeoPixelColors.RED))
basic.forever(on_forever7)
def on_forever8():
if time >= "16:00":
strip.show_rainbow(1, 360)
if time == "14:31":
strip.show_rainbow(1, 360)
if time == "14:32":
strip.show_rainbow(1, 360)
if time == "14:33":
strip.show_rainbow(1, 360)
if time == "14:34":
strip.show_rainbow(1, 360)
basic.forever(on_forever8)