From 401f197d1e7ecd14f0848ebfc4f1a4a84c86eca7 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 8 Mar 2022 11:43:04 +0000 Subject: [PATCH 1/6] fix #1548 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9cf30065a..38ce09f75 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,7 @@ and which gives information about the app for the Launcher. "screenshots" : [ { url:"screenshot.png" } ], // optional screenshot for app "type":"...", // optional(if app) - // 'app' - an application + // 'clock' - a clock - required for clocks to automatically start // 'widget' - a widget // 'launch' - replacement launcher app // 'bootloader' - code that runs at startup only From eca40798282f5ebde99238c4581bc458835c793f Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 8 Mar 2022 13:00:31 +0000 Subject: [PATCH 2/6] Fix issue with code uploader where it'd silently refuse to upload code with warnings in --- apps/custom/custom.html | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/apps/custom/custom.html b/apps/custom/custom.html index 684f813ae..307f2fd2f 100644 --- a/apps/custom/custom.html +++ b/apps/custom/custom.html @@ -16,12 +16,12 @@

Type your javascript code here

-

Then click

+

Then click  

From 30ade21eac2e17476d05fe2c94ce49be6ea528ef Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Tue, 8 Mar 2022 20:16:00 +0100 Subject: [PATCH 3/6] New power management app for setting a charging alarm and voltage offset --- apps/powermanager/ChangeLog | 1 + apps/powermanager/README.md | 15 ++++ apps/powermanager/app.png | Bin 0 -> 1202 bytes apps/powermanager/boot.js | 29 ++++++++ apps/powermanager/default.json | 4 + apps/powermanager/metadata.json | 17 +++++ apps/powermanager/settings.js | 125 ++++++++++++++++++++++++++++++++ 7 files changed, 191 insertions(+) create mode 100644 apps/powermanager/ChangeLog create mode 100644 apps/powermanager/README.md create mode 100644 apps/powermanager/app.png create mode 100644 apps/powermanager/boot.js create mode 100644 apps/powermanager/default.json create mode 100644 apps/powermanager/metadata.json create mode 100644 apps/powermanager/settings.js diff --git a/apps/powermanager/ChangeLog b/apps/powermanager/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/powermanager/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/apps/powermanager/README.md b/apps/powermanager/README.md new file mode 100644 index 000000000..f2cfcdf3e --- /dev/null +++ b/apps/powermanager/README.md @@ -0,0 +1,15 @@ +# Power manager + +Manages settings for charging. You can set a warning threshold to be able to disconnect the charger at a given percentage. Also allows to set the battery calibration offset. + +## Internals + +Battery calibration offset is set by writing `batFullVoltage` in setting.json + +## TODO + +* Optionally keep battery history and show as graph + +## Creator + +[halemmerich](https://github.com/halemmerich) diff --git a/apps/powermanager/app.png b/apps/powermanager/app.png new file mode 100644 index 0000000000000000000000000000000000000000..dc51aa01b227a901238a89efea92b9fea499c80a GIT binary patch literal 1202 zcmV;j1Wo&iP)r6rLSW%NLZf}TW{iIbICYNK}hu=e5Hx!##M_nv!a z><=66J$tXU|7)MU*IIiW+Jk9Wg2T@6_C$;SV{b|fzi#r9;-!T^> zQ@av>q`t*N#%=&i#ZGL)DRuf!#r8C2>LBtegkktZtnj>k#?4D(K20)v4Q>#`KF5fD z#tp~1H1_&I;8h3*p<9qTtHAg(@GmxFY#VtM#?ylQvIb<9C7Gw%!l(h9C=TUT9NvK3 zA=rXlIJphH3gaEIk_(%VU6^FwH$<^vP9pFXI-8L1OtKYRQPVdQ&tZHSg8g9>eoB*H zSVGVAq~mAohsh%C$RhWgay0wKII-_vY=N%jg6v0nryUg$&D)02$_Jwk+#x5t4fo&~ zgJ3{eoQ4nO!K5j@RxY4x3@@dhgkW{o9z(yg)th~LIdG^xv$Pzk$iqE-o#rq?Y25&_r(Lk zfQm3^t&#>DftRXCufeko7_eAxqbv9allqaFgcVA<(c10uOH$H-`2`K=#D+QsJX(;$ z41Aqr&TEAHSbUiTcj5^gP}N`5fUE3Dep8LEfzXMQiVUpwLI+|(`rR!OwJi-ynqhvO zXGNMP6}Psm z?cX-mRXAN-`?d=2Q4yDq{tTF$WNHnlZo9S1A2)fl3hFfr~sIp}w7WE;w1mD%P zT7zzCg8crX&a|SaKvrQ`C#nb;W+f$syo0C>Rg=H3D1jP`!1qbV?12V1T4Cr9Ps+(J zRqon2GwE3`B6pu?rovDUox=B5#9M2H7kVw}d#JAg%~lxd;S%{RYfMR98IHo=g5w_B zxI?)LLoJqzbf6WfcQx*o=VraOBxRN` zs%CJJ{6KfXb?L#X7ERFVZBq|fT)LLHcvM6lGgz1+Tz0cKS8!fQe8bwIx$0V@m>{nM zJzqjkmq>BC2?Mrk?+1r{aF?k2WWnu?68eUTMel}plfsM3aqJT_@U8r#-z&-+kVWP- zM1D~b9~>^zy4-yNUX`!-+c-h&|7HyskvRUAbj;3z!6R6Zes306%Wmv0sCcueIBZM* zZxp4GQR05Q057DzDI(k5i1!NWA1>m{@i;g=dst1-oi0irwFTB9ZMXd9M(>j0JiX7? zlmhztYCXbhUXUrPmm!W8Rk-nrd!`NItz|eAkIAFuTHK7!FWH?L&uU5o?A;sCkrCu}CMD_~&2coHWFPlaz QHUIzs07*qoM6N<$g5tA6ga7~l literal 0 HcmV?d00001 diff --git a/apps/powermanager/boot.js b/apps/powermanager/boot.js new file mode 100644 index 000000000..ff4ba8932 --- /dev/null +++ b/apps/powermanager/boot.js @@ -0,0 +1,29 @@ +(function() { + var settings = Object.assign( + require('Storage').readJSON("powermanager.default.json", true) || {}, + require('Storage').readJSON("powermanager.json", true) || {} + ); + + if (settings.warnEnabled){ + print("Charge warning enabled"); + var chargingInterval; + + function handleCharging(charging){ + if (charging){ + if (chargingInterval) clearInterval(chargingInterval); + chargingInterval = setInterval(()=>{ + if (E.getBattery() > settings.warn){ + Bangle.buzz(1000); + } + }, 10000); + } + if (chargingInterval && !charging){ + clearInterval(chargingInterval); + chargingInterval = undefined; + } + } + + Bangle.on("charging",handleCharging); + handleCharging(Bangle.isCharging()); + } +})(); diff --git a/apps/powermanager/default.json b/apps/powermanager/default.json new file mode 100644 index 000000000..a6d8412b2 --- /dev/null +++ b/apps/powermanager/default.json @@ -0,0 +1,4 @@ +{ + "warnEnabled": false, + "warn": 96 +} diff --git a/apps/powermanager/metadata.json b/apps/powermanager/metadata.json new file mode 100644 index 000000000..3ad31ba1e --- /dev/null +++ b/apps/powermanager/metadata.json @@ -0,0 +1,17 @@ +{ + "id": "powermanager", + "name": "Power Manager", + "shortName": "Power Manager", + "version": "0.01", + "description": "Allow configuration of warnings and thresholds for battery charging and display.", + "icon": "app.png", + "type": "bootloader", + "tags": "tool", + "supports": ["BANGLEJS2"], + "readme": "README.md", + "storage": [ + {"name":"powermanager.boot.js","url":"boot.js"}, + {"name":"powermanager.settings.js","url":"settings.js"}, + {"name":"powermanager.default.json","url":"default.json"} + ] +} diff --git a/apps/powermanager/settings.js b/apps/powermanager/settings.js new file mode 100644 index 000000000..c8aa057fa --- /dev/null +++ b/apps/powermanager/settings.js @@ -0,0 +1,125 @@ +(function(back) { + var systemsettings = require("Storage").readJSON("setting.json") || {}; + + function writeSettings(key, value) { + var s = require('Storage').readJSON(FILE, true) || {}; + s[key] = value; + require('Storage').writeJSON(FILE, s); + readSettings(); + } + + function readSettings() { + settings = Object.assign( + require('Storage').readJSON("powermanager.default.json", true) || {}, + require('Storage').readJSON(FILE, true) || {} + ); + } + + var FILE = "powermanager.json"; + var settings; + readSettings(); + + var mainmenu = { + '': { + 'title': 'Power Manager' + }, + '< Back': back, + 'Charge warning': function() { + E.showMenu(submenu_chargewarn); + }, + 'Calibrate': function() { + E.showMenu(submenu_calibrate); + } + }; + + + function roundToDigits(number, stepsize) { + return Math.round(number / stepsize) * stepsize; + } + + function getCurrentVoltageDirect() { + return (analogRead(D3) + analogRead(D3) + analogRead(D3) + analogRead(D3)) / 4; + } + + var stepsize = 0.0002; + var full = 0.32; + + function getInitialCalibrationOffset() { + return roundToDigits(systemsettings.batFullVoltage - full, stepsize) || 0; + } + + + var submenu_calibrate = { + '': { + title: "Calibrate" + }, + '< Back': function() { + E.showMenu(mainmenu); + }, + 'Offset': { + min: -0.05, + max: 0.05, + step: stepsize, + value: getInitialCalibrationOffset(), + format: v => roundToDigits(v, stepsize).toFixed((""+stepsize).length - 2), + onchange: v => { + print(typeof v); + systemsettings.batFullVoltage = v + full; + require("Storage").writeJSON("setting.json", systemsettings); + } + }, + 'Auto': function() { + var newVoltage = getCurrentVoltageDirect(); + E.showAlert("Please charge fully before auto setting").then(() => { + E.showPrompt("Set current charge as full").then((r) => { + if (r) { + systemsettings.batFullVoltage = newVoltage; + require("Storage").writeJSON("setting.json", systemsettings); + //reset value shown in menu to the newly set one + submenu_calibrate.Offset.value = getInitialCalibrationOffset(); + E.showMenu(mainmenu); + } + }); + }); + }, + 'Clear': function() { + E.showPrompt("Clear charging offset?").then((r) => { + if (r) { + delete systemsettings.batFullVoltage; + require("Storage").writeJSON("setting.json", systemsettings); + //reset value shown in menu to the newly set one + submenu_calibrate.Offset.value = getInitialCalibrationOffset(); + E.showMenu(mainmenu); + } + }); + } + }; + + var submenu_chargewarn = { + '': { + title: "Charge warning" + }, + '< Back': function() { + E.showMenu(mainmenu); + }, + 'Enabled': { + value: !!settings.warnEnabled, + format: v => settings.warnEnabled ? "On" : "Off", + onchange: v => { + writeSettings("warnEnabled", v); + } + }, + 'Percentage': { + min: 80, + max: 100, + step: 2, + value: settings.warn, + format: v => v + "%", + onchange: v => { + writeSettings("warn", v); + } + } + }; + + E.showMenu(mainmenu); +}) From d92fa8fb1a3af44a59ad6e57d03f61332c4916ef Mon Sep 17 00:00:00 2001 From: Nicholas Onorato Date: Tue, 8 Mar 2022 20:45:19 -0700 Subject: [PATCH 4/6] Added my countdown widget --- apps/widmnth/ChangeLog | 1 + apps/widmnth/README.md | 22 +++++++++++++++++++ apps/widmnth/metadata.json | 14 +++++++++++++ apps/widmnth/widget.js | 42 +++++++++++++++++++++++++++++++++++++ apps/widmnth/widget.png | Bin 0 -> 470 bytes 5 files changed, 79 insertions(+) create mode 100644 apps/widmnth/ChangeLog create mode 100644 apps/widmnth/README.md create mode 100644 apps/widmnth/metadata.json create mode 100644 apps/widmnth/widget.js create mode 100644 apps/widmnth/widget.png diff --git a/apps/widmnth/ChangeLog b/apps/widmnth/ChangeLog new file mode 100644 index 000000000..370f41e8a --- /dev/null +++ b/apps/widmnth/ChangeLog @@ -0,0 +1 @@ +0.01: Simple new widget! diff --git a/apps/widmnth/README.md b/apps/widmnth/README.md new file mode 100644 index 000000000..ef912c739 --- /dev/null +++ b/apps/widmnth/README.md @@ -0,0 +1,22 @@ +# Widget Name + +The days left in month widget is simple and just prints the number of days left in the month in the top left corner. +The idea is to encourage people to keep track of time and keep goals they may have for the month. + +## Usage + +Hopefully you just have to Install it and it'll work. Customizing the location would just be changing tl to tr. + +## Features + +* Shows days left in month +* Only updates at midnight. + + +## Requests + +Complaints,compliments,problems,suggestions,annoyances,bugs, and all other feedback can be filed at [this repo](https://github.com/N-Onorato/BangleApps) + +## Creator + +Nick diff --git a/apps/widmnth/metadata.json b/apps/widmnth/metadata.json new file mode 100644 index 000000000..25f3a8126 --- /dev/null +++ b/apps/widmnth/metadata.json @@ -0,0 +1,14 @@ +{ "id": "widmnth", + "name": "Days left in month widget", + "shortName":"Month Countdown", + "version":"0.01", + "description": "A simple widget that displays the number of days left in the month.", + "icon": "widget.png", + "type": "widget", + "tags": "widget,date,time,countdown,month", + "supports" : ["BANGLEJS","BANGLEJS2"], + "readme": "README.md", + "storage": [ + {"name":"widmnth.wid.js","url":"widget.js"} + ] +} diff --git a/apps/widmnth/widget.js b/apps/widmnth/widget.js new file mode 100644 index 000000000..c4eca155a --- /dev/null +++ b/apps/widmnth/widget.js @@ -0,0 +1,42 @@ + +(() => { + var days_left; + var clearCode; + + function getDaysLeft(day) { + let year = day.getMonth() == 11 ? day.getFullYear() + 1 : day.getFullYear(); // rollover if december. + next_month = new Date(year, (day.getMonth() + 1) % 12, 1, 0, 0, 0); + let days_left = Math.floor((next_month - day) / 86400000); // ms left in month divided by ms in a day + return days_left; + } + + function getTimeTilMidnight(now) { + let midnight = new Date(now.getTime()); + midnight.setHours(23); + midnight.setMinutes(59); + midnight.setSeconds(59); + midnight.setMilliseconds(999); + return (midnight - now) + 1; + } + + function update() { + let now = new Date(); + days_left = getDaysLeft(now); + let ms_til_midnight = getTimeTilMidnight(now); + clearCode = setTimeout(update, ms_til_midnight); + } + + function draw() { + g.reset(); + g.setFont("4x6", 3); + if(!clearCode) update(); // On first run calculate days left and setup interval to update state. + g.drawString(days_left < 10 ? "0" + days_left : days_left.toString(), this.x + 2, this.y + 4); + } + + // add your widget + WIDGETS.widmonthcountdown={ + area:"tl", // tl (top left), tr (top right), bl (bottom left), br (bottom right) + width: 24, + draw:draw + }; +})(); \ No newline at end of file diff --git a/apps/widmnth/widget.png b/apps/widmnth/widget.png new file mode 100644 index 0000000000000000000000000000000000000000..4a042ec05559285fa9ea28f8050432e3110adb5f GIT binary patch literal 470 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfvg8-ip*Uk#h-Aht{yyNS#ERE!1 z1C1m^c@L~eJGwU0KuhY#>Wp9y9ZeOn#r@$N>?|i;)!H{|fm92W1o;L3M+FQIlw&1< za-0Pok;M!Q+#5icQOZJ~h=GC8z|+MsL}OxdK#*Ib7taw6iNy?TA?pNpaUEh3Fcy0= z=WJfi25Am69j28AB|$+!f@YyiOraYZwoXc$6x3oG!H{!Ib?NIxUR~SD-`^{}#5()n zlGv?bp5;eBePUXgFoA1r>z-r0UR_6z9s3@laBZE@wh4i=?rqJQI=QJ(IKW}?;++@$ zUxvAFKDfB2FKvRP?Ah`uLTkcGO0-y`9YRc0R&qp_tl6=oL{ewL9ns~-_bpnySlMrR z1#3j>iN(xKPoIh%YY*uO*I}ELD9Tc__)wRdYG}9KhOGjP>*7>HleITUD(X2rxSja= zQNo=@4*u1m-PW@j&o#7bUYN$m{kTtU2G{D))w>*$3Up=9ipd_66)Rv|Evjv$qvJ4Z yL0U;kgK0^_*#IM^L#|%F4ni#pnK(KW85k1fyG8kLhC~1Zl)=;0&t;ucLK6TlqO}$P literal 0 HcmV?d00001 From e0937a942b216dd41fa574a39ed2186f34603398 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 9 Mar 2022 13:39:19 +0000 Subject: [PATCH 5/6] messages 0.25: Fix widget memory usage issues if message received and watch repeatedly calls Bangle.drawWidgets (fix #1550) --- apps/gbridge/metadata.json | 2 +- apps/messages/ChangeLog | 3 ++- apps/messages/metadata.json | 2 +- apps/messages/widget.js | 7 ++++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/gbridge/metadata.json b/apps/gbridge/metadata.json index 0c46aa852..db7119758 100644 --- a/apps/gbridge/metadata.json +++ b/apps/gbridge/metadata.json @@ -2,7 +2,7 @@ "id": "gbridge", "name": "Gadgetbridge", "version": "0.26", - "description": "(NOT RECOMMENDED) Displays Gadgetbridge notifications from Android. Please use the 'Android' Bangle.js app instead.", + "description": "(NOT RECOMMENDED) Displays Gadgetbridge notifications from Android. Please use the 'Android Integration' Bangle.js app instead.", "icon": "app.png", "type": "widget", "tags": "tool,system,android,widget", diff --git a/apps/messages/ChangeLog b/apps/messages/ChangeLog index bd40868a5..02492d5ea 100644 --- a/apps/messages/ChangeLog +++ b/apps/messages/ChangeLog @@ -35,5 +35,6 @@ Allow repeat to be switched Off, so there is no buzzing repetition. Also gave the widget a pixel more room to the right 0.23: Change message colors to match current theme instead of using green - Now attempt to use Large/Big/Medium fonts, and allow minimum font size to be configured + Now attempt to use Large/Big/Medium fonts, and allow minimum font size to be configured 0.24: Remove left-over debug statement +0.25: Fix widget memory usage issues if message received and watch repeatedly calls Bangle.drawWidgets (fix #1550) diff --git a/apps/messages/metadata.json b/apps/messages/metadata.json index 0387c1972..ff6a078a5 100644 --- a/apps/messages/metadata.json +++ b/apps/messages/metadata.json @@ -1,7 +1,7 @@ { "id": "messages", "name": "Messages", - "version": "0.24", + "version": "0.25", "description": "App to display notifications from iOS and Gadgetbridge/Android", "icon": "app.png", "type": "app", diff --git a/apps/messages/widget.js b/apps/messages/widget.js index d9363573a..ad8d58c40 100644 --- a/apps/messages/widget.js +++ b/apps/messages/widget.js @@ -1,5 +1,10 @@ WIDGETS["messages"]={area:"tl", width:0, iconwidth:24, draw:function() { + // If we had a setTimeout queued from the last time we were called, remove it + if (WIDGETS["messages"].i) { + clearTimeout(WIDGETS["messages"].i); + delete WIDGETS["messages"].i; + } Bangle.removeListener('touch', this.touch); if (!this.width) return; var c = (Date.now()-this.t)/1000; @@ -11,7 +16,7 @@ draw:function() { this.l = Date.now(); WIDGETS["messages"].buzz(); // buzz every 4 seconds } - setTimeout(()=>WIDGETS["messages"].draw(), 1000); + WIDGETS["messages"].i=setTimeout(()=>WIDGETS["messages"].draw(), 1000); if (process.env.HWVERSION>1) Bangle.on('touch', this.touch); },show:function(quiet) { WIDGETS["messages"].t=Date.now(); // first time From c1c7d2b484e16064939324aa700806f77b547e39 Mon Sep 17 00:00:00 2001 From: fparri Date: Thu, 10 Mar 2022 11:36:11 +0100 Subject: [PATCH 6/6] Update metadata.json I only changed the name of the app so that it shows the initials in uppercase. --- apps/widbaroalarm/metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/widbaroalarm/metadata.json b/apps/widbaroalarm/metadata.json index 0976df531..0953f4f1b 100644 --- a/apps/widbaroalarm/metadata.json +++ b/apps/widbaroalarm/metadata.json @@ -1,7 +1,7 @@ { "id": "widbaroalarm", - "name": "Barometer alarm widget", - "shortName": "Barometer alarm", + "name": "Barometer Alarm Widget", + "shortName": "Barometer Alarm", "version": "0.01", "description": "A widget that can alarm on when the pressure reaches defined thresholds.", "icon": "widget.png",