Commit e100631f authored by Don Gagne's avatar Don Gagne

Merge pull request #1933 from DonLakeFlyer/JoystickCalLog

Better Joystick Calibration logging
parents 22ec8918 a1820634
...@@ -253,14 +253,14 @@ void JoystickConfigController::_inputCenterWaitBegin(Joystick::AxisFunction_t fu ...@@ -253,14 +253,14 @@ void JoystickConfigController::_inputCenterWaitBegin(Joystick::AxisFunction_t fu
_nextButton->setEnabled(true); _nextButton->setEnabled(true);
} }
bool JoystickConfigController::_stickSettleComplete(int value) bool JoystickConfigController::_stickSettleComplete(int axis, int value)
{ {
// We are waiting for the stick to settle out to a max position // We are waiting for the stick to settle out to a max position
if (abs(_stickDetectValue - value) > _calSettleDelta) { if (abs(_stickDetectValue - value) > _calSettleDelta) {
// Stick is moving too much to consider stopped // Stick is moving too much to consider stopped
qCDebug(JoystickConfigControllerLog) << "_stickSettleComplete still moving, _stickDetectValue:value" << _stickDetectValue << value; qCDebug(JoystickConfigControllerLog) << "_stickSettleComplete still moving, axis:_stickDetectValue:value" << axis << _stickDetectValue << value;
_stickDetectValue = value; _stickDetectValue = value;
_stickDetectSettleStarted = false; _stickDetectSettleStarted = false;
...@@ -272,12 +272,13 @@ bool JoystickConfigController::_stickSettleComplete(int value) ...@@ -272,12 +272,13 @@ bool JoystickConfigController::_stickSettleComplete(int value)
if (_stickDetectSettleElapsed.elapsed() > _stickDetectSettleMSecs) { if (_stickDetectSettleElapsed.elapsed() > _stickDetectSettleMSecs) {
// Stick has stayed positioned in one place long enough, detection is complete. // Stick has stayed positioned in one place long enough, detection is complete.
qCDebug(JoystickConfigControllerLog) << "_stickSettleComplete detection complete, axis:_stickDetectValue:value" << axis << _stickDetectValue << value;
return true; return true;
} }
} else { } else {
// Start waiting for the stick to stay settled for _stickDetectSettleWaitMSecs msecs // Start waiting for the stick to stay settled for _stickDetectSettleWaitMSecs msecs
qCDebug(JoystickConfigControllerLog) << "_stickSettleComplete starting settle timer, _stickDetectValue:value" << _stickDetectValue << value; qCDebug(JoystickConfigControllerLog) << "_stickSettleComplete starting settle timer, axis:_stickDetectValue:value" << axis << _stickDetectValue << value;
_stickDetectSettleStarted = true; _stickDetectSettleStarted = true;
_stickDetectSettleElapsed.start(); _stickDetectSettleElapsed.start();
...@@ -310,11 +311,9 @@ void JoystickConfigController::_inputStickDetect(Joystick::AxisFunction_t functi ...@@ -310,11 +311,9 @@ void JoystickConfigController::_inputStickDetect(Joystick::AxisFunction_t functi
_stickDetectValue = value; _stickDetectValue = value;
} }
} else if (axis == _stickDetectAxis) { } else if (axis == _stickDetectAxis) {
if (_stickSettleComplete(value)) { if (_stickSettleComplete(axis, value)) {
AxisInfo* info = &_rgAxisInfo[axis]; AxisInfo* info = &_rgAxisInfo[axis];
qCDebug(JoystickConfigControllerLog) << "_inputStickDetect settle complete, function:axis:value" << function << axis << value;
// Stick detection is complete. Stick should be at max position. // Stick detection is complete. Stick should be at max position.
// Map the axis to the function // Map the axis to the function
_rgFunctionAxisMapping[function] = axis; _rgFunctionAxisMapping[function] = axis;
...@@ -322,7 +321,6 @@ void JoystickConfigController::_inputStickDetect(Joystick::AxisFunction_t functi ...@@ -322,7 +321,6 @@ void JoystickConfigController::_inputStickDetect(Joystick::AxisFunction_t functi
// Axis should be at max value, if it is below initial set point the the axis is reversed. // Axis should be at max value, if it is below initial set point the the axis is reversed.
info->reversed = value < _axisValueSave[axis]; info->reversed = value < _axisValueSave[axis];
qCDebug(JoystickConfigControllerLog) << "_inputStickDetect reversed:value:_axisValueSave" << info->reversed << value << _axisValueSave[axis];
if (info->reversed) { if (info->reversed) {
_rgAxisInfo[axis].axisMin = value; _rgAxisInfo[axis].axisMin = value;
...@@ -330,6 +328,8 @@ void JoystickConfigController::_inputStickDetect(Joystick::AxisFunction_t functi ...@@ -330,6 +328,8 @@ void JoystickConfigController::_inputStickDetect(Joystick::AxisFunction_t functi
_rgAxisInfo[axis].axisMax = value; _rgAxisInfo[axis].axisMax = value;
} }
qCDebug(JoystickConfigControllerLog) << "_inputStickDetect saving values, function:axis:value:reversed:_axisValueSave" << function << axis << value << info->reversed << _axisValueSave[axis];
_signalAllAttiudeValueChanges(); _signalAllAttiudeValueChanges();
_advanceState(); _advanceState();
...@@ -339,6 +339,8 @@ void JoystickConfigController::_inputStickDetect(Joystick::AxisFunction_t functi ...@@ -339,6 +339,8 @@ void JoystickConfigController::_inputStickDetect(Joystick::AxisFunction_t functi
void JoystickConfigController::_inputStickMin(Joystick::AxisFunction_t function, int axis, int value) void JoystickConfigController::_inputStickMin(Joystick::AxisFunction_t function, int axis, int value)
{ {
qCDebug(JoystickConfigControllerLog) << "_inputStickMin function:axis:value" << function << axis << value;
// We only care about the axis mapped to the function we are working on // We only care about the axis mapped to the function we are working on
if (_rgFunctionAxisMapping[function] != axis) { if (_rgFunctionAxisMapping[function] != axis) {
return; return;
...@@ -351,18 +353,20 @@ void JoystickConfigController::_inputStickMin(Joystick::AxisFunction_t function, ...@@ -351,18 +353,20 @@ void JoystickConfigController::_inputStickMin(Joystick::AxisFunction_t function,
_stickDetectAxis = axis; _stickDetectAxis = axis;
_stickDetectInitialValue = value; _stickDetectInitialValue = value;
_stickDetectValue = value; _stickDetectValue = value;
qCDebug(JoystickConfigControllerLog) << "_inputStickMin detected movement _stickDetectAxis:_stickDetectInitialValue" << _stickDetectAxis << _stickDetectInitialValue;
} }
} else { } else {
if (value < _calCenterPoint - _calMoveDelta) { if (value < _calCenterPoint - _calMoveDelta) {
_stickDetectAxis = axis; _stickDetectAxis = axis;
_stickDetectInitialValue = value; _stickDetectInitialValue = value;
_stickDetectValue = value; _stickDetectValue = value;
qCDebug(JoystickConfigControllerLog) << "_inputStickMin detected movement _stickDetectAxis:_stickDetectInitialValue" << _stickDetectAxis << _stickDetectInitialValue;
} }
} }
} else { } else {
// We are waiting for the selected axis to settle out // We are waiting for the selected axis to settle out
if (_stickSettleComplete(value)) { if (_stickSettleComplete(axis, value)) {
AxisInfo* info = &_rgAxisInfo[axis]; AxisInfo* info = &_rgAxisInfo[axis];
// Stick detection is complete. Stick should be at min position. // Stick detection is complete. Stick should be at min position.
...@@ -376,8 +380,8 @@ void JoystickConfigController::_inputStickMin(Joystick::AxisFunction_t function, ...@@ -376,8 +380,8 @@ void JoystickConfigController::_inputStickMin(Joystick::AxisFunction_t function,
if (function == Joystick::throttleFunction) { if (function == Joystick::throttleFunction) {
_rgAxisInfo[axis].axisTrim = value; _rgAxisInfo[axis].axisTrim = value;
} }
// XXX to support configs which can reverse they need to check a reverse
// flag here and not do this. qCDebug(JoystickConfigControllerLog) << "_inputStickMin saving values, function:axis:value:reversed" << function << axis << value << info->reversed;
_advanceState(); _advanceState();
} }
...@@ -386,6 +390,8 @@ void JoystickConfigController::_inputStickMin(Joystick::AxisFunction_t function, ...@@ -386,6 +390,8 @@ void JoystickConfigController::_inputStickMin(Joystick::AxisFunction_t function,
void JoystickConfigController::_inputCenterWait(Joystick::AxisFunction_t function, int axis, int value) void JoystickConfigController::_inputCenterWait(Joystick::AxisFunction_t function, int axis, int value)
{ {
qCDebug(JoystickConfigControllerLog) << "_inputCenterWait function:axis:value" << function << axis << value;
// We only care about the axis mapped to the function we are working on // We only care about the axis mapped to the function we are working on
if (_rgFunctionAxisMapping[function] != axis) { if (_rgFunctionAxisMapping[function] != axis) {
return; return;
...@@ -399,9 +405,10 @@ void JoystickConfigController::_inputCenterWait(Joystick::AxisFunction_t functio ...@@ -399,9 +405,10 @@ void JoystickConfigController::_inputCenterWait(Joystick::AxisFunction_t functio
_stickDetectAxis = axis; _stickDetectAxis = axis;
_stickDetectInitialValue = value; _stickDetectInitialValue = value;
_stickDetectValue = value; _stickDetectValue = value;
qCDebug(JoystickConfigControllerLog) << "_inputStickMin detected possible center _stickDetectAxis:_stickDetectInitialValue" << _stickDetectAxis << _stickDetectInitialValue;
} }
} else { } else {
if (_stickSettleComplete(value)) { if (_stickSettleComplete(axis, value)) {
_advanceState(); _advanceState();
} }
} }
......
...@@ -182,7 +182,7 @@ private: ...@@ -182,7 +182,7 @@ private:
void _skipFlaps(void); void _skipFlaps(void);
void _saveAllTrims(void); void _saveAllTrims(void);
bool _stickSettleComplete(int value); bool _stickSettleComplete(int axis, int value);
void _validateCalibration(void); void _validateCalibration(void);
void _writeCalibration(void); void _writeCalibration(void);
......
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