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

EngineRpm.cpp

Committer:
chrta
Date:
2014-04-27
Revision:
5:0b229ba8ede5
Child:
6:506b703a8acf

File content as of revision 5:0b229ba8ede5:

#include "EngineRpm.h"

EngineRpm::EngineRpm()
: PidValue("Engine RPM", "rpm")
{
}

bool EngineRpm::decode(const uint8_t* data, uint16_t length)
{
    if (length < 2)
    {
        return false;
    }
    
    if ((data[1] != 0x0C) || length != 4)
    {
        return false;
    }
    
    m_value = ((data[2] << 8) | data[3]) >> 2; //rpm
    return true;
}