rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
tps.cpp
Go to the documentation of this file.
1/**
2 * @author Andrey Belomutskiy, (c) 2012-2020
3 */
4#include "pch.h"
5#include "sent.h"
6#include "tunerstudio.h"
8
9/*
10void grabTPSIsClosed() {
11#if EFI_PROD_CODE
12 engineConfiguration->tpsMin = convertVoltageTo10bitADC(Sensor::getRaw(SensorType::Tps1));
13#endif // EFI_PROD_CODE
14}
15
16void grabTPSIsWideOpen() {
17#if EFI_PROD_CODE
18 engineConfiguration->tpsMax = convertVoltageTo10bitADC(Sensor::getRaw(SensorType::Tps1));
19#endif // EFI_PROD_CODE
20}
21*/
22
23static 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
32 /**
33 * search for 'maintainConstantValue' to find how this TS magic works
34 */
37}
38
43
44// In case of cable throttle we need support calibration of primary sensor of first throttle only
49
54
55#if EFI_SENT_SUPPORT
56
57extern SentTps sentTps;
58
59float decodeTpsSentValue(float sentValue) {
62 return interpolateMsg("tps", /*x1*/0xE48, /*y1*/0, /*x2*/0x1A0, /*y2*/POSITION_FULLY_OPEN, /*x*/sentValue);
64 return interpolateMsg("tps", /*x1*/ 250, /*y1*/0, /*x2*/ 3560, /*y2*/POSITION_FULLY_OPEN, /*x*/sentValue);
65 default:
66 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
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
80}
81#endif // EFI_PROD_CODE
82
86
87#endif /* EFI_SENT_SUPPORT */
virtual float getRaw() const
Definition sensor.h:148
void setValidValue(float value, efitick_t timestamp)
float interpolateMsg(const char *msg, float x1, float y1, float x2, float y2, float x)
Linear interpolation by two points.
efitick_t getTimeNowNt()
Definition efitime.cpp:19
static constexpr engine_configuration_s * engineConfiguration
SentInput
@ AcceleratorPedalPrimary
@ AcceleratorPedalSecondary
float getSentValue(SentInput input)
Definition sent.cpp:135
Definition tps.h:34
void grabPedalIsUp()
Definition tps.cpp:31
bool isDigitalTps1()
Definition tps.cpp:83
static void onGrabPedal()
Definition tps.cpp:23
void grapTps1PrimaryIsClosed()
Definition tps.cpp:45
void grapTps1PrimaryIsOpen()
Definition tps.cpp:50
void sentTpsDecode(SentInput sentCh)
Definition tps.cpp:71
SentTps sentTps
Definition init_tps.cpp:181
float decodeTpsSentValue(float sentValue)
Definition tps.cpp:59
void grabPedalIsWideOpen()
Definition tps.cpp:39
void tsCalibrationSetData(TsCalMode mode, float value, float value2, float timeoutMs)
maintainConstantValue implementation header