Skip to content

Commit

Permalink
preserve old behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthecoder committed Jun 25, 2024
1 parent fdd6637 commit 5a60de6
Showing 1 changed file with 34 additions and 9 deletions.
43 changes: 34 additions & 9 deletions include/sensors/core/tasks/pressure_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,22 +389,47 @@ class MMR920 {
hardware.reset_sync();
}
}
if (bind_sync &&
(sensor_buffer_index > AUTO_BASELINE_END || crossed_buffer_index)) {
if (std::fabs(pressure - current_pressure_baseline_pa -
current_moving_pressure_baseline_pa) >
threshold_pascals) {
hardware.set_sync();
if (bind_sync) {
if (enable_auto_baseline) {
if ((sensor_buffer_index > AUTO_BASELINE_END ||
crossed_buffer_index)) {
if (std::fabs(pressure - current_pressure_baseline_pa -
current_moving_pressure_baseline_pa) >
threshold_pascals) {
hardware.set_sync();
} else {
hardware.reset_sync();
}
}
} else {
hardware.reset_sync();
if (std::fabs(pressure - current_pressure_baseline_pa) >
threshold_pascals) {
hardware.set_sync();
} else {
hardware.reset_sync();
}
}
}

if (echo_this_time) {
auto response_pressure = pressure - current_pressure_baseline_pa -
current_moving_pressure_baseline_pa;
auto response_pressure = pressure - current_pressure_baseline_pa;
if (enable_auto_baseline) {
// apply moving baseline if using
response_pressure -= current_moving_pressure_baseline_pa;
}

sensor_buffer_log(response_pressure);
if (!enable_auto_baseline) {
// This preserves the old way of echoing continuous polls
can_client.send_can_message(
can::ids::NodeId::host,
can::messages::ReadFromSensorResponse{
.message_index = 0,
.sensor = can::ids::SensorType::pressure,
.sensor_id = sensor_id,
.sensor_data =
mmr920::reading_to_fixed_point(response_pressure)});
}

if (enable_auto_baseline &&
sensor_buffer_index == AUTO_BASELINE_END &&
Expand Down

0 comments on commit 5a60de6

Please sign in to comment.