summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanley Huang <stanleyhuangyc@gmail.com>2013-05-10 11:45:51 +0800
committerStanley Huang <stanleyhuangyc@gmail.com>2013-05-10 11:45:51 +0800
commitbe6cca65b06f5532161345d6ff6a96a884369d5a (patch)
tree7cfd03e288ef2a276435df2cf1ced863699b2bc4
parent21090300703359ef39e1b7f5311b9edb40e39d6c (diff)
download2021-arduino-obd-be6cca65b06f5532161345d6ff6a96a884369d5a.tar.gz
2021-arduino-obd-be6cca65b06f5532161345d6ff6a96a884369d5a.tar.bz2
2021-arduino-obd-be6cca65b06f5532161345d6ff6a96a884369d5a.zip
accelerometer related fix
-rw-r--r--obdlogger/obdlogger.ino18
1 files changed, 11 insertions, 7 deletions
diff --git a/obdlogger/obdlogger.ino b/obdlogger/obdlogger.ino
index 6f26c49..d7d0987 100644
--- a/obdlogger/obdlogger.ino
+++ b/obdlogger/obdlogger.ino
@@ -62,6 +62,7 @@ static uint32_t fileSize = 0;
static uint32_t lastFileSize = 0;
static uint32_t lastDataTime;
static uint32_t lastGPSDataTime = 0;
+static uint16_t lastSpeed = 0;
static int startDistance = 0;
static uint16_t fileIndex = 0;
@@ -230,7 +231,7 @@ public:
volumesize *= volume.clusterCount();
volumesize >>= 10;
- sprintf(buf, "%dGB", (int)(volumesize + 511) >> 10);
+ sprintf(buf, "%dGB", (int)((volumesize + 511) / 1000));
lcd.print(buf);
} else {
lcd.print("No SD Card ");
@@ -320,10 +321,10 @@ private:
uint16_t elapsed = (uint16_t)(dataTime - lastDataTime);
char buf[20];
// log x/y/z of accelerometer
- len = sprintf(buf, "%u,F10,%d %d %d", data.value.x_accel, data.value.y_accel, data.value.z_accel);
+ len = sprintf(buf, "%u,F10,%d %d %d\n", data.value.x_accel, data.value.y_accel, data.value.z_accel);
sdfile.write((uint8_t*)buf, len);
// log x/y/z of gyro meter
- len = sprintf(buf, "%u,F11,%d %d %d", data.value.x_gyro, data.value.y_gyro, data.value.z_gyro);
+ len = sprintf(buf, "%u,F11,%d %d %d\n", data.value.x_gyro, data.value.y_gyro, data.value.z_gyro);
sdfile.write((uint8_t*)buf, len);
}
void LogData(byte pid)
@@ -412,9 +413,12 @@ private:
lcd.print(buf);
break;
case PID_SPEED:
- sprintf(buf, "%3u", (unsigned int)value % 1000);
- lcd.setCursor(0, 0);
- lcd.printLarge(buf);
+ if (lastSpeed != value) {
+ sprintf(buf, "%3u", (unsigned int)value % 1000);
+ lcd.setCursor(0, 0);
+ lcd.printLarge(buf);
+ lastSpeed = value;
+ }
break;
case PID_THROTTLE:
sprintf(buf, "%2d", value % 100);
@@ -434,7 +438,7 @@ private:
{
byte n;
/* 0~2g -> 0~8 */
- g /= 190 * 25;
+ g /= 128 * 25;
lcd.setCursor(0, 1);
if (g == 0) {
lcd.clearLine(1);