![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Working read code with mode button
Dependencies: SDFileSystem emic2 mbed-rtos mbed
Fork of BAT_senior_design_Testnew by
Diff: button.cpp
- Revision:
- 1:f3d363ca2343
- Parent:
- 0:5887cb744114
- Child:
- 43:82d67fb53e61
--- a/button.cpp Mon Dec 04 19:58:40 2017 +0000 +++ b/button.cpp Mon Dec 04 20:14:24 2017 +0000 @@ -10,20 +10,15 @@ // 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; } -// get servo pin +// set button state void button::setState(int mystate) { state = mystate; @@ -34,12 +29,6 @@ press = mypress; } -// get servo pin -/*void button::setMode(int mymode) -{ - mode = mymode; -}*/ - // get current state of the button int button::getState() { @@ -54,29 +43,23 @@ 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; @@ -114,7 +97,6 @@ // 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); @@ -126,7 +108,6 @@ int button::updateState() { - //myled = 0; // state 0 - button is up, pb = 0 if (pb == 0 && state == 3) { // nothing happens here, servo is still @@ -137,12 +118,6 @@ 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) { @@ -156,9 +131,6 @@ press = 0; } // state 4 - handle debouncing while button is down - /*if (pb1 = 1 && state == 2) { - count++; - }*/ return state; }