From: R. Steve McKown Date: Sat, 31 Dec 2011 21:23:31 +0000 (-0700) Subject: Extend candle flicker in most modes X-Git-Tag: 1.2 X-Git-Url: https://oss.titaniummirror.com/gitweb?p=rgblamp.git;a=commitdiff_plain;h=a3982b963fd174f5d267e88ad97388f1697f6f83 Extend candle flicker in most modes Flicker is not implemented in MODE_PARTY or when color is white. --- diff --git a/main.c b/main.c index 3c30660..4efecb5 100644 --- a/main.c +++ b/main.c @@ -74,7 +74,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 +182,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 +374,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();