diff --git a/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp b/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp index c8205a6bb..e9409a8c4 100644 --- a/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp +++ b/include/motor-control/core/stepper_motor/motor_interrupt_handler.hpp @@ -410,9 +410,8 @@ class MotorInterruptHandler { if (buffered_move.sensor_id != can::ids::SensorId::UNUSED) { auto binding = static_cast(can::ids::SensorOutputBinding::sync) | - static_cast( - can::ids::SensorOutputBinding::report); // sync and - // report + static_cast(can::ids::SensorOutputBinding::report) | + static_cast(can::ids::SensorOutputBinding::auto_baseline_report); if (buffered_move.sensor_id == can::ids::SensorId::BOTH) { send_bind_message(buffered_move.sensor_type, can::ids::SensorId::S0, binding); diff --git a/include/sensors/core/tasks/pressure_driver.hpp b/include/sensors/core/tasks/pressure_driver.hpp index 4cabb5519..2ba78d0f5 100644 --- a/include/sensors/core/tasks/pressure_driver.hpp +++ b/include/sensors/core/tasks/pressure_driver.hpp @@ -76,10 +76,16 @@ class MMR920 { sensor_buffer_index = 0; // reset buffer index crossed_buffer_index = false; sensor_buffer->fill(0.0); - current_moving_pressure_baseline_pa = 0.0; } } + void set_auto_baseline_report(bool should_auto) { + enable_auto_baseline = should_auto; + //Always set this to 0, we want to clear it if disabled and + // reset if if we haven't baselined yet + current_moving_pressure_baseline_pa = 0.0; + } + void set_bind_sync(bool should_bind) { bind_sync = should_bind; hardware.reset_sync(); @@ -400,7 +406,7 @@ class MMR920 { sensor_buffer_log(response_pressure); - if (sensor_buffer_index == AUTO_BASELINE_END && + if (enable_auto_baseline && sensor_buffer_index == AUTO_BASELINE_END && !crossed_buffer_index) { // this is the auto-base lining during a move. It requires that // a BaselineSensorRequest is sent prior to a move using the @@ -566,6 +572,7 @@ class MMR920 { bool _initialized = false; bool echoing = false; + bool enable_auto_baseline = false; bool bind_sync = false; bool max_pressure_sync = false; diff --git a/include/sensors/core/tasks/pressure_sensor_task.hpp b/include/sensors/core/tasks/pressure_sensor_task.hpp index 60b0f45a2..a8cb937bc 100644 --- a/include/sensors/core/tasks/pressure_sensor_task.hpp +++ b/include/sensors/core/tasks/pressure_sensor_task.hpp @@ -136,6 +136,9 @@ class PressureMessageHandler { driver.set_max_bind_sync( m.binding & static_cast( can::ids::SensorOutputBinding::max_threshold_sync)); + driver.set_auto_baseline_report( + m.binding & static_cast( + can::ids::SensorOutputBinding::auto_baseline_report)); std::array tags{utils::ResponseTag::IS_PART_OF_POLL, utils::ResponseTag::POLL_IS_CONTINUOUS}; auto tags_as_int = utils::byte_from_tags(tags);