Skip to content

Commit

Permalink
Stop on koeo code 000
Browse files Browse the repository at this point in the history
  • Loading branch information
flxkrmr committed Jan 8, 2023
1 parent abda871 commit d4aa82d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/EecIv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void EecIv::setModeLiveData() {
}


int EecIv::mainLoop() {
void EecIv::mainLoop() {
switch(currentState) {
case IDLE:
startMessageCounter = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/EecIv.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class EecIv {

void restartReading();

int mainLoop();
void mainLoop();

callback_t debugPrint;
callback_t onFaultCodeFinished;
Expand Down
19 changes: 17 additions & 2 deletions src/EecIvReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ int screenMode = SELECT_MODE;
char koeo_codes[12][4];
int koeo_counter = 0;
int koeo_code = 0;
char koeo_max = -1;

void setup() {
Serial.begin(19200);
Expand Down Expand Up @@ -190,7 +191,7 @@ void initSelectMode() {
}

void switchKoeoCode(bool down) {
koeo_code = down ? (koeo_code+12-1)%12 : (koeo_code+1)%12;
koeo_code = down ? (koeo_code+koeo_max)%(koeo_max+1) : (koeo_code+1)%(koeo_max+1);
char code_buf[16];
sprintf(code_buf, "[%0d] %s", koeo_code+1, koeo_codes[koeo_code]);
drawMenuScreen(BACK_SIGN, UP_SIGN, DOWN_SIGN, "Fault Code", code_buf, "", "");
Expand Down Expand Up @@ -220,13 +221,17 @@ void selectMode() {
eecIv.setModeKoeo();
eecIv.restartReading();
screenMode = RUNNING_KOEO;
koeo_max = -1;
drawWaitingScreen();
break;
}
}

void onKoeoReadCode(char message[]) {
sprintf(koeo_codes[koeo_counter], message);
if (koeo_max == -1 && !strcmp(message, "000")) {
koeo_max = koeo_counter - 1;
}
koeo_counter++;
}

Expand All @@ -236,10 +241,20 @@ void onStartMessageTimeout() {
}

void onKoeoFinished() {
// empty koeo
if (koeo_counter == 0) {
drawMenuScreen(BACK_SIGN, UP_SIGN, DOWN_SIGN, "No Errors", "", "", "");
screenMode = RESULT_FAULT_CODE;
koeo_counter = 0;
koeo_code = 0;
return;
}

char code_buf[16];
koeo_counter = 0;
koeo_code = 0;
screenMode = RESULT_KOEO;
char code_buf[16];

sprintf(code_buf, "[%0d] %s", koeo_code+1, koeo_codes[koeo_code]);
drawMenuScreen(BACK_SIGN, UP_SIGN, DOWN_SIGN, "Fault Code", code_buf, "", "");
}
Expand Down

0 comments on commit d4aa82d

Please sign in to comment.