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

Done

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