24 FuncSensPair(
float divideInput,
SensorType type)
26 , m_sens(type, MS2NT(10))
28 m_sens.setFunction(m_func);
31 bool init(
const TpsConfig& cfg) {
33 if (!configure(cfg)) {
39 return m_sens.Register();
50 const char* name()
const {
51 return m_sens.getSensorName();
55 bool configure(
const TpsConfig& cfg) {
59 printf(
"Configured NO hardware %s\n", name());
64 float scaledClosed = cfg.closed / m_func.getDivideInput();
65 float scaledOpen = cfg.open / m_func.getDivideInput();
67 float split = absF(scaledOpen - scaledClosed);
79 cfg.open, POSITION_FULLY_OPEN,
84 printf(
"Configured YES %s\n", name());
93 struct RedundantPair {
95 RedundantPair(FuncSensPair& pri, FuncSensPair& sec,
SensorType outputType)
98 , m_redund(outputType, m_pri.type(), m_sec.type())
102 void init(
bool isFordTps,
RedundantFordTps* fordTps,
float secondaryMaximum,
const TpsConfig& primary,
const TpsConfig& secondary,
bool allowIdenticalSensors =
false) {
103 bool hasFirst = m_pri.init(primary);
109 if (!allowIdenticalSensors) {
113 bool tooCloseClosed = absF(primary.closed - secondary.closed) < 0.2f;
114 bool tooCloseOpen = absF(primary.open - secondary.open) < 0.2f;
116 if (hasBothSensors && tooCloseClosed && tooCloseOpen) {
122 bool hasSecond = m_sec.init(secondary);
128 if (isFordTps && fordTps) {
146 if (isFordTps && fordTps) {
149 m_redund.unregister();
154 void updateUnfilteredRawValues() {
188 pedal.updateUnfilteredRawValues();
212 if (tpsSecondaryMaximum < 20) {
214 tpsSecondaryMaximum = 20;
233 if (ppsSecondaryMaximum < 20) {
235 ppsSecondaryMaximum = 20;
const char * getSensorType(SensorType value)
static void UnsubscribeSensor(FunctionalSensor &sensor)
static AdcSubscriptionEntry * SubscribeSensor(FunctionalSensor &sensor, adc_channel_e channel, float lowpassCutoffHZ, float voltsPerAdcVolt=0.0f)
TunerStudioOutputChannels outputChannels
Class for sensors that convert from some raw floating point value (ex: voltage, frequency,...
void setProxiedSensor(SensorType proxiedSensor)
void configure(float maxDifference, float secondaryMaximum)
engine_configuration_s & activeConfiguration
void firmwareError(ObdCode code, const char *fmt,...)
void updateUnfilteredRawPedal()
static RedundantFordTps fordPps(SensorType::AcceleratorPedal, SensorType::AcceleratorPedalPrimary, SensorType::AcceleratorPedalSecondary)
static RedundantFordTps fordTps1(SensorType::Tps1, SensorType::Tps1Primary, SensorType::Tps1Secondary)
static FuncSensPair tps1s(TPS_TS_CONVERSION, SensorType::Tps1Secondary)
static RedundantPair tps2(tps2p, tps2s, SensorType::Tps2)
static RedundantPair pedal(pedalPrimary, pedalSecondary, SensorType::AcceleratorPedal)
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 FuncSensPair wastegate(PACK_MULT_VOLTAGE, SensorType::WastegatePosition)
static FuncSensPair pedalPrimary(1, SensorType::AcceleratorPedalPrimary)
static RedundantFordTps fordTps2(SensorType::Tps2, SensorType::Tps2Primary, SensorType::Tps2Secondary)
engine_configuration_s * engineConfiguration
bool isBrainPinValid(brain_pin_e brainPin)
A sensor to duplicate a sensor to an additional SensorType.
@ AcceleratorPedalPrimary
@ AcceleratorPedalSecondary
adc_channel_e tps1_1AdcChannel
adc_channel_e tps2_2AdcChannel
adc_channel_e idlePositionChannel
float throttlePedalUpVoltage
uint16_t wastegatePositionMax
adc_channel_e throttlePedalPositionSecondAdcChannel
int16_t tpsErrorDetectionTooLow
scaled_channel< uint8_t, 2, 1 > tpsSecondaryMaximum
sent_input_pin_e sentInputPins[SENT_INPUT_COUNT]
uint16_t tps2SecondaryMax
uint16_t wastegatePositionMin
adc_channel_e tps1_2AdcChannel
float throttlePedalSecondaryWOTVoltage
float throttlePedalSecondaryUpVoltage
uint16_t tps1SecondaryMin
float throttlePedalWOTVoltage
adc_channel_e tps2_1AdcChannel
uint16_t tps1SecondaryMax
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