slitaz-arm rev 135
rpi: add Audio support in CGI admin interface
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat Apr 26 10:41:23 2014 +0200 (2014-04-26) |
parents | 4ca086909ca8 |
children | 32e4a7121e8f |
files | cgi-adm/data/style.css cgi-adm/tools.cgi rpi/cgi-adm/data/header.html rpi/cgi-adm/plugins/rpi_config/rpi_config.cgi rpi/rootfs/usr/share/sounds/ready.mp3 |
line diff
1.1 --- a/cgi-adm/data/style.css Sat Apr 26 04:03:04 2014 +0200 1.2 +++ b/cgi-adm/data/style.css Sat Apr 26 10:41:23 2014 +0200 1.3 @@ -8,8 +8,8 @@ 1.4 a:hover { text-decoration: none; } 1.5 li { list-style-type: square; color: #4d4d4d; } 1.6 pre, textarea { 1.7 - font-size: 100%; 1.8 - background: #eee; 1.9 + font-size: 110%; 1.10 + background: #ddd; 1.11 padding: 10px; 1.12 overflow: hidden; 1.13 } 1.14 @@ -42,7 +42,10 @@ 1.15 /* Content */ 1.16 1.17 #content { margin: 4%; text-align: justify; } 1.18 -.button a { text-decoration: none; } 1.19 +#notify { padding: 10px; background-color: #ddd; border: 1px solid #00A500; } 1.20 +.button { margin: 25px 0; } .button a { text-decoration: none; } 1.21 +.center { text-align: center; } 1.22 + 1.23 input[type="submit"], select, .button a { 1.24 color: #444444; 1.25 border: 1px solid #afafaf; 1.26 @@ -72,7 +75,8 @@ 1.27 border: 1px solid #999; 1.28 } 1.29 1.30 -pre, input[type="submit"], input[type="text"], textarea, .button a { 1.31 +pre, input[type="submit"], input[type="text"], textarea, .button a, 1.32 +#notify, img { 1.33 border-radius: 4px; 1.34 } 1.35
2.1 --- a/cgi-adm/tools.cgi Sat Apr 26 04:03:04 2014 +0200 2.2 +++ b/cgi-adm/tools.cgi Sat Apr 26 10:41:23 2014 +0200 2.3 @@ -37,6 +37,15 @@ 2.4 EOT 2.5 } 2.6 2.7 +# Usage: notify [hide|"Message..."] 2.8 +notify() { 2.9 + if [ "$1" == "hide" ]; then 2.10 + echo "<style type='text/css'>#notify { display: none !important; }</style>" 2.11 + else 2.12 + echo "<div id='notify'>$@</div>" 2.13 + fi 2.14 +} 2.15 + 2.16 list_plugins() { 2.17 for p in $(ls -1 $plugins) 2.18 do
3.1 --- a/rpi/cgi-adm/data/header.html Sat Apr 26 04:03:04 2014 +0200 3.2 +++ b/rpi/cgi-adm/data/header.html Sat Apr 26 10:41:23 2014 +0200 3.3 @@ -14,6 +14,7 @@ 3.4 <a href="tools.cgi?plugins">Plugins</a> 3.5 <a href="tools.cgi?status">Status</a> 3.6 <a href="tools.cgi?rpi_config">Config</a> 3.7 + <a href="tools.cgi?audio">Audio</a> 3.8 <a href="tools.cgi?rpi_gpio">GPIO</a> 3.9 </nav> 3.10 </header>
4.1 --- a/rpi/cgi-adm/plugins/rpi_config/rpi_config.cgi Sat Apr 26 04:03:04 2014 +0200 4.2 +++ b/rpi/cgi-adm/plugins/rpi_config/rpi_config.cgi Sat Apr 26 10:41:23 2014 +0200 4.3 @@ -4,16 +4,69 @@ 4.4 # 4.5 4.6 case " $(GET) " in 4.7 + *\ audio\ *) 4.8 + html_header "Audio Mixer" 4.9 + case " $(GET audio) " in 4.10 + *\ auto\ *|*\ analog\ *|*\ hdmi\ *) 4.11 + amixer -q cset numid=3 $(GET cset) ;; 4.12 + *\ vol\ *) 4.13 + amixer -q cset numid=1 "$(GET cset)%" ;; 4.14 + *\ mute\ *) 4.15 + amixer -q cset numid=1 mute ;; 4.16 + *\ play\ *) 4.17 + notify "Playing MP3 system sound..." 4.18 + mpg123 /usr/share/sounds/ready.mp3 2>/dev/null 4.19 + notify hide ;; 4.20 + esac 4.21 + cat << EOT 4.22 +<h1>Audio Mixer</h1> 4.23 +<div class="button"> 4.24 + <a href="$script?audio=play">Play sound</a> 4.25 + <a href="$script?audio=mute">Mute</a> 4.26 + <a href="$script?audio=vol&cset=100">Vol 100%</a> 4.27 + <a href="$script?audio=vol&cset=50">Vol 50%</a> 4.28 +</div> 4.29 +<pre> 4.30 +$(amixer) 4.31 +</pre> 4.32 + 4.33 +<h2>Audio Output</h2> 4.34 +<p> 4.35 + The Raspberry Pi has two audio output modes: HDMI and headphone jack. 4.36 + You can switch between these modes at any time. 4.37 +</p> 4.38 +<div class="button"> 4.39 + <a href="$script?audio=auto&cset=0">Auto</a> 4.40 + <a href="$script?audio=analog&cset=1">Headphone</a> 4.41 + <a href="$script?audio=hdmi&cset=2">HDMI</a> 4.42 +</div> 4.43 + 4.44 +<h2>Controls</h2> 4.45 +<pre> 4.46 +$(amixer controls) 4.47 +</pre> 4.48 + 4.49 +<h2>Contents</h2> 4.50 +<pre> 4.51 +$(amixer contents) 4.52 +</pre> 4.53 + 4.54 +EOT 4.55 + html_footer && exit 0 ;; 4.56 4.57 *\ leds\ *) 4.58 trigger="/sys/class/leds/led0/trigger" 4.59 brightness="/sys/class/leds/led0/brightness" 4.60 html_header "Leds" 4.61 case " $(GET leds) " in 4.62 - *\ act_test\ *) 4.63 - (echo "1" > ${brightness} 4.64 - sleep 3; echo "0" > ${brightness}) & ;; 4.65 - *\ act_on\ *) 4.66 + *\ act_test\ *) 4.67 + notify "ACT Led should be on..." 4.68 + echo "1" > ${brightness} 4.69 + sleep 4 4.70 + echo "0" > ${brightness} 4.71 + notify hide ;; 4.72 + *\ act_on\ *) 4.73 + echo "0" > ${brightness}; usleep 50000 4.74 echo "1" > ${brightness} ;; 4.75 *\ act_off\ *) 4.76 echo "0" > ${brightness} ;; 4.77 @@ -25,7 +78,7 @@ 4.78 Brightness : $(cat $brightness) 4.79 </pre> 4.80 <div class="button"> 4.81 - <a href="$script?leds=act_on">ACT Test</a> 4.82 + <a href="$script?leds=act_test">ACT Test</a> 4.83 <a href="$script?leds=act_on">ACT On</a> 4.84 <a href="$script?leds=act_off">ACT Off</a> 4.85 </div> 4.86 @@ -48,7 +101,7 @@ 4.87 <h1>RPi Overclocking</h1> 4.88 4.89 <pre> 4.90 -$(/home/pankso/Projects/slitaz-arm/rpi/tazberry rpi_oclock) 4.91 +$(tazberry rpi_oclock) 4.92 </pre> 4.93 4.94 <h2>Current settings:</h2> 4.95 @@ -57,7 +110,7 @@ 4.96 $(fgrep over_voltage /boot/config.txt) 4.97 </pre> 4.98 <div class="button"> 4.99 - <a href='$script?editor&file=/boot/config.txt'>Edit boot configuration</a> 4.100 + <a href='$script?editor&file=/boot/config.txt&from=?rpi_config'>Edit boot configuration</a> 4.101 <div> 4.102 EOT 4.103 html_footer && exit 0 ;; 4.104 @@ -75,6 +128,7 @@ 4.105 <div id="actions"> 4.106 <form method="get" action="$script"> 4.107 <input type="submit" name="rdate" value="Set system time" /> 4.108 + <input type="submit" name="audio" value="Audio mixer" /> 4.109 <input type="submit" name="oclock" value="Overclocking" /> 4.110 <input type="submit" name="leds" value="Leds" /> 4.111 </form> 4.112 @@ -89,7 +143,7 @@ 4.113 $(cat /boot/cmdline.txt 2>/dev/null) 4.114 </pre> 4.115 <div class="button"> 4.116 - <a href="$script?editor&file=/boot/cmdline.txt">Edit cmdline.txt</a> 4.117 + <a href="$script?editor&file=/boot/cmdline.txt&from=?rpi_config">Edit cmdline.txt</a> 4.118 </div> 4.119 4.120 <h2>Boot configuration file</h2> 4.121 @@ -100,7 +154,7 @@ 4.122 $(cat /boot/config.txt 2>/dev/null) 4.123 </pre> 4.124 <div class="button"> 4.125 - <a href="$script?editor&file=/boot/config.txt">Edit config.txt</a> 4.126 + <a href="$script?editor&file=/boot/config.txt&from=?rpi_config">Edit config.txt</a> 4.127 </div> 4.128 4.129 <h2>Blacklisted Kernel modules</h2> 4.130 @@ -112,7 +166,7 @@ 4.131 $(cat $blacklist 2>/dev/null) 4.132 </pre> 4.133 <div class="button"> 4.134 - <a href="$script?editor&file=$blacklist">Edit $(basename $blacklist)</a> 4.135 + <a href="$script?editor&file=$blacklist&from=?rpi_config">Edit $(basename $blacklist)</a> 4.136 </div> 4.137 EOT 4.138
5.1 Binary file rpi/rootfs/usr/share/sounds/ready.mp3 has changed