slitaz-arm view rpi/pileds @ rev 170

Small improvment to pileds
author Christophe Lincoln <pankso@slitaz.org>
date Sun May 04 19:37:40 2014 +0200 (2014-05-04)
parents f3a522138df4
children 6db0c7f6fd10
line source
1 #!/bin/sh
2 #
3 # PiLeds - Let play with leds has 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 ada-clean Clean: Adafruit 7-segment or 8x8 Matrix
19 EOT
20 #8x8 Adafruit 8x8 LED Matrix Backpack example
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 "1" > ${brightness}
47 else
48 echo "0" > ${brightness}
49 fi ;;
51 7-clock)
52 scripts="/usr/share/adafruit/LEDBackpack"
53 load_modules
54 check_packages "python-rpi-adafruit"
55 if [ -f "${scripts}/ex_7segment_clock.py" ]; then
56 python ${scripts}/ex_7segment_clock.py
57 else
58 gettext "Missing:"; echo " ${scripts}/ex_7segment_clock.py"
59 fi ;;
61 8x8)
62 scripts="/usr/share/adafruit/LEDBackpack"
63 #load_modules
64 #check_packages "python-rpi-adafruit"
65 echo "TODO: $scripts" ;;
67 ada-clean)
68 adafruit_clean ;;
70 *) usage ;;
72 esac && exit 0