From 35509ee977411c112ea82f149fabe051419c91c5 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Mon, 12 Nov 2012 10:03:30 +0100 Subject: [PATCH] moved sanitycheck from system to manualcontrol to not break OSD and PipX targets Conflicts: flight/Modules/ManualControl/manualcontrol.c --- flight/Modules/ManualControl/manualcontrol.c | 23 ++++++++++++++++++++ flight/Modules/System/systemmod.c | 16 -------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/flight/Modules/ManualControl/manualcontrol.c b/flight/Modules/ManualControl/manualcontrol.c index 2c7a68575..f696162f1 100644 --- a/flight/Modules/ManualControl/manualcontrol.c +++ b/flight/Modules/ManualControl/manualcontrol.c @@ -34,6 +34,7 @@ */ #include "openpilot.h" +#include "sanitycheck.h" #include "manualcontrol.h" #include "manualcontrolsettings.h" #include "stabilizationsettings.h" @@ -47,6 +48,7 @@ #include "altitudeholddesired.h" #include "positionactual.h" #include "baroaltitude.h" +#include "systemsettings.h" #if defined(PIOS_INCLUDE_USB_RCTX) #include "pios_usb_rctx.h" @@ -89,6 +91,7 @@ static void altitudeHoldDesired(ManualControlCommandData * cmd); static void processFlightMode(ManualControlSettingsData * settings, float flightMode); static void processArm(ManualControlCommandData * cmd, ManualControlSettingsData * settings); static void setArmedIfChanged(uint8_t val); +static void configurationUpdatedCb(UAVObjEvent * ev); static void manualControlTask(void *parameters); static float scaleChannel(int16_t value, int16_t max, int16_t min, int16_t neutral); @@ -163,6 +166,15 @@ static void manualControlTask(void *parameters) AccessoryDesiredCreateInstance(); AccessoryDesiredCreateInstance(); + // Run this initially to make sure the configuration is checked + configuration_check(); + + // Whenever the configuration changes, make sure it is safe to fly + SystemSettingsConnectCallback(configurationUpdatedCb); + ManualControlSettingsConnectCallback(configurationUpdatedCb); + + // Whenever the configuration changes, make sure it is safe to fly + // Make sure unarmed on power up ManualControlCommandGet(&cmd); FlightStatusGet(&flightStatus); @@ -924,6 +936,17 @@ static void applyDeadband(float *value, float deadband) *value += deadband; } + +/** + * Called whenever a critical configuration component changes + */ +static void configurationUpdatedCb(UAVObjEvent * ev) +{ + configuration_check(); +} + + + /** * @} * @} diff --git a/flight/Modules/System/systemmod.c b/flight/Modules/System/systemmod.c index 8f5193c14..638af30ed 100644 --- a/flight/Modules/System/systemmod.c +++ b/flight/Modules/System/systemmod.c @@ -40,10 +40,8 @@ #include "openpilot.h" #include "systemmod.h" -#include "sanitycheck.h" #include "objectpersistence.h" #include "flightstatus.h" -#include "manualcontrolsettings.h" #include "systemstats.h" #include "systemsettings.h" #include "i2cstats.h" @@ -90,7 +88,6 @@ static bool mallocFailed; // Private functions static void objectUpdatedCb(UAVObjEvent * ev); -static void configurationUpdatedCb(UAVObjEvent * ev); static void hwSettingsUpdatedCb(UAVObjEvent * ev); static void updateStats(); static void updateSystemAlarms(); @@ -174,12 +171,7 @@ static void systemTask(void *parameters) // Listen for SettingPersistance object updates, connect a callback function ObjectPersistenceConnectQueue(objectPersistenceQueue); - // Run this initially to make sure the configuration is checked - configuration_check(); - // Whenever the configuration changes, make sure it is safe to fly - SystemSettingsConnectCallback(configurationUpdatedCb); - ManualControlSettingsConnectCallback(configurationUpdatedCb); HwSettingsConnectCallback(hwSettingsUpdatedCb); // Main system loop @@ -320,14 +312,6 @@ static void objectUpdatedCb(UAVObjEvent * ev) } } -/** - * Called whenever a critical configuration component changes - */ -static void configurationUpdatedCb(UAVObjEvent * ev) -{ - configuration_check(); -} - /** * Called whenever hardware settings changed */