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 | 1120 | void speedoUpdate() { | ||
10 |
1/2✓ Branch 0 taken 1120 times.
✗ Branch 1 not taken.
|
1/2✓ Decision 'true' taken 1120 times.
✗ Decision 'false' not taken.
|
1120 | if (!hasSpeedoInit) { |
11 | 1120 | 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 | 584 | void initSpeedometer() { | ||
26 | 584 | hasSpeedoInit = false; | ||
27 | ||||
28 |
1/2✓ Branch 1 taken 584 times.
✗ Branch 2 not taken.
|
1/2✓ Decision 'true' taken 584 times.
✗ Decision 'false' not taken.
|
584 | if (!isBrainPinValid(engineConfiguration->speedometerOutputPin)) { |
29 | 584 | return; | ||
30 | } | |||
31 | ||||
32 | ✗ | startSimplePwm(&speedoPwm, | ||
33 | "Speedometer", | |||
34 | &engine->scheduler, | |||
35 | &enginePins.speedoOut, | |||
36 | NAN, 0.5f); | |||
37 | ||||
38 | ✗ | hasSpeedoInit = true; | ||
39 | } | |||
40 |