added toggel command to firmware
authorrealraum <realraum@realraum.at>
Fri, 1 May 2009 23:08:53 +0000 (23:08 +0000)
committerrealraum <realraum@realraum.at>
Fri, 1 May 2009 23:08:53 +0000 (23:08 +0000)
firmware-messages.txt
firmware/tuer.pde

index e056a29..cf16cea 100644 (file)
@@ -21,6 +21,8 @@
    response: "Ok", "Already closed", "Error: .*"
   o ... open
    response: "Ok", "Already opened", "Error: .*"
+  t ... toggle
+   responce: "Ok", "Error: .*"
   s ... status
    response: "Status: closed|opened|<->, opening|waiting|closing|idle"
          or  "Error: .*"
index ddf8ba3..d2c7a09 100644 (file)
@@ -38,6 +38,7 @@ int debounce_cnt = 0;
 
 #define CMD_OPEN 'o'
 #define CMD_CLOSE 'c'
+#define CMD_TOGGLE 't'
 #define CMD_STATUS 's'
 #define CMD_RESET 'r'
 
@@ -554,6 +555,17 @@ void loop()
       else
         Serial.println("Error: Operation in progress");
     }
+    else if (command == CMD_TOGGLE) {
+      if(current_state == IDLE) {
+       if(is_closed())
+         start_open();
+       else
+         start_close();
+       Serial.println("Ok");
+      }
+      else
+        Serial.println("Error: Operation in progress");
+    }
     else if (command == CMD_STATUS)
       print_status();
     else