From: R. Steve McKown Date: Sat, 17 Dec 2011 02:34:43 +0000 (-0700) Subject: Aesthetic cleanups X-Git-Tag: 1.0~7 X-Git-Url: https://oss.titaniummirror.com/gitweb?p=rgblamp.git;a=commitdiff_plain;h=197b6fb1de7321b9c7ca7ddd906076acd580c6fc Aesthetic cleanups --- diff --git a/main.c b/main.c index c258972..738362c 100644 --- a/main.c +++ b/main.c @@ -62,27 +62,33 @@ #define dbgpin_toggle() (RA2 = (LATA2 == 0) ? 1 : 0) enum { - HELD_TMR_PERIODS = 1, /* Held timer fires every 32.768 msec */ - HELD_PERIODS = 16, /* Held this long before held events fire */ - COLOR_WHITE = 0, - COLOR_COUNT = 19, - BRIGHT_TOP = 100, - BRIGHT_BOTTOM = -5, - BRIGHT_MAX = 85, - BRIGHT_MIN = 1, - BRIGHT_INIT = 42, /* later, get from eeprom */ - - MODE_SOLID = 0, + /* Operating modes */ + MODE_SOLID = 0, /* Cycle through colors[][] before next mode */ //MODE_CANDLE, - MODE_FADE, - MODE_PARTY, + MODE_FADE, /* Auto cycle through colors */ + MODE_PARTY, /* Random yet fast incolor and fade */ MODE_COUNT, + /* Indexes in colors[][] for LEDs */ LED_RED = 0, LED_GRN, LED_BLU, LED_WHT, LED_COUNT, + + HELD_TMR_PERIODS = 1, /* Held timer fires every 32.768 msec */ + HELD_PERIODS = 16, /* Held this long before held events fire */ + COLOR_WHITE = 0, /* Color index for white */ + COLOR_COUNT = 19, + BRIGHT_TOP = 100, /* Bright ramps up to top ... */ + 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 */ + STD_FADE = 16, /* Fade time in 32.768 ms units */ + STD_INCOLOR = 29491, /* Time in color when MODE_FADE, in 32.768 ms units */ + PARTY_MIN = 8, /* Min party fade and incolor units */ + PARTY_RANGE = 8, /* Party fade/incolor range (max = min+range) */ }; typedef struct { @@ -114,11 +120,6 @@ const unsigned char colors[COLOR_COUNT][LED_COUNT] = { { 3, 3, 3, 3 }, }; -const static int std_fade = 16; -const static int std_incolor = 29491; -const static int party_min = 8; -const static int party_range = 8; - unsigned char mode = MODE_SOLID; unsigned char color = COLOR_WHITE; led_t red; @@ -167,16 +168,16 @@ void leds_set() void start_fade() { /* RGB PWM values are 8 bits, but computations are done in 15 - * (leaving room for a sign bit), so leds_set() uses >>7 to convert - * to PWM values. - */ + * (leaving room for a sign bit), so leds_set() uses >>7 to convert + * to PWM values. + */ int newr, newg, newb, neww; /* Select the destination color and fade-to time depending upon mode. */ - fade_steps = std_fade; + fade_steps = STD_FADE; if (mode == MODE_PARTY) { color = rand() % COLOR_COUNT; - fade_steps = party_min + (rand() % party_range); + fade_steps = PARTY_MIN + (rand() % PARTY_RANGE); } else if (mode == MODE_FADE) { if (++color == COLOR_COUNT) color = 0; @@ -324,9 +325,9 @@ void fade_task() wht.value += wht.remainder; tmr_stop(TMR_FADE); if (mode == MODE_FADE) - tmr_start(TMR_INCOLOR, std_incolor); + tmr_start(TMR_INCOLOR, STD_INCOLOR); else if (mode == MODE_PARTY) - tmr_start(TMR_INCOLOR, party_min + (rand() % party_range)); + tmr_start(TMR_INCOLOR, PARTY_MIN + (rand() % PARTY_RANGE)); } leds_set(); } @@ -372,7 +373,7 @@ void user_tasks(unsigned char block) case TASK_BTN_RS: /* rocker switch state change */ rs_task(); break; - case TASK_BTN_PB_HELD: /* pushbutton is being held down */ + case TASK_BTN_PB_HELD: /* pushbutton is being held down */ pb_held_task(); break; case TASK_FADE: /* fade timer has fired */