This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lights.py
87 lines (73 loc) · 2.12 KB
/
lights.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
from machine import Pin
from apa102 import APA102
import time
class Lights:
counter = None
apa = None
def __init__(self):
clock = Pin(12, Pin.OUT) # Green
data = Pin(13, Pin.OUT) # Yellow
self.apa = APA102(clock, data, 56)
self.counter = 0
def set_low_load(self):
'''
define color for green-light
'''
self.set_bottom_color((255, 255, 255, 31))
self.set_middle_color((0, 0, 0, 0))
self.set_top_color((0, 0, 0, 0))
self.write_pixels()
def set_middle_load(self):
'''
define color for mid-red-light
'''
self.set_bottom_color((0, 0, 0, 0))
self.set_middle_color((255, 255, 255, 31))
self.set_top_color((0, 0, 0, 0))
self.write_pixels()
def set_high_load(self):
'''
define color for top-red-light
'''
self.set_bottom_color((0, 0, 0, 0))
self.set_middle_color((0, 0, 0, 0))
self.set_top_color((255, 255, 255, 31))
self.write_pixels()
def set_chaos_load(self):
self.set_bottom_color((0, 0, 0, 0))
self.set_middle_color((0, 0, 0, 0))
for i in range(620):
self.counter = i%31
self.set_top_color((255, 255, 255, self.counter))
self.write_pixels()
def write_pixels(self):
'''
write pixels^^
'''
self.apa.write()
def set_all_color(self, color):
'''
sets the color for all Lights
'''
self.set_bottom_color(color)
self.set_middle_color(color)
self.set_top_color(color)
self.write_pixels()
def set_bottom_color(self, color):
'''
sets the green-light
'''
for i in range(0, 19):
self.apa[i] = color
def set_middle_color(self, color):
'''
sets the mid-red-light
'''
for i in range(19, 37):
self.apa[i] = color
def set_top_color(self, color):
'''
sets the top-red-light
'''
for i in range(37, 56):
self.apa[i] = color