From 698738a17bf7abfe8729609a62d5b8c14eb9753a Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Thu, 15 Jun 2017 20:43:37 +0200 Subject: [PATCH] thermometer engine blocked state introduced --- my_src/hmi.c | 14 +++++++++++--- my_src/hmi.h | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/my_src/hmi.c b/my_src/hmi.c index 28b7b82..84721e5 100644 --- a/my_src/hmi.c +++ b/my_src/hmi.c @@ -20,6 +20,7 @@ const uint32_t STORAGE_MAGIC = 0xaffe000a; const uint8_t COLD_COUNT_THRESHOLD = 40; const uint32_t HOT_TEMPERATURE_THRESHOLD = 5; +const char THERMOMETER_STATE_MARKS[TE_LAST] = {'I', 'H', 'C', 'C', 'C', 'B'}; @@ -66,7 +67,7 @@ void updateDisplay(void *handle) { LED_P8x16Str(0, 4, buf); - sprintf(buf, " %5ds", lDisplay->overrunTime); + sprintf(buf, "%c %5ds", THERMOMETER_STATE_MARKS[lDisplay->thermometerEngineState], lDisplay->overrunTime); // static uint32_t h = 0; // static uint32_t c = 0; // uint32_t i = HAL_GetTick(); @@ -103,19 +104,25 @@ void thermometerEngine(void *handle) { break; case TE_CONFIRMED: disableAlarm(); - lDisplay->thermometerEngineState = TE_IDLE; + lDisplay->thermometerEngineState = TE_BLOCKED; + break; + case TE_BLOCKED: break; default: lDisplay->thermometerEngineState = TE_IDLE; } } -void thermometerEngineConfirmAlarm() { +static void thermometerEngineConfirmAlarm() { if (display.thermometerEngineState == TE_UNCONFIRMED) { display.thermometerEngineState = TE_CONFIRMED; } } +static void thermometerEngineUnblock() { + display.thermometerEngineState = TE_IDLE; +} + void hmiInit() { eepromRead(STORAGE_ADDRESS, &storage, sizeof(storage)); if (storage.magic == STORAGE_MAGIC) { @@ -222,6 +229,7 @@ void buttonShort() { thermometerEngineConfirmAlarm(); } else if (display.timerState == RUNNING || display.timerState == OVERRUN) { stopTimer(); + thermometerEngineUnblock(); disableAlarm(); } } diff --git a/my_src/hmi.h b/my_src/hmi.h index 9c98bea..ad0e02c 100644 --- a/my_src/hmi.h +++ b/my_src/hmi.h @@ -14,7 +14,7 @@ -typedef enum { TE_IDLE, TE_HOT, TE_COLD, TE_UNCONFIRMED, TE_CONFIRMED } tThermometerEngineState; +typedef enum { TE_IDLE = 0, TE_HOT, TE_COLD, TE_UNCONFIRMED, TE_CONFIRMED, TE_BLOCKED, TE_LAST } tThermometerEngineState; typedef struct { uint32_t toggle;