Published for Bernard
Dependencies: DebounceIn USBDevice mbed
Revision 8:6f46e3682189, committed 2015-09-15
- Comitter:
- figlax
- Date:
- Tue Sep 15 21:02:08 2015 +0000
- Parent:
- 7:0b2dfff14976
- Commit message:
- Published for Bernard
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 0b2dfff14976 -r 6f46e3682189 main.cpp --- a/main.cpp Thu Sep 18 08:48:06 2014 +0000 +++ b/main.cpp Tue Sep 15 21:02:08 2015 +0000 @@ -9,16 +9,18 @@ DigitalOut myled3(LED2); Serial pc(USBTX, USBRX); // tx, rx -DigitalIn button(D2); -DigitalIn button2(D3); -DigitalIn button3(D4); -DigitalIn button4(D5); -DigitalIn button5(D12); -DigitalIn button6(D7); -DigitalIn button7(D8); -DigitalIn button8(D9); -DebounceIn toggle(D10); +DigitalIn button(D3); +DigitalIn button2(D4); +DigitalIn button3(D5); +DigitalIn button4(D6); +DigitalIn button5(D7); +DigitalIn button6(D8); +DigitalIn button7(D9); +DigitalIn button8(D10); +DebounceIn toggle(D2); DebounceIn enter(D11); +DigitalOut led1(D14); +DigitalOut led2(D13); int main() { @@ -50,8 +52,10 @@ int button6_counter=0; int button7_counter=0; int button8_counter=0; + int ec=0; int n=0; + int t=0; int l=3; int l2=3; @@ -85,6 +89,8 @@ wait(0.4); myled=1; + + while(1) { enter_new = enter.read(); @@ -141,7 +147,10 @@ n=0; } if (n==1) { - pc.printf(" "); + if (ec>1){ + pc.printf(" "); + } + ec=0; n=0; } button_counter=0; @@ -160,7 +169,7 @@ toggle_new = toggle.read(); if ((toggle_new==0) && (toggle_old==1)) { - + t=1; myled= 0; wait(0.2); myled= 1; @@ -177,6 +186,8 @@ if (button_counter==(l)) { button_counter=0; } + t=0; + ec=0; } if (button2.read()==0) { button_counter= 0; @@ -190,6 +201,8 @@ if (button2_counter==(l2)) { button2_counter=0; } + t=0; + ec=0; } if (button3.read()==0) { button_counter= 0; @@ -203,6 +216,8 @@ if (button3_counter==(l3)) { button3_counter=0; } + t=0; + ec=0; } if (button4.read()==0) { button_counter= 0; @@ -216,6 +231,8 @@ if (button4_counter==(l4)) { button4_counter=0; } + t=0; + ec=0; } if (button5.read()==0) { button_counter= 0; @@ -229,6 +246,8 @@ if (button5_counter==(l5)) { button5_counter=0; } + t=0; + ec=0; } if (button6.read()==0) { button_counter= 0; @@ -242,6 +261,8 @@ if (button6_counter==(l6)) { button6_counter=0; } + t=0; + ec=0; } if (button7.read()==0) { button_counter= 0; @@ -255,6 +276,8 @@ if (button7_counter==(l7)) { button7_counter=0; } + t=0; + ec=0; } if (button8.read()==0) { button_counter= 0; @@ -268,6 +291,12 @@ if (button8_counter==(l8)) { button8_counter=0; } + t=0; + ec=0; + } + if (t==1){ + ec= ec+1; + //unsure if all button counters should be set to zero here. } } toggle_old= toggle_new;