Small project to display some OBD values from the Toyota GT86/ Subaru BRZ/ Scion FRS on an OLED display.

Dependencies:   Adafruit_GFX MODSERIAL mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PidDecoder.cpp Source File

PidDecoder.cpp

00001 #include "PidDecoder.h"
00002 #include "EngineCoolantTemperature.h"
00003 #include "EngineRpm.h"
00004 #include "VehicleSpeed.h"
00005 #include "Throttle.h"
00006 #include "OilTemperature.h"
00007 
00008 #include "DebugPrint.h"
00009 #include "display.h"
00010 
00011 static VehicleSpeed speed;
00012 static EngineRpm rpm;
00013 static EngineCoolantTemp temp;
00014 static Throttle throttle;
00015 OilTemperature oilTemperature;
00016 static PidValue* pids[] =
00017 { &speed, &rpm, &temp, &throttle, &oilTemperature
00018 };
00019 
00020 extern Display display;
00021 char buf[128];                          
00022                              
00023 void PidDecoder::decode(const uint8_t* data, uint16_t length)
00024 {   
00025     for (unsigned int i = 0; i < sizeof(pids) / sizeof(pids[0]); i++)
00026     {
00027         if (pids[i]->decode(data, length))
00028         {
00029             pc.printf("New Value for %s: ", pids[i]->getName());
00030             pids[i]->print();
00031             snprintf(buf, sizeof(buf), "%s: %d %s", pids[i]->getName(), pids[i]->getValue(), pids[i]->getUnit());
00032             display.sendTo(buf);
00033             display.display();
00034         }
00035     }
00036 }