132
132
#define STROBE_BRIGHTNESS MAX_LEVEL
135
// try to auto-detect how many eeprom bytes
136
// FIXME: detect this better, and assign offsets better, for various configs
135
#if defined(USE_CANDLE_MODE) || defined(USE_BIKE_FLASHER_MODE) || defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE) || defined(USE_LIGHTNING_MODE)
136
#define USE_STROBE_STATE
139
// auto-detect how many eeprom bytes
137
140
#define USE_EEPROM
138
#ifdef USE_INDICATOR_LED
139
#define EEPROM_BYTES 15
140
#elif defined(USE_THERMAL_REGULATION)
141
#define EEPROM_BYTES 14
143
#define EEPROM_BYTES 12
145
ramp_discrete_floor_e,
146
ramp_discrete_ceil_e,
147
ramp_discrete_steps_e,
148
#ifdef USE_STROBE_STATE
151
#if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
155
#ifdef USE_BIKE_FLASHER_MODE
156
bike_flasher_brightness_e,
159
#ifdef USE_MUGGLE_MODE
160
muggle_mode_active_e,
162
#ifdef USE_THERMAL_REGULATION
166
#ifdef USE_INDICATOR_LED
167
indicator_led_mode_e,
171
#define EEPROM_BYTES eeprom_indexes_e_END
145
173
#ifdef START_AT_MEMORIZED_LEVEL
146
174
#define USE_EEPROM_WL
147
175
#define EEPROM_WL_BYTES 1
167
195
uint8_t steady_state(EventPtr event, uint16_t arg);
168
196
uint8_t ramp_config_state(EventPtr event, uint16_t arg);
169
197
// party and tactical strobes
170
#if defined(USE_CANDLE_MODE) || defined(USE_BIKE_FLASHER_MODE) || defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE) || defined(USE_LIGHTNING_MODE)
171
#define USE_STROBE_STATE
198
#ifdef USE_STROBE_STATE
172
199
uint8_t strobe_state(EventPtr event, uint16_t arg);
174
201
#ifdef USE_BATTCHECK
1605
1632
void load_config() {
1606
1633
if (load_eeprom()) {
1607
ramp_style = eeprom[0];
1608
ramp_smooth_floor = eeprom[1];
1609
ramp_smooth_ceil = eeprom[2];
1610
ramp_discrete_floor = eeprom[3];
1611
ramp_discrete_ceil = eeprom[4];
1612
ramp_discrete_steps = eeprom[5];
1634
ramp_style = eeprom[ramp_style_e];
1635
ramp_smooth_floor = eeprom[ramp_smooth_floor_e];
1636
ramp_smooth_ceil = eeprom[ramp_smooth_ceil_e];
1637
ramp_discrete_floor = eeprom[ramp_discrete_floor_e];
1638
ramp_discrete_ceil = eeprom[ramp_discrete_ceil_e];
1639
ramp_discrete_steps = eeprom[ramp_discrete_steps_e];
1613
1640
#if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
1614
strobe_type = eeprom[6]; // TODO: move this to eeprom_wl?
1615
strobe_delays[0] = eeprom[7];
1616
strobe_delays[1] = eeprom[8];
1641
strobe_type = eeprom[strobe_type_e]; // TODO: move this to eeprom_wl?
1642
strobe_delays[0] = eeprom[strobe_delays_0_e];
1643
strobe_delays[1] = eeprom[strobe_delays_1_e];
1618
1645
#ifdef USE_BIKE_FLASHER_MODE
1619
bike_flasher_brightness = eeprom[9];
1646
bike_flasher_brightness = eeprom[bike_flasher_brightness_e];
1621
beacon_seconds = eeprom[10];
1648
beacon_seconds = eeprom[beacon_seconds_e];
1622
1649
#ifdef USE_MUGGLE_MODE
1623
muggle_mode_active = eeprom[11];
1650
muggle_mode_active = eeprom[muggle_mode_active_e];
1625
1652
#ifdef USE_THERMAL_REGULATION
1626
therm_ceil = eeprom[12];
1627
therm_cal_offset = eeprom[13];
1653
therm_ceil = eeprom[therm_ceil_e];
1654
therm_cal_offset = eeprom[therm_cal_offset_e];
1629
1656
#ifdef USE_INDICATOR_LED
1630
indicator_led_mode = eeprom[14];
1657
indicator_led_mode = eeprom[indicator_led_mode_e];
1633
1660
#ifdef START_AT_MEMORIZED_LEVEL
1640
1667
void save_config() {
1641
eeprom[0] = ramp_style;
1642
eeprom[1] = ramp_smooth_floor;
1643
eeprom[2] = ramp_smooth_ceil;
1644
eeprom[3] = ramp_discrete_floor;
1645
eeprom[4] = ramp_discrete_ceil;
1646
eeprom[5] = ramp_discrete_steps;
1668
eeprom[ramp_style_e] = ramp_style;
1669
eeprom[ramp_smooth_floor_e] = ramp_smooth_floor;
1670
eeprom[ramp_smooth_ceil_e] = ramp_smooth_ceil;
1671
eeprom[ramp_discrete_floor_e] = ramp_discrete_floor;
1672
eeprom[ramp_discrete_ceil_e] = ramp_discrete_ceil;
1673
eeprom[ramp_discrete_steps_e] = ramp_discrete_steps;
1647
1674
#if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
1648
eeprom[6] = strobe_type; // TODO: move this to eeprom_wl?
1649
eeprom[7] = strobe_delays[0];
1650
eeprom[8] = strobe_delays[1];
1675
eeprom[strobe_type_e] = strobe_type; // TODO: move this to eeprom_wl?
1676
eeprom[strobe_delays_0_e] = strobe_delays[0];
1677
eeprom[strobe_delays_1_e] = strobe_delays[1];
1652
1679
#ifdef USE_BIKE_FLASHER_MODE
1653
eeprom[9] = bike_flasher_brightness;
1680
eeprom[bike_flasher_brightness_e] = bike_flasher_brightness;
1655
eeprom[10] = beacon_seconds;
1682
eeprom[beacon_seconds_e] = beacon_seconds;
1656
1683
#ifdef USE_MUGGLE_MODE
1657
eeprom[11] = muggle_mode_active;
1684
eeprom[muggle_mode_active_e] = muggle_mode_active;
1659
1686
#ifdef USE_THERMAL_REGULATION
1660
eeprom[12] = therm_ceil;
1661
eeprom[13] = therm_cal_offset;
1687
eeprom[therm_ceil_e] = therm_ceil;
1688
eeprom[therm_cal_offset_e] = therm_cal_offset;
1663
1690
#ifdef USE_INDICATOR_LED
1664
eeprom[14] = indicator_led_mode;
1691
eeprom[indicator_led_mode_e] = indicator_led_mode;