GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 46.7% 7 / 0 / 15
Functions: 100.0% 2 / 0 / 2
Branches: 33.3% 2 / 0 / 6
Decisions: 33.3% 2 / - / 6

firmware/controllers/gauges/speedometer.cpp
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 90816 void speedoUpdate() {
16
1/2
✓ Branch 0 taken 90816 times.
✗ Branch 1 not taken.
1/2
✓ Decision 'true' taken 90816 times.
✗ Decision 'false' not taken.
90816 if (!hasSpeedoInit) {
17 90816 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 599 void initSpeedometer() {
32 599 hasSpeedoInit = false;
33
34
1/2
✓ Branch 1 taken 599 times.
✗ Branch 2 not taken.
1/2
✓ Decision 'true' taken 599 times.
✗ Decision 'false' not taken.
599 if (!isBrainPinValid(engineConfiguration->speedometerOutputPin)) {
35 599 return;
36 }
37
38 startSimplePwm(&speedoPwm,
39 "Speedometer",
40 &engine->scheduler,
41 &enginePins.speedoOut,
42 NAN, 0.5f);
43
44 hasSpeedoInit = true;
45 }
46