63
64
* Settings to modify per driver
66
#define VOLTAGE_MON // Comment out to disable
67
//#define VOLTAGE_MON // Comment out to disable
68
69
#define MEMORY // Comment out to disable
71
#define TICKS_250MS // If enabled, ticks are every 250 ms. If disabled, ticks are every 500 ms
72
// Affects turbo timeout/rampdown timing
70
74
// Levels should start around 10 with Fast PWM
72
76
#define MODE_MOON 3 // Can comment out to remove mode, but should be set through soldering stars
73
77
#define MODE_LOW 14 // Can comment out to remove mode
74
78
#define MODE_MED 39 // Can comment out to remove mode
75
#define MODE_HIGH_W_TURBO 110 // MODE_HIGH value when turbo is enabled
76
#define MODE_HIGH 255 // Can comment out to remove mode
79
//#define MODE_HIGH 255 // Can comment out to remove mode
77
80
#define MODE_TURBO 255 // Can comment out to remove mode
78
#define TURBO_TIMEOUT 240 // How many WTD ticks before before dropping down (.5 sec each)
81
#define MODE_TURBO_LOW 140 // Level turbo ramps down to if turbo enabled
82
#define TURBO_TIMEOUT 240 // How many WTD ticks before before dropping down
83
#define TURBO_RAMP_DOWN // By default we will start to gradually ramp down, once TURBO_TIMEOUT ticks are reached, 1 PWM_LVL each tick until reaching MODE_TURBO_LOW PWM_LVL
84
// If commented out, we will step down to MODE_TURBO_LOW once TURBO_TIMEOUT ticks are reached
80
86
#define FAST_PWM_START 8 // Above what output level should we switch from phase correct to fast-PWM?
81
87
#define DUAL_PWM_START 8 // Above what output level should we switch from the alternate PWM output to both PWM outputs? Comment out to disable alternate PWM output
202
203
inline void WDT_on() {
203
// Setup watchdog timer to only interrupt, not reset, every 500ms.
204
// Setup watchdog timer to only interrupt, not reset
204
205
cli(); // Disable interrupts
205
206
wdt_reset(); // Reset the WDT
206
207
WDTCR |= (1<<WDCE) | (1<<WDE); // Start timed sequence
209
WDTCR = (1<<WDTIE) | (1<<WDP2); // Enable interrupt every 250ms
207
211
WDTCR = (1<<WDTIE) | (1<<WDP2) | (1<<WDP0); // Enable interrupt every 500ms
208
213
sei(); // Enable interrupts
272
277
#ifdef MODE_TURBO
273
278
//if (ticks == TURBO_TIMEOUT && modes[mode_idx] == MODE_TURBO) { // Doesn't make any sense why this doesn't work
274
if (ticks == TURBO_TIMEOUT && mode_idx == (mode_cnt - 1)) {
279
if (ticks >= TURBO_TIMEOUT && mode_idx == (mode_cnt - 1) && PWM_LVL > MODE_TURBO_LOW) {
280
#ifdef TURBO_RAMP_DOWN
281
set_output(PWM_LVL - 1);
275
283
// Turbo mode is always at end
276
set_output(modes[--mode_idx]);
277
store_mode_idx(mode_idx);
284
set_output(MODE_TURBO_LOW);
285
if (MODE_TURBO_LOW <= modes[mode_idx-1]) {
286
// Dropped at or below the previous mode, so set it to the stored mode
287
// Kept this as it was the same functionality as before. For the TURBO_RAMP_DOWN feature
288
// it doesn't do this logic because I don't know what makes the most sense
289
store_mode_idx(--mode_idx);