mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
OP-493: Use multiple instances when using multiple accessory channels
This commit is contained in:
parent
1365542103
commit
a1d60cb77d
@ -76,7 +76,6 @@ static ArmState_t armState;
|
||||
static portTickType lastSysTime;
|
||||
|
||||
// Private functions
|
||||
static void updateAccessoryDesired(ManualControlCommandData * cmd);
|
||||
static void updateActuatorDesired(ManualControlCommandData * cmd);
|
||||
static void updateStabilizationDesired(ManualControlCommandData * cmd, ManualControlSettingsData * settings);
|
||||
static void processFlightMode(ManualControlSettingsData * settings, float flightMode);
|
||||
@ -268,10 +267,20 @@ static void manualControlTask(void *parameters)
|
||||
cmd.Throttle = scaledChannel[settings.Throttle];
|
||||
flightMode = scaledChannel[settings.FlightMode];
|
||||
|
||||
// Set accessory channels
|
||||
cmd.Accessory1 = (settings.Accessory1 != MANUALCONTROLSETTINGS_ACCESSORY1_NONE) ? scaledChannel[settings.Accessory1] : 0;
|
||||
cmd.Accessory2 = (settings.Accessory2 != MANUALCONTROLSETTINGS_ACCESSORY2_NONE) ? scaledChannel[settings.Accessory2] : 0;
|
||||
cmd.Accessory3 = (settings.Accessory3 != MANUALCONTROLSETTINGS_ACCESSORY3_NONE) ? scaledChannel[settings.Accessory3] : 0;
|
||||
AccessoryDesiredData accessory;
|
||||
// Set Accessory 1
|
||||
accessory.AccessoryVal = scaledChannel[settings.Accessory1];
|
||||
if(AccessoryDesiredInstSet(0, &accessory) != 0)
|
||||
AccessoryDesiredCreateInstance();
|
||||
// Set Accessory 2
|
||||
accessory.AccessoryVal = scaledChannel[settings.Accessory2];
|
||||
if(AccessoryDesiredInstSet(1, &accessory) != 0)
|
||||
AccessoryDesiredCreateInstance();
|
||||
// Set Accsesory 3
|
||||
accessory.AccessoryVal = scaledChannel[settings.Accessory3];
|
||||
if(AccessoryDesiredInstSet(2, &accessory) != 0)
|
||||
AccessoryDesiredCreateInstance();
|
||||
|
||||
|
||||
processFlightMode(&settings, flightMode);
|
||||
processArm(&cmd, &settings);
|
||||
@ -296,30 +305,17 @@ static void manualControlTask(void *parameters)
|
||||
break;
|
||||
case FLIGHTMODE_MANUAL:
|
||||
updateActuatorDesired(&cmd);
|
||||
updateAccessoryDesired(&cmd);
|
||||
break;
|
||||
case FLIGHTMODE_STABILIZED:
|
||||
updateStabilizationDesired(&cmd, &settings);
|
||||
updateAccessoryDesired(&cmd);
|
||||
break;
|
||||
case FLIGHTMODE_GUIDANCE:
|
||||
updateAccessoryDesired(&cmd);
|
||||
// TODO: Implement
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void updateAccessoryDesired(ManualControlCommandData * cmd)
|
||||
{
|
||||
AccessoryDesiredData accessory;
|
||||
AccessoryDesiredGet(&accessory);
|
||||
accessory.Accessory1 = cmd->Accessory1;
|
||||
accessory.Accessory2 = cmd->Accessory2;
|
||||
accessory.Accessory3 = cmd->Accessory3;
|
||||
AccessoryDesiredSet(&accessory);
|
||||
}
|
||||
|
||||
static void updateActuatorDesired(ManualControlCommandData * cmd)
|
||||
{
|
||||
ActuatorDesiredData actuator;
|
||||
|
@ -1,9 +1,7 @@
|
||||
<xml>
|
||||
<object name="AccessoryDesired" singleinstance="true" settings="false">
|
||||
<description>Desired Auxillary actuator settings. Comes from @ref ManualControlModule.</description>
|
||||
<field name="Accessory1" units="%" type="float" elements="1"/>
|
||||
<field name="Accessory2" units="%" type="float" elements="1" />
|
||||
<field name="Accessory3" units="%" type="float" elements="1" />
|
||||
<field name="AccessoryVal" units="" type="float" elements="1"/>
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
||||
<telemetryflight acked="false" updatemode="periodic" period="1000"/>
|
||||
|
@ -6,11 +6,7 @@
|
||||
<field name="Pitch" units="%" type="float" elements="1"/>
|
||||
<field name="Yaw" units="%" type="float" elements="1"/>
|
||||
<field name="Throttle" units="%" type="float" elements="1"/>
|
||||
|
||||
<field name="Accessory1" units="%" type="float" elements="1"/>
|
||||
<field name="Accessory2" units="%" type="float" elements="1"/>
|
||||
<field name="Accessory3" units="%" type="float" elements="1"/>
|
||||
<field name="Channel" units="us" type="uint16" elements="8"/>
|
||||
<field name="Channel" units="us" type="uint16" elements="8"/>
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
||||
<telemetryflight acked="false" updatemode="periodic" period="2000"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user