-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathledborg.py
More file actions
48 lines (40 loc) · 999 Bytes
/
ledborg.py
File metadata and controls
48 lines (40 loc) · 999 Bytes
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
#!/usr/bin/env python
#
# ledborg.py - ledborg module for PiPurr-Server
#
#
# Contains code from piborg.org
#
# Tris Linnell
# http://canthack.org
import time
import wiringpi2 as wiringpi
wiringpi.wiringPiSetup()
# Set up pins
PIN_RED = 0
PIN_GREEN = 2
PIN_BLUE = 3
LED_MAX = 100
wiringpi.softPwmCreate(PIN_RED, 0, LED_MAX)
wiringpi.softPwmCreate(PIN_GREEN, 0, LED_MAX)
wiringpi.softPwmCreate(PIN_BLUE, 0, LED_MAX)
wiringpi.softPwmWrite(PIN_RED, 0)
wiringpi.softPwmWrite(PIN_GREEN, 0)
wiringpi.softPwmWrite(PIN_BLUE, 0)
# LedBorg colours.
RED = (1,0,0)
YELLOW = (1,1,0)
GREEN = (0,1,0)
BLUE = (0,0,1)
MAGENTA = (1,0,1)
OFF = (0,0,0)
WHITE = (1,1,1)
#For LedBorg lights
def setColour(colour):
wiringpi.softPwmWrite(PIN_RED, int(colour[0] * LED_MAX))
wiringpi.softPwmWrite(PIN_GREEN, int(colour[1] * LED_MAX))
wiringpi.softPwmWrite(PIN_BLUE, int(colour[2] * LED_MAX))
def flashColour(colour):
setColour(colour)
time.sleep(0.5)
setColour(OFF)