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 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  

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 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 000000000..dc51aa01b Binary files /dev/null and b/apps/powermanager/app.png differ 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); +}) diff --git a/apps/widbaroalarm/metadata.json b/apps/widbaroalarm/metadata.json index 82aaab65a..9c58a41ab 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.02", "description": "A widget that can alarm on when the pressure reaches defined thresholds.", "icon": "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 000000000..4a042ec05 Binary files /dev/null and b/apps/widmnth/widget.png differ