integrating esc code

This commit is contained in:
Pascal Brisset
2005-12-15 16:56:14 +00:00
parent b24472f0ee
commit 9ac33172e6
14 changed files with 279 additions and 73 deletions
+1 -1
View File
@@ -134,7 +134,7 @@ ac_h : tools static_h
PAPARAZZI_HOME=`pwd` PAPARAZZI_SRC=`pwd` $(TOOLS)/gen_aircraft.out $(AIRCRAFT) PAPARAZZI_HOME=`pwd` PAPARAZZI_SRC=`pwd` $(TOOLS)/gen_aircraft.out $(AIRCRAFT)
sim_ac: ac_h sim_sitl sim_ac: ac_h sim_sitl
hard_ac: ac_h ap fbw hard_ac: ac_h fbw ap
ac: sim_ac hard_ac ac: sim_ac hard_ac
doxygen: doxygen:
+124
View File
@@ -0,0 +1,124 @@
<airframe name="Gorazoptere_brushless_ANALOG">
<section name="IMU_ANALOG" prefix="IMU_">
<define name="INIT_EULER_DOT_VARIANCE_MAX" value="3"/>
<define name="INIT_EULER_DOT_NB_SAMPLES_MIN" value ="10"/>
<define name="ADC_ROLL_DOT" value="1"/>
<define name="ADC_PITCH_DOT" value="2"/>
<define name="ADC_YAW_DOT" value="3"/>
<define name="ADC_ROLL_DOT_SIGN" value="-"/>
<define name="ADC_PITCH_DOT_SIGN" value="+"/>
<define name="ADC_YAW_DOT_SIGN" value="-"/>
<define name="ADC_ROLL_DOT_ZERO" value="512"/>
<define name="ADC_PITCH_DOT_ZERO" value="512"/>
<define name="ADC_YAW_DOT_ZERO" value="512"/>
<define name="ADC_ROLL_DOT_SCALE" value="(real_t) (0.9444 * 3.14159 / 180.0)"/>
<define name="ADC_PITCH_DOT_SCALE" value="(real_t) (0.9444 * 3.14159 / 180.0)"/>
<define name="ADC_YAW_DOT_SCALE" value="(real_t) (0.9444 * 3.14159 / 180.0)"/>
<define name="ADC_ACCELX" value="3"/>
<define name="ADC_ACCELY" value="4"/>
<define name="ADC_ACCELZ" value="5"/>
<define name="ADC_ACCELX_SIGN" value="-"/>
<define name="ADC_ACCELY_SIGN" value="+"/>
<define name="ADC_ACCELZ_SIGN" value="-"/>
<define name="ADC_ACCELX_ZERO" value="0x24A"/>
<define name="ADC_ACCELY_ZERO" value="0x280"/>
<define name="ADC_ACCELZ_ZERO" value="0x210"/>
<define name="ADC_ACCELX_SCALE" value="0x24A"/>
<define name="ADC_ACCELY_SCALE" value="0x280"/>
<define name="ADC_ACCELZ_SCALE" value="0x210"/>
</section>
<section name="RATE_LOOP">
<define name="ROLL_DOT_PGAIN" value="-100."/>
<define name="ROLL_DOT_IGAIN" value="0."/>
<define name="ROLL_DOT_DGAIN" value="0."/>
<define name="PITCH_DOT_PGAIN" value="-100."/>
<define name="PITCH_DOT_IGAIN" value="0."/>
<define name="PITCH_DOT_DGAIN" value="0."/>
<define name="YAW_DOT_PGAIN" value="-100."/>
<define name="YAW_DOT_IGAIN" value="0."/>
<define name="YAW_DOT_DGAIN" value="0."/>
</section>
<section name="DESIRED_OF_RADIO" prefix="DESIRED_OF_RADIO_">
<define name="ROLL_DOT" value="0.015"/>
<define name="PITCH_DOT" value="0.015"/>
<define name="YAW_DOT" value="0.015"/>
</section>
<section name="adc" prefix="ADC_CHANNEL_">
<define name="IR1" value="0"/>
<define name="IR2" value="1"/>
<define name="VSUPPLY" value="6"/>
</section>
<servos min="0" neutral="0" max="0x3ff">
<servo name="MOTOR_FRONT" no="0" min="0" neutral="0" max="0x3ff"/>
<servo name="MOTOR_BACK" no="1" min="0" neutral="0" max="0x3ff"/>
<servo name="MOTOR_LEFT" no="2" min="0" neutral="0" max="0x3ff"/>
<servo name="MOTOR_RIGHT" no="3" min="0" neutral="0" max="0x3ff"/>
</servos>
<command>
<let var="roll" value="0.3 * @ROLL"/>
<let var="pitch" value="0.3 * @PITCH"/>
<let var="yaw" value="-0.4 * @YAW"/>
<let var="throttle" value="2.0 * @THROTTLE"/>
<set servo="MOTOR_FRONT" value="$throttle + $pitch - $yaw"/>
<set servo="MOTOR_BACK" value="$throttle - $pitch - $yaw"/>
<set servo="MOTOR_RIGHT" value="$throttle + $roll + $yaw"/>
<set servo="MOTOR_LEFT" value="$throttle - $roll + $yaw"/>
</command>
<section name="INFRARED" prefix="IR_">
<define name="ADC_ROLL_NEUTRAL" value="0"/>
<define name="ADC_PITCH_NEUTRAL" value="1024"/>
<define name="ROLL_NEUTRAL_DEFAULT" value="0" unit="deg"/>
<define name="PITCH_NEUTRAL_DEFAULT" value="0" unit="deg"/>
<define name="DEFAULT_CONTRAST" value="200"/>
<define name="RAD_OF_IR_CONTRAST" value="0.75"/>
<linear name="RollOfIrs" arity="2" coeff1="-1" coeff2="1"/>
<linear name="PitchOfIrs" arity="2" coeff1="1" coeff2="1"/>
</section>
<section name="PID">
<define name="ROLL_PGAIN" value="23000."/>
<define name="PITCH_OF_ROLL" value="0.0"/>
<define name="PITCH_PGAIN" value="23000."/>
<define name="MAX_ROLL" value="0.35"/>
<define name="MAX_PITCH" value="0.35"/>
<define name="MIN_PITCH" value="-0.35"/>
<define name="AILERON_OF_GAZ" value="-0.13"/>
</section>
<section name="ALT" prefix="CLIMB_">
<define name="PITCH_PGAIN" value="-0.1"/>
<define name="PITCH_IGAIN" value="0.025"/>
<define name="PGAIN" value="-0.03"/>
<define name="IGAIN" value="0.1"/>
<define name="MAX" value="1."/>
<define name="LEVEL_GAZ" value="0.31"/>
<define name="PITCH_OF_VZ_PGAIN" value="0.05"/>
<define name="GAZ_OF_CLIMB" value="0.2" unit="%/(m/s)"/>
</section>
<section name="NAV">
<define name="COURSE_PGAIN" value="-0.2"/>
<define name="ALTITUDE_PGAIN" value="-0.025"/>
<define name="NAV_PITCH" value="0."/>
</section>
<section name="BAT">
<define name="MILLIAMP_PER_PERCENT" value="2.16"/>
<define name="VOLTAGE_ADC_A" value="0.0175"/>
<define name="VOLTAGE_ADC_B" value="0.088"/>
<define name="VoltageOfAdc(adc)" value="(VOLTAGE_ADC_A * adc + VOLTAGE_ADC_B)"/>
<define name="LOW_BATTERY" value="93" unit="1e-1V"/>
</section>
<section name="MISC">
<define name="NOMINAL_AIRSPEED" value="10." unit="m/s"/>
<define name="CARROT" value="5." unit="s"/>
</section>
<makefile>
include $(PAPARAZZI_SRC)/conf/autopilot/disc_board.makefile
LOCAL_CFLAGS += -DIMU_3DMG
fbw.CFLAGS += -DRATE_LOOP
fbw.EXTRA_SRCS += control.c imu.c
fbw.CFLAGS += -DIMU_RESET_ON_BOOT
fbw.CFLAGS += -DTIMER1_TOP=0x400
</makefile>
</airframe>
+24
View File
@@ -0,0 +1,24 @@
ARCHI=avr
ap.ARCHDIR = $(ARCHI)
ap.ARCH = atmega128
ap.TARGET = autopilot
ap.TARGETDIR = autopilot
ap.LOW_FUSE = a0
ap.HIGH_FUSE = 99
ap.EXT_FUSE = ff
ap.LOCK_FUSE = ff
ap.srcs = main_ap.c $(SRC_ARCH)/modem.c link_mcu.c $(SRC_ARCH)/link_mcu_ap.c $(SRC_ARCH)/spi_ap.c $(SRC_ARCH)/adc_ap.c gps_ubx.c infrared.c pid.c nav.c $(SRC_ARCH)/uart_ap.c estimator.c if_calib.c mainloop.c cam.c
fbw.ARCHDIR = $(ARCHI)
fbw.ARCH = atmega128
fbw.TARGET = fbw
fbw.TARGETDIR = fbw
fbw.LOW_FUSE = 2e
fbw.HIGH_FUSE = cb
fbw.EXT_FUSE = ff
fbw.LOCK_FUSE = ff
fbw.srcs = main_fbw.c $(SRC_ARCH)/ppm.c $(SRC_ARCH)/esc.c $(SRC_ARCH)/spi_fbw.c $(SRC_ARCH)/uart_ap.c $(SRC_ARCH)/adc_fbw.c
-4
View File
@@ -30,8 +30,6 @@
#include "airframe.h" #include "airframe.h"
#if defined CTL_BRD_V1_2 || defined CTL_BRD_V1_2_1
#include <inttypes.h> #include <inttypes.h>
@@ -56,6 +54,4 @@ struct adc_buf {
void adc_buf_channel(uint8_t adc_channel, struct adc_buf* s); void adc_buf_channel(uint8_t adc_channel, struct adc_buf* s);
#endif /* CTL_BRD_V1_2 || CTL_BRD_V1_2 */
#endif /* _ADC_H_ */ #endif /* _ADC_H_ */
+58
View File
@@ -0,0 +1,58 @@
/* $Id$
*
* Copied from autopilot (autopilot.sf.net) thanx alot Trammell
* (c) 2003-2005 Pascal Brisset, Antoine Drouin
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/** Implementation of command.h */
#include <avr/io.h>
#include "command.h"
#define MAX_TICK 0x3FF
#define MOT_CTL_0 OCR3C
#define MOT_CTL_1 OCR1A
#define MOT_CTL_2 OCR3B
#define MOT_CTL_3 OCR3A
void command_init ( void ) {
/* OC1A output */
DDRB |= _BV(5);
/* fast PWM, 10 bits */
TCCR1A |= _BV(WGM10) | _BV(WGM11) | _BV(COM1A1);
TCCR1B |= _BV(WGM12);
/* OC3A, OC3B, OC3C outputs */
DDRE |= _BV(3) | _BV(4) | _BV(5);
/* fast PWM : 10 bits */
TCCR3A |= _BV(WGM30) | _BV(WGM31) | _BV(COM3A1) | _BV(COM3B1) | _BV(COM3C1);
TCCR3B |= _BV(WGM32);
}
#define SERVO_NEUTRAL(_) 0
#define COMMAND_(i) MOT_CTL_ ## i
#define COMMAND(i) COMMAND_(i)
#define ChopServo(x) (x > MAX_TICK ? MAX_TICK : x)
void command_set(const pprz_t values[]) {
CommandSet(values); /*Generated from airframe.xml */
}
+11
View File
@@ -58,6 +58,14 @@ volatile bool_t ppm_valid;
#define RestartPpmCycle() { state = 0; sync_start = TCNT2; return; } #define RestartPpmCycle() { state = 0; sync_start = TCNT2; return; }
#ifdef TIMER1_TOP
static volatile uint16_t tmr1_ov_cnt = 0;
SIGNAL(SIG_OVERFLOW1) {
tmr1_ov_cnt += TIMER1_TOP;
return;
}
#endif
SIGNAL( SIG_INPUT_CAPTURE1 ) SIGNAL( SIG_INPUT_CAPTURE1 )
{ {
static uint16_t last; static uint16_t last;
@@ -67,6 +75,9 @@ SIGNAL( SIG_INPUT_CAPTURE1 )
static uint8_t sync_start; static uint8_t sync_start;
this = ICR1; this = ICR1;
#ifdef TIMER1_TOP
this += tmr1_ov_cnt;
#endif
width = this - last; width = this - last;
last = this; last = this;
+6
View File
@@ -84,6 +84,12 @@ ppm_init( void )
/* Enable interrupt on input capture */ /* Enable interrupt on input capture */
sbi( TIMSK, TICIE1 ); sbi( TIMSK, TICIE1 );
#ifdef TIMER1_TOP
/* Enable timer1 overflow it. */
/* needed to increase timer1 count to 16 bits in fast pwm mode (TIMER1_TOP rollover) */
sbi( TIMSK, TOIE1 );
#endif
} }
#define PPM_NB_PULSES RADIO_CTL_NB #define PPM_NB_PULSES RADIO_CTL_NB
+9 -31
View File
@@ -2,7 +2,7 @@
* *
* Copied from autopilot (autopilot.sf.net) thanx alot Trammell * Copied from autopilot (autopilot.sf.net) thanx alot Trammell
* (c) 2002 Trammell Hudson <hudson@rotomotion.com> * (c) 2002 Trammell Hudson <hudson@rotomotion.com>
* (c) 2003 Pascal Brisset, Antoine Drouin * (c) 2003-2005 Pascal Brisset, Antoine Drouin
* *
* This file is part of paparazzi. * This file is part of paparazzi.
* *
@@ -24,10 +24,11 @@
*/ */
/** Implementation of command.h */
#include <avr/io.h> #include <avr/io.h>
#include <avr/signal.h> #include <avr/signal.h>
#include "servo.h" #include "command.h"
#include "link_autopilot.h"
#include "airframe.h" #include "airframe.h"
@@ -76,6 +77,8 @@
/* holds the servo pulses width in clock ticks */ /* holds the servo pulses width in clock ticks */
static uint16_t servo_widths[_4017_NB_CHANNELS]; static uint16_t servo_widths[_4017_NB_CHANNELS];
#define COMMAND(i) servo_widths[i]
/* /*
* We use the output compare registers to generate our servo pulses. * We use the output compare registers to generate our servo pulses.
* These should be connected to a decade counter that routes the * These should be connected to a decade counter that routes the
@@ -91,7 +94,7 @@ static uint16_t servo_widths[_4017_NB_CHANNELS];
* Ideally, you can use two decade counters to drive 20 servos. * Ideally, you can use two decade counters to drive 20 servos.
*/ */
void void
servo_init( void ) command_init( void )
{ {
uint8_t i; uint8_t i;
@@ -190,31 +193,6 @@ the sequence:
servo++; servo++;
} }
void command_set(const pprz_t values[]) {
void servo_set_one(uint8_t servo, uint16_t value_us) { CommandSet(values); /*Generated from airframe.xml */
servo_widths[servo] = ChopServo(CLOCK*value_us);
}
/* void */
/* servo_transmit(void) { */
/* uint8_t servo; */
/* uart_transmit((uint8_t)0); uart_transmit((uint8_t)0); */
/* for(servo = 0; servo < _4017_NB_CHANNELS; servo++) { */
/* uart_transmit((uint8_t)(servo_widths[servo] >> 8)); */
/* uart_transmit((uint8_t)(servo_widths[servo] & 0xff)); */
/* } */
/* uart_transmit((uint8_t)'\n'); */
/* } */
/*
*
* defines how servos react to radio control or autopilot channels
*
*/
void servo_set(const pprz_t values[]) {
ServoSet(values); /*Generated from airframe.xml */
} }
+1 -1
View File
@@ -46,7 +46,7 @@ static inline void timer_init( void ) {
/* Timer0: Modem clock is started in modem.h in ctc mode*/ /* Timer0: Modem clock is started in modem.h in ctc mode*/
/* Timer1 @ Clk/1: System clock, ppm and servos */ /* Timer1 @ Clk/1: System clock */
TCCR1A = 0x00; TCCR1A = 0x00;
TCCR1B = 0x01; TCCR1B = 0x01;
+11 -11
View File
@@ -41,7 +41,7 @@ static uint8_t tx_buf[ TX_BUF_SIZE ];
* With 16.0 MHz clock,UBRR=25 => 38400 baud * With 16.0 MHz clock,UBRR=25 => 38400 baud
* *
*/ */
void uart_init_tx( void ) { void uart0_init_tx( void ) {
/* Baudrate is 38.4k */ /* Baudrate is 38.4k */
UBRRH = 0; UBRRH = 0;
UBRRL = 25; UBRRL = 25;
@@ -53,14 +53,14 @@ void uart_init_tx( void ) {
UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0); UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0);
} }
void uart_init_rx() { void uart0_init_rx() {
/* Enable receiver */ /* Enable receiver */
UCSRB |= _BV(RXEN); UCSRB |= _BV(RXEN);
/* Enable uart receive interrupt */ /* Enable uart receive interrupt */
sbi( UCSRB, RXCIE ); sbi( UCSRB, RXCIE );
} }
void uart_transmit( unsigned char data ) { void uart0_transmit( unsigned char data ) {
if (UCSRB & _BV(TXCIE)) { if (UCSRB & _BV(TXCIE)) {
/* we are waiting for the last char to be sent : buffering */ /* we are waiting for the last char to be sent : buffering */
if (tx_tail == tx_head + 1) { /* BUF_SIZE = 256 */ if (tx_tail == tx_head + 1) { /* BUF_SIZE = 256 */
@@ -75,26 +75,26 @@ void uart_transmit( unsigned char data ) {
} }
} }
void uart_print_hex ( uint8_t c ) { void uart0_print_hex ( uint8_t c ) {
const uint8_t hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', const uint8_t hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
uint8_t high = (c & 0xF0)>>4; uint8_t high = (c & 0xF0)>>4;
uint8_t low = c & 0x0F; uint8_t low = c & 0x0F;
uart_transmit(hex[high]); uart0_transmit(hex[high]);
uart_transmit(hex[low]); uart0_transmit(hex[low]);
} }
void uart_print_hex16 ( uint16_t c ) { void uart0_print_hex16 ( uint16_t c ) {
uint8_t high = (uint8_t)(c>>8); uint8_t high = (uint8_t)(c>>8);
uint8_t low = (uint8_t)(c); uint8_t low = (uint8_t)(c);
uart_print_hex(high); uart0_print_hex(high);
uart_print_hex(low); uart0_print_hex(low);
} }
void uart_print_string(const uint8_t* s) { void uart0_print_string(const uint8_t* s) {
uint8_t i = 0; uint8_t i = 0;
while (s[i]) { while (s[i]) {
uart_transmit(s[i]); uart0_transmit(s[i]);
i++; i++;
} }
} }
+9
View File
@@ -0,0 +1,9 @@
#ifndef COMMAND_H
#define COMMAND_H
#include "link_autopilot.h"
extern void command_init( void );
extern void command_set(const pprz_t values[]);
#endif /* COMMAND_H */
+16 -16
View File
@@ -28,7 +28,7 @@
#include "int.h" #include "int.h"
#include "timer_fbw.h" #include "timer_fbw.h"
#include "servo.h" #include "command.h"
#include "ppm.h" #include "ppm.h"
#include "spi_fbw_hw.h" #include "spi_fbw_hw.h"
#include "spi_fbw.h" #include "spi_fbw.h"
@@ -116,7 +116,7 @@ inline void radio_control_task(void) {
pitch_dot_dgain = roll_dot_dgain; pitch_dot_dgain = roll_dot_dgain;
control_set_desired(last_radio); control_set_desired(last_radio);
#else #else
servo_set(last_radio); command_set(last_radio);
#endif #endif
} }
} }
@@ -129,7 +129,7 @@ inline void spi_task(void) {
#if defined IMU_ANALOG || defined IMU_3DMG #if defined IMU_ANALOG || defined IMU_3DMG
control_set_desired(from_mega128.channels); control_set_desired(from_mega128.channels);
#else #else
servo_set(from_mega128.channels); command_set(from_mega128.channels);
#endif #endif
} }
} }
@@ -151,11 +151,11 @@ int main( void )
while (foo2++); while (foo2++);
} }
} }
uart_init_tx(); uart0_init_tx();
#if defined IMU_3DMG #if defined IMU_3DMG
uart_init_rx(); uart0_init_rx();
#else #else
uart_print_string("FBW Booting $Id$\n"); uart0_print_string("FBW Booting $Id$\n");
#endif #endif
adc_init(); adc_init();
adc_buf_channel(ADC_CHANNEL_VSUPPLY, &vsupply_adc_buf); adc_buf_channel(ADC_CHANNEL_VSUPPLY, &vsupply_adc_buf);
@@ -165,7 +165,7 @@ int main( void )
#endif #endif
timer_init(); timer_init();
servo_init(); command_init();
ppm_init(); ppm_init();
spi_init(); spi_init();
@@ -207,7 +207,7 @@ int main( void )
if ((mode == MODE_MANUAL && !radio_ok) || if ((mode == MODE_MANUAL && !radio_ok) ||
(mode == MODE_AUTO && !mega128_ok)) { (mode == MODE_AUTO && !mega128_ok)) {
failsafe_mode = TRUE; failsafe_mode = TRUE;
servo_set(failsafe); command_set(failsafe);
} }
if(timer_periodic()) { if(timer_periodic()) {
@@ -222,12 +222,12 @@ int main( void )
static uint8_t foo = 0; static uint8_t foo = 0;
foo++; foo++;
if (!(foo%10)) { if (!(foo%10)) {
uart_print_hex16(roll_dot); uart0_print_hex16(roll_dot);
uart_transmit(','); uart0_transmit(',');
uart_print_hex16(pitch_dot); uart0_print_hex16(pitch_dot);
uart_transmit(','); uart0_transmit(',');
uart_print_hex16(yaw_dot); uart0_print_hex16(yaw_dot);
uart_transmit('\n'); uart0_transmit('\n');
} }
} }
#endif /* 0 */ #endif /* 0 */
@@ -236,10 +236,10 @@ int main( void )
control_run(); control_run();
if (radio_ok) { if (radio_ok) {
if (last_radio[RADIO_THROTTLE] > 0.1*MAX_PPRZ) { if (last_radio[RADIO_THROTTLE] > 0.1*MAX_PPRZ) {
servo_set(control_commands); command_set(control_commands);
} }
else { else {
servo_set(failsafe); command_set(failsafe);
} }
} }
#endif #endif
+7 -7
View File
@@ -29,13 +29,13 @@
#include "uart_fbw_hw.h" #include "uart_fbw_hw.h"
void uart_init_tx( void ); void uart0_init_tx( void );
void uart_init_rx( void ); void uart0_init_rx( void );
void uart_transmit( unsigned char data ); void uart0_transmit( unsigned char data );
void uart_print_hex ( uint8_t c ); void uart0_print_hex ( uint8_t c );
void uart_print_hex16 ( uint16_t c ); void uart0_print_hex16 ( uint16_t c );
void uart_print_string(const uint8_t* s); void uart0_print_string(const uint8_t* s);
void uart_print_float( const float * f); void uart0_print_float( const float * f);
#endif #endif
+2 -2
View File
@@ -98,7 +98,7 @@ let parse_command = fun command ->
printf " command_value = %s;\\\n" v; printf " command_value = %s;\\\n" v;
printf " command_value *= command_value>0 ? SERVO_%s_TRAVEL_UP : SERVO_%s_TRAVEL_DOWN;\\\n" servo servo; printf " command_value *= command_value>0 ? SERVO_%s_TRAVEL_UP : SERVO_%s_TRAVEL_DOWN;\\\n" servo servo;
printf " servo_value = SERVO_NEUTRAL(SERVO_%s) + (int16_t)(command_value);\\\n" servo; printf " servo_value = SERVO_NEUTRAL(SERVO_%s) + (int16_t)(command_value);\\\n" servo;
printf " servo_widths[SERVO_%s] = ChopServo(servo_value);\\\n\\\n" servo printf " COMMAND(SERVO_%s) = ChopServo(servo_value);\\\n\\\n" servo
| "let" -> | "let" ->
let var = a "var" let var = a "var"
and value = a "value" in and value = a "value" in
@@ -141,7 +141,7 @@ let parse_section = fun s ->
define "SERVO_MAX_US" (sprintf "%.0ful" max); define "SERVO_MAX_US" (sprintf "%.0ful" max);
nl () nl ()
| "command" -> | "command" ->
printf "#define ServoSet(values) { \\\n"; printf "#define CommandSet(values) { \\\n";
printf " uint16_t servo_value;\\\n"; printf " uint16_t servo_value;\\\n";
printf " float command_value;\\\n"; printf " float command_value;\\\n";
List.iter parse_command (Xml.children s); List.iter parse_command (Xml.children s);