Minh Nguyen / Pushbutton
Revision:
9:7dd8100b2ba5
Parent:
8:9aaeab58e561
Child:
10:17af93056d39
--- a/Pushbutton.cpp	Wed Mar 17 20:09:13 2021 +0000
+++ b/Pushbutton.cpp	Wed Mar 24 01:47:27 2021 +0000
@@ -6,11 +6,8 @@
 DigitalIn Pushbutton::lastPressed(PIN_ACCEL_PANEL);
 
 //Constructor
-Pushbutton::Pushbutton(PinName bt) : button(bt),buttonInt(bt){
-    busy = 0;
-}
-Pushbutton::Pushbutton(PinName bt, int* state, int* flagIn) : buttonInt(bt),button(bt){
-    busy = 0;
+Pushbutton::Pushbutton(PinName bt) : button(bt),buttonInt(bt),button2(bt){}
+Pushbutton::Pushbutton(PinName bt, int* state, int* flagIn, PinName bt2) : buttonInt(bt),button(bt),button2(bt2){
     flag = flagIn;
     mode = state;
     if(INPUT_LOGIC == 0)
@@ -34,10 +31,14 @@
     wait_us(DEBOUNCE_TIME);
     
     Pushbutton::lastPressed = (button == INPUT_LOGIC) ? button : Pushbutton::lastPressed;
-    busy == (button == INPUT_LOGIC) ? 1 : 0;
     return (button == INPUT_LOGIC) ? 1 : 0;
 }
 
+//setConnected()
+void Pushbutton::setConnected(bool con){
+    connected = con;
+}
+
 //updateMode()
 void Pushbutton::updateMode()
 {   
@@ -67,7 +68,7 @@
                     *mode = OP_MANUAL_ALL;
                     return;
                 }
-                else if(*mode == OP_MANUAL_ALL || *mode == OP_WSETTING || *mode == OP_CONFIRM || *mode == OP_POWER_OFF)
+                else if(*mode == OP_MANUAL_ALL || *mode == OP_WSETTING || *mode == OP_CONFIRM || *mode == OP_POWER_OFF || *mode == OP_ATRACK)
                 {
                     *mode = OP_NORMAL;
                     return;
@@ -91,7 +92,11 @@
                 return;
             }
         }
-        *mode = OP_WSETTING;
+        
+        if(button2.read() && connected)
+            *mode = OP_ATRACK;
+        else
+            *mode = OP_WSETTING;
         return;
     }
 }