Adds BatteryChart app and widget
parent
204ccd81ad
commit
dbb558a5c8
13
apps.json
13
apps.json
|
|
@ -1131,5 +1131,18 @@
|
|||
"storage": [
|
||||
{"name":"custom"}
|
||||
]
|
||||
},
|
||||
{ "id": "batchart",
|
||||
"name": "Battery Chart",
|
||||
"shortName":"BatChart",
|
||||
"icon": "widget.png",
|
||||
"version":"0.01",
|
||||
"description": "A widget and an app for recording and visualizing battery percentage over time.",
|
||||
"tags": "app,widget,battery,time,record,chart,tool",
|
||||
"storage": [
|
||||
{"name":"batchart.wid.js","url":"widget.js"},
|
||||
{"name":"batchart.app.js","url":"app.js"},
|
||||
{"name":"batchart.img.js","url":"app-icon.js"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
0.01: New App!
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
// place your const, vars, functions or classes here
|
||||
|
||||
function renderBatteryChart(){
|
||||
g.drawString("t", 215, 175);
|
||||
g.drawLine(40,190,40,80);
|
||||
|
||||
g.drawString("%", 39, 70);
|
||||
g.drawString("100", 15, 75);
|
||||
g.drawLine(35,80,40,80);
|
||||
|
||||
g.drawString("50", 20,125);
|
||||
g.drawLine(35,130,40,130);
|
||||
|
||||
g.drawString("0", 25, 175);
|
||||
g.drawLine(35,180,210,180);
|
||||
|
||||
g.drawString("Chart not yet functional", 60, 125);
|
||||
}
|
||||
|
||||
// special function to handle display switch on
|
||||
Bangle.on('lcdPower', (on) => {
|
||||
if (on) {
|
||||
// call your app function here
|
||||
// If you clear the screen, do Bangle.drawWidgets();
|
||||
renderBatteryChart();
|
||||
}
|
||||
});
|
||||
|
||||
g.clear();
|
||||
// call your app function here
|
||||
|
||||
renderBatteryChart();
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
|
|
@ -0,0 +1,35 @@
|
|||
WIDGETS = {};
|
||||
|
||||
(() => {
|
||||
var settings = {};
|
||||
var batChartFile; // file for battery percentage recording
|
||||
const recordingInterval10Min = 60*10*1000;
|
||||
const recordingInterval10S = 10*1000; //For testing
|
||||
var recordingInterval = null;
|
||||
|
||||
// draw your widget
|
||||
function draw() {
|
||||
if (!settings.isRecording) return;
|
||||
g.reset();
|
||||
g.drawString("BC", this.x, this.y);
|
||||
}
|
||||
|
||||
// Called by the heart app to reload settings and decide what's
|
||||
function reload() {
|
||||
WIDGETS["batchart"].width = 24;
|
||||
batChartFile = require("Storage").open(".batchart","a");
|
||||
recordingInterval = setInterval(()=>{
|
||||
if (batChartFile)
|
||||
console.log ([getTime().toFixed(0),E.getBattery()].join(","));
|
||||
//batChartfile.write([getTime().toFixed(0),E.getBattery].join(",")+"\n");
|
||||
}, recordingInterval10S)
|
||||
}
|
||||
|
||||
// add the widget
|
||||
WIDGETS["batchart"]={area:"tl",width:24,draw:draw,reload:function() {
|
||||
reload();
|
||||
Bangle.drawWidgets(); // relayout all widgets
|
||||
}};
|
||||
// load settings, set correct widget width
|
||||
reload();
|
||||
})()
|
||||
Loading…
Reference in New Issue