From 83f8f091aa1be940d456af5de78a6ae69cff7466 Mon Sep 17 00:00:00 2001 From: Ryan Howard Date: Tue, 4 Jun 2024 15:28:38 -0400 Subject: [PATCH] fix(sensors): send the pressure sensor response with the baseline applied (#783) * send the pressure sensor response with the baseline applied * aww dang missed a ; * format * keep signedness * calculate the baseline correctly --- include/sensors/core/tasks/pressure_driver.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/sensors/core/tasks/pressure_driver.hpp b/include/sensors/core/tasks/pressure_driver.hpp index 410dc0913..f0872519b 100644 --- a/include/sensors/core/tasks/pressure_driver.hpp +++ b/include/sensors/core/tasks/pressure_driver.hpp @@ -355,7 +355,7 @@ class MMR920 { } } if (bind_sync) { - if (std::fabs(pressure) - std::fabs(current_pressure_baseline_pa) > + if (std::fabs(pressure - current_pressure_baseline_pa) > threshold_pascals) { hardware.set_sync(); } else { @@ -364,11 +364,10 @@ class MMR920 { } if (echo_this_time) { + auto response_pressure = pressure - current_pressure_baseline_pa; #ifdef USE_PRESSURE_MOVE - // send a response with 9999 to make an overload of the buffer - // visible if (pressure_buffer_index < PRESSURE_SENSOR_BUFFER_SIZE) { - (*p_buff).at(pressure_buffer_index) = pressure; + (*p_buff).at(pressure_buffer_index) = response_pressure; pressure_buffer_index++; } #else @@ -378,7 +377,8 @@ class MMR920 { .message_index = m.message_index, .sensor = can::ids::SensorType::pressure, .sensor_id = sensor_id, - .sensor_data = mmr920::reading_to_fixed_point(pressure)}); + .sensor_data = + mmr920::reading_to_fixed_point(response_pressure)}); #endif } }