Http Version - Fix to show error when requests fail, and changed display type of distance in UI from float to Int

This commit is contained in:
unrealdragon 2026-08-12 14:32:54 +05:30
commit e1d57eae32

View file

@ -14,7 +14,7 @@ Item {
property double height_max: tank_base.height - 10
property double current_level: 0
property double percentage_filled: 0
property double distance: 0
property int distance: 0
property double min_thres_input: 0
property double max_thres_input: 0
property double rate_of_fill: 0
@ -33,16 +33,16 @@ Item {
bottomMargin: -5
}
radius: 10
width: parent.width / 4
height: parent.height / 15
width: tank_base.width / 3
height: tank_base.height / 15
}
Rectangle {
id: tank_base
color: root.tank_base_color
anchors.centerIn: parent
width: parent.width / 2
height: parent.height / 2
width: parent.width
height: parent.height
border.color: root.tank_base_border_color
border.width: 5
radius: 4
@ -72,7 +72,7 @@ Item {
Text {
id: water_level_reading
text: "Current Reading: " + root.distance + " cm"
text: "Current Reading: " + (root.distance / 10)+ " cm"
font.pointSize: 16
color: root.text_color
anchors {
@ -125,7 +125,7 @@ Item {
text: "Expected to fill in: " + root.expected_to_fill + " s"
font.pointSize: 16
color: root.text_color
visible: (root.rate_of_fill > 1) ? true : false
visible: (root.rate_of_fill > 0) ? true : false
anchors {
margins: 5
top: rate_of_fill_label.bottom
@ -141,10 +141,11 @@ Item {
function setDistance(distance) {
root.distance = distance;
console.log("Distance changed to: ", distance);
let distance_f = distance / 10;
console.log("Distance changed to: ", distance_f);
let current_min_reading = Math.max(0, min_thres_input);
let effective_max_reading = Math.max(0, max_thres_input) - current_min_reading;
let current_reading = Math.max(0, root.distance - current_min_reading);
let current_reading = Math.max(0, distance_f - current_min_reading);
console.log("Current reading is: " + current_reading)
console.log("Current min reading is: " + current_min_reading)
console.log("Effective max reading is: " + effective_max_reading)