summaryrefslogtreecommitdiff
path: root/Main.qml
diff options
context:
space:
mode:
Diffstat (limited to 'Main.qml')
-rw-r--r--Main.qml100
1 files changed, 66 insertions, 34 deletions
diff --git a/Main.qml b/Main.qml
index 665cd4f..01f2b96 100644
--- a/Main.qml
+++ b/Main.qml
@@ -60,7 +60,8 @@ ApplicationWindow {
}
function readParams() {
- var url = apiRoot + "/sensor/params"
+ // var url = apiRoot + "/sensor/params"
+ var url = "http://radxa:8080/v1/sensor/params"
console.log("readParams:", url);
XHR.sendRequest("GET", url, function(response) {
@@ -79,21 +80,32 @@ ApplicationWindow {
var json = JSON.parse(response.content);
- console.log("readParams result:", json)
+ console.log("readParams result:", json, json.exposureTime)
- if (exposureTimeSpinBox.value != json.exposureTime) {
+ if (enableAutoExposureCheckbox.checked !== (json.autoExposure === "true")) {
+ console.log("update enableAutoExposureCheckbox to", json.autoExposure)
+ enableAutoExposureCheckbox.checked = json.autoExposure === "true";
+ }
+
+ if (exposureTimeSpinBox.value !== json.exposureTime) {
console.log("update exposureTimeSpinBox to", json.exposureTime)
exposureTimeSpinBox.value = json.exposureTime;
}
- if (laserLevelSpinBox.value != json.laserLevel) {
- console.log("update laserLevelSpinBox to", json.laserLevel)
- laserLevelSpinBox.value = json.laserLevel;
+ if (enableAutoGainCheckbox.checked !== (json.autoGain === "true")) {
+ console.log("update enableAutoGainCheckbox to", json.autoGain)
+ enableAutoGainCheckbox.checked = json.autoGain === "true";
}
- if (enableAutoExposureCheckbox.checked != (json.aeEnable == "true")) {
- console.log("update enableAutoExposureCheckbox to", json.aeEnable)
- enableAutoExposureCheckbox.checked = json.aeEnable == "true";
+ // TODO: fix this bullshit in DoubleSpinBox
+ if (gainSpinBox.value !== json.gain) {
+ console.log("update gainSpinBox to", json.gain / 10.)
+ gainSpinBox.value = json.gain / 10.;
+ }
+
+ if (laserLevelSpinBox.value !== json.laserLevel) {
+ console.log("update laserLevelSpinBox to", json.laserLevel)
+ laserLevelSpinBox.value = json.laserLevel;
}
});
}
@@ -102,15 +114,24 @@ ApplicationWindow {
readParams();
}
+ // Timer {
+ // repeat: true
+ // interval: 1000 / 500
+ // running: true
+ // onTriggered: readParams()
+ // }
+
function writeParams() {
- var url = apiRoot + "/sensor/params";
+ // var url = apiRoot + "/sensor/params";
+ var url = "http://radxa:8080/v1/sensor/params"
console.log("writeParams:", url);
var json = new Object();
- json["aeEnable"] = enableAutoExposureCheckbox.checked;
+ json["autoExposure"] = enableAutoExposureCheckbox.checked;
json["exposureTime"] = exposureTimeSpinBox.value;
+ json["autoGain"] = enableAutoGainCheckbox.checked;
+ json["gain"] = gainSpinBox.value / 10.;
json["laserLevel"] = laserLevelSpinBox.value;
- json["gain"] = gainSpinBox.value;
console.log(JSON.stringify(json));
XHR.sendRequest("POST", url, function(response) {
@@ -300,6 +321,16 @@ ApplicationWindow {
(parseFloat(timestampUs % (1000 * 1000 * 1000)) / 1000.).toFixed(1)
}
+ CheckBox {
+ id: enableAutoExposureCheckbox
+
+ Layout.columnSpan: 2
+
+ text: qsTr("Auto exposure")
+
+ onCheckedChanged: writeParams()
+ }
+
Label {
text: qsTr("Exposure time (us):")
}
@@ -313,62 +344,63 @@ ApplicationWindow {
from: 10
to: 94000000
- stepSize: 100
+ stepSize: 10
editable: true
value: 68000
onValueChanged: writeParams()
}
+ CheckBox {
+ id: enableAutoGainCheckbox
+
+ Layout.columnSpan: 2
+
+ text: qsTr("Auto gain")
+
+ onCheckedChanged: writeParams()
+ }
+
Label {
- text: qsTr("Laser level (1/50K):")
+ text: qsTr("Gain [0,254]:")
}
- SpinBox {
- id: laserLevelSpinBox
+ DoubleSpinBox {
+ id: gainSpinBox
Layout.fillWidth: true
-
Layout.minimumWidth: implicitWidth
- from: 0
- to: 50000
+ from: 0.0
+ // TODO: fix this bullshit in DoubleSpinBox
+ to: 40.0 * 10.
stepSize: 1
+ decimals: 1
editable: true
- value: 3
onValueChanged: writeParams()
}
Label {
- text: qsTr("Gain [1,254]:")
+ text: qsTr("Laser level (1/50K):")
}
SpinBox {
- id: gainSpinBox
+ id: laserLevelSpinBox
Layout.fillWidth: true
+
Layout.minimumWidth: implicitWidth
from: 0
- to: 254
+ to: 50000
stepSize: 1
editable: true
- value: 2
+ value: 3
onValueChanged: writeParams()
}
- CheckBox {
- id: enableAutoExposureCheckbox
-
- Layout.columnSpan: 2
-
- text: qsTr("Auto exposure")
-
- onCheckedChanged: writeParams()
- }
-
Label {
text: qsTr("Printer distance (mm):")
}