Éric Bisson
/
S5info_APP2
School Project
Diff: main.cpp
- Revision:
- 5:e878d87782ce
- Parent:
- 4:87e9b434bb4d
- Child:
- 6:193013e37136
diff -r 87e9b434bb4d -r e878d87782ce main.cpp --- a/main.cpp Tue Jan 31 19:15:03 2017 +0000 +++ b/main.cpp Tue Jan 31 19:28:54 2017 +0000 @@ -37,14 +37,33 @@ unsigned short u16Last_p19 = 0; unsigned short u16Last_p20 = 0; -void signal_analog() -{ - t1->signal_set(1); -} - +unsigned char currentTimer = 0; void signal_digital() { - t2->signal_set(1); + currentTimer++; + + switch (currentTimer) + { + case 2: + case 4: + case 6: + case 8: + { + t2->signal_set(1); + break; + } + case 5: + { + t1->signal_set(1); + break; + } + case 10: + t2->signal_set(1); + t1->signal_set(1); + currentTimer = 0; + break; + } + t2->signal_set(2); } unsigned short moyenne_mobile(MovingAverage_t* MA, unsigned short newData) @@ -134,7 +153,8 @@ bool bP16 = en_2->read(); // prise en charge du phénomène de rebond - wait_ms(50); // :') + t2->signal_clr(2); + t2->signal_wait(2); // :') // génération éventuelle d'un événement if (en_1->read() == bP15 && bP15 != bLast_p15) @@ -191,11 +211,9 @@ t2->start(lecture_num); t3->start(collection); - Ticker tick1; - Ticker tick2; + Ticker tick; - tick1.attach(&signal_digital, 0.1); - tick2.attach(&signal_analog, 0.25); + tick.attach(&signal_digital, 0.05); // tick aux 50ms while(true) { }