diff options
Diffstat (limited to 'obdlogger')
-rw-r--r-- | obdlogger/config.h | 10 | ||||
-rw-r--r-- | obdlogger/obdlogger.ino | 41 |
2 files changed, 43 insertions, 8 deletions
diff --git a/obdlogger/config.h b/obdlogger/config.h index e2b3f88..073b394 100644 --- a/obdlogger/config.h +++ b/obdlogger/config.h @@ -6,13 +6,14 @@ **************************************/ #define ENABLE_DATA_OUT 0 #define ENABLE_DATA_LOG 1 +#define USE_SOFTSERIAL 0 //this defines the format of log file #define LOG_FORMAT FORMAT_CSV /************************************** * Default working mode **************************************/ -#define MODE_DEFAULT MODE_TIMER /* MODE_LOGGER */ +#define MODE_DEFAULT MODE_LOGGER /* MODE_LOGGER/MODE_TIMER */ //#define MODE_SWITCH_PIN 8 /************************************** @@ -33,15 +34,16 @@ /************************************** * Choose LCD model here **************************************/ -LCD_SSD1306 lcd; -//LCD_ZTOLED lcd; +//LCD_SSD1306 lcd; +LCD_Null lcd; /************************************** * Other options **************************************/ -#define USE_MPU6050 0 +#define USE_MPU6050 1 //#define OBD_MIN_INTERVAL 50 /* ms */ #define GPS_DATA_TIMEOUT 2000 /* ms */ //#define DEBUG Serial +#define DEBUG_BAUDRATE 9600 #endif // CONFIG_H_INCLUDED diff --git a/obdlogger/obdlogger.ino b/obdlogger/obdlogger.ino index 84fdbeb..f685e31 100644 --- a/obdlogger/obdlogger.ino +++ b/obdlogger/obdlogger.ino @@ -14,6 +14,9 @@ #include "MicroLCD.h" #include "images.h" #include "config.h" +#if USE_SOFTSERIAL +#include <SoftwareSerial.h> +#endif #include "datalogger.h" // logger states @@ -103,8 +106,11 @@ public: showStates(); #if USE_MPU6050 - if (MPU6050_init() == 0) state |= STATE_ACC_READY; - showStates(); + Wire.begin(); + if (MPU6050_init() == 0) { + state |= STATE_ACC_READY; + showStates(); + } #endif #ifdef GPSUART @@ -357,7 +363,7 @@ private: sprintf(buf, "GZ%3d", data.value.z_gyro / 256); lcd.setCursor(64, 5); lcd.print(buf); - delay(50); + //delay(50); } #endif } @@ -441,6 +447,16 @@ private: //showGForce(data.value.y_accel); // log x/y/z of gyro meter logData(PID_GYRO, data.value.x_gyro, data.value.y_gyro, data.value.z_gyro); + +#ifdef DEBUG + DEBUG.print(dataTime); + DEBUG.print(" X:"); + DEBUG.print(data.value.x_accel); + DEBUG.print(" Y:"); + DEBUG.print(data.value.y_accel); + DEBUG.print(" Z:"); + DEBUG.println(data.value.z_accel); +#endif } #endif void logOBDData(byte pid) @@ -625,6 +641,15 @@ private: // screen layout related stuff void showStates() { +#ifdef DEBUG + DEBUG.print(millis()); + DEBUG.print(" OBD:"); + DEBUG.print((state & STATE_OBD_READY) ? 'Y' : 'N'); + DEBUG.print(" ACC:"); + DEBUG.print((state & STATE_ACC_READY) ? 'Y' : 'N'); + DEBUG.print(" GPS:"); + DEBUG.println((state & STATE_GPS_FOUND) ? 'Y' : 'N'); +#endif // DEBUG lcd.setFont(FONT_SIZE_MEDIUM); lcd.setCursor(0, 2); lcd.print("OBD"); @@ -640,6 +665,13 @@ private: } void showLoggerData(byte pid, int value) { +#ifdef DEBUG + DEBUG.print(millis()); + DEBUG.print(" PID["); + DEBUG.print(pid, HEX); + DEBUG.print("]="); + DEBUG.println(value); +#endif char buf[8]; switch (pid) { case PID_RPM: @@ -763,7 +795,8 @@ static COBDLogger logger; void setup() { #ifdef DEBUG - DEBUG.begin(38400); + DEBUG.begin(DEBUG_BAUDRATE); + DEBUG.println("OBD logger debug console"); #endif lcd.begin(); |