implement cdp/tip

This commit is contained in:
Matthew Kennedy 2023-09-18 05:04:10 -04:00 committed by rusefillc
parent 1552b26fa6
commit 93b0b6519f
3 changed files with 23 additions and 12 deletions

View File

@ -14,6 +14,8 @@ static FunctionalSensor baroSensor(SensorType::BarometricPressure, MS2NT(50));
static LinearFunc mapConverter;
static FunctionalSensor slowMapSensor(SensorType::MapSlow, MS2NT(50));
static FunctionalSensor slowMapSensor2(SensorType::MapSlow2, MS2NT(50));
static FunctionalSensor compressorDischargePress(SensorType::CompressorDischargePressure, MS2NT(50));
static FunctionalSensor throttleInletPress(SensorType::ThrottleInletPressure, MS2NT(50));
// lowest reasonable idle is maybe 600 rpm
// one sample per cycle (1 cylinder, or "sample one cyl" mode) gives a period of 100ms
@ -98,16 +100,18 @@ void configureMapFunction(LinearFunc& converter, air_pressure_sensor_type_e sens
}
void initMap() {
// Set up the conversion function
configureMapFunction(mapConverter, engineConfiguration->map.sensor.type);
slowMapSensor.setFunction(mapConverter);
slowMapSensor2.setFunction(mapConverter);
fastMapSensor.setFunction(mapConverter);
fastMapSensor2.setFunction(mapConverter);
compressorDischargePress.setFunction(mapConverter);
throttleInletPress.setFunction(mapConverter);
auto mapChannel = engineConfiguration->map.sensor.hwChannel;
if (isAdcChannelValid(mapChannel)) {
// Set up the conversion function
configureMapFunction(mapConverter, engineConfiguration->map.sensor.type);
slowMapSensor.setFunction(mapConverter);
slowMapSensor2.setFunction(mapConverter);
fastMapSensor.setFunction(mapConverter);
fastMapSensor2.setFunction(mapConverter);
slowMapSensor.Register();
slowMapSensor2.Register();
fastMapSensor.Register();
@ -119,6 +123,9 @@ void initMap() {
AdcSubscription::SubscribeSensor(slowMapSensor, mapChannel, 100);
}
AdcSubscription::SubscribeSensor(throttleInletPress, engineConfiguration->throttleInletPressureChannel, 100);
AdcSubscription::SubscribeSensor(compressorDischargePress, engineConfiguration->compressorDischargePressureChannel, 100);
auto baroChannel = engineConfiguration->baroSensor.hwChannel;
if (isAdcChannelValid(baroChannel)) {
configureMapFunction(baroConverter, engineConfiguration->baroSensor.type);
@ -133,4 +140,6 @@ void initMap() {
void deinitMap() {
AdcSubscription::UnsubscribeSensor(slowMapSensor, engineConfiguration->map.sensor.hwChannel);
AdcSubscription::UnsubscribeSensor(baroSensor, engineConfiguration->baroSensor.hwChannel);
AdcSubscription::UnsubscribeSensor(throttleInletPress, engineConfiguration->throttleInletPressureChannel);
AdcSubscription::UnsubscribeSensor(compressorDischargePress, engineConfiguration->compressorDischargePressureChannel);
}

View File

@ -1555,10 +1555,10 @@ pin_input_mode_e[LUA_DIGITAL_INPUT_COUNT iterate] luaDigitalInputPinModes;
ThermistorConf ambientTempSensor
ThermistorConf compressorDischargeTemperature
!
! Just a shortcut to facilitate compatible configuration changes, i.e. a change which does not touch FLASH_DATA_VERSION and thus does not require manual tune migration
!
uint8_t[256] mainUnusedEnd;;"units", 1, 0, 0, 1, 0
adc_channel_e throttleInletPressureChannel;Place the sensor before the throttle, but after any turbocharger/supercharger and intercoolers if fitted. Uses the same calibration as the MAP sensor.
adc_channel_e compressorDischargePressureChannel;Place the sensor after the turbocharger/supercharger, but before any intercoolers if fitted. Uses the same calibration as the MAP sensor.
uint8_t[254] mainUnusedEnd;;"units", 1, 0, 0, 1, 0
! end of engine_configuration_s
end_struct

View File

@ -2914,6 +2914,8 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
field = "Flex fuel sensor", flexSensorPin
field = "Turbo Speed Sensor", turboSpeedSensorInputPin
field = "Turbo Speed Multiplier", turboSpeedSensorMultiplier
field = "Throttle inlet pressure sensor", throttleInletPressureChannel
field = "Compressor discharge pressure sensor", compressorDischargePressureChannel
dialog = fuelLevelDialog, "Fuel Level Sensor"
field = "Input channel", fuelLevelSensor