Skip to content

Commit

Permalink
kill the recording of both sensors when a move finishes
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthecoder committed Apr 10, 2024
1 parent 4fea8a9 commit 0f9a46c
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,12 @@ class MotorInterruptHandler {
return tick_count < buffered_move.duration;
}
#ifdef USE_PRESSURE_MOVE
auto send_bind_message(can::ids::SensorId sensor) -> void {
auto send_bind_message(can::ids::SensorId sensor, uint8_t binding) -> void {
auto msg = can::messages::BindSensorOutputRequest{
.message_index = buffered_move.message_index,
.sensor = can::ids::SensorType::pressure,
.sensor_id = sensor,
.binding = static_cast<uint8_t>(0x3) // sync and report
};
.binding = binding};
send_to_pressure_sensor_queue(msg);
}
#endif
Expand All @@ -398,11 +397,12 @@ class MotorInterruptHandler {
hardware.get_encoder_pulses();
#ifdef USE_PRESSURE_MOVE
if (buffered_move.sensor_id != can::ids::SensorId::UNUSED) {
uint8_t binding = static_cast<uint8_t>(0x3); // sync and report
if (buffered_move.sensor_id == can::ids::SensorId::BOTH) {
send_bind_message(can::ids::SensorId::S0);
send_bind_message(can::ids::SensorId::S1);
send_bind_message(can::ids::SensorId::S0, binding);
send_bind_message(can::ids::SensorId::S1, binding);
} else {
send_bind_message(buffered_move.sensor_id);
send_bind_message(buffered_move.sensor_id, binding);
}
}
#endif
Expand Down Expand Up @@ -495,13 +495,14 @@ class MotorInterruptHandler {
build_and_send_ack(ack_msg_id);
#ifdef USE_PRESSURE_MOVE
if (buffered_move.sensor_id != can::ids::SensorId::UNUSED) {
auto stop_msg = can::messages::BindSensorOutputRequest{
.message_index = buffered_move.message_index,
.sensor = can::ids::SensorType::pressure,
.sensor_id = buffered_move.sensor_id,
.binding =
static_cast<uint8_t>(can::ids::SensorOutputBinding::sync)};
send_to_pressure_sensor_queue(stop_msg);
uint8_t binding = static_cast<uint8_t>(
can::ids::SensorOutputBinding::sync);
if (buffered_move.sensor_id == can::ids::SensorId::BOTH) {
send_bind_message(can::ids::SensorId::S0, binding);
send_bind_message(can::ids::SensorId::S1, binding);
} else {
send_bind_message(buffered_move.sensor_id, binding);
}
}
#endif
set_buffered_move(MotorMoveMessage{});
Expand Down

0 comments on commit 0f9a46c

Please sign in to comment.