diff options
Diffstat (limited to 'lpo/lpo.ino')
-rw-r--r-- | lpo/lpo.ino | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/lpo/lpo.ino b/lpo/lpo.ino index 85a595b..b85de2b 100644 --- a/lpo/lpo.ino +++ b/lpo/lpo.ino @@ -2,38 +2,36 @@ * Inpired from simple_obd_display.ino by Stanley Huang <stanley@freematics.com.au> * (Simple OBD Data Display for Freematics OBD-II Adapter) *************************************************************************/ -#include "MyLCD.h" +#include <MyLCD.h> #include "MyOBD.h" - MyLCD lcd; MyOBD obd; void setup() { lcd.begin(); - lcd.print("obd.begin()"); + lcd.println("obd.begin()"); obd.begin(); - lcd.println(" done"); reconnect(); showDTC(); + while(1); // Freeze exec here for now initScreen(); } void reconnect() { - lcd.setCursor(1,2); - lcd.print("obd.init() "); - lcd.setCursor(11,2); + lcd.println("obd.init()"); while (!obd.init()) { - lcd.print("."); + lcd.println("obd.init() failed"); } - lcd.println(" done"); } void showDTC() { static char buf[10]; static uint16_t codes[16]; - byte c, count = obd.readDTC(codes, 16); + byte c, count; + lcd.println("obd.readDTC()"); + count = obd.readDTC(codes, 16); lcd.print("DTC: "); if ( count==0 ) { lcd.println("none"); @@ -50,8 +48,16 @@ void loop() { static byte pids[]= {PID_RPM, PID_SPEED, PID_ENGINE_LOAD, PID_THROTTLE}; static byte index = 0, prev_err=obd.errors; + static long prevRead = 0; + long wait; byte pid = pids[index]; int value; + + // Don't read on CAN bus to fast, it struggle and reset main car dashboard + wait = millis() - prevRead + 25; // 40 Hz, 10 FPS for 4 pids + if ( wait > 0 ) delay(wait); + prevRead = millis(); + // send a query to OBD adapter for specified OBD-II pid if (obd.readPID(pid, value)) { showData(pid, value); |