# HG changeset patch # User Christophe Lincoln # Date 1398514148 -7200 # Node ID 71b3777ac5f1965eab68c5df8cf728b78b12d525 # Parent fae61a8c31e09e0d13fa3717668d03451e6efa6a Largely improve R-Pi GPIO pins support diff -r fae61a8c31e0 -r 71b3777ac5f1 cgi-adm/data/style.css --- a/cgi-adm/data/style.css Sat Apr 26 12:41:01 2014 +0200 +++ b/cgi-adm/data/style.css Sat Apr 26 14:09:08 2014 +0200 @@ -50,14 +50,15 @@ input[type="submit"], select, .button a { color: #444444; border: 1px solid #afafaf; - padding: 4px; + padding: 6px; margin: 4px 0px; font-size: 14px; line-height: 1.2em; + cursor: pointer; background-image: -webkit-linear-gradient(#FAFAFA, #F4F4F4 40%, #E5E5E5); background-image: -moz-linear-gradient(#FAFAFA, #F4F4F4 40%, #E5E5E5); -webkit-appearance: none; - -webkit-padding-end: 12px; + -webkit-padding-end: 6px; -webkit-padding-start: 6px; } input[type="submit"], { @@ -70,7 +71,6 @@ padding: 4px; min-width: 360px; } - input[type="submit"]:hover, select:hover, .button a:hover { background-color: #ddd; border: 1px solid #999; diff -r fae61a8c31e0 -r 71b3777ac5f1 rpi/cgi-adm/plugins/rpi_config/rpi_config.cgi --- a/rpi/cgi-adm/plugins/rpi_config/rpi_config.cgi Sat Apr 26 12:41:01 2014 +0200 +++ b/rpi/cgi-adm/plugins/rpi_config/rpi_config.cgi Sat Apr 26 14:09:08 2014 +0200 @@ -24,7 +24,7 @@ Play sound Mute Vol 100% - Vol 50% + Vol 75%
 $(amixer)
diff -r fae61a8c31e0 -r 71b3777ac5f1 rpi/cgi-adm/plugins/rpi_gpio/rpi_gpio.cgi
--- a/rpi/cgi-adm/plugins/rpi_gpio/rpi_gpio.cgi	Sat Apr 26 12:41:01 2014 +0200
+++ b/rpi/cgi-adm/plugins/rpi_gpio/rpi_gpio.cgi	Sat Apr 26 14:09:08 2014 +0200
@@ -7,14 +7,58 @@
 
 	*\ rpi_gpio\ *)
 		sysfs="/sys/class/gpio"
+
+		case " $(GET rpi_gpio) " in
+			*\ export\ *)
+				sysfs="/sys/class/gpio"
+				pin="$(GET pin)"
+				set="$(GET set)"
+				[ "$set" == "unexport" ] || html_header "GPIO pin: $pin"
+				if [ ! -d "$sysfs/gpio${pin}" ]; then
+					echo ${pin} > ${sysfs}/export
+				fi
+				# in/out
+				case "$set" in
+					in)
+						echo "0" > ${sysfs}/gpio${pin}/value
+						echo "in" > ${sysfs}/gpio${pin}/direction ;;
+					out)
+						echo "out" > ${sysfs}/gpio${pin}/direction ;;
+					write)
+						echo "out" > ${sysfs}/gpio${pin}/direction
+						echo "1" > ${sysfs}/gpio${pin}/value ;;
+					unexport)
+						echo "$pin" > ${sysfs}/unexport ;;
+				esac
+				[ "$set" == "unexport" ] || cat << EOT
+

Raspberry Pi GPIO pin: $pin

+ +
+Direction : $(cat $sysfs/gpio${pin}/direction)
+Value     : $(cat $sysfs/gpio${pin}/value)
+
+ + + +EOT + html_footer && [ "$set" == "unexport" ] || exit 0 ;; + esac + + # Main page html_header "GPIO pins" + cat << EOT

Raspberry Pi GPIO pins

The R-Pi offers GPIO lower-level interfaces intended to connect - more directly with chips and subsystem modules. Documentation on the: - Official Wiki + more directly with chips and subsystem modules. Documentation on: + the Official Wiki

$sysfs

@@ -22,14 +66,13 @@ $(ls -1p $sysfs)
-

Export example

- -
-# echo 24 > $sysfs/export
-# cat $sysfs/gpio24/direction
-
- +

Export GPIO pin

+
EOT - +for pin in 0 1 4 7 8 9 10 11 14 15 17 18 21 22 23 24 25 +do + echo -n "${pin} " +done + echo '
' html_footer && exit 0 ;; esac