Commit 9f33e4b2 authored by Gus Grubba's avatar Gus Grubba

Handle setup page completed at the setup root level

parent 366305f9
......@@ -33,15 +33,9 @@ SetupPage {
readonly property string dialogTitle: qsTr("Radio")
property bool controllerCompleted: false
property bool controllerAndViewReady: false
Component.onCompleted: {
if (controllerCompleted) {
controllerAndViewReady = true
controller.start()
updateChannelCount()
}
onSetupPageCompleted: {
controller.start()
updateChannelCount()
}
function updateChannelCount()
......@@ -56,14 +50,6 @@ SetupPage {
cancelButton: cancelButton
nextButton: nextButton
skipButton: skipButton
Component.onCompleted: {
controllerCompleted = true
controllerAndViewReady = true
controller.start()
updateChannelCount()
}
onChannelCountChanged: updateChannelCount()
onFunctionMappingChangedAPMReboot: mainWindow.showMessageDialog(qsTr("Reboot required"), qsTr("Your stick mappings have changed, you must reboot the vehicle for correct operation."))
onThrottleReversedCalFailure: mainWindow.showMessageDialog(qsTr("Throttle channel reversed"), qsTr("Calibration failed. The throttle channel on your transmitter is reversed. You must correct this on your transmitter in order to complete calibration."))
......@@ -71,10 +57,8 @@ SetupPage {
Component {
id: copyTrimsDialogComponent
QGCViewMessage {
message: qsTr("Center your sticks and move throttle all the way down, then press Ok to copy trims. After pressing Ok, reset the trims on your radio back to zero.")
function accept() {
hideDialog()
controller.copyTrims()
......@@ -84,11 +68,9 @@ SetupPage {
Component {
id: zeroTrimsDialogComponent
QGCViewMessage {
message: qsTr("Before calibrating you should zero all your trims and subtrims. Click Ok to start Calibration.\n\n%1").arg(
(QGroundControl.multiVehicleManager.activeVehicle.px4Firmware ? "" : qsTr("Please ensure all motor power is disconnected AND all props are removed from the vehicle.")))
function accept() {
hideDialog()
controller.nextButtonClicked()
......@@ -98,7 +80,6 @@ SetupPage {
Component {
id: channelCountDialogComponent
QGCViewMessage {
message: controller.channelCount == 0 ? qsTr("Please turn on transmitter.") : qsTr("%1 channels or more are needed to fly.").arg(controller.minChannelCount)
}
......@@ -106,7 +87,6 @@ SetupPage {
Component {
id: spektrumBindDialogComponent
QGCViewDialog {
function accept() {
......
......@@ -36,36 +36,36 @@ namespace Ui {
class RadioComponentController : public FactPanelController
{
Q_OBJECT
friend class RadioConfigTest; ///< This allows our unit test to access internal information needed.
public:
RadioComponentController(void);
~RadioComponentController();
Q_PROPERTY(int minChannelCount MEMBER _chanMinimum CONSTANT)
Q_PROPERTY(int channelCount READ channelCount NOTIFY channelCountChanged)
Q_PROPERTY(QQuickItem* statusText MEMBER _statusText NOTIFY statusTextChanged)
Q_PROPERTY(QQuickItem* cancelButton MEMBER _cancelButton NOTIFY cancelButtonChanged)
Q_PROPERTY(QQuickItem* nextButton MEMBER _nextButton NOTIFY nextButtonChanged)
Q_PROPERTY(QQuickItem* skipButton MEMBER _skipButton NOTIFY skipButtonChanged)
Q_PROPERTY(bool rollChannelMapped READ rollChannelMapped NOTIFY rollChannelMappedChanged)
Q_PROPERTY(bool pitchChannelMapped READ pitchChannelMapped NOTIFY pitchChannelMappedChanged)
Q_PROPERTY(bool yawChannelMapped READ yawChannelMapped NOTIFY yawChannelMappedChanged)
Q_PROPERTY(bool throttleChannelMapped READ throttleChannelMapped NOTIFY throttleChannelMappedChanged)
Q_PROPERTY(int rollChannelRCValue READ rollChannelRCValue NOTIFY rollChannelRCValueChanged)
Q_PROPERTY(int pitchChannelRCValue READ pitchChannelRCValue NOTIFY pitchChannelRCValueChanged)
Q_PROPERTY(int yawChannelRCValue READ yawChannelRCValue NOTIFY yawChannelRCValueChanged)
Q_PROPERTY(int throttleChannelRCValue READ throttleChannelRCValue NOTIFY throttleChannelRCValueChanged)
Q_PROPERTY(int rollChannelReversed READ rollChannelReversed NOTIFY rollChannelReversedChanged)
Q_PROPERTY(int pitchChannelReversed READ pitchChannelReversed NOTIFY pitchChannelReversedChanged)
Q_PROPERTY(int yawChannelReversed READ yawChannelReversed NOTIFY yawChannelReversedChanged)
Q_PROPERTY(int throttleChannelReversed READ throttleChannelReversed NOTIFY throttleChannelReversedChanged)
Q_PROPERTY(int transmitterMode READ transmitterMode WRITE setTransmitterMode NOTIFY transmitterModeChanged)
Q_PROPERTY(QString imageHelp MEMBER _imageHelp NOTIFY imageHelpChanged)
......@@ -82,27 +82,27 @@ public:
Q_INVOKABLE void nextButtonClicked(void);
Q_INVOKABLE void start(void);
Q_INVOKABLE void copyTrims(void);
int rollChannelRCValue(void);
int pitchChannelRCValue(void);
int yawChannelRCValue(void);
int throttleChannelRCValue(void);
bool rollChannelMapped(void);
bool pitchChannelMapped(void);
bool yawChannelMapped(void);
bool throttleChannelMapped(void);
bool rollChannelReversed(void);
bool pitchChannelReversed(void);
bool yawChannelReversed(void);
bool throttleChannelReversed(void);
int channelCount(void);
int transmitterMode(void) { return _transmitterMode; }
void setTransmitterMode(int mode);
signals:
void statusTextChanged(void);
void cancelButtonChanged(void);
......@@ -111,25 +111,25 @@ signals:
void channelCountChanged(int channelCount);
void channelRCValueChanged(int channel, int rcValue);
void rollChannelMappedChanged(bool mapped);
void pitchChannelMappedChanged(bool mapped);
void yawChannelMappedChanged(bool mapped);
void throttleChannelMappedChanged(bool mapped);
void rollChannelRCValueChanged(int rcValue);
void pitchChannelRCValueChanged(int rcValue);
void yawChannelRCValueChanged(int rcValue);
void throttleChannelRCValueChanged(int rcValue);
void rollChannelReversedChanged(bool reversed);
void pitchChannelReversedChanged(bool reversed);
void yawChannelReversedChanged(bool reversed);
void throttleChannelReversedChanged(bool reversed);
void imageHelpChanged(QString source);
void transmitterModeChanged(int mode);
/// Signalled when in unit test mode and a message box should be displayed by the next button
void nextButtonMessageBoxDisplayed(void);
......@@ -152,7 +152,7 @@ private:
rcCalFunctionThrottle,
rcCalFunctionMax,
};
/// @brief The states of the calibration state machine.
enum rcCalStates {
rcCalStateChannelWait,
......@@ -164,7 +164,7 @@ private:
rcCalStateTrims,
rcCalStateSave
};
typedef void (RadioComponentController::*inputFn)(enum rcCalFunctions function, int chan, int value);
typedef void (RadioComponentController::*buttonFn)(void);
struct stateMachineEntry {
......@@ -175,12 +175,12 @@ private:
buttonFn nextFn;
buttonFn skipFn;
};
/// @brief A set of information associated with a function.
struct FunctionInfo {
const char* parameterName; ///< Parameter name for function mapping
};
/// @brief A set of information associated with a radio channel.
struct ChannelInfo {
enum rcCalFunctions function; ///< Function mapped to this channel, rcCalFunctionMax for none
......@@ -189,47 +189,47 @@ private:
int rcMax; ///< Maximum RC value
int rcTrim; ///< Trim position
};
int _currentStep; ///< Current step of state machine
const struct stateMachineEntry* _getStateMachineEntry(int step) const;
const struct FunctionInfo* _functionInfo(void) const;
bool _px4Vehicle(void) const;
void _advanceState(void);
void _setupCurrentState(void);
void _inputCenterWaitBegin(enum rcCalFunctions function, int channel, int value);
void _inputStickDetect(enum rcCalFunctions function, int channel, int value);
void _inputStickMin(enum rcCalFunctions function, int channel, int value);
void _inputCenterWait(enum rcCalFunctions function, int channel, int value);
void _inputSwitchMinMax(enum rcCalFunctions function, int channel, int value);
void _inputSwitchDetect(enum rcCalFunctions function, int channel, int value);
void _switchDetect(enum rcCalFunctions function, int channel, int value, bool moveToNextStep);
void _saveAllTrims(void);
bool _stickSettleComplete(int value);
void _validateCalibration(void);
void _writeCalibration(void);
void _resetInternalCalibrationValues(void);
void _setInternalCalibrationValuesFromParameters(void);
void _startCalibration(void);
void _stopCalibration(void);
void _rcCalSave(void);
void _writeParameters(void);
void _rcCalSaveCurrentValues(void);
void _setHelpImage(const char* imageFile);
void _loadSettings(void);
void _storeSettings(void);
void _signalAllAttitudeValueChanges(void);
int _chanMax(void) const;
......@@ -239,7 +239,7 @@ private:
// @brief Called by unit test code to set the mode to unit testing
void _setUnitTestMode(void){ _unitTestMode = true; }
// Member variables
static const char* _imageFileMode1Dir;
......@@ -256,12 +256,12 @@ private:
static const char* _imagePitchUp;
static const char* _imagePitchDown;
static const char* _imageSwitchMinMax;
static const char* _settingsGroup;
static const char* _settingsKeyTransmitterMode;
int _transmitterMode; ///< 1: transmitter is mode 1, 2: transmitted is mode 2
static const int _updateInterval; ///< Interval for ui update timer
static const struct FunctionInfo _rgFunctionInfoAPM[rcCalFunctionMax]; ///< Information associated with each function, PX4 firmware
......@@ -280,13 +280,13 @@ private:
struct ChannelInfo _rgChannelInfo[_chanMaxAny]; ///< Information associated with each rc channel
QList<int> _apmPossibleMissingRCChannelParams; ///< List of possible missing RC*_* params for APM stack
enum rcCalStates _rcCalState; ///< Current calibration state
int _rcCalStateCurrentChannel; ///< Current channel being worked on in rcCalStateIdentify and rcCalStateDetectInversion
bool _rcCalStateChannelComplete; ///< Work associated with current channel is complete
int _rcCalStateIdentifyOldMapping; ///< Previous mapping for channel being currently identified
int _rcCalStateReverseOldMapping; ///< Previous mapping for channel being currently used to detect inversion
static const int _rcCalPWMCenterPoint;
static const int _rcCalPWMValidMinValue;
static const int _rcCalPWMValidMaxValue;
......@@ -303,25 +303,25 @@ private:
bool _revParamIsBool;
int _rcValueSave[_chanMaxAny]; ///< Saved values prior to detecting channel movement
int _rcRawValue[_chanMaxAny]; ///< Current set of raw channel values
int _stickDetectChannel;
int _stickDetectInitialValue;
int _stickDetectValue;
bool _stickDetectSettleStarted;
QTime _stickDetectSettleElapsed;
static const int _stickDetectSettleMSecs;
bool _unitTestMode;
QQuickItem* _statusText;
QQuickItem* _cancelButton;
QQuickItem* _nextButton;
QQuickItem* _skipButton;
bool _unitTestMode = false;
QQuickItem* _statusText = nullptr;
QQuickItem* _cancelButton = nullptr;
QQuickItem* _nextButton = nullptr;
QQuickItem* _skipButton = nullptr;
QString _imageHelp;
#ifdef UNITTEST_BUILD
// Nasty hack to expose controller to unit test code
static RadioComponentController* _unitTestController;
......
......@@ -25,13 +25,14 @@ Item {
id: setupView
enabled: !_disableDueToArmed && !_disableDueToFlying
property alias pageComponent: pageLoader.sourceComponent
property string pageName: vehicleComponent ? vehicleComponent.name : ""
property string pageDescription: vehicleComponent ? vehicleComponent.description : ""
property real availableWidth: width - pageLoader.x
property real availableHeight: height - pageLoader.y
property bool showAdvanced: false
property alias advanced: advancedCheckBox.checked
property alias pageComponent: pageLoader.sourceComponent
property string pageName: vehicleComponent ? vehicleComponent.name : ""
property string pageDescription: vehicleComponent ? vehicleComponent.description : ""
property real availableWidth: width - pageLoader.x
property real availableHeight: height - pageLoader.y
property bool showAdvanced: false
property alias advanced: advancedCheckBox.checked
property bool setupPageCompleted: false
property bool _vehicleIsRover: activeVehicle ? activeVehicle.rover : false
property bool _vehicleArmed: activeVehicle ? activeVehicle.armed : false
......@@ -43,6 +44,10 @@ Item {
property real _margins: ScreenTools.defaultFontPixelHeight * 0.5
property string _pageTitle: qsTr("%1 Setup").arg(pageName)
Component.onCompleted: {
setupPageCompleted = true
}
QGCFlickable {
anchors.fill: parent
contentWidth: pageLoader.x + pageLoader.item.width
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment