-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlights.py
More file actions
58 lines (44 loc) · 1.69 KB
/
lights.py
File metadata and controls
58 lines (44 loc) · 1.69 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
import board
import neopixel
class RGB:
def __init__(self, red, green, blue):
self.red = red
self.green = green
self.blue = blue
def setRed(self, red):
self.red = red
def setGreen(self, green):
self.green = green
def setBlue(self, blue):
self.blue = blue
def getRed(self):
return self.red
def getGreen(self):
return self.green
def getBlue(self):
return self.blue
class Lights:
def __init__(self, color, brightness):
self.numPixels = 12 #Number of neopixels in the array.
self.color = color #Color of the Pixels. Accepts an RGB value. So 255, 0, 0 for red.
self.brightness = brightness #Brightness of the pixels. Max brightness is 3, Min is 0
self.pixelPin = board.D18
self.pixelOrder = neopixel.RGB
self.pixels = neopixel.NeoPixel(self.pixelPin, self.numPixels)
self.pixels.brightness = self.brightness
self.pixels.fill((self.color.getRed(), self.color.getGreen(), self.color.getBlue()))
#Public functions. Setters to interface with the UI to set new values.
def setColor(self, color):
self.color = color
self.pixels.fill((self.color.getRed(), self.color.getGreen(), self.color.getBlue()))
def setRGB(self, red, green, blue):
self.red = red
self.green = green
self.blue = blue
self.pixels.fil(red, green, blue)
def setBrightness(self, newBrightness):
self.brightness = newBrightness
self.pixels.brightness = self.brightness
#Public functions. Getters to get values for current values of the pixels.
def getBrightness(self):
return self.brightness