From 5b1dc42e9023a21cf45082a8cbefb1169d6e01ea Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Tue, 17 May 2016 16:02:18 +0200 Subject: [PATCH] Reduce delay between loops and add RF commands for RF remote control --- cape_rccar/main.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/cape_rccar/main.c b/cape_rccar/main.c index 0ed4b66..b279b7c 100644 --- a/cape_rccar/main.c +++ b/cape_rccar/main.c @@ -449,6 +449,28 @@ void handle_rf_rx_data(void) #if (DEBUG == 1) uprintf(UART_DEBUG, "RF: ret:%d, st: %d.\n", ret, status); #endif + + if (ret <= 0) { + return; + } + + switch (data[2]) { + case 'D': + if (data[3] > DIRECTION_CTRL_SERVO_MAX) { + data[3] = DIRECTION_CTRL_SERVO_MAX; + } + if (data[3] < DIRECTION_CTRL_SERVO_MIN) { + data[3] = DIRECTION_CTRL_SERVO_MIN; + } + set_servo(UART_DEBUG, DIRECTION_CTRL_SERVO, data[3]); + break; + case 'S': + set_servo(UART_DEBUG, SPEED_CTRL_SERVO, data[3]); + break; + default: + uprintf(UART_DEBUG, "Received unhandled command on RF\n"); + break; + } } void send_on_rf(void) @@ -631,7 +653,7 @@ int main(void) tmp101_sensor_start_conversion(&tmp101_sensor); /* A conversion takes about 40ms */ /* Tell we are alive :) */ - chenillard(250); + chenillard(10); /* Read the temperature */ if (tmp101_sensor_read(&tmp101_sensor, NULL, &board_temp) != 0) { -- 2.43.0