Preparation for conversion to parameter groups 7
This commit is contained in:
parent
4f4c14a02d
commit
d2ac5d84b1
|
@ -166,7 +166,7 @@
|
|||
#define displayPortProfileMax7456Mutable(x) (&masterConfig.displayPortProfileMax7456)
|
||||
#define displayPortProfileOledMutable(x) (&masterConfig.displayPortProfileOled)
|
||||
|
||||
#define servoParams(x) (&servoProfile()->servoConf[i])
|
||||
#define servoParams(x) (&servoProfile()->servoConf[x])
|
||||
#define adjustmentRanges(x) (&adjustmentProfile()->adjustmentRanges[x])
|
||||
#define rxFailsafeChannelConfigs(x) (&masterConfig.rxConfig.failsafe_channel_configurations[x])
|
||||
#define osdConfig(x) (&masterConfig.osdProfile)
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <math.h>
|
||||
#include <ctype.h>
|
||||
|
||||
//#define USE_PARAMETER_GROUPS
|
||||
#include "platform.h"
|
||||
|
||||
// FIXME remove this for targets that don't need a CLI. Perhaps use a no-op macro when USE_CLI is not enabled
|
||||
|
|
|
@ -906,7 +906,7 @@ void activateConfig(void)
|
|||
mixerUseConfigs(&masterConfig.airplaneConfig);
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
servoUseConfigs(&masterConfig.servoMixerConfig, masterConfig.servoProfile.servoConf, &masterConfig.gimbalConfig, &masterConfig.channelForwardingConfig);
|
||||
servoUseConfigs(&masterConfig.servoMixerConfig, masterConfig.servoProfile.servoConf, &masterConfig.channelForwardingConfig);
|
||||
#endif
|
||||
|
||||
imuConfigure(throttleCorrectionConfig()->throttle_correction_angle);
|
||||
|
|
|
@ -248,7 +248,7 @@ void init(void)
|
|||
// Spektrum satellite binding if enabled on startup.
|
||||
// Must be called before that 100ms sleep so that we don't lose satellite's binding window after startup.
|
||||
// The rest of Spektrum initialization will happen later - via spektrumInit()
|
||||
spektrumBind(rxConfig());
|
||||
spektrumBind(rxConfigMutable());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ void init(void)
|
|||
|
||||
mixerInit(mixerConfig()->mixerMode, customMotorMixerMutable(0));
|
||||
#ifdef USE_SERVOS
|
||||
servoMixerInit(masterConfig.customServoMixer);
|
||||
servoMixerInit(customServoMixers(0));
|
||||
#endif
|
||||
|
||||
uint16_t idlePulse = motorConfig()->mincommand;
|
||||
|
@ -461,7 +461,7 @@ void init(void)
|
|||
#endif
|
||||
|
||||
#ifdef LED_STRIP
|
||||
ledStripInit(ledStripConfig());
|
||||
ledStripInit();
|
||||
|
||||
if (feature(FEATURE_LED_STRIP)) {
|
||||
ledStripEnable();
|
||||
|
|
|
@ -56,7 +56,6 @@ static servoMixerConfig_t *servoMixerConfig;
|
|||
|
||||
static uint8_t servoRuleCount = 0;
|
||||
static servoMixer_t currentServoMixer[MAX_SERVO_RULES];
|
||||
static gimbalConfig_t *gimbalConfig;
|
||||
int16_t servo[MAX_SUPPORTED_SERVOS];
|
||||
static int useServo;
|
||||
static servoParam_t *servoConf;
|
||||
|
@ -146,11 +145,10 @@ const mixerRules_t servoMixers[] = {
|
|||
|
||||
static servoMixer_t *customServoMixers;
|
||||
|
||||
void servoUseConfigs(servoMixerConfig_t *servoMixerConfigToUse, servoParam_t *servoParamsToUse, struct gimbalConfig_s *gimbalConfigToUse, struct channelForwardingConfig_s *channelForwardingConfigToUse)
|
||||
void servoUseConfigs(servoMixerConfig_t *servoMixerConfigToUse, servoParam_t *servoParamsToUse, struct channelForwardingConfig_s *channelForwardingConfigToUse)
|
||||
{
|
||||
servoMixerConfig = servoMixerConfigToUse;
|
||||
servoConf = servoParamsToUse;
|
||||
gimbalConfig = gimbalConfigToUse;
|
||||
channelForwardingConfig = channelForwardingConfigToUse;
|
||||
}
|
||||
|
||||
|
|
|
@ -134,8 +134,7 @@ void writeServos(void);
|
|||
void filterServos(void);
|
||||
|
||||
void servoMixerInit(servoMixer_t *customServoMixers);
|
||||
struct gimbalConfig_s;
|
||||
void servoUseConfigs(servoMixerConfig_t *servoConfigToUse, servoParam_t *servoParamsToUse, struct gimbalConfig_s *gimbalConfigToUse, struct channelForwardingConfig_s *channelForwardingConfigToUse);
|
||||
void servoUseConfigs(servoMixerConfig_t *servoConfigToUse, servoParam_t *servoParamsToUse, struct channelForwardingConfig_s *channelForwardingConfigToUse);
|
||||
void servoMixerLoadMix(int index, servoMixer_t *customServoMixers);
|
||||
void loadCustomServoMixer(void);
|
||||
void servoConfigureOutput(void);
|
||||
|
|
|
@ -90,7 +90,6 @@ PG_REGISTER_WITH_RESET_FN(specialColorIndexes_t, specialColors, PG_SPECIAL_COLOR
|
|||
|
||||
static bool ledStripInitialised = false;
|
||||
static bool ledStripEnabled = true;
|
||||
static ledStripConfig_t * currentLedStripConfig;
|
||||
|
||||
static void ledStripDisable(void);
|
||||
|
||||
|
@ -184,7 +183,7 @@ STATIC_UNIT_TESTED void determineLedStripDimensions(void)
|
|||
int maxY = 0;
|
||||
|
||||
for (int ledIndex = 0; ledIndex < ledCounts.count; ledIndex++) {
|
||||
const ledConfig_t *ledConfig = ¤tLedStripConfig->ledConfigs[ledIndex];
|
||||
const ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[ledIndex];
|
||||
|
||||
maxX = MAX(ledGetX(ledConfig), maxX);
|
||||
maxY = MAX(ledGetY(ledConfig), maxY);
|
||||
|
@ -206,7 +205,7 @@ STATIC_UNIT_TESTED void updateLedCount(void)
|
|||
int count = 0, countRing = 0, countScanner= 0;
|
||||
|
||||
for (int ledIndex = 0; ledIndex < LED_MAX_STRIP_LENGTH; ledIndex++) {
|
||||
const ledConfig_t *ledConfig = ¤tLedStripConfig->ledConfigs[ledIndex];
|
||||
const ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[ledIndex];
|
||||
|
||||
if (!(*ledConfig))
|
||||
break;
|
||||
|
@ -236,7 +235,7 @@ void reevaluateLedConfig(void)
|
|||
// get specialColor by index
|
||||
static hsvColor_t* getSC(ledSpecialColorIds_e index)
|
||||
{
|
||||
return ¤tLedStripConfig->colors[currentLedStripConfig->specialColors.color[index]];
|
||||
return &ledStripConfig()->colors[ledStripConfig()->specialColors.color[index]];
|
||||
}
|
||||
|
||||
static const char directionCodes[LED_DIRECTION_COUNT] = { 'N', 'E', 'S', 'W', 'U', 'D' };
|
||||
|
@ -260,7 +259,7 @@ bool parseLedStripConfig(int ledIndex, const char *config)
|
|||
};
|
||||
static const char chunkSeparators[PARSE_STATE_COUNT] = {',', ':', ':', ':', '\0'};
|
||||
|
||||
ledConfig_t *ledConfig = ¤tLedStripConfig->ledConfigs[ledIndex];
|
||||
ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[ledIndex];
|
||||
memset(ledConfig, 0, sizeof(ledConfig_t));
|
||||
|
||||
int x = 0, y = 0, color = 0; // initialize to prevent warnings
|
||||
|
@ -379,7 +378,7 @@ typedef enum {
|
|||
|
||||
static quadrant_e getLedQuadrant(const int ledIndex)
|
||||
{
|
||||
const ledConfig_t *ledConfig = ¤tLedStripConfig->ledConfigs[ledIndex];
|
||||
const ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[ledIndex];
|
||||
|
||||
int x = ledGetX(ledConfig);
|
||||
int y = ledGetY(ledConfig);
|
||||
|
@ -421,7 +420,7 @@ static const struct {
|
|||
|
||||
static hsvColor_t* getDirectionalModeColor(const int ledIndex, const modeColorIndexes_t *modeColors)
|
||||
{
|
||||
const ledConfig_t *ledConfig = ¤tLedStripConfig->ledConfigs[ledIndex];
|
||||
const ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[ledIndex];
|
||||
|
||||
quadrant_e quad = getLedQuadrant(ledIndex);
|
||||
for (unsigned i = 0; i < ARRAYLEN(directionQuadrantMap); i++) {
|
||||
|
@ -429,7 +428,7 @@ static hsvColor_t* getDirectionalModeColor(const int ledIndex, const modeColorIn
|
|||
quadrant_e quadMask = directionQuadrantMap[i].quadrantMask;
|
||||
|
||||
if (ledGetDirectionBit(ledConfig, dir) && (quad & quadMask))
|
||||
return ¤tLedStripConfig->colors[modeColors->color[dir]];
|
||||
return &ledStripConfig()->colors[modeColors->color[dir]];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -455,7 +454,7 @@ static const struct {
|
|||
static void applyLedFixedLayers()
|
||||
{
|
||||
for (int ledIndex = 0; ledIndex < ledCounts.count; ledIndex++) {
|
||||
const ledConfig_t *ledConfig = ¤tLedStripConfig->ledConfigs[ledIndex];
|
||||
const ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[ledIndex];
|
||||
hsvColor_t color = *getSC(LED_SCOLOR_BACKGROUND);
|
||||
|
||||
int fn = ledGetFunction(ledConfig);
|
||||
|
@ -463,13 +462,13 @@ static void applyLedFixedLayers()
|
|||
|
||||
switch (fn) {
|
||||
case LED_FUNCTION_COLOR:
|
||||
color = currentLedStripConfig->colors[ledGetColor(ledConfig)];
|
||||
color = ledStripConfig()->colors[ledGetColor(ledConfig)];
|
||||
break;
|
||||
|
||||
case LED_FUNCTION_FLIGHT_MODE:
|
||||
for (unsigned i = 0; i < ARRAYLEN(flightModeToLed); i++)
|
||||
if (!flightModeToLed[i].flightMode || FLIGHT_MODE(flightModeToLed[i].flightMode)) {
|
||||
hsvColor_t *directionalColor = getDirectionalModeColor(ledIndex, ¤tLedStripConfig->modeColors[flightModeToLed[i].ledMode]);
|
||||
hsvColor_t *directionalColor = getDirectionalModeColor(ledIndex, &ledStripConfig()->modeColors[flightModeToLed[i].ledMode]);
|
||||
if (directionalColor) {
|
||||
color = *directionalColor;
|
||||
}
|
||||
|
@ -510,7 +509,7 @@ static void applyLedFixedLayers()
|
|||
static void applyLedHsv(uint32_t mask, const hsvColor_t *color)
|
||||
{
|
||||
for (int ledIndex = 0; ledIndex < ledCounts.count; ledIndex++) {
|
||||
const ledConfig_t *ledConfig = ¤tLedStripConfig->ledConfigs[ledIndex];
|
||||
const ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[ledIndex];
|
||||
if ((*ledConfig & mask) == mask)
|
||||
setLedHsv(ledIndex, color);
|
||||
}
|
||||
|
@ -708,7 +707,7 @@ static void applyLedIndicatorLayer(bool updateNow, timeUs_t *timer)
|
|||
}
|
||||
|
||||
for (int ledIndex = 0; ledIndex < ledCounts.count; ledIndex++) {
|
||||
const ledConfig_t *ledConfig = ¤tLedStripConfig->ledConfigs[ledIndex];
|
||||
const ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[ledIndex];
|
||||
if (ledGetOverlayBit(ledConfig, LED_OVERLAY_INDICATOR)) {
|
||||
if (getLedQuadrant(ledIndex) & quadrants)
|
||||
setLedHsv(ledIndex, flashColor);
|
||||
|
@ -748,7 +747,7 @@ static void applyLedThrustRingLayer(bool updateNow, timeUs_t *timer)
|
|||
}
|
||||
|
||||
for (int ledIndex = 0; ledIndex < ledCounts.count; ledIndex++) {
|
||||
const ledConfig_t *ledConfig = ¤tLedStripConfig->ledConfigs[ledIndex];
|
||||
const ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[ledIndex];
|
||||
if (ledGetFunction(ledConfig) == LED_FUNCTION_THRUST_RING) {
|
||||
|
||||
bool applyColor;
|
||||
|
@ -759,7 +758,7 @@ static void applyLedThrustRingLayer(bool updateNow, timeUs_t *timer)
|
|||
}
|
||||
|
||||
if (applyColor) {
|
||||
const hsvColor_t *ringColor = ¤tLedStripConfig->colors[ledGetColor(ledConfig)];
|
||||
const hsvColor_t *ringColor = &ledStripConfig()->colors[ledGetColor(ledConfig)];
|
||||
setLedHsv(ledIndex, ringColor);
|
||||
}
|
||||
|
||||
|
@ -875,7 +874,7 @@ static void applyLedAnimationLayer(bool updateNow, timeUs_t *timer)
|
|||
int nextRow = (frameCounter + 1 < animationFrames) ? frameCounter + 1 : 0;
|
||||
|
||||
for (int ledIndex = 0; ledIndex < ledCounts.count; ledIndex++) {
|
||||
const ledConfig_t *ledConfig = ¤tLedStripConfig->ledConfigs[ledIndex];
|
||||
const ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[ledIndex];
|
||||
|
||||
if (ledGetY(ledConfig) == previousRow) {
|
||||
setLedHsv(ledIndex, getSC(LED_SCOLOR_ANIMATION));
|
||||
|
@ -937,7 +936,7 @@ void ledStripUpdate(timeUs_t currentTimeUs)
|
|||
return;
|
||||
}
|
||||
|
||||
if (IS_RC_MODE_ACTIVE(BOXLEDLOW) && !(currentLedStripConfig->ledstrip_visual_beeper && isBeeperOn())) {
|
||||
if (IS_RC_MODE_ACTIVE(BOXLEDLOW) && !(ledStripConfig()->ledstrip_visual_beeper && isBeeperOn())) {
|
||||
if (ledStripEnabled) {
|
||||
ledStripDisable();
|
||||
ledStripEnabled = false;
|
||||
|
@ -968,7 +967,7 @@ void ledStripUpdate(timeUs_t currentTimeUs)
|
|||
// apply all layers; triggered timed functions has to update timers
|
||||
|
||||
scaledThrottle = ARMING_FLAG(ARMED) ? scaleRange(rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX, 0, 100) : 0;
|
||||
scaledAux = scaleRange(rcData[currentLedStripConfig->ledstrip_aux_channel], PWM_RANGE_MIN, PWM_RANGE_MAX, 0, HSV_HUE_MAX + 1);
|
||||
scaledAux = scaleRange(rcData[ledStripConfig()->ledstrip_aux_channel], PWM_RANGE_MIN, PWM_RANGE_MAX, 0, HSV_HUE_MAX + 1);
|
||||
|
||||
applyLedFixedLayers();
|
||||
|
||||
|
@ -984,7 +983,7 @@ bool parseColor(int index, const char *colorConfig)
|
|||
{
|
||||
const char *remainingCharacters = colorConfig;
|
||||
|
||||
hsvColor_t *color = ¤tLedStripConfig->colors[index];
|
||||
hsvColor_t *color = &ledStripConfig()->colors[index];
|
||||
|
||||
bool result = true;
|
||||
static const uint16_t hsv_limit[HSV_COLOR_COMPONENT_COUNT] = {
|
||||
|
@ -1037,15 +1036,15 @@ bool setModeColor(ledModeIndex_e modeIndex, int modeColorIndex, int colorIndex)
|
|||
if (modeIndex < LED_MODE_COUNT) { // modeIndex_e is unsigned, so one-sided test is enough
|
||||
if(modeColorIndex < 0 || modeColorIndex >= LED_DIRECTION_COUNT)
|
||||
return false;
|
||||
currentLedStripConfig->modeColors[modeIndex].color[modeColorIndex] = colorIndex;
|
||||
ledStripConfig()->modeColors[modeIndex].color[modeColorIndex] = colorIndex;
|
||||
} else if (modeIndex == LED_SPECIAL) {
|
||||
if (modeColorIndex < 0 || modeColorIndex >= LED_SPECIAL_COLOR_COUNT)
|
||||
return false;
|
||||
currentLedStripConfig->specialColors.color[modeColorIndex] = colorIndex;
|
||||
ledStripConfig()->specialColors.color[modeColorIndex] = colorIndex;
|
||||
} else if (modeIndex == LED_AUX_CHANNEL) {
|
||||
if (modeColorIndex < 0 || modeColorIndex >= 1)
|
||||
return false;
|
||||
currentLedStripConfig->ledstrip_aux_channel = colorIndex;
|
||||
ledStripConfig()->ledstrip_aux_channel = colorIndex;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -1103,26 +1102,21 @@ void applyDefaultSpecialColors(specialColorIndexes_t *specialColors)
|
|||
memcpy_fn(specialColors, &defaultSpecialColors, sizeof(defaultSpecialColors));
|
||||
}
|
||||
|
||||
void ledStripInit(ledStripConfig_t *ledStripConfig)
|
||||
void ledStripInit()
|
||||
{
|
||||
currentLedStripConfig = ledStripConfig;
|
||||
|
||||
ledConfigs = currentLedStripConfig->ledConfigs;
|
||||
colors = currentLedStripConfig->colors;
|
||||
modeColors = currentLedStripConfig->modeColors;
|
||||
specialColors = currentLedStripConfig->specialColors;
|
||||
ledConfigs = ledStripConfig()->ledConfigs;
|
||||
colors = ledStripConfig()->colors;
|
||||
modeColors = ledStripConfig()->modeColors;
|
||||
specialColors = ledStripConfig()->specialColors;
|
||||
ledStripInitialised = false;
|
||||
}
|
||||
|
||||
void ledStripEnable(void)
|
||||
{
|
||||
if (currentLedStripConfig == NULL) {
|
||||
return;
|
||||
}
|
||||
reevaluateLedConfig();
|
||||
ledStripInitialised = true;
|
||||
|
||||
ws2811LedStripInit(currentLedStripConfig->ioTag);
|
||||
ws2811LedStripInit(ledStripConfig()->ioTag);
|
||||
}
|
||||
|
||||
static void ledStripDisable(void)
|
||||
|
|
|
@ -183,7 +183,7 @@ bool parseLedStripConfig(int ledIndex, const char *config);
|
|||
void generateLedConfig(ledConfig_t *ledConfig, char *ledConfigBuffer, size_t bufferSize);
|
||||
void reevaluateLedConfig(void);
|
||||
|
||||
void ledStripInit(ledStripConfig_t *ledStripConfig);
|
||||
void ledStripInit(void);
|
||||
void ledStripEnable(void);
|
||||
void ledStripUpdate(timeUs_t currentTimeUs);
|
||||
|
||||
|
|
Loading…
Reference in New Issue