chargent: support BangleJS2

pull/2540/head
Rob Pilling 2023-01-29 17:00:47 +00:00
parent bddef2ef0f
commit 1a49342ccf
4 changed files with 9 additions and 7 deletions

View File

@ -1 +1,2 @@
0.01: First version
0.02: Support BangleJS2

View File

@ -1,4 +1,6 @@
(() => {
const pin = process.env.HWVERSION === 2 ? D3 : D30;
var id;
Bangle.on('charging', (charging) => {
if (charging) {
@ -6,9 +8,9 @@
var max = 0;
var count = 0;
id = setInterval(() => {
var d30 = analogRead(D30);
if (max < d30) {
max = d30;
var battlvl = analogRead(pin);
if (max < battlvl) {
max = battlvl;
count = 0;
} else {
count++;

View File

@ -1 +0,0 @@
(function(){var a;Bangle.on("charging",function(e){if(e){if(!a){var c=0,b=0;a=setInterval(function(){var d=analogRead(D30);c<d?(c=d,b=0):(b++,10<=b&&(Bangle.buzz(500),setTimeout(function(){return Bangle.buzz(500)},1E3)))},3E4)}}else a&&(clearInterval(a),a=void 0)})})()

View File

@ -1,13 +1,13 @@
{ "id": "chargent",
"name": "Charge Gently",
"version": "0.01",
"version": "0.02",
"description": "When charging, reminds you to disconnect the watch to prolong battery life.",
"icon": "icon.png",
"type": "bootloader",
"tags": "battery",
"supports": ["BANGLEJS"],
"supports": ["BANGLEJS", "BANGLEJS2"],
"readme": "README.md",
"storage": [
{"name": "chargent.boot.js", "url": "boot.min.js"}
{"name": "chargent.boot.js", "url": "boot.js"}
]
}