Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/smartbatt/ChangeLog
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
v0.01: New app!
v0.02: Add dynamic intervals, depending on total cycles recorded
Binary file added apps/smartbatt/app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed apps/smartbatt/icon.png
Binary file not shown.
4 changes: 2 additions & 2 deletions apps/smartbatt/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"id": "smartbatt",
"name": "Smart Battery Module",
"shortName": "Smart Battery",
"version": "0.01",
"version": "0.02",
"description": "Provides a `smartbatt` module that returns the battery in days, and learns from daily usage over time for accurate predictions.",
"icon": "icon.png",
"icon": "app.png",
"type": "module",
"tags": "tool,system,clkinfo",
"supports": ["BANGLEJS","BANGLEJS2"],
Expand Down
14 changes: 14 additions & 0 deletions apps/smartbatt/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@
reason: reason
});
}
clearInterval(interval)
if(data.totalCycles<=200){
//5m intervals
interval=setInterval(recordBattery, 600000);
}else if(data.totalCycles<=300){
//30m intervals
interval=setInterval(recordBattery, 1800000);
}else if(data.totalCycles<=500){
//1h intervals
interval=setInterval(recordBattery, 3600000);
}else {
//3h intervals
interval=setInterval(recordBattery, 10800000);
}
}

function weightedAverage(oldValue, oldWeight, newValue, newWeight) {
Expand Down