Skip to content

Commit

Permalink
chore: Add NSUtils.toMmol
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed May 9, 2024
1 parent 7cc0e87 commit 0e79950
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/com.gabe565.nightscout.sdPlugin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

<!-- Plugin Source -->
<script src="js/const.js"></script>
<script src="js/NSUtils.js"></script>
<script src="js/Template.js"></script>
<script src="js/Nightscout.js"></script>
<script src="js/app.js"></script>
Expand Down
5 changes: 5 additions & 0 deletions src/com.gabe565.nightscout.sdPlugin/js/NSUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class NSUtils {
static toMmol(mgdl) {
return ((mgdl * ConversionFactor * 10) | 0) / 10;
}
}
4 changes: 2 additions & 2 deletions src/com.gabe565.nightscout.sdPlugin/js/Template.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ class Template {
context.font = "36px Verdana";
let last = data.bgnow.last;
if (unit === Unit.Mmol) {
last = Math.round(last * ConversionFactor * 10) / 10;
last = NSUtils.toMmol(last);
}
context.fillText(last, Width / 2 + 20, Height / 2 - 10);

context.font = "25px Verdana";
context.fillStyle = "#ddd";
let delta = data.delta.display;
if (unit === Unit.Mmol) {
delta = Math.round(data.delta.scaled * ConversionFactor * 10) / 10;
delta = NSUtils.toMmol(data.delta.scaled);
if (delta >= 0) {
delta = "+" + delta;
}
Expand Down

0 comments on commit 0e79950

Please sign in to comment.