Skip to content

Commit

Permalink
Default blackbox device to NONE on reset (#12221)
Browse files Browse the repository at this point in the history
* Default blackbox device to NONE on reset

* Add check for flashIsSupported

* Move blackbox validation outside of validateAndFixGyroConfig()
  • Loading branch information
haslinghuis committed Jan 29, 2023
1 parent 99088f2 commit d926404
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/main/blackbox/blackbox.c
Expand Up @@ -88,7 +88,7 @@
#elif defined(ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT)
#define DEFAULT_BLACKBOX_DEVICE BLACKBOX_DEVICE_SDCARD
#else
#define DEFAULT_BLACKBOX_DEVICE BLACKBOX_DEVICE_SERIAL
#define DEFAULT_BLACKBOX_DEVICE BLACKBOX_DEVICE_NONE
#endif

PG_REGISTER_WITH_RESET_TEMPLATE(blackboxConfig_t, blackboxConfig, PG_BLACKBOX_CONFIG, 3);
Expand Down Expand Up @@ -873,7 +873,7 @@ STATIC_UNIT_TESTED bool writeSlowFrameIfNeeded(void)

void blackboxValidateConfig(void)
{
// If we've chosen an unsupported device, change the device to serial
// If we've chosen an unsupported device, change the device to NONE
switch (blackboxConfig()->device) {
#ifdef USE_FLASHFS
case BLACKBOX_DEVICE_FLASH:
Expand All @@ -886,7 +886,7 @@ void blackboxValidateConfig(void)
break;

default:
blackboxConfigMutable()->device = BLACKBOX_DEVICE_SERIAL;
blackboxConfigMutable()->device = BLACKBOX_DEVICE_NONE;
}
}

Expand Down
28 changes: 17 additions & 11 deletions src/main/config/config.c
Expand Up @@ -593,6 +593,10 @@ static void validateAndFixConfig(void)
}
#endif

#ifdef USE_BLACKBOX
validateAndFixBlackBox();
#endif // USE_BLACKBOX

#if defined(TARGET_VALIDATECONFIG)
// This should be done at the end of the validation
targetValidateConfiguration();
Expand Down Expand Up @@ -687,7 +691,19 @@ void validateAndFixGyroConfig(void)
}
}

if (systemConfig()->activeRateProfile >= CONTROL_RATE_PROFILE_COUNT) {
systemConfigMutable()->activeRateProfile = 0;
}
loadControlRateProfile();

if (systemConfig()->pidProfileIndex >= PID_PROFILE_COUNT) {
systemConfigMutable()->pidProfileIndex = 0;
}
loadPidProfile();
}

#ifdef USE_BLACKBOX
void validateAndFixBlackBox(void) {
#ifndef USE_FLASHFS
if (blackboxConfig()->device == BLACKBOX_DEVICE_FLASH) {
blackboxConfigMutable()->device = BLACKBOX_DEVICE_NONE;
Expand All @@ -702,18 +718,8 @@ void validateAndFixGyroConfig(void)
blackboxConfigMutable()->device = BLACKBOX_DEVICE_NONE;
}
}
#endif // USE_BLACKBOX

if (systemConfig()->activeRateProfile >= CONTROL_RATE_PROFILE_COUNT) {
systemConfigMutable()->activeRateProfile = 0;
}
loadControlRateProfile();

if (systemConfig()->pidProfileIndex >= PID_PROFILE_COUNT) {
systemConfigMutable()->pidProfileIndex = 0;
}
loadPidProfile();
}
#endif // USE_BLACKBOX

bool readEEPROM(void)
{
Expand Down
3 changes: 3 additions & 0 deletions src/main/config/config.h
Expand Up @@ -68,6 +68,9 @@ void ensureEEPROMStructureIsValid(void);

void saveConfigAndNotify(void);
void validateAndFixGyroConfig(void);
#ifdef USE_BLACKBOX
void validateAndFixBlackBox(void);
#endif

void setConfigDirty(void);
bool isConfigDirty(void);
Expand Down
8 changes: 5 additions & 3 deletions src/main/target/common_post.h
Expand Up @@ -234,9 +234,6 @@
#endif

#ifdef USE_FLASH
#define USE_FLASHFS
#define USE_FLASH_TOOLS
#endif

#if (defined(USE_FLASH_W25M512) || defined(USE_FLASH_W25Q128FV)) && !defined(USE_FLASH_M25P16)
#define USE_FLASH_M25P16
Expand All @@ -252,9 +249,14 @@

#if defined(USE_FLASH_M25P16) || defined(USE_FLASH_W25M) || defined(USE_FLASH_W25N01G) || defined(USE_FLASH_W25Q128FV)
#define USE_FLASH_CHIP
#define USE_FLASH_TOOLS
#define USE_FLASHFS
#endif

#endif // USE_FLASH

#ifndef USE_FLASH_CHIP
#undef USE_FLASH_TOOLS
#undef USE_FLASHFS
#endif

Expand Down
2 changes: 0 additions & 2 deletions src/test/unit/target.h
Expand Up @@ -72,8 +72,6 @@

#define TARGET_BOARD_IDENTIFIER "TEST"

#define DEFAULT_BLACKBOX_DEVICE BLACKBOX_DEVICE_SERIAL

#define LED_STRIP_TIMER 1
#define SOFTSERIAL_1_TIMER 2
#define SOFTSERIAL_2_TIMER 3
Expand Down

0 comments on commit d926404

Please sign in to comment.