mirror of https://github.com/espruino/BangleApps
Port the batchart app to banglejs2
parent
c004336e3e
commit
5463ba1b9e
|
@ -7,4 +7,5 @@
|
|||
0.07: Improve logging and charting of component states and add widget icon
|
||||
0.08: Fix for Home button in the app and README added.
|
||||
0.09: Fix failing dismissal of Gadgetbridge notifications, record (coarse) bluetooth state
|
||||
0.10: Remove widget icon and improve listener and setInterval handling for widget (might help with https://github.com/espruino/BangleApps/issues/381)
|
||||
0.10: Remove widget icon and improve listener and setInterval handling for widget (might help with https://github.com/espruino/BangleApps/issues/381)
|
||||
0.11: Initial port to the BangleJS2
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
|
||||
|
||||
const board = process.env.BOARD;
|
||||
const isBangle2 = board === "BANGLEJS2" || board === "EMSCRIPTEN2";
|
||||
const GraphXZero = 40;
|
||||
const GraphYZero = 180;
|
||||
const GraphY100 = 80;
|
||||
const GraphYZero = isBangle2? g.getHeight() - (g.getHeight() * 0.1): 180;
|
||||
const GraphY100 = isBangle2? 50: 80;
|
||||
const MaxValueCount = g.getWidth() - (GraphXZero * 2); // 144
|
||||
|
||||
const GraphMarkerOffset = 5;
|
||||
const MaxValueCount = 144;
|
||||
const GraphXMax = GraphXZero + MaxValueCount;
|
||||
|
||||
const GraphLcdY = GraphYZero + 10;
|
||||
|
@ -12,9 +16,11 @@ const GraphBluetoothY = GraphYZero + 22;
|
|||
const GraphGpsY = GraphYZero + 28;
|
||||
const GraphHrmY = GraphYZero + 34;
|
||||
|
||||
|
||||
const Storage = require("Storage");
|
||||
|
||||
function renderCoordinateSystem() {
|
||||
g.setBgColor(0,0,0);
|
||||
g.setFont("6x8", 1);
|
||||
|
||||
// Left Y axis (Battery)
|
||||
|
@ -36,7 +42,12 @@ function renderCoordinateSystem() {
|
|||
g.drawLine(GraphXZero - GraphMarkerOffset, GraphYZero, GraphXMax + GraphMarkerOffset, GraphYZero);
|
||||
|
||||
// Right Y axis (Temperature)
|
||||
g.setColor(0.4, 0.4, 1);
|
||||
if (isBangle2) {
|
||||
g.setColor(1, 0, 0);
|
||||
} else {
|
||||
g.setColor(0.4, 0.4, 1);
|
||||
}
|
||||
|
||||
g.drawLine(GraphXMax, GraphYZero + GraphMarkerOffset, GraphXMax, GraphY100);
|
||||
g.drawString("°C", GraphXMax + GraphMarkerOffset, GraphY100 - 10);
|
||||
g.setFontAlign(-1, -1, 0);
|
||||
|
@ -62,6 +73,10 @@ function loadData() {
|
|||
let logFileName = "bclog" + startingDay;
|
||||
|
||||
let dataLines = loadLinesFromFile(MaxValueCount, logFileName);
|
||||
if (!dataLines) {
|
||||
console.log("Cannot load lines from file");
|
||||
dataLines = [];
|
||||
}
|
||||
|
||||
// Top up to MaxValueCount from previous days as required
|
||||
let previousDay = decrementDay(startingDay);
|
||||
|
@ -235,8 +250,12 @@ Bangle.on('lcdPower', (on) => {
|
|||
}
|
||||
});
|
||||
|
||||
setWatch(switchOffApp, BTN2, {edge:"falling", debounce:50, repeat:true});
|
||||
|
||||
if (isBangle2) {
|
||||
setWatch(switchOffApp, BTN1, {edge:"falling", debounce:50, repeat:true});
|
||||
g.setBgColor(0,0,0);
|
||||
} else {
|
||||
setWatch(switchOffApp, BTN2, {edge:"falling", debounce:50, repeat:true});
|
||||
}
|
||||
g.clear();
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
"id": "batchart",
|
||||
"name": "Battery Chart",
|
||||
"shortName": "Battery Chart",
|
||||
"version": "0.10",
|
||||
"version": "0.11",
|
||||
"description": "A widget and an app for recording and visualizing battery percentage over time.",
|
||||
"icon": "app.png",
|
||||
"tags": "app,widget,battery,time,record,chart,tool",
|
||||
"supports": ["BANGLEJS"],
|
||||
"supports": ["BANGLEJS", "BANGLEJS2"],
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"batchart.wid.js","url":"widget.js"},
|
||||
|
|
Loading…
Reference in New Issue