mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
Further use of config macros
This commit is contained in:
parent
83d5e37d77
commit
0e055b460b
6 changed files with 144 additions and 148 deletions
|
@ -101,6 +101,9 @@
|
|||
#define pidConfig(x) (&masterConfig.pidConfig)
|
||||
#define adjustmentProfile(x) (&masterConfig.adjustmentProfile)
|
||||
#define modeActivationProfile(x) (&masterConfig.modeActivationProfile)
|
||||
#define servoProfile(x) (&masterConfig.servoProfile)
|
||||
#define customMotorMixer(i) (&masterConfig.customMotorMixer[i])
|
||||
#define customServoMixer(i) (&masterConfig.customServoMixer[i])
|
||||
|
||||
|
||||
// System-wide
|
||||
|
@ -121,7 +124,7 @@ typedef struct master_s {
|
|||
servoMixerConfig_t servoMixerConfig;
|
||||
servoMixer_t customServoMixer[MAX_SERVO_RULES];
|
||||
// Servo-related stuff
|
||||
servoParam_t servoConf[MAX_SUPPORTED_SERVOS]; // servo configuration
|
||||
servoProfile_t servoProfile;
|
||||
// gimbal-related configuration
|
||||
gimbalConfig_t gimbalConfig;
|
||||
#endif
|
||||
|
|
|
@ -783,13 +783,13 @@ void createDefaultConfig(master_t *config)
|
|||
#ifdef USE_SERVOS
|
||||
// servos
|
||||
for (int i = 0; i < MAX_SUPPORTED_SERVOS; i++) {
|
||||
config->servoConf[i].min = DEFAULT_SERVO_MIN;
|
||||
config->servoConf[i].max = DEFAULT_SERVO_MAX;
|
||||
config->servoConf[i].middle = DEFAULT_SERVO_MIDDLE;
|
||||
config->servoConf[i].rate = 100;
|
||||
config->servoConf[i].angleAtMin = DEFAULT_SERVO_MIN_ANGLE;
|
||||
config->servoConf[i].angleAtMax = DEFAULT_SERVO_MAX_ANGLE;
|
||||
config->servoConf[i].forwardFromChannel = CHANNEL_FORWARDING_DISABLED;
|
||||
config->servoProfile.servoConf[i].min = DEFAULT_SERVO_MIN;
|
||||
config->servoProfile.servoConf[i].max = DEFAULT_SERVO_MAX;
|
||||
config->servoProfile.servoConf[i].middle = DEFAULT_SERVO_MIDDLE;
|
||||
config->servoProfile.servoConf[i].rate = 100;
|
||||
config->servoProfile.servoConf[i].angleAtMin = DEFAULT_SERVO_MIN_ANGLE;
|
||||
config->servoProfile.servoConf[i].angleAtMax = DEFAULT_SERVO_MAX_ANGLE;
|
||||
config->servoProfile.servoConf[i].forwardFromChannel = CHANNEL_FORWARDING_DISABLED;
|
||||
}
|
||||
|
||||
// gimbal
|
||||
|
@ -909,7 +909,7 @@ void activateConfig(void)
|
|||
);
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
servoUseConfigs(&masterConfig.servoMixerConfig, masterConfig.servoConf, &masterConfig.gimbalConfig);
|
||||
servoUseConfigs(&masterConfig.servoMixerConfig, masterConfig.servoProfile.servoConf, &masterConfig.gimbalConfig);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -683,25 +683,25 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
|||
break;
|
||||
case MSP_SERVO_CONFIGURATIONS:
|
||||
for (int i = 0; i < MAX_SUPPORTED_SERVOS; i++) {
|
||||
sbufWriteU16(dst, masterConfig.servoConf[i].min);
|
||||
sbufWriteU16(dst, masterConfig.servoConf[i].max);
|
||||
sbufWriteU16(dst, masterConfig.servoConf[i].middle);
|
||||
sbufWriteU8(dst, masterConfig.servoConf[i].rate);
|
||||
sbufWriteU8(dst, masterConfig.servoConf[i].angleAtMin);
|
||||
sbufWriteU8(dst, masterConfig.servoConf[i].angleAtMax);
|
||||
sbufWriteU8(dst, masterConfig.servoConf[i].forwardFromChannel);
|
||||
sbufWriteU32(dst, masterConfig.servoConf[i].reversedSources);
|
||||
sbufWriteU16(dst, servoProfile()->servoConf[i].min);
|
||||
sbufWriteU16(dst, servoProfile()->servoConf[i].max);
|
||||
sbufWriteU16(dst, servoProfile()->servoConf[i].middle);
|
||||
sbufWriteU8(dst, servoProfile()->servoConf[i].rate);
|
||||
sbufWriteU8(dst, servoProfile()->servoConf[i].angleAtMin);
|
||||
sbufWriteU8(dst, servoProfile()->servoConf[i].angleAtMax);
|
||||
sbufWriteU8(dst, servoProfile()->servoConf[i].forwardFromChannel);
|
||||
sbufWriteU32(dst, servoProfile()->servoConf[i].reversedSources);
|
||||
}
|
||||
break;
|
||||
case MSP_SERVO_MIX_RULES:
|
||||
for (int i = 0; i < MAX_SERVO_RULES; i++) {
|
||||
sbufWriteU8(dst, masterConfig.customServoMixer[i].targetChannel);
|
||||
sbufWriteU8(dst, masterConfig.customServoMixer[i].inputSource);
|
||||
sbufWriteU8(dst, masterConfig.customServoMixer[i].rate);
|
||||
sbufWriteU8(dst, masterConfig.customServoMixer[i].speed);
|
||||
sbufWriteU8(dst, masterConfig.customServoMixer[i].min);
|
||||
sbufWriteU8(dst, masterConfig.customServoMixer[i].max);
|
||||
sbufWriteU8(dst, masterConfig.customServoMixer[i].box);
|
||||
sbufWriteU8(dst, customServoMixer(i)->targetChannel);
|
||||
sbufWriteU8(dst, customServoMixer(i)->inputSource);
|
||||
sbufWriteU8(dst, customServoMixer(i)->rate);
|
||||
sbufWriteU8(dst, customServoMixer(i)->speed);
|
||||
sbufWriteU8(dst, customServoMixer(i)->min);
|
||||
sbufWriteU8(dst, customServoMixer(i)->max);
|
||||
sbufWriteU8(dst, customServoMixer(i)->box);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
@ -1426,14 +1426,14 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
if (i >= MAX_SUPPORTED_SERVOS) {
|
||||
return MSP_RESULT_ERROR;
|
||||
} else {
|
||||
masterConfig.servoConf[i].min = sbufReadU16(src);
|
||||
masterConfig.servoConf[i].max = sbufReadU16(src);
|
||||
masterConfig.servoConf[i].middle = sbufReadU16(src);
|
||||
masterConfig.servoConf[i].rate = sbufReadU8(src);
|
||||
masterConfig.servoConf[i].angleAtMin = sbufReadU8(src);
|
||||
masterConfig.servoConf[i].angleAtMax = sbufReadU8(src);
|
||||
masterConfig.servoConf[i].forwardFromChannel = sbufReadU8(src);
|
||||
masterConfig.servoConf[i].reversedSources = sbufReadU32(src);
|
||||
servoProfile()->servoConf[i].min = sbufReadU16(src);
|
||||
servoProfile()->servoConf[i].max = sbufReadU16(src);
|
||||
servoProfile()->servoConf[i].middle = sbufReadU16(src);
|
||||
servoProfile()->servoConf[i].rate = sbufReadU8(src);
|
||||
servoProfile()->servoConf[i].angleAtMin = sbufReadU8(src);
|
||||
servoProfile()->servoConf[i].angleAtMax = sbufReadU8(src);
|
||||
servoProfile()->servoConf[i].forwardFromChannel = sbufReadU8(src);
|
||||
servoProfile()->servoConf[i].reversedSources = sbufReadU32(src);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
@ -1444,13 +1444,13 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
if (i >= MAX_SERVO_RULES) {
|
||||
return MSP_RESULT_ERROR;
|
||||
} else {
|
||||
masterConfig.customServoMixer[i].targetChannel = sbufReadU8(src);
|
||||
masterConfig.customServoMixer[i].inputSource = sbufReadU8(src);
|
||||
masterConfig.customServoMixer[i].rate = sbufReadU8(src);
|
||||
masterConfig.customServoMixer[i].speed = sbufReadU8(src);
|
||||
masterConfig.customServoMixer[i].min = sbufReadU8(src);
|
||||
masterConfig.customServoMixer[i].max = sbufReadU8(src);
|
||||
masterConfig.customServoMixer[i].box = sbufReadU8(src);
|
||||
customServoMixer(i)->targetChannel = sbufReadU8(src);
|
||||
customServoMixer(i)->inputSource = sbufReadU8(src);
|
||||
customServoMixer(i)->rate = sbufReadU8(src);
|
||||
customServoMixer(i)->speed = sbufReadU8(src);
|
||||
customServoMixer(i)->min = sbufReadU8(src);
|
||||
customServoMixer(i)->max = sbufReadU8(src);
|
||||
customServoMixer(i)->box = sbufReadU8(src);
|
||||
loadCustomServoMixer();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -110,6 +110,10 @@ typedef struct servoMixerConfig_s{
|
|||
int8_t servo_lowpass_enable; // enable/disable lowpass filter
|
||||
} servoMixerConfig_t;
|
||||
|
||||
typedef struct servoProfile_s {
|
||||
servoParam_t servoConf[MAX_SUPPORTED_SERVOS];
|
||||
} servoProfile_t;
|
||||
|
||||
extern int16_t servo[MAX_SUPPORTED_SERVOS];
|
||||
|
||||
void servoTable(void);
|
||||
|
|
|
@ -122,8 +122,8 @@ void cliDfu(char *cmdLine);
|
|||
static void cliDump(char *cmdLine);
|
||||
static void cliDiff(char *cmdLine);
|
||||
static void printConfig(char *cmdLine, bool doDiff);
|
||||
static void cliDumpProfile(uint8_t profileIndex, uint8_t dumpMask, master_t *defaultProfile);
|
||||
static void cliDumpRateProfile(uint8_t rateProfileIndex, uint8_t dumpMask, master_t *defaultProfile) ;
|
||||
static void cliDumpProfile(uint8_t profileIndex, uint8_t dumpMask, const master_t *defaultProfile);
|
||||
static void cliDumpRateProfile(uint8_t rateProfileIndex, uint8_t dumpMask, const master_t *defaultProfile) ;
|
||||
static void cliExit(char *cmdline);
|
||||
static void cliFeature(char *cmdline);
|
||||
static void cliMotor(char *cmdline);
|
||||
|
@ -155,7 +155,7 @@ static void cliTasks(char *cmdline);
|
|||
static void cliVersion(char *cmdline);
|
||||
static void cliRxRange(char *cmdline);
|
||||
#if (FLASH_SIZE > 64)
|
||||
static void printResource(uint8_t dumpMask, master_t *defaultConfig);
|
||||
static void printResource(uint8_t dumpMask, const master_t *defaultConfig);
|
||||
static void cliResource(char *cmdline);
|
||||
#endif
|
||||
#ifdef GPS
|
||||
|
@ -1012,7 +1012,7 @@ typedef union {
|
|||
|
||||
static void cliSetVar(const clivalue_t *var, const int_float_value_t value);
|
||||
static void cliPrintVar(const clivalue_t *var, uint32_t full);
|
||||
static void cliPrintVarDefault(const clivalue_t *var, uint32_t full, master_t *defaultConfig);
|
||||
static void cliPrintVarDefault(const clivalue_t *var, uint32_t full, const master_t *defaultConfig);
|
||||
static void cliPrintVarRange(const clivalue_t *var);
|
||||
static void cliPrint(const char *str);
|
||||
static void cliPrintf(const char *fmt, ...);
|
||||
|
@ -1209,16 +1209,13 @@ static void cliRxFail(char *cmdline)
|
|||
}
|
||||
}
|
||||
|
||||
static void printAux(uint8_t dumpMask, master_t *defaultConfig)
|
||||
static void printAux(uint8_t dumpMask, const modeActivationProfile_t *defaultModeActivationProfile)
|
||||
{
|
||||
// print out aux channel settings
|
||||
modeActivationCondition_t *mac;
|
||||
modeActivationCondition_t *macDefault;
|
||||
bool equalsDefault;
|
||||
for (uint32_t i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
||||
mac = &modeActivationProfile()->modeActivationConditions[i];
|
||||
macDefault = &defaultConfig->modeActivationProfile.modeActivationConditions[i];
|
||||
equalsDefault = mac->modeId == macDefault->modeId
|
||||
const modeActivationCondition_t *mac = &modeActivationProfile()->modeActivationConditions[i];
|
||||
const modeActivationCondition_t *macDefault = &defaultModeActivationProfile->modeActivationConditions[i];
|
||||
const bool equalsDefault = mac->modeId == macDefault->modeId
|
||||
&& mac->auxChannelIndex == macDefault->auxChannelIndex
|
||||
&& mac->range.startStep == macDefault->range.startStep
|
||||
&& mac->range.endStep == macDefault->range.endStep;
|
||||
|
@ -1283,12 +1280,11 @@ static void cliAux(char *cmdline)
|
|||
static void printSerial(uint8_t dumpMask, const serialConfig_t *serialConfigDefault)
|
||||
{
|
||||
const serialConfig_t *serialConfig = serialConfig();
|
||||
bool equalsDefault;
|
||||
for (uint32_t i = 0; i < SERIAL_PORT_COUNT; i++) {
|
||||
if (!serialIsPortAvailable(serialConfig->portConfigs[i].identifier)) {
|
||||
continue;
|
||||
};
|
||||
equalsDefault = serialConfig->portConfigs[i].identifier == serialConfigDefault->portConfigs[i].identifier
|
||||
const bool equalsDefault = serialConfig->portConfigs[i].identifier == serialConfigDefault->portConfigs[i].identifier
|
||||
&& serialConfig->portConfigs[i].functionMask == serialConfigDefault->portConfigs[i].functionMask
|
||||
&& serialConfig->portConfigs[i].msp_baudrateIndex == serialConfigDefault->portConfigs[i].msp_baudrateIndex
|
||||
&& serialConfig->portConfigs[i].gps_baudrateIndex == serialConfigDefault->portConfigs[i].gps_baudrateIndex
|
||||
|
@ -1475,16 +1471,13 @@ static void cliSerialPassthrough(char *cmdline)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void printAdjustmentRange(uint8_t dumpMask, master_t *defaultConfig)
|
||||
static void printAdjustmentRange(uint8_t dumpMask, const adjustmentProfile_t *defaultAdjustmentProfile)
|
||||
{
|
||||
// print out adjustment ranges channel settings
|
||||
adjustmentRange_t *ar;
|
||||
adjustmentRange_t *arDefault;
|
||||
bool equalsDefault;
|
||||
for (uint32_t i = 0; i < MAX_ADJUSTMENT_RANGE_COUNT; i++) {
|
||||
ar = &adjustmentProfile()->adjustmentRanges[i];
|
||||
arDefault = &defaultConfig->adjustmentProfile.adjustmentRanges[i];
|
||||
equalsDefault = ar->auxChannelIndex == arDefault->auxChannelIndex
|
||||
const adjustmentRange_t *ar = &adjustmentProfile()->adjustmentRanges[i];
|
||||
const adjustmentRange_t *arDefault = &defaultAdjustmentProfile->adjustmentRanges[i];
|
||||
const bool equalsDefault = ar->auxChannelIndex == arDefault->auxChannelIndex
|
||||
&& ar->range.startStep == arDefault->range.startStep
|
||||
&& ar->range.endStep == arDefault->range.endStep
|
||||
&& ar->adjustmentFunction == arDefault->adjustmentFunction
|
||||
|
@ -1573,24 +1566,24 @@ static void cliAdjustmentRange(char *cmdline)
|
|||
}
|
||||
|
||||
#ifndef USE_QUAD_MIXER_ONLY
|
||||
static void printMotorMix(uint8_t dumpMask, master_t *defaultConfig)
|
||||
static void printMotorMix(uint8_t dumpMask, const motorMixer_t *defaultCustomMotorMixer)
|
||||
{
|
||||
char buf0[8];
|
||||
char buf1[8];
|
||||
char buf2[8];
|
||||
char buf3[8];
|
||||
for (uint32_t i = 0; i < MAX_SUPPORTED_MOTORS; i++) {
|
||||
if (masterConfig.customMotorMixer[i].throttle == 0.0f)
|
||||
if (customMotorMixer(i)->throttle == 0.0f)
|
||||
break;
|
||||
float thr = masterConfig.customMotorMixer[i].throttle;
|
||||
float roll = masterConfig.customMotorMixer[i].roll;
|
||||
float pitch = masterConfig.customMotorMixer[i].pitch;
|
||||
float yaw = masterConfig.customMotorMixer[i].yaw;
|
||||
float thrDefault = defaultConfig->customMotorMixer[i].throttle;
|
||||
float rollDefault = defaultConfig->customMotorMixer[i].roll;
|
||||
float pitchDefault = defaultConfig->customMotorMixer[i].pitch;
|
||||
float yawDefault = defaultConfig->customMotorMixer[i].yaw;
|
||||
bool equalsDefault = thr == thrDefault && roll == rollDefault && pitch == pitchDefault && yaw == yawDefault;
|
||||
float thr = customMotorMixer(i)->throttle;
|
||||
float roll = customMotorMixer(i)->roll;
|
||||
float pitch = customMotorMixer(i)->pitch;
|
||||
float yaw = customMotorMixer(i)->yaw;
|
||||
float thrDefault = defaultCustomMotorMixer[i].throttle;
|
||||
float rollDefault = defaultCustomMotorMixer[i].roll;
|
||||
float pitchDefault = defaultCustomMotorMixer[i].pitch;
|
||||
float yawDefault = defaultCustomMotorMixer[i].yaw;
|
||||
const bool equalsDefault = thr == thrDefault && roll == rollDefault && pitch == pitchDefault && yaw == yawDefault;
|
||||
|
||||
const char *format = "mmix %d %s %s %s %s\r\n";
|
||||
cliDefaultPrintf(dumpMask, equalsDefault, format,
|
||||
|
@ -1623,7 +1616,7 @@ static void cliMotorMix(char *cmdline)
|
|||
} else if (strncasecmp(cmdline, "reset", 5) == 0) {
|
||||
// erase custom mixer
|
||||
for (uint32_t i = 0; i < MAX_SUPPORTED_MOTORS; i++)
|
||||
masterConfig.customMotorMixer[i].throttle = 0.0f;
|
||||
customMotorMixer(i)->throttle = 0.0f;
|
||||
} else if (strncasecmp(cmdline, "load", 4) == 0) {
|
||||
ptr = nextArg(cmdline);
|
||||
if (ptr) {
|
||||
|
@ -1647,22 +1640,22 @@ static void cliMotorMix(char *cmdline)
|
|||
if (i < MAX_SUPPORTED_MOTORS) {
|
||||
ptr = nextArg(ptr);
|
||||
if (ptr) {
|
||||
masterConfig.customMotorMixer[i].throttle = fastA2F(ptr);
|
||||
customMotorMixer(i)->throttle = fastA2F(ptr);
|
||||
check++;
|
||||
}
|
||||
ptr = nextArg(ptr);
|
||||
if (ptr) {
|
||||
masterConfig.customMotorMixer[i].roll = fastA2F(ptr);
|
||||
customMotorMixer(i)->roll = fastA2F(ptr);
|
||||
check++;
|
||||
}
|
||||
ptr = nextArg(ptr);
|
||||
if (ptr) {
|
||||
masterConfig.customMotorMixer[i].pitch = fastA2F(ptr);
|
||||
customMotorMixer(i)->pitch = fastA2F(ptr);
|
||||
check++;
|
||||
}
|
||||
ptr = nextArg(ptr);
|
||||
if (ptr) {
|
||||
masterConfig.customMotorMixer[i].yaw = fastA2F(ptr);
|
||||
customMotorMixer(i)->yaw = fastA2F(ptr);
|
||||
check++;
|
||||
}
|
||||
if (check != 4) {
|
||||
|
@ -1746,7 +1739,6 @@ static void cliRxRange(char *cmdline)
|
|||
#ifdef LED_STRIP
|
||||
static void printLed(uint8_t dumpMask, const ledStripConfig_t *defaultLedStripConfig)
|
||||
{
|
||||
bool equalsDefault;
|
||||
ledConfig_t ledConfig;
|
||||
ledConfig_t ledConfigDefault;
|
||||
char ledConfigBuffer[20];
|
||||
|
@ -1754,7 +1746,7 @@ static void printLed(uint8_t dumpMask, const ledStripConfig_t *defaultLedStripCo
|
|||
for (uint32_t i = 0; i < LED_MAX_STRIP_LENGTH; i++) {
|
||||
ledConfig = ledStripConfig()->ledConfigs[i];
|
||||
ledConfigDefault = defaultLedStripConfig->ledConfigs[i];
|
||||
equalsDefault = ledConfig == ledConfigDefault;
|
||||
const bool equalsDefault = ledConfig == ledConfigDefault;
|
||||
generateLedConfig(&ledConfig, ledConfigBuffer, sizeof(ledConfigBuffer));
|
||||
generateLedConfig(&ledConfigDefault, ledConfigDefaultBuffer, sizeof(ledConfigDefaultBuffer));
|
||||
const char *format = "led %u %s\r\n";
|
||||
|
@ -1786,13 +1778,10 @@ static void cliLed(char *cmdline)
|
|||
|
||||
static void printColor(uint8_t dumpMask, const ledStripConfig_t *defaultLedStripConfig)
|
||||
{
|
||||
const hsvColor_t *color;
|
||||
const hsvColor_t *colorDefault;
|
||||
bool equalsDefault;
|
||||
for (uint32_t i = 0; i < LED_CONFIGURABLE_COLOR_COUNT; i++) {
|
||||
color = &ledStripConfig()->colors[i];
|
||||
colorDefault = &defaultLedStripConfig->colors[i];
|
||||
equalsDefault = color->h == colorDefault->h
|
||||
const hsvColor_t *color = &ledStripConfig()->colors[i];
|
||||
const hsvColor_t *colorDefault = &defaultLedStripConfig->colors[i];
|
||||
const bool equalsDefault = color->h == colorDefault->h
|
||||
&& color->s == colorDefault->s
|
||||
&& color->v == colorDefault->v;
|
||||
const char *format = "color %u %d,%u,%u\r\n";
|
||||
|
@ -1891,13 +1880,13 @@ static void cliModeColor(char *cmdline)
|
|||
#endif
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
static void printServo(uint8_t dumpMask, master_t *defaultConfig)
|
||||
static void printServo(uint8_t dumpMask, servoProfile_t *defaultServoProfile)
|
||||
{
|
||||
// print out servo settings
|
||||
for (uint32_t i = 0; i < MAX_SUPPORTED_SERVOS; i++) {
|
||||
servoParam_t *servoConf = &masterConfig.servoConf[i];
|
||||
servoParam_t *servoConfDefault = &defaultConfig->servoConf[i];
|
||||
bool equalsDefault = servoConf->min == servoConfDefault->min
|
||||
const servoParam_t *servoConf = &servoProfile()->servoConf[i];
|
||||
const servoParam_t *servoConfDefault = &defaultServoProfile->servoConf[i];
|
||||
const bool equalsDefault = servoConf->min == servoConfDefault->min
|
||||
&& servoConf->max == servoConfDefault->max
|
||||
&& servoConf->middle == servoConfDefault->middle
|
||||
&& servoConf->angleAtMin == servoConfDefault->angleAtMax
|
||||
|
@ -1977,7 +1966,7 @@ static void cliServo(char *cmdline)
|
|||
return;
|
||||
}
|
||||
|
||||
servo = &masterConfig.servoConf[i];
|
||||
servo = &servoProfile()->servoConf[i];
|
||||
|
||||
if (
|
||||
arguments[MIN] < PWM_PULSE_MIN || arguments[MIN] > PWM_PULSE_MAX ||
|
||||
|
@ -2005,16 +1994,16 @@ static void cliServo(char *cmdline)
|
|||
#endif
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
static void printServoMix(uint8_t dumpMask, master_t *defaultConfig)
|
||||
static void printServoMix(uint8_t dumpMask, const master_t *defaultConfig)
|
||||
{
|
||||
for (uint32_t i = 0; i < MAX_SERVO_RULES; i++) {
|
||||
servoMixer_t customServoMixer = masterConfig.customServoMixer[i];
|
||||
servoMixer_t customServoMixer = *customServoMixer(i);
|
||||
servoMixer_t customServoMixerDefault = defaultConfig->customServoMixer[i];
|
||||
if (customServoMixer.rate == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
bool equalsDefault = customServoMixer.targetChannel == customServoMixerDefault.targetChannel
|
||||
const bool equalsDefault = customServoMixer.targetChannel == customServoMixerDefault.targetChannel
|
||||
&& customServoMixer.inputSource == customServoMixerDefault.inputSource
|
||||
&& customServoMixer.rate == customServoMixerDefault.rate
|
||||
&& customServoMixer.speed == customServoMixerDefault.speed
|
||||
|
@ -2049,8 +2038,8 @@ static void printServoMix(uint8_t dumpMask, master_t *defaultConfig)
|
|||
|
||||
// print servo directions
|
||||
for (uint32_t i = 0; i < MAX_SUPPORTED_SERVOS; i++) {
|
||||
servoParam_t *servoConf = &masterConfig.servoConf[i];
|
||||
servoParam_t *servoConfDefault = &defaultConfig->servoConf[i];
|
||||
const servoParam_t *servoConf = &servoProfile()->servoConf[i];
|
||||
const servoParam_t *servoConfDefault = &defaultConfig->servoProfile.servoConf[i];
|
||||
bool equalsDefault = servoConf->reversedSources == servoConfDefault->reversedSources;
|
||||
for (uint32_t channel = 0; channel < INPUT_SOURCE_COUNT; channel++) {
|
||||
equalsDefault = ~(servoConf->reversedSources ^ servoConfDefault->reversedSources) & (1 << channel);
|
||||
|
@ -2078,7 +2067,7 @@ static void cliServoMix(char *cmdline)
|
|||
// erase custom mixer
|
||||
memset(masterConfig.customServoMixer, 0, sizeof(masterConfig.customServoMixer));
|
||||
for (uint32_t i = 0; i < MAX_SUPPORTED_SERVOS; i++) {
|
||||
masterConfig.servoConf[i].reversedSources = 0;
|
||||
servoProfile()->servoConf[i].reversedSources = 0;
|
||||
}
|
||||
} else if (strncasecmp(cmdline, "load", 4) == 0) {
|
||||
ptr = nextArg(cmdline);
|
||||
|
@ -2111,7 +2100,7 @@ static void cliServoMix(char *cmdline)
|
|||
for (uint32_t servoIndex = 0; servoIndex < MAX_SUPPORTED_SERVOS; servoIndex++) {
|
||||
cliPrintf("%d", servoIndex);
|
||||
for (uint32_t inputSource = 0; inputSource < INPUT_SOURCE_COUNT; inputSource++)
|
||||
cliPrintf("\t%s ", (masterConfig.servoConf[servoIndex].reversedSources & (1 << inputSource)) ? "r" : "n");
|
||||
cliPrintf("\t%s ", (servoProfile()->servoConf[servoIndex].reversedSources & (1 << inputSource)) ? "r" : "n");
|
||||
cliPrintf("\r\n");
|
||||
}
|
||||
return;
|
||||
|
@ -2132,9 +2121,9 @@ static void cliServoMix(char *cmdline)
|
|||
&& args[INPUT] >= 0 && args[INPUT] < INPUT_SOURCE_COUNT
|
||||
&& (*ptr == 'r' || *ptr == 'n')) {
|
||||
if (*ptr == 'r')
|
||||
masterConfig.servoConf[args[SERVO]].reversedSources |= 1 << args[INPUT];
|
||||
servoProfile()->servoConf[args[SERVO]].reversedSources |= 1 << args[INPUT];
|
||||
else
|
||||
masterConfig.servoConf[args[SERVO]].reversedSources &= ~(1 << args[INPUT]);
|
||||
servoProfile()->servoConf[args[SERVO]].reversedSources &= ~(1 << args[INPUT]);
|
||||
} else
|
||||
cliShowParseError();
|
||||
|
||||
|
@ -2161,13 +2150,13 @@ static void cliServoMix(char *cmdline)
|
|||
args[MIN] >= 0 && args[MIN] <= 100 &&
|
||||
args[MAX] >= 0 && args[MAX] <= 100 && args[MIN] < args[MAX] &&
|
||||
args[BOX] >= 0 && args[BOX] <= MAX_SERVO_BOXES) {
|
||||
masterConfig.customServoMixer[i].targetChannel = args[TARGET];
|
||||
masterConfig.customServoMixer[i].inputSource = args[INPUT];
|
||||
masterConfig.customServoMixer[i].rate = args[RATE];
|
||||
masterConfig.customServoMixer[i].speed = args[SPEED];
|
||||
masterConfig.customServoMixer[i].min = args[MIN];
|
||||
masterConfig.customServoMixer[i].max = args[MAX];
|
||||
masterConfig.customServoMixer[i].box = args[BOX];
|
||||
customServoMixer(i)->targetChannel = args[TARGET];
|
||||
customServoMixer(i)->inputSource = args[INPUT];
|
||||
customServoMixer(i)->rate = args[RATE];
|
||||
customServoMixer(i)->speed = args[SPEED];
|
||||
customServoMixer(i)->min = args[MIN];
|
||||
customServoMixer(i)->max = args[MAX];
|
||||
customServoMixer(i)->box = args[BOX];
|
||||
cliServoMix("");
|
||||
} else {
|
||||
cliShowParseError();
|
||||
|
@ -2347,7 +2336,7 @@ static void cliFlashRead(char *cmdline)
|
|||
#endif
|
||||
|
||||
#ifdef VTX
|
||||
static void printVtx(uint8_t dumpMask, master_t *defaultConfig)
|
||||
static void printVtx(uint8_t dumpMask, const master_t *defaultConfig)
|
||||
{
|
||||
// print out vtx channel settings
|
||||
vtxChannelActivationCondition_t *cac;
|
||||
|
@ -2448,7 +2437,7 @@ static void cliName(char *cmdline)
|
|||
printName(DUMP_MASTER);
|
||||
}
|
||||
|
||||
static void printFeature(uint8_t dumpMask, master_t *defaultConfig)
|
||||
static void printFeature(uint8_t dumpMask, const master_t *defaultConfig)
|
||||
{
|
||||
uint32_t mask = featureMask();
|
||||
uint32_t defaultMask = defaultConfig->enabledFeatures;
|
||||
|
@ -2540,7 +2529,7 @@ static void cliFeature(char *cmdline)
|
|||
}
|
||||
|
||||
#ifdef BEEPER
|
||||
static void printBeeper(uint8_t dumpMask, master_t *defaultConfig)
|
||||
static void printBeeper(uint8_t dumpMask, const master_t *defaultConfig)
|
||||
{
|
||||
uint8_t beeperCount = beeperTableEntryCount();
|
||||
uint32_t mask = getBeeperOffMask();
|
||||
|
@ -2683,12 +2672,12 @@ void *getValuePointer(const clivalue_t *value)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
static void *getDefaultPointer(void *valuePointer, master_t *defaultConfig)
|
||||
static void *getDefaultPointer(void *valuePointer, const master_t *defaultConfig)
|
||||
{
|
||||
return ((uint8_t *)valuePointer) - (uint32_t)&masterConfig + (uint32_t)defaultConfig;
|
||||
}
|
||||
|
||||
static bool valueEqualsDefault(const clivalue_t *value, master_t *defaultConfig)
|
||||
static bool valueEqualsDefault(const clivalue_t *value, const master_t *defaultConfig)
|
||||
{
|
||||
void *ptr = getValuePointer(value);
|
||||
|
||||
|
@ -2723,7 +2712,7 @@ static bool valueEqualsDefault(const clivalue_t *value, master_t *defaultConfig)
|
|||
return result;
|
||||
}
|
||||
|
||||
static void dumpValues(uint16_t valueSection, uint8_t dumpMask, master_t *defaultConfig)
|
||||
static void dumpValues(uint16_t valueSection, uint8_t dumpMask, const master_t *defaultConfig)
|
||||
{
|
||||
const clivalue_t *value;
|
||||
for (uint32_t i = 0; i < VALUE_COUNT; i++) {
|
||||
|
@ -2823,13 +2812,13 @@ static void printConfig(char *cmdline, bool doDiff)
|
|||
|
||||
cliDumpPrintf(dumpMask, masterConfig.customMotorMixer[0].throttle == 0.0f, "\r\nmmix reset\r\n\r\n");
|
||||
|
||||
printMotorMix(dumpMask, &defaultConfig);
|
||||
printMotorMix(dumpMask, defaultConfig.customMotorMixer);
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
#ifndef CLI_MINIMAL_VERBOSITY
|
||||
cliPrint("\r\n# servo\r\n");
|
||||
#endif
|
||||
printServo(dumpMask, &defaultConfig);
|
||||
printServo(dumpMask, &defaultConfig.servoProfile);
|
||||
|
||||
#ifndef CLI_MINIMAL_VERBOSITY
|
||||
cliPrint("\r\n# servo mix\r\n");
|
||||
|
@ -2882,12 +2871,12 @@ static void printConfig(char *cmdline, bool doDiff)
|
|||
#ifndef CLI_MINIMAL_VERBOSITY
|
||||
cliPrint("\r\n# aux\r\n");
|
||||
#endif
|
||||
printAux(dumpMask, &defaultConfig);
|
||||
printAux(dumpMask, &defaultConfig.modeActivationProfile);
|
||||
|
||||
#ifndef CLI_MINIMAL_VERBOSITY
|
||||
cliPrint("\r\n# adjrange\r\n");
|
||||
#endif
|
||||
printAdjustmentRange(dumpMask, &defaultConfig);
|
||||
printAdjustmentRange(dumpMask, &defaultConfig.adjustmentProfile);
|
||||
|
||||
#ifndef CLI_MINIMAL_VERBOSITY
|
||||
cliPrint("\r\n# rxrange\r\n");
|
||||
|
@ -2950,7 +2939,7 @@ static void printConfig(char *cmdline, bool doDiff)
|
|||
}
|
||||
}
|
||||
|
||||
static void cliDumpProfile(uint8_t profileIndex, uint8_t dumpMask, master_t *defaultConfig)
|
||||
static void cliDumpProfile(uint8_t profileIndex, uint8_t dumpMask, const master_t *defaultConfig)
|
||||
{
|
||||
if (profileIndex >= MAX_PROFILE_COUNT) {
|
||||
// Faulty values
|
||||
|
@ -2966,7 +2955,7 @@ static void cliDumpProfile(uint8_t profileIndex, uint8_t dumpMask, master_t *def
|
|||
cliRateProfile("");
|
||||
}
|
||||
|
||||
static void cliDumpRateProfile(uint8_t rateProfileIndex, uint8_t dumpMask, master_t *defaultConfig)
|
||||
static void cliDumpRateProfile(uint8_t rateProfileIndex, uint8_t dumpMask, const master_t *defaultConfig)
|
||||
{
|
||||
if (rateProfileIndex >= MAX_RATEPROFILES) {
|
||||
// Faulty values
|
||||
|
@ -3404,7 +3393,7 @@ static void cliPrintVar(const clivalue_t *var, uint32_t full)
|
|||
printValuePointer(var, ptr, full);
|
||||
}
|
||||
|
||||
static void cliPrintVarDefault(const clivalue_t *var, uint32_t full, master_t *defaultConfig)
|
||||
static void cliPrintVarDefault(const clivalue_t *var, uint32_t full, const master_t *defaultConfig)
|
||||
{
|
||||
void *ptr = getValuePointer(var);
|
||||
|
||||
|
@ -3843,7 +3832,7 @@ const cliResourceValue_t resourceTable[] = {
|
|||
#endif
|
||||
};
|
||||
|
||||
static void printResource(uint8_t dumpMask, master_t *defaultConfig)
|
||||
static void printResource(uint8_t dumpMask, const master_t *defaultConfig)
|
||||
{
|
||||
for (unsigned int i = 0; i < ARRAYLEN(resourceTable); i++) {
|
||||
const char* owner;
|
||||
|
|
|
@ -627,25 +627,25 @@ static bool bstSlaveProcessFeedbackCommand(uint8_t bstRequest)
|
|||
break;
|
||||
case BST_SERVO_CONFIGURATIONS:
|
||||
for (i = 0; i < MAX_SUPPORTED_SERVOS; i++) {
|
||||
bstWrite16(masterConfig.servoConf[i].min);
|
||||
bstWrite16(masterConfig.servoConf[i].max);
|
||||
bstWrite16(masterConfig.servoConf[i].middle);
|
||||
bstWrite8(masterConfig.servoConf[i].rate);
|
||||
bstWrite8(masterConfig.servoConf[i].angleAtMin);
|
||||
bstWrite8(masterConfig.servoConf[i].angleAtMax);
|
||||
bstWrite8(masterConfig.servoConf[i].forwardFromChannel);
|
||||
bstWrite32(masterConfig.servoConf[i].reversedSources);
|
||||
bstWrite16(servoProfile()->servoConf[i].min);
|
||||
bstWrite16(servoProfile()->servoConf[i].max);
|
||||
bstWrite16(servoProfile()->servoConf[i].middle);
|
||||
bstWrite8(servoProfile()->servoConf[i].rate);
|
||||
bstWrite8(servoProfile()->servoConf[i].angleAtMin);
|
||||
bstWrite8(servoProfile()->servoConf[i].angleAtMax);
|
||||
bstWrite8(servoProfile()->servoConf[i].forwardFromChannel);
|
||||
bstWrite32(servoProfile()->servoConf[i].reversedSources);
|
||||
}
|
||||
break;
|
||||
case BST_SERVO_MIX_RULES:
|
||||
for (i = 0; i < MAX_SERVO_RULES; i++) {
|
||||
bstWrite8(masterConfig.customServoMixer[i].targetChannel);
|
||||
bstWrite8(masterConfig.customServoMixer[i].inputSource);
|
||||
bstWrite8(masterConfig.customServoMixer[i].rate);
|
||||
bstWrite8(masterConfig.customServoMixer[i].speed);
|
||||
bstWrite8(masterConfig.customServoMixer[i].min);
|
||||
bstWrite8(masterConfig.customServoMixer[i].max);
|
||||
bstWrite8(masterConfig.customServoMixer[i].box);
|
||||
bstWrite8(customServoMixer(i)->targetChannel);
|
||||
bstWrite8(customServoMixer(i)->inputSource);
|
||||
bstWrite8(customServoMixer(i)->rate);
|
||||
bstWrite8(customServoMixer(i)->speed);
|
||||
bstWrite8(customServoMixer(i)->min);
|
||||
bstWrite8(customServoMixer(i)->max);
|
||||
bstWrite8(customServoMixer(i)->box);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
@ -1157,14 +1157,14 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
|
|||
if (i >= MAX_SUPPORTED_SERVOS) {
|
||||
ret = BST_FAILED;
|
||||
} else {
|
||||
masterConfig.servoConf[i].min = bstRead16();
|
||||
masterConfig.servoConf[i].max = bstRead16();
|
||||
masterConfig.servoConf[i].middle = bstRead16();
|
||||
masterConfig.servoConf[i].rate = bstRead8();
|
||||
masterConfig.servoConf[i].angleAtMin = bstRead8();
|
||||
masterConfig.servoConf[i].angleAtMax = bstRead8();
|
||||
masterConfig.servoConf[i].forwardFromChannel = bstRead8();
|
||||
masterConfig.servoConf[i].reversedSources = bstRead32();
|
||||
servoProfile()->servoConf[i].min = bstRead16();
|
||||
servoProfile()->servoConf[i].max = bstRead16();
|
||||
servoProfile()->servoConf[i].middle = bstRead16();
|
||||
servoProfile()->servoConf[i].rate = bstRead8();
|
||||
servoProfile()->servoConf[i].angleAtMin = bstRead8();
|
||||
servoProfile()->servoConf[i].angleAtMax = bstRead8();
|
||||
servoProfile()->servoConf[i].forwardFromChannel = bstRead8();
|
||||
servoProfile()->servoConf[i].reversedSources = bstRead32();
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
@ -1174,13 +1174,13 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
|
|||
if (i >= MAX_SERVO_RULES) {
|
||||
ret = BST_FAILED;
|
||||
} else {
|
||||
masterConfig.customServoMixer[i].targetChannel = bstRead8();
|
||||
masterConfig.customServoMixer[i].inputSource = bstRead8();
|
||||
masterConfig.customServoMixer[i].rate = bstRead8();
|
||||
masterConfig.customServoMixer[i].speed = bstRead8();
|
||||
masterConfig.customServoMixer[i].min = bstRead8();
|
||||
masterConfig.customServoMixer[i].max = bstRead8();
|
||||
masterConfig.customServoMixer[i].box = bstRead8();
|
||||
customServoMixer(i)->targetChannel = bstRead8();
|
||||
customServoMixer(i)->inputSource = bstRead8();
|
||||
customServoMixer(i)->rate = bstRead8();
|
||||
customServoMixer(i)->speed = bstRead8();
|
||||
customServoMixer(i)->min = bstRead8();
|
||||
customServoMixer(i)->max = bstRead8();
|
||||
customServoMixer(i)->box = bstRead8();
|
||||
loadCustomServoMixer();
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue