| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | #include "pch.h" | |||
| 2 | ||||
| 3 | #include "speedometer.h" | |||
| 4 | ||||
| 5 | static SimplePwm speedoPwm("speedo"); | |||
| 6 | ||||
| 7 | static bool hasSpeedoInit = false; | |||
| 8 | ||||
| 9 | 1101 | void speedoUpdate() { | ||
| 10 |
1/2✓ Branch 0 taken 1101 times.
✗ Branch 1 not taken.
|
1/2✓ Decision 'true' taken 1101 times.
✗ Decision 'false' not taken.
|
1101 | if (!hasSpeedoInit) { |
| 11 | 1101 | return; | ||
| 12 | } | |||
| 13 | ||||
| 14 | ✗ | float kph = Sensor::getOrZero(SensorType::VehicleSpeed); | ||
| 15 | ✗ | float kps = kph * (1. / 3600); | ||
| 16 | ✗ | float freq = kps * engineConfiguration->speedometerPulsePerKm; | ||
| 17 | ||||
| 18 | ✗ | if (freq < 1) { | ||
| 19 | ✗ | freq = NAN; | ||
| 20 | } | |||
| 21 | ||||
| 22 | ✗ | speedoPwm.setFrequency(freq); | ||
| 23 | } | |||
| 24 | ||||
| 25 | 585 | void initSpeedometer() { | ||
| 26 | 585 | hasSpeedoInit = false; | ||
| 27 | ||||
| 28 |
1/2✓ Branch 1 taken 585 times.
✗ Branch 2 not taken.
|
1/2✓ Decision 'true' taken 585 times.
✗ Decision 'false' not taken.
|
585 | if (!isBrainPinValid(engineConfiguration->speedometerOutputPin)) { |
| 29 | 585 | return; | ||
| 30 | } | |||
| 31 | ||||
| 32 | ✗ | startSimplePwm(&speedoPwm, | ||
| 33 | "Speedometer", | |||
| 34 | &engine->scheduler, | |||
| 35 | &enginePins.speedoOut, | |||
| 36 | NAN, 0.5f); | |||
| 37 | ||||
| 38 | ✗ | hasSpeedoInit = true; | ||
| 39 | } | |||
| 40 |