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
OilTemperature.cpp@6:506b703a8acf, 2014-05-01 (annotated)
- Committer:
- chrta
- Date:
- Thu May 01 09:29:29 2014 +0000
- Revision:
- 6:506b703a8acf
- Parent:
- 5:0b229ba8ede5
Changes for display.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chrta | 5:0b229ba8ede5 | 1 | #include "OilTemperature.h" |
chrta | 5:0b229ba8ede5 | 2 | |
chrta | 6:506b703a8acf | 3 | const char OilTemperature::REQUEST_DATA[8] = {0x02, 0x21, 0x01, 0, 0, 0, 0, 0}; |
chrta | 6:506b703a8acf | 4 | const char OilTemperature::SECOND_MESSAGE[8] = {0x30, 0, 0, 0, 0, 0, 0, 0}; |
chrta | 5:0b229ba8ede5 | 5 | |
chrta | 5:0b229ba8ede5 | 6 | OilTemperature::OilTemperature() |
chrta | 6:506b703a8acf | 7 | : PidValue("Oil Temp", "C") |
chrta | 5:0b229ba8ede5 | 8 | { |
chrta | 5:0b229ba8ede5 | 9 | } |
chrta | 5:0b229ba8ede5 | 10 | |
chrta | 5:0b229ba8ede5 | 11 | bool OilTemperature::decode(const uint8_t* data, uint16_t length) |
chrta | 5:0b229ba8ede5 | 12 | { |
chrta | 5:0b229ba8ede5 | 13 | if (length < 2) |
chrta | 5:0b229ba8ede5 | 14 | { |
chrta | 5:0b229ba8ede5 | 15 | return false; |
chrta | 5:0b229ba8ede5 | 16 | } |
chrta | 5:0b229ba8ede5 | 17 | |
chrta | 5:0b229ba8ede5 | 18 | if ((length != 31) || (data[0] != 0x61) || (data[1] != 0x01)) |
chrta | 5:0b229ba8ede5 | 19 | { |
chrta | 5:0b229ba8ede5 | 20 | return false; |
chrta | 5:0b229ba8ede5 | 21 | } |
chrta | 5:0b229ba8ede5 | 22 | |
chrta | 5:0b229ba8ede5 | 23 | m_value = data[30] - 40; // deg C |
chrta | 5:0b229ba8ede5 | 24 | return true; |
chrta | 5:0b229ba8ede5 | 25 | } |