summaryrefslogtreecommitdiff
path: root/samples/test_obd_i2c
diff options
context:
space:
mode:
authorStanley Huang <stanleyhuangyc@gmail.com>2015-02-27 21:07:41 +0800
committerStanley Huang <stanleyhuangyc@gmail.com>2015-02-27 21:07:41 +0800
commita726e4b4462fb25dd5ba39c06ac1ddf12cdd8fbc (patch)
tree36c49cfc49b6f13fe485d913067fcf1c25831ad4 /samples/test_obd_i2c
parentf52d3b35bb852fe21aac72821489a93dc3eb2f69 (diff)
download2021-arduino-obd-a726e4b4462fb25dd5ba39c06ac1ddf12cdd8fbc.tar.gz
2021-arduino-obd-a726e4b4462fb25dd5ba39c06ac1ddf12cdd8fbc.tar.bz2
2021-arduino-obd-a726e4b4462fb25dd5ba39c06ac1ddf12cdd8fbc.zip
Remove deprecated files
Diffstat (limited to 'samples/test_obd_i2c')
-rw-r--r--samples/test_obd_i2c/test_obd_i2c.ino144
1 files changed, 0 insertions, 144 deletions
diff --git a/samples/test_obd_i2c/test_obd_i2c.ino b/samples/test_obd_i2c/test_obd_i2c.ino
deleted file mode 100644
index 7d78004..0000000
--- a/samples/test_obd_i2c/test_obd_i2c.ino
+++ /dev/null
@@ -1,144 +0,0 @@
-#include <Arduino.h>
-#include <Wire.h>
-#include <OBD.h>
-#include <MPU6050.h>
-#include <SPI.h>
-
-#define CON Serial
-
-bool hasAAC = false;
-
-COBDI2C obd;
-
-bool initACC()
-{
- if (MPU6050_init() != 0)
- return false;
- return true;
-
-}
-void processACC()
-{
- accel_t_gyro_union data;
- MPU6050_readout(&data);
- CON.print('[');
- CON.print(millis());
- CON.print(']');
- // log x/y/z of accelerometer
- CON.print(" AX=");
- CON.print(data.value.x_accel);
- CON.print(" AY=");
- CON.print(data.value.y_accel);
- CON.print(" AZ=");
- CON.println(data.value.z_accel);
- // log x/y/z of gyro meter
- CON.print('[');
- CON.print(millis());
- CON.print(']');
- CON.print(" GX=");
- CON.print(data.value.x_gyro);
- CON.print(" GY=");
- CON.print(data.value.y_gyro);
- CON.print(" GZ=");
- CON.println(data.value.z_gyro);
-}
-
-void setup()
-{
- CON.begin(115200);
- //lcd.begin();
-
- CON.println("OBD TESTER");
-
- obd.begin();
-
- hasAAC = initACC();
- if (hasAAC)
- CON.println("MPU6050 detected");
-
- for (;;) {
- CON.println("Connecting...");
- if (obd.init()) break;
- delay(1000);
- }
- CON.println("Connected");
-
- obd.gpsStart(38400);
-
- //obd.btInit(9600);
-}
-
-byte getChecksum(char* buffer, byte len)
-{
- uint8_t checksum = 0;
- for (byte i = 0; i < len; i++) {
- checksum ^= buffer[i];
- }
- return checksum;
-}
-
-typedef struct {
- uint32_t time;
- uint16_t pid;
- uint8_t flags;
- uint8_t checksum;
- float value;
-} LOG_DATA;
-
-void sendData(uint16_t pid, int value)
-{
- LOG_DATA ld = {millis(), pid, 1, 0, value};
- ld.checksum = getChecksum((char*)&ld, sizeof(LOG_DATA));
- obd.btSend((byte*)&ld, sizeof(LOG_DATA));
-}
-
-void loop()
-{
- int value;
-
- //lcd.setCursor(0, 8);
-
- CON.print('[');
- CON.print(millis());
- CON.print(']');
- if (obd.read(PID_RPM, value, false)) {
- //sendData(0x100 | PID_RPM, value);
- CON.print(" RPM:");
- CON.print(value);
- }
- if (obd.read(PID_SPEED, value, false)) {
- //sendData(0x100 | PID_SPEED, value);
- CON.print(" SPD:");
- CON.print(value);
- }
- if (obd.read(PID_THROTTLE, value, false)) {
- //sendData(0x100 | PID_THROTTLE, value);
- CON.print(" THR:");
- CON.print(value);
- }
- CON.println("");
- if (hasAAC) {
- processACC();
- }
- //delay(500);
-
- GPS_DATA gpsdata;
- if (obd.gpsQuery(&gpsdata)) {
- CON.print('[');
- CON.print(millis());
- CON.print(']');
- CON.print(" LAT:");
- CON.print(gpsdata.lat, 6);
- CON.print(" LON:");
- CON.print(gpsdata.lon, 6);
- CON.print(" ALT:");
- CON.print(gpsdata.alt, 1);
- CON.print(" SAT:");
- CON.print(gpsdata.sat);
- CON.print(" AGE:");
- CON.print(gpsdata.age);
- CON.print(" TIME:");
- CON.println(gpsdata.time);
- }
- //delay(500);
-}