Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of kl46z_stop_watch_v2 by
Revision 2:5ad6ad8c563a, committed 2016-10-19
- Comitter:
- kennylujan42
- Date:
- Wed Oct 19 06:27:05 2016 +0000
- Parent:
- 1:0d13b6d7907f
- Commit message:
- KLUJA-SSD-341-Hw-9.2
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 0d13b6d7907f -r 5ad6ad8c563a main.cpp --- a/main.cpp Wed Oct 12 15:55:44 2016 +0000 +++ b/main.cpp Wed Oct 19 06:27:05 2016 +0000 @@ -9,7 +9,7 @@ #define RBUT PTC3 #define STOPPEDSTATE 0 #define TIMINGSTATE 1 -#define RESETTINGSTATE 0 +#define RESETTINGSTATE 2 #define PRINTDELTA 0.01 #define LCDCHARLEN 10 #define BUTTONTIME 0.2 @@ -59,41 +59,59 @@ int fifthSeconds; bool statetoggle = false; //was in stopped state. + int RButtonState; + int LButtonState; + + initialize_global_vars(); showTitle(); while (true) { + + LButtonState = !buttons[1].read(); + RButtonState = !buttons[0].read(); + + if (ButtonTimer > BUTTONTIME){ for (i=0; i<NUMBUTS; i++){ // index will be 0 or 1 - if(!buttons[i]) { // a buttton is pressed - displayState = i; - switch (displayState){ // this keeps things generic - case TIMINGSTATE: { - statetoggle = !statetoggle; - break; - } - case RESETTINGSTATE :{ + + if(LButtonState && RButtonState) { //a butttons is pressed + displayState = RESETTINGSTATE; + statetoggle = !statetoggle; + + break; + } + else if(LButtonState){ + displayState = TIMINGSTATE; + statetoggle = !statetoggle; + break; + } + else if(RButtonState){ + displayState = STOPPEDSTATE; + break; + } + else{ + ButtonTimer.reset(); break; - } - } - } // if ! buttons - }// for loop to look at buttons + } + } + + ButtonTimer.reset(); switch (displayState){ - /* this goes away case STOPPEDSTATE : { rled = 0.0; gled = 1.0; break; } - */ + case RESETTINGSTATE: - if (!statetoggle){ + if (statetoggle){ secondsCount = 0; displayState = TIMINGSTATE; } rled = 0.0; - gled = 1.0; + gled = 0.0; break; @@ -116,4 +134,5 @@ LCDMess(lcdData); }// end Button timer } -} \ No newline at end of file +} +