algo
Dependencies: Debounced TextLCD2 mbed
Fork of tarea2 by
Revision 1:bf54a30a2b14, committed 2015-10-14
- Comitter:
- szapataa
- Date:
- Wed Oct 14 00:07:42 2015 +0000
- Parent:
- 0:3883458d6df5
- Commit message:
- n
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 3883458d6df5 -r bf54a30a2b14 main.cpp --- a/main.cpp Wed Oct 30 15:49:35 2013 +0000 +++ b/main.cpp Wed Oct 14 00:07:42 2015 +0000 @@ -11,12 +11,13 @@ DigitalIn button1(PTC12); DigitalIn button2(PTC13); DigitalIn button3(PTC16); +DebouncedIn button4(PTC17); int C1=0x0F; int spnum=0,kinum=0,kpnum=0,kdnum=0,pos=1; -int incremento=1,flagt=0; +int incremento=1,decremento=1,flagt=0; Timer t; int main() @@ -32,7 +33,7 @@ lcd.printf("Kd=%d",kdnum); lcd.locate(0,0); lcd.printf("Sp=%d",spnum); - + while(1) { if (!button1) @@ -131,6 +132,110 @@ { if(flagt==0) { + t.start(); + flagt=1; + } + + led1 =!led1; + wait(0.50); + if(!button2) + { + if(t.read()>10) + { + decremento=100; + } + else if(t.read()>5.5) + { + decremento=10; + } + + if(pos==1) + { + + if(spnum>=999) + { + spnum=999; + lcd.locate(3,0); + lcd.printf(" "); + lcd.locate(3,0); + lcd.printf("%d", spnum); + + } + + else + { + if(spnum==0) + { spnum=0; + lcd.locate(0,0); + lcd.printf("Sp=%d",spnum); + lcd.locate(3,0); + lcd.printf("%d", spnum); + } + + spnum-=decremento; + lcd.locate(3,0); + lcd.printf("%d", spnum); + } + } + else if(pos==2) + { + if(kpnum>=999) + { + kpnum=999; + lcd.locate(11,0); + lcd.printf(" "); + lcd.locate(11,0); + lcd.printf("%d", kpnum); + } + else + { + kpnum-=decremento; + lcd.locate(11,0); + lcd.printf("%d", kpnum); + } + } + else if(pos==3) + { + if(kinum>=999) + { + kinum=999; + lcd.locate(3,1); + lcd.printf(" "); + lcd.locate(3,1); + lcd.printf("%d", kinum); + } + else + { + kinum-=decremento; + lcd.locate(3,1); + lcd.printf("%d", kinum); + } + } + else if(pos==4) + { + if(kdnum>=999) + { + kdnum=999; + lcd.locate(11,1); + lcd.printf(" "); + lcd.locate(11,1); + lcd.printf("%d", kdnum); + } + else + { + kdnum-=decremento; + lcd.locate(11,1); + lcd.printf("%d", kdnum); + } + } + } + } + + + /*if (!button2) + { + if(flagt==0) + { //t.reset(); t.start(); flagt=1; @@ -212,7 +317,7 @@ } } } - } + }*/ if (!button3) {