slitaz-arm view rpi/pileds @ rev 172

Add support for 8x8 leds exampe in pileds
author Christophe Lincoln <pankso@slitaz.org>
date Sun May 04 22:25:37 2014 +0200 (2014-05-04)
parents 6db0c7f6fd10
children 48a8666c6207
line source
1 #!/bin/sh
2 #
3 # PiLeds - Let's play with leds as a kid :-)
4 # (C) 2014 SliTaz GNU/Linux - BSD License
5 #
6 . /lib/libtaz.sh
7 check_root
9 usage() {
10 cat << EOT
12 $(boldify "Usage:") $(basename $0) [command]
14 $(boldify "Commands:")
15 act Turn on/off the on board ACT green led
16 7-clock Adafruit 7-segment LED Backpack clock example
17 8x8 Adafruit 8x8 LED Matrix Backpack example
18 ada-clean Clean: Adafruit 7-segment or 8x8 Matrix
20 EOT
21 }
23 load_modules() {
24 modprobe i2c-bcm2708
25 modprobe i2c-dev
26 }
28 check_packages() {
29 db="/var/lib/tazpkg/installed"
30 for pkg in i2c-tools $@; do
31 [ -f "$db/$pkg/receipt" ] || spk-add ${pkg}
32 done
33 }
35 adafruit_clean() {
36 python /usr/lib/python2.7/Adafruit_LEDBackpack.py
37 }
39 case "$1" in
41 act)
42 brightness="/sys/class/leds/led0/brightness"
43 status="$(cat $brightness)"
44 [ "$quiet" ] || gettext "Current status:"; echo " '$status'"
45 if [ "$status" == 0 ]; then
46 echo "0" > ${brightness}; usleep 50000
47 echo "1" > ${brightness}
48 else
49 echo "0" > ${brightness}
50 fi ;;
52 7-clock)
53 scripts="/usr/share/adafruit/LEDBackpack"
54 load_modules
55 check_packages "python-rpi-adafruit"
56 if [ -f "${scripts}/ex_7segment_clock.py" ]; then
57 python ${scripts}/ex_7segment_clock.py
58 else
59 gettext "Missing:"; echo " ${scripts}/ex_7segment_clock.py"
60 fi ;;
62 8x8)
63 scripts="/usr/share/adafruit/LEDBackpack"
64 load_modules
65 check_packages "python-rpi-adafruit"
66 if [ -f "${scripts}/ex_7segment_clock.py" ]; then
67 python ${scripts}/ex_8x8_pixels.py
68 else
69 gettext "Missing:"; echo " ${scripts}/ex_8x8_pixels.py"
70 fi ;;
72 ada-clean)
73 adafruit_clean ;;
75 *) usage ;;
77 esac && exit 0