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

OP-1740: GetSet use enums: Getting more files to conform to using enums instead of uint8_t...

This commit is contained in:
Rich von Lehe 2015-04-11 15:43:04 -05:00
parent b3a7a89dca
commit e6de41855b
14 changed files with 48 additions and 43 deletions

View File

@ -154,7 +154,7 @@ void plan_setup_returnToBase()
pathDesired.StartingVelocity = 0.0f; pathDesired.StartingVelocity = 0.0f;
pathDesired.EndingVelocity = 0.0f; pathDesired.EndingVelocity = 0.0f;
uint8_t ReturnToBaseNextCommand; FlightModeSettingsReturnToBaseNextCommandOptions ReturnToBaseNextCommand;
FlightModeSettingsReturnToBaseNextCommandGet(&ReturnToBaseNextCommand); FlightModeSettingsReturnToBaseNextCommandGet(&ReturnToBaseNextCommand);
pathDesired.ModeParameters[PATHDESIRED_MODEPARAMETER_GOTOENDPOINT_NEXTCOMMAND] = (float)ReturnToBaseNextCommand; pathDesired.ModeParameters[PATHDESIRED_MODEPARAMETER_GOTOENDPOINT_NEXTCOMMAND] = (float)ReturnToBaseNextCommand;
pathDesired.ModeParameters[PATHDESIRED_MODEPARAMETER_GOTOENDPOINT_UNUSED1] = 0.0f; pathDesired.ModeParameters[PATHDESIRED_MODEPARAMETER_GOTOENDPOINT_UNUSED1] = 0.0f;

View File

@ -74,7 +74,7 @@ int32_t configuration_check()
// Classify navigation capability // Classify navigation capability
#ifdef REVOLUTION #ifdef REVOLUTION
RevoSettingsInitialize(); RevoSettingsInitialize();
uint8_t revoFusion; RevoSettingsFusionAlgorithmOptions revoFusion;
RevoSettingsFusionAlgorithmGet(&revoFusion); RevoSettingsFusionAlgorithmGet(&revoFusion);
bool navCapableFusion; bool navCapableFusion;
switch (revoFusion) { switch (revoFusion) {
@ -104,8 +104,8 @@ int32_t configuration_check()
// For each available flight mode position sanity check the available // For each available flight mode position sanity check the available
// modes // modes
uint8_t num_modes; uint8_t num_modes;
uint8_t modes[FLIGHTMODESETTINGS_FLIGHTMODEPOSITION_NUMELEM]; FlightModeSettingsFlightModePositionOptions modes[FLIGHTMODESETTINGS_FLIGHTMODEPOSITION_NUMELEM];
uint8_t FlightModeAssistMap[STABILIZATIONSETTINGS_FLIGHTMODEASSISTMAP_NUMELEM]; StabilizationSettingsFlightModeAssistMapOptions FlightModeAssistMap[STABILIZATIONSETTINGS_FLIGHTMODEASSISTMAP_NUMELEM];
ManualControlSettingsFlightModeNumberGet(&num_modes); ManualControlSettingsFlightModeNumberGet(&num_modes);
StabilizationSettingsFlightModeAssistMapGet(FlightModeAssistMap); StabilizationSettingsFlightModeAssistMapGet(FlightModeAssistMap);
FlightModeSettingsFlightModePositionGet(modes); FlightModeSettingsFlightModePositionGet(modes);
@ -208,7 +208,7 @@ int32_t configuration_check()
} }
} }
uint8_t checks_disabled; FlightModeSettingsDisableSanityChecksOptions checks_disabled;
FlightModeSettingsDisableSanityChecksGet(&checks_disabled); FlightModeSettingsDisableSanityChecksGet(&checks_disabled);
if (checks_disabled == FLIGHTMODESETTINGS_DISABLESANITYCHECKS_TRUE) { if (checks_disabled == FLIGHTMODESETTINGS_DISABLESANITYCHECKS_TRUE) {
severity = SYSTEMALARMS_ALARM_WARNING; severity = SYSTEMALARMS_ALARM_WARNING;
@ -236,22 +236,22 @@ static bool check_stabilization_settings(int index, bool multirotor, bool copter
// Get the different axis modes for this switch position // Get the different axis modes for this switch position
switch (index) { switch (index) {
case 1: case 1:
FlightModeSettingsStabilization1SettingsArrayGet(modes); FlightModeSettingsStabilization1SettingsArrayGet((FlightModeSettingsStabilization1SettingsOptions*) modes);
break; break;
case 2: case 2:
FlightModeSettingsStabilization2SettingsArrayGet(modes); FlightModeSettingsStabilization2SettingsArrayGet((FlightModeSettingsStabilization2SettingsOptions*) modes);
break; break;
case 3: case 3:
FlightModeSettingsStabilization3SettingsArrayGet(modes); FlightModeSettingsStabilization3SettingsArrayGet((FlightModeSettingsStabilization3SettingsOptions*) modes);
break; break;
case 4: case 4:
FlightModeSettingsStabilization4SettingsArrayGet(modes); FlightModeSettingsStabilization4SettingsArrayGet((FlightModeSettingsStabilization4SettingsOptions*) modes);
break; break;
case 5: case 5:
FlightModeSettingsStabilization5SettingsArrayGet(modes); FlightModeSettingsStabilization5SettingsArrayGet((FlightModeSettingsStabilization5SettingsOptions*) modes);
break; break;
case 6: case 6:
FlightModeSettingsStabilization6SettingsArrayGet(modes); FlightModeSettingsStabilization6SettingsArrayGet((FlightModeSettingsStabilization6SettingsOptions*) modes);
break; break;
default: default:
return false; return false;
@ -325,7 +325,7 @@ static bool check_stabilization_settings(int index, bool multirotor, bool copter
FrameType_t GetCurrentFrameType() FrameType_t GetCurrentFrameType()
{ {
uint8_t airframe_type; SystemSettingsAirframeTypeOptions airframe_type;
SystemSettingsAirframeTypeGet(&airframe_type); SystemSettingsAirframeTypeGet(&airframe_type);
switch ((SystemSettingsAirframeTypeOptions)airframe_type) { switch ((SystemSettingsAirframeTypeOptions)airframe_type) {

View File

@ -98,7 +98,7 @@ int32_t AirspeedInitialize()
#else #else
HwSettingsInitialize(); HwSettingsInitialize();
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM]; HwSettingsOptionalModulesOptions optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
HwSettingsOptionalModulesArrayGet(optionalModules); HwSettingsOptionalModulesArrayGet(optionalModules);
@ -110,7 +110,7 @@ int32_t AirspeedInitialize()
} }
#endif #endif
uint8_t adcRouting[HWSETTINGS_ADCROUTING_NUMELEM]; HwSettingsADCRoutingOptions adcRouting[HWSETTINGS_ADCROUTING_NUMELEM];
HwSettingsADCRoutingArrayGet(adcRouting); HwSettingsADCRoutingArrayGet(adcRouting);
// Determine if the barometric airspeed sensor is routed to an ADC pin // Determine if the barometric airspeed sensor is routed to an ADC pin

View File

@ -153,7 +153,7 @@ int32_t GPSStart(void)
int32_t GPSInitialize(void) int32_t GPSInitialize(void)
{ {
gpsPort = PIOS_COM_GPS; gpsPort = PIOS_COM_GPS;
uint8_t gpsProtocol; GPSSettingsDataProtocolOptions gpsProtocol;
#ifdef MODULE_GPS_BUILTIN #ifdef MODULE_GPS_BUILTIN
gpsEnabled = true; gpsEnabled = true;
@ -338,7 +338,7 @@ static void gpsTask(__attribute__((unused)) void *parameters)
(gpsSettings.DataProtocol == GPSSETTINGS_DATAPROTOCOL_UBX && gpspositionsensor.AutoConfigStatus == GPSPOSITIONSENSOR_AUTOCONFIGSTATUS_ERROR)) { (gpsSettings.DataProtocol == GPSSETTINGS_DATAPROTOCOL_UBX && gpspositionsensor.AutoConfigStatus == GPSPOSITIONSENSOR_AUTOCONFIGSTATUS_ERROR)) {
// we have not received any valid GPS sentences for a while. // we have not received any valid GPS sentences for a while.
// either the GPS is not plugged in or a hardware problem or the GPS has locked up. // either the GPS is not plugged in or a hardware problem or the GPS has locked up.
uint8_t status = GPSPOSITIONSENSOR_STATUS_NOGPS; GPSPositionSensorStatusOptions status = GPSPOSITIONSENSOR_STATUS_NOGPS;
GPSPositionSensorStatusSet(&status); GPSPositionSensorStatusSet(&status);
AlarmsSet(SYSTEMALARMS_ALARM_GPS, SYSTEMALARMS_ALARM_ERROR); AlarmsSet(SYSTEMALARMS_ALARM_GPS, SYSTEMALARMS_ALARM_ERROR);
} else { } else {
@ -439,7 +439,7 @@ static void updateHwSettings()
{ {
if (gpsPort) { if (gpsPort) {
// Retrieve settings // Retrieve settings
uint8_t speed; HwSettingsGPSSpeedOptions speed;
HwSettingsGPSSpeedGet(&speed); HwSettingsGPSSpeedGet(&speed);
// Set port speed // Set port speed

View File

@ -134,7 +134,7 @@ static void ControlUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
} }
DebugLogEntrySet(entry); DebugLogEntrySet(entry);
} else if (control.Operation == DEBUGLOGCONTROL_OPERATION_FORMATFLASH) { } else if (control.Operation == DEBUGLOGCONTROL_OPERATION_FORMATFLASH) {
uint8_t armed; FlightStatusArmedOptions armed;
FlightStatusArmedGet(&armed); FlightStatusArmedGet(&armed);
if (armed == FLIGHTSTATUS_ARMED_DISARMED) { if (armed == FLIGHTSTATUS_ARMED_DISARMED) {
PIOS_DEBUGLOG_Format(); PIOS_DEBUGLOG_Format();

View File

@ -182,7 +182,7 @@ static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
{ {
frameType = GetCurrentFrameType(); frameType = GetCurrentFrameType();
#ifndef PIOS_EXCLUDE_ADVANCED_FEATURES #ifndef PIOS_EXCLUDE_ADVANCED_FEATURES
uint8_t TreatCustomCraftAs; VtolPathFollowerSettingsTreatCustomCraftAsOptions TreatCustomCraftAs;
VtolPathFollowerSettingsTreatCustomCraftAsGet(&TreatCustomCraftAs); VtolPathFollowerSettingsTreatCustomCraftAsGet(&TreatCustomCraftAs);
@ -485,7 +485,7 @@ static uint8_t isAssistedFlightMode(uint8_t position, uint8_t flightMode, Flight
{ {
uint8_t flightModeAssistOption = STABILIZATIONSETTINGS_FLIGHTMODEASSISTMAP_NONE; uint8_t flightModeAssistOption = STABILIZATIONSETTINGS_FLIGHTMODEASSISTMAP_NONE;
uint8_t isAssistedFlag = FLIGHTSTATUS_FLIGHTMODEASSIST_NONE; uint8_t isAssistedFlag = FLIGHTSTATUS_FLIGHTMODEASSIST_NONE;
uint8_t FlightModeAssistMap[STABILIZATIONSETTINGS_FLIGHTMODEASSISTMAP_NUMELEM]; StabilizationSettingsFlightModeAssistMapOptions FlightModeAssistMap[STABILIZATIONSETTINGS_FLIGHTMODEASSISTMAP_NUMELEM];
StabilizationSettingsFlightModeAssistMapGet(FlightModeAssistMap); StabilizationSettingsFlightModeAssistMapGet(FlightModeAssistMap);
if (position < STABILIZATIONSETTINGS_FLIGHTMODEASSISTMAP_NUMELEM) { if (position < STABILIZATIONSETTINGS_FLIGHTMODEASSISTMAP_NUMELEM) {

View File

@ -55,9 +55,9 @@ void pathFollowerHandler(bool newinit)
plan_initialize(); plan_initialize();
} }
uint8_t flightMode; FlightStatusFlightModeOptions flightMode;
uint8_t assistedControlFlightMode; FlightStatusAssistedControlStateOptions assistedControlFlightMode;
uint8_t flightModeAssist; FlightStatusFlightModeAssistOptions flightModeAssist;
FlightStatusFlightModeGet(&flightMode); FlightStatusFlightModeGet(&flightMode);
FlightStatusFlightModeAssistGet(&flightModeAssist); FlightStatusFlightModeAssistGet(&flightModeAssist);
FlightStatusAssistedControlStateGet(&assistedControlFlightMode); FlightStatusAssistedControlStateGet(&assistedControlFlightMode);

View File

@ -96,27 +96,27 @@ void stabilizedHandler(bool newinit)
switch (flightStatus.FlightMode) { switch (flightStatus.FlightMode) {
case FLIGHTSTATUS_FLIGHTMODE_STABILIZED1: case FLIGHTSTATUS_FLIGHTMODE_STABILIZED1:
stab_settings = FlightModeSettingsStabilization1SettingsToArray(settings.Stabilization1Settings); stab_settings = (uint8_t*) FlightModeSettingsStabilization1SettingsToArray(settings.Stabilization1Settings);
break; break;
case FLIGHTSTATUS_FLIGHTMODE_STABILIZED2: case FLIGHTSTATUS_FLIGHTMODE_STABILIZED2:
stab_settings = FlightModeSettingsStabilization2SettingsToArray(settings.Stabilization2Settings); stab_settings = (uint8_t*) FlightModeSettingsStabilization2SettingsToArray(settings.Stabilization2Settings);
break; break;
case FLIGHTSTATUS_FLIGHTMODE_STABILIZED3: case FLIGHTSTATUS_FLIGHTMODE_STABILIZED3:
stab_settings = FlightModeSettingsStabilization3SettingsToArray(settings.Stabilization3Settings); stab_settings = (uint8_t*) FlightModeSettingsStabilization3SettingsToArray(settings.Stabilization3Settings);
break; break;
case FLIGHTSTATUS_FLIGHTMODE_STABILIZED4: case FLIGHTSTATUS_FLIGHTMODE_STABILIZED4:
stab_settings = FlightModeSettingsStabilization4SettingsToArray(settings.Stabilization4Settings); stab_settings = (uint8_t*) FlightModeSettingsStabilization4SettingsToArray(settings.Stabilization4Settings);
break; break;
case FLIGHTSTATUS_FLIGHTMODE_STABILIZED5: case FLIGHTSTATUS_FLIGHTMODE_STABILIZED5:
stab_settings = FlightModeSettingsStabilization5SettingsToArray(settings.Stabilization5Settings); stab_settings = (uint8_t*) FlightModeSettingsStabilization5SettingsToArray(settings.Stabilization5Settings);
break; break;
case FLIGHTSTATUS_FLIGHTMODE_STABILIZED6: case FLIGHTSTATUS_FLIGHTMODE_STABILIZED6:
stab_settings = FlightModeSettingsStabilization6SettingsToArray(settings.Stabilization6Settings); stab_settings = (uint8_t*) FlightModeSettingsStabilization6SettingsToArray(settings.Stabilization6Settings);
break; break;
default: default:
// Major error, this should not occur because only enter this block when one of these is true // Major error, this should not occur because only enter this block when one of these is true
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_CRITICAL); AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_CRITICAL);
stab_settings = FlightModeSettingsStabilization1SettingsToArray(settings.Stabilization1Settings); stab_settings = (uint8_t*) FlightModeSettingsStabilization1SettingsToArray(settings.Stabilization1Settings);
return; return;
} }

View File

@ -42,8 +42,8 @@ void takeOffLocationHandlerInit()
{ {
TakeOffLocationInitialize(); TakeOffLocationInitialize();
// check whether there is a preset/valid takeoff location // check whether there is a preset/valid takeoff location
uint8_t mode; TakeOffLocationModeOptions mode;
uint8_t status; TakeOffLocationStatusOptions status;
TakeOffLocationModeGet(&mode); TakeOffLocationModeGet(&mode);
TakeOffLocationStatusGet(&status); TakeOffLocationStatusGet(&status);
// preset with invalid location will actually behave like FirstTakeoff // preset with invalid location will actually behave like FirstTakeoff
@ -61,8 +61,8 @@ void takeOffLocationHandlerInit()
*/ */
void takeOffLocationHandler() void takeOffLocationHandler()
{ {
uint8_t armed; FlightStatusArmedOptions armed;
uint8_t status; TakeOffLocationStatusOptions status;
FlightStatusArmedGet(&armed); FlightStatusArmedGet(&armed);
@ -77,7 +77,7 @@ void takeOffLocationHandler()
case FLIGHTSTATUS_ARMED_ARMING: case FLIGHTSTATUS_ARMED_ARMING:
case FLIGHTSTATUS_ARMED_ARMED: case FLIGHTSTATUS_ARMED_ARMED:
if (!locationSet || status != TAKEOFFLOCATION_STATUS_VALID) { if (!locationSet || status != TAKEOFFLOCATION_STATUS_VALID) {
uint8_t mode; TakeOffLocationModeOptions mode;
TakeOffLocationModeGet(&mode); TakeOffLocationModeGet(&mode);
if ((mode != TAKEOFFLOCATION_MODE_PRESET) || (status == TAKEOFFLOCATION_STATUS_INVALID)) { if ((mode != TAKEOFFLOCATION_MODE_PRESET) || (status == TAKEOFFLOCATION_STATUS_INVALID)) {
@ -91,7 +91,7 @@ void takeOffLocationHandler()
case FLIGHTSTATUS_ARMED_DISARMED: case FLIGHTSTATUS_ARMED_DISARMED:
// unset if location is to be acquired at each arming // unset if location is to be acquired at each arming
if (locationSet) { if (locationSet) {
uint8_t mode; TakeOffLocationModeOptions mode;
TakeOffLocationModeGet(&mode); TakeOffLocationModeGet(&mode);
if (mode == TAKEOFFLOCATION_MODE_ARMINGLOCATION) { if (mode == TAKEOFFLOCATION_MODE_ARMINGLOCATION) {
locationSet = false; locationSet = false;

View File

@ -138,7 +138,7 @@ MODULE_INITCALL(PathPlannerInitialize, PathPlannerStart);
static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
{ {
uint8_t TreatCustomCraftAs; VtolPathFollowerSettingsTreatCustomCraftAsOptions TreatCustomCraftAs;
VtolPathFollowerSettingsTreatCustomCraftAsGet(&TreatCustomCraftAs); VtolPathFollowerSettingsTreatCustomCraftAsGet(&TreatCustomCraftAs);

View File

@ -334,7 +334,7 @@ static void stabilizationInnerloopTask()
} }
{ {
uint8_t armed; FlightStatusArmedOptions armed;
FlightStatusArmedGet(&armed); FlightStatusArmedGet(&armed);
float throttleDesired; float throttleDesired;
ManualControlCommandThrottleGet(&throttleDesired); ManualControlCommandThrottleGet(&throttleDesired);

View File

@ -264,7 +264,7 @@ static void stabilizationOuterloopTask()
RateDesiredSet(&rateDesired); RateDesiredSet(&rateDesired);
{ {
uint8_t armed; FlightStatusArmedOptions armed;
FlightStatusArmedGet(&armed); FlightStatusArmedGet(&armed);
float throttleDesired; float throttleDesired;
ManualControlCommandThrottleGet(&throttleDesired); ManualControlCommandThrottleGet(&throttleDesired);

View File

@ -685,7 +685,7 @@ static void updateSettings()
{ {
if (telemetryPort) { if (telemetryPort) {
// Retrieve settings // Retrieve settings
uint8_t speed; HwSettingsTelemetrySpeedOptions speed;
HwSettingsTelemetrySpeedGet(&speed); HwSettingsTelemetrySpeedGet(&speed);
// Set port speed // Set port speed

View File

@ -152,7 +152,7 @@ void PIOS_Board_Init(void)
/* Configure IO ports */ /* Configure IO ports */
/* Configure Telemetry port */ /* Configure Telemetry port */
uint8_t hwsettings_rv_telemetryport; HwSettingsRV_TelemetryPortOptions hwsettings_rv_telemetryport;
HwSettingsRV_TelemetryPortGet(&hwsettings_rv_telemetryport); HwSettingsRV_TelemetryPortGet(&hwsettings_rv_telemetryport);
switch (hwsettings_rv_telemetryport) { switch (hwsettings_rv_telemetryport) {
@ -164,10 +164,12 @@ void PIOS_Board_Init(void)
case HWSETTINGS_RV_TELEMETRYPORT_COMAUX: case HWSETTINGS_RV_TELEMETRYPORT_COMAUX:
PIOS_Board_configure_com(&pios_udp_telem_cfg, PIOS_COM_AUX_RX_BUF_LEN, PIOS_COM_AUX_TX_BUF_LEN, &pios_udp_com_driver, &pios_com_aux_id); PIOS_Board_configure_com(&pios_udp_telem_cfg, PIOS_COM_AUX_RX_BUF_LEN, PIOS_COM_AUX_TX_BUF_LEN, &pios_udp_com_driver, &pios_com_aux_id);
break; break;
default:
break;
} /* hwsettings_rv_telemetryport */ } /* hwsettings_rv_telemetryport */
/* Configure GPS port */ /* Configure GPS port */
uint8_t hwsettings_rv_gpsport; HwSettingsRV_GPSPortOptions hwsettings_rv_gpsport;
HwSettingsRV_GPSPortGet(&hwsettings_rv_gpsport); HwSettingsRV_GPSPortGet(&hwsettings_rv_gpsport);
switch (hwsettings_rv_gpsport) { switch (hwsettings_rv_gpsport) {
case HWSETTINGS_RV_GPSPORT_DISABLED: case HWSETTINGS_RV_GPSPORT_DISABLED:
@ -184,10 +186,12 @@ void PIOS_Board_Init(void)
case HWSETTINGS_RV_GPSPORT_COMAUX: case HWSETTINGS_RV_GPSPORT_COMAUX:
PIOS_Board_configure_com(&pios_udp_gps_cfg, PIOS_COM_AUX_RX_BUF_LEN, PIOS_COM_AUX_TX_BUF_LEN, &pios_udp_com_driver, &pios_com_aux_id); PIOS_Board_configure_com(&pios_udp_gps_cfg, PIOS_COM_AUX_RX_BUF_LEN, PIOS_COM_AUX_TX_BUF_LEN, &pios_udp_com_driver, &pios_com_aux_id);
break; break;
default:
break;
} /* hwsettings_rv_gpsport */ } /* hwsettings_rv_gpsport */
/* Configure AUXPort */ /* Configure AUXPort */
uint8_t hwsettings_rv_auxport; HwSettingsRV_AuxPortOptions hwsettings_rv_auxport;
HwSettingsRV_AuxPortGet(&hwsettings_rv_auxport); HwSettingsRV_AuxPortGet(&hwsettings_rv_auxport);
switch (hwsettings_rv_auxport) { switch (hwsettings_rv_auxport) {
@ -201,6 +205,7 @@ void PIOS_Board_Init(void)
case HWSETTINGS_RV_AUXPORT_COMAUX: case HWSETTINGS_RV_AUXPORT_COMAUX:
PIOS_Board_configure_com(&pios_udp_aux_cfg, PIOS_COM_AUX_RX_BUF_LEN, PIOS_COM_AUX_TX_BUF_LEN, &pios_udp_com_driver, &pios_com_aux_id); PIOS_Board_configure_com(&pios_udp_aux_cfg, PIOS_COM_AUX_RX_BUF_LEN, PIOS_COM_AUX_TX_BUF_LEN, &pios_udp_com_driver, &pios_com_aux_id);
break; break;
default:
break; break;
} /* hwsettings_rv_auxport */ } /* hwsettings_rv_auxport */
} }