]> oss.titaniummirror.com Git - rgblamp.git/commitdiff
Uses tmr, runs if already on, stops, will not wake
authorR. Steve McKown <rsmckown@gmail.com>
Thu, 8 Dec 2011 21:50:01 +0000 (14:50 -0700)
committerR. Steve McKown <rsmckown@gmail.com>
Thu, 8 Dec 2011 21:50:01 +0000 (14:50 -0700)
adc_random.c
buttons.c
tmr_defs.h

index d516d7fbc74b6802b1d4fe4a6f55aa3013c2ec27..e5e76940b762538c0a7ff8704d77c65a9e27fc92 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #include <htc.h>
-#include "timer.h"
+#include "tmr.h"
 
 unsigned char adc_random()
 {
@@ -28,7 +28,7 @@ unsigned char adc_random()
 
     /* Sample the ADC several times, accumulating the LSB of the result */
     for (unsigned i = 0; i < 128; i++) {
-        timer_uwait(10); /* Sampling time */
+        tmr_uwait(10); /* Sampling time */
         ADGO = 1; /* Start the conversion */
         while (ADGO); /* wait for completion */
         accumulate += ADRESL;
index 8ddd7ee2c94ff06fe10bc8e0bb51cc9ca51bee84..486fd5884a3d4f881e5b29e5d03fd5924081f99b 100644 (file)
--- a/buttons.c
+++ b/buttons.c
@@ -7,10 +7,13 @@
 
 #include <htc.h>
 #include "buttons.h"
-#include "timer.h"
+#include "tmr.h"
 
 void buttons_sleep()
 {
+    /* Turn off global interrupts.  Don't need to call the ISR */
+    GIE = 0;
+
     /* If the rocker is on, sleep until it is placed in the off position */
     IOCBN4 = 0; IOCBP4 = 1;
     IOCBN5 = 0; IOCBP5 = 1;
@@ -18,7 +21,7 @@ void buttons_sleep()
         IOCIE = 1;
         SLEEP();
         IOCIE = 0;
-        timer_mwait(50); /* debounce */
+        tmr_mwait(50); /* debounce */
     }
 
     /* Now that the rocker is off, sleep until it is turned on */
@@ -29,4 +32,7 @@ void buttons_sleep()
         SLEEP();
         IOCIE = 0;
     }
+
+    /* Turn global interrupts back on to activate the ISR. */
+    GIE = 0;
 }
index 34ffda5faf33ad410642d523be29dd05eaf59e39..cc6971165875c54f36f9606da196f49286934fe8 100644 (file)
@@ -14,7 +14,7 @@
  * accordingly.
  */
 enum {
-  TMR_AUTO_ONOFF = 0,
+  TMR_AUTO_OFFON = 0,
   TMR_FADE,
   TMR_DIM,
   TMR_BTN,