|
|
|
@ -17,251 +17,213 @@ import QGroundControl.Controls 1.0
@@ -17,251 +17,213 @@ import QGroundControl.Controls 1.0
|
|
|
|
|
import QGroundControl.ScreenTools 1.0 |
|
|
|
|
import QGroundControl.Palette 1.0 |
|
|
|
|
|
|
|
|
|
Item { |
|
|
|
|
id: serialLinkSettings |
|
|
|
|
width: parent ? parent.width : 0 |
|
|
|
|
height: serialColumn.height |
|
|
|
|
|
|
|
|
|
Column { |
|
|
|
|
id: serialLinkSettings |
|
|
|
|
spacing: ScreenTools.defaultFontPixelHeight * 0.5 |
|
|
|
|
anchors.margins: ScreenTools.defaultFontPixelWidth |
|
|
|
|
function saveSettings() { |
|
|
|
|
// No Need |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Column { |
|
|
|
|
id: serialColumn |
|
|
|
|
width: serialLinkSettings.width |
|
|
|
|
spacing: ScreenTools.defaultFontPixelHeight / 2 |
|
|
|
|
Row { |
|
|
|
|
spacing: ScreenTools.defaultFontPixelWidth |
|
|
|
|
QGCLabel { |
|
|
|
|
id: serialLabel |
|
|
|
|
text: qsTr("Serial Link Settings") |
|
|
|
|
text: qsTr("Serial Port:") |
|
|
|
|
width: _firstColumn |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
} |
|
|
|
|
Rectangle { |
|
|
|
|
height: 1 |
|
|
|
|
width: serialLabel.width |
|
|
|
|
color: qgcPal.button |
|
|
|
|
} |
|
|
|
|
Item { |
|
|
|
|
height: ScreenTools.defaultFontPixelHeight / 2 |
|
|
|
|
width: parent.width |
|
|
|
|
QGCLabel { |
|
|
|
|
text: qsTr("No serial ports available"); |
|
|
|
|
visible: QGroundControl.linkManager.serialPortStrings.length === 0 |
|
|
|
|
} |
|
|
|
|
Row { |
|
|
|
|
spacing: ScreenTools.defaultFontPixelWidth |
|
|
|
|
QGCLabel { |
|
|
|
|
text: qsTr("Serial Port:") |
|
|
|
|
width: _firstColumn |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
} |
|
|
|
|
QGCLabel { |
|
|
|
|
text: qsTr("No serial ports available"); |
|
|
|
|
visible: QGroundControl.linkManager.serialPortStrings.length == 0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QGCComboBox { |
|
|
|
|
id: commPortCombo |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
width: _secondColumn |
|
|
|
|
visible: QGroundControl.linkManager.serialPortStrings.length > 0 |
|
|
|
|
QGCComboBox { |
|
|
|
|
id: commPortCombo |
|
|
|
|
width: _secondColumn |
|
|
|
|
visible: QGroundControl.linkManager.serialPortStrings.length > 0 |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
|
|
|
|
|
onActivated: { |
|
|
|
|
if (index != -1) { |
|
|
|
|
if (index >= QGroundControl.linkManager.serialPortStrings.length) { |
|
|
|
|
// This item was adding at the end, must use added text as name |
|
|
|
|
subEditConfig.portName = commPortCombo.textAt(index) |
|
|
|
|
} else { |
|
|
|
|
subEditConfig.portName = QGroundControl.linkManager.serialPorts[index] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Component.onCompleted: { |
|
|
|
|
var index |
|
|
|
|
var serialPorts = [ ] |
|
|
|
|
|
|
|
|
|
for (var i=0; i<QGroundControl.linkManager.serialPortStrings.length; i++) { |
|
|
|
|
serialPorts.push(QGroundControl.linkManager.serialPortStrings[i]) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (subEditConfig != null) { |
|
|
|
|
if (subEditConfig.portDisplayName === "" && QGroundControl.linkManager.serialPorts.length > 0) { |
|
|
|
|
subEditConfig.portName = QGroundControl.linkManager.serialPorts[0] |
|
|
|
|
} |
|
|
|
|
index = serialPorts.indexOf(subEditConfig.portDisplayName) |
|
|
|
|
if (index === -1) { |
|
|
|
|
serialPorts.push(subEditConfig.portName) |
|
|
|
|
index = serialPorts.indexOf(subEditConfig.portName) |
|
|
|
|
} |
|
|
|
|
onActivated: { |
|
|
|
|
if (index != -1) { |
|
|
|
|
if (index >= QGroundControl.linkManager.serialPortStrings.length) { |
|
|
|
|
// This item was adding at the end, must use added text as name |
|
|
|
|
subEditConfig.portName = commPortCombo.textAt(index) |
|
|
|
|
} else { |
|
|
|
|
index = 0 |
|
|
|
|
subEditConfig.portName = QGroundControl.linkManager.serialPorts[index] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
commPortCombo.model = serialPorts |
|
|
|
|
commPortCombo.currentIndex = index |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Row { |
|
|
|
|
spacing: ScreenTools.defaultFontPixelWidth |
|
|
|
|
QGCLabel { |
|
|
|
|
text: qsTr("Baud Rate:") |
|
|
|
|
width: _firstColumn |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
} |
|
|
|
|
QGCComboBox { |
|
|
|
|
id: baudCombo |
|
|
|
|
width: _secondColumn |
|
|
|
|
model: QGroundControl.linkManager.serialBaudRates |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
onActivated: { |
|
|
|
|
if (index != -1) { |
|
|
|
|
subEditConfig.baud = parseInt(QGroundControl.linkManager.serialBaudRates[index]) |
|
|
|
|
} |
|
|
|
|
Component.onCompleted: { |
|
|
|
|
var index |
|
|
|
|
var serialPorts = [ ] |
|
|
|
|
for (var i=0; i<QGroundControl.linkManager.serialPortStrings.length; i++) { |
|
|
|
|
serialPorts.push(QGroundControl.linkManager.serialPortStrings[i]) |
|
|
|
|
} |
|
|
|
|
Component.onCompleted: { |
|
|
|
|
var baud = "57600" |
|
|
|
|
if(subEditConfig != null) { |
|
|
|
|
baud = subEditConfig.baud.toString() |
|
|
|
|
if (subEditConfig != null) { |
|
|
|
|
if (subEditConfig.portDisplayName === "" && QGroundControl.linkManager.serialPorts.length > 0) { |
|
|
|
|
subEditConfig.portName = QGroundControl.linkManager.serialPorts[0] |
|
|
|
|
} |
|
|
|
|
var index = baudCombo.find(baud) |
|
|
|
|
index = serialPorts.indexOf(subEditConfig.portDisplayName) |
|
|
|
|
if (index === -1) { |
|
|
|
|
console.warn(qsTr("Baud rate name not in combo box"), baud) |
|
|
|
|
} else { |
|
|
|
|
baudCombo.currentIndex = index |
|
|
|
|
serialPorts.push(subEditConfig.portName) |
|
|
|
|
index = serialPorts.indexOf(subEditConfig.portName) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
index = 0 |
|
|
|
|
} |
|
|
|
|
commPortCombo.model = serialPorts |
|
|
|
|
commPortCombo.currentIndex = index |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Item { |
|
|
|
|
height: ScreenTools.defaultFontPixelHeight / 2 |
|
|
|
|
width: parent.width |
|
|
|
|
} |
|
|
|
|
//----------------------------------------------------------------- |
|
|
|
|
//-- Advanced Serial Settings |
|
|
|
|
QGCCheckBox { |
|
|
|
|
id: showAdvanced |
|
|
|
|
text: qsTr("Show Advanced Serial Settings") |
|
|
|
|
} |
|
|
|
|
Item { |
|
|
|
|
height: ScreenTools.defaultFontPixelHeight / 2 |
|
|
|
|
width: parent.width |
|
|
|
|
} |
|
|
|
|
Row { |
|
|
|
|
spacing: ScreenTools.defaultFontPixelWidth |
|
|
|
|
QGCLabel { |
|
|
|
|
text: qsTr("Baud Rate:") |
|
|
|
|
width: _firstColumn |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
} |
|
|
|
|
//-- Flow Control |
|
|
|
|
QGCCheckBox { |
|
|
|
|
text: qsTr("Enable Flow Control") |
|
|
|
|
checked: subEditConfig ? subEditConfig.flowControl !== 0 : false |
|
|
|
|
visible: showAdvanced.checked |
|
|
|
|
onCheckedChanged: { |
|
|
|
|
if(subEditConfig) { |
|
|
|
|
subEditConfig.flowControl = checked ? 1 : 0 |
|
|
|
|
QGCComboBox { |
|
|
|
|
id: baudCombo |
|
|
|
|
width: _secondColumn |
|
|
|
|
model: QGroundControl.linkManager.serialBaudRates |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
onActivated: { |
|
|
|
|
if (index != -1) { |
|
|
|
|
subEditConfig.baud = parseInt(QGroundControl.linkManager.serialBaudRates[index]) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//-- Parity |
|
|
|
|
Row { |
|
|
|
|
spacing: ScreenTools.defaultFontPixelWidth |
|
|
|
|
visible: showAdvanced.checked |
|
|
|
|
QGCLabel { |
|
|
|
|
text: qsTr("Parity:") |
|
|
|
|
width: _firstColumn |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
} |
|
|
|
|
QGCComboBox { |
|
|
|
|
id: parityCombo |
|
|
|
|
width: _firstColumn |
|
|
|
|
model: [qsTr("None"), qsTr("Even"), qsTr("Odd")] |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
onActivated: { |
|
|
|
|
if (index != -1) { |
|
|
|
|
// Hard coded values from qserialport.h |
|
|
|
|
if(index == 0) |
|
|
|
|
subEditConfig.parity = 0 |
|
|
|
|
else if(index == 1) |
|
|
|
|
subEditConfig.parity = 2 |
|
|
|
|
else |
|
|
|
|
subEditConfig.parity = 3 |
|
|
|
|
} |
|
|
|
|
Component.onCompleted: { |
|
|
|
|
var baud = "57600" |
|
|
|
|
if(subEditConfig != null) { |
|
|
|
|
baud = subEditConfig.baud.toString() |
|
|
|
|
} |
|
|
|
|
Component.onCompleted: { |
|
|
|
|
var index = 0 |
|
|
|
|
if(subEditConfig != null) { |
|
|
|
|
index = subEditConfig.parity |
|
|
|
|
} |
|
|
|
|
if(index > 1) { |
|
|
|
|
index = index - 2 |
|
|
|
|
} |
|
|
|
|
parityCombo.currentIndex = index |
|
|
|
|
var index = baudCombo.find(baud) |
|
|
|
|
if (index === -1) { |
|
|
|
|
console.warn(qsTr("Baud rate name not in combo box"), baud) |
|
|
|
|
} else { |
|
|
|
|
baudCombo.currentIndex = index |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//-- Data Bits |
|
|
|
|
Row { |
|
|
|
|
spacing: ScreenTools.defaultFontPixelWidth |
|
|
|
|
visible: showAdvanced.checked |
|
|
|
|
QGCLabel { |
|
|
|
|
text: "Data Bits:" |
|
|
|
|
width: _firstColumn |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
} |
|
|
|
|
Item { |
|
|
|
|
height: ScreenTools.defaultFontPixelHeight / 2 |
|
|
|
|
width: parent.width |
|
|
|
|
} |
|
|
|
|
//----------------------------------------------------------------- |
|
|
|
|
//-- Advanced Serial Settings |
|
|
|
|
QGCCheckBox { |
|
|
|
|
id: showAdvanced |
|
|
|
|
text: qsTr("Show Advanced Serial Settings") |
|
|
|
|
} |
|
|
|
|
Item { |
|
|
|
|
height: ScreenTools.defaultFontPixelHeight / 2 |
|
|
|
|
width: parent.width |
|
|
|
|
} |
|
|
|
|
//-- Flow Control |
|
|
|
|
QGCCheckBox { |
|
|
|
|
text: qsTr("Enable Flow Control") |
|
|
|
|
checked: subEditConfig ? subEditConfig.flowControl !== 0 : false |
|
|
|
|
visible: showAdvanced.checked |
|
|
|
|
onCheckedChanged: { |
|
|
|
|
if(subEditConfig) { |
|
|
|
|
subEditConfig.flowControl = checked ? 1 : 0 |
|
|
|
|
} |
|
|
|
|
QGCComboBox { |
|
|
|
|
id: dataCombo |
|
|
|
|
width: _firstColumn |
|
|
|
|
model: ["5", "6", "7", "8"] |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
onActivated: { |
|
|
|
|
if (index != -1) { |
|
|
|
|
subEditConfig.dataBits = index + 5 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//-- Parity |
|
|
|
|
Row { |
|
|
|
|
spacing: ScreenTools.defaultFontPixelWidth |
|
|
|
|
visible: showAdvanced.checked |
|
|
|
|
QGCLabel { |
|
|
|
|
text: qsTr("Parity:") |
|
|
|
|
width: _firstColumn |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
} |
|
|
|
|
QGCComboBox { |
|
|
|
|
id: parityCombo |
|
|
|
|
width: _firstColumn |
|
|
|
|
model: [qsTr("None"), qsTr("Even"), qsTr("Odd")] |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
onActivated: { |
|
|
|
|
if (index != -1) { |
|
|
|
|
// Hard coded values from qserialport.h |
|
|
|
|
if(index == 0) |
|
|
|
|
subEditConfig.parity = 0 |
|
|
|
|
else if(index == 1) |
|
|
|
|
subEditConfig.parity = 2 |
|
|
|
|
else |
|
|
|
|
subEditConfig.parity = 3 |
|
|
|
|
} |
|
|
|
|
Component.onCompleted: { |
|
|
|
|
var index = 3 |
|
|
|
|
if(subEditConfig != null) { |
|
|
|
|
index = subEditConfig.parity - 5 |
|
|
|
|
if(index < 0) |
|
|
|
|
index = 3 |
|
|
|
|
} |
|
|
|
|
dataCombo.currentIndex = index |
|
|
|
|
} |
|
|
|
|
Component.onCompleted: { |
|
|
|
|
var index = 0 |
|
|
|
|
if(subEditConfig != null) { |
|
|
|
|
index = subEditConfig.parity |
|
|
|
|
} |
|
|
|
|
if(index > 1) { |
|
|
|
|
index = index - 2 |
|
|
|
|
} |
|
|
|
|
parityCombo.currentIndex = index |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//-- Stop Bits |
|
|
|
|
Row { |
|
|
|
|
spacing: ScreenTools.defaultFontPixelWidth |
|
|
|
|
visible: showAdvanced.checked |
|
|
|
|
QGCLabel { |
|
|
|
|
text: qsTr("Stop Bits:") |
|
|
|
|
width: _firstColumn |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
} |
|
|
|
|
QGCComboBox { |
|
|
|
|
id: stopCombo |
|
|
|
|
width: _firstColumn |
|
|
|
|
model: ["1", "2"] |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
onActivated: { |
|
|
|
|
if (index != -1) { |
|
|
|
|
subEditConfig.stopBits = index + 1 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//-- Data Bits |
|
|
|
|
Row { |
|
|
|
|
spacing: ScreenTools.defaultFontPixelWidth |
|
|
|
|
visible: showAdvanced.checked |
|
|
|
|
QGCLabel { |
|
|
|
|
text: "Data Bits:" |
|
|
|
|
width: _firstColumn |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
} |
|
|
|
|
QGCComboBox { |
|
|
|
|
id: dataCombo |
|
|
|
|
width: _firstColumn |
|
|
|
|
model: ["5", "6", "7", "8"] |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
onActivated: { |
|
|
|
|
if (index != -1) { |
|
|
|
|
subEditConfig.dataBits = index + 5 |
|
|
|
|
} |
|
|
|
|
Component.onCompleted: { |
|
|
|
|
var index = 0 |
|
|
|
|
if(subEditConfig != null) { |
|
|
|
|
index = subEditConfig.stopBits - 1 |
|
|
|
|
if(index < 0) |
|
|
|
|
index = 0 |
|
|
|
|
} |
|
|
|
|
stopCombo.currentIndex = index |
|
|
|
|
} |
|
|
|
|
Component.onCompleted: { |
|
|
|
|
var index = 3 |
|
|
|
|
if(subEditConfig != null) { |
|
|
|
|
index = subEditConfig.parity - 5 |
|
|
|
|
if(index < 0) |
|
|
|
|
index = 3 |
|
|
|
|
} |
|
|
|
|
dataCombo.currentIndex = index |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
QGCCheckBox { |
|
|
|
|
text: "High Latency" |
|
|
|
|
checked: false |
|
|
|
|
visible: editConfig ? editConfig.highLatencyAllowed : false |
|
|
|
|
onCheckedChanged: { |
|
|
|
|
if(editConfig) { |
|
|
|
|
editConfig.highLatency = checked |
|
|
|
|
} |
|
|
|
|
//-- Stop Bits |
|
|
|
|
Row { |
|
|
|
|
spacing: ScreenTools.defaultFontPixelWidth |
|
|
|
|
visible: showAdvanced.checked |
|
|
|
|
QGCLabel { |
|
|
|
|
text: qsTr("Stop Bits:") |
|
|
|
|
width: _firstColumn |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
} |
|
|
|
|
QGCComboBox { |
|
|
|
|
id: stopCombo |
|
|
|
|
width: _firstColumn |
|
|
|
|
model: ["1", "2"] |
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
onActivated: { |
|
|
|
|
if (index != -1) { |
|
|
|
|
subEditConfig.stopBits = index + 1 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Component.onCompleted: { |
|
|
|
|
if(editConfig) |
|
|
|
|
checked = editConfig.highLatency |
|
|
|
|
var index = 0 |
|
|
|
|
if(subEditConfig != null) { |
|
|
|
|
index = subEditConfig.stopBits - 1 |
|
|
|
|
if(index < 0) |
|
|
|
|
index = 0 |
|
|
|
|
} |
|
|
|
|
stopCombo.currentIndex = index |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|