Commit 6822b461 authored by Jacob Walser's avatar Jacob Walser

Allow TX mode selection for joystick calibration

parent f1b82fb9
......@@ -253,17 +253,6 @@
<file alias="radioThrottleDown.png">resources/calibration/mode2/radioThrottleDown.png</file>
<file alias="radioSwitchMinMax.png">resources/calibration/mode2/radioSwitchMinMax.png</file>
</qresource>
<qresource prefix="/qml/calibration/joystick">
<file alias="joystickCenter.png">resources/calibration/joystick/joystickCenter.png</file>
<file alias="joystickRollLeft.png">resources/calibration/joystick/joystickRollLeft.png</file>
<file alias="joystickRollRight.png">resources/calibration/joystick/joystickRollRight.png</file>
<file alias="joystickPitchUp.png">resources/calibration/joystick/joystickPitchUp.png</file>
<file alias="joystickPitchDown.png">resources/calibration/joystick/joystickPitchDown.png</file>
<file alias="joystickYawLeft.png">resources/calibration/joystick/joystickYawLeft.png</file>
<file alias="joystickYawRight.png">resources/calibration/joystick/joystickYawRight.png</file>
<file alias="joystickThrottleUp.png">resources/calibration/joystick/joystickThrottleUp.png</file>
<file alias="joystickThrottleDown.png">resources/calibration/joystick/joystickThrottleDown.png</file>
</qresource>
<qresource prefix="/db/mapping/joystick">
<file alias="gamecontrollerdb.txt">resources/SDL_GameControllerDB/gamecontrollerdb.txt</file>
</qresource>
......@@ -277,4 +266,48 @@
<qresource prefix="/opengl">
<file>resources/opengl/buglist.json</file>
</qresource>
<qresource prefix="/qml/calibration/joystick/mode1">
<file alias="joystickCenter.png">resources/calibration/joystick/mode1/joystickCenter.png</file>
<file alias="joystickPitchDown.png">resources/calibration/joystick/mode1/joystickPitchDown.png</file>
<file alias="joystickPitchUp.png">resources/calibration/joystick/mode1/joystickPitchUp.png</file>
<file alias="joystickRollLeft.png">resources/calibration/joystick/mode1/joystickRollLeft.png</file>
<file alias="joystickRollRight.png">resources/calibration/joystick/mode1/joystickRollRight.png</file>
<file alias="joystickThrottleDown.png">resources/calibration/joystick/mode1/joystickThrottleDown.png</file>
<file alias="joystickThrottleUp.png">resources/calibration/joystick/mode1/joystickThrottleUp.png</file>
<file alias="joystickYawLeft.png">resources/calibration/joystick/mode1/joystickYawLeft.png</file>
<file alias="joystickYawRight.png">resources/calibration/joystick/mode1/joystickYawRight.png</file>
</qresource>
<qresource prefix="/qml/calibration/joystick/mode2">
<file alias="joystickCenter.png">resources/calibration/joystick/mode2/joystickCenter.png</file>
<file alias="joystickPitchDown.png">resources/calibration/joystick/mode2/joystickPitchDown.png</file>
<file alias="joystickPitchUp.png">resources/calibration/joystick/mode2/joystickPitchUp.png</file>
<file alias="joystickRollLeft.png">resources/calibration/joystick/mode2/joystickRollLeft.png</file>
<file alias="joystickRollRight.png">resources/calibration/joystick/mode2/joystickRollRight.png</file>
<file alias="joystickThrottleDown.png">resources/calibration/joystick/mode2/joystickThrottleDown.png</file>
<file alias="joystickThrottleUp.png">resources/calibration/joystick/mode2/joystickThrottleUp.png</file>
<file alias="joystickYawLeft.png">resources/calibration/joystick/mode2/joystickYawLeft.png</file>
<file alias="joystickYawRight.png">resources/calibration/joystick/mode2/joystickYawRight.png</file>
</qresource>
<qresource prefix="/qml/calibration/joystick/mode3">
<file alias="joystickCenter.png">resources/calibration/joystick/mode3/joystickCenter.png</file>
<file alias="joystickPitchDown.png">resources/calibration/joystick/mode3/joystickPitchDown.png</file>
<file alias="joystickPitchUp.png">resources/calibration/joystick/mode3/joystickPitchUp.png</file>
<file alias="joystickRollLeft.png">resources/calibration/joystick/mode3/joystickRollLeft.png</file>
<file alias="joystickRollRight.png">resources/calibration/joystick/mode3/joystickRollRight.png</file>
<file alias="joystickThrottleDown.png">resources/calibration/joystick/mode3/joystickThrottleDown.png</file>
<file alias="joystickThrottleUp.png">resources/calibration/joystick/mode3/joystickThrottleUp.png</file>
<file alias="joystickYawLeft.png">resources/calibration/joystick/mode3/joystickYawLeft.png</file>
<file alias="joystickYawRight.png">resources/calibration/joystick/mode3/joystickYawRight.png</file>
</qresource>
<qresource prefix="/qml/calibration/joystick/mode4">
<file alias="joystickCenter.png">resources/calibration/joystick/mode4/joystickCenter.png</file>
<file alias="joystickPitchDown.png">resources/calibration/joystick/mode4/joystickPitchDown.png</file>
<file alias="joystickPitchUp.png">resources/calibration/joystick/mode4/joystickPitchUp.png</file>
<file alias="joystickRollLeft.png">resources/calibration/joystick/mode4/joystickRollLeft.png</file>
<file alias="joystickRollRight.png">resources/calibration/joystick/mode4/joystickRollRight.png</file>
<file alias="joystickThrottleDown.png">resources/calibration/joystick/mode4/joystickThrottleDown.png</file>
<file alias="joystickThrottleUp.png">resources/calibration/joystick/mode4/joystickThrottleUp.png</file>
<file alias="joystickYawLeft.png">resources/calibration/joystick/mode4/joystickYawLeft.png</file>
<file alias="joystickYawRight.png">resources/calibration/joystick/mode4/joystickYawRight.png</file>
</qresource>
</RCC>
......@@ -643,12 +643,53 @@ SetupPage {
id: rightColumn
anchors.top: parent.top
anchors.right: parent.right
width: defaultTextWidth * 35
spacing: 10
width: Math.min(joystickPage.defaultTextWidth * 35, availableWidth * 0.4)
spacing: ScreenTools.defaultFontPixelHeight / 2
Row {
spacing: ScreenTools.defaultFontPixelWidth
ExclusiveGroup { id: modeGroup }
QGCLabel {
text: "TX Mode:"
}
QGCRadioButton {
exclusiveGroup: modeGroup
text: "1"
checked: controller.transmitterMode == 1
onClicked: controller.transmitterMode = 1
}
QGCRadioButton {
exclusiveGroup: modeGroup
text: "2"
checked: controller.transmitterMode == 2
onClicked: controller.transmitterMode = 2
}
QGCRadioButton {
exclusiveGroup: modeGroup
text: "3"
checked: controller.transmitterMode == 3
onClicked: controller.transmitterMode = 3
}
QGCRadioButton {
exclusiveGroup: modeGroup
text: "4"
checked: controller.transmitterMode == 4
onClicked: controller.transmitterMode = 4
}
}
Image {
//width: parent.width
height: defaultTextHeight * 15
width: parent.width
fillMode: Image.PreserveAspectFit
smooth: true
source: controller.imageHelp
......
......@@ -29,8 +29,11 @@ const int JoystickConfigController::_calMinDelta = 1000; ///< Amo
const int JoystickConfigController::_stickDetectSettleMSecs = 500;
const char* JoystickConfigController::_imageFilePrefix = "calibration/";
const char* JoystickConfigController::_imageFileMode2Dir = "joystick/";
const char* JoystickConfigController::_imageFilePrefix = "calibration/joystick/";
const char* JoystickConfigController::_imageFileMode1Dir = "mode1/";
const char* JoystickConfigController::_imageFileMode2Dir = "mode2/";
const char* JoystickConfigController::_imageFileMode3Dir = "mode3/";
const char* JoystickConfigController::_imageFileMode4Dir = "mode4/";
const char* JoystickConfigController::_imageCenter = "joystickCenter.png";
const char* JoystickConfigController::_imageThrottleUp = "joystickThrottleUp.png";
const char* JoystickConfigController::_imageThrottleDown = "joystickThrottleDown.png";
......@@ -43,6 +46,7 @@ const char* JoystickConfigController::_imagePitchDown = "joystickPitchDown.p
JoystickConfigController::JoystickConfigController(void)
: _activeJoystick(NULL)
, _transmitterMode(2)
, _currentStep(-1)
, _axisCount(0)
, _rgAxisInfo(NULL)
......@@ -642,7 +646,23 @@ void JoystickConfigController::_setHelpImage(const char* imageFile)
{
QString file = _imageFilePrefix;
file += _imageFileMode2Dir;
switch(_transmitterMode) {
case 1:
file += _imageFileMode1Dir;
break;
case 2:
file += _imageFileMode2Dir;
break;
case 3:
file += _imageFileMode3Dir;
break;
case 4:
file += _imageFileMode4Dir;
break;
default:
Q_ASSERT(false);
}
file += imageFile;
qCDebug(JoystickConfigControllerLog) << "_setHelpImage" << file;
......@@ -784,6 +804,17 @@ bool JoystickConfigController::throttleAxisReversed(void)
}
}
void JoystickConfigController::setTransmitterMode(int mode)
{
if (mode == 1 || mode == 2 || mode == 3 || mode == 4) {
_transmitterMode = mode;
if (_currentStep != -1) {
const stateMachineEntry* state = _getStateMachineEntry(_currentStep);
_setHelpImage(state->image);
}
}
}
void JoystickConfigController::_signalAllAttiudeValueChanges(void)
{
emit rollAxisMappedChanged(rollAxisMapped());
......
......@@ -69,6 +69,7 @@ public:
Q_PROPERTY(bool deadbandToggle READ getDeadbandToggle WRITE setDeadbandToggle NOTIFY deadbandToggled)
Q_PROPERTY(int transmitterMode READ transmitterMode WRITE setTransmitterMode NOTIFY transmitterModeChanged)
Q_PROPERTY(QString imageHelp MEMBER _imageHelp NOTIFY imageHelpChanged)
Q_INVOKABLE void cancelButtonClicked(void);
......@@ -100,6 +101,9 @@ public:
void setDeadbandToggle(bool);
int axisCount(void);
int transmitterMode(void) { return _transmitterMode; }
void setTransmitterMode(int mode);
signals:
void axisValueChanged(int axis, int value);
......@@ -127,6 +131,7 @@ signals:
void deadbandToggled(bool value);
void imageHelpChanged(QString source);
void transmitterModeChanged(int mode);
// @brief Signalled when in unit test mode and a message box should be displayed by the next button
void nextButtonMessageBoxDisplayed(void);
......@@ -172,6 +177,7 @@ private:
Joystick* _activeJoystick;
int _transmitterMode;
int _currentStep; ///< Current step of state machine
const struct stateMachineEntry* _getStateMachineEntry(int step);
......@@ -211,7 +217,10 @@ private:
// Member variables
static const char* _imageFileMode1Dir;
static const char* _imageFileMode2Dir;
static const char* _imageFileMode3Dir;
static const char* _imageFileMode4Dir;
static const char* _imageFilePrefix;
static const char* _imageCenter;
static const char* _imageThrottleUp;
......
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