diff options
-rw-r--r-- | gpslogger/config.h | 23 | ||||
-rw-r--r-- | gpslogger/datalogger.h | 146 | ||||
-rw-r--r-- | gpslogger/gpslogger.ino | 513 | ||||
-rw-r--r-- | gpslogger/images.h | 5 |
4 files changed, 216 insertions, 471 deletions
diff --git a/gpslogger/config.h b/gpslogger/config.h index 7e1d2e2..9d6fb07 100644 --- a/gpslogger/config.h +++ b/gpslogger/config.h @@ -4,34 +4,23 @@ /************************************** * Data logging/streaming out **************************************/ -#define ENABLE_DATA_OUT 0 +#define ENABLE_DATA_OUT 1 #define ENABLE_DATA_LOG 1 -#define USE_SOFTSERIAL 0 +#define USE_SOFTSERIAL 1 //this defines the format of log file -#define LOG_FORMAT FORMAT_CSV -#define STREAM_FORMAT FORMAT_CSV -#define STREAM_BAUDRATE 115200 +#define STREAM_FORMAT FORMAT_TEXT +#define STREAM_BAUDRATE 9600 /************************************** * 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 - -/************************************** -* Choose LCD model here -**************************************/ -LCD_SSD1289 lcd; -//LCD_ILI9341 lcd; -//LCD_Null lcd; +#define SD_CS_PIN SS /************************************** * Other options **************************************/ #define USE_MPU6050 0 -#define GPS_BAUDRATE 38400 +#define GPS_BAUDRATE 115200 #define GPS_DATA_TIMEOUT 2000 /* ms */ //#define DEBUG Serial #define DEBUG_BAUDRATE 9600 diff --git a/gpslogger/datalogger.h b/gpslogger/datalogger.h index 2a58bf3..a5fbacd 100644 --- a/gpslogger/datalogger.h +++ b/gpslogger/datalogger.h @@ -1,13 +1,13 @@ /************************************************************************* * Arduino Data Logger Class * Distributed under GPL v2.0 -* Copyright (c) 2013-2014 Stanley Huang <stanleyhuangyc@gmail.com> -* All rights reserved. +* Written by Stanley Huang <stanleyhuangyc@gmail.com> * Visit http://freematics.com for more information *************************************************************************/ #define FORMAT_BIN 0 #define FORMAT_CSV 1 +#define FORMAT_TEXT 2 typedef struct { uint32_t time; @@ -17,8 +17,6 @@ typedef struct { float value[3]; } LOG_DATA_COMM; -#define HEADER_LEN 128 /* bytes */ - #define PID_GPS_LATITUDE 0xA #define PID_GPS_LONGITUDE 0xB #define PID_GPS_ALTITUDE 0xC @@ -34,22 +32,16 @@ typedef struct { #define PID_MEMS_TEMP 0x23 #define PID_BATTERY_VOLTAGE 0x24 +#define PID_DATA_SIZE 0x80 + #define FILE_NAME_FORMAT "/DAT%05d.CSV" #if ENABLE_DATA_OUT #if USE_SOFTSERIAL - -#if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) - SoftwareSerial SerialBLE(A8, A9); /* for BLE Shield on MEGA*/ +SoftwareSerial SerialRF(A2, A3); #else - SoftwareSerial SerialBLE(A2, A3); /* for BLE Shield on UNO/leonardo*/ -#endif - -#else - -#define SerialBLE Serial3 - +#define SerialRF Serial #endif #endif @@ -58,34 +50,62 @@ typedef struct { static File sdfile; #endif -static const char* idstr = "FREEMATICS\r"; +typedef struct { + uint16_t pid; + char name[3]; +} PID_NAME; + +const PID_NAME pidNames[] PROGMEM = { +{PID_ACC, {'A','C','C'}}, +{PID_GYRO, {'G','Y','R'}}, +{PID_COMPASS, {'M','A','G'}}, +{PID_GPS_LATITUDE, {'L','A','T'}}, +{PID_GPS_LONGITUDE, {'L','O','N'}}, +{PID_GPS_ALTITUDE, {'A','L','T'}}, +{PID_GPS_SPEED, {'S','P','D'}}, +{PID_GPS_HEADING, {'C','R','S'}}, +{PID_GPS_SAT_COUNT, {'S','A','T'}}, +{PID_GPS_TIME, {'T','I','M'}}, +{PID_GPS_DATE, {'D','T','E'}}, +{PID_BATTERY_VOLTAGE, {'B','A','T'}}, +{PID_DATA_SIZE, {'D','A','T'}}, +}; class CDataLogger { public: void initSender() { #if ENABLE_DATA_OUT - SerialBLE.begin(STREAM_BAUDRATE); - SerialBLE.print(idstr); + SerialRF.begin(STREAM_BAUDRATE); + /* + SerialRF.print("AT+NAMEFreematics"); + delay(10); + while (SerialRF.available()) SerialRF.read(); + SerialRF.println(); + */ + m_lastSendTime = 0; #endif #if ENABLE_DATA_LOG m_lastDataTime = 0; #endif } - void logTimeElapsed() + void recordData(const char* buf) { #if ENABLE_DATA_LOG dataSize += sdfile.print(dataTime - m_lastDataTime); - sdfile.write(','); - dataSize++; + dataSize += sdfile.write(','); + dataSize += sdfile.write(buf); m_lastDataTime = dataTime; #endif +#if MIN_DATA_INTERVAL + uint32_t t = millis(); + uint32_t elapsed = t - m_lastSendTime; + if (elapsed < MIN_DATA_INTERVAL) delay(MIN_DATA_INTERVAL - elapsed); + m_lastSendTime = t; +#endif } void logData(char c) { -#if ENABLE_DATA_OUT && STREAM_FORMAT == FORMAT_CSV - SerialBLE.write(c); -#endif #if ENABLE_DATA_LOG if (c >= ' ') { sdfile.write(c); @@ -96,56 +116,78 @@ public: void logData(uint16_t pid, int value) { char buf[16]; - byte n = sprintf(buf, "%X,%d\r", pid, value); +#if STREAM_FORMAT == FORMAT_TEXT + sprintf(buf + translatePIDName(pid, buf), "%d\r", value); +#else + sprintf(buf, "%X,%d\r", pid, value); +#endif #if ENABLE_DATA_OUT #if STREAM_FORMAT == FORMAT_BIN LOG_DATA_COMM ld = {dataTime, pid, 1, 0, value}; ld.checksum = getChecksum((char*)&ld, 12); - SerialBLE.write((uint8_t*)&ld, 12); + SerialRF.write((uint8_t*)&ld, 12); #else - SerialBLE.write((uint8_t*)buf, n); + SerialRF.print(buf); #endif #endif -#if ENABLE_DATA_LOG - logTimeElapsed(); - dataSize += sdfile.write((uint8_t*)buf, n); -#endif + recordData(buf); } void logData(uint16_t pid, int32_t value) { char buf[20]; - byte n = sprintf(buf, "%X,%ld\r", pid, value); +#if STREAM_FORMAT == FORMAT_TEXT + sprintf(buf + translatePIDName(pid, buf), "%ld\r", value); +#else + sprintf(buf, "%X,%ld\r", pid, value); +#endif #if ENABLE_DATA_OUT #if STREAM_FORMAT == FORMAT_BIN LOG_DATA_COMM ld = {dataTime, pid, 1, 0, value}; ld.checksum = getChecksum((char*)&ld, 12); - SerialBLE.write((uint8_t*)&ld, 12); + SerialRF.write((uint8_t*)&ld, 12); #else - SerialBLE.write((uint8_t*)buf, n); + SerialRF.print(buf); #endif #endif -#if ENABLE_DATA_LOG - logTimeElapsed(); - dataSize += sdfile.write((uint8_t*)buf, n); + recordData(buf); + } + void logData(uint16_t pid, uint32_t value) + { + char buf[20]; +#if STREAM_FORMAT == FORMAT_TEXT + sprintf(buf + translatePIDName(pid, buf), "%lu\r", value); +#else + sprintf(buf, "%X,%lu\r", pid, value); #endif +#if ENABLE_DATA_OUT +#if STREAM_FORMAT == FORMAT_BIN + LOG_DATA_COMM ld = {dataTime, pid, 1, 0, value}; + ld.checksum = getChecksum((char*)&ld, 12); + SerialRF.write((uint8_t*)&ld, 12); +#else + SerialRF.print(buf); +#endif +#endif + recordData(buf); } void logData(uint16_t pid, int value1, int value2, int value3) { char buf[24]; - byte n = sprintf(buf, "%X,%d,%d,%d\r", pid, value1, value2, value3); +#if STREAM_FORMAT == FORMAT_TEXT + sprintf(buf + translatePIDName(pid, buf), "%d,%d,%d\r", value1, value2, value3); +#else + sprintf(buf, "%X,%d,%d,%d\r", pid, value1, value2, value3); +#endif #if ENABLE_DATA_OUT #if STREAM_FORMAT == FORMAT_BIN LOG_DATA_COMM ld = {dataTime, pid, 3, 0, {value1, value2, value3}}; ld.checksum = getChecksum((char*)&ld, 20); - SerialBLE.write((uint8_t*)&ld, 20); + SerialRF.write((uint8_t*)&ld, 20); #else - SerialBLE.write((uint8_t*)buf, n); -#endif + SerialRF.print(buf); #endif -#if ENABLE_DATA_LOG - logTimeElapsed(); - dataSize += sdfile.write((uint8_t*)buf, n); #endif + recordData(buf); } #if ENABLE_DATA_LOG uint16_t openFile(uint16_t logFlags = 0, uint32_t dateTime = 0) @@ -173,6 +215,7 @@ public: if (!sdfile) { return 0; } + m_lastDataTime = dateTime; return fileIndex; } void closeFile() @@ -195,7 +238,24 @@ private: } return checksum; } +#if STREAM_FORMAT == FORMAT_TEXT + byte translatePIDName(uint16_t pid, char* text) + { + for (uint16_t n = 0; n < sizeof(pidNames) / sizeof(pidNames[0]); n++) { + uint16_t id = pgm_read_word(&pidNames[n].pid); + if (pid == id) { + memcpy_P(text, pidNames[n].name, 3); + text[3] = ','; + return 4; + } + } + return sprintf(text, "%X=", pid); + } +#endif #if ENABLE_DATA_LOG uint32_t m_lastDataTime; #endif +#if ENABLE_DATA_OUT + uint32_t m_lastSendTime; +#endif }; diff --git a/gpslogger/gpslogger.ino b/gpslogger/gpslogger.ino index e01f9d3..3e915e3 100644 --- a/gpslogger/gpslogger.ino +++ b/gpslogger/gpslogger.ino @@ -1,39 +1,22 @@ /************************************************************************* -* Arduino GPS Data Logger / Speed Meter / Odometer +* Reference code for generic GPS data logger +* Works with Freematics GPS Data Logger Kit +* Visit http://freematics.com for more information * Distributed under GPL v2.0 * Written by Stanley Huang -* All rights reserved. *************************************************************************/ #include <Arduino.h> #include <SPI.h> #include <SD.h> #include <TinyGPS.h> +#include "config.h" #if USE_SOFTSERIAL #include <SoftwareSerial.h> #endif -#include "MultiLCD.h" -#include "config.h" #include "datalogger.h" -#define DISPLAY_MODES 1 - -uint32_t start; -uint32_t distance = 0; -int speed = 0; -byte sat = 0; -uint32_t records = 0; -char heading[2]; -bool acc = false; - -float curLat = 0; -float curLon = 0; -int16_t alt = 0; -int16_t startAlt = 32767; -long lastLat = 0; -long lastLon = 0; -uint32_t time; - +//bool acc = false; #if USE_MPU6050 #include <Wire.h> @@ -42,444 +25,162 @@ uint32_t time; #if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) #define GPSUART Serial2 -#elif defined(__AVR_ATmega644P__) +#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega32U4__) #define GPSUART Serial1 #else #define GPSUART Serial #endif -#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F" - TinyGPS gps; CDataLogger logger; -void initScreen(); - #if USE_MPU6050 bool initACC() { - if (MPU6050_init() != 0) - return false; - return true; + if (MPU6050_init() != 0) + return false; + return true; } void processACC() { - accel_t_gyro_union data; - MPU6050_readout(&data); - logger.dataTime = millis(); - // log x/y/z of accelerometer - logger.logData(PID_ACC, data.value.x_accel, data.value.y_accel, data.value.z_accel); - // log x/y/z of gyro meter - logger.logData(PID_GYRO, data.value.x_gyro, data.value.y_gyro, data.value.z_gyro); + accel_t_gyro_union data; + MPU6050_readout(&data); + logger.dataTime = millis(); + // log x/y/z of accelerometer + logger.logData(PID_ACC, data.value.x_accel, data.value.y_accel, data.value.z_accel); + delay(10); + // log x/y/z of gyro meter + logger.logData(PID_GYRO, data.value.x_gyro, data.value.y_gyro, data.value.z_gyro); } #endif void processGPS() { - static uint32_t lastTime = 0; - - // parsed GPS data is ready - logger.dataTime = millis(); - - uint32_t date; - gps.get_datetime(&date, &time, 0); - logger.logData(PID_GPS_TIME, time, date); + long lat, lon; + int speed = 0; + int16_t alt = 0; + uint32_t date, time; - speed = (int)(gps.speed() * 1852 / 100); - if (speed < 1000) speed = 0; - logger.logData(PID_GPS_SPEED, speed); + logger.dataTime = millis(); - /* - if (sat >= 3 && gps.satellites() < 3) { - initScreen(); - } - */ - - sat = gps.satellites(); - if (sat > 100) sat = 0; - - long lat, lon; - gps.get_position(&lat, &lon, 0); - curLat = (float)lat / 100000; - curLon = (float)lon / 100000; - logger.logData(PID_GPS_COORDINATES, curLat, curLon); + gps.get_datetime(&date, &time, 0); + logger.logData(PID_GPS_TIME, (int32_t)time); + delay(10); - if (logger.dataTime - lastTime >= 3000 && speed > 0) { - if (lastLat == 0) lastLat = lat; - if (lastLon == 0) lastLon = lon; + speed = (int)(gps.speed() * 1852 / 100000); + logger.logData(PID_GPS_SPEED, speed); + delay(10); - int16_t latDiff = lat - lastLat; - int16_t lonDiff = lon - lastLon; + //logger.logData(PID_GPS_SAT_COUNT, (int)gps.satellites()); - uint16_t d = latDiff * latDiff + lonDiff * lonDiff; - if (d >= 100) { - distance += sqrt(d); - lastLat = lat; - lastLon = lon; + alt = gps.altitude() / 100; + if (alt > -10000 && alt < 10000) { + logger.logData(PID_GPS_ALTITUDE, alt); + delay(10); + } - if (latDiff > 0) { - heading[0] = 'N'; - } else if (latDiff < 0) { - heading[0] = 'S'; - } else { - heading[0] = ' '; - } - if (lonDiff > 0) { - heading[1] = 'E'; - } else if (lonDiff < 0) { - heading[1] = 'W'; - } else { - heading[1] = ' '; - } - } - lastTime = logger.dataTime; - -#if ENABLE_DATA_LOG - // flush file every several seconds - logger.flushFile(); -#endif - } - - alt = gps.altitude() / 100; - if (alt > -10000 && alt < 10000) { - logger.logData(PID_GPS_ALTITUDE, alt); - if (sat > 5 && startAlt == 32767) { - // save start altitude - startAlt = alt; - } - } else { - alt = 0; - } - - records++; + gps.get_position(&lat, &lon, 0); + logger.logData(PID_GPS_LATITUDE, lat); + delay(10); + logger.logData(PID_GPS_LONGITUDE, lon); } bool CheckSD() { - Sd2Card card; - SdVolume volume; - - pinMode(SS, OUTPUT); - if (card.init(SPI_HALF_SPEED, SD_CS_PIN)) { - const char* type; - char buf[20]; - - switch(card.type()) { - case SD_CARD_TYPE_SD1: - type = "SD1"; - break; - case SD_CARD_TYPE_SD2: - type = "SD2"; - break; - case SD_CARD_TYPE_SDHC: - type = "SDHC"; - break; - default: - type = "SDx"; - } - - lcd.print(type); - lcd.write(' '); - if (!volume.init(card)) { - lcd.println("No FAT!"); - return false; - } - - uint32_t volumesize = volume.blocksPerCluster(); - volumesize >>= 1; // 512 bytes per block - volumesize *= volume.clusterCount(); - volumesize >>= 10; - - lcd.print((int)((volumesize + 511) / 1000)); - lcd.println("GB"); - } else { - lcd.println("SD Error"); - return false; - } - - if (!SD.begin(SD_CS_PIN)) { - lcd.println("Bad SD"); - return false; + Sd2Card card; + //SdVolume volume; + + pinMode(SS, OUTPUT); + if (card.init(SPI_HALF_SPEED, SD_CS_PIN)) { + const char* type; + char buf[20]; + + switch (card.type()) { + case SD_CARD_TYPE_SD1: + type = "SD1"; + break; + case SD_CARD_TYPE_SD2: + type = "SD2"; + break; + case SD_CARD_TYPE_SDHC: + type = "SDHC"; + break; + default: + type = "SDx"; } - return true; -} - -void initScreen() -{ - lcd.clear(); - lcd.setColor(RGB16_CYAN); - lcd.setFontSize(FONT_SIZE_MEDIUM); - lcd.setCursor(32, 0); - lcd.print("Speed"); - lcd.setCursor(120, 0); - lcd.print("Distance"); - lcd.setCursor(32, 8); - lcd.print("Watts"); - lcd.setCursor(120, 8); - lcd.print("Calories"); - lcd.setCursor(40, 16); - lcd.print("Time"); - lcd.setCursor(150, 16); - lcd.print("RPM"); - lcd.setCursor(20, 24); - lcd.print("Altitude"); - lcd.setCursor(120, 24); - lcd.print("Alt Gained"); - - lcd.setFontSize(FONT_SIZE_SMALL); - lcd.setCursor(76, 5); - lcd.print("km/h"); - lcd.setCursor(180, 5); - lcd.print("km"); - lcd.setCursor(72, 28); - lcd.print('m'); - lcd.setCursor(192, 28); - lcd.print('m'); - - lcd.setFontSize(FONT_SIZE_SMALL); - lcd.setCursor(240, 0); - lcd.println("UTC:"); - lcd.setCursor(240, 2); - lcd.println("LAT:"); - lcd.setCursor(240, 4); - lcd.println("LON:"); - lcd.setCursor(240, 6); - lcd.println("ALT:"); - lcd.setCursor(240, 8); - lcd.println("SAT:"); - lcd.setCursor(240, 10); - lcd.println("PTS:"); - lcd.setCursor(240, 12); - lcd.println("KBs:"); -} - -#if USE_MPU6050 -void displayMPU6050() -{ - accel_t_gyro_union data; - char buf[8]; - MPU6050_readout(&data); - - int temp = (data.value.temperature + 12412) / 340; - sprintf(buf, "TEMP%3dC", temp); - lcd.setFontSize(FONT_SIZE_MEDIUM); - lcd.setCursor(80, 2); - lcd.print(buf); - - sprintf(buf, "AX%3d", data.value.x_accel / 160); - lcd.setCursor(98, 3); - lcd.print(buf); - sprintf(buf, "AY%3d", data.value.y_accel / 160); - lcd.setCursor(98, 4); - lcd.print(buf); - sprintf(buf, "AZ%3d", data.value.z_accel / 160); - lcd.setCursor(98, 5); - lcd.print(buf); - - sprintf(buf, "GX%3d", data.value.x_gyro / 256); - lcd.setCursor(64, 3); - lcd.print(buf); - sprintf(buf, "GY%3d", data.value.y_gyro / 256); - lcd.setCursor(64, 4); - lcd.print(buf); - sprintf(buf, "GZ%3d", data.value.z_gyro / 256); - lcd.setCursor(64, 5); - lcd.print(buf); + SerialRF.print(type); + SerialRF.print(' '); + } else { + SerialRF.println("No SD"); + return false; + } + + if (!SD.begin(SD_CS_PIN)) { + SerialRF.println("Bad SD"); + return false; + } + return true; } -#endif void setup() { - lcd.begin(); - lcd.setFontSize(FONT_SIZE_MEDIUM); - lcd.setColor(RGB16_YELLOW); - lcd.println("Freematics GPS Logger/Meter"); - lcd.setColor(RGB16_WHITE); - lcd.println("\r\nInitializing..."); + logger.initSender(); + SerialRF.println("Init..."); #if ENABLE_DATA_LOG - CheckSD(); - + if (CheckSD()) { int index = logger.openFile(); - lcd.print("File: "); - lcd.println(index); + SerialRF.print("File: "); + SerialRF.println(index); + } #endif // ENABLE_DATA_LOG #if USE_MPU6050 - Wire.begin(); - acc = initACC(); + Wire.begin(); + acc = initACC(); - lcd.print("ACC:"); - lcd.println(acc ? "YES" : "NO"); + SerialRF.print("ACC:"); + SerialRF.println(acc ? "YES" : "NO"); #endif - logger.initSender(); + GPSUART.begin(GPS_BAUDRATE); + delay(500); - GPSUART.begin(GPS_BAUDRATE); - delay(1000); - - if (GPSUART.available()) { - // init GPS - lcd.println("GPS:"); - byte n = 0xff; - uint32_t tm = 0; - start = millis(); - char progress[] = {'-', '/', '|', '\\'}; - do { - if (!GPSUART.available()) continue; - if (n == 0xff) { - lcd.print("YES"); - lcd.setCursor(0, 10); - lcd.print("SAT "); - n = 0; - } - char c = GPSUART.read(); - - if (sat == 0 && millis() - tm > 100) { - lcd.setCursor(32, 12); - lcd.write(progress[n]); - n = (n + 1) % 4; - tm = millis(); - } - - if (!gps.encode(c)) continue; - sat = gps.satellites(); - if (sat > 100) sat = 0; - lcd.setCursor(32, 12); - lcd.printInt(sat); - } while (sat < 3 && millis() - start < 30000); - } else { - lcd.println("No GPS"); + if (GPSUART.available()) { + // init GPS + SerialRF.println("Searching..."); + for (;;) { + if (!GPSUART.available()) continue; + char c = GPSUART.read(); + if (!gps.encode(c)) break; } - delay(1000); - - //GPSUART.println(PMTK_SET_NMEA_UPDATE_10HZ); - - - initScreen(); - - start = millis(); + } else { + SerialRF.println("No GPS"); + } } -void displayTimeSpeedDistance() +void loop() { - uint32_t elapsed = millis() - start; - uint16_t n; - - // display elapsed time (mm:ss:mm) - lcd.setColor(RGB16_WHITE); - lcd.setFontSize(FONT_SIZE_XLARGE); - n = elapsed / 60000; - lcd.setCursor(0, 18); - lcd.printInt(n, 2); - lcd.write(':'); - elapsed -= n * 60000; - lcd.setFlags(FLAG_PAD_ZERO); - lcd.printInt(n = elapsed / 1000, 2); - lcd.write('.'); - elapsed -= n * 1000; - lcd.setFontSize(FONT_SIZE_MEDIUM); - lcd.write(elapsed / 100 + '0'); - //if (sat < 3) return; - - - lcd.setFlags(0); - lcd.setColor(RGB16_WHITE); - lcd.setFontSize(FONT_SIZE_XLARGE); - - // display RPM - lcd.setCursor(120, 18); - lcd.printInt(120, 4); - - // display speed - n = speed / 1000; - lcd.setCursor(0, 3); - lcd.printInt(n, 3); - n = speed - n * 1000; - lcd.write('.'); - lcd.write(n / 100 + '0'); + static uint32_t lastTime = 0; - // display distance - lcd.setCursor(100, 3); - lcd.printInt(n = distance / 1000, 3); - n = distance - n * 1000; - lcd.write('.'); - lcd.write(n / 100 + '0'); - - // display watts - lcd.setCursor(0, 10); - lcd.printInt(123, 4); - lcd.setCursor(120, 10); - lcd.printInt(234, 4); - - // display altitude - lcd.setCursor(0, 26); - if (alt >= 0) { - lcd.printInt(alt, 4); - } else { - lcd.print(" -"); - lcd.printInt(-alt, 3); + if (GPSUART.available()) { + char c = GPSUART.read(); + if (gps.encode(c)) { + processGPS(); } + } - lcd.setCursor(120, 26); - if (startAlt != 32767) { - if (alt >= startAlt) { - lcd.printInt(alt - startAlt, 4); - } else { - lcd.print(" -"); - lcd.printInt(startAlt - alt, 3); - } - } else { - lcd.printInt(0, 4); - } -} - -void displayExtraInfo() -{ - lcd.setFontSize(FONT_SIZE_SMALL); - lcd.setColor(RGB16_WHITE); - lcd.setCursor(0, 0); - lcd.write(heading[0]); - lcd.write(heading[1]); - - lcd.setFlags(0); - lcd.setCursor(266, 0); - lcd.print(time); - lcd.setCursor(266, 2); - lcd.print(curLat, 5); - lcd.setCursor(266, 4); - lcd.print(curLon, 5); - lcd.setCursor(266, 6); - lcd.print(alt); - lcd.print(' '); - lcd.setCursor(266, 8); - lcd.print(sat); - lcd.print(' '); - - lcd.setCursor(266, 10); - lcd.printLong(records); - - lcd.setCursor(266, 12); - lcd.printInt(logger.dataSize >> 10); -} - -void loop() -{ - if (GPSUART.available()) { - char c = GPSUART.read(); - if (gps.encode(c)) { - processGPS(); - } else { - return; - } - } +#if ENABLE_DATA_LOG + // flush file every 3 seconds + if (logger.dataTime - lastTime >= 3000) { + lastTime = logger.dataTime; + logger.flushFile(); + } +#endif #if USE_MPU6050 - processACC(); + processACC(); #endif - - displayTimeSpeedDistance(); - displayExtraInfo(); } diff --git a/gpslogger/images.h b/gpslogger/images.h deleted file mode 100644 index 2f92ee1..0000000 --- a/gpslogger/images.h +++ /dev/null @@ -1,5 +0,0 @@ -static const PROGMEM uint8_t tick[16 *16 / 8] = -{0x00,0x80,0xC0,0xE0,0xC0,0x80,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0x78,0x30,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x1F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00}; - -static const PROGMEM uint8_t cross[16 *16 / 8] = -{0x00,0x0C,0x1C,0x3C,0x78,0xF0,0xE0,0xC0,0xE0,0xF0,0x78,0x3C,0x1C,0x0C,0x00,0x00,0x00,0x30,0x38,0x3C,0x1E,0x0F,0x07,0x03,0x07,0x0F,0x1E,0x3C,0x38,0x30,0x00,0x00}; |