kiosk current files
authorBernhard Tittelbach <xro@realraum.at>
Wed, 29 Oct 2014 18:59:43 +0000 (18:59 +0000)
committerBernhard Tittelbach <xro@realraum.at>
Wed, 29 Oct 2014 18:59:43 +0000 (18:59 +0000)
raspberrypi_gpio_relay_licht/index.html
raspberrypi_gpio_relay_licht/indexz.html [new file with mode: 0755]
raspberrypi_gpio_relay_licht/mswitch.cgi
raspberrypi_gpio_relay_licht/rc.local
raspberrypi_gpio_relay_licht/realraumsimpel.png [new file with mode: 0755]
raspberrypi_gpio_relay_licht/realraumsimpelz.png [new file with mode: 0755]
raspberrypi_gpio_relay_licht/style.css [new file with mode: 0755]
raspberrypi_gpio_relay_licht/stylez.css [new file with mode: 0755]
raspberrypi_gpio_relay_licht/switch.cgi
raspberrypi_gpio_relay_licht/switch.html [new file with mode: 0644]

index 5bf1fba..e99dc1f 100644 (file)
@@ -1,5 +1,218 @@
 <html>
 <head>
-<meta http-equiv="refresh" content="0; URL=http://licht.realraum.at/cgi-bin/switch.cgi?nofloat=1">
+<link rel="stylesheet" type="text/css" href="style.css">
 </head>
+
+
+
+<script type="text/javascript">
+
+   var pc1_state=false;
+   var pc2_state=false;
+   var pc3_state=false;
+   var pc4_state=false;
+   var pc5_state=false;
+   var pc6_state=false;
+
+function callBackButtons(req)
+{
+       if(req.status != 200)
+       {
+               return;
+       }
+
+
+       var data = JSON.parse(req.responseText);
+
+               if(data['ceiling1']==true)
+               {
+                       pc1_state=true;
+                       document.getElementById("pc1").style.background="green";
+               }
+               else 
+               {
+                       pc1_state=false;
+                       document.getElementById("pc1").style.background="red";
+               }
+               
+
+                if(data['ceiling2']==true)
+                {
+                        pc2_state=true;
+                        document.getElementById("pc2").style.background="green";
+                }
+                else 
+                {
+                        pc2_state=false;
+                        document.getElementById("pc2").style.background="red";
+                }
+               
+                if(data['ceiling3']==true)
+                {
+                        pc3_state=true;
+                        document.getElementById("pc3").style.background="green";
+                }
+                else 
+                {
+                        pc3_state=false;
+                        document.getElementById("pc3").style.background="red";
+                }
+               
+
+                if(data['ceiling4']==true)
+                {
+                        pc4_state=true;
+                        document.getElementById("pc4").style.background="green";
+                }
+                else 
+                {
+                        pc4_state=false;
+                        document.getElementById("pc4").style.background="red";
+                }
+
+
+                if(data['ceiling5']==true)
+                {
+                        pc5_state=true;
+                        document.getElementById("pc5").style.background="green";
+                }
+                else 
+                {
+                        pc5_state=false;
+                        document.getElementById("pc5").style.background="red";
+                }
+
+                if(data['ceiling6']==true)
+                {
+                        pc6_state=true;
+                        document.getElementById("pc6").style.background="green";
+                }
+                else 
+                {
+                        pc6_state=false;
+                        document.getElementById("pc6").style.background="red";
+                }
+}
+
+function updateButtons(uri) {
+  var req = new XMLHttpRequest;
+  req.overrideMimeType("application/json");
+  req.open("GET", uri, true);
+  req.onload  = function() {callBackButtons(req)};
+  req.setRequestHeader("googlechromefix","");
+  req.send(null);
+}
+function sendMultiButton( str ) {
+ url = "/cgi-bin/mswitch.cgi?"+str;
+  updateButtons(url);
+}
+
+
+//function pc(n) switches light n
+
+function pc1()
+{
+       if(pc1_state===true)
+        {
+          pc1_state=false;
+          sendMultiButton("ceiling1=0")
+          document.getElementById("pc1").style.background="red";
+       }       
+       else
+       {
+          pc1_state=true;
+          sendMultiButton("ceiling1=1")
+           document.getElementById("pc1").style.background="green";
+       }
+}
+function pc2()
+{
+       if(pc2_state===true)
+        {
+          pc2_state=false;
+           sendMultiButton("ceiling2=0")               
+          document.getElementById("pc2").style.background="red";
+       }       
+       else
+       {
+          pc2_state=true;
+          sendMultiButton("ceiling2=1")        
+           document.getElementById("pc2").style.background="green";
+       }
+}
+function pc3()
+{
+       if(pc3_state===true)
+        {
+          pc3_state=false;
+          sendMultiButton("ceiling3=0")        
+          document.getElementById("pc3").style.background="red";
+       }       
+       else
+       {
+          pc3_state=true;
+          sendMultiButton("ceiling3=1")
+           document.getElementById("pc3").style.background="green";
+       }
+}
+function pc4()
+{
+       if(pc4_state===true)
+        {
+          pc4_state=false;
+          sendMultiButton("ceiling4=0")
+          document.getElementById("pc4").style.background="red";
+       }       
+       else
+       {
+          pc4_state=true;
+          sendMultiButton("ceiling4=1")
+           document.getElementById("pc4").style.background="green";
+       }
+}
+function pc5()
+{
+       if(pc5_state===true)
+        {
+          pc5_state=false;
+          sendMultiButton("ceiling5=0")
+          document.getElementById("pc5").style.background="red";
+       }       
+       else
+       {
+          pc5_state=true;
+          sendMultiButton("ceiling5=1")
+           document.getElementById("pc5").style.background="green";
+       }
+}
+
+function pc6()
+{
+       if(pc6_state===true)
+        {
+          pc6_state=false;
+          sendMultiButton("ceiling6=0")
+          document.getElementById("pc6").style.background="red";
+       }       
+       else
+       {
+          pc6_state=true;
+          sendMultiButton("ceiling6=1")
+           document.getElementById("pc6").style.background="green";
+       }
+}
+
+setInterval("updateButtons('/cgi-bin/mswitch.cgi');", 30*100 );
+updateButtons("/cgi-bin/mswitch.cgi");
+</script>
+
+<body>
+<div style="position:absolute; top:640px;"><a href="switch.html">Link to old switches</a></div>
+<div class="pc1" id="pc1" onclick="pc1()"></div>
+<div class="pc2" id="pc2" onclick="pc2()"></div>
+<div class="pc3" id="pc3" onclick="pc3()"></div>
+<div class="pc4" id="pc4" onclick="pc4()"></div>
+<div class="pc5" id="pc5" onclick="pc5()"></div>
+<div class="pc6" id="pc6" onclick="pc6()"></div>
+</body>
 </html>
diff --git a/raspberrypi_gpio_relay_licht/indexz.html b/raspberrypi_gpio_relay_licht/indexz.html
new file mode 100755 (executable)
index 0000000..fa03ef3
--- /dev/null
@@ -0,0 +1,218 @@
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="stylez.css">
+</head>
+
+
+
+<script type="text/javascript">
+
+   var pc1_state=false;
+   var pc2_state=false;
+   var pc3_state=false;
+   var pc4_state=false;
+   var pc5_state=false;
+   var pc6_state=false;
+
+function callBackButtons(req)
+{
+       if(req.status != 200)
+       {
+               return;
+       }
+
+
+       var data = JSON.parse(req.responseText);
+
+               if(data['ceiling1']==true)
+               {
+                       pc1_state=true;
+                       document.getElementById("pc1").style.background="green";
+               }
+               else 
+               {
+                       pc1_state=false;
+                       document.getElementById("pc1").style.background="red";
+               }
+               
+
+                if(data['ceiling2']==true)
+                {
+                        pc2_state=true;
+                        document.getElementById("pc2").style.background="green";
+                }
+                else 
+                {
+                        pc2_state=false;
+                        document.getElementById("pc2").style.background="red";
+                }
+               
+                if(data['ceiling3']==true)
+                {
+                        pc3_state=true;
+                        document.getElementById("pc3").style.background="green";
+                }
+                else 
+                {
+                        pc3_state=false;
+                        document.getElementById("pc3").style.background="red";
+                }
+               
+
+                if(data['ceiling4']==true)
+                {
+                        pc4_state=true;
+                        document.getElementById("pc4").style.background="green";
+                }
+                else 
+                {
+                        pc4_state=false;
+                        document.getElementById("pc4").style.background="red";
+                }
+
+
+                if(data['ceiling5']==true)
+                {
+                        pc5_state=true;
+                        document.getElementById("pc5").style.background="green";
+                }
+                else 
+                {
+                        pc5_state=false;
+                        document.getElementById("pc5").style.background="red";
+                }
+
+                if(data['ceiling6']==true)
+                {
+                        pc6_state=true;
+                        document.getElementById("pc6").style.background="green";
+                }
+                else 
+                {
+                        pc6_state=false;
+                        document.getElementById("pc6").style.background="red";
+                }
+}
+
+function updateButtons(uri) {
+  var req = new XMLHttpRequest;
+  req.overrideMimeType("application/json");
+  req.open("GET", uri, true);
+  req.onload  = function() {callBackButtons(req)};
+  req.setRequestHeader("googlechromefix","");
+  req.send(null);
+}
+function sendMultiButton( str ) {
+ url = "/cgi-bin/mswitch.cgi?"+str;
+  updateButtons(url);
+}
+
+
+//function pc(n) switches light n
+
+function pc1()
+{
+       if(pc1_state===true)
+        {
+          pc1_state=false;
+          sendMultiButton("ceiling1=0")
+          document.getElementById("pc1").style.background="red";
+       }       
+       else
+       {
+          pc1_state=true;
+          sendMultiButton("ceiling1=1")
+           document.getElementById("pc1").style.background="green";
+       }
+}
+function pc2()
+{
+       if(pc2_state===true)
+        {
+          pc2_state=false;
+           sendMultiButton("ceiling2=0")               
+          document.getElementById("pc2").style.background="red";
+       }       
+       else
+       {
+          pc2_state=true;
+          sendMultiButton("ceiling2=1")        
+           document.getElementById("pc2").style.background="green";
+       }
+}
+function pc3()
+{
+       if(pc3_state===true)
+        {
+          pc3_state=false;
+          sendMultiButton("ceiling3=0")        
+          document.getElementById("pc3").style.background="red";
+       }       
+       else
+       {
+          pc3_state=true;
+          sendMultiButton("ceiling3=1")
+           document.getElementById("pc3").style.background="green";
+       }
+}
+function pc4()
+{
+       if(pc4_state===true)
+        {
+          pc4_state=false;
+          sendMultiButton("ceiling4=0")
+          document.getElementById("pc4").style.background="red";
+       }       
+       else
+       {
+          pc4_state=true;
+          sendMultiButton("ceiling4=1")
+           document.getElementById("pc4").style.background="green";
+       }
+}
+function pc5()
+{
+       if(pc5_state===true)
+        {
+          pc5_state=false;
+          sendMultiButton("ceiling5=0")
+          document.getElementById("pc5").style.background="red";
+       }       
+       else
+       {
+          pc5_state=true;
+          sendMultiButton("ceiling5=1")
+           document.getElementById("pc5").style.background="green";
+       }
+}
+
+function pc6()
+{
+       if(pc6_state===true)
+        {
+          pc6_state=false;
+          sendMultiButton("ceiling6=0")
+          document.getElementById("pc6").style.background="red";
+       }       
+       else
+       {
+          pc6_state=true;
+          sendMultiButton("ceiling6=1")
+           document.getElementById("pc6").style.background="green";
+       }
+}
+
+setInterval("updateButtons('/cgi-bin/mswitch.cgi');", 30*100 );
+updateButtons("/cgi-bin/mswitch.cgi");
+</script>
+
+<body>
+<div class="pc1" id="pc1" onclick="pc1()"></div>
+<div class="pc2" id="pc2" onclick="pc2()"></div>
+<div class="pc3" id="pc3" onclick="pc3()"></div>
+<div class="pc4" id="pc4" onclick="pc4()"></div>
+<div class="pc5" id="pc5" onclick="pc5()"></div>
+<div class="pc6" id="pc6" onclick="pc6()"></div>
+
+</body>
+</html>
index 08d1bcd..d62bce9 100755 (executable)
@@ -11,6 +11,7 @@ IDGPIOMAP[ceiling4]=17
 IDGPIOMAP[ceiling5]=22
 IDGPIOMAP[ceiling6]=21
 GPIOPATH=/sys/class/gpio/gpio
+SAVESTATE=/var/log/licht/mswitch.state
 
 for k v in ${(kv)IDGPIOMAP}; do
   GPIOIDMAP[$v]=$k
@@ -44,6 +45,16 @@ print_gpio_state() {
   fi
 }
 
+print_gpio_state_10() {
+  GPIO=${IDGPIOMAP[$1]}
+  GPIOVALUE=$(cat "${GPIOPATH}${GPIO}/value")
+  if [[ $GPIOVALUE == "0" ]]; then
+    echo -n "1"
+  else
+    echo -n "0"
+  fi
+}
+
 gpio_is_on() {
   GPIO=${IDGPIOMAP[$1]}
   GPIOVALUE=$(cat "${GPIOPATH}${GPIO}/value")
@@ -61,9 +72,12 @@ for CHECKID in $VALID_ONOFF_IDS; do
     echo "$VAL" > "${GPIOPATH}${IDGPIOMAP[$CHECKID]}/value"
   fi
   GPIOSTATES+=(\"${CHECKID}\":"$(print_gpio_state $CHECKID)")
+  URISTATES+=("${CHECKID}=$(print_gpio_state_10 $CHECKID)")
 done
 JSON_STATE="{${(j:,:)GPIOSTATES}}"
 print ${(q)JSON_STATE}
 if ((#GPIOS > 0)); then
   print "[$(date +%s),\"$REMOTE_ADDR\",${(q)JSON_STATE}]," >> /var/log/licht/mswitch.log
+  echo -n "${(j:&:)URISTATES}">$SAVESTATE
 fi
+
index 254a556..33672c7 100644 (file)
@@ -1,40 +1,41 @@
-#!/bin/sh -e
-#
-# rc.local
-#
-# This script is executed at the end of each multiuser runlevel.
-# Make sure that the script will "exit 0" on success or any other
-# value on error.
-#
-# In order to enable or disable this script just change the execution
-# bits.
-#
-# By default this script does nothing.
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          rc.local
+# Required-Start:    $all
+# Required-Stop:
+# Default-Start:     2 3 4 5
+# Default-Stop:
+# Short-Description: Run /etc/rc.local if it exist
+### END INIT INFO
 
-for gpio in 4 17 18 21 22 23; do
- echo $gpio > /sys/class/gpio/export
- echo out > /sys/class/gpio/gpio$gpio/direction
- chown www-data /sys/class/gpio/gpio$gpio/value
-done
 
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
 
-# Print the IP address
-_IP=$(hostname -I) || true
-if [ "$_IP" ]; then
-  printf "My IP address is %s\n" "$_IP"
-fi
+. /lib/init/vars.sh
+. /lib/lsb/init-functions
 
-MAX_TRIES=20
-if ! ifconfig eth0 && ifconfig wlan0 ; then
-  sleep 6
-  while ((MAX_TRIES-- > 0)) && ! /sbin/wpa_cli status | grep -q wpa_state=COMPLETED; do
-    /sbin/wpa_cli status
-    ifdown wlan0
-    ifup wlan0
-  done
-fi
+do_start() {
+       if [ -x /etc/rc.local ]; then
+               [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)"
+               /etc/rc.local
+               ES=$?
+               [ "$VERBOSE" != no ] && log_end_msg $ES
+               return $ES
+       fi
+}
 
-su realraum -s /bin/sh -c "sleep 10 && /home/realraum/play-sound-status.py /home/realraum/play-sound-status.cfg &>/dev/null &" &
-su realraum -s /bin/sh -c "sleep 10 && /home/realraum/stuff.py &>/dev/null &" &
-
-exit 0
+case "$1" in
+    start)
+       do_start
+        ;;
+    restart|reload|force-reload)
+        echo "Error: argument '$1' not supported" >&2
+        exit 3
+        ;;
+    stop)
+        ;;
+    *)
+        echo "Usage: $0 start|stop" >&2
+        exit 3
+        ;;
+esac
diff --git a/raspberrypi_gpio_relay_licht/realraumsimpel.png b/raspberrypi_gpio_relay_licht/realraumsimpel.png
new file mode 100755 (executable)
index 0000000..0b9cbb1
Binary files /dev/null and b/raspberrypi_gpio_relay_licht/realraumsimpel.png differ
diff --git a/raspberrypi_gpio_relay_licht/realraumsimpelz.png b/raspberrypi_gpio_relay_licht/realraumsimpelz.png
new file mode 100755 (executable)
index 0000000..38e2904
Binary files /dev/null and b/raspberrypi_gpio_relay_licht/realraumsimpelz.png differ
diff --git a/raspberrypi_gpio_relay_licht/style.css b/raspberrypi_gpio_relay_licht/style.css
new file mode 100755 (executable)
index 0000000..2560904
--- /dev/null
@@ -0,0 +1,70 @@
+body 
+{
+       background-image:url("./realraumsimpel.png");
+        background-repeat:no-repeat;
+}
+
+#pc1
+{
+    background-color:#f00;     
+}
+.pc1
+{
+    position:absolute;
+    height:122px;
+    width:122px;
+    top:370px;
+    left:697px;
+    background-color:#f00;
+    z-index:20;
+}
+.pc2
+{
+    position:absolute;
+    height:122px;
+    width:122px;
+    top:142px;
+    left:697px;
+    background-color:#f00;
+    z-index:20;
+}
+.pc3
+{
+    position:absolute;
+    height:122px;
+    width:122px;
+    top:370px;
+    left:402px;
+    background-color:#f00;
+    z-index:20;
+}
+.pc4
+{
+    position:absolute;
+    height:122px;
+    width:122px;
+    top:142px;
+    left:402px;
+    background-color:#f00;
+    z-index:20;
+}
+.pc5
+{
+    position:absolute;
+    height:122px;
+    width:122px;
+    top:370px;
+    left:127px;
+    background-color:#f00;
+    z-index:20;
+}
+.pc6
+{
+    position:absolute;
+    height:122px;
+    width:122px;
+    top:142px;
+    left:127px;
+    background-color:#f00;
+    z-index:20;
+}
diff --git a/raspberrypi_gpio_relay_licht/stylez.css b/raspberrypi_gpio_relay_licht/stylez.css
new file mode 100755 (executable)
index 0000000..96a87fb
--- /dev/null
@@ -0,0 +1,70 @@
+body 
+{
+       background-image:url("./realraumsimpelz.png");
+        background-repeat:no-repeat;
+}
+
+#pc1
+{
+    background-color:#f00;     
+}
+.pc1
+{
+    position:absolute;
+    height:122px;
+    width:122px;
+    top:370px;
+    left:697px;
+    background-color:#f00;
+    z-index:20;
+}
+.pc2
+{
+    position:absolute;
+    height:122px;
+    width:122px;
+    top:142px;
+    left:697px;
+    background-color:#f00;
+    z-index:20;
+}
+.pc3
+{
+    position:absolute;
+    height:122px;
+    width:122px;
+    top:370px;
+    left:402px;
+    background-color:#f00;
+    z-index:20;
+}
+.pc4
+{
+    position:absolute;
+    height:122px;
+    width:122px;
+    top:142px;
+    left:402px;
+    background-color:#f00;
+    z-index:20;
+}
+.pc5
+{
+    position:absolute;
+    height:122px;
+    width:122px;
+    top:370px;
+    left:127px;
+    background-color:#f00;
+    z-index:20;
+}
+.pc6
+{
+    position:absolute;
+    height:122px;
+    width:122px;
+    top:142px;
+    left:127px;
+    background-color:#f00;
+    z-index:20;
+}
index d4e3683..5ff6ac6 100755 (executable)
@@ -183,12 +183,12 @@ fi
 
 #Pattern1
 echo "<div class=\"switchbox\">"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"4=0&23=0&18=1&17=1&22=0&21=0\");'>[&nbsp;|&nbsp;]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"4=1&23=1&18=0&17=0&22=1&21=1\");'>[|&nbsp;|]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"4=1&23=1&18=0&17=0&22=0&21=1\");'>[|&nbsp;.]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"4=0&23=1&18=0&17=1&22=0&21=1\");'>[***]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"4=1&23=0&18=0&17=0&22=0&21=1\");'>[.&nbsp;*]</button>"
-echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"4=0&23=1&18=0&17=0&22=1&21=0\");'>[*&nbsp;.]</button>"
+echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=0&ceiling2=0&ceiling3=1&ceiling4=1&ceiling5=0&ceiling6=0\");'>[&nbsp;|&nbsp;]</button>"
+echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=1&ceiling2=1&ceiling3=0&ceiling4=0&ceiling5=1&ceiling6=1\");'>[|&nbsp;|]</button>"
+echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=1&ceiling2=0&ceiling3=0&ceiling4=0&ceiling5=1&ceiling6=1\");'>[|&nbsp;.]</button>"
+echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=0&ceiling2=1&ceiling3=0&ceiling4=1&ceiling5=0&ceiling6=1\");'>[***]</button>"
+echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=1&ceiling2=0&ceiling3=0&ceiling4=0&ceiling5=0&ceiling6=1\");'>[*&nbsp;.]</button>"
+echo -n " <button class=\"sendbutton\" onClick='sendMultiButton(\"ceiling1=0&ceiling2=0&ceiling3=0&ceiling4=0&ceiling5=1&ceiling6=1\");'>[|&nbsp;&nbsp;]</button>"
 echo "</div>"
 
 if [ "$NOFLOAT" = "1" ]; then
diff --git a/raspberrypi_gpio_relay_licht/switch.html b/raspberrypi_gpio_relay_licht/switch.html
new file mode 100644 (file)
index 0000000..5bf1fba
--- /dev/null
@@ -0,0 +1,5 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0; URL=http://licht.realraum.at/cgi-bin/switch.cgi?nofloat=1">
+</head>
+</html>