From d945505c64b82f5f3ff2d5aabca5c99c0802fa66 Mon Sep 17 00:00:00 2001 From: Stanley Huang Date: Fri, 9 Oct 2015 16:41:12 +1100 Subject: Add PID value listing on startup --- megalogger/config.h | 5 +++-- megalogger/megalogger.ino | 45 +++++++++++++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 16 deletions(-) (limited to 'megalogger') diff --git a/megalogger/config.h b/megalogger/config.h index 881d7f2..ef36ce6 100644 --- a/megalogger/config.h +++ b/megalogger/config.h @@ -51,8 +51,8 @@ /************************************** * Accelerometer & Gyro **************************************/ -//#define USE_MPU6050 1 -#define USE_MPU9150 1 +#define USE_MPU6050 1 +//#define USE_MPU9150 1 #define ACC_DATA_RATIO 160 #define GYRO_DATA_RATIO 256 #define COMPASS_DATA_RATIO 8 @@ -62,6 +62,7 @@ **************************************/ #define OBD_MIN_INTERVAL 20 /* ms */ #define ACC_DATA_INTERVAL 200 /* ms */ +#define GUI_PID_LIST_DURATION 5 /* sec */ /************************************** * LCD module (uncomment only one) diff --git a/megalogger/megalogger.ino b/megalogger/megalogger.ino index a228a4e..a9cb339 100644 --- a/megalogger/megalogger.ino +++ b/megalogger/megalogger.ino @@ -612,20 +612,37 @@ void showECUCap() PID_EGR_ERROR, PID_COMMANDED_EVAPORATIVE_PURGE, PID_FUEL_LEVEL, PID_CONTROL_MODULE_VOLTAGE, PID_ABSOLUTE_ENGINE_LOAD, PID_AMBIENT_TEMP, PID_COMMANDED_THROTTLE_ACTUATOR, PID_ETHANOL_FUEL, PID_FUEL_RAIL_PRESSURE, PID_HYBRID_BATTERY_PERCENTAGE, PID_ENGINE_OIL_TEMP, PID_FUEL_INJECTION_TIMING, PID_ENGINE_FUEL_RATE, PID_ENGINE_TORQUE_DEMANDED, PID_ENGINE_TORQUE_PERCENTAGE}; + lcd.setFontSize(FONT_SIZE_SMALL); lcd.setColor(RGB16_WHITE); - lcd.setFontSize(FONT_SIZE_MEDIUM); - for (byte i = 0; i < sizeof(pidlist) / sizeof(pidlist[0]); i += 2) { - for (byte j = 0; j < 2; j++) { - byte pid = pgm_read_byte(pidlist + i + j); - lcd.setCursor(216 + j * 56 , i + 4); - lcd.print((int)pid | 0x100, HEX); - bool valid = obd.isValidPID(pid); - if (valid) { - lcd.setColor(RGB16_GREEN); - lcd.draw(tick, 16, 16); - lcd.setColor(RGB16_WHITE); - } - } + for (byte i = 0; i < sizeof(pidlist) / sizeof(pidlist[0]); i++) { + byte pid = pgm_read_byte(pidlist + i); + lcd.setCursor(252, i + 4); + lcd.write('0'); + lcd.print((int)pid | 0x100, HEX); + } + int values[sizeof(pidlist)]; + bool scanned = false; + for (uint32_t t = millis(); millis() - t < GUI_PID_LIST_DURATION * 1000; ) { + for (byte i = 0; i < sizeof(pidlist) / sizeof(pidlist[0]); i++) { + byte pid = pgm_read_byte(pidlist + i); + bool valid = obd.isValidPID(pid); + if (valid) { + int value; + if (obd.read(pid, value)) { + if (!scanned || value == values[i]) + lcd.setColor(RGB16_CYAN); + else if (value > values[i]) + lcd.setColor(RGB16_GREEN); + else + lcd.setColor(RGB16_RED); + lcd.setCursor(280 , i + 4); + byte n = lcd.print(value); + for (; n < 4; n++) lcd.print(' '); + values[i] = value; + } + } + } + scanned = true; } } @@ -715,7 +732,7 @@ void testOut() } else { lcd.println("Timeout"); } - delay(1000); + delay(500); } lcd.println(); } -- cgit v1.2.3