From 8ac3204aa7911aec20967c4d57b92da027b1ad03 Mon Sep 17 00:00:00 2001 From: Nikita Kostovsky Date: Sun, 24 Nov 2024 09:55:29 +0100 Subject: add encoder --- Main.qml | 127 ++++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 97 insertions(+), 30 deletions(-) (limited to 'Main.qml') diff --git a/Main.qml b/Main.qml index d2ca11d..8d87aab 100644 --- a/Main.qml +++ b/Main.qml @@ -6,6 +6,8 @@ import QmlCustomPlot 1.0 import "request.js" as XHR +import eurydice + ApplicationWindow { id: mainWindowRoot @@ -13,7 +15,8 @@ ApplicationWindow { height: 480 visible: true // visibility: Window.Maximized - visibility: ApplicationWindow.Maximized + // visibility: ApplicationWindow.Maximized + visibility: ApplicationWindow.FullScreen title: qsTr("Hello World") @@ -122,6 +125,23 @@ ApplicationWindow { }, JSON.stringify(json)); } + function resetEncoder() { + var url = apiRoot + "/commands/resetEncoder"; + console.log("resetEncoder:", url); + + XHR.sendRequest("POST", url, function(response) { + + if (response.status != "200") { + console.log("response status: ", response.status); + return; + } + + // console.log("resetEncoder result:", response.content); + + // var json = JSON.parse(response.content); + }); + } + RowLayout { id: horizontalLayout @@ -218,6 +238,28 @@ ApplicationWindow { text: "med. diff: " + median_diff.toFixed(3) } + Label { + Layout.fillWidth: true + Layout.alignment: Qt.AlignTop + + text: "Pos: " + (parseFloat(encoderPosition) / 200.).toFixed(3) + } + + Label { + Layout.fillWidth: true + Layout.alignment: Qt.AlignTop + + text: "Measurement: " + measurementCounter + } + + Label { + Layout.fillWidth: true + Layout.alignment: Qt.AlignTop + + text: "Timestamp (ms): " + + (parseFloat(timestampUs % (1000 * 1000 * 1000)) / 1000.).toFixed(1) + } + Label { text: qsTr("Exposure time (us):") } @@ -232,7 +274,7 @@ ApplicationWindow { stepSize: 100 editable: true - value: 200 + value: 1000 onValueChanged: writeParams() } @@ -258,50 +300,75 @@ ApplicationWindow { onCheckedChanged: writeParams() } + Button { + text: qsTr("Reset encoder") + onClicked: resetEncoder() + } + Item { Layout.fillHeight: true } } } - ImageViewer { - id: image + ColumnLayout { - Layout.fillHeight: true - Layout.fillWidth: true - Layout.minimumWidth: 200 - } + TabBar { + id: tabBar - Item { + Layout.fillWidth: true - Layout.fillHeight: true - Layout.fillWidth: true - Layout.minimumWidth: 900 - Layout.minimumHeight: 600 + currentIndex: 0 - Rectangle { - color: "red" - opacity: 0.1 - z: 101 + Shortcut { + sequence: "alt+1" + onActivated: tabBar.currentIndex = 0 + } + + Shortcut { + sequence: "alt+2" + onActivated: tabBar.currentIndex = 1 + } + + TabButton { + text: qsTr("Image") + } + + TabButton { + text: qsTr("Pixels") + } } - QmlCustomPlot { - id: qmlPlot + SwipeView { + Layout.fillHeight: true + Layout.fillWidth: true + Layout.minimumWidth: mainWindowRoot.width * 0.8 - anchors.fill: parent + currentIndex: tabBar.currentIndex + clip: true + interactive: false - Label { - anchors { - top: parent.top - topMargin: 8 * 2 - horizontalCenter: parent.horizontalCenter - } - text: qmlPlot.fps - color: Material.color(Material.accent) + ImageViewer { + id: image } - plot: myPlot - // Component.onCompleted: initCustomPlot() + QmlCustomPlot { + id: qmlPlot + + Label { + anchors { + top: parent.top + topMargin: 8 * 2 + horizontalCenter: parent.horizontalCenter + } + text: qmlPlot.fps + color: Material.accent + } + + plot: myPlot + // Component.onCompleted: setRange(Qt.rect(-640, 0, 1280, 800)) + // Component.onCompleted: initCustomPlot() + } } } } -- cgit v1.2.3-70-g09d2