GCC Code Coverage Report


Directory: ./
File: firmware/controllers/gauges/speedometer.cpp
Date: 2025-10-03 00:57:22
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

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