mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
Merged in f5soh/librepilot/LP-478_Wizard_stick_do_not_move (pull request #384)
LP-478 TX Wizard issues
This commit is contained in:
commit
ae74c7f3f0
@ -10,7 +10,7 @@
|
||||
* pass it to ManualControl
|
||||
*
|
||||
* @file receiver.c
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015-2017.
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
|
||||
* @brief Receiver module. Handles safety R/C link and flight mode.
|
||||
*
|
||||
@ -68,7 +68,7 @@
|
||||
// safe band to allow a bit of calibration error or trim offset (in microseconds)
|
||||
#define CONNECTION_OFFSET 250
|
||||
|
||||
#define ASSISTEDCONTROL_DEADBAND_MINIMUM 2 // minimum value for a well bahaved Tx, in percent.
|
||||
#define ASSISTEDCONTROL_DEADBAND_MINIMUM 2 // minimum value for a well behaved Tx, in percent.
|
||||
|
||||
// Private types
|
||||
|
||||
@ -198,24 +198,21 @@ static void receiverTask(__attribute__((unused)) void *parameters)
|
||||
{
|
||||
ManualControlSettingsData settings;
|
||||
ManualControlCommandData cmd;
|
||||
FlightStatusData flightStatus;
|
||||
|
||||
uint8_t armed;
|
||||
uint8_t disconnected_count = 0;
|
||||
uint8_t connected_count = 0;
|
||||
|
||||
// For now manual instantiate extra instances of Accessory Desired. In future should be done dynamically
|
||||
// this includes not even registering it if not used
|
||||
AccessoryDesiredCreateInstance();
|
||||
AccessoryDesiredCreateInstance();
|
||||
AccessoryDesiredCreateInstance();
|
||||
AccessoryDesiredCreateInstance(); // Accessory1
|
||||
AccessoryDesiredCreateInstance(); // Accessory2
|
||||
AccessoryDesiredCreateInstance(); // Accessory3
|
||||
|
||||
// Rssi input
|
||||
AccessoryDesiredCreateInstance();
|
||||
|
||||
// Whenever the configuration changes, make sure it is safe to fly
|
||||
|
||||
ManualControlCommandGet(&cmd);
|
||||
FlightStatusGet(&flightStatus);
|
||||
|
||||
/* Initialize the RcvrActivty FSM */
|
||||
portTickType lastActivityTime = xTaskGetTickCount();
|
||||
@ -241,17 +238,20 @@ static void receiverTask(__attribute__((unused)) void *parameters)
|
||||
ManualControlSettingsGet(&settings);
|
||||
SystemSettingsThrustControlGet(&thrustType);
|
||||
|
||||
FlightStatusArmedGet(&armed);
|
||||
/* Update channel activity monitor */
|
||||
if (flightStatus.Armed == FLIGHTSTATUS_ARMED_DISARMED) {
|
||||
if (armed == FLIGHTSTATUS_ARMED_DISARMED) {
|
||||
if (updateRcvrActivity(&activity_fsm)) {
|
||||
/* Reset the aging timer because activity was detected */
|
||||
lastActivityTime = lastSysTime;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read signal quality from the group used for the throttle */
|
||||
(void)updateRcvrStatus(&activity_fsm,
|
||||
settings.ChannelGroups.Throttle,
|
||||
rssiValue);
|
||||
}
|
||||
|
||||
if (timeDifferenceMs(lastActivityTime, lastSysTime) > 5000) {
|
||||
resetRcvrActivity(&activity_fsm);
|
||||
resetRcvrStatus(&activity_fsm);
|
||||
@ -794,7 +794,9 @@ group_completed:
|
||||
return activity_updated;
|
||||
}
|
||||
|
||||
/* Read signal quality from the specified group or use Rssi input value if any */
|
||||
/**
|
||||
* Read signal quality from the specified group or use Rssi input value if any
|
||||
*/
|
||||
static bool updateRcvrStatus(
|
||||
struct rcvr_activity_fsm *fsm,
|
||||
ManualControlSettingsChannelGroupsOptions group, int8_t rssiValue)
|
||||
|
@ -58,7 +58,7 @@
|
||||
#define MAX_INPUT_US 2500
|
||||
|
||||
#define CHANNEL_NUMBER_NONE 0
|
||||
#define DEFAULT_FLIGHT_MODE_NUMBER 0
|
||||
#define DEFAULT_FLIGHT_MODE_NUMBER 1
|
||||
|
||||
ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
|
||||
ConfigTaskWidget(parent),
|
||||
@ -200,6 +200,8 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
|
||||
connect(ui->runCalibration, SIGNAL(toggled(bool)), this, SLOT(simpleCalibration(bool)));
|
||||
|
||||
connect(ReceiverActivity::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateReceiverActivityStatus()));
|
||||
connect(FlightStatus::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateReceiverActivityStatus()));
|
||||
|
||||
ui->receiverActivityStatus->setStyleSheet("QLabel { background-color: darkGreen; color: rgb(255, 255, 255); \
|
||||
border: 1px solid grey; border-radius: 5; margin:1px; font:bold;}");
|
||||
|
||||
@ -440,6 +442,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
|
||||
|
||||
groundChannelOrder << ManualControlSettings::CHANNELGROUPS_THROTTLE <<
|
||||
ManualControlSettings::CHANNELGROUPS_YAW <<
|
||||
ManualControlSettings::CHANNELGROUPS_FLIGHTMODE <<
|
||||
ManualControlSettings::CHANNELGROUPS_ACCESSORY0;
|
||||
}
|
||||
|
||||
@ -662,12 +665,8 @@ void ConfigInputWidget::wzNext()
|
||||
throttleError = false;
|
||||
checkThrottleRange();
|
||||
|
||||
// Force flight mode number to be 1 if 2 CH ground vehicle was selected
|
||||
if (transmitterType == ground) {
|
||||
forceOneFlightMode();
|
||||
}
|
||||
|
||||
manualSettingsObj->setData(manualSettingsData);
|
||||
|
||||
// move to Arming Settings tab
|
||||
ui->stackedWidget->setCurrentIndex(0);
|
||||
ui->tabWidget->setCurrentIndex(3);
|
||||
@ -843,12 +842,12 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
|
||||
extraWidgets.clear();
|
||||
for (int index = 0; index < manualSettingsObj->getField("ChannelMax")->getElementNames().length(); index++) {
|
||||
QString name = manualSettingsObj->getField("ChannelMax")->getElementNames().at(index);
|
||||
if (!name.contains("Access") && !name.contains("Flight") &&
|
||||
if (!name.contains("Access") && !name.contains("Flight") && !name.contains("Rssi") &&
|
||||
(!name.contains("Collective") || transmitterType == heli)) {
|
||||
QCheckBox *cb = new QCheckBox(name, this);
|
||||
// Make sure checked status matches current one
|
||||
cb->setChecked(manualSettingsData.ChannelMax[index] < manualSettingsData.ChannelMin[index]);
|
||||
wizardUi->checkBoxesLayout->addWidget(cb, extraWidgets.size() / 4, extraWidgets.size() % 4);
|
||||
wizardUi->checkBoxesLayout->addWidget(cb, extraWidgets.size() / 5, extraWidgets.size() % 5);
|
||||
extraWidgets.append(cb);
|
||||
connect(cb, SIGNAL(toggled(bool)), this, SLOT(invertControls()));
|
||||
}
|
||||
@ -917,12 +916,6 @@ void ConfigInputWidget::wizardTearDownStep(enum wizardSteps step)
|
||||
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(identifyControls()));
|
||||
wizardUi->wzNext->setEnabled(true);
|
||||
setTxMovement(nothing);
|
||||
/* If flight mode stick isn't identified, force flight mode number to be 1 */
|
||||
manualSettingsData = manualSettingsObj->getData();
|
||||
if (manualSettingsData.ChannelGroups[ManualControlSettings::CHANNELNUMBER_FLIGHTMODE] ==
|
||||
ManualControlSettings::CHANNELGROUPS_NONE) {
|
||||
forceOneFlightMode();
|
||||
}
|
||||
break;
|
||||
case wizardIdentifyCenter:
|
||||
manualCommandData = manualCommandObj->getData();
|
||||
@ -1182,6 +1175,7 @@ void ConfigInputWidget::identifyControls()
|
||||
void ConfigInputWidget::identifyLimits()
|
||||
{
|
||||
uint16_t inputValue;
|
||||
static uint16_t previousInputFMValue;
|
||||
bool newLimitValue = false;
|
||||
bool newFlightModeValue = false;
|
||||
|
||||
@ -1214,6 +1208,10 @@ void ConfigInputWidget::identifyLimits()
|
||||
}
|
||||
// Flightmode channel
|
||||
if (i == ManualControlSettings::CHANNELGROUPS_FLIGHTMODE) {
|
||||
int deltaInput = abs(previousInputFMValue - inputValue);
|
||||
previousInputFMValue = inputValue;
|
||||
// Expecting two consecutive readings within a close value
|
||||
if (deltaInput < 5) {
|
||||
// Avoid duplicate values too close and error due to RcTx drift
|
||||
int minSpacing = 100; // 100µs
|
||||
for (int pos = 0; pos < manualSettingsData.FlightModeNumber + 1; ++pos) {
|
||||
@ -1246,6 +1244,7 @@ void ConfigInputWidget::identifyLimits()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Save only if something changed
|
||||
if (newLimitValue || newFlightModeValue) {
|
||||
UAVObjectUpdaterHelper updateHelper;
|
||||
@ -2013,11 +2012,6 @@ void ConfigInputWidget::simpleCalibration(bool enable)
|
||||
|
||||
restoreMdataSingle(manualCommandObj, &manualControlMdata);
|
||||
|
||||
// Force flight mode number to be 1 if 2 channel ground vehicle was confirmed
|
||||
if (transmitterType == ground) {
|
||||
forceOneFlightMode();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < ManualControlSettings::CHANNELNUMBER_RSSI; i++) {
|
||||
if ((i == ManualControlSettings::CHANNELNUMBER_FLIGHTMODE) || (i == ManualControlSettings::CHANNELNUMBER_THROTTLE)) {
|
||||
adjustSpecialNeutrals();
|
||||
@ -2148,19 +2142,16 @@ void ConfigInputWidget::resetActuatorSettings()
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigInputWidget::forceOneFlightMode()
|
||||
{
|
||||
manualSettingsData = manualSettingsObj->getData();
|
||||
manualSettingsData.FlightModeNumber = 1;
|
||||
manualSettingsObj->setData(manualSettingsData);
|
||||
}
|
||||
|
||||
void ConfigInputWidget::updateReceiverActivityStatus()
|
||||
{
|
||||
ReceiverActivity *receiverActivity = ReceiverActivity::GetInstance(getObjectManager());
|
||||
|
||||
Q_ASSERT(receiverActivity);
|
||||
|
||||
FlightStatus *flightStatus = FlightStatus::GetInstance(getObjectManager());
|
||||
|
||||
Q_ASSERT(flightStatus);
|
||||
|
||||
UAVObjectField *activeGroup = receiverActivity->getField(QString("ActiveGroup"));
|
||||
Q_ASSERT(activeGroup);
|
||||
|
||||
@ -2170,12 +2161,15 @@ void ConfigInputWidget::updateReceiverActivityStatus()
|
||||
QString activeGroupText = activeGroup->getValue().toString();
|
||||
QString activeChannelText = activeChannel->getValue().toString();
|
||||
|
||||
|
||||
if (activeGroupText != "None") {
|
||||
ui->receiverActivityStatus->setText(tr("%1 input - Channel %2").arg(activeGroupText).arg(activeChannelText));
|
||||
ui->receiverActivityStatus->setStyleSheet("QLabel { background-color: green; color: rgb(255, 255, 255); \
|
||||
border: 1px solid grey; border-radius: 5; margin:1px; font:bold;}");
|
||||
} else {
|
||||
ui->receiverActivityStatus->setText(tr("No activity"));
|
||||
bool armed = (flightStatus->getArmed() == FlightStatus::ARMED_ARMED);
|
||||
QString receiverActivityText = armed ? tr("Disabled (Armed)") : tr("No activity");
|
||||
ui->receiverActivityStatus->setText(receiverActivityText);
|
||||
ui->receiverActivityStatus->setStyleSheet("QLabel { background-color: darkGreen; color: rgb(255, 255, 255); \
|
||||
border: 1px solid grey; border-radius: 5; margin:1px; font:bold;}");
|
||||
}
|
||||
|
@ -228,7 +228,6 @@ private slots:
|
||||
void resetChannelSettings();
|
||||
void resetFlightModeSettings();
|
||||
void resetActuatorSettings();
|
||||
void forceOneFlightMode();
|
||||
void updateReceiverActivityStatus();
|
||||
|
||||
void failsafeFlightModeChanged(int index);
|
||||
|
Loading…
Reference in New Issue
Block a user