From e4a506850b1f5285c56b47240b06d39354c0d9fb Mon Sep 17 00:00:00 2001 From: Alberto Nidasio <alberto.nidasio@skywarder.eu> Date: Sun, 25 Sep 2022 17:38:44 +0200 Subject: [PATCH] [Sensors] Fixed analog pressures sensors transfer function --- src/boards/Main/Sensors/Sensors.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/boards/Main/Sensors/Sensors.cpp b/src/boards/Main/Sensors/Sensors.cpp index ca3800db5..84d0e8fe3 100644 --- a/src/boards/Main/Sensors/Sensors.cpp +++ b/src/boards/Main/Sensors/Sensors.cpp @@ -495,8 +495,15 @@ void Sensors::ads131m04Init() void Sensors::staticPressureInit() { - function<ADCData()> getVoltage( - bind(&ADS131M04::getVoltage, ads131m04, ADC_CH_STATIC_PORT)); + function<ADCData()> getVoltage = [&]() + { + auto data = ads131m04->getVoltage(ADC_CH_STATIC_PORT); + + // Account for the voltage divider with 10K and 2.31K + data.voltage = data.voltage * (10 + 2.31) / 2.31; + + return data; + }; staticPressure = new MPXH6115A(getVoltage, REFERENCE_VOLTAGE); @@ -518,8 +525,15 @@ void Sensors::staticPressureInit() void Sensors::dplPressureInit() { - function<ADCData()> getVoltage( - bind(&ADS131M04::getVoltage, ads131m04, ADC_CH_DPL_PORT)); + function<ADCData()> getVoltage = [&]() + { + auto data = ads131m04->getVoltage(ADC_CH_DPL_PORT); + + // Account for the voltage divider with 10K and 2.31K + data.voltage = data.voltage * (10 + 2.31) / 2.31; + + return data; + }; dplPressure = new MPXH6400A(getVoltage, REFERENCE_VOLTAGE); -- GitLab