]> oss.titaniummirror.com Git - rgblamp.git/blobdiff - main.c
Clock loop start to loop start using Timer 0
[rgblamp.git] / main.c
diff --git a/main.c b/main.c
index 4f36d146b1133f58aa7e32e07ddd4c05f9fc5831..b998176d06e98b1a497434ee09c715b72f419b3b 100644 (file)
--- a/main.c
+++ b/main.c
 #include <htc.h>
 #include <stdlib.h>
 #include "picinit.h"
+#include "unused.h"
 #include "buttons.h"
 #include "rgb.h"
-#include "unused.h"
+#include "timer.h"
 
-#define STEP_SIZE               32 /* ms */
 #define reset_steps()           do { incolor_steps = 1; fade_steps = 0; } \
                                   while (0)
 #define rand_u8()               (rand() & 0xff)
@@ -90,6 +90,7 @@ int main(void)
     unused_init();
     buttons_init();
     rgb_init();
+    timer_init();
     dbgpin_init();
 
     reset_steps();
@@ -153,7 +154,7 @@ int main(void)
               wht.remainder = neww - (wht.value + wht.increment * fade_steps);
             }
             dbgpin_low();
-            __delay_ms(STEP_SIZE); /* step should be start to start... */
+            timer_owait(); /* wait 32 ms since last return from last call() */
             dbgpin_high();
         } else {
             rgb_off();