Skip to content

Commit d4aa82d

Browse files
committed
Stop on koeo code 000
1 parent abda871 commit d4aa82d

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/EecIv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void EecIv::setModeLiveData() {
7575
}
7676

7777

78-
int EecIv::mainLoop() {
78+
void EecIv::mainLoop() {
7979
switch(currentState) {
8080
case IDLE:
8181
startMessageCounter = 0;

src/EecIv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class EecIv {
2020

2121
void restartReading();
2222

23-
int mainLoop();
23+
void mainLoop();
2424

2525
callback_t debugPrint;
2626
callback_t onFaultCodeFinished;

src/EecIvReader.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ int screenMode = SELECT_MODE;
8282
char koeo_codes[12][4];
8383
int koeo_counter = 0;
8484
int koeo_code = 0;
85+
char koeo_max = -1;
8586

8687
void setup() {
8788
Serial.begin(19200);
@@ -190,7 +191,7 @@ void initSelectMode() {
190191
}
191192

192193
void switchKoeoCode(bool down) {
193-
koeo_code = down ? (koeo_code+12-1)%12 : (koeo_code+1)%12;
194+
koeo_code = down ? (koeo_code+koeo_max)%(koeo_max+1) : (koeo_code+1)%(koeo_max+1);
194195
char code_buf[16];
195196
sprintf(code_buf, "[%0d] %s", koeo_code+1, koeo_codes[koeo_code]);
196197
drawMenuScreen(BACK_SIGN, UP_SIGN, DOWN_SIGN, "Fault Code", code_buf, "", "");
@@ -220,13 +221,17 @@ void selectMode() {
220221
eecIv.setModeKoeo();
221222
eecIv.restartReading();
222223
screenMode = RUNNING_KOEO;
224+
koeo_max = -1;
223225
drawWaitingScreen();
224226
break;
225227
}
226228
}
227229

228230
void onKoeoReadCode(char message[]) {
229231
sprintf(koeo_codes[koeo_counter], message);
232+
if (koeo_max == -1 && !strcmp(message, "000")) {
233+
koeo_max = koeo_counter - 1;
234+
}
230235
koeo_counter++;
231236
}
232237

@@ -236,10 +241,20 @@ void onStartMessageTimeout() {
236241
}
237242

238243
void onKoeoFinished() {
244+
// empty koeo
245+
if (koeo_counter == 0) {
246+
drawMenuScreen(BACK_SIGN, UP_SIGN, DOWN_SIGN, "No Errors", "", "", "");
247+
screenMode = RESULT_FAULT_CODE;
248+
koeo_counter = 0;
249+
koeo_code = 0;
250+
return;
251+
}
252+
253+
char code_buf[16];
239254
koeo_counter = 0;
240255
koeo_code = 0;
241256
screenMode = RESULT_KOEO;
242-
char code_buf[16];
257+
243258
sprintf(code_buf, "[%0d] %s", koeo_code+1, koeo_codes[koeo_code]);
244259
drawMenuScreen(BACK_SIGN, UP_SIGN, DOWN_SIGN, "Fault Code", code_buf, "", "");
245260
}

0 commit comments

Comments
 (0)