From c6c4c3adf9b7a1524430bd727d1768afb2beb16b Mon Sep 17 00:00:00 2001 From: mikeller Date: Sun, 23 Jun 2019 19:56:45 +1200 Subject: [PATCH] Fixed dispatch initialisation for persistent statistics. --- src/main/fc/init.c | 6 +++++- src/main/fc/rc_adjustments.c | 2 +- src/main/fc/stats.c | 6 +++++- src/main/fc/stats.h | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/fc/init.c b/src/main/fc/init.c index c088e003e..9675be27d 100644 --- a/src/main/fc/init.c +++ b/src/main/fc/init.c @@ -88,6 +88,7 @@ #include "fc/init.h" #include "fc/rc_controls.h" #include "fc/runtime_config.h" +#include "fc/stats.h" #include "fc/tasks.h" #include "flight/failsafe.h" @@ -932,10 +933,13 @@ void init(void) pwmEnableMotors(); #endif +#ifdef USE_PERSISTENT_STATS + statsInit(); +#endif + setArmingDisabled(ARMING_DISABLED_BOOT_GRACE_TIME); fcTasksInit(); systemState |= SYSTEM_STATE_READY; - } diff --git a/src/main/fc/rc_adjustments.c b/src/main/fc/rc_adjustments.c index d86f71385..33f4c9f56 100644 --- a/src/main/fc/rc_adjustments.c +++ b/src/main/fc/rc_adjustments.c @@ -767,7 +767,7 @@ static void processStepwiseAdjustments(controlRateConfig_t *controlRateConfig, c static void setConfigDirtyIfNotPermanent(const channelRange_t *range) { - if (range->startStep == MIN_MODE_RANGE_STEP && range->endStep == MAX_MODE_RANGE_STEP) { + if (!(range->startStep == MIN_MODE_RANGE_STEP && range->endStep == MAX_MODE_RANGE_STEP)) { // Only set the configuration dirty if this range is NOT permanently enabled (and the config thus never used). setConfigDirty(); } diff --git a/src/main/fc/stats.c b/src/main/fc/stats.c index 87340167d..25d571fd2 100644 --- a/src/main/fc/stats.c +++ b/src/main/fc/stats.c @@ -49,6 +49,11 @@ static bool saveRequired = false; #define DISTANCE_FLOWN_CM (0) #endif +void statsInit(void) +{ + dispatchEnable(); +} + void writeStats(struct dispatchEntry_s* self) { UNUSED(self); @@ -93,7 +98,6 @@ void statsOnDisarm(void) if (saveRequired) { /* signal that stats need to be saved but don't execute time consuming flash operation now - let the disarming process complete and then execute the actual save */ - dispatchEnable(); dispatchAdd(&writeStatsEntry, STATS_SAVE_DELAY_US); } } diff --git a/src/main/fc/stats.h b/src/main/fc/stats.h index 01554930c..831f7a7b1 100644 --- a/src/main/fc/stats.h +++ b/src/main/fc/stats.h @@ -20,5 +20,7 @@ #pragma once +void statsInit(void); + void statsOnArm(void); void statsOnDisarm(void);