throttle speed before ejection
[aversive.git] / modules / devices / servo / multiservo / test / main.c
1 /*  
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)
3  * 
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  *  Revision : $Id: main.c,v 1.4.4.2 2007-05-23 17:18:14 zer0 Exp $
19  *
20  */
21
22 #include <stdio.h>
23
24 #include <aversive/error.h>
25 #include <uart.h>
26 #include <aversive/wait.h>
27 #include <multiservo.h>
28
29
30 void mylog(struct error * e, ...)
31 {
32         va_list ap;
33         
34         va_start(ap, e);
35         printf_P(PSTR("[%d]: E%d "), e->severity, e->err_num);
36         vfprintf_P(stdout, e->text, ap); 
37         printf_P(PSTR("\n"));
38         va_end(ap);
39 }
40
41 int main(void)
42 {
43 #ifndef HOST_VERSION
44   /* uart stuff */
45         uart_init();  
46         fdevopen(uart0_dev_send,NULL);
47 #endif
48         
49         error_register_debug(mylog);
50         printf_P("hello !!\n");
51         
52         multiservo_init();
53         multiservo_add(&PORTC, 7); /* return id 0 (atm32) */
54         //  multiservo_add(&PORTF, 0); /* return id 0 (atm 128) */
55         sei();
56         while(1) {
57                 multiservo_set(0, 1200);
58                 wait_ms(1000);
59                 multiservo_set(0, 1800);
60                 wait_ms(1000);
61         }
62         return 0;
63 }
64