slitaz-arm view rpi/cgi-adm/plugins/rpi_config/rpi_config.cgi @ rev 143

Add basic I2C support in CGI/adm interface
author Christophe Lincoln <pankso@slitaz.org>
date Mon Apr 28 22:02:06 2014 +0200 (2014-04-28)
parents 71b3777ac5f1
children 48a8666c6207
line source
1 #!/bin/sh
2 #
3 # TazBerry CGI Plugin - Raspberry Pi configuration
4 #
6 case " $(GET) " in
7 *\ audio\ *)
8 html_header "Audio Control"
9 case " $(GET audio) " in
10 *\ auto\ *|*\ analog\ *|*\ hdmi\ *)
11 amixer -q cset numid=3 $(GET cset) ;;
12 *\ vol\ *)
13 amixer -q cset numid=1 "$(GET cset)%" ;;
14 *\ mute\ *)
15 amixer -q cset numid=1 mute ;;
16 *\ play\ *)
17 notify "Playing MP3 system sound..."
18 mpg123 /usr/share/sounds/ready.mp3 2>/dev/null
19 notify hide ;;
20 esac
21 cat << EOT
22 <h1>Audio Mixer</h1>
23 <div class="button">
24 <a href="$script?audio=play">Play sound</a>
25 <a href="$script?audio=mute">Mute</a>
26 <a href="$script?audio=vol&amp;cset=100">Vol 100%</a>
27 <a href="$script?audio=vol&amp;cset=75">Vol 75%</a>
28 </div>
29 <pre>
30 $(amixer)
31 </pre>
33 <h2>Audio Output</h2>
34 <p>
35 The Raspberry Pi has two audio output modes: HDMI and headphone jack.
36 You can switch between these modes at any time.
37 </p>
38 <div class="button">
39 <a href="$script?audio=auto&amp;cset=0">Auto</a>
40 <a href="$script?audio=analog&amp;cset=1">Headphone</a>
41 <a href="$script?audio=hdmi&amp;cset=2">HDMI</a>
42 </div>
44 <h2>Controls</h2>
45 <pre>
46 $(amixer controls)
47 </pre>
49 <h2>Contents</h2>
50 <pre>
51 $(amixer contents)
52 </pre>
54 EOT
55 html_footer && exit 0 ;;
57 *\ leds\ *)
58 trigger="/sys/class/leds/led0/trigger"
59 brightness="/sys/class/leds/led0/brightness"
60 html_header "Leds"
61 case " $(GET leds) " in
62 *\ act_test\ *)
63 notify "ACT Led turned on for 5 sec..."
64 echo "1" > ${brightness}
65 sleep 5
66 echo "0" > ${brightness}
67 notify hide ;;
68 *\ act_on\ *)
69 echo "0" > ${brightness}; usleep 50000
70 echo "1" > ${brightness} ;;
71 *\ act_off\ *)
72 echo "0" > ${brightness} ;;
73 esac
74 cat << EOT
75 <h1>Leds</h1>
76 <pre>
77 Trigger : $(cat $trigger)
78 Brightness : $(cat $brightness)
79 </pre>
80 <div class="button">
81 <a href="$script?leds=act_test">ACT Led test</a>
82 <a href="$script?leds=act_on">ACT Led on</a>
83 <a href="$script?leds=act_off">ACT Led off</a>
84 </div>
85 EOT
86 html_footer && exit 0 ;;
88 *\ i2c\ *)
89 html_header "I2C Bus"
90 modprobe -q i2c-bcm2708
91 modprobe -q i2c-dev
92 echo '<h1>Raspberry Pi I2C Bus</h1>'
93 if [ ! -x "/usr/sbin/i2cdetect" ]; then
94 echo "<div id='error'>Missing package: i2c-tools</div>"
95 html_footer && exit 0
96 fi
97 cat << EOT
98 <p>
99 I2C kernel modules: i2c-bcm2708 + i2c-dev
100 </p>
102 <h2>I2C Detect</h2>
103 <pre>
104 $(i2cdetect -y 1)
105 </pre>
106 EOT
107 html_footer && exit 0 ;;
109 *\ oclock\ *)
110 html_header "Overclocking"
111 cat << EOT
112 <h1>RPi Overclocking</h1>
114 <pre>
115 $(tazberry rpi_oclock)
116 </pre>
118 <h2>Current settings:</h2>
119 <pre>
120 $(fgrep _freq /boot/config.txt)
121 $(fgrep over_voltage /boot/config.txt)
122 </pre>
123 <div class="button">
124 <a href='$script?editor&amp;file=/boot/config.txt&amp;from=?rpi_config'>Edit boot configuration</a>
125 <div>
126 EOT
127 html_footer && exit 0 ;;
129 *\ rpi_config\ *)
130 blacklist="/etc/modprobe.d/rpi-blacklist.conf"
131 html_header "Raspberry Pi"
132 cat << EOT
133 <h1>SliTaz Raspberry Pi</h1>
135 <p>
136 Remotely configure your SliTaz Raspberry Pi device.
137 </p>
139 <div id="actions">
140 <form method="get" action="$script">
141 <input type="submit" name="audio" value="Audio control" />
142 <input type="submit" name="oclock" value="Overclocking" />
143 <input type="submit" name="leds" value="Leds" />
144 <input type="submit" name="i2c" value="I2C Bus" />
145 </form>
146 </div>
148 <h2>Kernel boot parameters</h2>
149 <p>
150 This file provides the Linux Kernel boot time parameters and SliTaz
151 boot time options.
152 </p>
153 <pre>
154 $(cat /boot/cmdline.txt 2>/dev/null)
155 </pre>
156 <div class="button">
157 <a href="$script?editor&amp;file=/boot/cmdline.txt&amp;from=?rpi_config">Edit cmdline.txt</a>
158 </div>
160 <h2>Boot configuration file</h2>
161 <p>
162 The Raspberry Pi boot time configuration file
163 </p>
164 <pre>
165 $(cat /boot/config.txt 2>/dev/null)
166 </pre>
167 <div class="button">
168 <a href="$script?editor&amp;file=/boot/config.txt&amp;from=?rpi_config">Edit config.txt</a>
169 </div>
171 <h2>Blacklisted Kernel modules</h2>
172 <p>
173 List of the Linux Kernel modules that should not be loaded on boot
174 time to save resources and speed up your Raspberry Pi.
175 </p>
176 <pre>
177 $(cat $blacklist 2>/dev/null)
178 </pre>
179 <div class="button">
180 <a href="$script?editor&amp;file=$blacklist&amp;from=?rpi_config">Edit $(basename $blacklist)</a>
181 </div>
182 EOT
184 html_footer && exit 0 ;;
185 esac