mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14: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;
|
static portTickType lastSysTime;
|
||||||
|
|
||||||
// Private functions
|
// Private functions
|
||||||
static void updateAccessoryDesired(ManualControlCommandData * cmd);
|
|
||||||
static void updateActuatorDesired(ManualControlCommandData * cmd);
|
static void updateActuatorDesired(ManualControlCommandData * cmd);
|
||||||
static void updateStabilizationDesired(ManualControlCommandData * cmd, ManualControlSettingsData * settings);
|
static void updateStabilizationDesired(ManualControlCommandData * cmd, ManualControlSettingsData * settings);
|
||||||
static void processFlightMode(ManualControlSettingsData * settings, float flightMode);
|
static void processFlightMode(ManualControlSettingsData * settings, float flightMode);
|
||||||
@ -268,10 +267,20 @@ static void manualControlTask(void *parameters)
|
|||||||
cmd.Throttle = scaledChannel[settings.Throttle];
|
cmd.Throttle = scaledChannel[settings.Throttle];
|
||||||
flightMode = scaledChannel[settings.FlightMode];
|
flightMode = scaledChannel[settings.FlightMode];
|
||||||
|
|
||||||
// Set accessory channels
|
AccessoryDesiredData accessory;
|
||||||
cmd.Accessory1 = (settings.Accessory1 != MANUALCONTROLSETTINGS_ACCESSORY1_NONE) ? scaledChannel[settings.Accessory1] : 0;
|
// Set Accessory 1
|
||||||
cmd.Accessory2 = (settings.Accessory2 != MANUALCONTROLSETTINGS_ACCESSORY2_NONE) ? scaledChannel[settings.Accessory2] : 0;
|
accessory.AccessoryVal = scaledChannel[settings.Accessory1];
|
||||||
cmd.Accessory3 = (settings.Accessory3 != MANUALCONTROLSETTINGS_ACCESSORY3_NONE) ? scaledChannel[settings.Accessory3] : 0;
|
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);
|
processFlightMode(&settings, flightMode);
|
||||||
processArm(&cmd, &settings);
|
processArm(&cmd, &settings);
|
||||||
@ -296,30 +305,17 @@ static void manualControlTask(void *parameters)
|
|||||||
break;
|
break;
|
||||||
case FLIGHTMODE_MANUAL:
|
case FLIGHTMODE_MANUAL:
|
||||||
updateActuatorDesired(&cmd);
|
updateActuatorDesired(&cmd);
|
||||||
updateAccessoryDesired(&cmd);
|
|
||||||
break;
|
break;
|
||||||
case FLIGHTMODE_STABILIZED:
|
case FLIGHTMODE_STABILIZED:
|
||||||
updateStabilizationDesired(&cmd, &settings);
|
updateStabilizationDesired(&cmd, &settings);
|
||||||
updateAccessoryDesired(&cmd);
|
|
||||||
break;
|
break;
|
||||||
case FLIGHTMODE_GUIDANCE:
|
case FLIGHTMODE_GUIDANCE:
|
||||||
updateAccessoryDesired(&cmd);
|
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
break;
|
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)
|
static void updateActuatorDesired(ManualControlCommandData * cmd)
|
||||||
{
|
{
|
||||||
ActuatorDesiredData actuator;
|
ActuatorDesiredData actuator;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
<xml>
|
<xml>
|
||||||
<object name="AccessoryDesired" singleinstance="true" settings="false">
|
<object name="AccessoryDesired" singleinstance="true" settings="false">
|
||||||
<description>Desired Auxillary actuator settings. Comes from @ref ManualControlModule.</description>
|
<description>Desired Auxillary actuator settings. Comes from @ref ManualControlModule.</description>
|
||||||
<field name="Accessory1" units="%" type="float" elements="1"/>
|
<field name="AccessoryVal" units="" type="float" elements="1"/>
|
||||||
<field name="Accessory2" units="%" type="float" elements="1" />
|
|
||||||
<field name="Accessory3" units="%" type="float" elements="1" />
|
|
||||||
<access gcs="readwrite" flight="readwrite"/>
|
<access gcs="readwrite" flight="readwrite"/>
|
||||||
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
||||||
<telemetryflight acked="false" updatemode="periodic" period="1000"/>
|
<telemetryflight acked="false" updatemode="periodic" period="1000"/>
|
||||||
|
@ -6,11 +6,7 @@
|
|||||||
<field name="Pitch" units="%" type="float" elements="1"/>
|
<field name="Pitch" units="%" type="float" elements="1"/>
|
||||||
<field name="Yaw" units="%" type="float" elements="1"/>
|
<field name="Yaw" units="%" type="float" elements="1"/>
|
||||||
<field name="Throttle" units="%" type="float" elements="1"/>
|
<field name="Throttle" units="%" type="float" elements="1"/>
|
||||||
|
<field name="Channel" units="us" type="uint16" elements="8"/>
|
||||||
<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"/>
|
|
||||||
<access gcs="readwrite" flight="readwrite"/>
|
<access gcs="readwrite" flight="readwrite"/>
|
||||||
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
||||||
<telemetryflight acked="false" updatemode="periodic" period="2000"/>
|
<telemetryflight acked="false" updatemode="periodic" period="2000"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user