projects
/
svn42.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
display state and switch multiple at once
[svn42.git]
/
router_gpio_relay_licht
/
switch.cgi
diff --git
a/router_gpio_relay_licht/switch.cgi
b/router_gpio_relay_licht/switch.cgi
index
9f53097
..
9406356
100755
(executable)
--- a/
router_gpio_relay_licht/switch.cgi
+++ b/
router_gpio_relay_licht/switch.cgi
@@
-25,6
+25,20
@@
GPIOPATH=/sys/class/gpio/gpio
#VALID_ONOFF_IDS="7 18 20 29"
VALID_ONOFF_IDS="7 18 20"
#VALID_ONOFF_IDS="7 18 20 29"
VALID_ONOFF_IDS="7 18 20"
+print_gpio_state() {
+ GPIOVALUE=$(cat "${GPIOPATH}${1}/value")
+ if [ "$GPIOVALUE" = "1" ]; then
+ echo "ON"
+ else
+ echo "Off"
+ fi
+}
+
+gpio_is_on() {
+ GPIOVALUE=$(cat "${GPIOPATH}${1}/value")
+ [ "$GPIOVALUE" = "1" ]
+}
+
if [ "$POWER" == "1" -o "$POWER" == "0" ]; then
for CHECKID in $VALID_ONOFF_IDS ; do
if [ "$CHECKID" == "$ID" ]; then
if [ "$POWER" == "1" -o "$POWER" == "0" ]; then
for CHECKID in $VALID_ONOFF_IDS ; do
if [ "$CHECKID" == "$ID" ]; then
@@
-113,6
+127,12
@@
echo ' height: 32px;'
#echo ' background-color: grey;'
echo ' margin: 0px;'
echo '}'
#echo ' background-color: grey;'
echo ' margin: 0px;'
echo '}'
+
+echo '.enableborder {
+ font-weight: bold;
+ font-variant: small-caps;
+ border-style: inset;'
+echo '}'
echo '</style>'
echo "</head>"
echo "<body>"
echo '</style>'
echo "</head>"
echo "<body>"
@@
-121,15
+141,23
@@
echo "<body>"
echo "<div style=\"float:left;\">"
echo "<div style=\"float:left; border:1px solid black; margin-right:2ex; margin-bottom:2ex;\">"
for DISPID in $VALID_ONOFF_IDS; do
echo "<div style=\"float:left;\">"
echo "<div style=\"float:left; border:1px solid black; margin-right:2ex; margin-bottom:2ex;\">"
for DISPID in $VALID_ONOFF_IDS; do
- NAME="$(eval echo \$DESC_$DISPID)"
+ NAME="$(eval echo -n \$DESC_$DISPID)"
[ -z "$NAME" ] && NAME=$DISPID
echo "<div class=\"switchbox\">"
echo "<span class=\"alignbuttonsleft\">"
[ -z "$NAME" ] && NAME=$DISPID
echo "<div class=\"switchbox\">"
echo "<span class=\"alignbuttonsleft\">"
- echo " <button class=\"onbutton\" onClick='sendButton(\"1\",\"$DISPID\");'>On</button>"
+ if gpio_is_on $DISPID; then
+ echo " <button class=\"onbutton enableborder\" onClick='sendButton(\"1\",\"$DISPID\");'>On</button>"
echo " <button class=\"offbutton\" onClick='sendButton(\"0\",\"$DISPID\");'>Off</button>"
echo " <button class=\"offbutton\" onClick='sendButton(\"0\",\"$DISPID\");'>Off</button>"
+ else
+ echo " <button class=\"onbutton\" onClick='sendButton(\"1\",\"$DISPID\");'>On</button>"
+ echo " <button class=\"offbutton enableborder\" onClick='sendButton(\"0\",\"$DISPID\");'>Off</button>"
+ fi
echo "</span>"
echo "</span>"
- echo "<div class=\"switchnameright\">$NAME</div>"
+ echo -n "<div class=\"switchnameright\">$NAME</div>"
+# echo -n "<div class=\"switchnameright\">$NAME ("
+# print_gpio_state $DISPID
+# echo ")</div>"
echo "</div>"
if [ "$NOFLOAT" == "1" ]; then
echo "</div>"
if [ "$NOFLOAT" == "1" ]; then