]> oss.titaniummirror.com Git - rgblamp.git/blobdiff - main.c
Remove unused timer definition
[rgblamp.git] / main.c
diff --git a/main.c b/main.c
index 3c3066075c1bc9983bc5c62a6e41727133d19137..0ca9cdc69c1983806c766eecfb6a3293f75b5d6c 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,3 +1,32 @@
+/*
+ * 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
  *
@@ -74,7 +103,7 @@ enum {
   HELD_TMR_PERIODS = 1,  /* Held timer fires every 32.768 msec */
   HELD_PERIODS = 16,     /* Held this long before held events fire */
   COLOR_COUNT = 12,
-  COLOR_CANDLE = 0,      /* Color index for white */
+  COLOR_CANDLE = 0,      /* Color index for the candle color */
   COLOR_WHITE = 11,      /* Color index for white */
   BRIGHT_TOP = 100,      /* Bright ramps up to top ... */
   BRIGHT_BOTTOM = -5,    /* ... then down to bottom */
@@ -182,7 +211,7 @@ void leds_set()
   signed char b;
 
   /* Use correct brightness value, then constrain it */
-  if (mode == MODE_SOLID && color == COLOR_CANDLE)
+  if (mode != MODE_PARTY && color != COLOR_WHITE)
     b = cbright;
   else
     b = bright;
@@ -374,13 +403,15 @@ void fade_task()
     wht.value += wht.remainder;
     tmr_stop(TMR_CANDLE);
     tmr_stop(TMR_FADE);
-    if (mode == MODE_CYCLE)
-      tmr_start(TMR_INCOLOR, STD_INCOLOR);
-    else if (mode == MODE_PARTY)
+    if (mode == MODE_PARTY)
       tmr_start(TMR_INCOLOR, PARTY_MIN + (lfsr_get() % PARTY_RANGE));
-    else if (mode == MODE_SOLID && color == COLOR_CANDLE) {
-      cbright = bright - CBRIGHT_VARIANCE / 2;
-      tmr_startPeriodic(TMR_CANDLE, 1);
+    else {
+      if (mode == MODE_CYCLE)
+        tmr_start(TMR_INCOLOR, STD_INCOLOR);
+      if (color != COLOR_WHITE) {
+        cbright = bright - CBRIGHT_VARIANCE / 2;
+        tmr_startPeriodic(TMR_CANDLE, 1);
+      }
     }
   }
   leds_set();