+/*
+ * Copyright © 2011, 2012, Titanium Mirror, Inc..
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - Neither the name of Titanium Mirror, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
/*
* File: main.c
*
BRIGHT_BOTTOM = -5, /* ... then down to bottom */
BRIGHT_MAX = 85, /* Bright values are constrained for computations */
BRIGHT_MIN = 1, /* ... by min and max. */
- BRIGHT_INIT = 42, /* later, get from eeprom */
- CBRIGHT_VARIANCE = 20, /* brightness range for candle flicker */
+ BRIGHT_INIT = 42, /* Initial value is replaced by value from eeprom */
+ CBRIGHT_VARIANCE = 20, /* Brightness range for candle flicker */
STD_FADE = 16, /* Fade time in 32.768 ms units */
STD_INCOLOR = 29491, /* Time in color when MODE_CYCLE, in 32.768 ms units */
PARTY_MIN = 8, /* Min party fade and incolor units */
btn_pben();
}
+/* Event on to off, either by switch or auto-off timer */
void turnOff()
{
- /* Event on to off, either by switch or auto-off timer */
tmr_stop(TMR_CFG);
tmr_stop(TMR_CANDLE);
tmr_stop(TMR_INCOLOR);
}
}
+/* The button is being held. Change the color magnitude. */
void pb_held()
{
- /* The button has been held. Change the color magnitude. */
if (bright_up) {
if (bright == BRIGHT_TOP)
bright_up = 0;
while ((tid = task_get(block)) >= 0) {
switch (tid) {
- case TASK_BTN_PB: /* pushbutton state change */
+ case TASK_BTN_PB:
pb_task();
break;
- case TASK_BTN_RS: /* rocker switch state change */
+ case TASK_BTN_RS:
rs_task();
break;
- case TASK_BTN_PB_HELD: /* pushbutton is being held down */
+ case TASK_BTN_PB_HELD:
pb_held_task();
break;
- case TASK_FADE: /* fade timer has fired */
+ case TASK_FADE:
fade_task();
break;
- case TASK_INCOLOR: /* in-color timer has fired */
+ case TASK_INCOLOR:
start_fade();
break;
- case TASK_CANDLE: /* periodic adjustment for candle flicker */
+ case TASK_CANDLE:
candle_task();
break;
- case TASK_TMR32: /* auto on/off event */
+ case TASK_TMR32:
auto_offon_task();
break;
- case TASK_CFG: /* Save config to EEPROM event */
+ case TASK_CFG:
cfg_write();
break;
}