added remote start button press

Sat, 17 Dec 2011 13:35:40 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Sat, 17 Dec 2011 13:35:40 +0100
changeset 90
7ed95dbadf1f
parent 89
4b5b4c7ba03d
child 91
e0738355b517

added remote start button press

blackbox/main.c file | annotate | diff | comparison | revisions
slotUI/SlotCli.py file | annotate | diff | comparison | revisions
--- a/blackbox/main.c	Sat Dec 17 13:24:20 2011 +0100
+++ b/blackbox/main.c	Sat Dec 17 13:35:40 2011 +0100
@@ -175,6 +175,32 @@
     return 0;
 }
 
+void startbutton(void) {
+    // start button press active
+    if (mode == 0) {
+        mode = 1; // set wait for race start mode
+        reset_vars();
+        LED(1, 1);
+        LED(2, 1);
+        LED(3, 1);
+        LED(4, 1);
+        LED(5, 1);
+        RS232_puts_p(prepare);
+    } else if (mode == 1) {
+        // Initiate race countdown
+        sysclk.value = 0;
+        countdown = 5;
+        countdown_loops = COUNTDOWN_DELAY;
+        mode = 2;
+        LED(1, 0);
+        LED(2, 0);
+        LED(3, 0);
+        LED(4, 0);
+        LED(5, 0);
+        RS232_puts_p(countdownstart);
+    }
+}
+
 ISR ( USART_RXC_vect ) {
     uint8_t tmp;
     char c = UDR;
@@ -246,6 +272,11 @@
                     RS232_puts_p(ok);
                     break;
 
+                case '#': // remote start button press
+                    RS232_puts_p(ok);
+                    startbutton();
+                    break;
+
                 case '+': // toggle panic mode
                     RS232_puts_p(ok);
                     if (mode != 0xff) {
@@ -569,6 +600,7 @@
     } else slot[idx].seccnt++;
 }
 
+
 int main(void)
 {
 
@@ -602,31 +634,7 @@
         btn_start = (PIN(SW_START_PORT) & _BV(SW_START));
         if (old_start != btn_start) {
             // start button changed
-            if (btn_start == 0) {
-                // start button press active
-                if (mode == 0) {
-                    mode = 1; // set wait for race start mode
-                    reset_vars();
-                    LED(1, 1);
-                    LED(2, 1);
-                    LED(3, 1);
-                    LED(4, 1);
-                    LED(5, 1);
-                    RS232_puts_p(prepare);
-                } else if (mode == 1) {
-                    // Initiate race countdown
-                    sysclk.value = 0;
-                    countdown = 5;
-                    countdown_loops = COUNTDOWN_DELAY;
-                    mode = 2;
-                    LED(1, 0);
-                    LED(2, 0);
-                    LED(3, 0);
-                    LED(4, 0);
-                    LED(5, 0);
-                    RS232_puts_p(countdownstart);
-                }
-            }
+            if (btn_start == 0) startbutton();
             old_start = btn_start;
         }
 
--- a/slotUI/SlotCli.py	Sat Dec 17 13:24:20 2011 +0100
+++ b/slotUI/SlotCli.py	Sat Dec 17 13:35:40 2011 +0100
@@ -168,6 +168,7 @@
             key = self.scr.getch()
             if key == ord('q'): break
             elif key == ord(' '): self.box.query("+") # panic / resume
+            elif key == 10: self.box.query("#") # remote start button press
             elif key == ord('1'): self.readName(0)
             elif key == ord('2'): self.readName(1)
             elif key == ord('3'): self.readName(2)

mercurial