diff options
author | Stanley Huang <stanleyhuangyc@gmail.com> | 2014-09-07 00:19:51 +1000 |
---|---|---|
committer | Stanley Huang <stanleyhuangyc@gmail.com> | 2014-09-07 00:19:51 +1000 |
commit | 332f3d85d1204f864982ea7a192a8830c1bac012 (patch) | |
tree | e853c6423884de40d4e4cb7fdc176b0e92b96655 | |
parent | dc68f92f175fa8e0bf761baed4b49dc1e2aa150b (diff) | |
download | 2021-arduino-obd-332f3d85d1204f864982ea7a192a8830c1bac012.tar.gz 2021-arduino-obd-332f3d85d1204f864982ea7a192a8830c1bac012.tar.bz2 2021-arduino-obd-332f3d85d1204f864982ea7a192a8830c1bac012.zip |
add logging for battery voltage
-rw-r--r-- | megalogger/datalogger.h | 5 | ||||
-rw-r--r-- | megalogger/megalogger.ino | 18 |
2 files changed, 14 insertions, 9 deletions
diff --git a/megalogger/datalogger.h b/megalogger/datalogger.h index 920af4c..95f688a 100644 --- a/megalogger/datalogger.h +++ b/megalogger/datalogger.h @@ -30,6 +30,9 @@ typedef struct { #define PID_ACC 0x20 #define PID_GYRO 0x21 +#define PID_COMPASS 0x22 +#define PID_TEMP 0x23 +#define PID_VOLTAGE 0x24 #define FILE_NAME_FORMAT "/DAT%05d.CSV" @@ -151,7 +154,7 @@ public: { uint16_t fileIndex; char filename[24] = "/FRMATICS"; - + dataSize = 0; if (SD.exists(filename)) { for (fileIndex = 1; fileIndex; fileIndex++) { diff --git a/megalogger/megalogger.ino b/megalogger/megalogger.ino index b9258d9..2570444 100644 --- a/megalogger/megalogger.ino +++ b/megalogger/megalogger.ino @@ -144,6 +144,16 @@ public: if (isValidPID(pidTier3[index3])) logOBDData(pidTier3[index3]); index3 = (index3 + 1) % TIER_NUM3; + if (index3 == 0) { + // get and display voltage + int v = getVoltage(); + lcd.setFontSize(FONT_SIZE_SMALL); + lcd.setCursor(108, 12); + lcd.printInt(v / 10); + lcd.write('.'); + lcd.printInt(v % 10); + logData(PID_VOLTAGE, v); + } } else { if (isValidPID(pidTier2[index2])) logOBDData(pidTier2[index2++]); @@ -162,14 +172,6 @@ public: lcd.printInt((uint16_t)t); } lastRefreshTime = dataTime; - - // get display voltage - unsigned int v = getVoltage(); - lcd.setFontSize(FONT_SIZE_SMALL); - lcd.setCursor(108, 12); - lcd.printInt(v / 1000); - lcd.write('.'); - lcd.printInt((v % 1000) / 100); } if (errors >= 3) { |