Commit 066ffe31 authored by Gus Grubba's avatar Gus Grubba

Done

parent 88b201ef
This diff is collapsed.
...@@ -28,8 +28,7 @@ public: ...@@ -28,8 +28,7 @@ public:
AssignedButtonAction(QObject* parent, const QString name); AssignedButtonAction(QObject* parent, const QString name);
QString action; QString action;
QTime buttonTime; QTime buttonTime;
bool repeat = false; bool repeat = false;
int frequency = 1;
}; };
//-- Assignable Button Action //-- Assignable Button Action
...@@ -100,14 +99,15 @@ public: ...@@ -100,14 +99,15 @@ public:
Q_PROPERTY(bool gimbalEnabled READ gimbalEnabled WRITE setGimbalEnabled NOTIFY gimbalEnabledChanged) Q_PROPERTY(bool gimbalEnabled READ gimbalEnabled WRITE setGimbalEnabled NOTIFY gimbalEnabledChanged)
Q_PROPERTY(int throttleMode READ throttleMode WRITE setThrottleMode NOTIFY throttleModeChanged) Q_PROPERTY(int throttleMode READ throttleMode WRITE setThrottleMode NOTIFY throttleModeChanged)
Q_PROPERTY(float frequency READ frequency WRITE setFrequency NOTIFY frequencyChanged) Q_PROPERTY(float axisFrequency READ axisFrequency WRITE setAxisFrequency NOTIFY axisFrequencyChanged)
Q_PROPERTY(float buttonFrequency READ buttonFrequency WRITE setButtonFrequency NOTIFY buttonFrequencyChanged)
Q_PROPERTY(bool negativeThrust READ negativeThrust WRITE setNegativeThrust NOTIFY negativeThrustChanged) Q_PROPERTY(bool negativeThrust READ negativeThrust WRITE setNegativeThrust NOTIFY negativeThrustChanged)
Q_PROPERTY(float exponential READ exponential WRITE setExponential NOTIFY exponentialChanged) Q_PROPERTY(float exponential READ exponential WRITE setExponential NOTIFY exponentialChanged)
Q_PROPERTY(bool accumulator READ accumulator WRITE setAccumulator NOTIFY accumulatorChanged) Q_PROPERTY(bool accumulator READ accumulator WRITE setAccumulator NOTIFY accumulatorChanged)
Q_PROPERTY(bool circleCorrection READ circleCorrection WRITE setCircleCorrection NOTIFY circleCorrectionChanged) Q_PROPERTY(bool circleCorrection READ circleCorrection WRITE setCircleCorrection NOTIFY circleCorrectionChanged)
Q_INVOKABLE void setButtonRepeat (int button, bool repeat); Q_INVOKABLE void setButtonRepeat (int button, bool repeat);
Q_INVOKABLE void setButtonFrequency (int button, int freq); Q_INVOKABLE bool getButtonRepeat (int button);
Q_INVOKABLE void setButtonAction (int button, const QString& action); Q_INVOKABLE void setButtonAction (int button, const QString& action);
Q_INVOKABLE QString getButtonAction (int button); Q_INVOKABLE QString getButtonAction (int button);
...@@ -144,32 +144,35 @@ public: ...@@ -144,32 +144,35 @@ public:
*/ */
virtual bool requiresCalibration(void) { return true; } virtual bool requiresCalibration(void) { return true; }
int throttleMode (); int throttleMode ();
void setThrottleMode (int mode); void setThrottleMode (int mode);
bool negativeThrust (); bool negativeThrust ();
void setNegativeThrust (bool allowNegative); void setNegativeThrust (bool allowNegative);
float exponential (); float exponential ();
void setExponential (float expo); void setExponential (float expo);
bool accumulator (); bool accumulator ();
void setAccumulator (bool accu); void setAccumulator (bool accu);
bool deadband (); bool deadband ();
void setDeadband (bool accu); void setDeadband (bool accu);
bool circleCorrection (); bool circleCorrection ();
void setCircleCorrection(bool circleCorrection); void setCircleCorrection(bool circleCorrection);
void setTXMode (int mode); void setTXMode (int mode);
int getTXMode () { return _transmitterMode; } int getTXMode () { return _transmitterMode; }
/// Set the current calibration mode /// Set the current calibration mode
void setCalibrationMode (bool calibrating); void setCalibrationMode (bool calibrating);
float frequency (); float axisFrequency () { return _axisFrequency; }
void setFrequency (float val); void setAxisFrequency (float val);
float buttonFrequency () { return _buttonFrequency; }
void setButtonFrequency(float val);
signals: signals:
// The raw signals are only meant for use by calibration // The raw signals are only meant for use by calibration
...@@ -196,7 +199,8 @@ signals: ...@@ -196,7 +199,8 @@ signals:
void buttonActionTriggered (int action); void buttonActionTriggered (int action);
void gimbalEnabledChanged (); void gimbalEnabledChanged ();
void frequencyChanged (); void axisFrequencyChanged ();
void buttonFrequencyChanged ();
void startContinuousZoom (int direction); void startContinuousZoom (int direction);
void stopContinuousZoom (); void stopContinuousZoom ();
void stepZoom (int direction); void stepZoom (int direction);
...@@ -262,7 +266,8 @@ protected: ...@@ -262,7 +266,8 @@ protected:
bool _accumulator = false; bool _accumulator = false;
bool _deadband = false; bool _deadband = false;
bool _circleCorrection = true; bool _circleCorrection = true;
float _frequency = 25.0f; float _axisFrequency = 25.0f;
float _buttonFrequency = 5.0f;
Vehicle* _activeVehicle = nullptr; Vehicle* _activeVehicle = nullptr;
bool _gimbalEnabled = false; bool _gimbalEnabled = false;
...@@ -292,13 +297,13 @@ private: ...@@ -292,13 +297,13 @@ private:
static const char* _calibratedSettingsKey; static const char* _calibratedSettingsKey;
static const char* _buttonActionNameKey; static const char* _buttonActionNameKey;
static const char* _buttonActionRepeatKey; static const char* _buttonActionRepeatKey;
static const char* _buttonActionFrequencyKey;
static const char* _throttleModeSettingsKey; static const char* _throttleModeSettingsKey;
static const char* _exponentialSettingsKey; static const char* _exponentialSettingsKey;
static const char* _accumulatorSettingsKey; static const char* _accumulatorSettingsKey;
static const char* _deadbandSettingsKey; static const char* _deadbandSettingsKey;
static const char* _circleCorrectionSettingsKey; static const char* _circleCorrectionSettingsKey;
static const char* _frequencySettingsKey; static const char* _axisFrequencySettingsKey;
static const char* _buttonFrequencySettingsKey;
static const char* _txModeSettingsKey; static const char* _txModeSettingsKey;
static const char* _fixedWingTXModeSettingsKey; static const char* _fixedWingTXModeSettingsKey;
static const char* _multiRotorTXModeSettingsKey; static const char* _multiRotorTXModeSettingsKey;
......
...@@ -168,19 +168,17 @@ void QmlObjectListModel::insert(int i, QObject* object) ...@@ -168,19 +168,17 @@ void QmlObjectListModel::insert(int i, QObject* object)
if (i < 0 || i > _objectList.count()) { if (i < 0 || i > _objectList.count()) {
qWarning() << "Invalid index index:count" << i << _objectList.count(); qWarning() << "Invalid index index:count" << i << _objectList.count();
} }
if(object) {
QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
// Look for a dirtyChanged signal on the object
// Look for a dirtyChanged signal on the object if (object->metaObject()->indexOfSignal(QMetaObject::normalizedSignature("dirtyChanged(bool)")) != -1) {
if (object->metaObject()->indexOfSignal(QMetaObject::normalizedSignature("dirtyChanged(bool)")) != -1) { if (!_skipDirtyFirstItem || i != 0) {
if (!_skipDirtyFirstItem || i != 0) { QObject::connect(object, SIGNAL(dirtyChanged(bool)), this, SLOT(_childDirtyChanged(bool)));
QObject::connect(object, SIGNAL(dirtyChanged(bool)), this, SLOT(_childDirtyChanged(bool))); }
} }
} }
_objectList.insert(i, object); _objectList.insert(i, object);
insertRows(i, 1); insertRows(i, 1);
setDirty(true); setDirty(true);
} }
......
...@@ -61,6 +61,9 @@ SetupPage { ...@@ -61,6 +61,9 @@ SetupPage {
QGCTabBar { QGCTabBar {
id: bar id: bar
width: parent.width width: parent.width
Component.onCompleted: {
currentIndex = _activeJoystick && _activeJoystick.calibrated ? 0 : 2
}
anchors.top: parent.top anchors.top: parent.top
QGCTabButton { QGCTabButton {
text: qsTr("General") text: qsTr("General")
......
...@@ -144,20 +144,38 @@ Item { ...@@ -144,20 +144,38 @@ Item {
visible: advancedSettings.checked visible: advancedSettings.checked
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Message Frequency //-- Axis Message Frequency
QGCLabel { QGCLabel {
text: qsTr("Message frequency (Hz):") text: qsTr("Axis frequency (Hz):")
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
visible: advancedSettings.checked visible: advancedSettings.checked
} }
QGCTextField { QGCTextField {
text: _activeJoystick.frequency text: _activeJoystick.axisFrequency
enabled: advancedSettings.checked enabled: advancedSettings.checked
validator: DoubleValidator { bottom: 0.25; top: 100.0; } validator: DoubleValidator { bottom: 0.25; top: 50.0; }
inputMethodHints: Qt.ImhFormattedNumbersOnly inputMethodHints: Qt.ImhFormattedNumbersOnly
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
onEditingFinished: { onEditingFinished: {
_activeJoystick.frequency = parseFloat(text) _activeJoystick.axisFrequency = parseFloat(text)
}
visible: advancedSettings.checked
}
//-----------------------------------------------------------------
//-- Button Repeat Frequency
QGCLabel {
text: qsTr("Button repeat frequency (Hz):")
Layout.alignment: Qt.AlignVCenter
visible: advancedSettings.checked
}
QGCTextField {
text: _activeJoystick.buttonFrequency
enabled: advancedSettings.checked
validator: DoubleValidator { bottom: 0.25; top: 50.0; }
inputMethodHints: Qt.ImhFormattedNumbersOnly
Layout.alignment: Qt.AlignVCenter
onEditingFinished: {
_activeJoystick.buttonFrequency = parseFloat(text)
} }
visible: advancedSettings.checked visible: advancedSettings.checked
} }
......
...@@ -46,7 +46,7 @@ Item { ...@@ -46,7 +46,7 @@ Item {
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
property bool pressed property bool pressed
property var currentAction: _activeJoystick ? _activeJoystick.assignableActions.get(buttonActionCombo.currentIndex) : null property var currentAssignableAction: _activeJoystick ? _activeJoystick.assignableActions.get(buttonActionCombo.currentIndex) : null
Rectangle { Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: ScreenTools.defaultFontPixelHeight * 1.5 width: ScreenTools.defaultFontPixelHeight * 1.5
...@@ -73,39 +73,23 @@ Item { ...@@ -73,39 +73,23 @@ Item {
if(_activeJoystick) { if(_activeJoystick) {
var i = find(_activeJoystick.buttonActions[modelData]) var i = find(_activeJoystick.buttonActions[modelData])
if(i < 0) i = 0 if(i < 0) i = 0
currentIndex = 0 currentIndex = i
} }
} }
} }
QGCCheckBox { QGCCheckBox {
id: repeatCheck id: repeatCheck
text: qsTr("Repeat") text: qsTr("Repeat")
enabled: currentAction && _activeJoystick.calibrated && currentAction.canRepeat enabled: currentAssignableAction && _activeJoystick.calibrated && currentAssignableAction.canRepeat
onClicked: { onClicked: {
_activeJoystick.setButtonRepeat(modelData, checked) _activeJoystick.setButtonRepeat(modelData, checked)
} }
anchors.verticalCenter: parent.verticalCenter
}
QGCComboBox {
width: ScreenTools.defaultFontPixelWidth * 10
model: ["1Hz","2Hz","5Hz","10Hz","25Hz"]
enabled: repeatCheck.checked
onActivated: {
var freq = 1;
switch(index) {
case 0: freq = 1; break;
case 1: freq = 2; break;
case 2: freq = 5; break;
case 3: freq = 10; break;
case 4: freq = 25; break;
}
_activeJoystick.setButtonFrequency(modelData, freq)
}
Component.onCompleted: { Component.onCompleted: {
if(_activeJoystick) {
checked = _activeJoystick.getButtonRepeat(modelData)
}
} }
anchors.verticalCenter: parent.verticalCenter
} }
Item { Item {
width: ScreenTools.defaultFontPixelWidth * 2 width: ScreenTools.defaultFontPixelWidth * 2
......
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