Skip to content

Commit 5800fef

Browse files
committed
Fix bugs, add avg
1 parent 07c3b9d commit 5800fef

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

nodejs-assets/nodejs-project/index.html

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,8 @@
541541
sections.innerHTML += element;
542542
};
543543

544+
let cellStartValues = [];
545+
544546
const estimateBalanceCells = [];
545547
function createCellsSection(balanceStatus, cellVolts) {
546548
if (!balanceStatus || !cellVolts) return;
@@ -569,6 +571,15 @@
569571
{id: 'cell-avg', name: 'Avg', value: averageVoltage.toFixed(3)},
570572
];
571573

574+
if (!cellStartValues.length) {
575+
cellStartValues = cellVolts;
576+
}
577+
578+
const cellDiffs = cellStartValues.map((v, i) => {
579+
const diff = cellVolts[i] - v;
580+
return diff.toFixed(3);
581+
});
582+
572583
const element = `
573584
<div id="cellsSection">
574585
@@ -671,14 +682,19 @@
671682
return '🟢';
672683
}
673684
674-
return off;
685+
if (isLow) {
686+
return off;
687+
}
688+
689+
return '🔵';
675690
})()}
676-
<span title="Balance Status" style="${
677-
!v ? 'filter: grayscale(100%);' : ''
678-
}">⚖️</span>
691+
<span title="Balance Status" style="${
692+
!v ? 'filter: grayscale(100%); opacity: 0.4' : ''
693+
}">⚖️</span>
679694
</span>
680-
681-
695+
<span title="Changes" style="opacity: 0.5">${
696+
cellDiffs[i] > 0 ? '+' : ''
697+
}${cellDiffs[i]}</span>
682698
</div>
683699
`;
684700
})

0 commit comments

Comments
 (0)