chargent: support BangleJS2

master
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.01: First version
0.02: Support BangleJS2

View File

@ -1,4 +1,6 @@
(() => { (() => {
const pin = process.env.HWVERSION === 2 ? D3 : D30;
var id; var id;
Bangle.on('charging', (charging) => { Bangle.on('charging', (charging) => {
if (charging) { if (charging) {
@ -6,9 +8,9 @@
var max = 0; var max = 0;
var count = 0; var count = 0;
id = setInterval(() => { id = setInterval(() => {
var d30 = analogRead(D30); var battlvl = analogRead(pin);
if (max < d30) { if (max < battlvl) {
max = d30; max = battlvl;
count = 0; count = 0;
} else { } else {
count++; 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", { "id": "chargent",
"name": "Charge Gently", "name": "Charge Gently",
"version": "0.01", "version": "0.02",
"description": "When charging, reminds you to disconnect the watch to prolong battery life.", "description": "When charging, reminds you to disconnect the watch to prolong battery life.",
"icon": "icon.png", "icon": "icon.png",
"type": "bootloader", "type": "bootloader",
"tags": "battery", "tags": "battery",
"supports": ["BANGLEJS"], "supports": ["BANGLEJS", "BANGLEJS2"],
"readme": "README.md", "readme": "README.md",
"storage": [ "storage": [
{"name": "chargent.boot.js", "url": "boot.min.js"} {"name": "chargent.boot.js", "url": "boot.js"}
] ]
} }