summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--obdlogger/MicroLCD.cpp30
-rw-r--r--obdlogger/config.h8
-rw-r--r--obdlogger/obdlogger.cbp1
-rw-r--r--obdlogger/obdlogger.ino51
4 files changed, 47 insertions, 43 deletions
diff --git a/obdlogger/MicroLCD.cpp b/obdlogger/MicroLCD.cpp
index 691b643..6892099 100644
--- a/obdlogger/MicroLCD.cpp
+++ b/obdlogger/MicroLCD.cpp
@@ -23,19 +23,6 @@ const PROGMEM unsigned char digits16x24[][48] = {
{0x00,0x00,0x00,0xF8,0x1F,0x1C,0xFC,0x7F,0x3C,0xFE,0x7F,0x7C,0xFE,0xFF,0x7C,0xFF,0xFF,0xFC,0xFF,0xFF,0xFC,0x07,0xE0,0xE0,0x07,0xE0,0xE0,0x07,0x60,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x7F,0xFE,0xFF,0x7F,0xFC,0xFF,0x3F,0xF0,0xFF,0x0F},/*"9",9*/
};
-const PROGMEM unsigned char digits16x16[][32] = {
-{0x00,0xE0,0xF8,0xFC,0xFE,0x1E,0x07,0x07,0x07,0x07,0x1E,0xFE,0xFC,0xF8,0xF0,0x00,0x00,0x07,0x0F,0x3F,0x3F,0x7C,0x70,0x70,0x70,0x70,0x7C,0x3F,0x1F,0x1F,0x07,0x00},/*0*/
-{0x00,0x00,0x00,0x06,0x07,0x07,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x00,0x00,0x00,0x00,0x00,0x00},/*1*/
-{0x00,0x38,0x3C,0x3E,0x3E,0x0F,0x07,0x07,0x07,0xCF,0xFF,0xFE,0xFE,0x38,0x00,0x00,0x00,0x40,0x40,0x60,0x70,0x78,0x7C,0x7E,0x7F,0x77,0x73,0x71,0x70,0x70,0x00,0x00},/*2*/
-{0x00,0x18,0x1C,0x1E,0x1E,0x0F,0xC7,0xC7,0xE7,0xFF,0xFE,0xBE,0x9C,0x00,0x00,0x00,0x00,0x0C,0x1C,0x3C,0x3C,0x78,0x70,0x70,0x70,0x79,0x7F,0x3F,0x1F,0x0F,0x00,0x00},/*3*/
-{0x00,0x00,0x80,0xC0,0xE0,0x70,0x38,0x1C,0x1E,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x06,0x07,0x07,0x07,0x06,0x06,0x06,0x06,0x06,0x7F,0x7F,0x7F,0x7F,0x06,0x06,0x00},/*4*/
-{0x00,0x00,0x00,0x00,0xF0,0xFF,0xFF,0xFF,0xE7,0xE7,0xE7,0xE7,0xC7,0x87,0x00,0x00,0x00,0x00,0x38,0x78,0x71,0x70,0x70,0x70,0x70,0x70,0x39,0x3F,0x3F,0x1F,0x0F,0x00},/*5*/
-{0x00,0x80,0xE0,0xF0,0xF8,0xFC,0x7F,0x7F,0x6F,0x67,0xE1,0xE1,0xC0,0x80,0x00,0x00,0x00,0x0F,0x1F,0x3F,0x3F,0x78,0x70,0x70,0x70,0x70,0x78,0x3F,0x3F,0x1F,0x0F,0x00},/*6*/
-{0x00,0x07,0x07,0x07,0x07,0x07,0xC7,0xE7,0xF7,0xFF,0x7F,0x3F,0x1F,0x07,0x03,0x01,0x00,0x20,0x38,0x7C,0x7E,0x3F,0x0F,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*7*/
-{0x00,0x00,0x00,0x1C,0xBE,0xFE,0xFF,0xE7,0xC3,0xC3,0xE7,0xFF,0xFE,0xBE,0x1C,0x00,0x00,0x00,0x0E,0x3F,0x3F,0x7F,0x71,0x60,0x60,0x60,0x71,0x7F,0x3F,0x3F,0x0F,0x00},/*8*/
-{0x00,0x78,0xFC,0xFE,0xFE,0x8F,0x07,0x07,0x07,0x07,0x8F,0xFE,0xFE,0xFC,0xF8,0x00,0x00,0x00,0x00,0x01,0x43,0x43,0x73,0x7B,0x7F,0x7F,0x1F,0x0F,0x07,0x03,0x00,0x00},/*9*/
-};
-
const PROGMEM unsigned char digits8x8[][8] = {
{0x3C,0x7E,0x83,0x81,0x81,0x7E,0x3C,0x00},/*0*/
{0x84,0x84,0x82,0xFF,0xFF,0x80,0x80,0x00},/*1*/
@@ -148,6 +135,19 @@ const PROGMEM unsigned char font5x8[][5] = {
};
#ifndef MEMORY_SAVING
+const PROGMEM unsigned char digits16x16[][32] = {
+{0x00,0xE0,0xF8,0xFC,0xFE,0x1E,0x07,0x07,0x07,0x07,0x1E,0xFE,0xFC,0xF8,0xF0,0x00,0x00,0x07,0x0F,0x3F,0x3F,0x7C,0x70,0x70,0x70,0x70,0x7C,0x3F,0x1F,0x1F,0x07,0x00},/*0*/
+{0x00,0x00,0x00,0x06,0x07,0x07,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x00,0x00,0x00,0x00,0x00,0x00},/*1*/
+{0x00,0x38,0x3C,0x3E,0x3E,0x0F,0x07,0x07,0x07,0xCF,0xFF,0xFE,0xFE,0x38,0x00,0x00,0x00,0x40,0x40,0x60,0x70,0x78,0x7C,0x7E,0x7F,0x77,0x73,0x71,0x70,0x70,0x00,0x00},/*2*/
+{0x00,0x18,0x1C,0x1E,0x1E,0x0F,0xC7,0xC7,0xE7,0xFF,0xFE,0xBE,0x9C,0x00,0x00,0x00,0x00,0x0C,0x1C,0x3C,0x3C,0x78,0x70,0x70,0x70,0x79,0x7F,0x3F,0x1F,0x0F,0x00,0x00},/*3*/
+{0x00,0x00,0x80,0xC0,0xE0,0x70,0x38,0x1C,0x1E,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x06,0x07,0x07,0x07,0x06,0x06,0x06,0x06,0x06,0x7F,0x7F,0x7F,0x7F,0x06,0x06,0x00},/*4*/
+{0x00,0x00,0x00,0x00,0xF0,0xFF,0xFF,0xFF,0xE7,0xE7,0xE7,0xE7,0xC7,0x87,0x00,0x00,0x00,0x00,0x38,0x78,0x71,0x70,0x70,0x70,0x70,0x70,0x39,0x3F,0x3F,0x1F,0x0F,0x00},/*5*/
+{0x00,0x80,0xE0,0xF0,0xF8,0xFC,0x7F,0x7F,0x6F,0x67,0xE1,0xE1,0xC0,0x80,0x00,0x00,0x00,0x0F,0x1F,0x3F,0x3F,0x78,0x70,0x70,0x70,0x70,0x78,0x3F,0x3F,0x1F,0x0F,0x00},/*6*/
+{0x00,0x07,0x07,0x07,0x07,0x07,0xC7,0xE7,0xF7,0xFF,0x7F,0x3F,0x1F,0x07,0x03,0x01,0x00,0x20,0x38,0x7C,0x7E,0x3F,0x0F,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*7*/
+{0x00,0x00,0x00,0x1C,0xBE,0xFE,0xFF,0xE7,0xC3,0xC3,0xE7,0xFF,0xFE,0xBE,0x1C,0x00,0x00,0x00,0x0E,0x3F,0x3F,0x7F,0x71,0x60,0x60,0x60,0x71,0x7F,0x3F,0x3F,0x0F,0x00},/*8*/
+{0x00,0x78,0xFC,0xFE,0xFE,0x8F,0x07,0x07,0x07,0x07,0x8F,0xFE,0xFE,0xFC,0xF8,0x00,0x00,0x00,0x00,0x01,0x43,0x43,0x73,0x7B,0x7F,0x7F,0x1F,0x0F,0x07,0x03,0x00,0x00},/*9*/
+};
+
const PROGMEM unsigned char font8x16_terminal[][16] = {
{0x00,0x00,0x00,0x00,0x7C,0x00,0xFE,0x1B,0xFE,0x1B,0x7C,0x00,0x00,0x00,0x00,0x00},/*"!",0*/
{0x00,0x00,0x0E,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x0E,0x00,0x00,0x00},/*""",1*/
@@ -408,6 +408,7 @@ void LCD_SSD1306::writeDigit(byte n)
m_col += 6;
} else if (m_font == FONT_SIZE_MEDIUM) {
write(n <= 9 ? ('0' + n) : ' ');
+#ifndef MEMORY_SAVING
} else if (m_font == FONT_SIZE_LARGE) {
if (n <= 9) {
byte i;
@@ -460,7 +461,8 @@ void LCD_SSD1306::writeDigit(byte n)
Wire.endTransmission();
}
m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 30 : 16;
- } else if (m_font == FONT_SIZE_XLARGE) {
+#endif
+ } else {
if (n <= 9) {
byte i;
ssd1306_command(0xB0 + m_row);//set page address
diff --git a/obdlogger/config.h b/obdlogger/config.h
index e00362c..e2b3f88 100644
--- a/obdlogger/config.h
+++ b/obdlogger/config.h
@@ -13,15 +13,15 @@
* Default working mode
**************************************/
#define MODE_DEFAULT MODE_TIMER /* MODE_LOGGER */
-#define MODE_SWITCH_PIN 8
+//#define MODE_SWITCH_PIN 8
/**************************************
* Choose SD pin here
**************************************/
//#define SD_CS_PIN SS // generic
//#define SD_CS_PIN 4 // ethernet shield
-#define SD_CS_PIN 7 // microduino
-//#define SD_CS_PIN 10 // SD breakout
+//#define SD_CS_PIN 7 // microduino
+#define SD_CS_PIN 10 // SD breakout
/**************************************
* Config GPS here
@@ -40,7 +40,7 @@ LCD_SSD1306 lcd;
* Other options
**************************************/
#define USE_MPU6050 0
-#define OBD_MIN_INTERVAL 50 /* ms */
+//#define OBD_MIN_INTERVAL 50 /* ms */
#define GPS_DATA_TIMEOUT 2000 /* ms */
//#define DEBUG Serial
diff --git a/obdlogger/obdlogger.cbp b/obdlogger/obdlogger.cbp
index 26cf9bc..e8f3685 100644
--- a/obdlogger/obdlogger.cbp
+++ b/obdlogger/obdlogger.cbp
@@ -585,6 +585,7 @@
<Unit filename="MicroLCD.cpp" />
<Unit filename="MicroLCD.h" />
<Unit filename="SSD1306.cpp" />
+ <Unit filename="config.h" />
<Unit filename="datalogger.h" />
<Unit filename="images.h" />
<Unit filename="obdlogger.ino">
diff --git a/obdlogger/obdlogger.ino b/obdlogger/obdlogger.ino
index 0bbff55..bbd73a4 100644
--- a/obdlogger/obdlogger.ino
+++ b/obdlogger/obdlogger.ino
@@ -47,24 +47,23 @@
TinyGPS gps;
+static long lastLat = 0;
+static long lastLon = 0;
+static long curLat = 0;
+static long curLon = 0;
+static uint32_t lastGPSDataTime = 0;
+static uint16_t speedGPS = 0;
+
#endif // GPSUART
#endif
static uint32_t lastFileSize = 0;
-//static uint32_t lastDataTime;
-static uint32_t lastGPSDataTime = 0;
static uint16_t lastSpeed = -1;
static uint32_t lastSpeedTime = 0;
static uint16_t speed = 0;
-static uint16_t speedGPS = 0;
-static int startDistance = 0;
+static uint32_t distance = 0;
static uint16_t fileIndex = 0;
static uint32_t startTime = 0;
-static long lastLat = 0;
-static long lastLon = 0;
-static long curLat = 0;
-static long curLon = 0;
-static uint16_t distance = 0;
#define STAGE_IDLE 0
#define STAGE_WAIT_START 1
@@ -81,11 +80,11 @@ static byte stage = STAGE_IDLE;
static uint16_t times[4] = {0};
static byte pollPattern[]= {
- PID_RPM, PID_SPEED, PID_ENGINE_LOAD, PID_RPM, PID_SPEED, PID_THROTTLE, PID_RPM, PID_SPEED, PID_ENGINE_LOAD, PID_RPM, PID_SPEED, PID_THROTTLE,
+ PID_RPM, PID_SPEED, PID_ENGINE_LOAD, PID_RPM, PID_SPEED, PID_THROTTLE
};
static byte pollPattern2[] = {
- PID_DISTANCE, PID_COOLANT_TEMP, PID_INTAKE_TEMP, PID_AMBIENT_TEMP, PID_FUEL_LEVEL,
+ PID_COOLANT_TEMP, PID_INTAKE_TEMP, PID_AMBIENT_TEMP, PID_FUEL_LEVEL,
};
#define PATTERN_NUM sizeof(pollPattern)
@@ -98,8 +97,9 @@ public:
COBDLogger():state(0) {}
void setup()
{
+#if USE_GPS
lastGPSDataTime = 0;
-
+#endif
showStates();
#if USE_MPU6050
@@ -152,8 +152,6 @@ public:
//delay(1000);
#endif
- readSensor(PID_DISTANCE, startDistance);
-
#if ENABLE_DATA_LOG
// open file for logging
if (!(state & STATE_SD_READY)) {
@@ -205,6 +203,12 @@ public:
}
}
+ char buf[10];
+ sprintf(buf, "%4ukm", (uint16_t)(distance / 1000));
+ lcd.setFont(FONT_SIZE_SMALL);
+ lcd.setCursor(92, 6);
+ lcd.print(buf);
+
#if USE_MPU6050
if (state & STATE_ACC_READY) {
processAccelerometer();
@@ -496,8 +500,10 @@ private:
dataTime = t;
logData(0x100 | PID_SPEED, speed);
+#if USE_GPS
lastLat = curLat;
lastLon = curLon;
+#endif
lastSpeed = 0;
distance = 0;
@@ -517,7 +523,10 @@ private:
lcd.write('.');
lcd.write('0' + n);
}
- if (times[2] == 0 && (speedGPS >= SPEED_THRESHOLD_3 || speed >= SPEED_THRESHOLD_3)) {
+#if USE_GPS
+ if (speedGPS > speed) speed = speedGPS;
+#endif
+ if (times[2] == 0 && speed >= SPEED_THRESHOLD_3) {
times[2] = elapsed / 100;
stage = STAGE_IDLE;
lcd.clearLine(0);
@@ -527,10 +536,10 @@ private:
lcd.setFont(FONT_SIZE_MEDIUM);
lcd.setCursor(0, 0);
lcd.print("DONE!");
- } else if (times[1] == 0 && (speedGPS >= SPEED_THRESHOLD_2 || speed >= SPEED_THRESHOLD_2)) {
+ } else if (times[1] == 0 && speed >= SPEED_THRESHOLD_2) {
times[1] = elapsed / 100;
showTimerResults();
- } else if (times[0] == 0 && (speedGPS >= SPEED_THRESHOLD_1 || speed >= SPEED_THRESHOLD_1)) {
+ } else if (times[0] == 0 && speed >= SPEED_THRESHOLD_1) {
times[0] = elapsed / 100;
showTimerResults();
} else if (speed == 0) {
@@ -658,14 +667,6 @@ private:
lcd.printInt(value, 3);
}
break;
- case PID_DISTANCE:
- if ((unsigned int)value >= startDistance) {
- sprintf(buf, "%4ukm", ((unsigned int)value - startDistance) % 1000);
- lcd.setFont(FONT_SIZE_SMALL);
- lcd.setCursor(92, 6);
- lcd.print(buf);
- }
- break;
}
}
void showGForce(int g)