From fb0dba446da54c3188cb4d6cea54c07103e43977 Mon Sep 17 00:00:00 2001 From: jlino Date: Sun, 16 Apr 2017 11:36:18 +0100 Subject: [PATCH] nunchuck over uart --- bldc_interface.cpp | 17 ++++++++++++++++- bldc_interface.h | 1 + comm_uart_arduino.cpp | 2 +- datatypes.h | 10 ++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/bldc_interface.cpp b/bldc_interface.cpp index b192e94..f63d310 100644 --- a/bldc_interface.cpp +++ b/bldc_interface.cpp @@ -659,7 +659,22 @@ void bldc_interface_set_servo_pos(float pos) { buffer_append_float16(send_buffer, pos, 1000.0, &send_index); send_packet_no_fwd(send_buffer, send_index); } - +*/ +void bldc_interface_set_uartchuck_data(const chuck_data *chuck_d_remote) { + uint8_t send_buffer[13]; + int send_index = 0; + fwd_can_append(send_buffer, &send_index); + send_buffer[send_index++] = COMM_CUSTOM_APP_DATA; + send_buffer[send_index++] = (uint8_t) chuck_d_remote->js_x; + send_buffer[send_index++] = (uint8_t) chuck_d_remote->js_y; + send_buffer[send_index++] = (uint8_t) chuck_d_remote->bt_c; + send_buffer[send_index++] = (uint8_t) chuck_d_remote->bt_z; + buffer_append_int16(send_buffer, chuck_d_remote->acc_x, &send_index); + buffer_append_int16(send_buffer, chuck_d_remote->acc_y, &send_index); + buffer_append_int16(send_buffer, chuck_d_remote->acc_z, &send_index); + send_packet_no_fwd(send_buffer, send_index); +} +/* void bldc_interface_set_mcconf(const mc_configuration *mcconf) { int send_index = 0; fwd_can_append(send_buffer, &send_index); diff --git a/bldc_interface.h b/bldc_interface.h index f49ee25..e80316e 100644 --- a/bldc_interface.h +++ b/bldc_interface.h @@ -52,6 +52,7 @@ void bldc_interface_set_current_brake(float current); void bldc_interface_set_rpm(int rpm); void bldc_interface_set_pos(float pos); void bldc_interface_set_servo_pos(float pos); +void bldc_interface_set_uartchuck_data(const chuck_data *chuck_d_remote); // JL void bldc_interface_set_mcconf(const mc_configuration *mcconf); void bldc_interface_set_appconf(const app_configuration *appconf); diff --git a/comm_uart_arduino.cpp b/comm_uart_arduino.cpp index c8bd371..d88085f 100644 --- a/comm_uart_arduino.cpp +++ b/comm_uart_arduino.cpp @@ -27,7 +27,7 @@ // Settings -#define __CUA_UART_BAUDRATE 9600 //115200 +#define __CUA_UART_BAUDRATE 115200 // 9600 // Private functions static void send_packet(unsigned char *data, int len); diff --git a/datatypes.h b/datatypes.h index 09c99a3..4969bdb 100644 --- a/datatypes.h +++ b/datatypes.h @@ -268,6 +268,16 @@ typedef struct { float tc_max_diff; } chuk_config; +typedef struct { + int js_x; + int js_y; + int acc_x; + int acc_y; + int acc_z; + bool bt_c; + bool bt_z; +} chuck_data; + // NRF Datatypes typedef enum { NRF_SPEED_250K = 0, -- 2.24.1