+#define cfg_write(mode, color) do { \
+ eeprom_write(CFG_MODE_ADDR, (mode)); \
+ eeprom_write(CFG_COLOR_ADDR, (color)); \
+ } while (0)
+
+#define cfg_read(mode, color) do { \
+ unsigned char tmp; \
+ tmp = eeprom_read(CFG_MODE_ADDR); \
+ mode = (tmp < MODE_COUNT) ? tmp : MODE_SOLID; \
+ tmp = eeprom_read(CFG_COLOR_ADDR); \
+ color = (tmp < COLOR_COUNT) ? tmp : 0; \
+ } while (0)
+
+enum {
+ /* Operating modes */
+ MODE_SOLID = 0, /* Cycle through colors[][] before next mode */
+ //MODE_CANDLE,
+ MODE_CYCLE, /* 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 = 11,
+ 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_CYCLE, in 32.768 ms units */
+ PARTY_MIN = 8, /* Min party fade and incolor units */
+ PARTY_RANGE = 8, /* Party fade/incolor range mask for rand() */
+ /* ... see start_fade() */
+ CFG_MODE_ADDR = 0, /* EEPROM address of mode variable */
+ CFG_COLOR_ADDR, /* EEPROM address of color variable */
+ CFG_DELAY = 92, /* 3 seconds in 32.768 msec units */
+};
+