forked from adammhaile/RPi-LPD8806
-
Notifications
You must be signed in to change notification settings - Fork 3
/
bootstrap.py
47 lines (36 loc) · 1.14 KB
/
bootstrap.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
#!/usr/bin/python
"""
use "from bootstrap import *" from any script to do all the standard setup
and checks needed by any script
"""
from raspledstrip.ledstrip import *
from raspledstrip.LPD8806 import LPD8806Native
import os.path
import sys
# Check that the system is set up like we want it
dev = '/dev/spidev0.0'
if not os.path.exists(dev):
sys.stderr.write("""
The SPI device /dev/spidev0.0 does not exist. You may need to load
the appropriate kernel modules. Try:
sudo modprobe spi_bcm2708 ; sudo modprobe spidev
You may also need to unblacklist the spi_bcm2708 module in
/etc/modprobe.d/raspi-blacklist.conf
""")
sys.exit(2)
#permissions check
try:
open(dev)
except IOError as e:
if e.errno == 13:
sys.stderr.write("""
It looks like SPI device /dev/spidev0.0 has the wrong permissions.
Try making it world writable:
sudo chmod a+rw /dev/spidev0.0
""")
sys.exit(2)
led_count = 36
led = LEDStrip(LPD8806Native(led_count, dev))
#led.setChannelOrder(ChannelOrder.BRG) #Only use this if your strip does not use the GRB order
#led.setMasterBrightness(0.5) #use this to set the overall max brightness of the strip
led.all_off()