timer 0 mit Sekunden

Dependents:   16_PT1000

Fork of timer0 by Reinhold Schaefer

Files at this revision

API Documentation at this revision

Comitter:
rs27
Date:
Sun Aug 03 19:12:56 2014 +0000
Parent:
0:bbd867fd30d1
Commit message:
Sekunden Timer integriert

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	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;
+            }
+        }
+    }
 }
 
 //--------------------------------------------------------
--- a/timer0.h	Sat Jul 26 07:27:37 2014 +0000
+++ b/timer0.h	Sun Aug 03 19:12:56 2014 +0000
@@ -25,6 +25,7 @@
   
   public:
     uint16_t counter;
+    uint16_t countMillisecond;
     
     timer0();
     void func(void);