Commit 5949ff7a authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4628 from nanthony21/joystickindicator

Changed joystick indicators to show output rather than input
parents 1991d269 09514ef7
......@@ -429,7 +429,7 @@ void RadioComponentController::_inputStickDetect(enum rcCalFunctions function, i
_rgChannelInfo[channel].rcMax = value;
}
_signalAllAttiudeValueChanges();
_signalAllAttitudeValueChanges();
_advanceState();
}
......@@ -582,7 +582,7 @@ void RadioComponentController::_resetInternalCalibrationValues(void)
_rgFunctionChannelMapping[i] = _chanMax();
}
_signalAllAttiudeValueChanges();
_signalAllAttitudeValueChanges();
}
/// @brief Sets internal calibration values from the stored parameters
......@@ -654,7 +654,7 @@ void RadioComponentController::_setInternalCalibrationValuesFromParameters(void)
}
}
_signalAllAttiudeValueChanges();
_signalAllAttitudeValueChanges();
}
void RadioComponentController::spektrumBindMode(int mode)
......@@ -1023,7 +1023,7 @@ void RadioComponentController::setTransmitterMode(int mode)
}
}
void RadioComponentController::_signalAllAttiudeValueChanges(void)
void RadioComponentController::_signalAllAttitudeValueChanges(void)
{
emit rollChannelMappedChanged(rollChannelMapped());
emit pitchChannelMappedChanged(pitchChannelMapped());
......
......@@ -230,7 +230,7 @@ private:
void _loadSettings(void);
void _storeSettings(void);
void _signalAllAttiudeValueChanges(void);
void _signalAllAttitudeValueChanges(void);
int _chanMax(void) const;
......
......@@ -84,8 +84,6 @@ SetupPage {
property int axisValue: 0
property int deadbandValue: 0
property int __lastAxisValue: 0
readonly property int __axisValueMaxJitter: 100
property color __barColor: qgcPal.windowShade
// Bar
......@@ -105,6 +103,7 @@ SetupPage {
width: _deadbandWidth
height: parent.height / 2
color: "#8c161a"
visible: controller.deadbandToggle
property real _percentDeadband: ((2 * deadbandValue) / (32768.0 * 2))
property real _deadbandWidth: parent.width * _percentDeadband
......@@ -203,11 +202,9 @@ SetupPage {
}
Connections {
target: controller
onRollAxisValueChanged: rollLoader.item.axisValue = value
target: _activeJoystick
onRollAxisDeadbandChanged: rollLoader.item.deadbandValue = value
onManualControl: rollLoader.item.axisValue = roll*32768.0
}
}
......@@ -235,12 +232,9 @@ SetupPage {
}
Connections {
target: controller
onPitchAxisValueChanged: pitchLoader.item.axisValue = value
onPitchAxisDeadbandChanged: pitchLoader.item.deadbandValue = value
target: _activeJoystick
onManualControl: pitchLoader.item.axisValue = pitch*32768.0
}
}
......@@ -268,11 +262,9 @@ SetupPage {
}
Connections {
target: controller
onYawAxisValueChanged: yawLoader.item.axisValue = value
target: _activeJoystick
onYawAxisDeadbandChanged: yawLoader.item.deadbandValue = value
onManualControl: yawLoader.item.axisValue = yaw*32768.0
}
}
......@@ -300,11 +292,9 @@ SetupPage {
}
Connections {
target: controller
onThrottleAxisValueChanged: throttleLoader.item.axisValue = value
target: _activeJoystick
onThrottleAxisDeadbandChanged: throttleLoader.item.deadbandValue = value
onManualControl: throttleLoader.item.axisValue = (-2*throttle+1)*32768.0
}
}
} // Column - Attitude Control labels
......@@ -746,6 +736,12 @@ SetupPage {
axisMonitorRepeater.itemAt(axis).loader.item.axisValue = value
}
}
onAxisDeadbandChanged: {
if (axisMonitorRepeater.itemAt(axis)) {
axisMonitorRepeater.itemAt(axis).loader.item.deadbandValue = value
}
}
}
Repeater {
......
......@@ -144,26 +144,6 @@ void JoystickConfigController::_axisValueChanged(int axis, int value)
// We always update raw values
_axisRawValue[axis] = value;
emit axisValueChanged(axis, _axisRawValue[axis]);
// Signal attitude axis values to Qml if mapped
if (_rgAxisInfo[axis].function != Joystick::maxFunction) {
switch (_rgAxisInfo[axis].function) {
case Joystick::rollFunction:
emit rollAxisValueChanged(_axisRawValue[axis]);
break;
case Joystick::pitchFunction:
emit pitchAxisValueChanged(_axisRawValue[axis]);
break;
case Joystick::yawFunction:
emit yawAxisValueChanged(_axisRawValue[axis]);
break;
case Joystick::throttleFunction:
emit throttleAxisValueChanged(_axisRawValue[axis]);
break;
default:
break;
}
}
//qCDebug(JoystickConfigControllerLog) << "Raw value" << axis << value;
......@@ -223,7 +203,7 @@ bool JoystickConfigController::getDeadbandToggle() {
void JoystickConfigController::setDeadbandToggle(bool deadband) {
_activeJoystick->setDeadband(deadband);
_signalAllAttiudeValueChanges();
_signalAllAttitudeValueChanges();
emit deadbandToggled(deadband);
}
......@@ -247,7 +227,7 @@ void JoystickConfigController::_axisDeadbandChanged(int axis, int value)
value = abs(value)<_calValidMaxValue?abs(value):_calValidMaxValue;
_rgAxisInfo[axis].deadband = value;
emit axisDeadbandChanged(axis,value);
qCDebug(JoystickConfigControllerLog) << "Axis:" << axis << "Deadband:" << _rgAxisInfo[axis].deadband;
}
......@@ -257,7 +237,7 @@ void JoystickConfigController::_inputCenterWaitBegin(Joystick::AxisFunction_t fu
Q_UNUSED(function);
//sensing deadband
if (abs(value)*1.1f>_rgAxisInfo[axis].deadband) { //add 10% on top of existing deadband
if ((abs(value)*1.1f>_rgAxisInfo[axis].deadband)&&(_activeJoystick->deadband())) { //add 10% on top of existing deadband
_axisDeadbandChanged(axis,abs(value)*1.1f);
}
......@@ -353,7 +333,7 @@ void JoystickConfigController::_inputStickDetect(Joystick::AxisFunction_t functi
qCDebug(JoystickConfigControllerLog) << "_inputStickDetect saving values, function:axis:value:reversed:_axisValueSave" << function << axis << value << info->reversed << _axisValueSave[axis];
_signalAllAttiudeValueChanges();
_signalAllAttitudeValueChanges();
_advanceState();
}
......@@ -451,6 +431,7 @@ void JoystickConfigController::_resetInternalCalibrationValues(void)
info->function = Joystick::maxFunction;
info->reversed = false;
info->deadband = 0;
emit axisDeadbandChanged(i,info->deadband);
info->axisMin = JoystickConfigController::_calCenterPoint;
info->axisMax = JoystickConfigController::_calCenterPoint;
info->axisTrim = JoystickConfigController::_calCenterPoint;
......@@ -461,7 +442,7 @@ void JoystickConfigController::_resetInternalCalibrationValues(void)
_rgFunctionAxisMapping[i] = _axisNoAxis;
}
_signalAllAttiudeValueChanges();
_signalAllAttitudeValueChanges();
}
/// @brief Sets internal calibration values from the stored settings
......@@ -489,6 +470,7 @@ void JoystickConfigController::_setInternalCalibrationValuesFromSettings(void)
info->axisMax = calibration.max;
info->reversed = calibration.reversed;
info->deadband = calibration.deadband;
emit axisDeadbandChanged(axis,info->deadband);
qCDebug(JoystickConfigControllerLog) << "Read settings name:axis:min:max:trim:reversed" << joystick->name() << axis << info->axisMin << info->axisMax << info->axisTrim << info->reversed;
}
......@@ -505,7 +487,7 @@ void JoystickConfigController::_setInternalCalibrationValuesFromSettings(void)
_transmitterMode = joystick->getTXMode();
_signalAllAttiudeValueChanges();
_signalAllAttitudeValueChanges();
}
/// @brief Validates the current settings against the calibration rules resetting values as necessary.
......@@ -683,77 +665,7 @@ int JoystickConfigController::axisCount(void)
return _axisCount;
}
int JoystickConfigController::rollAxisValue(void)
{
if (_rgFunctionAxisMapping[Joystick::rollFunction] != _axisNoAxis) {
return _axisRawValue[Joystick::rollFunction];
} else {
return 1500;
}
}
int JoystickConfigController::pitchAxisValue(void)
{
if (_rgFunctionAxisMapping[Joystick::pitchFunction] != _axisNoAxis) {
return _axisRawValue[Joystick::pitchFunction];
} else {
return 1500;
}
}
int JoystickConfigController::yawAxisValue(void)
{
if (_rgFunctionAxisMapping[Joystick::yawFunction] != _axisNoAxis) {
return _axisRawValue[Joystick::yawFunction];
} else {
return 1500;
}
}
int JoystickConfigController::throttleAxisValue(void)
{
if (_rgFunctionAxisMapping[Joystick::throttleFunction] != _axisNoAxis) {
return _axisRawValue[Joystick::throttleFunction];
} else {
return 1500;
}
}
int JoystickConfigController::rollAxisDeadband(void)
{
if ((_rgFunctionAxisMapping[Joystick::rollFunction] != _axisNoAxis) && (_activeJoystick->deadband())) {
return _rgAxisInfo[_rgFunctionAxisMapping[Joystick::rollFunction]].deadband;
} else {
return 0;
}
}
int JoystickConfigController::pitchAxisDeadband(void)
{
if ((_rgFunctionAxisMapping[Joystick::pitchFunction] != _axisNoAxis) && (_activeJoystick->deadband())) {
return _rgAxisInfo[_rgFunctionAxisMapping[Joystick::pitchFunction]].deadband;
} else {
return 0;
}
}
int JoystickConfigController::yawAxisDeadband(void)
{
if ((_rgFunctionAxisMapping[Joystick::yawFunction] != _axisNoAxis) && (_activeJoystick->deadband())) {
return _rgAxisInfo[_rgFunctionAxisMapping[Joystick::yawFunction]].deadband;
} else {
return 0;
}
}
int JoystickConfigController::throttleAxisDeadband(void)
{
if ((_rgFunctionAxisMapping[Joystick::throttleFunction] != _axisNoAxis) && (_activeJoystick->deadband())) {
return _rgAxisInfo[_rgFunctionAxisMapping[Joystick::throttleFunction]].deadband;
} else {
return 0;
}
}
bool JoystickConfigController::rollAxisMapped(void)
{
......@@ -825,7 +737,7 @@ void JoystickConfigController::setTransmitterMode(int mode)
}
}
void JoystickConfigController::_signalAllAttiudeValueChanges(void)
void JoystickConfigController::_signalAllAttitudeValueChanges(void)
{
emit rollAxisMappedChanged(rollAxisMapped());
emit pitchAxisMappedChanged(pitchAxisMapped());
......@@ -837,11 +749,6 @@ void JoystickConfigController::_signalAllAttiudeValueChanges(void)
emit yawAxisReversedChanged(yawAxisReversed());
emit throttleAxisReversedChanged(throttleAxisReversed());
emit rollAxisDeadbandChanged(rollAxisDeadband());
emit pitchAxisDeadbandChanged(pitchAxisDeadband());
emit yawAxisDeadbandChanged(yawAxisDeadband());
emit throttleAxisDeadbandChanged(throttleAxisDeadband());
emit transmitterModeChanged(_transmitterMode);
}
......
......@@ -52,16 +52,6 @@ public:
Q_PROPERTY(bool yawAxisMapped READ yawAxisMapped NOTIFY yawAxisMappedChanged)
Q_PROPERTY(bool throttleAxisMapped READ throttleAxisMapped NOTIFY throttleAxisMappedChanged)
Q_PROPERTY(int rollAxisValue READ rollAxisValue NOTIFY rollAxisValueChanged)
Q_PROPERTY(int pitchAxisValue READ pitchAxisValue NOTIFY pitchAxisValueChanged)
Q_PROPERTY(int yawAxisValue READ yawAxisValue NOTIFY yawAxisValueChanged)
Q_PROPERTY(int throttleAxisValue READ throttleAxisValue NOTIFY throttleAxisValueChanged)
Q_PROPERTY(int rollAxisDeadband READ rollAxisDeadband NOTIFY rollAxisDeadbandChanged)
Q_PROPERTY(int pitchAxisDeadband READ pitchAxisDeadband NOTIFY pitchAxisDeadbandChanged)
Q_PROPERTY(int yawAxisDeadband READ yawAxisDeadband NOTIFY yawAxisDeadbandChanged)
Q_PROPERTY(int throttleAxisDeadband READ throttleAxisDeadband NOTIFY throttleAxisDeadbandChanged)
Q_PROPERTY(int rollAxisReversed READ rollAxisReversed NOTIFY rollAxisReversedChanged)
Q_PROPERTY(int pitchAxisReversed READ pitchAxisReversed NOTIFY pitchAxisReversedChanged)
Q_PROPERTY(int yawAxisReversed READ yawAxisReversed NOTIFY yawAxisReversedChanged)
......@@ -78,16 +68,6 @@ public:
Q_INVOKABLE void nextButtonClicked(void);
Q_INVOKABLE void start(void);
int rollAxisValue(void);
int pitchAxisValue(void);
int yawAxisValue(void);
int throttleAxisValue(void);
int rollAxisDeadband(void);
int pitchAxisDeadband(void);
int yawAxisDeadband(void);
int throttleAxisDeadband(void);
bool rollAxisMapped(void);
bool pitchAxisMapped(void);
bool yawAxisMapped(void);
......@@ -110,21 +90,12 @@ public:
signals:
void axisValueChanged(int axis, int value);
void axisDeadbandChanged(int axis, int value);
void rollAxisMappedChanged(bool mapped);
void pitchAxisMappedChanged(bool mapped);
void yawAxisMappedChanged(bool mapped);
void throttleAxisMappedChanged(bool mapped);
void rollAxisValueChanged(int value);
void pitchAxisValueChanged(int value);
void yawAxisValueChanged(int value);
void throttleAxisValueChanged(int value);
void rollAxisDeadbandChanged(int value);
void pitchAxisDeadbandChanged(int value);
void yawAxisDeadbandChanged(int value);
void throttleAxisDeadbandChanged(int value);
void rollAxisReversedChanged(bool reversed);
void pitchAxisReversedChanged(bool reversed);
......@@ -217,7 +188,7 @@ private:
void _setHelpImage(const char* imageFile);
void _signalAllAttiudeValueChanges(void);
void _signalAllAttitudeValueChanges(void);
// Member variables
......
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