1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

Merged in f5soh/librepilot/LP-550_Flight_Modules_fixes (pull request #463)

LP-550 Flight Modules fixes

Approved-by: Lalanne Laurent <f5soh@free.fr>
Approved-by: Philippe Renon <philippe_renon@yahoo.fr>
Approved-by: Alessio Morale <alessiomorale@gmail.com>
This commit is contained in:
Lalanne Laurent 2018-01-24 20:01:19 +00:00 committed by Philippe Renon
commit a353661820
6 changed files with 42 additions and 25 deletions

View File

@ -93,15 +93,16 @@ int32_t AirspeedStart()
*/
int32_t AirspeedInitialize()
{
HwSettingsOptionalModulesData optionalModules;
HwSettingsOptionalModulesGet(&optionalModules);
#ifdef MODULE_AIRSPEED_BUILTIN
airspeedEnabled = true;
optionalModules.Airspeed = HWSETTINGS_OPTIONALMODULES_ENABLED;
HwSettingsOptionalModulesSet(&optionalModules);
#else
HwSettingsOptionalModulesOptions optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
HwSettingsOptionalModulesArrayGet(optionalModules);
if (optionalModules[HWSETTINGS_OPTIONALMODULES_AIRSPEED] == HWSETTINGS_OPTIONALMODULES_ENABLED) {
if (optionalModules.Airspeed == HWSETTINGS_OPTIONALMODULES_ENABLED) {
airspeedEnabled = true;
} else {
airspeedEnabled = false;

View File

@ -164,11 +164,15 @@ static void UpdateStabilizationDesired(bool doingIdent);
*/
int32_t AutoTuneInitialize(void)
{
#if defined(MODULE_AutoTune_BUILTIN)
moduleEnabled = true;
#else
HwSettingsOptionalModulesData optionalModules;
HwSettingsOptionalModulesGet(&optionalModules);
#if defined(MODULE_AUTOTUNE_BUILTIN)
moduleEnabled = true;
optionalModules.AutoTune = HWSETTINGS_OPTIONALMODULES_ENABLED;
HwSettingsOptionalModulesSet(&optionalModules);
#else
if (optionalModules.AutoTune == HWSETTINGS_OPTIONALMODULES_ENABLED) {
// even though the AutoTune module is automatically enabled
// (below, when the flight mode switch is configured to use autotune)
@ -180,7 +184,7 @@ int32_t AutoTuneInitialize(void)
// do it for them if they have autotune on their flight mode switch
moduleEnabled = AutoTuneFoundInFMS();
}
#endif /* defined(MODULE_AutoTune_BUILTIN) */
#endif /* defined(MODULE_AUTOTUNE_BUILTIN) */
if (moduleEnabled) {
AccessoryDesiredInitialize();

View File

@ -57,14 +57,10 @@
//
// Configuration
//
#define SAMPLE_PERIOD_MS 500
#define SAMPLE_PERIOD_MS 500
// Time since power on the cells detection is active
#define DETECTION_TIMEFRAME 60000
// Private types
// Private variables
static bool batteryEnabled = false;
#define DETECTION_TIMEFRAME 60000
#ifndef PIOS_ADC_VOLTAGE_PIN
#define PIOS_ADC_VOLTAGE_PIN -1
@ -92,12 +88,17 @@ static void GetNbCells(const FlightBatterySettingsData *batterySettings, FlightB
*/
int32_t BatteryInitialize(void)
{
#ifdef MODULE_BATTERY_BUILTIN
batteryEnabled = true;
#else
bool batteryEnabled;
HwSettingsOptionalModulesData optionalModules;
HwSettingsOptionalModulesGet(&optionalModules);
#ifdef MODULE_BATTERY_BUILTIN
batteryEnabled = true;
optionalModules.Battery = HWSETTINGS_OPTIONALMODULES_ENABLED;
HwSettingsOptionalModulesSet(&optionalModules);
#else
if (optionalModules.Battery == HWSETTINGS_OPTIONALMODULES_ENABLED) {
batteryEnabled = true;
} else {

View File

@ -92,13 +92,15 @@ int32_t CameraStabInitialize(void)
{
bool cameraStabEnabled;
#ifdef MODULE_CAMERASTAB_BUILTIN
cameraStabEnabled = true;
#else
HwSettingsOptionalModulesData optionalModules;
HwSettingsOptionalModulesGet(&optionalModules);
#ifdef MODULE_CAMERASTAB_BUILTIN
cameraStabEnabled = true;
optionalModules.CameraStab = HWSETTINGS_OPTIONALMODULES_ENABLED;
HwSettingsOptionalModulesSet(&optionalModules);
#else
if (optionalModules.CameraStab == HWSETTINGS_OPTIONALMODULES_ENABLED) {
cameraStabEnabled = true;
} else {

View File

@ -196,13 +196,15 @@ int32_t GPSStart(void)
int32_t GPSInitialize(void)
{
#ifdef MODULE_GPS_BUILTIN
gpsEnabled = true;
#else
HwSettingsOptionalModulesData optionalModules;
HwSettingsOptionalModulesGet(&optionalModules);
#ifdef MODULE_GPS_BUILTIN
gpsEnabled = true;
optionalModules.GPS = HWSETTINGS_OPTIONALMODULES_ENABLED;
HwSettingsOptionalModulesSet(&optionalModules);
#else
if (optionalModules.GPS == HWSETTINGS_OPTIONALMODULES_ENABLED) {
gpsEnabled = true;
} else {

View File

@ -100,15 +100,22 @@ static float scale(float val, float inMin, float inMax, float outMin, float outM
int32_t TxPIDInitialize(void)
{
bool txPIDEnabled;
HwSettingsOptionalModulesData optionalModules;
HwSettingsOptionalModulesGet(&optionalModules);
#ifdef MODULE_TXPID_BUILTIN
txPIDEnabled = true;
optionalModules.TxPID = HWSETTINGS_OPTIONALMODULES_ENABLED;
HwSettingsOptionalModulesSet(&optionalModules);
#else
if (optionalModules.TxPID == HWSETTINGS_OPTIONALMODULES_ENABLED) {
txPIDEnabled = true;
} else {
txPIDEnabled = false;
}
#endif
if (txPIDEnabled) {
TxPIDStatusInitialize();