diff options
author | Stanley Huang <stanleyhuangyc@gmail.com> | 2013-08-07 01:29:40 +0800 |
---|---|---|
committer | Stanley Huang <stanleyhuangyc@gmail.com> | 2013-08-07 01:29:40 +0800 |
commit | ed5d853f77f12fb9c286ae8e1a705582f1996de2 (patch) | |
tree | 7814517fca14e3d38c82fe8414926ec3937eb6ff | |
parent | 9e3c092a8ac7b75f60a9e875b007c0210cf195f3 (diff) | |
download | 2021-arduino-obd-ed5d853f77f12fb9c286ae8e1a705582f1996de2.tar.gz 2021-arduino-obd-ed5d853f77f12fb9c286ae8e1a705582f1996de2.tar.bz2 2021-arduino-obd-ed5d853f77f12fb9c286ae8e1a705582f1996de2.zip |
add GPS Logger
-rw-r--r-- | gpslogger/datalogger.h | 246 | ||||
-rw-r--r-- | gpslogger/gpslogger.cbp | 664 | ||||
-rw-r--r-- | gpslogger/gpslogger.depend | 69 | ||||
-rw-r--r-- | gpslogger/gpslogger.ino | 462 | ||||
-rw-r--r-- | gpslogger/images.h | 5 |
5 files changed, 1446 insertions, 0 deletions
diff --git a/gpslogger/datalogger.h b/gpslogger/datalogger.h new file mode 100644 index 0000000..9368548 --- /dev/null +++ b/gpslogger/datalogger.h @@ -0,0 +1,246 @@ +// configurations +#define ENABLE_DATA_OUT 0 +#define ENABLE_DATA_LOG 1 + +typedef enum { + LOG_TYPE_DEFAULT = 0, + LOG_TYPE_0_60, + LOG_TYPE_0_100, + LOG_TYPE_100_200, + LOG_TYPE_400M, + LOG_TYPE_LAPS, + LOG_TYPE_ROUTE, +} LOG_TYPES; + +#define FLAG_CAR 0x1 +#define FLAG_CYCLING 0x2 +#define FLAG_OBD 0x10 +#define FLAG_GPS 0x20 +#define FLAG_ACC 0x40 + +typedef struct { + uint32_t time; + uint16_t pid; + uint8_t flags; + uint8_t checksum; + float value; +} LOG_DATA; + +typedef struct { + uint32_t time; + uint16_t pid; + uint8_t flags; + uint8_t checksum; + float value[3]; +} LOG_DATA_COMM; + +typedef struct { + uint32_t time; /* e.g. 1307281259 */ + uint16_t pid; + uint8_t message; + uint8_t checksum; + uint16_t fileIndex; + uint16_t fileSize; /* KB */ + uint16_t logFlags; + uint8_t logType; + uint8_t data[5]; +} LOG_DATA_FILE_INFO; + +typedef struct { + uint32_t time; + uint16_t pid; + uint8_t message; + uint8_t checksum; + uint8_t data[12]; +} LOG_DATA_COMMAND; + +typedef struct { + uint32_t id; + uint32_t dataOffset; + uint8_t ver; + uint8_t logType; + uint16_t flags; + uint32_t dateTime; //4, YYMMDDHHMM, e.g. 1305291359 + /* + uint8_t devid[8]; + uint8_t vin[24]; + uint8_t unused[84]; + */ +} HEADER; + +#define HEADER_LEN 128 /* bytes */ + +#define PID_GPS_COORDINATES 0xF00A +#define PID_GPS_ALTITUDE 0xF00C +#define PID_GPS_SPEED 0xF00D +#define PID_GPS_HEADING 0xF00E +#define PID_GPS_SAT_COUNT 0xF00F +#define PID_GPS_TIME 0xF010 + +#define PID_ACC 0xF020 +#define PID_GYRO 0xF021 + +#define PID_MESSAGE 0xFE00 + +#define MSG_FILE_LIST_BEGIN 0x1 +#define MSG_FILE_LIST_END 0x2 +#define MSG_FILE_INFO 0x3 +#define MSG_FILE_REQUEST 0x4 + +#define FILE_NAME_FORMAT "/DAT%05d.LOG" + +#if ENABLE_DATA_OUT +#if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) + SoftwareSerial mySerial(A8, A9); /* for BLE Shield on MEGA*/ +#elif defined(__AVR_ATmega644P__) + SoftwareSerial mySerial(9, 10); /* for Microduino */ +#else + SoftwareSerial mySerial(A2, A3); /* for BLE Shield on UNO*/ +#endif +#endif + +class CDataLogger { +public: + void initSender() + { +#if ENABLE_DATA_OUT + mySerial.begin(9600); +#endif + } +#if ENABLE_DATA_OUT + void sendFileInfo(File& file) + { + if (file.size() < HEADER_LEN) return; + + LOG_DATA_FILE_INFO info = {0}; + info.fileIndex = atol(file.name() + 3); + if (info.fileIndex == 0) return; + + HEADER hdr; + if (file.readBytes((char*)&hdr, sizeof(hdr)) != sizeof(hdr)) return; + + info.pid = PID_MESSAGE; + info.message = MSG_FILE_INFO; + info.fileSize = file.size(); + info.time = hdr.dateTime; + info.logType = hdr.logType; + info.logFlags = hdr.flags; + info.checksum = getChecksum((char*)&info, sizeof(info)); + mySerial.write((uint8_t*)&info, sizeof(info)); + } + void sendCommand(byte message, void* data = 0, byte bytes = 0) + { + LOG_DATA_COMMAND msg = {0, PID_MESSAGE, message}; + if (data) memcpy(msg.data, data, bytes); + msg.checksum = getChecksum((char*)&msg, sizeof(msg)); + mySerial.write((uint8_t*)&msg, sizeof(msg)); + } + bool receiveCommand(LOG_DATA_COMMAND& msg) + { + if (!mySerial.available()) + return false; + + if (mySerial.readBytes((char*)&msg, sizeof(msg)) != sizeof(msg)) + return false; + + uint8_t checksum = msg.checksum; + msg.checksum = 0; + if (getChecksum((char*)&msg, sizeof(msg)) != msg.checksum) { + return false; + } + return true; + } +#endif + void logData(uint16_t pid, float value) + { + LOG_DATA_COMM ld = {dataTime, pid, 1, 0, value}; + ld.checksum = getChecksum((char*)&ld, 12); +#if ENABLE_DATA_OUT + mySerial.write((uint8_t*)&ld, 12); +#endif +#if ENABLE_DATA_LOG + sdfile.write((uint8_t*)&ld, 12); +#endif + dataSize += 12; + } + void logData(uint16_t pid, float value1, float value2) + { + LOG_DATA_COMM ld = {dataTime, pid, 2, 0, {value1, value2}}; + ld.checksum = getChecksum((char*)&ld, 16); +#if ENABLE_DATA_OUT + mySerial.write((uint8_t*)&ld, 16); +#endif +#if ENABLE_DATA_LOG + sdfile.write((uint8_t*)&ld, 16); +#endif + dataSize += 16; + } + void logData(uint16_t pid, float value1, float value2, float value3) + { + LOG_DATA_COMM ld = {dataTime, pid, 3, 0, {value1, value2, value3}}; + ld.checksum = getChecksum((char*)&ld, 20); +#if ENABLE_DATA_OUT + mySerial.write((uint8_t*)&ld, 20); +#endif +#if ENABLE_DATA_LOG + sdfile.write((uint8_t*)&ld, 20); +#endif + dataSize += 20; + } +#if ENABLE_DATA_LOG + uint16_t openFile(LOG_TYPES logType, uint16_t logFlags = 0, uint32_t dateTime = 0) + { + uint16_t fileIndex; + char filename[24] = "/FRMATICS"; + + if (SD.exists(filename)) { + for (fileIndex = 1; fileIndex; fileIndex++) { + sprintf(filename + 9, FILE_NAME_FORMAT, fileIndex); + if (!SD.exists(filename)) { + break; + } + } + if (fileIndex == 0) + return 0; + } else { + SD.mkdir(filename); + fileIndex = 1; + sprintf(filename + 9, FILE_NAME_FORMAT, 1); + } + + sdfile = SD.open(filename, FILE_WRITE); + if (!sdfile) { + return 0; + } + + HEADER hdr = {'UDUS', HEADER_LEN, 1, logType, logFlags, dateTime}; + sdfile.write((uint8_t*)&hdr, sizeof(hdr)); + for (byte i = 0; i < HEADER_LEN - sizeof(hdr); i++) + sdfile.write((uint8_t)0); + dataSize = HEADER_LEN; + return fileIndex; + } + void closeFile() + { + sdfile.close(); + } + void flushFile() + { + sdfile.flush(); + } +#endif + uint32_t dataTime; + uint32_t dataSize; +private: + static byte getChecksum(char* buffer, byte len) + { + uint8_t checksum = 0; + for (byte i = 0; i < len; i++) { + checksum ^= buffer[i]; + } + return checksum; + } +#if ENABLE_DATA_LOG + File sdfile; +#endif +}; diff --git a/gpslogger/gpslogger.cbp b/gpslogger/gpslogger.cbp new file mode 100644 index 0000000..c1c6ef3 --- /dev/null +++ b/gpslogger/gpslogger.cbp @@ -0,0 +1,664 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_project_file> + <FileVersion major="1" minor="6" /> + <Project> + <Option title="gpslogger" /> + <Option pch_mode="2" /> + <Option compiler="gcc" /> + <Build> + <Target title="Simulator - Debug"> + <Option output="build/telelogger_sim.exe" prefix_auto="1" extension_auto="0" /> + <Option object_output="obj/Debug/" /> + <Option type="1" /> + <Option compiler="GCC" /> + <Compiler> + <Add option="-g" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-DARDUSIM" /> + <Add option="-D__AVR_ATmega2560__" /> + <Add option="-x c++" /> + <Add directory="$(ARDUINO_DIR)/arduino/cores" /> + <Add directory="$(ARDUINO_DIR)/arduino/variants/standard" /> + <Add directory="$(ARDUINO_DIR)/include" /> + </Compiler> + <Linker> + <Add option="-lardusim" /> + </Linker> + <Environment> + <Variable name="ARDUINO_DIR" value="$(APP_PATH)\ardusim" /> + </Environment> + </Target> + <Target title="Simulator - Release"> + <Option output="build/telelogger_sim.exe" prefix_auto="1" extension_auto="0" /> + <Option object_output="obj/Release/" /> + <Option type="1" /> + <Option compiler="GCC" /> + <Compiler> + <Add option="-O2" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-DARDUSIM" /> + <Add option="-D__AVR_ATmega2560__" /> + <Add option="-x c++" /> + <Add directory="$(ARDUINO_DIR)/arduino/cores" /> + <Add directory="$(ARDUINO_DIR)/arduino/variants/standard" /> + <Add directory="$(ARDUINO_DIR)/include" /> + </Compiler> + <Linker> + <Add option="-s" /> + <Add option="-lardusim" /> + </Linker> + <Environment> + <Variable name="ARDUINO_DIR" value="$(APP_PATH)\ardusim" /> + </Environment> + </Target> + <Target title="Arduino Uno"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega328P__" /> + <Add option="-O2" /> + <Add option="-Os" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/standard" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Uno" /> + <Variable name="BOARD_ID" value="uno" /> + <Variable name="MCU" value="atmega328p" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="115200" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Arduino Leonardo"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega32U4__" /> + <Add option="-DUSB_VID=0x2341" /> + <Add option="-DUSB_PID=0x8036" /> + <Add option="-O2" /> + <Add option="-Os" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/leonardo" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Leonardo" /> + <Variable name="BOARD_ID" value="leonardo" /> + <Variable name="MCU" value="atmega32u4" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="57600" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Arduino Esplora"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega32U4__" /> + <Add option="-DUSB_VID=0x2341" /> + <Add option="-DUSB_PID=0x8037" /> + <Add option="-O2" /> + <Add option="-Os" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/leonardo" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Esplora" /> + <Variable name="BOARD_ID" value="esplora" /> + <Variable name="MCU" value="atmega32u4" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="57600" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Arduino Micro"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega32U4__" /> + <Add option="-DUSB_VID=0x2341" /> + <Add option="-DUSB_PID=0x803C" /> + <Add option="-O2" /> + <Add option="-Os" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/micro" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Micro" /> + <Variable name="BOARD_ID" value="micro" /> + <Variable name="MCU" value="atmega32u4" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="57600" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Arduino Duemilanove (328)"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega328P__" /> + <Add option="-O2" /> + <Add option="-Os" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/standard" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Duemilanove (328)" /> + <Variable name="BOARD_ID" value="duemilanove328" /> + <Variable name="MCU" value="atmega328p" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="57600" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Arduino Duemilanove (168)"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega168__" /> + <Add option="-O2" /> + <Add option="-Os" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/standard" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Duemilanove (168)" /> + <Variable name="BOARD_ID" value="duemilanove168" /> + <Variable name="MCU" value="atmega168" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="19200" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Arduino Nano (328)"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega328P__" /> + <Add option="-O2" /> + <Add option="-Os" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/eightanaloginputs" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Nano (328)" /> + <Variable name="BOARD_ID" value="nano328" /> + <Variable name="MCU" value="atmega328p" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="57600" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Arduino Nano (168)"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega168__" /> + <Add option="-O2" /> + <Add option="-Os" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/eightanaloginputs" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Nano (168)" /> + <Variable name="BOARD_ID" value="nano168" /> + <Variable name="MCU" value="atmega168" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="19200" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Arduino Mini (328)"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega328P__" /> + <Add option="-O2" /> + <Add option="-Os" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/eightanaloginputs" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Mini (328)" /> + <Variable name="BOARD_ID" value="mini328" /> + <Variable name="MCU" value="atmega328p" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="57600" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Arduino Mini (168)"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega168__" /> + <Add option="-O2" /> + <Add option="-Os" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/eightanaloginputs" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Mini (168)" /> + <Variable name="BOARD_ID" value="mini168" /> + <Variable name="MCU" value="atmega168" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="19200" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Arduino Pro Mini (328)"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega328P__" /> + <Add option="-O2" /> + <Add option="-Os" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/standard" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Pro Mini (328)" /> + <Variable name="BOARD_ID" value="promini328" /> + <Variable name="MCU" value="atmega328p" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="57600" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Arduino Pro Mini (168)"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega168__" /> + <Add option="-O2" /> + <Add option="-Os" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/standard" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Pro Mini (168)" /> + <Variable name="BOARD_ID" value="promini168" /> + <Variable name="MCU" value="atmega168" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="19200" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Arduino Mega 2560/ADK"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega2560__" /> + <Add option="-O2" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/mega" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Mega 2560\ADK" /> + <Variable name="BOARD_ID" value="mega2560" /> + <Variable name="MCU" value="atmega2560" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="57600" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Arduino Mega 1280"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega1280__" /> + <Add option="-O2" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/mega" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Mega 1280" /> + <Variable name="BOARD_ID" value="mega1280" /> + <Variable name="MCU" value="atmega1280" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="57600" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Arduino Mega 8"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega328P__" /> + <Add option="-O2" /> + <Add option="-Os" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/standard" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Arduino Mega 8" /> + <Variable name="BOARD_ID" value="mega8" /> + <Variable name="MCU" value="atmega8" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="19200" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + <Target title="Microduino Core+ (644P)"> + <Option output="build/telelogger_${BOARD_ID}.elf" prefix_auto="1" extension_auto="0" /> + <Option object_output="build" /> + <Option type="1" /> + <Option compiler="avrgcc" /> + <Compiler> + <Add option="-x c++" /> + <Add option="-mmcu=$(MCU)" /> + <Add option="-DF_CPU=16000000L" /> + <Add option="-D__AVR_ATmega644P__" /> + <Add option="-O2" /> + <Add option="-Os" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" /> + <Add directory="$(ARDUINO_DIR)/libraries" /> + <Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/plus" /> + </Compiler> + <Linker> + <Add option="-mmcu=$(MCU)" /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option='"$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add option="-s" /> + </Linker> + <ExtraCommands> + <Add before='$(TARGET_COMPILER_DIR)ArduinoUploader "$(PROJECT_DIR)." $(BOARD_ID) - $(MCU_CLOCK) 0 "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/lib_${BOARD_ID}_${MCU_CLOCK}.a" "$(PROJECT_DIR)${TARGET_OUTPUT_DIR}/core_${BOARD_ID}_${MCU_CLOCK}.a"' /> + <Add after='avr-objcopy -O ihex -R .eeprom -R .eesafe "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).hex"' /> + <Add after='avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex "$(TARGET_OUTPUT_FILE)" "$(TARGET_OUTPUT_FILE).eep.hex"' /> + <Add after='avr-size --mcu=$(MCU) --format=avr "$(TARGET_OUTPUT_FILE)"' /> + </ExtraCommands> + <Environment> + <Variable name="BOARD" value="Microduino Core+ (644P)" /> + <Variable name="BOARD_ID" value="uduino644p" /> + <Variable name="MCU" value="atmega644p" /> + <Variable name="MCU_CLOCK" value="16" /> + <Variable name="UPLOAD_BAUDRATE" value="115200" /> + <Variable name="UPLOAD_PORT" value="" /> + </Environment> + </Target> + </Build> + <Compiler> + <Add directory="." /> + </Compiler> + <Unit filename="datalogger.h" /> + <Unit filename="gpslogger.ino"> + <Option compile="1" /> + <Option link="1" /> + </Unit> + <Extensions> + <code_completion /> + <debugger /> + </Extensions> + </Project> +</CodeBlocks_project_file> diff --git a/gpslogger/gpslogger.depend b/gpslogger/gpslogger.depend new file mode 100644 index 0000000..76777d7 --- /dev/null +++ b/gpslogger/gpslogger.depend @@ -0,0 +1,69 @@ +# depslib dependency file v1.0 +1375809089 source:e:\projects\sudulog\arduino\gpslogger\gpslogger.ino + <Arduino.h> + <Wire.h> + <MultiLCD.h> + <SD.h> + <TinyGPS.h> + <MPU6050.h> + <SoftwareSerial.h> + "datalogger.h" + "images.h" + +1371033101 d:\apps\codeblocks\arduino\hardware\arduino\cores\arduino\arduino.h + <stdlib.h> + <string.h> + <math.h> + <avr/pgmspace.h> + <avr/io.h> + <avr/interrupt.h> + "binary.h" + "WCharacter.h" + "WString.h" + "HardwareSerial.h" + "pins_arduino.h" + +1362986950 d:\apps\codeblocks\arduino\hardware\arduino\cores\arduino\binary.h + +1362986950 d:\apps\codeblocks\arduino\hardware\arduino\cores\arduino\wcharacter.h + <ctype.h> + +1371033133 d:\apps\codeblocks\arduino\hardware\arduino\cores\arduino\wstring.h + <stdlib.h> + <string.h> + <ctype.h> + <avr/pgmspace.h> + +1362986950 d:\apps\codeblocks\arduino\hardware\arduino\cores\arduino\hardwareserial.h + <inttypes.h> + "Stream.h" + "USBAPI.h" + +1371032829 d:\apps\codeblocks\arduino\hardware\arduino\cores\arduino\stream.h + <inttypes.h> + "Print.h" + +1362986950 d:\apps\codeblocks\arduino\hardware\arduino\cores\arduino\print.h + <inttypes.h> + <stdio.h> + "WString.h" + "Printable.h" + +1362986950 d:\apps\codeblocks\arduino\hardware\arduino\cores\arduino\printable.h + <new.h> + +1362986950 d:\apps\codeblocks\arduino\hardware\arduino\cores\arduino\new.h + <stdlib.h> + +1362986950 d:\apps\codeblocks\arduino\hardware\arduino\cores\arduino\usbapi.h + +1362986950 d:\apps\codeblocks\arduino\hardware\arduino\variants\standard\pins_arduino.h + <avr/pgmspace.h> + +1375367080 e:\projects\sudulog\arduino\gpslogger\datalogger.h + +1370839737 e:\projects\sudulog\arduino\gpslogger\images.h + +1371040485 d:\apps\codeblocks\arduino\hardware\arduino\variants\plus\pins_arduino.h + <avr/pgmspace.h> + diff --git a/gpslogger/gpslogger.ino b/gpslogger/gpslogger.ino new file mode 100644 index 0000000..540962c --- /dev/null +++ b/gpslogger/gpslogger.ino @@ -0,0 +1,462 @@ +#include <Arduino.h> +#include <Wire.h> +#include <MultiLCD.h> +#include <SD.h> +#include <TinyGPS.h> +#include <MPU6050.h> +#include <SoftwareSerial.h> +#include "datalogger.h" +#include "images.h" + +#define DISPLAY_MODES 2 + +//#define SD_CS_PIN 4 // ethernet shield +#define SD_CS_PIN 7 // microduino +//#define SD_CS_PIN 10 // SD breakout + +LCD_SSD1306 lcd; +//LCD_ZTOLED lcd; + +uint32_t start; +uint32_t distance = 0; +uint16_t speed = 0; +byte sat = 0; +uint16_t records = 0; +char heading[2]; +bool acc; +byte displayMode = 0; + +#if defined(__AVR_ATmega644P__) +#define GPSUART Serial1 +#else +#define GPSUART Serial +#endif +#define GPS_BAUDRATE 115200 + +#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F" + +TinyGPS gps; + +// SD card +Sd2Card card; +SdVolume volume; +File sdfile; + +CDataLogger logger; + +bool initACC() +{ + 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); +} + +void processGPS() +{ + static long lastLat = 0; + static long lastLon = 0; + static uint32_t lastTime = 0; + uint32_t time; + + // parsed GPS data is ready + logger.dataTime = millis(); + + { + uint32_t date; + gps.get_datetime(&date, &time, 0); + logger.logData(PID_GPS_TIME, time, date); + } + + speed = (uint16_t)(gps.speed() * 1852 / 100); + logger.logData(PID_GPS_SPEED, speed, 0); + + byte satnew = gps.satellites(); + if (satnew < 100) sat = satnew; + + { + long lat, lon; + gps.get_position(&lat, &lon, 0); + logger.logData(PID_GPS_COORDINATES, (float)lat / 100000, (float)lon / 100000); + + if (logger.dataTime - lastTime >= 5000) { + int16_t latDiff = lat - lastLat; + int16_t lonDiff = lon - lastLon; + + 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] = ' '; + } + + uint16_t d = sqrt(latDiff * latDiff + lonDiff * lonDiff); + if (d >= 10) { + distance += d; + } + lastTime = logger.dataTime; + + } + lastLat = lat; + lastLon = lon; + } + + { + long alt = gps.altitude(); + logger.logData(PID_GPS_ALTITUDE, (float)alt); + } + records++; +} + +bool CheckSD() +{ + lcd.setCursor(0, 0); + lcd.setFont(FONT_SIZE_MEDIUM); + 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.clear(); + lcd.print(type); + lcd.write(' '); + if (!volume.init(card)) { + lcd.print("No FAT!"); + return false; + } + + uint32_t volumesize = volume.blocksPerCluster(); + volumesize >>= 1; // 512 bytes per block + volumesize *= volume.clusterCount(); + volumesize >>= 10; + + sprintf(buf, "%dGB", (int)((volumesize + 511) / 1000)); + lcd.print(buf); + } else { + lcd.clear(); + lcd.print("SD"); + lcd.draw(cross, 32, 0, 16, 16); + return false; + } + + if (!SD.begin(SD_CS_PIN)) { + lcd.setCursor(0, 0); + lcd.print("Bad SD"); + return false; + } + return true; +} + +void initScreen() +{ + lcd.clear(); + switch (displayMode) { + case 0: + lcd.setFont(FONT_SIZE_MEDIUM); + lcd.setCursor(48, 1); + lcd.write('.'); + lcd.setCursor(48, 6); + lcd.write('.'); + lcd.setFont(FONT_SIZE_SMALL); + lcd.setCursor(110, 0); + lcd.write(':'); + lcd.setCursor(110, 1); + lcd.print("kph"); + lcd.setCursor(64, 3); + lcd.print("km/h"); + lcd.setCursor(76, 7); + lcd.print("km"); + lcd.setCursor(104, 6); + lcd.print("S:"); + break; + default: + lcd.setFont(FONT_SIZE_MEDIUM); + lcd.setCursor(48, 0); + lcd.write(':'); + lcd.setCursor(48, 3); + lcd.write('.'); + lcd.setCursor(48, 6); + lcd.write('.'); + lcd.setFont(FONT_SIZE_SMALL); + lcd.setCursor(88, 1); + lcd.write('.'); + lcd.setCursor(76, 4); + lcd.print("kph"); + lcd.setCursor(76, 7); + lcd.print("km"); + } + lcd.setCursor(104, 6); + lcd.print("S:"); +} + +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.setFont(FONT_SIZE_SMALL); + 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); +} + +void setup() +{ + lcd.begin(); + lcd.setFont(FONT_SIZE_MEDIUM); + + // init button + pinMode(8, INPUT); + + CheckSD(); + + unsigned long t = millis(); + + lcd.setCursor(0, 2); + lcd.print("ACC"); + lcd.draw(acc ? tick : cross, 32, 16, 16, 16); + + lcd.setCursor(0, 4); + lcd.print("GPS"); + lcd.draw(cross, 32, 32, 16, 16); + + Serial.begin(57600); + GPSUART.begin(GPS_BAUDRATE); + logger.initSender(); + + acc = initACC(); + + byte n = 0xff; + uint32_t tm = 0; + start = millis(); + char progress[] = {'-', '/', '|', '\\'}; + do { + if (!GPSUART.available()) continue; + if (n == 0xff) { + lcd.draw(tick, 32, 32, 16, 16); + lcd.setCursor(0, 6); + lcd.print("SAT "); + n = 0; + } + char c = GPSUART.read(); + + if (sat == 0 && millis() - tm > 100) { + lcd.setCursor(32, 6); + lcd.write(progress[n]); + n = (n + 1) % 4; + tm = millis(); + } + + if (!gps.encode(c)) continue; + + if (acc) { + displayMPU6050(); + } + + sat = gps.satellites(); + if (sat < 100) { + lcd.setCursor(32, 6); + lcd.printInt(sat); + } + } while (sat < 3 || millis() - start < 3000); + //} while (0); + + GPSUART.println(PMTK_SET_NMEA_UPDATE_10HZ); + + logger.openFile(LOG_TYPE_ROUTE, FLAG_CYCLING | FLAG_GPS | (acc ? FLAG_ACC : 0)); + + initScreen(); + + Serial.begin(9600); + + start = millis(); +} + +void displaySpeedDistance() +{ + // display speed + lcd.setFont(FONT_SIZE_XLARGE); + uint16_t n = speed / 1000; + if (n >= 100) { + lcd.setCursor(0, 0); + lcd.printInt(n, 3); + } else { + lcd.setCursor(16, 0); + lcd.printInt(n, 2); + } + lcd.setCursor(56, 0); + n = speed - n * 1000; + lcd.printInt(n / 100); + + // display distance + lcd.setCursor(0, 5); + lcd.printInt(n = distance / 1000, 3); + lcd.setCursor(56, 5); + n = distance - n * 1000; + lcd.printInt(n / 100); + + // display average speed + uint16_t elapsed = (millis() - start) / 1000; + byte avgSpeed = distance * 36 / elapsed / 10; + lcd.setFont(FONT_SIZE_SMALL); + lcd.setCursor(92, 1); + lcd.printInt(avgSpeed, 3); + + // display elapsed time (mm:ss) + lcd.setFlags(FLAG_PAD_ZERO); + lcd.setCursor(98, 0); + lcd.printInt(n = elapsed / 60, 2); + elapsed -= n * 60; + lcd.setCursor(116, 0); + lcd.printInt(elapsed, 2); + + lcd.setFlags(0); +} + +void displayTimeSpeedDistance() +{ + uint32_t elapsed = millis() - start; + uint16_t n; + + // display speed + lcd.setFont(FONT_SIZE_LARGE); + n = speed / 1000; + if (n >= 100) { + lcd.setCursor(0, 3); + lcd.printInt(n, 3); + } else { + lcd.setCursor(16, 3); + lcd.printInt(n, 2); + } + lcd.setCursor(56, 3); + n = speed - n * 1000; + lcd.printInt(n / 100); + + // display distance + lcd.setCursor(0, 6); + lcd.printInt(n = distance / 1000, 3); + lcd.setCursor(56, 6); + n = distance - n * 1000; + lcd.printInt(n / 100); + + // display elapsed time (mm:ss:mm) + n = elapsed / 60000; + if (n >= 100) { + lcd.setCursor(0, 0); + lcd.printInt(n, 3); + } else { + lcd.setCursor(16, 0); + lcd.printInt(n, 2); + } + elapsed -= n * 60000; + lcd.setFlags(FLAG_PAD_ZERO); + lcd.setCursor(56, 0); + lcd.printInt(n = elapsed / 1000, 2); + elapsed -= n * 1000; + lcd.setCursor(96, 1); + lcd.setFont(FONT_SIZE_SMALL); + lcd.printInt(n = elapsed / 10, 2); + + lcd.setFlags(0); +} + +void displayMinorInfo() +{ + lcd.setCursor(0, 0); + lcd.write(heading[0]); + lcd.write(heading[1]); + + lcd.setFlags(0); + lcd.setFont(FONT_SIZE_SMALL); + lcd.setCursor(116, 6); + lcd.printInt((uint16_t)sat, 2); + lcd.setCursor(98, 7); + lcd.printInt(records, 5); +} + +void loop() +{ + if (GPSUART.available()) { + char c = GPSUART.read(); + if (gps.encode(c)) { + processGPS(); + } else { + return; + } + } + + processACC(); + + switch (displayMode) { + case 0: + displaySpeedDistance(); + break; + default: + displayTimeSpeedDistance(); + } + + displayMinorInfo(); + + if (digitalRead(8) == 0) { + delay(50); + if (digitalRead(8) == 0) { + displayMode = (displayMode + 1) % DISPLAY_MODES; + while (digitalRead(8) == 0); + initScreen(); + } + } +} diff --git a/gpslogger/images.h b/gpslogger/images.h new file mode 100644 index 0000000..2f92ee1 --- /dev/null +++ b/gpslogger/images.h @@ -0,0 +1,5 @@ +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}; |