GCC Code Coverage Report


Directory: ./
File: firmware/controllers/sensors/tps.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 28.6% 8 0 28
Functions: 28.6% 2 0 7
Branches: 66.7% 2 0 3
Decisions: 66.7% 2 - 3

Line Branch Decision Exec Source
1 /**
2 * @author Andrey Belomutskiy, (c) 2012-2020
3 */
4 #include "pch.h"
5 #include "sent.h"
6 #include "tunerstudio.h"
7 #include "tunerstudio_calibration_channel.h"
8
9 /*
10 void grabTPSIsClosed() {
11 #if EFI_PROD_CODE
12 engineConfiguration->tpsMin = convertVoltageTo10bitADC(Sensor::getRaw(SensorType::Tps1));
13 #endif // EFI_PROD_CODE
14 }
15
16 void grabTPSIsWideOpen() {
17 #if EFI_PROD_CODE
18 engineConfiguration->tpsMax = convertVoltageTo10bitADC(Sensor::getRaw(SensorType::Tps1));
19 #endif // EFI_PROD_CODE
20 }
21 */
22
23 static void onGrabPedal() {
24 static uint8_t grabPedalCounter = 0;
25 grabPedalCounter++;
26 if (grabPedalCounter % 2 == 0) {
27 // todo fix root cause! work-around: make sure not to write bad tune since that would brick requestBurn();
28 }
29 }
30
31 void grabPedalIsUp() {
32 /**
33 * search for 'maintainConstantValue' to find how this TS magic works
34 */
35 tsCalibrationSetData(TsCalMode::PedalMin, Sensor::getRaw(SensorType::AcceleratorPedalPrimary), Sensor::getRaw(SensorType::AcceleratorPedalSecondary));
36 onGrabPedal();
37 }
38
39 void grabPedalIsWideOpen() {
40 tsCalibrationSetData(TsCalMode::PedalMax, Sensor::getRaw(SensorType::AcceleratorPedalPrimary), Sensor::getRaw(SensorType::AcceleratorPedalSecondary));
41 onGrabPedal();
42 }
43
44 // In case of cable throttle we need support calibration of primary sensor of first throttle only
45 void grapTps1PrimaryIsClosed()
46 {
47 tsCalibrationSetData(TsCalMode::Tps1Min, Sensor::getRaw(SensorType::Tps1Primary));
48 }
49
50 void grapTps1PrimaryIsOpen()
51 {
52 tsCalibrationSetData(TsCalMode::Tps1Max, Sensor::getRaw(SensorType::Tps1Primary));
53 }
54
55 #if EFI_SENT_SUPPORT
56
57 extern SentTps sentTps;
58
59 2 float decodeTpsSentValue(float sentValue) {
60
2/3
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
2 switch (engineConfiguration->sentEtbType) {
61
1/1
✓ Decision 'true' taken 1 time.
1 case SentEtbType::GM_TYPE_1:
62 1 return interpolateMsg("tps", /*x1*/0xE48, /*y1*/0, /*x2*/0x1A0, /*y2*/POSITION_FULLY_OPEN, /*x*/sentValue);
63 case SentEtbType::FORD_TYPE_1:
64 return interpolateMsg("tps", /*x1*/ 250, /*y1*/0, /*x2*/ 3560, /*y2*/POSITION_FULLY_OPEN, /*x*/sentValue);
65
1/1
✓ Decision 'true' taken 1 time.
1 default:
66 1 return interpolateMsg("tps", /*x1*/engineConfiguration->customSentTpsMin, /*y1*/0, /*x2*/engineConfiguration->customSentTpsMax, /*y2*/POSITION_FULLY_OPEN, /*x*/sentValue);
67 }
68 }
69
70 #if EFI_PROD_CODE
71 void sentTpsDecode(SentInput sentCh) {
72 if ((!isDigitalTps1()) || (engineConfiguration->EtbSentInput != sentCh)) {
73 return;
74 }
75 // todo: move away from weird float API
76 float sentValue = getSentValue(sentCh);
77 float tpsValue = decodeTpsSentValue(sentValue);
78
79 sentTps.setValidValue(tpsValue, getTimeNowNt());
80 }
81 #endif // EFI_PROD_CODE
82
83 20 bool isDigitalTps1() {
84 20 return (engineConfiguration->sentEtbType != SentEtbType::NONE);
85 }
86
87 #endif /* EFI_SENT_SUPPORT */
88