1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

TxPID: add update mode option as a workaround for GCS interaction

This commit is contained in:
Oleg Semyonov 2011-09-19 16:16:28 +03:00
parent aad263bdd8
commit a9137e9db1
2 changed files with 17 additions and 2 deletions

View File

@ -56,12 +56,13 @@
#include "accessorydesired.h"
#include "manualcontrolcommand.h"
#include "stabilizationsettings.h"
#include "flightstatus.h"
//
// Configuration
//
#define SAMPLE_PERIOD_MS 100
#define TELEMETRY_UPDATE_PERIOD_MS 1000 // 0 = update on change (default)
#define SAMPLE_PERIOD_MS 200
#define TELEMETRY_UPDATE_PERIOD_MS 0 // 0 = update on change (default)
// Sanity checks
#if (TXPIDSETTINGS_PIDS_NUMELEM != TXPIDSETTINGS_INPUTS_NUMELEM) || \
@ -97,6 +98,9 @@ int32_t TxPIDInitialize(void)
// Change StabilizationSettings update rate from OnChange to periodic
// to prevent telemetry link flooding with frequent updates in case of
// control channel jitter.
// Warning: saving to flash with this code active will change the
// StabilizationSettings update rate permanently. Use Metadata via
// browser to reset to defaults (telemetryAcked=true, OnChange).
UAVObjMetadata metadata;
StabilizationSettingsGetMetadata(&metadata);
metadata.telemetryAcked = 0;
@ -121,6 +125,16 @@ static void updatePIDs(UAVObjEvent* ev)
TxPIDSettingsData inst;
TxPIDSettingsGet(&inst);
if (inst.UpdateMode == TXPIDSETTINGS_UPDATEMODE_NEVER)
return;
uint8_t armed;
FlightStatusArmedGet(&armed);
if ((inst.UpdateMode == TXPIDSETTINGS_UPDATEMODE_WHENARMED) &&
(armed == FLIGHTSTATUS_ARMED_DISARMED))
return;
StabilizationSettingsData stab;
StabilizationSettingsGet(&stab);
AccessoryDesiredData accessory;

View File

@ -1,6 +1,7 @@
<xml>
<object name="TxPIDSettings" singleinstance="true" settings="true">
<description>Settings used by @ref TxPID optional module to tune PID settings using R/C transmitter</description>
<field name="UpdateMode" units="option" type="enum" elements="1" options="Never,When Armed,Always" defaultvalue="When Armed"/>
<field name="Inputs" units="channel" type="enum"
elementnames="Instance1,Instance2,Instance3"
options="Throttle,Accessory0,Accessory1,Accessory2,Accessory3,Accessory4,Accessory5"