2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2021-05-09 16:47:37 -07:00
|
|
|
#include "init.h"
|
|
|
|
#include "adc_subscription.h"
|
|
|
|
#include "functional_sensor.h"
|
2021-10-04 14:18:08 -07:00
|
|
|
#include "identity_func.h"
|
2021-05-09 16:47:37 -07:00
|
|
|
|
|
|
|
// These aux sensors just read voltage - so the converter function has nothing to do
|
|
|
|
|
|
|
|
static FunctionalSensor auxSensors[] = {
|
|
|
|
{ SensorType::Aux1, MS2NT(50) },
|
|
|
|
{ SensorType::Aux2, MS2NT(50) },
|
|
|
|
{ SensorType::Aux3, MS2NT(50) },
|
|
|
|
{ SensorType::Aux4, MS2NT(50) },
|
2021-10-19 16:48:18 -07:00
|
|
|
{ SensorType::Aux5, MS2NT(50) },
|
|
|
|
{ SensorType::Aux6, MS2NT(50) },
|
|
|
|
{ SensorType::Aux7, MS2NT(50) },
|
|
|
|
{ SensorType::Aux8, MS2NT(50) },
|
2021-05-09 16:47:37 -07:00
|
|
|
};
|
|
|
|
|
2021-09-01 04:47:25 -07:00
|
|
|
static_assert(efi::size(auxSensors) == AUX_ANALOG_INPUT_COUNT);
|
2021-05-09 16:47:37 -07:00
|
|
|
|
|
|
|
void initAuxSensors(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
2021-10-19 17:04:03 -07:00
|
|
|
for (size_t i = 0; i < efi::size(CONFIG(auxAnalogInputs)); i++) {
|
|
|
|
auto channel = CONFIG(auxAnalogInputs)[i];
|
2021-05-09 16:47:37 -07:00
|
|
|
|
|
|
|
// Skip unconfigured channels
|
|
|
|
if (!isAdcChannelValid(channel)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto& sensor = auxSensors[i];
|
2021-10-04 14:18:08 -07:00
|
|
|
sensor.setFunction(identityFunction);
|
2021-05-09 16:47:37 -07:00
|
|
|
sensor.Register();
|
|
|
|
|
|
|
|
AdcSubscription::SubscribeSensor(sensor, channel, 10);
|
|
|
|
}
|
|
|
|
}
|