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

EngineCoolantTemperature.cpp

Committer:
chrta
Date:
2014-05-11
Revision:
7:a19b63c0a0fa
Parent:
6:506b703a8acf

File content as of revision 7:a19b63c0a0fa:

#include "EngineCoolantTemperature.h"

const char EngineCoolantTemp::REQUEST_DATA[8] = {0x02, 0x01, 0x05, 0, 0, 0, 0, 0};

EngineCoolantTemp::EngineCoolantTemp()
: PidValue("Coolant Temp", "C")
{
}

bool EngineCoolantTemp::decode(const uint8_t* data, uint16_t length)
{
    if (length < 2)
    {
        return false;
    }
    
    if ((data[1] != 0x05) || length != 3)
    {
        return false;
    }
    
    m_value = data[2] - 40; // degree celcius
    return true;
}