Skip to content

Commit

Permalink
Introduce/use temp_round() to show temperatures
Browse files Browse the repository at this point in the history
To simplify things and avoid typos like the one fixed in the previous
commit.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin authored and jeremypoulter committed Jul 6, 2024
1 parent 209425e commit 5f4f87d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/components/blocks/monitoring/Data.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { _ } from 'svelte-i18n'
import {status_store} from "../../../lib/stores/status.js"
import { derived} from "svelte/store"
import {round, s2mns} from "../../../lib/utils.js"
import {round, temp_round, s2mns} from "../../../lib/utils.js"
import {sec2time, displayRange} from "../../../lib/utils.js"
let evelapsed = derived(uistates_store, store => s2mns(store.vehicle_state_update))
Expand All @@ -29,10 +29,10 @@
{name: $_("monitoring-sensors-current"), value: $status_store.amp/1000, unit: $_("units.A")},
{name: $_("monitoring-sensors-voltage"), value: $status_store.voltage, unit: $_("units.V")},
{name: $_("monitoring-sensors-evsetemp"), value: round($status_store.temp/10,1), unit: $_("units.C")},
{name: "temp1", value: !$status_store.temp1.isNaN?round($status_store.temp1/10,1):"", unit: $_("units.C")},
{name: "temp2", value: !$status_store.temp2.isNaN?round($status_store.temp2/10,1):"", unit: $_("units.C")},
{name: "temp3", value: !$status_store.temp3.isNaN?round($status_store.temp3/10,1):"", unit: $_("units.C")},
{name: "temp4", value: !$status_store.temp4.isNaN?round($status_store.temp4/10,1):"", unit: $_("units.C")},
{name: "temp1", value: temp_round($status_store.temp1), unit: $_("units.C")},
{name: "temp2", value: temp_round($status_store.temp2), unit: $_("units.C")},
{name: "temp3", value: temp_round($status_store.temp3), unit: $_("units.C")},
{name: "temp4", value: temp_round($status_store.temp4), unit: $_("units.C")},
{name: $_("monitoring-sensors-sensorscale"), value: $config_store.scale},
{name: $_("monitoring-sensors-sensoroffset"), value: $config_store.offset}
]
Expand Down
9 changes: 8 additions & 1 deletion src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ export function round(value, precision = null) {
return Math.round(value * multiplier) / multiplier;
}

export function temp_round(value) {
if (isNaN(value)) {
return ""
}
return round(value/10,1)
}

export let getBreakpoint = function () {
const mobilemini = 410
const mobile = 640
Expand Down Expand Up @@ -488,4 +495,4 @@ export function compareVersion(last, old) {
if (last [i] < old[i]) return -1
}
return last.length == old.length ? 0 : (last.length < old.length ? -1 : 1)
}
}

0 comments on commit 5f4f87d

Please sign in to comment.