Robot angle is now a float and therefore converted as a int16_t when sended

This commit is contained in:
Ulysse Cura 2025-05-27 22:59:11 +02:00
parent 5512d868ed
commit d964cdf9cf
2 changed files with 4 additions and 4 deletions

View File

@ -3,7 +3,7 @@
#include <pico/types.h>
#define ANGLE_PER_SECOND 45
#define ANGLE_PER_SECOND 90
typedef enum buttons_t {
BUTTON_L,
@ -31,7 +31,7 @@ extern const button_def_t BUTTONS_DEFS[];
typedef struct inputs_buffer_t {
int8_t x_axis_speed;
int8_t y_axis_speed;
int16_t robot_angle;
float robot_angle;
bool buttons_states[NB_BUTTONS];
} inputs_buffer_t;

View File

@ -93,8 +93,8 @@ void udp_server_send(void)
for(uint i = 0; i < 16; i++) data[i] = 0;
data[UDP_PAYLOAD_ANGLE_L_BYTE] = controller.inputs_buffer.robot_angle & 0xff;
data[UDP_PAYLOAD_ANGLE_H_BYTE] = (controller.inputs_buffer.robot_angle >> 8) & 0xff;
data[UDP_PAYLOAD_ANGLE_L_BYTE] = ((int16_t)controller.inputs_buffer.robot_angle) & 0xff;
data[UDP_PAYLOAD_ANGLE_H_BYTE] = (((int16_t)controller.inputs_buffer.robot_angle) >> 8) & 0xff;
data[UDP_PAYLOAD_X_AXIS_SPEED_BYTE] = *(uint8_t *)&controller.inputs_buffer.x_axis_speed;
data[UDP_PAYLOAD_Y_AXIS_SPEED_BYTE] = *(uint8_t *)&controller.inputs_buffer.y_axis_speed;