28 FuncSensPair(
float divideInput,
SensorType type)
30 , m_sens(type, MS2NT(10))
32 m_sens.setFunction(m_func);
35 bool init(
const TpsConfig& cfg) {
37 if (!configure(cfg)) {
43 return m_sens.Register();
54 const char* name()
const {
55 return m_sens.getSensorName();
59 bool configure(
const TpsConfig& cfg) {
63 printf(
"Configured NO hardware %s\n", name());
68 float scaledClosed = cfg.closed / m_func.getDivideInput();
69 float scaledOpen = cfg.open / m_func.getDivideInput();
71 float split = std::abs(scaledOpen - scaledClosed);
83 cfg.open, POSITION_FULLY_OPEN,
88 printf(
"Configured YES %s\n", name());
99 RedundantPair(FuncSensPair& pri, FuncSensPair& sec,
SensorType outputType)
102 , m_redund(outputType, m_pri.type(), m_sec.type())
106 void init(
bool isFordTps,
RedundantFordTps* fordTps,
float secondaryMaximum,
const TpsConfig& primary,
const TpsConfig& secondary,
bool allowIdenticalSensors =
false) {
107 bool hasFirst = m_pri.init(primary);
113 if (!allowIdenticalSensors) {
117 bool tooCloseClosed = std::abs(primary.closed - secondary.closed) < 0.2f;
118 bool tooCloseOpen = std::abs(primary.open - secondary.open) < 0.2f;
120 if (hasBothSensors && tooCloseClosed && tooCloseOpen) {
126 bool hasSecond = m_sec.init(secondary);
132 if (isFordTps && fordTps) {
150 if (isFordTps && fordTps) {
153 m_redund.unregister();
159 void updateUnfilteredRawValues() {
195 pedal.updateUnfilteredRawValues();
216 if (tpsSecondaryMaximum < 20) {
218 tpsSecondaryMaximum = 20;
240 if (ppsSecondaryMaximum < 20) {
242 ppsSecondaryMaximum = 20;
const char * getSensorType(SensorType value)
static AdcSubscriptionEntry * SubscribeSensor(FunctionalSensorBase &sensor, adc_channel_e channel, float lowpassCutoffHZ, float voltsPerAdcVolt=0.0f)
static void UnsubscribeSensor(FunctionalSensorBase &sensor)
TunerStudioOutputChannels outputChannels
void setSmoothingFactor(float p_smoothingFactor)
float initOrAverage(float value)
Class for sensors that convert from some raw floating point value (ex: voltage, frequency,...
void setConverter(functionFunctionPtr p_converter)
void setProxiedSensor(SensorType proxiedSensor)
void configure(float maxDifference, float secondaryMaximum)
static EngineAccessor engine
engine_configuration_s & activeConfiguration
static constexpr engine_configuration_s * engineConfiguration
void firmwareError(ObdCode code, const char *fmt,...)
void updateUnfilteredRawPedal()
static FuncSensPair wastegate(1, SensorType::WastegatePosition)
static ProxySensor ppsFilterSensor(SensorType::AcceleratorPedal)
static RedundantFordTps fordTps1(SensorType::Tps1, SensorType::Tps1Primary, SensorType::Tps1Secondary)
static FuncSensPair tps1s(TPS_TS_CONVERSION, SensorType::Tps1Secondary)
static RedundantPair pedal(pedalPrimary, pedalSecondary, SensorType::AcceleratorPedalUnfiltered)
static RedundantPair tps2(tps2p, tps2s, SensorType::Tps2)
PUBLIC_API_WEAK float getFuncPairAllowedSplit()
static FuncSensPair tps2s(TPS_TS_CONVERSION, SensorType::Tps2Secondary)
static FuncSensPair tps1p(TPS_TS_CONVERSION, SensorType::Tps1Primary)
static FuncSensPair idlePos(PACK_MULT_VOLTAGE, SensorType::IdlePosition)
static RedundantPair analogTps1(tps1p, tps1s, SensorType::Tps1)
static FuncSensPair tps2p(TPS_TS_CONVERSION, SensorType::Tps2Primary)
static ProxySensor driverIntent(SensorType::DriverThrottleIntent)
static FuncSensPair pedalSecondary(1, SensorType::AcceleratorPedalSecondary)
static RedundantFordTps fordPps(SensorType::AcceleratorPedalUnfiltered, SensorType::AcceleratorPedalPrimary, SensorType::AcceleratorPedalSecondary)
static FuncSensPair pedalPrimary(1, SensorType::AcceleratorPedalPrimary)
static RedundantFordTps fordTps2(SensorType::Tps2, SensorType::Tps2Primary, SensorType::Tps2Secondary)
A sensor to duplicate a sensor to an additional SensorType.
expected< float > SensorResult
@ AcceleratorPedalPrimary
@ AcceleratorPedalSecondary
@ AcceleratorPedalUnfiltered
adc_channel_e tps1_1AdcChannel
adc_channel_e tps2_2AdcChannel
adc_channel_e idlePositionChannel
float throttlePedalUpVoltage
adc_channel_e throttlePedalPositionSecondAdcChannel
tps_limit_t tps1SecondaryMax
int16_t tpsErrorDetectionTooLow
float wastegatePositionOpenedVoltage
scaled_channel< uint8_t, 2, 1 > tpsSecondaryMaximum
uint16_t tps2SecondaryMax
adc_channel_e tps1_2AdcChannel
float throttlePedalSecondaryWOTVoltage
float throttlePedalSecondaryUpVoltage
float wastegatePositionClosedVoltage
float throttlePedalWOTVoltage
tps_limit_t tps1SecondaryMin
adc_channel_e tps2_1AdcChannel
scaled_channel< uint8_t, 10, 1 > etbSplit
uint16_t tps2SecondaryMin
adc_channel_e wastegatePositionSensor
int16_t tpsErrorDetectionTooHigh
adc_channel_e throttlePedalPositionAdcChannel
scaled_channel< uint8_t, 2, 1 > ppsSecondaryMaximum