From 7e6c599d4149f069c1cadc086ad87bafb75d4cd3 Mon Sep 17 00:00:00 2001 From: Stanley Huang Date: Tue, 24 Jan 2017 22:21:28 +1100 Subject: Added DTC reading --- megaloggerHD/megaloggerHD.ino | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/megaloggerHD/megaloggerHD.ino b/megaloggerHD/megaloggerHD.ino index 7d32709..efc5f71 100644 --- a/megaloggerHD/megaloggerHD.ino +++ b/megaloggerHD/megaloggerHD.ino @@ -574,15 +574,11 @@ void reconnect() state &= ~(STATE_OBD_READY | STATE_GUI_ON); //digitalWrite(SD_CS_PIN, LOW); for (;;) { - if (!obd.init()) - continue; - - int value; - if (obd.readPID(PID_RPM, value)) + if (obd.init()) break; obd.sleep(); - Narcoleptic.delay(4000); + Narcoleptic.delay(10000); } // re-initialize state |= STATE_OBD_READY; @@ -731,8 +727,23 @@ void setup() lcd.print("VIN:"); lcd.setColor(RGB16_YELLOW); lcd.println(buf); + lcd.println(); } + uint16_t dtc[6]; + int num = obd.readDTC(dtc, sizeof(dtc) / sizeof(dtc[0])); + lcd.setColor(RGB16_WHITE); + lcd.print(num); + lcd.println(" DTC found"); + if (num > 0) { + lcd.setColor(RGB16_YELLOW); + for (byte i = 0; i < num; i++) { + lcd.print(dtc[i], HEX); + lcd.print(' '); + } + } + lcd.println(); + showECUCap(); lcd.setCursor(0, 28); lcd.setColor(RGB16_YELLOW); -- cgit v1.2.3