vBatt -> SensorType::vBatt fix #2260

This commit is contained in:
rusefillc 2021-03-11 23:07:18 -05:00
parent d650271077
commit 16b8fb64ca
5 changed files with 4 additions and 9 deletions

View File

@ -288,8 +288,6 @@ void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
fuelLevelVoltage);
}
sensors.vBatt = Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE);
#if (BOARD_TLE8888_COUNT > 0)
// nasty value injection into C driver which would not be able to access Engine class
vBattForTle8888 = Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE);

View File

@ -36,9 +36,6 @@ public:
Accelerometer accelerometer;
// todo: remove this variable, replace with Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE)
// todo: https://github.com/rusefi/rusefi/issues/2260
float vBatt = 0;
/**
* that's fuel in tank - just a gauge
*/

View File

@ -78,7 +78,7 @@ float InjectorModel::getInjectorMassFlowRate() const {
float InjectorModel::getDeadtime() const {
return interpolate2d(
ENGINE(sensors.vBatt),
Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE),
engineConfiguration->injector.battLagCorrBins,
engineConfiguration->injector.battLagCorr
);

View File

@ -20,7 +20,7 @@ CJ125::CJ125() : wboHeaterControl("wbo"),
void CJ125::SetHeater(float value DECLARE_ENGINE_PARAMETER_SUFFIX) {
// limit duty cycle for sensor safety
// todo: would be much nicer to have continuous function (vBatt)
float maxDuty = (engine->sensors.vBatt > CJ125_HEATER_LIMITING_VOLTAGE) ? CJ125_HEATER_LIMITING_RATE : 1.0f;
float maxDuty = (Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE) > CJ125_HEATER_LIMITING_VOLTAGE) ? CJ125_HEATER_LIMITING_RATE : 1.0f;
heaterDuty = (value < CJ125_HEATER_MIN_DUTY) ? 0.0f : minF(maxF(value, 0.0f), maxDuty);
#ifdef CJ125_DEBUG
scheduleMsg(logger, "cjSetHeater: %.2f", heaterDuty);

View File

@ -49,10 +49,10 @@ TEST(InjectorModel, Deadtime) {
InjectorModel dut;
INJECT_ENGINE_REFERENCE(&dut);
engine->sensors.vBatt = 3;
Sensor::setMockValue(SensorType::BatteryVoltage, 3);
EXPECT_EQ(dut.getDeadtime(), 6);
engine->sensors.vBatt = 7;
Sensor::setMockValue(SensorType::BatteryVoltage, 7);
EXPECT_EQ(dut.getDeadtime(), 14);
}