#include "btn.h"
#include "rgb.h"
#include "tmr.h"
+#include "tmr32.h"
#include "task.h"
#include "adc_random.h"
-#define AUTO_OFF_COUNT 549316UL /* 5 hrs in 32.768 ms units */
-#define AUTO_ON_COUNT 2087402UL /* 19 hrs in 32.768 ms units */
+#if 1
+#define AUTO_OFF_COUNT 1800U /* 1 hr in 2 sec units */
+#define AUTO_ON_COUNT 19800U /* 11 hrs in 2 sec units */
+#else
+#define AUTO_OFF_COUNT 9000U /* 5 hrs in 2 sec units */
+#define AUTO_ON_COUNT 34200U /* 19 hrs in 2 sec units */
+#endif
#define leds_set(r,g,b,w) rgb_set((r).value >> 7, (g).value >> 7, \
(b).value >> 7, 0)
#define dbgpin_init() do { \
tmr_stop(TMR_FADE);
rgb_off();
dbgpin_low();
+ SLEEP();
on = 0;
}
void rs_task()
{
+ btn_rsen();
switch (btn_rs()) {
case BTN_RS_OFF:
- tmr_stop(TMR_AUTO_OFFON);
+ tmr32_set(0);
turnOff();
break;
case BTN_RS_RIGHT:
- tmr_start(TMR_AUTO_OFFON, AUTO_OFF_COUNT);
+ tmr32_set(AUTO_OFF_COUNT);
/* fall through */
case BTN_RS_LEFT:
turnOn();
break;
}
- btn_rsen();
}
void fade_task()
if (on) {
turnOff();
if (btn_rs() == BTN_RS_RIGHT)
- tmr_start(TMR_AUTO_OFFON, AUTO_ON_COUNT);
+ tmr32_set(AUTO_ON_COUNT);
} else /* off */ {
turnOn();
if (btn_rs() == BTN_RS_RIGHT)
- tmr_start(TMR_AUTO_OFFON, AUTO_OFF_COUNT);
+ tmr32_set(AUTO_OFF_COUNT);
}
}
case TASK_INCOLOR: /* in-color timer has fired */
start_fade();
break;
- case TASK_AUTO_OFFON: /* auto on/off timer has fired */
+ case TASK_TMR32: /* auto on/off event */
auto_offon_task();
break;
}
btn_init();
rgb_init();
tmr_init();
+ tmr32_init();
task_init();
dbgpin_init();