Skip to content

Commit

Permalink
move msg back to motormessage queue, simulator fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
caila-marashaj committed Dec 3, 2024
1 parent 9a34332 commit 90f2701
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions stm32-modules/heater-shaker/simulator/motor_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,21 @@ struct SimMotorPolicy {
}
}

auto last_reset_reason() -> uint16_t { return reset_reason; }

auto set_last_reset_reason(uint16_t sim_reason) -> void {
reset_reason = sim_reason;
}

private:
int16_t rpm_setpoint = 0;
int16_t rpm_current = 0;
int32_t ramp_rate = DEFAULT_RAMP_RATE_RPM_PER_S;
float sim_plate_lock_power = 0;
bool sim_plate_lock_enabled = false;
bool sim_plate_lock_braked = false;
// Simulated reset reason from HAL RCC flag
uint16_t reset_reason = 0;
};

struct motor_thread::TaskControlBlock {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ class MotorTask {

auto response = messages::GetResetReasonResponse{
.responding_to_id = msg.id, .reason = reason};
static_cast<void>(_task_registry->comms->get_message_queue().try_send(
static_cast<void>(task_registry->comms->get_message_queue().try_send(
messages::HostCommsMessage(response)));
}

Expand Down
8 changes: 8 additions & 0 deletions stm32-modules/thermocycler-gen2/simulator/motor_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ class SimMotorPolicy : public SimTMC2130Policy {

auto seal_switches_are_shared() -> bool { return false; }

auto last_reset_reason() -> uint16_t { return reset_reason; }

auto set_last_reset_reason(uint16_t sim_reason) -> void {
reset_reason = sim_reason;
}

private:
// Lowest position the lid can move before stalling
static constexpr uint32_t min_lid_steps =
Expand All @@ -132,6 +138,8 @@ class SimMotorPolicy : public SimTMC2130Policy {
static constexpr double open_switch_pos_angle = 90.0F;
// Simulated width of each lid switch in degrees
static constexpr double switch_width_angle = 1.0F;
// Simulated reset reason from HAL RCC flag
uint16_t reset_reason = 0;

// Check if open switch is triggered
[[nodiscard]] static auto open_switch_triggered(double angle) -> bool {
Expand Down

0 comments on commit 90f2701

Please sign in to comment.