diff --git a/lambda/display.c b/lambda/display.c index 8b168d6..2975e7d 100644 --- a/lambda/display.c +++ b/lambda/display.c @@ -38,9 +38,7 @@ /** * Sets the given two lines of text on the display. Right-pads with whitespace - * so each line is always completely overwritten. This seems to be more - * efficient than clearing the display only when necessary which even garbles it - * sometimes. + * so each line is always completely overwritten. */ static void setText(const char* const line0, const char* const line1) { char line0padded[17]; @@ -64,8 +62,12 @@ char line0[17]; char line1[17]; snprintf(line0, sizeof(line0), "Ti %3dC To %3dC ", meas.tempI, meas.tempO); - snprintf(line1, sizeof(line1), "L %d.%02d %s %s", - lambdaT.quot, abs(lambdaT.rem), toInfo(lambdax100), hint); + if (getHeatingState() == HEATING_READY || position == MENU_MAX_VALUES) { + snprintf(line1, sizeof(line1), "L %d.%02d %s %s", + lambdaT.quot, abs(lambdaT.rem), toInfo(lambdax100), hint); + } else { + snprintf(line1, sizeof(line1), "L -%12s", hint); + } setText(line0, line1); } diff --git a/lambda/lambda.c b/lambda/lambda.c index 26373a9..67d3356 100644 --- a/lambda/lambda.c +++ b/lambda/lambda.c @@ -58,17 +58,13 @@ // main loop while (true) { - if (! isSimulation() && getInts() >= ints + INTS_PER_SEC && - getHeatingState() != HEATING_FAULT) { + if (! isSimulation() && getInts() >= ints + INTS_PER_SEC) { ints = getInts(); meas = measure(); if (isLogging()) { logMeas(meas); } - if (getHeatingState() == HEATING_OFF || - getHeatingState() == HEATING_READY) { - updateMeas(meas); - } + updateMeas(meas); reason(meas); } if (! isSimulation()) { diff --git a/lambda/rules.c b/lambda/rules.c index 86cd15b..5376b51 100644 --- a/lambda/rules.c +++ b/lambda/rules.c @@ -136,7 +136,7 @@ */ static void heatingTimeout(bool* const fired, int8_t const dir, Measurement const meas) { - if (isHeatingOn() && getTime() > 10800 && meas.tempI < 400) { + if (isHeatingOn() && getTime() >= 10800 && meas.tempI < 400) { setHeatingOn(false); } } diff --git a/lambda/sensors.c b/lambda/sensors.c index 13768f3..48ab4d8 100644 --- a/lambda/sensors.c +++ b/lambda/sensors.c @@ -91,9 +91,13 @@ tempOVoltageAvg = tempOVoltage + tempOVoltageAvg - ((tempOVoltageAvg - 4) >> 3); - uint32_t lambdaVoltage = linADC(getVoltage(ADC_LAMBDA)); - lambdaVoltageAvg = lambdaVoltage + lambdaVoltageAvg - - ((lambdaVoltageAvg - 4) >> 3); + if (heatingState == HEATING_READY) { + uint32_t lambdaVoltage = linADC(getVoltage(ADC_LAMBDA)); + lambdaVoltageAvg = lambdaVoltage + lambdaVoltageAvg - + ((lambdaVoltageAvg - 4) >> 3); + } else { + lambdaVoltageAvg = 44 << 3; + } uint16_t heatingVoltage = linADC(getVoltage(ADC_HEATING));