Preparation for conversion to parameter groups 12
This commit is contained in:
parent
14a7c805c1
commit
2c667376fa
|
@ -194,7 +194,7 @@ void pwmCompleteMotorUpdate(uint8_t motorCount)
|
|||
pwmCompleteWritePtr(motorCount);
|
||||
}
|
||||
|
||||
void motorInit(const motorDevConfig_t *motorConfig, uint16_t idlePulse, uint8_t motorCount)
|
||||
void motorDevInit(const motorDevConfig_t *motorConfig, uint16_t idlePulse, uint8_t motorCount)
|
||||
{
|
||||
memset(motors, 0, sizeof(motors));
|
||||
|
||||
|
@ -325,7 +325,7 @@ void pwmWriteServo(uint8_t index, uint16_t value)
|
|||
}
|
||||
}
|
||||
|
||||
void servoInit(const servoDevConfig_t *servoConfig)
|
||||
void servoDevInit(const servoDevConfig_t *servoConfig)
|
||||
{
|
||||
for (uint8_t servoIndex = 0; servoIndex < MAX_SUPPORTED_SERVOS; servoIndex++) {
|
||||
const ioTag_t tag = servoConfig->ioTags[servoIndex];
|
||||
|
|
|
@ -126,7 +126,7 @@ typedef struct motorDevConfig_s {
|
|||
ioTag_t ioTags[MAX_SUPPORTED_MOTORS];
|
||||
} motorDevConfig_t;
|
||||
|
||||
void motorInit(const motorDevConfig_t *motorDevConfig, uint16_t idlePulse, uint8_t motorCount);
|
||||
void motorDevInit(const motorDevConfig_t *motorDevConfig, uint16_t idlePulse, uint8_t motorCount);
|
||||
|
||||
typedef struct servoDevConfig_s {
|
||||
// PWM values, in milliseconds, common range is 1000-2000 (1ms to 2ms)
|
||||
|
@ -135,7 +135,7 @@ typedef struct servoDevConfig_s {
|
|||
ioTag_t ioTags[MAX_SUPPORTED_SERVOS];
|
||||
} servoDevConfig_t;
|
||||
|
||||
void servoInit(const servoDevConfig_t *servoDevConfig);
|
||||
void servoDevInit(const servoDevConfig_t *servoDevConfig);
|
||||
|
||||
void pwmServoConfig(const struct timerHardware_s *timerHardware, uint8_t servoIndex, uint16_t servoPwmRate, uint16_t servoCenterPulse);
|
||||
|
||||
|
|
|
@ -52,13 +52,11 @@ uint8_t cliMode = 0;
|
|||
#include "config/parameter_group.h"
|
||||
#include "config/parameter_group_ids.h"
|
||||
|
||||
#include "config/parameter_group.h"
|
||||
#include "config/parameter_group_ids.h"
|
||||
|
||||
#include "drivers/accgyro.h"
|
||||
#include "drivers/buf_writer.h"
|
||||
#include "drivers/bus_i2c.h"
|
||||
#include "drivers/compass.h"
|
||||
#include "drivers/display.h"
|
||||
#include "drivers/dma.h"
|
||||
#include "drivers/flash.h"
|
||||
#include "drivers/io.h"
|
||||
|
@ -72,12 +70,12 @@ uint8_t cliMode = 0;
|
|||
#include "drivers/system.h"
|
||||
#include "drivers/timer.h"
|
||||
#include "drivers/vcd.h"
|
||||
#include "drivers/display.h"
|
||||
|
||||
#include "fc/cli.h"
|
||||
#include "fc/config.h"
|
||||
#include "fc/rc_adjustments.h"
|
||||
#include "fc/rc_controls.h"
|
||||
#include "fc/runtime_config.h"
|
||||
#include "fc/cli.h"
|
||||
|
||||
#include "flight/failsafe.h"
|
||||
#include "flight/imu.h"
|
||||
|
@ -92,10 +90,8 @@ uint8_t cliMode = 0;
|
|||
#include "io/gimbal.h"
|
||||
#include "io/gps.h"
|
||||
#include "io/ledstrip.h"
|
||||
#include "io/motors.h"
|
||||
#include "io/osd.h"
|
||||
#include "io/serial.h"
|
||||
#include "io/servos.h"
|
||||
#include "io/vtx.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
|
@ -397,6 +393,7 @@ typedef enum {
|
|||
#ifdef OSD
|
||||
TABLE_OSD,
|
||||
#endif
|
||||
LOOKUP_TABLE_COUNT
|
||||
} lookupTableIndex_e;
|
||||
|
||||
static const lookupTableEntry_t lookupTables[] = {
|
||||
|
@ -887,7 +884,6 @@ static beeperDevConfig_t beeperDevConfigCopy;
|
|||
#endif
|
||||
static controlRateConfig_t controlRateProfilesCopy[MAX_CONTROL_RATE_PROFILE_COUNT];
|
||||
static pidProfile_t pidProfileCopy[MAX_PROFILE_COUNT];
|
||||
static modeActivationOperatorConfig_t modeActivationOperatorConfigCopy;
|
||||
#endif // USE_PARAMETER_GROUPS
|
||||
|
||||
static void cliPrint(const char *str)
|
||||
|
@ -968,7 +964,7 @@ static void cliPrintf(const char *format, ...)
|
|||
bufWriterFlush(cliWriter);
|
||||
}
|
||||
|
||||
static void printValuePointer(const clivalue_t *var, void *valuePointer, uint32_t full)
|
||||
static void printValuePointer(const clivalue_t *var, const void *valuePointer, uint32_t full)
|
||||
{
|
||||
int32_t value = 0;
|
||||
char buf[8];
|
||||
|
@ -1189,10 +1185,6 @@ static const cliCurrentAndDefaultConfig_t *getCurrentAndDefaultConfigs(pgn_t pgn
|
|||
ret.currentConfig = &systemConfigCopy;
|
||||
ret.defaultConfig = systemConfig();
|
||||
break;
|
||||
case PG_MODE_ACTIVATION_OPERATOR_CONFIG:
|
||||
ret.currentConfig = &modeActivationOperatorConfigCopy;
|
||||
ret.defaultConfig = modeActivationOperatorConfig();
|
||||
break;
|
||||
case PG_CONTROL_RATE_PROFILES:
|
||||
ret.currentConfig = &controlRateProfilesCopy[0];
|
||||
ret.defaultConfig = controlRateProfiles(0);
|
||||
|
@ -1366,7 +1358,7 @@ static bool valueEqualsDefault(const clivalue_t *value, const master_t *defaultC
|
|||
|
||||
static void cliPrintVar(const clivalue_t *var, uint32_t full)
|
||||
{
|
||||
void *ptr = getValuePointer(var);
|
||||
const void *ptr = getValuePointer(var);
|
||||
|
||||
printValuePointer(var, ptr, full);
|
||||
}
|
||||
|
@ -1574,9 +1566,9 @@ static void cliRxFailsafe(char *cmdline)
|
|||
|
||||
ptr = nextArg(ptr);
|
||||
if (ptr) {
|
||||
char *p = strchr(rxFailsafeModeCharacters, *(ptr));
|
||||
const char *p = strchr(rxFailsafeModeCharacters, *(ptr));
|
||||
if (p) {
|
||||
uint8_t requestedMode = p - rxFailsafeModeCharacters;
|
||||
const uint8_t requestedMode = p - rxFailsafeModeCharacters;
|
||||
mode = rxFailsafeModesTable[type][requestedMode];
|
||||
} else {
|
||||
mode = RX_FAILSAFE_MODE_INVALID;
|
||||
|
@ -1607,7 +1599,6 @@ static void cliRxFailsafe(char *cmdline)
|
|||
return;
|
||||
}
|
||||
channelFailsafeConfig->mode = mode;
|
||||
|
||||
}
|
||||
|
||||
char modeCharacter = rxFailsafeModeCharacters[channelFailsafeConfig->mode];
|
||||
|
@ -2226,14 +2217,11 @@ static void printColor(uint8_t dumpMask, const hsvColor_t *colors, const hsvColo
|
|||
|
||||
static void cliColor(char *cmdline)
|
||||
{
|
||||
int i;
|
||||
const char *ptr;
|
||||
|
||||
if (isEmpty(cmdline)) {
|
||||
printColor(DUMP_MASTER, ledStripConfig()->colors, NULL);
|
||||
} else {
|
||||
ptr = cmdline;
|
||||
i = atoi(ptr);
|
||||
const char *ptr = cmdline;
|
||||
const int i = atoi(ptr);
|
||||
if (i < LED_CONFIGURABLE_COLOR_COUNT) {
|
||||
ptr = nextArg(cmdline);
|
||||
if (!parseColor(i, ptr)) {
|
||||
|
@ -2626,7 +2614,8 @@ static void cliWriteBytes(const uint8_t *buffer, int count)
|
|||
}
|
||||
}
|
||||
|
||||
static void cliSdInfo(char *cmdline) {
|
||||
static void cliSdInfo(char *cmdline)
|
||||
{
|
||||
UNUSED(cmdline);
|
||||
|
||||
cliPrint("SD card: ");
|
||||
|
@ -2704,7 +2693,7 @@ static void cliFlashErase(char *cmdline)
|
|||
UNUSED(cmdline);
|
||||
|
||||
#ifndef MINIMAL_CLI
|
||||
uint32_t i;
|
||||
uint32_t i = 0;
|
||||
cliPrintf("Erasing, please wait ... \r\n");
|
||||
#else
|
||||
cliPrintf("Erasing,\r\n");
|
||||
|
@ -2733,8 +2722,8 @@ static void cliFlashErase(char *cmdline)
|
|||
|
||||
static void cliFlashWrite(char *cmdline)
|
||||
{
|
||||
uint32_t address = atoi(cmdline);
|
||||
char *text = strchr(cmdline, ' ');
|
||||
const uint32_t address = atoi(cmdline);
|
||||
const char *text = strchr(cmdline, ' ');
|
||||
|
||||
if (!text) {
|
||||
cliShowParseError();
|
||||
|
@ -2750,7 +2739,6 @@ static void cliFlashWrite(char *cmdline)
|
|||
static void cliFlashRead(char *cmdline)
|
||||
{
|
||||
uint32_t address = atoi(cmdline);
|
||||
uint32_t length;
|
||||
|
||||
uint8_t buffer[32];
|
||||
|
||||
|
@ -2759,7 +2747,7 @@ static void cliFlashRead(char *cmdline)
|
|||
if (!nextArg) {
|
||||
cliShowParseError();
|
||||
} else {
|
||||
length = atoi(nextArg);
|
||||
uint32_t length = atoi(nextArg);
|
||||
|
||||
cliPrintf("Reading %u bytes at %u:\r\n", length, address);
|
||||
|
||||
|
@ -2981,9 +2969,9 @@ static void cliFeature(char *cmdline)
|
|||
#ifdef BEEPER
|
||||
static void printBeeper(uint8_t dumpMask, const master_t *defaultConfig)
|
||||
{
|
||||
uint8_t beeperCount = beeperTableEntryCount();
|
||||
uint32_t mask = getBeeperOffMask();
|
||||
uint32_t defaultMask = defaultConfig->beeper_off_flags;
|
||||
const uint8_t beeperCount = beeperTableEntryCount();
|
||||
const uint32_t mask = getBeeperOffMask();
|
||||
const uint32_t defaultMask = defaultConfig->beeper_off_flags;
|
||||
for (int32_t i = 0; i < beeperCount - 2; i++) {
|
||||
const char *formatOff = "beeper -%s\r\n";
|
||||
const char *formatOn = "beeper %s\r\n";
|
||||
|
@ -3352,13 +3340,11 @@ static void cliPlaySound(char *cmdline)
|
|||
|
||||
static void cliProfile(char *cmdline)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (isEmpty(cmdline)) {
|
||||
cliPrintf("profile %d\r\n", getCurrentProfile());
|
||||
return;
|
||||
} else {
|
||||
i = atoi(cmdline);
|
||||
const int i = atoi(cmdline);
|
||||
if (i >= 0 && i < MAX_PROFILE_COUNT) {
|
||||
masterConfig.current_profile_index = i;
|
||||
writeEEPROM();
|
||||
|
@ -3370,13 +3356,11 @@ static void cliProfile(char *cmdline)
|
|||
|
||||
static void cliRateProfile(char *cmdline)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (isEmpty(cmdline)) {
|
||||
cliPrintf("rateprofile %d\r\n", getCurrentControlRateProfile());
|
||||
return;
|
||||
} else {
|
||||
i = atoi(cmdline);
|
||||
const int i = atoi(cmdline);
|
||||
if (i >= 0 && i < MAX_RATEPROFILES) {
|
||||
changeControlRateProfile(i);
|
||||
cliRateProfile("");
|
||||
|
@ -4389,5 +4373,6 @@ void cliEnter(serialPort_t *serialPort)
|
|||
void cliInit(const serialConfig_t *serialConfig)
|
||||
{
|
||||
UNUSED(serialConfig);
|
||||
BUILD_BUG_ON(LOOKUP_TABLE_COUNT != ARRAYLEN(lookupTables));
|
||||
}
|
||||
#endif // USE_CLI
|
||||
|
|
|
@ -272,9 +272,9 @@ void init(void)
|
|||
serialInit(feature(FEATURE_SOFTSERIAL), SERIAL_PORT_NONE);
|
||||
#endif
|
||||
|
||||
mixerInit(mixerConfig()->mixerMode, customMotorMixerMutable(0));
|
||||
mixerInit(mixerConfig()->mixerMode);
|
||||
#ifdef USE_SERVOS
|
||||
servoMixerInit(customServoMixers(0));
|
||||
servosInit();
|
||||
#endif
|
||||
|
||||
uint16_t idlePulse = motorConfig()->mincommand;
|
||||
|
@ -288,13 +288,13 @@ void init(void)
|
|||
}
|
||||
|
||||
mixerConfigureOutput();
|
||||
motorInit(&motorConfig()->dev, idlePulse, getMotorCount());
|
||||
motorDevInit(&motorConfig()->dev, idlePulse, getMotorCount());
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
servoConfigureOutput();
|
||||
if (isMixerUsingServos()) {
|
||||
//pwm_params.useChannelForwarding = feature(FEATURE_CHANNEL_FORWARDING);
|
||||
servoInit(&servoConfig()->dev);
|
||||
servoDevInit(&servoConfig()->dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -230,8 +230,6 @@ const mixer_t mixers[] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
static const motorMixer_t *customMixers;
|
||||
|
||||
static uint16_t disarmMotorOutput, deadbandMotor3dHigh, deadbandMotor3dLow;
|
||||
uint16_t motorOutputHigh, motorOutputLow;
|
||||
static float rcCommandThrottleRange, rcCommandThrottleRange3dLow, rcCommandThrottleRange3dHigh;
|
||||
|
@ -289,12 +287,10 @@ void initEscEndpoints(void) {
|
|||
rcCommandThrottleRange3dHigh = PWM_RANGE_MAX - rxConfig()->midrc - flight3DConfig()->deadband3d_throttle;
|
||||
}
|
||||
|
||||
void mixerInit(mixerMode_e mixerMode, const motorMixer_t *initialCustomMixers)
|
||||
void mixerInit(mixerMode_e mixerMode)
|
||||
{
|
||||
currentMixerMode = mixerMode;
|
||||
|
||||
customMixers = initialCustomMixers;
|
||||
|
||||
initEscEndpoints();
|
||||
}
|
||||
|
||||
|
@ -308,9 +304,9 @@ void mixerConfigureOutput(void)
|
|||
// load custom mixer into currentMixer
|
||||
for (int i = 0; i < MAX_SUPPORTED_MOTORS; i++) {
|
||||
// check if done
|
||||
if (customMixers[i].throttle == 0.0f)
|
||||
if (customMotorMixer(i)->throttle == 0.0f)
|
||||
break;
|
||||
currentMixer[i] = customMixers[i];
|
||||
currentMixer[i] = *customMotorMixer(i);
|
||||
motorCount++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -124,7 +124,7 @@ uint8_t getMotorCount();
|
|||
float getMotorMixRange();
|
||||
|
||||
void mixerLoadMix(int index, motorMixer_t *customMixers);
|
||||
void mixerInit(mixerMode_e mixerMode, const motorMixer_t *customMotorMixers);
|
||||
void mixerInit(mixerMode_e mixerMode);
|
||||
|
||||
void mixerConfigureOutput(void);
|
||||
|
||||
|
|
|
@ -147,8 +147,6 @@ const mixerRules_t servoMixers[] = {
|
|||
{ 0, NULL },
|
||||
};
|
||||
|
||||
static const servoMixer_t *customServoMixers;
|
||||
|
||||
void servoUseConfigs(servoParam_t *servoParamsToUse, struct channelForwardingConfig_s *channelForwardingConfigToUse)
|
||||
{
|
||||
servoConf = servoParamsToUse;
|
||||
|
@ -157,7 +155,7 @@ void servoUseConfigs(servoParam_t *servoParamsToUse, struct channelForwardingCon
|
|||
|
||||
int16_t determineServoMiddleOrForwardFromChannel(servoIndex_e servoIndex)
|
||||
{
|
||||
uint8_t channelToForwardFrom = servoConf[servoIndex].forwardFromChannel;
|
||||
const uint8_t channelToForwardFrom = servoConf[servoIndex].forwardFromChannel;
|
||||
|
||||
if (channelToForwardFrom != CHANNEL_FORWARDING_DISABLED && channelToForwardFrom < rxRuntimeConfig.channelCount) {
|
||||
return rcData[channelToForwardFrom];
|
||||
|
@ -166,7 +164,6 @@ int16_t determineServoMiddleOrForwardFromChannel(servoIndex_e servoIndex)
|
|||
return servoConf[servoIndex].middle;
|
||||
}
|
||||
|
||||
|
||||
int servoDirection(int servoIndex, int inputSource)
|
||||
{
|
||||
// determine the direction (reversed or not) from the direction bitfield of the servo
|
||||
|
@ -176,10 +173,8 @@ int servoDirection(int servoIndex, int inputSource)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void servoMixerInit(const servoMixer_t *initialCustomServoMixers)
|
||||
void servosInit(void)
|
||||
{
|
||||
customServoMixers = initialCustomServoMixers;
|
||||
|
||||
// enable servos for mixes that require them. note, this shifts motor counts.
|
||||
useServo = mixers[currentMixerMode].useServo;
|
||||
// if we want camstab/trig, that also enables servos, even if mixer doesn't
|
||||
|
@ -201,10 +196,10 @@ void loadCustomServoMixer(void)
|
|||
// load custom mixer into currentServoMixer
|
||||
for (uint8_t i = 0; i < MAX_SERVO_RULES; i++) {
|
||||
// check if done
|
||||
if (customServoMixers[i].rate == 0)
|
||||
if (customServoMixers(i)->rate == 0)
|
||||
break;
|
||||
|
||||
currentServoMixer[i] = customServoMixers[i];
|
||||
currentServoMixer[i] = *customServoMixers(i);
|
||||
servoRuleCount++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,7 +105,6 @@ typedef struct servoParam_s {
|
|||
PG_DECLARE_ARRAY(servoParam_t, MAX_SUPPORTED_SERVOS, servoParams);
|
||||
|
||||
typedef struct servoConfig_s {
|
||||
// PWM values, in milliseconds, common range is 1000-2000 (1 to 2ms)
|
||||
servoDevConfig_t dev;
|
||||
uint16_t servo_lowpass_freq; // lowpass servo filter frequency selection; 1/1000ths of loop freq
|
||||
uint8_t tri_unarmed_servo; // send tail servo correction pulses even when unarmed
|
||||
|
@ -125,11 +124,9 @@ extern int16_t servo[MAX_SUPPORTED_SERVOS];
|
|||
|
||||
bool isMixerUsingServos(void);
|
||||
void writeServos(void);
|
||||
|
||||
void servoMixerInit(const servoMixer_t *customServoMixers);
|
||||
void servoUseConfigs(servoParam_t *servoParamsToUse, struct channelForwardingConfig_s *channelForwardingConfigToUse);
|
||||
void servoMixerLoadMix(int index, servoMixer_t *customServoMixers);
|
||||
void loadCustomServoMixer(void);
|
||||
void servoConfigureOutput(void);
|
||||
void servoUseConfigs(servoParam_t *servoParamsToUse, struct channelForwardingConfig_s *channelForwardingConfigToUse);
|
||||
int servoDirection(int servoIndex, int fromChannel);
|
||||
|
||||
void servoConfigureOutput(void);
|
||||
void servosInit(void);
|
||||
|
|
Loading…
Reference in New Issue