timer 0 mit Sekunden
Fork of timer0 by
Diff: timer0.cpp
- Revision:
- 1:cd53b287f41b
- Parent:
- 0:bbd867fd30d1
--- a/timer0.cpp Sat Jul 26 07:27:37 2014 +0000 +++ b/timer0.cpp Sun Aug 03 19:12:56 2014 +0000 @@ -12,6 +12,8 @@ CountDownTimers[i].status = 0xFF; ticker.attach_us(this, &timer0::func, 1000); + + countMillisecond = 0; } //-------------------------------------------------------- @@ -20,9 +22,12 @@ { uint8_t i; + countMillisecond++; + if(counter != 0) counter--; // ----- count down timers in ms ------------------------------------------------- + for (i=0; i<TIMER0_NUM_COUNTDOWNTIMERS; i++) { if (CountDownTimers[i].status == 1) @@ -34,6 +39,26 @@ } } + //--------------------------------------------------------- + // count down timer für Sekunden + + if (countMillisecond >= 1000) + { + countMillisecond = 0; + + // ----- count down timers in Sekunden ------------------------------------------------- + + for (i=0; i<TIMER0_NUM_COUNTDOWNTIMERS; i++) + { + if (CountDownTimers[i].status == 2) + { + if (CountDownTimers[i].count_timer > 0) + CountDownTimers[i].count_timer -- ; + if (CountDownTimers[i].count_timer == 0) + CountDownTimers[i].status = 0; + } + } + } } //--------------------------------------------------------