diff options
| author | Nikita Kostovsky <nikita@kostovsky.me> | 2025-11-14 21:06:10 +0100 |
|---|---|---|
| committer | Nikita Kostovsky <nikita@kostovsky.me> | 2025-11-14 21:06:10 +0100 |
| commit | a24bb7cb1e2e25805243ce6d63dbc42cbce836ae (patch) | |
| tree | 1c16031f36a1ff4a779019b7c870c1754e10f12e /Main.qml | |
| parent | 3a0137b045c817516b2341931ad9128fa70a1fd5 (diff) | |
adopt new params; introduce ugly DoubleSpinBox
Diffstat (limited to 'Main.qml')
| -rw-r--r-- | Main.qml | 100 |
1 files changed, 66 insertions, 34 deletions
@@ -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):") } |
