Skip to content

Commit

Permalink
send the pressure sensor response with the baseline applied
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthecoder committed Jun 3, 2024
1 parent 8738ed7 commit 205376c
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions include/sensors/core/tasks/pressure_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 205376c

Please sign in to comment.