summaryrefslogtreecommitdiff
path: root/megaloggerHD
diff options
context:
space:
mode:
authorStanley Huang <stanleyhuangyc@gmail.com>2017-02-16 20:40:33 +1100
committerStanley Huang <stanleyhuangyc@gmail.com>2017-02-16 20:40:33 +1100
commitce35233cb19328c6998d43c9426d970974714983 (patch)
tree577f2a4d1e394d33529d8e2fc26ee073feb5ff33 /megaloggerHD
parent33a7b016dea7679fd319eb94baca680a5117f3e4 (diff)
download2021-arduino-obd-ce35233cb19328c6998d43c9426d970974714983.tar.gz
2021-arduino-obd-ce35233cb19328c6998d43c9426d970974714983.tar.bz2
2021-arduino-obd-ce35233cb19328c6998d43c9426d970974714983.zip
Minor updates
Diffstat (limited to 'megaloggerHD')
-rw-r--r--megaloggerHD/datalogger.h9
-rw-r--r--megaloggerHD/megaloggerHD.ino27
2 files changed, 24 insertions, 12 deletions
diff --git a/megaloggerHD/datalogger.h b/megaloggerHD/datalogger.h
index 8d241d6..462c157 100644
--- a/megaloggerHD/datalogger.h
+++ b/megaloggerHD/datalogger.h
@@ -33,7 +33,8 @@ typedef struct {
#define PID_DATA_SIZE 0x80
-#define FILE_NAME_FORMAT "/DAT%05d.CSV"
+#define FILE_NAME_FORMAT "DAT%05d.CSV"
+#define FILE_PATH "/DATA/"
#if ENABLE_DATA_OUT
@@ -213,12 +214,12 @@ public:
uint16_t openFile(uint16_t logFlags = 0, uint32_t dateTime = 0)
{
uint16_t fileIndex;
- char filename[24] = "/FRMATICS";
+ char filename[24] = FILE_PATH;
dataSize = 0;
if (SD.exists(filename)) {
for (fileIndex = 1; fileIndex; fileIndex++) {
- sprintf(filename + 9, FILE_NAME_FORMAT, fileIndex);
+ sprintf(filename + sizeof(FILE_PATH) - 1, FILE_NAME_FORMAT, fileIndex);
if (!SD.exists(filename)) {
break;
}
@@ -228,7 +229,7 @@ public:
} else {
SD.mkdir(filename);
fileIndex = 1;
- sprintf(filename + 9, FILE_NAME_FORMAT, 1);
+ sprintf(filename + sizeof(FILE_PATH) - 1, FILE_NAME_FORMAT, 1);
}
sdfile = SD.open(filename, FILE_WRITE);
diff --git a/megaloggerHD/megaloggerHD.ino b/megaloggerHD/megaloggerHD.ino
index f7d7e47..e1ba855 100644
--- a/megaloggerHD/megaloggerHD.ino
+++ b/megaloggerHD/megaloggerHD.ino
@@ -1,6 +1,5 @@
/*************************************************************************
-* Reference code for Freematics OBD-II UART Adapter
-* Works with Freematics OBD-II Telematics Advanced Kit
+* Reference code for Freematics OBD-II Advanced Telematics Kit
* Visit http://freematics.com for more information
* Distributed under BSD license
* Written by Stanley Huang <support@freematics.com.au>
@@ -603,7 +602,7 @@ void showStates()
void testOut()
{
- const char cmds[][6] = {"ATZ\r", "ATL1\r", "ATRV\r", "0100\r", "0902\r"};
+ const char cmds[][6] = {"ATZ\r", "ATH0\r", "ATRV\r", "0100\r", "0902\r"};
char buf[128];
lcd.setFontSize(FONT_SIZE_SMALL);
lcd.setCursor(0, 13);
@@ -670,21 +669,33 @@ void setup()
#endif
byte version = obd.begin();
- lcd.print("Adapter Ver. ");
- lcd.print(version / 10);
- lcd.print('.');
- lcd.println(version % 10);
+ if (version) {
+ lcd.print("Adapter Ver. ");
+ lcd.print(version / 10);
+ lcd.print('.');
+ lcd.println(version % 10);
+ } else {
+#ifdef OBD_ADAPTER_I2C
+ lcd.print("OBD-II I2C Adapter ");
+#else
+ lcd.print("OBD-II UART Adapter ");
+#endif
+ lcd.setColor(RGB16_RED);
+ lcd.draw(cross, 16, 16);
+ lcd.setColor(RGB16_WHITE);
+ }
#ifdef OBD_ADAPTER_I2C
Wire.begin();
#endif
- if (obd.memsInit())
+ if (version && obd.memsInit())
state |= STATE_MEMS_READY;
showStates();
#if USE_GPS
unsigned long t = millis();
+ while (GPSUART.available()) GPSUART.read();
do {
if (GPSUART.available() && GPSUART.read() == '\r') {
state |= STATE_GPS_CONNECTED;