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
PidDecoder.cpp@7:a19b63c0a0fa, 2014-05-11 (annotated)
- Committer:
- chrta
- Date:
- Sun May 11 09:05:37 2014 +0000
- Revision:
- 7:a19b63c0a0fa
- Parent:
- 6:506b703a8acf
Changed Adafruit_GFX to my own fork.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chrta | 3:eb807d330292 | 1 | #include "PidDecoder.h" |
chrta | 5:0b229ba8ede5 | 2 | #include "EngineCoolantTemperature.h" |
chrta | 5:0b229ba8ede5 | 3 | #include "EngineRpm.h" |
chrta | 5:0b229ba8ede5 | 4 | #include "VehicleSpeed.h" |
chrta | 5:0b229ba8ede5 | 5 | #include "Throttle.h" |
chrta | 5:0b229ba8ede5 | 6 | #include "OilTemperature.h" |
chrta | 3:eb807d330292 | 7 | |
chrta | 5:0b229ba8ede5 | 8 | #include "DebugPrint.h" |
chrta | 6:506b703a8acf | 9 | #include "display.h" |
chrta | 3:eb807d330292 | 10 | |
chrta | 3:eb807d330292 | 11 | static VehicleSpeed speed; |
chrta | 3:eb807d330292 | 12 | static EngineRpm rpm; |
chrta | 3:eb807d330292 | 13 | static EngineCoolantTemp temp; |
chrta | 3:eb807d330292 | 14 | static Throttle throttle; |
chrta | 3:eb807d330292 | 15 | OilTemperature oilTemperature; |
chrta | 3:eb807d330292 | 16 | static PidValue* pids[] = |
chrta | 3:eb807d330292 | 17 | { &speed, &rpm, &temp, &throttle, &oilTemperature |
chrta | 6:506b703a8acf | 18 | }; |
chrta | 6:506b703a8acf | 19 | |
chrta | 6:506b703a8acf | 20 | extern Display display; |
chrta | 6:506b703a8acf | 21 | char buf[128]; |
chrta | 3:eb807d330292 | 22 | |
chrta | 3:eb807d330292 | 23 | void PidDecoder::decode(const uint8_t* data, uint16_t length) |
chrta | 3:eb807d330292 | 24 | { |
chrta | 3:eb807d330292 | 25 | for (unsigned int i = 0; i < sizeof(pids) / sizeof(pids[0]); i++) |
chrta | 3:eb807d330292 | 26 | { |
chrta | 3:eb807d330292 | 27 | if (pids[i]->decode(data, length)) |
chrta | 3:eb807d330292 | 28 | { |
chrta | 3:eb807d330292 | 29 | pc.printf("New Value for %s: ", pids[i]->getName()); |
chrta | 3:eb807d330292 | 30 | pids[i]->print(); |
chrta | 6:506b703a8acf | 31 | snprintf(buf, sizeof(buf), "%s: %d %s", pids[i]->getName(), pids[i]->getValue(), pids[i]->getUnit()); |
chrta | 6:506b703a8acf | 32 | display.sendTo(buf); |
chrta | 6:506b703a8acf | 33 | display.display(); |
chrta | 3:eb807d330292 | 34 | } |
chrta | 3:eb807d330292 | 35 | } |
chrta | 3:eb807d330292 | 36 | } |