Skip to content

Commit

Permalink
send warning when door/reed state change
Browse files Browse the repository at this point in the history
  • Loading branch information
ahiuchingau committed Mar 15, 2024
1 parent 750940a commit 4677a4b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/bootloader/core/ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ typedef enum {
can_errorcode_motor_busy = 0xb,
can_errorcode_stop_requested = 0xc,
can_errorcode_over_pressure = 0xd,
can_errorcode_door_open = 0xe,
can_errorcode_reed_open = 0xf,
} CANErrorCode;

/** Tool types detected on Head. */
Expand Down
2 changes: 2 additions & 0 deletions include/can/core/ids.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ enum class ErrorCode {
motor_busy = 0xb,
stop_requested = 0xc,
over_pressure = 0xd,
door_open = 0xe,
reed_open = 0xf,
};

/** Error Severity levels. */
Expand Down
17 changes: 14 additions & 3 deletions include/hepa-uv/core/uv_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,23 @@ class UVMessageHandler {
// reset push button state if the door is opened or the reed switch is
// not set
if (!door_closed || !reed_switch_set) {
gpio::reset(drive_pins.uv_on_off);
// Set the push button LED's to user intervention (blue)
if (_timer.is_running()) {
gpio::reset(drive_pins.uv_on_off);
_timer.stop();
// send error message when door/reed state change while uv
// is on
auto resp = can::messages::ErrorMessage{
.message_index = 0,
.severity = can::ids::ErrorSeverity::warning,
.error_code = !door_closed ? can::ids::ErrorCode::door_open
: can::ids::ErrorCode::reed_open,
};
can_client.send_can_message(can::ids::NodeId::host, resp);
}
led_control_client.send_led_control_message(
// Set the push button LED's to user intervention (blue)
led_control_task_messages::PushButtonLED(UV_BUTTON, 0, 0, 50,
0));
if (_timer.is_running()) _timer.stop();
uv_push_button = false;
uv_light_on = false;
return;
Expand Down

0 comments on commit 4677a4b

Please sign in to comment.