Skip to content

Commit

Permalink
Merge pull request snaptec#1928 from cshagen/master
Browse files Browse the repository at this point in the history
Fix for display color theme: number lengths
  • Loading branch information
benderl authored Jan 16, 2022
2 parents b8e5896 + 8b0443b commit cec39eb
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion web/display/colors/chargePointList.js
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ class ChargePointList {
updateValues() { // A value has changed. Only update the values, do not redraw all
this.chargepoints.map((cp, i) => {
let powerString = formatWatt(cp.power) + " " + this.phaseSymbols[cp.phasesInUse] + " " + cp.targetCurrent + " A";
let energyString = formatWattH(cp.energy * 1000) + " / " + Math.round(cp.energy / cp.energyPer100km * 1000) / 10 + " km"
let energyString = formatWattH(cp.energy * 1000) + " / " + Math.floor(cp.energy / cp.energyPer100km * 100) + " km"
if (cp.configured) {
d3.select(".cpname-" + i).text(cp.name) // name
if (cp.isSocConfigured) { // soc
14 changes: 9 additions & 5 deletions web/display/colors/powerdata.js
Original file line number Diff line number Diff line change
@@ -391,18 +391,22 @@ class SHDevice {
};

function formatWatt(watt) {
if (watt >= 1000) {
if (watt >= 10000) {
return (Math.round(watt / 1000) + " kW");
} else if (watt >= 1000) {
return ((Math.round(watt / 100) / 10) + " kW");
} else {
return (watt + " W");
}
}

function formatWattH(watt) {
if (watt >= 1000) {
return ((Math.round(watt / 100) / 10) + " kWh");
function formatWattH(watth) {
if (watth >= 10000) {
return (Math.round(watth / 1000) + " kWh");
} else if (watth >= 1000) {
return ((Math.round(watth / 100) / 10) + " kWh");
} else {
return (Math.round(watt) + " Wh");
return (Math.round(watth) + " Wh");
}
}
function formatTime(seconds) {

0 comments on commit cec39eb

Please sign in to comment.