| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | #include "pch.h" | |||
| 2 | ||||
| 3 | /** | |||
| 4 | * GMT800 platform (1999–2007 classic Chevrolet Silverado/GMC Sierra, Tahoe, Yukon, etc.) | |||
| 5 | * 4000 pulses per mile | |||
| 6 | * 2485 pulses per kilometer | |||
| 7 | */ | |||
| 8 | ||||
| 9 | #include "speedometer.h" | |||
| 10 | ||||
| 11 | static SimplePwm speedoPwm("speedo"); | |||
| 12 | ||||
| 13 | static bool hasSpeedoInit = false; | |||
| 14 | ||||
| 15 | 90815 | void speedoUpdate() { | ||
| 16 |
1/2✓ Branch 0 taken 90815 times.
✗ Branch 1 not taken.
|
1/2✓ Decision 'true' taken 90815 times.
✗ Decision 'false' not taken.
|
90815 | if (!hasSpeedoInit) { |
| 17 | 90815 | return; | ||
| 18 | } | |||
| 19 | ||||
| 20 | ✗ | float kph = Sensor::getOrZero(SensorType::VehicleSpeed); | ||
| 21 | ✗ | float kps = kph * (1. / 3600); | ||
| 22 | ✗ | float freq = kps * engineConfiguration->speedometerPulsePerKm; | ||
| 23 | ||||
| 24 | ✗ | if (freq < 1) { | ||
| 25 | ✗ | freq = NAN; | ||
| 26 | } | |||
| 27 | ||||
| 28 | ✗ | speedoPwm.setFrequency(freq); | ||
| 29 | } | |||
| 30 | ||||
| 31 | 591 | void initSpeedometer() { | ||
| 32 | 591 | hasSpeedoInit = false; | ||
| 33 | ||||
| 34 |
1/2✓ Branch 1 taken 591 times.
✗ Branch 2 not taken.
|
1/2✓ Decision 'true' taken 591 times.
✗ Decision 'false' not taken.
|
591 | if (!isBrainPinValid(engineConfiguration->speedometerOutputPin)) { |
| 35 | 591 | return; | ||
| 36 | } | |||
| 37 | ||||
| 38 | ✗ | startSimplePwm(&speedoPwm, | ||
| 39 | "Speedometer", | |||
| 40 | &engine->scheduler, | |||
| 41 | &enginePins.speedoOut, | |||
| 42 | NAN, 0.5f); | |||
| 43 | ||||
| 44 | ✗ | hasSpeedoInit = true; | ||
| 45 | } | |||
| 46 |