diff --git a/Core/Inc/vehicle_state.h b/Core/Inc/vehicle_state.h index 635baf0..086306d 100644 --- a/Core/Inc/vehicle_state.h +++ b/Core/Inc/vehicle_state.h @@ -46,15 +46,23 @@ typedef enum { INICHK_START = 0, INICHK_WD_CHECK = 1, INICHK_WD_OK = 2, - INICHK_ASB_CHECK_1 = 3, - INICHK_ASB_CHECK_2 = 4, - INICHK_WAIT_TS = 5, - INICHK_EBS_CHECK_A = 6, - INICHK_EBS_CHECK_B = 7, - INICHK_DONE = 8, - INICHK_ERROR = 9 + INICHK_POS_CHK_1 = 3, + INICHK_ASB_CHECK_A_1 = 4, + INICHK_ASB_CHECK_A_2 = 5, + INICHK_SWITCH_B = 6, + INICHK_ASB_CHECK_B_1 = 7, + INICHK_ASB_CHECK_B_2 = 8, + INICHK_SWITCH_A = 9, + INICHK_ASB_CHECK_AB_1 = 10, + INICHK_ASB_CHECK_AB_2 = 11, + INICHK_POS_CHK_2 = 12, + INICHK_WAIT_TS = 13, + INICHK_DONE = 14, + INICHK_ERROR = 15 } IniChkState; +const char *inichkstate_str(IniChkState state); + typedef enum { AMS_ERROR_NONE = 0x00, AMS_ERROR_SLAVE_TIMEOUT = 0x01, diff --git a/Core/Src/vehicle_state.c b/Core/Src/vehicle_state.c index e170181..a4034ed 100644 --- a/Core/Src/vehicle_state.c +++ b/Core/Src/vehicle_state.c @@ -1,3 +1,41 @@ #include "vehicle_state.h" VehicleState vehicle_state = {0}; + +const char *inichkstate_str(IniChkState state) { + switch (vehicle_state.ini_chk_state) { + case INICHK_START: + return "START"; + case INICHK_WD_CHECK: + return "WD CHK"; + case INICHK_WD_OK: + return "WD OK"; + case INICHK_POS_CHK_1: + return "POS CHK 1"; + case INICHK_ASB_CHECK_A_1: + return "ASB CHK A1"; + case INICHK_ASB_CHECK_A_2: + return "ASB CHK A2"; + case INICHK_SWITCH_B: + return "SWITCH B"; + case INICHK_ASB_CHECK_B_1: + return "ASB CHK B1"; + case INICHK_ASB_CHECK_B_2: + return "ASB CHK B2"; + case INICHK_SWITCH_A: + return "SWITCH A"; + case INICHK_ASB_CHECK_AB_1: + return "ASB CHK AB1"; + case INICHK_ASB_CHECK_AB_2: + return "ASB CHK AB2"; + case INICHK_POS_CHK_2: + return "POS CHK 2"; + case INICHK_WAIT_TS: + return "WAIT TS"; + case INICHK_DONE: + return "DONE"; + case INICHK_ERROR: + return "ERROR"; + } + return "UNKNOWN"; +} diff --git a/TouchGFX/gui/src/ami_screen/AMIView.cpp b/TouchGFX/gui/src/ami_screen/AMIView.cpp index 77750af..0805456 100644 --- a/TouchGFX/gui/src/ami_screen/AMIView.cpp +++ b/TouchGFX/gui/src/ami_screen/AMIView.cpp @@ -80,47 +80,16 @@ void AMIView::setIniChkState(IniChkState state) { } else { if (state == INICHK_WAIT_TS) { progressBar.setColor(DriverViewStatusItem::COLOR_TS); + progressBar.setValue(100); } else { progressBar.setColor(DriverViewStatusItem::COLOR_OK); + float prog = ((float)vehicle_state.ini_chk_state) / INICHK_DONE; + progressBar.setValue(prog * 100); } - float prog = ((float)vehicle_state.ini_chk_state) / INICHK_DONE; - progressBar.setValue(prog * 100); } progressBar.invalidate(); - const char *label = "UNKNOWN"; - switch (vehicle_state.ini_chk_state) { - case INICHK_START: - label = "START"; - break; - case INICHK_WD_CHECK: - label = "WD CHK"; - break; - case INICHK_WD_OK: - label = "WD OK"; - break; - case INICHK_ASB_CHECK_1: - label = "ASB CHK 1"; - break; - case INICHK_ASB_CHECK_2: - label = "ASB CHK 2"; - break; - case INICHK_WAIT_TS: - label = "WAIT TS"; - break; - case INICHK_EBS_CHECK_A: - label = "EBS CHK A"; - break; - case INICHK_EBS_CHECK_B: - label = "EBS CHK B"; - break; - case INICHK_DONE: - label = "DONE"; - break; - case INICHK_ERROR: - label = "ERROR"; - break; - } + const char *label = inichkstate_str(state); touchgfx::Unicode::strncpy(progressBuffer, label, sizeof(progressBuffer) / sizeof(*progressBuffer)); progressLabel.setWildcard(progressBuffer); diff --git a/TouchGFX/gui/src/common/NamedField.cpp b/TouchGFX/gui/src/common/NamedField.cpp index 8b624af..ce1e569 100644 --- a/TouchGFX/gui/src/common/NamedField.cpp +++ b/TouchGFX/gui/src/common/NamedField.cpp @@ -144,42 +144,7 @@ void *get_r2dprog_text() { } void *get_inichk_text() { - const char *text; - switch (vehicle_state.ini_chk_state) { - case INICHK_START: - text = "START"; - break; - case INICHK_WD_CHECK: - text = "WD CHK"; - break; - case INICHK_WD_OK: - text = "WD OK"; - break; - case INICHK_ASB_CHECK_1: - text = "ASB CHK1"; - break; - case INICHK_ASB_CHECK_2: - text = "ASB CHK2"; - break; - case INICHK_WAIT_TS: - text = "WAIT TS"; - break; - case INICHK_EBS_CHECK_A: - text = "EBS CHKA"; - break; - case INICHK_EBS_CHECK_B: - text = "EBS CHKB"; - break; - case INICHK_DONE: - text = "DONE"; - break; - case INICHK_ERROR: - text = "ERROR"; - break; - default: - text = "UNKNOWN"; - } - return (void *)text; + return (void *)inichkstate_str(vehicle_state.ini_chk_state); } void *get_sdc_text() {