127 lines
2.9 KiB
QML
127 lines
2.9 KiB
QML
import QtQuick 2.12
|
|
import QtQuick.Layouts 1.12
|
|
import QtQuick.Dialogs 1.2
|
|
import Qt.labs.settings 1.1
|
|
|
|
import Controls 1.0 as Controls
|
|
import Cubo 1.0
|
|
|
|
ColumnLayout {
|
|
spacing: 20
|
|
|
|
Controls.Frame {
|
|
padding: 35
|
|
|
|
ColumnLayout {
|
|
anchors.fill: parent
|
|
spacing: 20
|
|
|
|
Controls.TitleLabel {
|
|
text: qsTr("Board information")
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
RowLayout {
|
|
spacing: 10
|
|
|
|
Controls.ContentLabel {
|
|
text: qsTr("Firmware")
|
|
}
|
|
|
|
Controls.DotSeparator {
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
Controls.ContentLabel {
|
|
id: firmwareLabel
|
|
}
|
|
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
RowLayout {
|
|
spacing: 10
|
|
|
|
Controls.ContentLabel {
|
|
text: qsTr("Hardware")
|
|
}
|
|
|
|
Controls.DotSeparator {
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
Controls.ContentLabel {
|
|
id: hardwareLabel
|
|
}
|
|
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
RowLayout {
|
|
spacing: 10
|
|
|
|
Controls.ContentLabel {
|
|
text: qsTr("UUID")
|
|
}
|
|
|
|
Controls.DotSeparator {
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
Controls.ContentLabel {
|
|
id: uuidLabel
|
|
}
|
|
|
|
Layout.fillWidth: true
|
|
}
|
|
}
|
|
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
Controls.Button {
|
|
text: qsTr("Upload firmware")
|
|
onClicked: firmwareFileDialog.open()
|
|
|
|
FileDialog {
|
|
id: firmwareFileDialog
|
|
title: qsTr("Select firmware file")
|
|
folder: shortcuts.documents
|
|
nameFilters: [ qsTr("Firmware files (*.bin)"), qsTr("All files (*)") ]
|
|
onAccepted: {
|
|
if (BmsInterface.isPortConnected()) {
|
|
updateHelper.uploadFirmware(firmwareFileDialog.fileUrl.toString().replace(/^(file:\/{3})/, ""), BmsInterface)
|
|
}
|
|
}
|
|
}
|
|
|
|
Settings {
|
|
category: "firmwareUpdate"
|
|
property alias folder: firmwareFileDialog.folder
|
|
}
|
|
}
|
|
|
|
Item {
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
FirmwareUpdateHelper {
|
|
id: updateHelper
|
|
}
|
|
|
|
Connections {
|
|
target: BmsInterface.commands()
|
|
onFwVersionReceived: {
|
|
firmwareLabel.text = major + "." + minor
|
|
hardwareLabel.text = hw
|
|
uuidLabel.text = bufferToHex(uuid)
|
|
}
|
|
}
|
|
|
|
function bufferToHex(buffer) {
|
|
return [...new Uint8Array(buffer)]
|
|
.map(b => b.toString(16).padStart(2, "0"))
|
|
.join("").toUpperCase();
|
|
}
|
|
}
|