Commit 4f293495 authored by Gus Grubba's avatar Gus Grubba

Initial work

Add camera trigger
Add video start/stop/toggle recording
Add gimbal pitch and yaw
parent a732ca8b
This diff is collapsed.
......@@ -49,6 +49,8 @@ public:
pitchFunction,
yawFunction,
throttleFunction,
gimbalPitchFunction,
gimbalYawFunction,
maxFunction
} AxisFunction_t;
......@@ -155,12 +157,14 @@ signals:
void circleCorrectionChanged(bool circleCorrection);
/// Signal containing new joystick information
/// @param roll Range is -1:1, negative meaning roll left, positive meaning roll right
/// @param pitch Range i -1:1, negative meaning pitch down, positive meaning pitch up
/// @param yaw Range is -1:1, negative meaning yaw left, positive meaning yaw right
/// @param throttle Range is 0:1, 0 meaning no throttle, 1 meaning full throttle
/// @param roll Range is -1:1, negative meaning roll left, positive meaning roll right
/// @param pitch Range i -1:1, negative meaning pitch down, positive meaning pitch up
/// @param yaw Range is -1:1, negative meaning yaw left, positive meaning yaw right
/// @param throttle Range is 0:1, 0 meaning no throttle, 1 meaning full throttle
/// @param gimbalPitch Range is -1:1
/// @param gimbalYaw Range is -1:1
/// @param mode See Vehicle::JoystickMode_t enum
void manualControl(float roll, float pitch, float yaw, float throttle, quint16 buttons, int joystickMmode);
void manualControl (float roll, float pitch, float yaw, float throttle, float gimbalPitch, float gimbalYaw, quint16 buttons, int joystickMmode);
void buttonActionTriggered(int action);
......@@ -168,20 +172,24 @@ signals:
void stepZoom (int direction);
void stepCamera (int direction);
void stepStream (int direction);
void triggerCamera ();
void startVideoRecord ();
void stopVideoRecord ();
void toggleVideoRecord ();
protected:
void _setDefaultCalibration(void);
void _saveSettings(void);
void _loadSettings(void);
float _adjustRange(int value, Calibration_t calibration, bool withDeadbands);
void _buttonAction(const QString& action);
bool _validAxis(int axis);
bool _validButton(int button);
void _setDefaultCalibration ();
void _saveSettings ();
void _loadSettings ();
float _adjustRange (int value, Calibration_t calibration, bool withDeadbands);
void _buttonAction (const QString& action);
bool _validAxis (int axis);
bool _validButton (int button);
private:
virtual bool _open() = 0;
virtual void _close() = 0;
virtual bool _update() = 0;
virtual bool _open() = 0;
virtual void _close() = 0;
virtual bool _update() = 0;
virtual bool _getButton(int i) = 0;
virtual int _getAxis(int i) = 0;
......@@ -196,7 +204,23 @@ private:
protected:
bool _exitThread; ///< true: signal thread to exit
bool _exitThread = false; ///< true: signal thread to exit
bool _calibrationMode = false;
int* _rgAxisValues = nullptr;
Calibration_t* _rgCalibration = nullptr;
bool* _rgButtonValues = nullptr;
quint16 _lastButtonBits = 0;
ThrottleMode_t _throttleMode = ThrottleModeDownZero;
bool _negativeThrust = false;
float _exponential = 0;
bool _accumulator = false;
bool _deadband = false;
bool _circleCorrection = true;
float _frequency = 25.0f;
Vehicle* _activeVehicle = nullptr;
bool _pollingStartedForCalibration = false;
QString _name;
bool _calibrated;
......@@ -207,28 +231,10 @@ protected:
int _totalButtonCount;
static int _transmitterMode;
bool _calibrationMode;
int* _rgAxisValues;
Calibration_t* _rgCalibration;
int _rgFunctionAxis[maxFunction];
int _rgFunctionAxis[maxFunction] = {};
bool* _rgButtonValues;
QStringList _rgButtonActions;
quint16 _lastButtonBits;
ThrottleMode_t _throttleMode;
bool _negativeThrust;
float _exponential;
bool _accumulator;
bool _deadband;
bool _circleCorrection;
float _frequency;
Vehicle* _activeVehicle;
bool _pollingStartedForCalibration;
MultiVehicleManager* _multiVehicleManager;
......@@ -261,6 +267,10 @@ private:
static const char* _buttonActionPreviousStream;
static const char* _buttonActionNextCamera;
static const char* _buttonActionPreviousCamera;
static const char* _buttonActionTriggerCamera;
static const char* _buttonActionStartVideoRecord;
static const char* _buttonActionStopVideoRecord;
static const char* _buttonActionToggleVideoRecord;
private slots:
void _activeVehicleChanged(Vehicle* activeVehicle);
......
......@@ -27,7 +27,7 @@ SetupPage {
pageName: qsTr("Joystick")
pageDescription: qsTr("Joystick Setup is used to configure a calibrate joysticks.")
readonly property real _maxButtons: 16
readonly property real _maxButtons: 64
Connections {
target: joystickManager
......@@ -67,12 +67,12 @@ SetupPage {
id: axisMonitorDisplayComponent
Item {
property int axisValue: 0
property int deadbandValue: 0
property bool narrowIndicator: false
property color deadbandColor: "#8c161a"
property int axisValue: 0
property int deadbandValue: 0
property bool narrowIndicator: false
property color deadbandColor: "#8c161a"
property color __barColor: qgcPal.windowShade
property color __barColor: qgcPal.windowShade
// Bar
Rectangle {
......@@ -93,9 +93,9 @@ SetupPage {
color: deadbandColor
visible: controller.deadbandToggle
property real _percentDeadband: ((2 * deadbandValue) / (32768.0 * 2))
property real _deadbandWidth: parent.width * _percentDeadband
property real _deadbandPosition: (parent.width - _deadbandWidth) / 2
property real _percentDeadband: ((2 * deadbandValue) / (32768.0 * 2))
property real _deadbandWidth: parent.width * _percentDeadband
property real _deadbandPosition: (parent.width - _deadbandWidth) / 2
}
// Center point
......@@ -183,14 +183,12 @@ SetupPage {
height: ScreenTools.defaultFontPixelHeight
width: 100
sourceComponent: axisMonitorDisplayComponent
property bool mapped: controller.rollAxisMapped
property bool reversed: controller.rollAxisReversed
}
Connections {
target: _activeJoystick
onManualControl: rollLoader.item.axisValue = roll*32768.0
}
}
......@@ -212,14 +210,12 @@ SetupPage {
height: ScreenTools.defaultFontPixelHeight
width: 100
sourceComponent: axisMonitorDisplayComponent
property bool mapped: controller.pitchAxisMapped
property bool reversed: controller.pitchAxisReversed
}
Connections {
target: _activeJoystick
onManualControl: pitchLoader.item.axisValue = pitch*32768.0
}
}
......@@ -241,14 +237,12 @@ SetupPage {
height: ScreenTools.defaultFontPixelHeight
width: 100
sourceComponent: axisMonitorDisplayComponent
property bool mapped: controller.yawAxisMapped
property bool reversed: controller.yawAxisReversed
}
Connections {
target: _activeJoystick
onManualControl: yawLoader.item.axisValue = yaw*32768.0
}
}
......@@ -270,17 +264,70 @@ SetupPage {
height: ScreenTools.defaultFontPixelHeight
width: 100
sourceComponent: axisMonitorDisplayComponent
property bool mapped: controller.throttleAxisMapped
property bool reversed: controller.throttleAxisReversed
}
Connections {
target: _activeJoystick
onManualControl: throttleLoader.item.axisValue = _activeJoystick.negativeThrust ? -throttle*32768.0 : (-2*throttle+1)*32768.0
}
}
Item {
width: parent.width
height: defaultTextHeight * 2
QGCLabel {
id: gimbalPitchLabel
width: ScreenTools.defaultFontPixelWidth * 10
text: qsTr("Gimbal Pitch")
}
Loader {
id: gimbalPitchLoader
anchors.left: gimbalPitchLabel.right
anchors.right: parent.right
height: ScreenTools.defaultFontPixelHeight
width: 100
sourceComponent: axisMonitorDisplayComponent
property bool mapped: controller.gimbalPitchAxisMapped
property bool reversed: controller.gimbalPitchAxisReversed
}
Connections {
target: _activeJoystick
onManualControl: gimbalPitchLoader.item.axisValue = gimbalPitch * 32768.0
}
}
Item {
width: parent.width
height: defaultTextHeight * 2
QGCLabel {
id: gimbalYawLabel
width: ScreenTools.defaultFontPixelWidth * 10
text: qsTr("Gimbal Yaw")
}
Loader {
id: gimbalYawLoader
anchors.left: gimbalYawLabel.right
anchors.right: parent.right
height: ScreenTools.defaultFontPixelHeight
width: 100
sourceComponent: axisMonitorDisplayComponent
property bool mapped: controller.gimbalYawAxisMapped
property bool reversed: controller.gimbalYawAxisReversed
}
Connections {
target: _activeJoystick
onManualControl: gimbalYawLoader.item.axisValue = gimbalYaw * 32768.0
}
}
} // Column - Attitude Control labels
// Command Buttons
......@@ -291,14 +338,12 @@ SetupPage {
QGCButton {
id: skipButton
text: qsTr("Skip")
onClicked: controller.skipButtonClicked()
}
QGCButton {
id: cancelButton
text: qsTr("Cancel")
onClicked: controller.cancelButtonClicked()
}
......@@ -306,7 +351,6 @@ SetupPage {
id: nextButton
primary: true
text: qsTr("Calibrate")
onClicked: controller.nextButtonClicked()
}
} // Row - Buttons
......
This diff is collapsed.
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