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 OilTemperature.cpp Source File

OilTemperature.cpp

00001 #include "OilTemperature.h"
00002 
00003 const char OilTemperature::REQUEST_DATA[8] = {0x02, 0x21, 0x01, 0, 0, 0, 0, 0};
00004 const char OilTemperature::SECOND_MESSAGE[8] = {0x30, 0, 0, 0, 0, 0, 0, 0};
00005 
00006 OilTemperature::OilTemperature()
00007 : PidValue("Oil Temp", "C")
00008 {
00009 }
00010 
00011 bool OilTemperature::decode(const uint8_t* data, uint16_t length)
00012 {
00013     if (length < 2)
00014     {
00015         return false;
00016     }
00017     
00018     if ((length != 31) || (data[0] != 0x61) || (data[1] != 0x01))
00019     {
00020         return false;
00021     }
00022     
00023     m_value = data[30] - 40; // deg C
00024     return true;
00025 }