vt100: include pgmspace.h as we use PROGMEM macro
[aversive.git] / projects / microb2010 / tests / hostsim / actuator.c
1 /*  
2  *  Copyright Droids Corporation (2009)
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: actuator.c,v 1.3 2009-05-02 10:08:09 zer0 Exp $
19  *
20  */
21
22 #include <aversive.h>
23 #include <aversive/pgmspace.h>
24 #include <aversive/wait.h>
25 #include <aversive/error.h>
26
27 #include <uart.h>
28 #include <timer.h>
29 #include <scheduler.h>
30 #include <time.h>
31
32 #include <pid.h>
33 #include <quadramp.h>
34 #include <control_system_manager.h>
35 #include <trajectory_manager.h>
36 #include <vect_base.h>
37 #include <lines.h>
38 #include <polygon.h>
39 #include <obstacle_avoidance.h>
40 #include <blocking_detection_manager.h>
41 #include <robot_system.h>
42 #include <position_manager.h>
43
44 #include <rdline.h>
45
46 #include "main.h"
47 #include "robotsim.h"
48
49 void pwm_set_and_save(void *pwm, int32_t val)
50 {
51         /* we need to do the saturation here, before saving the
52          * value */
53         if (val > 4095)
54                 val = 4095;
55         if (val < -4095)
56                 val = -4095;
57         
58         if (pwm == LEFT_PWM)
59                 mainboard.pwm_l = val;
60         else if (pwm == RIGHT_PWM)
61                 mainboard.pwm_r = val;
62 #ifdef HOST_VERSION
63         robotsim_pwm(pwm, val);
64 #else
65         pwm_ng_set(pwm, val);
66 #endif
67 }
68
69 void pickup_wheels_on(void)
70 {
71         mainboard.enable_pickup_wheels = 1;
72 }
73
74 void pickup_wheels_off(void)
75 {
76         mainboard.enable_pickup_wheels = 0;
77 }
78