From: R. Steve McKown Date: Thu, 8 Dec 2011 03:49:00 +0000 (-0700) Subject: Use bit defs and some aesthetic cleanup X-Git-Tag: 1.0~39 X-Git-Url: https://oss.titaniummirror.com/gitweb?p=rgblamp.git;a=commitdiff_plain;h=2c0e3168697a040a21ee29a8dfe68d266fc98298 Use bit defs and some aesthetic cleanup --- diff --git a/main.c b/main.c index 9754ea0..fbf88d3 100644 --- a/main.c +++ b/main.c @@ -36,7 +36,7 @@ #define AUTO_OFF_COUNT 549316UL /* 5 hrs in 32.768 ms units */ #define reset_steps() do { incolor_steps = 1; fade_steps = 0; } \ - while (0) + while (0) #define rand_u8() (rand() & 0xff) #define rand_u16() ((rand() << 8) + rand_u8()) #define rand_incolor_steps(s) (min_incolor_steps[s & 3] + \ @@ -44,19 +44,16 @@ #define rand_fade_steps(s) (min_fade_steps[s & 3] + \ (rand() % range_fade_steps[s & 3])) #define leds_set(r,g,b,w) rgb_set((r).value >> 7, \ - (g).value >> 7, \ - (b).value >> 7, \ - 0) - -#define dbgpin_init() \ -do { \ - /* Set RA2 as output low */ \ - PORTA &= ~0x04; \ - TRISA &= ~0x04; \ -} while (0) - -#define dbgpin_high() PORTA |= 0x04; -#define dbgpin_low() PORTA &= ~0x04; + (g).value >> 7, \ + (b).value >> 7, \ + 0) +#define dbgpin_init() do { \ + /* Set RA2 as output low */ \ + RA2 = 0; \ + TRISA2 = 0; \ + } while (0) +#define dbgpin_high() RA2 = 1; +#define dbgpin_low() RA2 = 0; typedef struct { int value; @@ -148,7 +145,7 @@ int main(void) } leds_set(red, grn, blu, wht); } else if (--incolor_steps == 0) { - int newr, newg, newb, neww, tmp; + int newr, newg, newb, neww; /* Next led color. All off is not a valid option. * RGB values are stored and processed as 15-bit non-negative