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

EngineRpm.cpp

00001 #include "EngineRpm.h"
00002 
00003 const char EngineRpm::REQUEST_DATA[8] = {0x02, 0x01, 0x0C, 0, 0, 0, 0, 0};
00004 
00005 EngineRpm::EngineRpm()
00006 : PidValue("Engine RPM", "rpm")
00007 {
00008 }
00009 
00010 bool EngineRpm::decode(const uint8_t* data, uint16_t length)
00011 {
00012     if (length < 2)
00013     {
00014         return false;
00015     }
00016     
00017     if ((data[1] != 0x0C) || length != 4)
00018     {
00019         return false;
00020     }
00021     
00022     m_value = ((data[2] << 8) | data[3]) >> 2; //rpm
00023     return true;
00024 }