diff --git a/lambda-test/display-test.c b/lambda-test/display-test.c index e984fa6..d1e7c7e 100644 --- a/lambda-test/display-test.c +++ b/lambda-test/display-test.c @@ -34,13 +34,10 @@ assertTrue(beepCount == 1); assertTrue(beepLength == 2); - cycleDisplay(); - assertTrue(position == 2); - - cycleDisplay(); - assertTrue(position == 3); - - cycleDisplay(); + cycleDisplay(); // 2 + cycleDisplay(); // 3 + cycleDisplay(); // 4 + cycleDisplay(); // roll over to 0 assertTrue(position == 0); return true; diff --git a/lambda/display.c b/lambda/display.c index 9c50b5b..0a17a9b 100644 --- a/lambda/display.c +++ b/lambda/display.c @@ -24,8 +24,9 @@ #define MENU_OFF 0 #define MENU_MAX_VALUES 1 -#define MENU_LAST_TEXT 2 -#define MENU_TIME 3 +#define MENU_CURRENT 2 +#define MENU_LAST_TEXT 3 +#define MENU_TIME 4 uint8_t position = MENU_OFF; bool updatePending = false; @@ -62,6 +63,18 @@ } /** + * Formats the given heater current and displays it. + */ +static void displayCurrent(uint16_t const current) { + div_t ampsT = div(current, 1000); + + char line1[17]; + snprintf(line1, sizeof(line1), "%d.%02dA", + ampsT.quot, abs(ampsT.rem)); + setText(MSG_HEATING_CURRENT, line1); +} + +/** * Formats and displays the time since last start/reset. */ static void displayTime(void) { @@ -74,6 +87,7 @@ if (isAlertActive()) { // button pressed during alert cancelAlert(false); + lcd_clear(); updatePending = true; return; } @@ -112,6 +126,8 @@ displayMeas(measMax, "|>"); } else if (position == MENU_LAST_TEXT) { setText(lastLine0, lastLine1); + } else if (position == MENU_CURRENT) { + displayCurrent(measLatest.current); } else if (position == MENU_TIME) { displayTime(); } else { diff --git a/lambda/lambda.c b/lambda/lambda.c index 9fec629..26373a9 100644 --- a/lambda/lambda.c +++ b/lambda/lambda.c @@ -23,7 +23,6 @@ #include #include #include -#include #include "usart.h" #include "lcdroutines.h" #include "adc.h" @@ -50,9 +49,9 @@ alert_P(1, 2, 31, PSTR(MSG_WELCOME), PSTR(""), false); // spend some time on being polite - _delay_ms(3000); + while (getTime() < 3) {} setHeatingOn(true); - _delay_ms(1000); + while (getTime() < 4) {} uint32_t ints = 0; Measurement meas; diff --git a/lambda/messages.h b/lambda/messages.h index c5c7810..3b04ec9 100644 --- a/lambda/messages.h +++ b/lambda/messages.h @@ -36,6 +36,7 @@ #define MSG_HEATING_READY_1 "ready" #define MSG_HEATING_FAULT_0 "Oxygen sensor" #define MSG_HEATING_FAULT_1 "heating fault!" + #define MSG_HEATING_CURRENT "Heater current" #define MSG_TIME_SINCE_START "Time since start" #elif LANG == 1 @@ -62,6 +63,7 @@ #define MSG_HEATING_READY_1 "bereit" #define MSG_HEATING_FAULT_0 "Lambdasonden-" #define MSG_HEATING_FAULT_1 "heizung Fehler!" + #define MSG_HEATING_CURRENT "Heizstrom" #define MSG_TIME_SINCE_START "Zeit seit Start" #endif diff --git a/lambda/sensors.h b/lambda/sensors.h index 74ce199..f10c657 100644 --- a/lambda/sensors.h +++ b/lambda/sensors.h @@ -13,7 +13,8 @@ #include -#define SHUNT_MILLIOHMS 100 +/* 0.1 Ohm 10% measured 0.111 Ohm */ +#define SHUNT_MILLIOHMS 111 #define HEATING_READY_MA 1500 #define HEATING_SHORT_MA 9000 #define HEATING_DISCONN_MA 100