slitaz-arm rev 140

Largely improve R-Pi GPIO pins support
author Christophe Lincoln <pankso@slitaz.org>
date Sat Apr 26 14:09:08 2014 +0200 (2014-04-26)
parents fae61a8c31e0
children d2106327fb89
files cgi-adm/data/style.css rpi/cgi-adm/plugins/rpi_config/rpi_config.cgi rpi/cgi-adm/plugins/rpi_gpio/rpi_gpio.cgi
line diff
     1.1 --- a/cgi-adm/data/style.css	Sat Apr 26 12:41:01 2014 +0200
     1.2 +++ b/cgi-adm/data/style.css	Sat Apr 26 14:09:08 2014 +0200
     1.3 @@ -50,14 +50,15 @@
     1.4  input[type="submit"], select, .button a {
     1.5  	color: #444444;
     1.6  	border: 1px solid #afafaf;
     1.7 -	padding: 4px;
     1.8 +	padding: 6px;
     1.9  	margin: 4px 0px;
    1.10  	font-size: 14px;
    1.11  	line-height: 1.2em;
    1.12 +	cursor: pointer;
    1.13  	background-image: -webkit-linear-gradient(#FAFAFA, #F4F4F4 40%, #E5E5E5);
    1.14  	background-image: -moz-linear-gradient(#FAFAFA, #F4F4F4 40%, #E5E5E5);
    1.15  	-webkit-appearance: none;
    1.16 -	-webkit-padding-end: 12px;
    1.17 +	-webkit-padding-end: 6px;
    1.18  	-webkit-padding-start: 6px;
    1.19  }
    1.20  input[type="submit"],  {
    1.21 @@ -70,7 +71,6 @@
    1.22  	padding: 4px;
    1.23  	min-width: 360px;
    1.24  }
    1.25 -
    1.26  input[type="submit"]:hover, select:hover, .button a:hover {
    1.27  	background-color: #ddd;
    1.28  	border: 1px solid #999;
     2.1 --- a/rpi/cgi-adm/plugins/rpi_config/rpi_config.cgi	Sat Apr 26 12:41:01 2014 +0200
     2.2 +++ b/rpi/cgi-adm/plugins/rpi_config/rpi_config.cgi	Sat Apr 26 14:09:08 2014 +0200
     2.3 @@ -24,7 +24,7 @@
     2.4  	<a href="$script?audio=play">Play sound</a>
     2.5  	<a href="$script?audio=mute">Mute</a>
     2.6  	<a href="$script?audio=vol&amp;cset=100">Vol 100%</a>
     2.7 -	<a href="$script?audio=vol&amp;cset=50">Vol 50%</a>
     2.8 +	<a href="$script?audio=vol&amp;cset=75">Vol 75%</a>
     2.9  </div>
    2.10  <pre>
    2.11  $(amixer)
     3.1 --- a/rpi/cgi-adm/plugins/rpi_gpio/rpi_gpio.cgi	Sat Apr 26 12:41:01 2014 +0200
     3.2 +++ b/rpi/cgi-adm/plugins/rpi_gpio/rpi_gpio.cgi	Sat Apr 26 14:09:08 2014 +0200
     3.3 @@ -7,14 +7,58 @@
     3.4  
     3.5  	*\ rpi_gpio\ *)
     3.6  		sysfs="/sys/class/gpio"
     3.7 +
     3.8 +		case " $(GET rpi_gpio) " in
     3.9 +			*\ export\ *)
    3.10 +				sysfs="/sys/class/gpio"
    3.11 +				pin="$(GET pin)"
    3.12 +				set="$(GET set)"
    3.13 +				[ "$set" == "unexport" ] || html_header "GPIO pin: $pin"
    3.14 +				if [ ! -d "$sysfs/gpio${pin}" ]; then
    3.15 +					echo ${pin} > ${sysfs}/export
    3.16 +				fi
    3.17 +				# in/out
    3.18 +				case "$set" in
    3.19 +					in)
    3.20 +						echo "0" > ${sysfs}/gpio${pin}/value
    3.21 +						echo "in" > ${sysfs}/gpio${pin}/direction ;;
    3.22 +					out)
    3.23 +						echo "out" > ${sysfs}/gpio${pin}/direction ;;
    3.24 +					write)
    3.25 +						echo "out" > ${sysfs}/gpio${pin}/direction
    3.26 +						echo "1" > ${sysfs}/gpio${pin}/value ;;
    3.27 +					unexport)
    3.28 +						echo "$pin" > ${sysfs}/unexport ;;
    3.29 +				esac
    3.30 +				[ "$set" == "unexport" ] || cat << EOT
    3.31 +<h1>Raspberry Pi GPIO pin: $pin</h1>
    3.32 +
    3.33 +<pre>
    3.34 +Direction : $(cat $sysfs/gpio${pin}/direction)
    3.35 +Value     : $(cat $sysfs/gpio${pin}/value)
    3.36 +</pre>
    3.37 +
    3.38 +<div class="button">
    3.39 +	<a href='$script?rpi_gpio=export&amp;pin=$pin&amp;set=in'>in</a>
    3.40 +	<a href='$script?rpi_gpio=export&amp;pin=$pin&amp;set=out'>out</a>
    3.41 +	<a href='$script?rpi_gpio=export&amp;pin=$pin&amp;set=write'>Write output</a>
    3.42 +	<a href='$script?rpi_gpio=export&amp;pin=$pin&amp;set=unexport'>Unexport</a>
    3.43 +</div>
    3.44 +
    3.45 +EOT
    3.46 +			html_footer && [ "$set" == "unexport" ] || exit 0 ;;
    3.47 +		esac
    3.48 +
    3.49 +		# Main page
    3.50  		html_header "GPIO pins"
    3.51 +		
    3.52  		cat << EOT
    3.53  <h1>Raspberry Pi GPIO pins</h1>
    3.54  
    3.55  <p>
    3.56  	The R-Pi offers GPIO lower-level interfaces intended to connect 
    3.57 -	more directly with chips and subsystem modules. Documentation on the:
    3.58 -	<a href="http://elinux.org/RPi_Low-level_peripherals">Official Wiki</a>
    3.59 +	more directly with chips and subsystem modules. Documentation on:
    3.60 +	<a href="http://elinux.org/RPi_Low-level_peripherals">the Official Wiki</a>
    3.61  </p>
    3.62  
    3.63  <h2>$sysfs</h2>
    3.64 @@ -22,14 +66,13 @@
    3.65  $(ls -1p $sysfs)
    3.66  </pre>
    3.67  
    3.68 -<h2>Export example</h2>
    3.69 -
    3.70 -<pre>
    3.71 -# echo 24 > $sysfs/export
    3.72 -# cat $sysfs/gpio24/direction
    3.73 -</pre>
    3.74 -
    3.75 +<h2>Export GPIO pin</h2>
    3.76 +<div class="button">
    3.77  EOT
    3.78 -	
    3.79 +for pin in 0 1 4 7 8 9 10 11 14 15 17 18 21 22 23 24 25
    3.80 +do
    3.81 +	echo -n "<a href='$script?rpi_gpio=export&amp;pin=$pin'>${pin}</a> "
    3.82 +done
    3.83 +		echo '<div>'
    3.84  		html_footer && exit 0 ;;
    3.85  esac