timer0

Dependents:   09_PT1000 10_PT1000 11_PT1000 18_PT1000

Files at this revision

API Documentation at this revision

Comitter:
rs27
Date:
Fri Aug 08 16:02:01 2014 +0000
Parent:
0:bbd867fd30d1
Child:
2:d8e4c9bfd51d
Commit message:
08.08.14

Changed in this revision

timer0.cpp Show annotated file Show diff for this revision Revisions of this file
timer0.h Show annotated file Show diff for this revision Revisions of this file
--- a/timer0.cpp	Sat Jul 26 07:27:37 2014 +0000
+++ b/timer0.cpp	Fri Aug 08 16:02:01 2014 +0000
@@ -12,6 +12,8 @@
       CountDownTimers[i].status = 0xFF;
   
     ticker.attach_us(this, &timer0::func, 1000);
+    
+    countMillisecond = 0;
 }
 
 //--------------------------------------------------------
@@ -20,13 +22,16 @@
 {
     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) 
-        {       // 10 ms
+        {      
             if (CountDownTimers[i].count_timer > 0)
                 CountDownTimers[i].count_timer -- ;
             if (CountDownTimers[i].count_timer == 0)
@@ -34,6 +39,25 @@
         }
     }
 
+    //---------------------------------------------------------
+    // 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;
+            }
+        }
+    }
+
 }
 
 //--------------------------------------------------------
--- a/timer0.h	Sat Jul 26 07:27:37 2014 +0000
+++ b/timer0.h	Fri Aug 08 16:02:01 2014 +0000
@@ -25,6 +25,7 @@
   
   public:
     uint16_t counter;
+    uint16_t countMillisecond;
     
     timer0();
     void func(void);