Skip to content

Commit

Permalink
add trigger disable when remote offline
Browse files Browse the repository at this point in the history
  • Loading branch information
jia-xie committed Apr 5, 2024
1 parent dfd3046 commit f852c34
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/app/src/robot.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void Robot_Cmd_Loop()
{
if (g_start_safely)
{
if (g_remote.controller.right_switch == DOWN)
if ((g_remote.online_flag == REMOTE_OFFLINE) || (g_remote.controller.right_switch == DOWN))
{
g_robot_state.enabled = 0;
g_launch_target.flywheel_enabled = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/devices/inc/remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "bsp_uart.h"

#define REMOTE_STICK_MAX (660.0f)
#define REMOTE_ONLINE (1)
#define REMOTE_OFFLINE (0)

#define KEY_W ((uint16_t)0x01<<0)
#define KEY_S ((uint16_t)0x01<<1)
Expand Down Expand Up @@ -80,6 +82,8 @@ typedef struct
struct Controller controller;
struct Keyboard keyboard;
struct Mouse mouse;

uint8_t online_flag;
} Remote_t;


Expand Down
3 changes: 3 additions & 0 deletions src/devices/src/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ void Remote_Buffer_Process()
g_remote.keyboard.C = (key_buffer >> 13) & 0x001;
g_remote.keyboard.V = (key_buffer >> 14) & 0x001;
g_remote.keyboard.B = (key_buffer >> 15) & 0x001;

g_remote.online_flag = 1;
}

void Remote_Rx_Callback(UART_Instance_t *uart_instance)
Expand All @@ -69,6 +71,7 @@ void Remote_Timeout_Callback()
{
// reinitalize the remote uart transmission
UART_Service_Init(g_remote_uart);
g_remote.online_flag = 0;
}

Remote_t* Remote_Init(UART_HandleTypeDef *huart)
Expand Down

0 comments on commit f852c34

Please sign in to comment.