mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Added adc, beeper, sonar, and ledStrip config() macros
This commit is contained in:
parent
e89f0a0299
commit
57a9393f5f
5 changed files with 30 additions and 26 deletions
|
@ -89,6 +89,10 @@
|
||||||
#define telemetryConfig(x) (&masterConfig.telemetryConfig)
|
#define telemetryConfig(x) (&masterConfig.telemetryConfig)
|
||||||
#define ppmConfig(x) (&masterConfig.ppmConfig)
|
#define ppmConfig(x) (&masterConfig.ppmConfig)
|
||||||
#define pwmConfig(x) (&masterConfig.pwmConfig)
|
#define pwmConfig(x) (&masterConfig.pwmConfig)
|
||||||
|
#define adcConfig(x) (&masterConfig.adcConfig)
|
||||||
|
#define beeperConfig(x) (&masterConfig.beeperConfig)
|
||||||
|
#define sonarConfig(x) (&masterConfig.sonarConfig)
|
||||||
|
#define ledStripConfig(x) (&masterConfig.ledStripConfig)
|
||||||
|
|
||||||
|
|
||||||
// System-wide
|
// System-wide
|
||||||
|
|
|
@ -963,7 +963,7 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
||||||
#ifdef LED_STRIP
|
#ifdef LED_STRIP
|
||||||
case MSP_LED_COLORS:
|
case MSP_LED_COLORS:
|
||||||
for (int i = 0; i < LED_CONFIGURABLE_COLOR_COUNT; i++) {
|
for (int i = 0; i < LED_CONFIGURABLE_COLOR_COUNT; i++) {
|
||||||
hsvColor_t *color = &masterConfig.ledStripConfig.colors[i];
|
hsvColor_t *color = &ledStripConfig()->colors[i];
|
||||||
sbufWriteU16(dst, color->h);
|
sbufWriteU16(dst, color->h);
|
||||||
sbufWriteU8(dst, color->s);
|
sbufWriteU8(dst, color->s);
|
||||||
sbufWriteU8(dst, color->v);
|
sbufWriteU8(dst, color->v);
|
||||||
|
@ -972,7 +972,7 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
||||||
|
|
||||||
case MSP_LED_STRIP_CONFIG:
|
case MSP_LED_STRIP_CONFIG:
|
||||||
for (int i = 0; i < LED_MAX_STRIP_LENGTH; i++) {
|
for (int i = 0; i < LED_MAX_STRIP_LENGTH; i++) {
|
||||||
ledConfig_t *ledConfig = &masterConfig.ledStripConfig.ledConfigs[i];
|
ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[i];
|
||||||
sbufWriteU32(dst, *ledConfig);
|
sbufWriteU32(dst, *ledConfig);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -982,19 +982,19 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
||||||
for (int j = 0; j < LED_DIRECTION_COUNT; j++) {
|
for (int j = 0; j < LED_DIRECTION_COUNT; j++) {
|
||||||
sbufWriteU8(dst, i);
|
sbufWriteU8(dst, i);
|
||||||
sbufWriteU8(dst, j);
|
sbufWriteU8(dst, j);
|
||||||
sbufWriteU8(dst, masterConfig.ledStripConfig.modeColors[i].color[j]);
|
sbufWriteU8(dst, ledStripConfig()->modeColors[i].color[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < LED_SPECIAL_COLOR_COUNT; j++) {
|
for (int j = 0; j < LED_SPECIAL_COLOR_COUNT; j++) {
|
||||||
sbufWriteU8(dst, LED_MODE_COUNT);
|
sbufWriteU8(dst, LED_MODE_COUNT);
|
||||||
sbufWriteU8(dst, j);
|
sbufWriteU8(dst, j);
|
||||||
sbufWriteU8(dst, masterConfig.ledStripConfig.specialColors.color[j]);
|
sbufWriteU8(dst, ledStripConfig()->specialColors.color[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
sbufWriteU8(dst, LED_AUX_CHANNEL);
|
sbufWriteU8(dst, LED_AUX_CHANNEL);
|
||||||
sbufWriteU8(dst, 0);
|
sbufWriteU8(dst, 0);
|
||||||
sbufWriteU8(dst, masterConfig.ledStripConfig.ledstrip_aux_channel);
|
sbufWriteU8(dst, ledStripConfig()->ledstrip_aux_channel);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1770,7 +1770,7 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
||||||
#ifdef LED_STRIP
|
#ifdef LED_STRIP
|
||||||
case MSP_SET_LED_COLORS:
|
case MSP_SET_LED_COLORS:
|
||||||
for (int i = 0; i < LED_CONFIGURABLE_COLOR_COUNT; i++) {
|
for (int i = 0; i < LED_CONFIGURABLE_COLOR_COUNT; i++) {
|
||||||
hsvColor_t *color = &masterConfig.ledStripConfig.colors[i];
|
hsvColor_t *color = &ledStripConfig()->colors[i];
|
||||||
color->h = sbufReadU16(src);
|
color->h = sbufReadU16(src);
|
||||||
color->s = sbufReadU8(src);
|
color->s = sbufReadU8(src);
|
||||||
color->v = sbufReadU8(src);
|
color->v = sbufReadU8(src);
|
||||||
|
@ -1783,7 +1783,7 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
||||||
if (i >= LED_MAX_STRIP_LENGTH || dataSize != (1 + 4)) {
|
if (i >= LED_MAX_STRIP_LENGTH || dataSize != (1 + 4)) {
|
||||||
return MSP_RESULT_ERROR;
|
return MSP_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
ledConfig_t *ledConfig = &masterConfig.ledStripConfig.ledConfigs[i];
|
ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[i];
|
||||||
*ledConfig = sbufReadU32(src);
|
*ledConfig = sbufReadU32(src);
|
||||||
reevaluateLedConfig();
|
reevaluateLedConfig();
|
||||||
}
|
}
|
||||||
|
|
|
@ -760,8 +760,8 @@ const clivalue_t valueTable[] = {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BEEPER
|
#ifdef BEEPER
|
||||||
{ "beeper_inversion", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.beeperConfig.isInverted, .config.lookup = { TABLE_OFF_ON } },
|
{ "beeper_inversion", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &beeperConfig()->isInverted, .config.lookup = { TABLE_OFF_ON } },
|
||||||
{ "beeper_od", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.beeperConfig.isOpenDrain, .config.lookup = { TABLE_OFF_ON } },
|
{ "beeper_od", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &beeperConfig()->isOpenDrain, .config.lookup = { TABLE_OFF_ON } },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SERIAL_RX
|
#ifdef SERIAL_RX
|
||||||
|
@ -949,7 +949,7 @@ const clivalue_t valueTable[] = {
|
||||||
{ "magzero_z", VAR_INT16 | MASTER_VALUE, &sensorTrims()->magZero.raw[Z], .config.minmax = { -32768, 32767 } },
|
{ "magzero_z", VAR_INT16 | MASTER_VALUE, &sensorTrims()->magZero.raw[Z], .config.minmax = { -32768, 32767 } },
|
||||||
#endif
|
#endif
|
||||||
#ifdef LED_STRIP
|
#ifdef LED_STRIP
|
||||||
{ "ledstrip_visual_beeper", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.ledStripConfig.ledstrip_visual_beeper, .config.lookup = { TABLE_OFF_ON } },
|
{ "ledstrip_visual_beeper", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &ledStripConfig()->ledstrip_visual_beeper, .config.lookup = { TABLE_OFF_ON } },
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_RTC6705
|
#ifdef USE_RTC6705
|
||||||
{ "vtx_channel", VAR_UINT8 | MASTER_VALUE, &masterConfig.vtx_channel, .config.minmax = { 0, 39 } },
|
{ "vtx_channel", VAR_UINT8 | MASTER_VALUE, &masterConfig.vtx_channel, .config.minmax = { 0, 39 } },
|
||||||
|
@ -1741,7 +1741,7 @@ static void printLed(uint8_t dumpMask, master_t *defaultConfig)
|
||||||
char ledConfigBuffer[20];
|
char ledConfigBuffer[20];
|
||||||
char ledConfigDefaultBuffer[20];
|
char ledConfigDefaultBuffer[20];
|
||||||
for (uint32_t i = 0; i < LED_MAX_STRIP_LENGTH; i++) {
|
for (uint32_t i = 0; i < LED_MAX_STRIP_LENGTH; i++) {
|
||||||
ledConfig = masterConfig.ledStripConfig.ledConfigs[i];
|
ledConfig = ledStripConfig()->ledConfigs[i];
|
||||||
ledConfigDefault = defaultConfig->ledStripConfig.ledConfigs[i];
|
ledConfigDefault = defaultConfig->ledStripConfig.ledConfigs[i];
|
||||||
equalsDefault = ledConfig == ledConfigDefault;
|
equalsDefault = ledConfig == ledConfigDefault;
|
||||||
generateLedConfig(&ledConfig, ledConfigBuffer, sizeof(ledConfigBuffer));
|
generateLedConfig(&ledConfig, ledConfigBuffer, sizeof(ledConfigBuffer));
|
||||||
|
@ -1779,7 +1779,7 @@ static void printColor(uint8_t dumpMask, master_t *defaultConfig)
|
||||||
hsvColor_t *colorDefault;
|
hsvColor_t *colorDefault;
|
||||||
bool equalsDefault;
|
bool equalsDefault;
|
||||||
for (uint32_t i = 0; i < LED_CONFIGURABLE_COLOR_COUNT; i++) {
|
for (uint32_t i = 0; i < LED_CONFIGURABLE_COLOR_COUNT; i++) {
|
||||||
color = &masterConfig.ledStripConfig.colors[i];
|
color = &ledStripConfig()->colors[i];
|
||||||
colorDefault = &defaultConfig->ledStripConfig.colors[i];
|
colorDefault = &defaultConfig->ledStripConfig.colors[i];
|
||||||
equalsDefault = color->h == colorDefault->h
|
equalsDefault = color->h == colorDefault->h
|
||||||
&& color->s == colorDefault->s
|
&& color->s == colorDefault->s
|
||||||
|
@ -1825,7 +1825,7 @@ static void printModeColor(uint8_t dumpMask, master_t *defaultConfig)
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < LED_MODE_COUNT; i++) {
|
for (uint32_t i = 0; i < LED_MODE_COUNT; i++) {
|
||||||
for (uint32_t j = 0; j < LED_DIRECTION_COUNT; j++) {
|
for (uint32_t j = 0; j < LED_DIRECTION_COUNT; j++) {
|
||||||
int colorIndex = masterConfig.ledStripConfig.modeColors[i].color[j];
|
int colorIndex = ledStripConfig()->modeColors[i].color[j];
|
||||||
int colorIndexDefault = defaultConfig->ledStripConfig.modeColors[i].color[j];
|
int colorIndexDefault = defaultConfig->ledStripConfig.modeColors[i].color[j];
|
||||||
const char *format = "mode_color %u %u %u\r\n";
|
const char *format = "mode_color %u %u %u\r\n";
|
||||||
cliDefaultPrintf(dumpMask, colorIndex == colorIndexDefault, format, i, j, colorIndexDefault);
|
cliDefaultPrintf(dumpMask, colorIndex == colorIndexDefault, format, i, j, colorIndexDefault);
|
||||||
|
@ -1835,13 +1835,13 @@ static void printModeColor(uint8_t dumpMask, master_t *defaultConfig)
|
||||||
|
|
||||||
const char *format = "mode_color %u %u %u\r\n";
|
const char *format = "mode_color %u %u %u\r\n";
|
||||||
for (uint32_t j = 0; j < LED_SPECIAL_COLOR_COUNT; j++) {
|
for (uint32_t j = 0; j < LED_SPECIAL_COLOR_COUNT; j++) {
|
||||||
int colorIndex = masterConfig.ledStripConfig.specialColors.color[j];
|
int colorIndex = ledStripConfig()->specialColors.color[j];
|
||||||
int colorIndexDefault = defaultConfig->ledStripConfig.specialColors.color[j];
|
int colorIndexDefault = defaultConfig->ledStripConfig.specialColors.color[j];
|
||||||
cliDefaultPrintf(dumpMask, colorIndex == colorIndexDefault, format, LED_SPECIAL, j, colorIndexDefault);
|
cliDefaultPrintf(dumpMask, colorIndex == colorIndexDefault, format, LED_SPECIAL, j, colorIndexDefault);
|
||||||
cliDumpPrintf(dumpMask, colorIndex == colorIndexDefault, format, LED_SPECIAL, j, colorIndex);
|
cliDumpPrintf(dumpMask, colorIndex == colorIndexDefault, format, LED_SPECIAL, j, colorIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ledStripAuxChannel = masterConfig.ledStripConfig.ledstrip_aux_channel;
|
int ledStripAuxChannel = ledStripConfig()->ledstrip_aux_channel;
|
||||||
int ledStripAuxChannelDefault = defaultConfig->ledStripConfig.ledstrip_aux_channel;
|
int ledStripAuxChannelDefault = defaultConfig->ledStripConfig.ledstrip_aux_channel;
|
||||||
cliDefaultPrintf(dumpMask, ledStripAuxChannel == ledStripAuxChannelDefault, format, LED_AUX_CHANNEL, 0, ledStripAuxChannelDefault);
|
cliDefaultPrintf(dumpMask, ledStripAuxChannel == ledStripAuxChannelDefault, format, LED_AUX_CHANNEL, 0, ledStripAuxChannelDefault);
|
||||||
cliDumpPrintf(dumpMask, ledStripAuxChannel == ledStripAuxChannelDefault, format, LED_AUX_CHANNEL, 0, ledStripAuxChannel);
|
cliDumpPrintf(dumpMask, ledStripAuxChannel == ledStripAuxChannelDefault, format, LED_AUX_CHANNEL, 0, ledStripAuxChannel);
|
||||||
|
@ -3788,7 +3788,7 @@ typedef struct {
|
||||||
|
|
||||||
const cliResourceValue_t resourceTable[] = {
|
const cliResourceValue_t resourceTable[] = {
|
||||||
#ifdef BEEPER
|
#ifdef BEEPER
|
||||||
{ OWNER_BEEPER, &masterConfig.beeperConfig.ioTag, 0 },
|
{ OWNER_BEEPER, &beeperConfig()->ioTag, 0 },
|
||||||
#endif
|
#endif
|
||||||
{ OWNER_MOTOR, &motorConfig()->ioTags[0], MAX_SUPPORTED_MOTORS },
|
{ OWNER_MOTOR, &motorConfig()->ioTags[0], MAX_SUPPORTED_MOTORS },
|
||||||
#ifdef USE_SERVOS
|
#ifdef USE_SERVOS
|
||||||
|
@ -3799,11 +3799,11 @@ const cliResourceValue_t resourceTable[] = {
|
||||||
{ OWNER_PWMINPUT, &pwmConfig()->ioTags[0], PWM_INPUT_PORT_COUNT },
|
{ OWNER_PWMINPUT, &pwmConfig()->ioTags[0], PWM_INPUT_PORT_COUNT },
|
||||||
#endif
|
#endif
|
||||||
#ifdef SONAR
|
#ifdef SONAR
|
||||||
{ OWNER_SONAR_TRIGGER, &masterConfig.sonarConfig.triggerTag, 0 },
|
{ OWNER_SONAR_TRIGGER, &sonarConfig()->triggerTag, 0 },
|
||||||
{ OWNER_SONAR_ECHO, &masterConfig.sonarConfig.echoTag, 0 },
|
{ OWNER_SONAR_ECHO, &sonarConfig()->echoTag, 0 },
|
||||||
#endif
|
#endif
|
||||||
#ifdef LED_STRIP
|
#ifdef LED_STRIP
|
||||||
{ OWNER_LED_STRIP, &masterConfig.ledStripConfig.ioTag, 0 },
|
{ OWNER_LED_STRIP, &ledStripConfig()->ioTag, 0 },
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -377,9 +377,9 @@ void init(void)
|
||||||
|
|
||||||
#ifdef USE_ADC
|
#ifdef USE_ADC
|
||||||
/* these can be removed from features! */
|
/* these can be removed from features! */
|
||||||
masterConfig.adcConfig.vbat.enabled = feature(FEATURE_VBAT);
|
adcConfig()->vbat.enabled = feature(FEATURE_VBAT);
|
||||||
masterConfig.adcConfig.currentMeter.enabled = feature(FEATURE_CURRENT_METER);
|
adcConfig()->currentMeter.enabled = feature(FEATURE_CURRENT_METER);
|
||||||
masterConfig.adcConfig.rssi.enabled = feature(FEATURE_RSSI_ADC);
|
adcConfig()->rssi.enabled = feature(FEATURE_RSSI_ADC);
|
||||||
adcInit(&masterConfig.adcConfig);
|
adcInit(&masterConfig.adcConfig);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -936,7 +936,7 @@ static bool bstSlaveProcessFeedbackCommand(uint8_t bstRequest)
|
||||||
#ifdef LED_STRIP
|
#ifdef LED_STRIP
|
||||||
case BST_LED_COLORS:
|
case BST_LED_COLORS:
|
||||||
for (i = 0; i < LED_CONFIGURABLE_COLOR_COUNT; i++) {
|
for (i = 0; i < LED_CONFIGURABLE_COLOR_COUNT; i++) {
|
||||||
hsvColor_t *color = &masterConfig.ledStripConfig.colors[i];
|
hsvColor_t *color = &ledStripConfig()->colors[i];
|
||||||
bstWrite16(color->h);
|
bstWrite16(color->h);
|
||||||
bstWrite8(color->s);
|
bstWrite8(color->s);
|
||||||
bstWrite8(color->v);
|
bstWrite8(color->v);
|
||||||
|
@ -945,7 +945,7 @@ static bool bstSlaveProcessFeedbackCommand(uint8_t bstRequest)
|
||||||
|
|
||||||
case BST_LED_STRIP_CONFIG:
|
case BST_LED_STRIP_CONFIG:
|
||||||
for (i = 0; i < LED_MAX_STRIP_LENGTH; i++) {
|
for (i = 0; i < LED_MAX_STRIP_LENGTH; i++) {
|
||||||
ledConfig_t *ledConfig = &masterConfig.ledStripConfig.ledConfigs[i];
|
ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[i];
|
||||||
bstWrite32(*ledConfig);
|
bstWrite32(*ledConfig);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1368,7 +1368,7 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
|
||||||
//for (i = 0; i < CONFIGURABLE_COLOR_COUNT; i++) {
|
//for (i = 0; i < CONFIGURABLE_COLOR_COUNT; i++) {
|
||||||
{
|
{
|
||||||
i = bstRead8();
|
i = bstRead8();
|
||||||
hsvColor_t *color = &masterConfig.ledStripConfig.colors[i];
|
hsvColor_t *color = &ledStripConfig()->colors[i];
|
||||||
color->h = bstRead16();
|
color->h = bstRead16();
|
||||||
color->s = bstRead8();
|
color->s = bstRead8();
|
||||||
color->v = bstRead8();
|
color->v = bstRead8();
|
||||||
|
@ -1381,7 +1381,7 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
|
||||||
ret = BST_FAILED;
|
ret = BST_FAILED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ledConfig_t *ledConfig = &masterConfig.ledStripConfig.ledConfigs[i];
|
ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[i];
|
||||||
*ledConfig = bstRead32();
|
*ledConfig = bstRead32();
|
||||||
reevaluateLedConfig();
|
reevaluateLedConfig();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue