Skip to content

Commit 09ba12d

Browse files
committed
Add reseting PWM field values on button select combo change
1 parent 0f606ae commit 09ba12d

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

src/Joystick/Joystick.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ void AssignedButtonAction::sendPwm(Vehicle *vehicle, bool buttonDown)
123123
if (buttonDown) {
124124
_pwmLatchButtonDown = !_pwmLatchButtonDown;
125125
pwmValue = _pwmLatchButtonDown ? _hiPwmValue : _loPwmValue;
126-
qCDebug(JoystickLog) << " calculated new PWM Value " << pwmValue;
127126
} else {
128-
qCDebug(JoystickLog) << "since button up - exiting";
127+
qCDebug(JoystickLog) << "since button is up - exiting";
129128
return;
130129
}
131130
}
132131

132+
qCDebug(JoystickLog) << " Sending PWM Value " << pwmValue;
133133
vehicle->rcChannelOverride(_pwmRcChannel, pwmValue);
134134
}
135135

src/Vehicle/Vehicle.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,7 +2219,8 @@ void Vehicle::requestDataStream(MAV_DATA_STREAM stream, uint16_t rate, bool send
22192219
void Vehicle::_sendMessageMultipleNext()
22202220
{
22212221
if (_nextSendMessageMultipleIndex < _sendMessageMultipleList.count()) {
2222-
qCDebug(VehicleLog) << "_sendMessageMultipleNext:" << _sendMessageMultipleList[_nextSendMessageMultipleIndex].message.msgid;
2222+
//bzd to be enabled but it spams too much
2223+
//qCDebug(VehicleLog) << "_sendMessageMultipleNext: " << _nextSendMessageMultipleIndex << ", mesg id: " << _sendMessageMultipleList[_nextSendMessageMultipleIndex].message.msgid;
22232224

22242225
SharedLinkInterfacePtr sharedLink = vehicleLinkManager()->primaryLink().lock();
22252226
if (sharedLink) {
@@ -4213,7 +4214,9 @@ void Vehicle::rcChannelOverride(uint8_t rcChannel, uint16_t pwmValue)
42134214
override_data[i] = UINT16_MAX;
42144215
}
42154216
override_data[rcChannel - 1] = pwmValue;
4216-
4217+
for (int i = 0; i < 18; i++) {
4218+
qCDebug(VehicleLog) << "Override data " << i << " is " << override_data[i];
4219+
}
42174220
mavlink_message_t message;
42184221

42194222
mavlink_msg_rc_channels_override_pack_chan(

src/VehicleSetup/JoystickConfigButtons.qml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,26 @@ ColumnLayout {
144144
anchors.verticalCenter: parent.verticalCenter
145145
}
146146
QGCTextField {
147+
id: lowPwmValue
147148
width: ScreenTools.defaultFontPixelWidth * 10
148149
implicitHeight: ScreenTools.implicitTextFieldHeight
149150
visible: true
150151
validator: IntValidator { bottom:1000; top: 2000}
151152

153+
Connections {
154+
target: buttonActionCombo
155+
onCurrentIndexChanged: {
156+
if(_activeJoystick) {
157+
console.log("index changed, ", buttonActionCombo.currentIndex)
158+
console.log("index changed, ", modelData)
159+
console.log("index changed, ", target)
160+
var pwm = pwmSettings._getButtonPwm(modelData, true)
161+
console.log("pwm ", pwm)
162+
lowPwmValue.text = pwm;
163+
}
164+
}
165+
}
166+
152167
Component.onCompleted: {
153168
if(_activeJoystick) {
154169
text = parent._getButtonPwm(modelData, true)
@@ -163,11 +178,27 @@ ColumnLayout {
163178
anchors.verticalCenter: parent.verticalCenter
164179
}
165180
QGCTextField {
181+
id: highPwmValue
166182
width: ScreenTools.defaultFontPixelWidth * 10
167183
implicitHeight: ScreenTools.implicitTextFieldHeight
168184
visible: true
169185
validator: IntValidator { bottom:1000; top: 2000}
170186

187+
Connections {
188+
target: buttonActionCombo
189+
function onCurrentIndexChanged(index) {
190+
if(_activeJoystick) {
191+
console.log("index changed, ", buttonActionCombo.currentIndex)
192+
console.log("index changed, ", modelData)
193+
console.log("index changed, ", target)
194+
console.log("text ", target.text)
195+
var pwm = pwmSettings._getButtonPwm(modelData, false)
196+
console.log("pwm ", pwm)
197+
highPwmValue.text = pwm;
198+
}
199+
}
200+
}
201+
171202
Component.onCompleted: {
172203
if(_activeJoystick) {
173204
text = parent._getButtonPwm(modelData, false)

0 commit comments

Comments
 (0)