From 21b3846c5f1a0a6cfa8c75734eceb07e5bbbc1fd Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Sat, 22 Mar 2008 16:18:54 +0100 Subject: * digital/io/src - add servo/trap commands over UART protocol to: - control the position of a servo motor (servo); - setup the configuration of vertical and horizontal position (trap); - open a path to a desired box (trap). --- digital/io/src/main.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'digital/io/src') diff --git a/digital/io/src/main.c b/digital/io/src/main.c index 76594bbd..9022c9ae 100644 --- a/digital/io/src/main.c +++ b/digital/io/src/main.c @@ -37,6 +37,7 @@ #include "asserv.h" /* Functions to control the asserv board */ #include "switch.h" /* Manage switches (jack, color selector) */ #include "eeprom.h" /* Parameters loaded/stored in the EEPROM */ +#include "trap.h" /* Trap module (trap_* functions) */ /** * Initialize the main and all its subsystems. @@ -62,6 +63,8 @@ main_init (void) eeprom_load_param (); /* Asserv communication */ asserv_init (); + /* Trap module */ + trap_init (); /* Enable interrupts */ sei (); @@ -109,6 +112,32 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args) utils_reset (); break; + /* Servo/trap commands */ + case c ('t', 3): + /* Set the high time values of a servo for the vertical and horizontal + * positions using trapdoor module. + * - 1b: servo id number; + * - 1b: high time value (horizontal); + * - 1b: high time value (vertical). + */ + trap_set_high_time (args[0], args[1], args[2]); + break; + + case c ('T', 1): + /* Setup traps to open a path to a destination box. + * - 1b: box identification + */ + trap_setup_path_to_box (args[0]); + break; + + case c ('s', 2): + /* Set servo motor to a desired position using the servo module. + * - 1b: servo id number; + * - 1b: pwm high time value (position). + */ + servo_set_high_time (args[0], args[1]); + break; + default: /* Unknown commands */ proto_send0 ('?'); -- cgit v1.2.3