Skip to content

Commit 6a30b6c

Browse files
authored
Merge branch 'master' into patch-1
2 parents 28baf8a + 1ff8162 commit 6a30b6c

26 files changed

+1074
-193
lines changed

apps/deko/ChangeLog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
0.01: first release
1+
0.01: First release
2+
0.02: Add setting to make widgets optional

apps/deko/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Deko Clock
22

3-
A simple clock with an Art Deko font
3+
A simple clock with an Art Deko font.
44

5-
The font was obtained from https://dafonttop.com/building.font and is free for personal use
5+
Widgets can be configured to be always on, always off, or only shown when unlocked.
66

7+
The font was obtained from https://dafonttop.com/building.font and is free for personal use.
78

8-
![](screenshot.png)
9+
![](screenshot.png) ![](screenshot-no-widgets.png)
910

10-
Written by: [Hugh Barney](https://github.com/hughbarney) For support and discussion please post in the [Bangle JS Forum](http://forum.espruino.com/microcosms/1424/)
11+
Written by: [Hugh Barney](https://github.com/hughbarney)
12+
Optional widgets settings added by [Trippnology](https://github.com/trippnology)
13+
14+
For support and discussion please post in the [Bangle JS Forum](http://forum.espruino.com/microcosms/1424/)

apps/deko/app.js

Lines changed: 55 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/deko/metadata.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
{
22
"id": "deko",
33
"name": "Deko Clock",
4-
"version": "0.01",
4+
"version": "0.02",
55
"description": "Clock with Art Deko font",
66
"readme": "README.md",
77
"icon": "app.png",
8-
"screenshots": [{"url":"screenshot.png"}],
8+
"screenshots": [
9+
{ "url": "screenshot.png" },
10+
{ "url": "screenshot-no-widgets.png" }
11+
],
912
"type": "clock",
1013
"tags": "clock",
11-
"supports": ["BANGLEJS","BANGLEJS2"],
14+
"supports": ["BANGLEJS", "BANGLEJS2"],
1215
"storage": [
13-
{"name":"deko.app.js","url":"app.js"},
14-
{"name":"deko.img","url":"app-icon.js","evaluate":true}
15-
]
16+
{ "name": "deko.app.js", "url": "app.js" },
17+
{ "name": "deko.settings.js", "url": "settings.js" },
18+
{ "name": "deko.img", "url": "app-icon.js", "evaluate": true }
19+
],
20+
"data": [{ "name": "deko.settings.json" }]
1621
}
2.45 KB
Loading

apps/deko/settings.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
(function (back) {
2+
const storage = require('Storage');
3+
const settingsFile = 'deko.settings.json';
4+
const defaultSettings = {
5+
loadWidgets: 1,
6+
};
7+
const settings = Object.assign(
8+
defaultSettings,
9+
storage.readJSON(settingsFile, 1) || {},
10+
);
11+
const loadWidgetsChoices = ['No', 'Yes', 'Unlocked'];
12+
13+
const save = () => storage.write(settingsFile, settings);
14+
15+
const appMenu = {
16+
'': { title: 'Deko Clock' },
17+
'< Back': back,
18+
'Load widgets?': {
19+
value: settings.loadWidgets,
20+
min: 0,
21+
max: 2,
22+
step: 1,
23+
format: (v) => loadWidgetsChoices[v],
24+
onchange: (v) => {
25+
settings.loadWidgets = v;
26+
save();
27+
},
28+
},
29+
};
30+
31+
E.showMenu(appMenu);
32+
})

apps/smartbatt/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v0.01: New app!

apps/smartbatt/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Smart Battery Module
2+
A module for providing a truly accurate battery life in terms of days. The module learns from daily usage and drainage patterns, and extrapolates that. As you use it more, and the battery keeps draining, the predictions should become more accurate.
3+
4+
Because the Bangle.js battery percent fluctuates naturally, it is highly recomended to use the `Power Manager` app and enable monotonic/stable percentage to stabilize the percentage, and reduce fluctuations. This may help provide more accurate readings.
5+
## Upon Install
6+
Use an app that needs this module, like `Smart Battery Widget`.
7+
When this app is installed, <i><b>do not rely on it for the first 24-30 hours.</b></i>
8+
The module might return different data than expected, or a severely low prediction. Give it time. It will learn from drainage rates, which needs the battery to drain. If your watch normally lasts for a long time on one charge, it will take longer for the module to return an accurate reading.
9+
10+
If you think something is wrong with the predictions after 3 days, try clearing the data, and let it rebuild again from scratch.
11+
## Clock Infos
12+
The module provides two clockInfos:
13+
- Days left
14+
- Learned drainage rate per hour
15+
16+
## Settings
17+
### Clear Data - Clears all learned data.
18+
Use this when you switch to a new clock or change the battery drainage in a fundamental way. The app averages drainage over time, and so you might just want to restart the learned data to be more accurate for the new configurations you have implemented.
19+
### Logging - Enables logging for stats that this module uses.
20+
To view the log file, go to the [Web IDE](https://www.espruino.com/ide/#), click on the storage icon (4 discs), and scroll to the file named `smartbattlog.json`. From there, you can view the file, copy to editor, or save it to your computer.
21+
Logs:
22+
* The time in a human-readable format (hh:mm:ss, mm:dd:yy) when the record event was triggered
23+
* The current battery percentage
24+
* The last saved battery percentage
25+
* The change in hours between the time last recorded and now
26+
* The average or learned drainage for battery per hour
27+
* The status of that record event:
28+
* Recorded
29+
* Skipped due to battery fluctuations or no change
30+
* Invalid time between the two periods (first record)
31+
## Functions
32+
From any app, you can call `require("smartbatt")` and then one of the functions below:
33+
* `require("smartbatt").record()` - Attempts to record the battery and push it to the average.
34+
* `require("smartbatt").get()` - Returns an object that contains:
35+
36+
37+
* `hrsRemaining` - Hours remaining
38+
* `avgDrainage` - Learned battery drainage per hour
39+
* `totalCycles` - Total times the battery has been recorded and averaged
40+
* `totalHours` - Total hours recorded
41+
* `batt` - Current battery level
42+
43+
44+
* `require("smartbatt").deleteData()` - Deletes all learned data. (Automatically re-learns)
45+
## Creator
46+
- RKBoss6
47+
## Contributors
48+
- RelapsingCertainly

apps/smartbatt/clkinfo.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
(function() {
2+
var batt;
3+
//updates values
4+
5+
6+
function getHrsFormatted(hrsLeft){
7+
8+
var daysLeft = hrsLeft / 24;
9+
daysLeft = Math.round(daysLeft);
10+
if(daysLeft >= 1) {
11+
return daysLeft+"d";
12+
}
13+
14+
else {
15+
return Math.round(hrsLeft)+"h";
16+
}
17+
}
18+
19+
//draws battery icon and fill bar
20+
function drawBatt(){
21+
batt =E.getBattery();
22+
var s=24,g=Graphics.createArrayBuffer(24,24,1,{msb:true});
23+
g.fillRect(0,6,s-3,18).clearRect(2,8,s-5,16).fillRect(s-2,10,s,15).fillRect(3,9,3+batt*(s-9)/100,15);
24+
g.transparent=0;
25+
return g.asImage("string");
26+
}
27+
28+
//calls both updates for values and icons.
29+
//might split in the future since values updates once every five minutes so we dont need to call it in every minute while the battery can be updated once a minute.
30+
function updateDisplay(){
31+
drawBatt();
32+
}
33+
34+
return {
35+
name: "SmartBatt",
36+
items: [
37+
{ name : "BattStatus",
38+
get : () => {
39+
40+
var img = drawBatt();
41+
var data=require("smartbatt").get();
42+
43+
//update clock info according to batt state
44+
if (Bangle.isCharging()) {
45+
return { text: batt+"%", img };
46+
}
47+
else{
48+
return { text: getHrsFormatted(data.hrsLeft), img };
49+
}
50+
},
51+
52+
show : function() {
53+
this.interval = setInterval(()=>{
54+
updateDisplay();
55+
this.emit('redraw');
56+
}, 300000);
57+
},
58+
59+
hide : function() {
60+
clearInterval(this.interval);
61+
this.interval = undefined;
62+
}
63+
},
64+
{ name : "AvgDrainage",
65+
get : () => {
66+
var img = drawBatt()
67+
var data=require("smartbatt").get();
68+
return { text: data.avgDrainage.toFixed(2)+"/h", img };
69+
},
70+
71+
show : function() {
72+
this.interval = setInterval(()=>{
73+
this.emit('redraw');
74+
}, 300000);
75+
},
76+
77+
hide : function() {
78+
clearInterval(this.interval);
79+
this.interval = undefined;
80+
}
81+
}
82+
]
83+
};
84+
})

apps/smartbatt/icon.png

403 KB
Loading

0 commit comments

Comments
 (0)