Skip to content

Commit

Permalink
add new binding type for sensors and use the auto-baselineing during …
Browse files Browse the repository at this point in the history
…sensor moves
  • Loading branch information
ryanthecoder committed Jun 25, 2024
1 parent 3109317 commit 0901b67
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,8 @@ class MotorInterruptHandler {
if (buffered_move.sensor_id != can::ids::SensorId::UNUSED) {
auto binding =
static_cast<uint8_t>(can::ids::SensorOutputBinding::sync) |
static_cast<uint8_t>(
can::ids::SensorOutputBinding::report); // sync and
// report
static_cast<uint8_t>(can::ids::SensorOutputBinding::report) |
static_cast<uint8_t>(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);
Expand Down
11 changes: 9 additions & 2 deletions include/sensors/core/tasks/pressure_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions include/sensors/core/tasks/pressure_sensor_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ class PressureMessageHandler {
driver.set_max_bind_sync(
m.binding & static_cast<uint8_t>(
can::ids::SensorOutputBinding::max_threshold_sync));
driver.set_auto_baseline_report(
m.binding & static_cast<uint8_t>(
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);
Expand Down

0 comments on commit 0901b67

Please sign in to comment.