From 205376c3576208077c54f5ceacf4fb20d1f17194 Mon Sep 17 00:00:00 2001 From: Ryan howard Date: Mon, 3 Jun 2024 15:29:42 -0400 Subject: [PATCH] send the pressure sensor response with the baseline applied --- .../sensors/core/tasks/pressure_driver.hpp | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/include/sensors/core/tasks/pressure_driver.hpp b/include/sensors/core/tasks/pressure_driver.hpp index 410dc0913..fac96a806 100644 --- a/include/sensors/core/tasks/pressure_driver.hpp +++ b/include/sensors/core/tasks/pressure_driver.hpp @@ -364,21 +364,23 @@ class MMR920 { } if (echo_this_time) { + auto response_pressure = + std::fabs(pressure) - + std::fabs(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; + if (pressure_buffer_index < PRESSURE_SENSOR_BUFFER_SIZE) { + (*p_buff).at(pressure_buffer_index) = response_pressure; pressure_buffer_index++; } #else - can_client.send_can_message( - can::ids::NodeId::host, - can::messages::ReadFromSensorResponse{ - .message_index = m.message_index, - .sensor = can::ids::SensorType::pressure, - .sensor_id = sensor_id, - .sensor_data = mmr920::reading_to_fixed_point(pressure)}); + can_client.send_can_message( + can::ids::NodeId::host, + can::messages::ReadFromSensorResponse{ + .message_index = m.message_index, + .sensor = can::ids::SensorType::pressure, + .sensor_id = sensor_id, + .sensor_data = mmr920::reading_to_fixed_point( + response_pressure)}); #endif } }