GCC Code Coverage Report


Directory: ./
File: firmware/util/math/deadband.h
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 22 0 22
Functions: 100.0% 5 0 5
Branches: 75.0% 6 0 8
Decisions: 0.0% 0 - 2

Line Branch Decision Exec Source
1 /**
2 * @file deadband.h
3 *
4 * @date April 6, 2020
5 * @author Matthew Kennedy, (c) 2020
6 */
7
8 #pragma once
9
10 #include "efilib.h"
11
12 template <int TDeadband>
13 class Deadband {
14 public:
15 466 bool gt(float lhs, float rhs) {
16 // If we're within the deadband, be "sticky" with the previous value
17 466 float absError = std::abs(lhs - rhs);
18
19 // If there's enough error, actually compare values
20
6/8
Deadband<5>::gt(float, float):
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 17 times.
Deadband<200>::gt(float, float):
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 8 times.
Deadband<25>::gt(float, float):
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
Deadband<2>::gt(float, float):
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
466 if (absError > TDeadband) {
21 441 m_lastState = lhs > rhs;
22 }
23
24 466 return m_lastState;
25 }
26
27 // Deadband has no concept of equal - only greater and less, so to compute gt, we just swap args
28 27 bool lt(float lhs, float rhs) {
29 27 return gt(rhs, lhs);
30 }
31
32 private:
33 bool m_lastState =false;
34 };
35