From 332f3d85d1204f864982ea7a192a8830c1bac012 Mon Sep 17 00:00:00 2001 From: Stanley Huang Date: Sun, 7 Sep 2014 00:19:51 +1000 Subject: add logging for battery voltage --- megalogger/datalogger.h | 5 ++++- 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) { -- cgit v1.2.3