forked from FOSS/BangleApps
Widget stores data to file, icon added
parent
dbb558a5c8
commit
fa23aaf3f0
|
@ -1136,7 +1136,7 @@
|
|||
"name": "Battery Chart",
|
||||
"shortName":"BatChart",
|
||||
"icon": "widget.png",
|
||||
"version":"0.01",
|
||||
"version":"0.02",
|
||||
"description": "A widget and an app for recording and visualizing battery percentage over time.",
|
||||
"tags": "app,widget,battery,time,record,chart,tool",
|
||||
"storage": [
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
0.01: New App!
|
||||
0.01: New app and widget
|
||||
0.02: Widget stores data to file (1 dataset/min)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwxH+AH4A/AH4AS64AIF/4pZABYuuGDIv/F/4v/F9+Gw0rAQIASF7YxTF7cxwAvtrdVF9qQTF/4vMYCQvcYCQvcSCQvdqpgQF7oEBYJ4veAoNbF9uGmMrrgvsw2AGILFKF8IACrYxJF8gxDSowvmBwWAF9oPGF9NbmIvtCAovqMAgvqCIgvrrdVF9oSDF9iPuF7crACxf/F++wFqmG2AvXGCouZAH4A/AGY"))
|
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.5 KiB |
|
@ -1,9 +1,18 @@
|
|||
WIDGETS = {};
|
||||
|
||||
(() => {
|
||||
var switchableConsumers = {
|
||||
none: 0,
|
||||
lcd: 1,
|
||||
compass: 2,
|
||||
bluetooth: 4,
|
||||
gps: 8,
|
||||
hrm: 16
|
||||
}
|
||||
var settings = {};
|
||||
var batChartFile; // file for battery percentage recording
|
||||
const recordingInterval10Min = 60*10*1000;
|
||||
const recordingInterval10Min = 60 * 10 * 1000;
|
||||
const recordingInterval1Min = 60*1000; //For testing
|
||||
const recordingInterval10S = 10*1000; //For testing
|
||||
var recordingInterval = null;
|
||||
|
||||
|
@ -16,13 +25,40 @@ WIDGETS = {};
|
|||
|
||||
// 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)
|
||||
WIDGETS["batchart"].width = 24;
|
||||
|
||||
// Check if the data file exists, if not try to create it.
|
||||
var batChartFileCheck = require("Storage").open("batchart.dat", "r");
|
||||
if (!batChartFileCheck)
|
||||
if (!require("Storage").write("batchart.dat", ""))
|
||||
//Only continue if the file was created
|
||||
return;
|
||||
|
||||
recordingInterval = setInterval(() => {
|
||||
var batChartFileAppend = require("Storage").open("batchart.dat", "a");
|
||||
if (batChartFileAppend) {
|
||||
console.log([getTime().toFixed(0), E.getBattery(), E.getTemperature(), getEnabledConsumersValue()].join(","));
|
||||
batChartFileAppend.write([getTime().toFixed(0),E.getBattery].join(",")+"\n");
|
||||
}
|
||||
}, recordingInterval1Min)
|
||||
}
|
||||
|
||||
function getEnabledConsumersValue() {
|
||||
var enabledConsumers = switchableConsumers.none;
|
||||
|
||||
if (Bangle.isLCDOn())
|
||||
enabledConsumers = enabledConsumers | switchableConsumers.lcd;
|
||||
// Already added in the hope they will be available soon to get more details
|
||||
// if (Bangle.isCompassOn())
|
||||
// enabledConsumers = enabledConsumers | switchableConsumers.compass;
|
||||
// if (Bangle.isBluetoothOn())
|
||||
// enabledConsumers = enabledConsumers | switchableConsumers.bluetooth;
|
||||
// if (Bangle.isGpsOn())
|
||||
// enabledConsumers = enabledConsumers | switchableConsumers.gps;
|
||||
// if (Bangle.isHrmOn())
|
||||
// enabledConsumers = enabledConsumers | switchableConsumers.hrm;
|
||||
|
||||
return enabledConsumers;
|
||||
}
|
||||
|
||||
// add the widget
|
||||
|
|
Loading…
Reference in New Issue