1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 17:25:20 +03:00

Remove serial_cli.c's dependency on mw.h/board.h.

Rename yawdeadband to yaw_deadband to match other variables/cli
commands.

Fix a couple of usages of MAX_MOTORS where MAX_SUPPORTED_MOTORS should
be used instead.
This commit is contained in:
Dominic Clifton 2014-04-23 20:42:38 +01:00
parent bcc55abcc8
commit a5f0999c26
12 changed files with 250 additions and 220 deletions

View file

@ -6,6 +6,8 @@ typedef struct batteryConfig_s {
uint8_t vbatmincellvoltage; // minimum voltage per cell, this triggers battery out alarms, in 0.1V units, default is 33 (3.3V) uint8_t vbatmincellvoltage; // minimum voltage per cell, this triggers battery out alarms, in 0.1V units, default is 33 (3.3V)
} batteryConfig_t; } batteryConfig_t;
extern uint8_t vbat;
extern uint8_t batteryCellCount;
extern uint16_t batteryWarningVoltage; extern uint16_t batteryWarningVoltage;
uint16_t batteryAdcToVoltage(uint16_t src); uint16_t batteryAdcToVoltage(uint16_t src);

View file

@ -1,4 +1,8 @@
#include <stdint.h>
#include <string.h>
#include <math.h>
#include "build_config.h" #include "build_config.h"
#include "maths.h"
#ifdef REQUIRE_PRINTF_LONG_SUPPORT #ifdef REQUIRE_PRINTF_LONG_SUPPORT
@ -85,3 +89,176 @@ char a2i(char ch, char **src, int base, int *nump)
*nump = num; *nump = num;
return ch; return ch;
} }
#ifndef HAVE_ITOA_FUNCTION
/*
** The following two functions together make up an itoa()
** implementation. Function i2a() is a 'private' function
** called by the public itoa() function.
**
** itoa() takes three arguments:
** 1) the integer to be converted,
** 2) a pointer to a character conversion buffer,
** 3) the radix for the conversion
** which can range between 2 and 36 inclusive
** range errors on the radix default it to base10
** Code from http://groups.google.com/group/comp.lang.c/msg/66552ef8b04fe1ab?pli=1
*/
static char *_i2a(unsigned i, char *a, unsigned r)
{
if (i / r > 0)
a = _i2a(i / r, a, r);
*a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i % r];
return a + 1;
}
char *itoa(int i, char *a, int r)
{
if ((r < 2) || (r > 36))
r = 10;
if (i < 0) {
*a = '-';
*_i2a(-(unsigned)i, a + 1, r) = 0;
} else
*_i2a(i, a, r) = 0;
return a;
}
#endif
char *ftoa(float x, char *floatString)
{
int32_t value;
char intString1[12];
char intString2[12] = { 0, };
char *decimalPoint = ".";
uint8_t dpLocation;
if (x > 0) // Rounding for x.xxx display format
x += 0.0005f;
else
x -= 0.0005f;
value = (int32_t) (x * 1000.0f); // Convert float * 1000 to an integer
itoa(abs(value), intString1, 10); // Create string from abs of integer value
if (value >= 0)
intString2[0] = ' '; // Positive number, add a pad space
else
intString2[0] = '-'; // Negative number, add a negative sign
if (strlen(intString1) == 1) {
intString2[1] = '0';
intString2[2] = '0';
intString2[3] = '0';
strcat(intString2, intString1);
} else if (strlen(intString1) == 2) {
intString2[1] = '0';
intString2[2] = '0';
strcat(intString2, intString1);
} else if (strlen(intString1) == 3) {
intString2[1] = '0';
strcat(intString2, intString1);
} else {
strcat(intString2, intString1);
}
dpLocation = strlen(intString2) - 3;
strncpy(floatString, intString2, dpLocation);
floatString[dpLocation] = '\0';
strcat(floatString, decimalPoint);
strcat(floatString, intString2 + dpLocation);
return floatString;
}
// Simple and fast atof (ascii to float) function.
//
// - Executes about 5x faster than standard MSCRT library atof().
// - An attractive alternative if the number of calls is in the millions.
// - Assumes input is a proper integer, fraction, or scientific format.
// - Matches library atof() to 15 digits (except at extreme exponents).
// - Follows atof() precedent of essentially no error checking.
//
// 09-May-2009 Tom Van Baak (tvb) www.LeapSecond.com
#define white_space(c) ((c) == ' ' || (c) == '\t')
#define valid_digit(c) ((c) >= '0' && (c) <= '9')
float fastA2F(const char *p)
{
int frac = 0;
float sign, value, scale;
// Skip leading white space, if any.
while (white_space(*p) ) {
p += 1;
}
// Get sign, if any.
sign = 1.0f;
if (*p == '-') {
sign = -1.0f;
p += 1;
} else if (*p == '+') {
p += 1;
}
// Get digits before decimal point or exponent, if any.
value = 0.0f;
while (valid_digit(*p)) {
value = value * 10.0f + (*p - '0');
p += 1;
}
// Get digits after decimal point, if any.
if (*p == '.') {
float pow10 = 10.0f;
p += 1;
while (valid_digit(*p)) {
value += (*p - '0') / pow10;
pow10 *= 10.0f;
p += 1;
}
}
// Handle exponent, if any.
scale = 1.0f;
if ((*p == 'e') || (*p == 'E')) {
unsigned int expon;
p += 1;
// Get sign of exponent, if any.
frac = 0;
if (*p == '-') {
frac = 1;
p += 1;
} else if (*p == '+') {
p += 1;
}
// Get digits of exponent, if any.
expon = 0;
while (valid_digit(*p)) {
expon = expon * 10 + (*p - '0');
p += 1;
}
if (expon > 308)
expon = 308;
// Calculate scaling factor.
// while (expon >= 50) { scale *= 1E50f; expon -= 50; }
while (expon >= 8) { scale *= 1E8f; expon -= 8; }
while (expon > 0) { scale *= 10.0f; expon -= 1; }
}
// Return signed and scaled floating point result.
return sign * (frac ? (value / scale) : (value * scale));
}

View file

@ -5,3 +5,9 @@ void li2a(long num, char *bf);
void ui2a(unsigned int num, unsigned int base, int uc, char *bf); void ui2a(unsigned int num, unsigned int base, int uc, char *bf);
void i2a(int num, char *bf); void i2a(int num, char *bf);
char a2i(char ch, char **src, int base, int *nump); char a2i(char ch, char **src, int base, int *nump);
char *ftoa(float x, char *floatString);
float fastA2F(const char *p);
#ifndef HAVE_ITOA_FUNCTION
char *itoa(int i, char *a, int r);
#endif

View file

@ -345,7 +345,7 @@ static void resetConf(void)
// Radio // Radio
parseRcChannels("AETR1234", &masterConfig.rxConfig); parseRcChannels("AETR1234", &masterConfig.rxConfig);
currentProfile.deadband = 0; currentProfile.deadband = 0;
currentProfile.yawdeadband = 0; currentProfile.yaw_deadband = 0;
currentProfile.alt_hold_throttle_neutral = 40; currentProfile.alt_hold_throttle_neutral = 40;
currentProfile.alt_hold_fast_change = 1; currentProfile.alt_hold_fast_change = 1;
currentProfile.throttle_correction_value = 0; // could 10 with althold or 40 for fpv currentProfile.throttle_correction_value = 0; // could 10 with althold or 40 for fpv

View file

@ -29,7 +29,7 @@ typedef struct profile_s {
// Radio/ESC-related configuration // Radio/ESC-related configuration
uint8_t deadband; // introduce a deadband around the stick center for pitch and roll axis. Must be greater than zero. uint8_t deadband; // introduce a deadband around the stick center for pitch and roll axis. Must be greater than zero.
uint8_t yawdeadband; // introduce a deadband around the stick center for yaw axis. Must be greater than zero. uint8_t yaw_deadband; // introduce a deadband around the stick center for yaw axis. Must be greater than zero.
uint8_t alt_hold_throttle_neutral; // defines the neutral zone of throttle stick during altitude hold, default setting is +/-40 uint8_t alt_hold_throttle_neutral; // defines the neutral zone of throttle stick during altitude hold, default setting is +/-40
uint8_t alt_hold_fast_change; // when disabled, turn off the althold when throttle stick is out of deadband defined with alt_hold_throttle_neutral; when enabled, altitude changes slowly proportional to stick movement uint8_t alt_hold_fast_change; // when disabled, turn off the althold when throttle stick is out of deadband defined with alt_hold_throttle_neutral; when enabled, altitude changes slowly proportional to stick movement
uint16_t throttle_correction_angle; // the angle when the throttle correction is maximal. in 0.1 degres, ex 225 = 22.5 ,30.0, 450 = 45.0 deg uint16_t throttle_correction_angle; // the angle when the throttle correction is maximal. in 0.1 degres, ex 225 = 22.5 ,30.0, 450 = 45.0 deg

View file

@ -8,13 +8,13 @@
#include "flight_common.h" #include "flight_common.h"
static uint8_t numberMotor = 0; static uint8_t numberMotor = 0;
int16_t motor[MAX_MOTORS]; int16_t motor[MAX_SUPPORTED_MOTORS];
int16_t motor_disarmed[MAX_MOTORS]; int16_t motor_disarmed[MAX_SUPPORTED_MOTORS];
int16_t servo[MAX_SERVOS] = { 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500 }; int16_t servo[MAX_SERVOS] = { 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500 };
static int useServo; static int useServo;
static motorMixer_t currentMixer[MAX_MOTORS]; static motorMixer_t currentMixer[MAX_SUPPORTED_MOTORS];
static const motorMixer_t mixerTri[] = { static const motorMixer_t mixerTri[] = {
{ 1.0f, 0.0f, 1.333333f, 0.0f }, // REAR { 1.0f, 0.0f, 1.333333f, 0.0f }, // REAR
@ -198,7 +198,7 @@ void mixerInit(void)
if (masterConfig.mixerConfiguration == MULTITYPE_CUSTOM) { if (masterConfig.mixerConfiguration == MULTITYPE_CUSTOM) {
// load custom mixer into currentMixer // load custom mixer into currentMixer
for (i = 0; i < MAX_MOTORS; i++) { for (i = 0; i < MAX_SUPPORTED_MOTORS; i++) {
// check if done // check if done
if (masterConfig.customMixer[i].throttle == 0.0f) if (masterConfig.customMixer[i].throttle == 0.0f)
break; break;
@ -239,7 +239,7 @@ void mixerResetMotors(void)
{ {
int i; int i;
// set disarmed motor values // set disarmed motor values
for (i = 0; i < MAX_MOTORS; i++) for (i = 0; i < MAX_SUPPORTED_MOTORS; i++)
motor_disarmed[i] = feature(FEATURE_3D) ? masterConfig.neutral3d : masterConfig.mincommand; motor_disarmed[i] = feature(FEATURE_3D) ? masterConfig.neutral3d : masterConfig.mincommand;
} }
@ -250,7 +250,7 @@ void mixerLoadMix(int index)
// we're 1-based // we're 1-based
index++; index++;
// clear existing // clear existing
for (i = 0; i < MAX_MOTORS; i++) for (i = 0; i < MAX_SUPPORTED_MOTORS; i++)
masterConfig.customMixer[i].throttle = 0.0f; masterConfig.customMixer[i].throttle = 0.0f;
// do we have anything here to begin with? // do we have anything here to begin with?

View file

@ -59,3 +59,9 @@ typedef struct servoParam_t {
bool isMixerUsingServos(void); bool isMixerUsingServos(void);
void mixerInit(void); void mixerInit(void);
void writeAllMotors(int16_t mc); void writeAllMotors(int16_t mc);
void mixerLoadMix(int index);
void mixerResetMotors(void);
// from mixer.c
extern int16_t motor_disarmed[MAX_SUPPORTED_MOTORS];

View file

@ -84,9 +84,9 @@ void annexCode(void)
prop1 = 100 - (uint16_t)currentProfile.controlRateConfig.rollPitchRate * tmp / 500; prop1 = 100 - (uint16_t)currentProfile.controlRateConfig.rollPitchRate * tmp / 500;
prop1 = (uint16_t)prop1 * prop2 / 100; prop1 = (uint16_t)prop1 * prop2 / 100;
} else { // YAW } else { // YAW
if (currentProfile.yawdeadband) { if (currentProfile.yaw_deadband) {
if (tmp > currentProfile.yawdeadband) { if (tmp > currentProfile.yaw_deadband) {
tmp -= currentProfile.yawdeadband; tmp -= currentProfile.yaw_deadband;
} else { } else {
tmp = 0; tmp = 0;
} }

View file

@ -51,10 +51,9 @@ extern int32_t BaroPID;
extern int32_t vario; extern int32_t vario;
extern int16_t throttleAngleCorrection; extern int16_t throttleAngleCorrection;
extern int16_t headFreeModeHold; extern int16_t headFreeModeHold;
extern int16_t motor[MAX_MOTORS]; extern int16_t motor[MAX_SUPPORTED_MOTORS];
extern int16_t servo[MAX_SERVOS]; extern int16_t servo[MAX_SERVOS];
extern uint16_t rssi; // range: [0;1023] extern uint16_t rssi; // range: [0;1023]
extern uint8_t vbat;
extern int16_t telemTemperature1; // gyro sensor temperature extern int16_t telemTemperature1; // gyro sensor temperature
extern uint8_t toggleBeep; extern uint8_t toggleBeep;

View file

@ -18,6 +18,8 @@ typedef enum {
#define MAX_SUPPORTED_RC_PPM_AND_PWM_CHANNEL_COUNT 8 #define MAX_SUPPORTED_RC_PPM_AND_PWM_CHANNEL_COUNT 8
#define MAX_SUPPORTED_RC_CHANNEL_COUNT (18) #define MAX_SUPPORTED_RC_CHANNEL_COUNT (18)
extern const char rcChannelLetters[];
extern int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT]; // interval [1000;2000] extern int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT]; // interval [1000;2000]
typedef struct rxConfig_s { typedef struct rxConfig_s {

View file

@ -1,16 +1,42 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include "board.h" #include "platform.h"
#include "mw.h"
#include "common/axis.h"
#include "common/printf.h" #include "common/printf.h"
#include "common/typeconversion.h"
#include "drivers/system_common.h"
#include "drivers/accgyro_common.h"
#include "drivers/serial_common.h" #include "drivers/serial_common.h"
#include "drivers/bus_i2c.h"
#include "serial_common.h" #include "serial_common.h"
#include "flight_common.h"
#include "flight_mixer.h"
#include "rc_controls.h"
#include "boardalignment.h"
#include "telemetry_common.h" #include "telemetry_common.h"
#include "gps_common.h" #include "gps_common.h"
#include "rx_common.h"
#include "battery.h"
#include "sensors_common.h"
#include "sensors_acceleration.h" #include "sensors_acceleration.h"
#include "sensors_gyro.h"
#include "sensors_barometer.h"
#include "failsafe.h"
#include "runtime_config.h"
#include "config.h"
#include "config_profile.h"
#include "config_master.h"
#include "serial_cli.h"
// we unset this on 'exit' // we unset this on 'exit'
extern uint8_t cliMode; extern uint8_t cliMode;
@ -31,14 +57,7 @@ static void cliSet(char *cmdline);
static void cliStatus(char *cmdline); static void cliStatus(char *cmdline);
static void cliVersion(char *cmdline); static void cliVersion(char *cmdline);
// from sensors.c uint16_t cycleTime; // FIXME dependency on mw.c
extern uint8_t batteryCellCount;
// from config.c RC Channel mapping
extern const char rcChannelLetters[];
// from mixer.c
extern int16_t motor_disarmed[MAX_MOTORS];
// signal that we're in cli mode // signal that we're in cli mode
uint8_t cliMode = 0; uint8_t cliMode = 0;
@ -47,9 +66,6 @@ uint8_t cliMode = 0;
static char cliBuffer[48]; static char cliBuffer[48];
static uint32_t bufferIndex = 0; static uint32_t bufferIndex = 0;
static float _atof(const char *p);
static char *ftoa(float x, char *floatString);
// sync this with MultiType enum from mw.h // sync this with MultiType enum from mw.h
static const char * const mixerNames[] = { static const char * const mixerNames[] = {
"TRI", "QUADP", "QUADX", "BI", "TRI", "QUADP", "QUADX", "BI",
@ -169,7 +185,7 @@ const clivalue_t valueTable[] = {
{ "gyro_cmpfm_factor", VAR_UINT16, &masterConfig.gyro_cmpfm_factor, 100, 1000 }, { "gyro_cmpfm_factor", VAR_UINT16, &masterConfig.gyro_cmpfm_factor, 100, 1000 },
{ "pid_controller", VAR_UINT8, &currentProfile.pidController, 0, 1 }, { "pid_controller", VAR_UINT8, &currentProfile.pidController, 0, 1 },
{ "deadband", VAR_UINT8, &currentProfile.deadband, 0, 32 }, { "deadband", VAR_UINT8, &currentProfile.deadband, 0, 32 },
{ "yawdeadband", VAR_UINT8, &currentProfile.yawdeadband, 0, 100 }, { "yawdeadband", VAR_UINT8, &currentProfile.yaw_deadband, 0, 100 },
{ "alt_hold_throttle_neutral", VAR_UINT8, &currentProfile.alt_hold_throttle_neutral, 1, 250 }, { "alt_hold_throttle_neutral", VAR_UINT8, &currentProfile.alt_hold_throttle_neutral, 1, 250 },
{ "alt_hold_fast_change", VAR_UINT8, &currentProfile.alt_hold_fast_change, 0, 1 }, { "alt_hold_fast_change", VAR_UINT8, &currentProfile.alt_hold_fast_change, 0, 1 },
{ "throttle_correction_value", VAR_UINT8, &currentProfile.throttle_correction_value, 0, 150 }, { "throttle_correction_value", VAR_UINT8, &currentProfile.throttle_correction_value, 0, 150 },
@ -248,184 +264,6 @@ static void cliPrintVar(const clivalue_t *var, uint32_t full);
static void cliPrint(const char *str); static void cliPrint(const char *str);
static void cliWrite(uint8_t ch); static void cliWrite(uint8_t ch);
#ifndef HAVE_ITOA_FUNCTION
/*
** The following two functions together make up an itoa()
** implementation. Function i2a() is a 'private' function
** called by the public itoa() function.
**
** itoa() takes three arguments:
** 1) the integer to be converted,
** 2) a pointer to a character conversion buffer,
** 3) the radix for the conversion
** which can range between 2 and 36 inclusive
** range errors on the radix default it to base10
** Code from http://groups.google.com/group/comp.lang.c/msg/66552ef8b04fe1ab?pli=1
*/
static char *i2a(unsigned i, char *a, unsigned r)
{
if (i / r > 0)
a = i2a(i / r, a, r);
*a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i % r];
return a + 1;
}
char *itoa(int i, char *a, int r)
{
if ((r < 2) || (r > 36))
r = 10;
if (i < 0) {
*a = '-';
*i2a(-(unsigned)i, a + 1, r) = 0;
} else
*i2a(i, a, r) = 0;
return a;
}
#endif
////////////////////////////////////////////////////////////////////////////////
// String to Float Conversion
///////////////////////////////////////////////////////////////////////////////
// Simple and fast atof (ascii to float) function.
//
// - Executes about 5x faster than standard MSCRT library atof().
// - An attractive alternative if the number of calls is in the millions.
// - Assumes input is a proper integer, fraction, or scientific format.
// - Matches library atof() to 15 digits (except at extreme exponents).
// - Follows atof() precedent of essentially no error checking.
//
// 09-May-2009 Tom Van Baak (tvb) www.LeapSecond.com
//
#define white_space(c) ((c) == ' ' || (c) == '\t')
#define valid_digit(c) ((c) >= '0' && (c) <= '9')
static float _atof(const char *p)
{
int frac = 0;
float sign, value, scale;
// Skip leading white space, if any.
while (white_space(*p) ) {
p += 1;
}
// Get sign, if any.
sign = 1.0f;
if (*p == '-') {
sign = -1.0f;
p += 1;
} else if (*p == '+') {
p += 1;
}
// Get digits before decimal point or exponent, if any.
value = 0.0f;
while (valid_digit(*p)) {
value = value * 10.0f + (*p - '0');
p += 1;
}
// Get digits after decimal point, if any.
if (*p == '.') {
float pow10 = 10.0f;
p += 1;
while (valid_digit(*p)) {
value += (*p - '0') / pow10;
pow10 *= 10.0f;
p += 1;
}
}
// Handle exponent, if any.
scale = 1.0f;
if ((*p == 'e') || (*p == 'E')) {
unsigned int expon;
p += 1;
// Get sign of exponent, if any.
frac = 0;
if (*p == '-') {
frac = 1;
p += 1;
} else if (*p == '+') {
p += 1;
}
// Get digits of exponent, if any.
expon = 0;
while (valid_digit(*p)) {
expon = expon * 10 + (*p - '0');
p += 1;
}
if (expon > 308)
expon = 308;
// Calculate scaling factor.
// while (expon >= 50) { scale *= 1E50f; expon -= 50; }
while (expon >= 8) { scale *= 1E8f; expon -= 8; }
while (expon > 0) { scale *= 10.0f; expon -= 1; }
}
// Return signed and scaled floating point result.
return sign * (frac ? (value / scale) : (value * scale));
}
///////////////////////////////////////////////////////////////////////////////
// FTOA
///////////////////////////////////////////////////////////////////////////////
static char *ftoa(float x, char *floatString)
{
int32_t value;
char intString1[12];
char intString2[12] = { 0, };
char *decimalPoint = ".";
uint8_t dpLocation;
if (x > 0) // Rounding for x.xxx display format
x += 0.0005f;
else
x -= 0.0005f;
value = (int32_t) (x * 1000.0f); // Convert float * 1000 to an integer
itoa(abs(value), intString1, 10); // Create string from abs of integer value
if (value >= 0)
intString2[0] = ' '; // Positive number, add a pad space
else
intString2[0] = '-'; // Negative number, add a negative sign
if (strlen(intString1) == 1) {
intString2[1] = '0';
intString2[2] = '0';
intString2[3] = '0';
strcat(intString2, intString1);
} else if (strlen(intString1) == 2) {
intString2[1] = '0';
intString2[2] = '0';
strcat(intString2, intString1);
} else if (strlen(intString1) == 3) {
intString2[1] = '0';
strcat(intString2, intString1);
} else {
strcat(intString2, intString1);
}
dpLocation = strlen(intString2) - 3;
strncpy(floatString, intString2, dpLocation);
floatString[dpLocation] = '\0';
strcat(floatString, decimalPoint);
strcat(floatString, intString2 + dpLocation);
return floatString;
}
static void cliPrompt(void) static void cliPrompt(void)
{ {
cliPrint("\r\n# "); cliPrint("\r\n# ");
@ -474,7 +312,7 @@ static void cliCMix(char *cmdline)
if (len == 0) { if (len == 0) {
cliPrint("Custom mixer: \r\nMotor\tThr\tRoll\tPitch\tYaw\r\n"); cliPrint("Custom mixer: \r\nMotor\tThr\tRoll\tPitch\tYaw\r\n");
for (i = 0; i < MAX_MOTORS; i++) { for (i = 0; i < MAX_SUPPORTED_MOTORS; i++) {
if (masterConfig.customMixer[i].throttle == 0.0f) if (masterConfig.customMixer[i].throttle == 0.0f)
break; break;
num_motors++; num_motors++;
@ -497,7 +335,7 @@ static void cliCMix(char *cmdline)
return; return;
} else if (strncasecmp(cmdline, "reset", 5) == 0) { } else if (strncasecmp(cmdline, "reset", 5) == 0) {
// erase custom mixer // erase custom mixer
for (i = 0; i < MAX_MOTORS; i++) for (i = 0; i < MAX_SUPPORTED_MOTORS; i++)
masterConfig.customMixer[i].throttle = 0.0f; masterConfig.customMixer[i].throttle = 0.0f;
} else if (strncasecmp(cmdline, "load", 4) == 0) { } else if (strncasecmp(cmdline, "load", 4) == 0) {
ptr = strchr(cmdline, ' '); ptr = strchr(cmdline, ' ');
@ -519,25 +357,25 @@ static void cliCMix(char *cmdline)
} else { } else {
ptr = cmdline; ptr = cmdline;
i = atoi(ptr); // get motor number i = atoi(ptr); // get motor number
if (--i < MAX_MOTORS) { if (--i < MAX_SUPPORTED_MOTORS) {
ptr = strchr(ptr, ' '); ptr = strchr(ptr, ' ');
if (ptr) { if (ptr) {
masterConfig.customMixer[i].throttle = _atof(++ptr); masterConfig.customMixer[i].throttle = fastA2F(++ptr);
check++; check++;
} }
ptr = strchr(ptr, ' '); ptr = strchr(ptr, ' ');
if (ptr) { if (ptr) {
masterConfig.customMixer[i].roll = _atof(++ptr); masterConfig.customMixer[i].roll = fastA2F(++ptr);
check++; check++;
} }
ptr = strchr(ptr, ' '); ptr = strchr(ptr, ' ');
if (ptr) { if (ptr) {
masterConfig.customMixer[i].pitch = _atof(++ptr); masterConfig.customMixer[i].pitch = fastA2F(++ptr);
check++; check++;
} }
ptr = strchr(ptr, ' '); ptr = strchr(ptr, ' ');
if (ptr) { if (ptr) {
masterConfig.customMixer[i].yaw = _atof(++ptr); masterConfig.customMixer[i].yaw = fastA2F(++ptr);
check++; check++;
} }
if (check != 4) { if (check != 4) {
@ -546,7 +384,7 @@ static void cliCMix(char *cmdline)
cliCMix(""); cliCMix("");
} }
} else { } else {
printf("Motor number must be between 1 and %d\r\n", MAX_MOTORS); printf("Motor number must be between 1 and %d\r\n", MAX_SUPPORTED_MOTORS);
} }
} }
} }
@ -569,7 +407,7 @@ static void cliDump(char *cmdline)
// print custom mix if exists // print custom mix if exists
if (masterConfig.customMixer[0].throttle != 0.0f) { if (masterConfig.customMixer[0].throttle != 0.0f) {
for (i = 0; i < MAX_MOTORS; i++) { for (i = 0; i < MAX_SUPPORTED_MOTORS; i++) {
if (masterConfig.customMixer[i].throttle == 0.0f) if (masterConfig.customMixer[i].throttle == 0.0f)
break; break;
thr = masterConfig.customMixer[i].throttle; thr = masterConfig.customMixer[i].throttle;
@ -795,8 +633,8 @@ static void cliMotor(char *cmdline)
pch = strtok(NULL, " "); pch = strtok(NULL, " ");
} }
if (motor_index < 0 || motor_index >= MAX_MOTORS) { if (motor_index < 0 || motor_index >= MAX_SUPPORTED_MOTORS) {
printf("No such motor, use a number [0, %d]\r\n", MAX_MOTORS); printf("No such motor, use a number [0, %d]\r\n", MAX_SUPPORTED_MOTORS);
return; return;
} }
@ -952,7 +790,7 @@ static void cliSet(char *cmdline)
eqptr++; eqptr++;
len--; len--;
value = atoi(eqptr); value = atoi(eqptr);
valuef = _atof(eqptr); valuef = fastA2F(eqptr);
for (i = 0; i < VALUE_COUNT; i++) { for (i = 0; i < VALUE_COUNT; i++) {
val = &valueTable[i]; val = &valueTable[i];
if (strncasecmp(cmdline, valueTable[i].name, strlen(valueTable[i].name)) == 0) { if (strncasecmp(cmdline, valueTable[i].name, strlen(valueTable[i].name)) == 0) {

View file

@ -108,7 +108,7 @@ static uint8_t availableBoxes[CHECKBOX_ITEM_COUNT];
// this is the number of filled indexes in above array // this is the number of filled indexes in above array
static uint8_t numberBoxItems = 0; static uint8_t numberBoxItems = 0;
// from mixer.c // from mixer.c
extern int16_t motor_disarmed[MAX_MOTORS]; extern int16_t motor_disarmed[MAX_SUPPORTED_MOTORS];
static const char pidnames[] = static const char pidnames[] =
"ROLL;" "ROLL;"
@ -348,7 +348,7 @@ static void evaluateCommand(void)
headSerialReply(0); headSerialReply(0);
break; break;
case MSP_SET_MOTOR: case MSP_SET_MOTOR:
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++) // FIXME should this use MAX_MOTORS or MAX_SUPPORTED_MOTORS instead of 8
motor_disarmed[i] = read16(); motor_disarmed[i] = read16();
headSerialReply(0); headSerialReply(0);
break; break;