diff --git a/lambda/alert.c b/lambda/alert.c index 258487f..acd8a37 100644 --- a/lambda/alert.c +++ b/lambda/alert.c @@ -17,8 +17,8 @@ #include "pins.h" volatile uint8_t beepCount = 0; -volatile uint16_t beepLength = 0; -volatile uint8_t oscCount = 0; +volatile uint8_t beepLength = 0; +volatile uint16_t oscCount = 0; volatile static bool alertActive = false; volatile static bool keepActive = false; @@ -46,10 +46,10 @@ void beep(uint8_t const beeps, uint8_t const length, uint16_t const tone) { OCR1A = tone; if (TCNT1 >= tone) TCNT1 = 0; - oscCount = 0; - beepCount = beeps; ATOMIC_BLOCK(ATOMIC_FORCEON) { beepLength = length; + oscCount = 0; + beepCount = beeps; } } @@ -58,12 +58,12 @@ bool const keep) { OCR1A = tone; if (TCNT1 >= tone) TCNT1 = 0; - alertActive = true; - keepActive = keep; - oscCount = 0; - beepCount = beeps; ATOMIC_BLOCK(ATOMIC_FORCEON) { + alertActive = true; + keepActive = keep; beepLength = length; + oscCount = 0; + beepCount = beeps; } displayText(line0, line1); } diff --git a/lambda/command.c b/lambda/command.c index b7d6fdc..3b17dc4 100644 --- a/lambda/command.c +++ b/lambda/command.c @@ -98,7 +98,7 @@ if (fields[2] != '\0') { tone = atoi(fields[2]); } - beep(1, length, tone); + beep(3, length, tone); } else if (strcmp_P(fields[0], PSTR("sa")) == 0) { // set airgate diff --git a/lambda/rules.c b/lambda/rules.c index b39c2f3..64fd057 100644 --- a/lambda/rules.c +++ b/lambda/rules.c @@ -90,7 +90,8 @@ static void airgate25(bool* const fired, Measurement const meas) { if (state == burning_down && ! isAirgateBusy() && meas.tempI < TEMP_AIRGATE_25 && - meas.lambda >= LAMBDA_TOO_LEAN && getAirgate() > AIRGATE_25) { + meas.lambda >= LAMBDA_TOO_LEAN && + getAirgate() > AIRGATE_25) { setAirgate(AIRGATE_25); alert_P(BEEPS, LENGTH, TONE, PSTR(MSG_AIRGATE_25_0), PSTR(""), false); *fired = true; @@ -104,7 +105,8 @@ static void airgateClose(bool* const fired, Measurement const meas) { if (state == burning_down && ! isAirgateBusy() && meas.tempI < TEMP_AIRGATE_0 && - meas.lambda >= LAMBDA_MAX && getAirgate() > AIRGATE_CLOSE) { + meas.lambda >= LAMBDA_MAX && + getAirgate() > AIRGATE_CLOSE) { setHeaterState(heaterStateOff); closeAirgateAndSleep(); alert_P(BEEPS, LENGTH, TONE, @@ -123,8 +125,10 @@ */ static void tooRich(bool* const fired, Measurement const meas) { if (! isAirgateBusy() && - meas.tempI > TEMP_FIRE_OUT && meas.lambda < LAMBDA_TOO_RICH && - getHeaterState() == heaterStateReady && getAirgate() < AIRGATE_50) { + meas.tempI > TEMP_FIRE_OUT && + meas.lambda < LAMBDA_TOO_RICH && + getAirgate() < AIRGATE_50 && + getHeaterState() == heaterStateReady) { setAirgate(AIRGATE_50); alert_P(BEEPS, LENGTH, TONE, PSTR(MSG_AIRGATE_50_0), PSTR(""), false); *fired = true; @@ -137,8 +141,10 @@ */ static void tooLean(bool* const fired, Measurement const meas) { if (! isAirgateBusy() && - meas.tempI > TEMP_AIRGATE_50 && meas.lambda > LAMBDA_TOO_LEAN && - getHeaterState() == heaterStateReady && getAirgate() > AIRGATE_50) { + meas.tempI > TEMP_AIRGATE_50 && + meas.lambda > LAMBDA_TOO_LEAN && + getAirgate() > AIRGATE_50 && + getHeaterState() == heaterStateReady) { setAirgate(AIRGATE_50); alert_P(BEEPS, LENGTH, TONE, PSTR(MSG_AIRGATE_50_0), PSTR(""), false); *fired = true; @@ -167,7 +173,8 @@ */ static void warmStart(bool* const fired, Measurement const meas) { if (! *fired && state == firing_up && - meas.tempI > TEMP_FIRE_OUT && tempIMax >= TEMP_AIRGATE_50) { + meas.tempI > TEMP_FIRE_OUT && + tempIMax >= TEMP_AIRGATE_50) { setSleepMode(false); resetRules(false); tempIMax = meas.tempI; @@ -224,7 +231,7 @@ getHeaterState() == heaterStateFault) { return; } - if (getHeaterUptime() >= 1800 && meas.tempI < TEMP_FIRE_OUT && + if (getHeaterUptime() >= 1800 && meas.tempI < TEMP_HEATER_TIMEOUT && meas.lambda >= LAMBDA_MAX) { setHeaterState(heaterStateOff); closeAirgateAndSleep(); diff --git a/lambda/rules.h b/lambda/rules.h index f2f103f..e4e764f 100644 --- a/lambda/rules.h +++ b/lambda/rules.h @@ -40,9 +40,11 @@ */ #define TEMP_AIRGATE_0 450 /** Temperature at which to consider the fire to have gone out */ -#define TEMP_FIRE_OUT 90 +#define TEMP_FIRE_OUT 70 /** Min. temperature at which to consider the fire to fire up again */ -#define TEMP_FIRE_OUT_RESET 100 +#define TEMP_FIRE_OUT_RESET 80 +/** If the temp. is below this value, switch off the heater after a timeout */ +#define TEMP_HEATER_TIMEOUT 100 /** Max. lambda value that can be measured */ #define LAMBDA_MAX 2000 /** Combustion is considered too rich if lambda is below this value */