diff --git a/flight/Modules/CameraStab/camerastab.c b/flight/Modules/CameraStab/camerastab.c index bff87d892..770ff7ab6 100644 --- a/flight/Modules/CameraStab/camerastab.c +++ b/flight/Modules/CameraStab/camerastab.c @@ -62,8 +62,6 @@ // Private variables -static uint8_t camerastabEnabled = 0; - // Private functions static void attitudeUpdated(UAVObjEvent* ev); static float bound(float val); @@ -76,16 +74,18 @@ int32_t CameraStabInitialize(void) { static UAVObjEvent ev; - HwSettingsInitialize(); + bool cameraStabEnabled; uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM]; - HwSettingsOptionalModulesGet(optionalModules); - if (optionalModules[HWSETTINGS_OPTIONALMODULES_CAMERASTAB] == HWSETTINGS_OPTIONALMODULES_ENABLED) { - camerastabEnabled=1; - } else { - camerastabEnabled=0; - } - if (camerastabEnabled) { + HwSettingsInitialize(); + HwSettingsOptionalModulesGet(optionalModules); + + if (optionalModules[HWSETTINGS_OPTIONALMODULES_CAMERASTAB] == HWSETTINGS_OPTIONALMODULES_ENABLED) + cameraStabEnabled = true; + else + cameraStabEnabled = false; + + if (cameraStabEnabled) { AttitudeActualInitialize(); diff --git a/flight/Modules/GPS/GPS.c b/flight/Modules/GPS/GPS.c index deef4fcbe..bc8f92c17 100644 --- a/flight/Modules/GPS/GPS.c +++ b/flight/Modules/GPS/GPS.c @@ -120,14 +120,16 @@ int32_t GPSStart(void) int32_t GPSInitialize(void) { gpsPort = PIOS_COM_GPS; + HwSettingsInitialize(); uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM]; + HwSettingsOptionalModulesGet(optionalModules); - if (optionalModules[HWSETTINGS_OPTIONALMODULES_GPS] == HWSETTINGS_OPTIONALMODULES_ENABLED) { + + if (optionalModules[HWSETTINGS_OPTIONALMODULES_GPS] == HWSETTINGS_OPTIONALMODULES_ENABLED) gpsEnabled = true; - } else { + else gpsEnabled = false; - } if (gpsPort && gpsEnabled) { GPSPositionInitialize(); @@ -149,6 +151,7 @@ int32_t GPSInitialize(void) return -1; } + MODULE_INITCALL(GPSInitialize, GPSStart) // ****************