Working read code with mode button

Dependencies:   SDFileSystem emic2 mbed-rtos mbed

Fork of BAT_senior_design_Testnew by BAT

Revision:
43:82d67fb53e61
Parent:
1:f3d363ca2343
--- a/button.cpp	Mon Dec 04 23:25:38 2017 +0000
+++ b/button.cpp	Tue Dec 05 03:31:58 2017 +0000
@@ -10,15 +10,20 @@
 // button constructor
 button::button(PwmOut servo, DigitalIn pb, int id)
     : servo(servo), pb(pb), state(0), press(0), id(id) {}
+/*button::button(PwmOut servo, DigitalIn pb, AnalogIn lp)
+    : servo(servo), pb(pb), linpot(lp), press(0), state(0) {}
+*/
+//Serial pc(USBTX, USBRX);
 
 // FUNCTIONS
+
 // get servo pin
 PwmOut button::getServoPin()
 {
     return servo;
 }
 
-// set button state
+// get servo pin
 void button::setState(int mystate)
 {
     state = mystate;
@@ -29,6 +34,12 @@
     press = mypress;
 }
 
+// get servo pin
+/*void button::setMode(int mymode)
+{
+    mode = mymode;
+}*/
+
 // get current state of the button
 int button::getState()
 {
@@ -43,23 +54,29 @@
 
 int button::getPress()
 {
+    //pc.printf("%d", press);
     return press;
 }
 
 // get current state of the button
 int button::getLp()
 {
+    /*    if (linpot < 2)
+            return 1;
+        else*/
     return 0;
 }
 
 // move servo into the slot
 void button::moveServoIn()
 {
+    //myled = 1;
     // rotate 90 degrees one way
     for(int i=4; i<=7; i++) {
         servo = i/100.0;
         wait(0.01);
     }
+    //press = 1;
     switch (id) {
         case 1:
             led2 = 0;
@@ -97,6 +114,7 @@
 // move servo out of the slot
 void button::moveServoOut()
 {
+    //myled = 0;
     for(int i=7; i>4; i--) {
         servo = i/100.0;
         wait(0.01);
@@ -108,6 +126,7 @@
 
 int button::updateState()
 {
+    //myled = 0;
     // state 0 - button is up, pb = 0
     if (pb == 0 && state == 3) {
         // nothing happens here, servo is still
@@ -118,6 +137,12 @@
         moveServoIn();
         state = 1;
         press = 1;
+
+        // Speaker says stuff
+        /*myTTS.volume(18); //max volume
+        myTTS.speakf("S");//Speak command starts with "S"
+        myTTS.speakf("Hey, you pressed a pin!");  // Send the desired string to convert to speech
+        myTTS.speakf("\r"); //marks end of speak command*/
     }
     // state 2 - button is down, pb = 0
     if (pb == 0 && state == 1) {
@@ -131,6 +156,9 @@
         press = 0;
     }
     // state 4 - handle debouncing while button is down
+    /*if (pb1 = 1 && state == 2) {
+        count++;
+    }*/
     return state;
 }