Implement `FuelLevelSensor` class #7180
This commit is contained in:
parent
c8a72d3c76
commit
bf34e55cd6
|
@ -0,0 +1,12 @@
|
||||||
|
//
|
||||||
|
// Created by kifir on 12/20/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
|
||||||
|
#include "fuel_level_sensor.h"
|
||||||
|
|
||||||
|
FuelLevelSensor::FuelLevelSensor(const SensorType type, const efidur_t timeoutPeriod)
|
||||||
|
: FunctionalSensorImpl(type, timeoutPeriod) {
|
||||||
|
setFunction(m_FuelLevelFunc);
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
//
|
||||||
|
// Created by kifir on 12/20/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "functional_sensor_impl.h"
|
||||||
|
#include "fuel_level_func.h"
|
||||||
|
|
||||||
|
class FuelLevelSensor : public FunctionalSensorImpl<FuelLevelFunc> {
|
||||||
|
public:
|
||||||
|
FuelLevelSensor(SensorType type, efidur_t timeoutPeriod);
|
||||||
|
|
||||||
|
void showInfo(const char* sensorName) const override;
|
||||||
|
private:
|
||||||
|
FuelLevelFunc m_FuelLevelFunc;
|
||||||
|
};
|
|
@ -2,6 +2,7 @@
|
||||||
#include "stored_value_sensor.h"
|
#include "stored_value_sensor.h"
|
||||||
#include "proxy_sensor.h"
|
#include "proxy_sensor.h"
|
||||||
#include "functional_sensor.h"
|
#include "functional_sensor.h"
|
||||||
|
#include "fuel_level_sensor.h"
|
||||||
#include "redundant_sensor.h"
|
#include "redundant_sensor.h"
|
||||||
#include "redundant_ford_tps.h"
|
#include "redundant_ford_tps.h"
|
||||||
#include "fallback_sensor.h"
|
#include "fallback_sensor.h"
|
||||||
|
@ -32,6 +33,11 @@ void FunctionalSensor::showInfo(const char* sensorName) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FuelLevelSensor::showInfo(const char* sensorName) const {
|
||||||
|
const auto value = get();
|
||||||
|
efiPrintf("Sensor \"%s\": Raw value: %.2f Valid: %s Converted value %.2f", sensorName, getRaw(), boolToString(value.Valid), value.Value);
|
||||||
|
}
|
||||||
|
|
||||||
#if EFI_CAN_SUPPORT || EFI_UNIT_TEST
|
#if EFI_CAN_SUPPORT || EFI_UNIT_TEST
|
||||||
#include "can_sensor.h"
|
#include "can_sensor.h"
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ CONTROLLERS_SENSORS_SRC_CPP = \
|
||||||
$(PROJECT_DIR)/controllers/sensors/core/functional_sensor_base.cpp \
|
$(PROJECT_DIR)/controllers/sensors/core/functional_sensor_base.cpp \
|
||||||
$(PROJECT_DIR)/controllers/sensors/core/functional_sensor_impl.cpp \
|
$(PROJECT_DIR)/controllers/sensors/core/functional_sensor_impl.cpp \
|
||||||
$(PROJECT_DIR)/controllers/sensors/core/functional_sensor.cpp \
|
$(PROJECT_DIR)/controllers/sensors/core/functional_sensor.cpp \
|
||||||
|
$(PROJECT_DIR)/controllers/sensors/core/fuel_level_sensor.cpp \
|
||||||
$(PROJECT_DIR)/controllers/sensors/core/sensor.cpp \
|
$(PROJECT_DIR)/controllers/sensors/core/sensor.cpp \
|
||||||
$(PROJECT_DIR)/controllers/sensors/thermistors.cpp \
|
$(PROJECT_DIR)/controllers/sensors/thermistors.cpp \
|
||||||
$(PROJECT_DIR)/controllers/sensors/allsensors.cpp \
|
$(PROJECT_DIR)/controllers/sensors/allsensors.cpp \
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
|
||||||
#include "functional_sensor.h"
|
|
||||||
#include "adc_subscription.h"
|
#include "adc_subscription.h"
|
||||||
#include "fuel_level_func.h"
|
#include "fuel_level_sensor.h"
|
||||||
|
|
||||||
static FunctionalSensor fuelSensor(SensorType::FuelLevel, /* timeout = */ MS2NT(500));
|
static FuelLevelSensor fuelSensor(SensorType::FuelLevel, /* timeout = */ MS2NT(500));
|
||||||
|
|
||||||
static FuelLevelFunc fuelCurve;
|
|
||||||
|
|
||||||
void initFuelLevel() {
|
void initFuelLevel() {
|
||||||
adc_channel_e channel = engineConfiguration->fuelLevelSensor;
|
adc_channel_e channel = engineConfiguration->fuelLevelSensor;
|
||||||
|
@ -15,8 +12,6 @@ void initFuelLevel() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fuelSensor.setFunction(fuelCurve);
|
|
||||||
|
|
||||||
// Filtering with such a small bandwidth helps prevent noisy data from fuel tank slosh
|
// Filtering with such a small bandwidth helps prevent noisy data from fuel tank slosh
|
||||||
AdcSubscription::SubscribeSensor(fuelSensor, channel, /*lowpassCutoff =*/ 0.05f);
|
AdcSubscription::SubscribeSensor(fuelSensor, channel, /*lowpassCutoff =*/ 0.05f);
|
||||||
fuelSensor.Register();
|
fuelSensor.Register();
|
||||||
|
|
Loading…
Reference in New Issue