hwid-batt: option to show batt high mark

pull/2811/head
Rob Pilling 2023-06-11 12:41:24 +01:00
parent 60287b7252
commit 00c29eb6f6
3 changed files with 33 additions and 3 deletions

View File

@ -11,6 +11,8 @@
"tags": "widget,battery", "tags": "widget,battery",
"provides_widgets" : ["battery"], "provides_widgets" : ["battery"],
"storage": [ "storage": [
{"name":"hwid_a_battery_widget.wid.js","url":"widget.js"} {"name":"hwid_a_battery_widget.wid.js","url":"widget.js"},
] {"name":"hwid_a_battery_widget.setting.js","url":"settings.js"}
],
"data": [{"name":"hwid_a_battery_widget.settings.json"}]
} }

View File

@ -0,0 +1,22 @@
(back => {
const S = require('Storage');
const SETTINGS_FILE = "hwid_a_battery_widget.settings.json";
const settings = S.readJSON(SETTINGS_FILE, 1) || {
showHighMark: true,
};
const save = () => S.write(SETTINGS_FILE, settings);
E.showMenu({
'': { 'title': 'Battery Widget (hank mod)' },
'< Back': back,
'Show high mark': {
value: settings.showHighMark,
onchange: v => {
settings.showHighMark = v;
save();
},
},
});
})

View File

@ -1,4 +1,9 @@
(function(){ (function(){
const showHighMark = (
require("Storage").readJSON("hwid_a_battery_widget.settings.json",1) || {
showHighMark: true,
}).showHighMark;
const intervalLow = 60000; // update time when not charging const intervalLow = 60000; // update time when not charging
const intervalHigh = 2000; // update time when charging const intervalHigh = 2000; // update time when charging
var old_l; var old_l;
@ -48,7 +53,8 @@
g.setColor(levelColor(l)); g.setColor(levelColor(l));
g.fillRect(x+4,y+14+3,xl,y+16+3); // charging bar g.fillRect(x+4,y+14+3,xl,y+16+3); // charging bar
g.fillRect((x+4+100*(s-12)/100)-1,y+14+3,x+4+100*(s-12)/100,y+16+3); // charging bar "full mark" if (showHighMark)
g.fillRect((x+4+100*(s-12)/100)-1,y+14+3,x+4+100*(s-12)/100,y+16+3); // charging bar "full mark"
// Show percentage // Show percentage
g.setColor(COLORS.black); g.setColor(COLORS.black);
g.setFontAlign(0,0); g.setFontAlign(0,0);