From ad6e2f71080f997e76c5a6c65aa594babb4477ff Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Fri, 24 Feb 2023 20:03:19 +0100 Subject: [PATCH 01/44] tweak clearRect width to not clear the indicator segment --- apps/runplus/karvonnen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/runplus/karvonnen.js b/apps/runplus/karvonnen.js index 7e7c07050..f50bd221b 100644 --- a/apps/runplus/karvonnen.js +++ b/apps/runplus/karvonnen.js @@ -67,7 +67,7 @@ // HR data: large, readable, in the middle of the screen function drawHR() { g.setFontAlign(-1,0,0); - g.clearRect(Rdiv(x,11/4),Rdiv(y,2)-25,Rdiv(x,11/4)+50*2,Rdiv(y,2)+25); + g.clearRect(Rdiv(x,11/4),Rdiv(y,2)-25,Rdiv(x,11/4)+50*2-14,Rdiv(y,2)+25); g.setColor(g.theme.fg); g.setFont("Vector",50); g.drawString(hr, Rdiv(x,11/4), Rdiv(y,2)+4); From a73543365211cc824106a0d0618ed7684ddf4ce6 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Fri, 24 Feb 2023 21:02:45 +0100 Subject: [PATCH 02/44] bump version --- apps/runplus/ChangeLog | 3 ++- apps/runplus/metadata.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/runplus/ChangeLog b/apps/runplus/ChangeLog index d3426428d..f47bcc720 100644 --- a/apps/runplus/ChangeLog +++ b/apps/runplus/ChangeLog @@ -13,4 +13,5 @@ 0.12: Fix for recorder not stopping at end of run. Bug introduced in 0.11 0.13: Revert #1578 (stop duplicate entries) as with 2v12 menus it causes other boxes to be wiped (fix #1643) 0.14: Fix Bangle.js 1 issue where after the 'overwrite track' menu, the start/stop button stopped working -0.15: Diverge from the standard "Run" app. Swipe to intensity interface a la Karvonnen (curtesy of FTeacher at https://github.com/f-teacher) +0.15: Diverge from the standard "Run" app. Swipe to intensity interface a la Karvonen (curtesy of FTeacher at https://github.com/f-teacher) +0.16: Don't clear zone 2b indicator segment when updating HRM reading. diff --git a/apps/runplus/metadata.json b/apps/runplus/metadata.json index 15492e20c..a28d36674 100644 --- a/apps/runplus/metadata.json +++ b/apps/runplus/metadata.json @@ -1,7 +1,7 @@ { "id": "runplus", "name": "Run+", - "version": "0.15", + "version": "0.16", "description": "Displays distance, time, steps, cadence, pace and more for runners. Based on the Run app, but extended with additional screen for heart rate interval training.", "icon": "app.png", "tags": "run,running,fitness,outdoors,gps,karvonnen", From 7f20125fd949534fa2517a9a558727987167b13f Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Fri, 24 Feb 2023 21:54:49 +0100 Subject: [PATCH 03/44] powermanager - Fix wrapping of deferred functions with parameters --- apps/powermanager/boot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/powermanager/boot.js b/apps/powermanager/boot.js index c931a243b..40487a5bf 100644 --- a/apps/powermanager/boot.js +++ b/apps/powermanager/boot.js @@ -84,7 +84,7 @@ if (!a.__wrapped){ wrapped = ()=>{ let start = Date.now(); - let result = a.apply(undefined, arguments.slice(1)); + let result = a.apply(undefined, arguments.slice(2)); // function arguments for deferred calls start at index 2, first is function, second is time let end = Date.now()-start; let f = a.toString().substring(0,100); if (settings.logDetails) logDeferred(t, end, f); From eab7ae25d9eaa25ac493842e4e41dbb5bc8a34b9 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Fri, 24 Feb 2023 21:56:48 +0100 Subject: [PATCH 04/44] powermanager - Bump version --- apps/powermanager/ChangeLog | 1 + apps/powermanager/metadata.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/powermanager/ChangeLog b/apps/powermanager/ChangeLog index a43558c3f..dbe102958 100644 --- a/apps/powermanager/ChangeLog +++ b/apps/powermanager/ChangeLog @@ -7,3 +7,4 @@ 0.06: Allow logging of some things using power Add widget for live monitoring of power use 0.07: Convert Yes/No On/Off in settings to checkboxes +0.08: Fix the wrapping of intervals/timeouts with parameters \ No newline at end of file diff --git a/apps/powermanager/metadata.json b/apps/powermanager/metadata.json index ca5a9f00b..2229629a9 100644 --- a/apps/powermanager/metadata.json +++ b/apps/powermanager/metadata.json @@ -2,7 +2,7 @@ "id": "powermanager", "name": "Power Manager", "shortName": "Power Manager", - "version": "0.07", + "version": "0.08", "description": "Allow configuration of warnings and thresholds for battery charging and display.", "icon": "app.png", "type": "bootloader", From 0db11e57073acc846d047b07005b4dd384969229 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Sat, 25 Feb 2023 12:40:25 +0100 Subject: [PATCH 05/44] write to correct settings file --- apps/runplus/ChangeLog | 1 + apps/runplus/settings.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/runplus/ChangeLog b/apps/runplus/ChangeLog index f47bcc720..3eeb31733 100644 --- a/apps/runplus/ChangeLog +++ b/apps/runplus/ChangeLog @@ -15,3 +15,4 @@ 0.14: Fix Bangle.js 1 issue where after the 'overwrite track' menu, the start/stop button stopped working 0.15: Diverge from the standard "Run" app. Swipe to intensity interface a la Karvonen (curtesy of FTeacher at https://github.com/f-teacher) 0.16: Don't clear zone 2b indicator segment when updating HRM reading. +Write to correct settings file, fixing settings not working. diff --git a/apps/runplus/settings.js b/apps/runplus/settings.js index 050eed4b8..cd72022be 100644 --- a/apps/runplus/settings.js +++ b/apps/runplus/settings.js @@ -1,5 +1,5 @@ (function(back) { - const SETTINGS_FILE = "run.json"; + const SETTINGS_FILE = "runplus.json"; var ExStats = require("exstats"); var statsList = ExStats.getList(); statsList.unshift({name:"-",id:""}); // add blank menu item From 3d21d2bef438a9e992905137829259dbfd402b77 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Sat, 25 Feb 2023 12:54:10 +0100 Subject: [PATCH 06/44] contributors appended to readme --- apps/runplus/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/runplus/README.md b/apps/runplus/README.md index 7f645b518..659cd964d 100644 --- a/apps/runplus/README.md +++ b/apps/runplus/README.md @@ -67,3 +67,10 @@ app loader, the module is automatically included in the app's source. However when developing via the IDE the module won't get pulled in by default. There are some options to fix this easily - please check out the [modules README.md file](https://github.com/espruino/BangleApps/blob/master/modules/README.md) +## Contributors (Run and Run+) +gfwilliams +hughbarney +GrandVizierOlaf +BartS23 +f-teacher +thyttan From 290fd81f46e60e46cdd3ee2a2c36d6e663e16bab Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sat, 25 Feb 2023 13:13:04 +0100 Subject: [PATCH 07/44] powermanager - Fix drawing on hidden widgets when LCD brightness is changed --- apps/powermanager/ChangeLog | 3 ++- apps/powermanager/widget.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/powermanager/ChangeLog b/apps/powermanager/ChangeLog index dbe102958..ee31195b2 100644 --- a/apps/powermanager/ChangeLog +++ b/apps/powermanager/ChangeLog @@ -7,4 +7,5 @@ 0.06: Allow logging of some things using power Add widget for live monitoring of power use 0.07: Convert Yes/No On/Off in settings to checkboxes -0.08: Fix the wrapping of intervals/timeouts with parameters \ No newline at end of file +0.08: Fix the wrapping of intervals/timeouts with parameters + Fix the widget drawing if widgets are hidden and Bangle.setLCDBrightness is called \ No newline at end of file diff --git a/apps/powermanager/widget.js b/apps/powermanager/widget.js index 116f1703e..3147c40ac 100644 --- a/apps/powermanager/widget.js +++ b/apps/powermanager/widget.js @@ -24,7 +24,7 @@ currently-running apps */ let brightnessSetting = settings.brightness || 1; Bangle.setLCDBrightness = ((o) => (a) => { brightnessSetting = a; - draw(WIDGETS.powermanager); + WIDGETS.powermanager.draw(WIDGETS.powermanager); return o(a); })(Bangle.setLCDBrightness); From 4a4c9315710f38d76c34a4b62c75acededab25ab Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Sat, 25 Feb 2023 13:47:51 +0100 Subject: [PATCH 08/44] add to the instruction for # of handlers i readme --- apps/backswipe/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/backswipe/README.md b/apps/backswipe/README.md index 1611263bb..21aa357b3 100644 --- a/apps/backswipe/README.md +++ b/apps/backswipe/README.md @@ -10,6 +10,12 @@ Standard # of drag handlers: 0-10 (Default: 0, must be changed for backswipe to Standard # of handlers settings are used to fine tune when backswipe should trigger the back function. E.g. when using a keyboard that works on drags, we don't want the backswipe to trigger when we just wanted to select a letter. This might not be able to cover all cases however. +To get an indication for standard # of handlers `Bangle["#onswipe"]` and `Bangle["#ondrag"]` can be entered in the [Espruino Web IDE](https://www.espruino.com/ide) console field. They return `undefined` if no handler is active, a function if one is active, or a list of functions if multiple are active. Calling this on the clock app is a good start. + +## TODO + +- Possibly add option to tweak standard # of handlers on per app basis. + ## Creator Kedlub From 21c928ba8796470aa60fea568fecaee356a73c4c Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Sat, 25 Feb 2023 17:51:08 +0100 Subject: [PATCH 09/44] add tag karvonen --- apps/runplus/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/runplus/metadata.json b/apps/runplus/metadata.json index a28d36674..2c221e0d4 100644 --- a/apps/runplus/metadata.json +++ b/apps/runplus/metadata.json @@ -4,7 +4,7 @@ "version": "0.16", "description": "Displays distance, time, steps, cadence, pace and more for runners. Based on the Run app, but extended with additional screen for heart rate interval training.", "icon": "app.png", - "tags": "run,running,fitness,outdoors,gps,karvonnen", + "tags": "run,running,fitness,outdoors,gps,karvonen,karvonnen", "supports": [ "BANGLEJS2" ], From 5e1857d963975e238af2a8825d0f2f3108c56901 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Sat, 25 Feb 2023 18:13:50 +0100 Subject: [PATCH 10/44] change spelling karvonnen -> karvonen in app.js, karvonen.js --- apps/runplus/app.js | 26 +++++++++++----------- apps/runplus/{karvonnen.js => karvonen.js} | 12 +++++----- 2 files changed, 19 insertions(+), 19 deletions(-) rename apps/runplus/{karvonnen.js => karvonen.js} (96%) diff --git a/apps/runplus/app.js b/apps/runplus/app.js index 15e042759..06270850f 100644 --- a/apps/runplus/app.js +++ b/apps/runplus/app.js @@ -2,7 +2,7 @@ let wu = require("widget_utils"); let runInterval; -let karvonnenActive = false; +let karvonenActive = false; // Run interface wrapped in a function let ExStats = require("exstats"); let B2 = process.env.HWVERSION===2; @@ -121,7 +121,7 @@ lc.push({ type:"h", filly:1, c:[ // Now calculate the layout let layout = new Layout( { type:"v", c: lc -},{lazy:true, btns:[{ label:"START", cb: ()=>{if (karvonnenActive) {stopKarvonnenUI();run();} onStartStop();}, id:"button"}]}); +},{lazy:true, btns:[{ label:"START", cb: ()=>{if (karvonenActive) {stopKarvonenUI();run();} onStartStop();}, id:"button"}]}); delete lc; layout.render(); @@ -150,7 +150,7 @@ Bangle.on("GPS", function(fix) { } }); -// run() function used to switch between traditional run UI and karvonnen UI +// run() function used to switch between traditional run UI and karvonen UI function run() { wu.show(); layout.lazy = false; @@ -160,35 +160,35 @@ function run() { if (!runInterval){ runInterval = setInterval(function() { layout.clock.label = locale.time(new Date(),1); - if (!isMenuDisplayed && !karvonnenActive) layout.render(); + if (!isMenuDisplayed && !karvonenActive) layout.render(); }, 1000); } } run(); /////////////////////////////////////////////// -// Karvonnen +// Karvonen /////////////////////////////////////////////// function stopRunUI() { // stop updating and drawing the traditional run app UI clearInterval(runInterval); runInterval = undefined; - karvonnenActive = true; + karvonenActive = true; } -function stopKarvonnenUI() { +function stopKarvonenUI() { g.reset().clear(); - clearInterval(karvonnenInterval); - karvonnenInterval = undefined; - karvonnenActive = false; + clearInterval(karvonenInterval); + karvonenInterval = undefined; + karvonenActive = false; } -let karvonnenInterval; +let karvonenInterval; // Define the function to go back and forth between the different UI's function swipeHandler(LR,_) { - if (LR==-1 && karvonnenActive && !isMenuDisplayed) {stopKarvonnenUI(); run();} - if (LR==1 && !karvonnenActive && !isMenuDisplayed) {stopRunUI(); karvonnenInterval = eval(require("Storage").read("runplus_karvonnen"))(settings.HRM, exs.stats.bpm);} + if (LR==-1 && karvonenActive && !isMenuDisplayed) {stopKarvonenUI(); run();} + if (LR==1 && !karvonenActive && !isMenuDisplayed) {stopRunUI(); karvonenInterval = eval(require("Storage").read("runplus_karvonen"))(settings.HRM, exs.stats.bpm);} } // Listen for swipes with the swipeHandler Bangle.on("swipe", swipeHandler); diff --git a/apps/runplus/karvonnen.js b/apps/runplus/karvonen.js similarity index 96% rename from apps/runplus/karvonnen.js rename to apps/runplus/karvonen.js index f50bd221b..de81494bb 100644 --- a/apps/runplus/karvonnen.js +++ b/apps/runplus/karvonen.js @@ -1,6 +1,6 @@ -(function karvonnen(hrmSettings, exsHrmStats) { +(function karvonen(hrmSettings, exsHrmStats) { //This app is an extra feature implementation for the Run.app of the bangle.js. It's called run+ - //The calculation of the Heart Rate Zones is based on the Karvonnen method. It requires to know maximum and minimum heart rates. More precise calculation methods require a lab. + //The calculation of the Heart Rate Zones is based on the Karvonen method. It requires to know maximum and minimum heart rates. More precise calculation methods require a lab. //Other methods are even more approximative. let wu = require("widget_utils"); wu.hide(); @@ -56,7 +56,7 @@ let hr = exsHrmStats.getValue(); let hr1 = hr; // These letiables display next and previous HR zone. - //get the hrzones right. The calculation of the Heart rate zones here is based on the Karvonnen method + //get the hrzones right. The calculation of the Heart rate zones here is based on the Karvonen method //60-70% of HRR+minHR = zone2. //70-80% of HRR+minHR = zone3. //80-90% of HRR+minHR = zone4. //90-99% of HRR+minHR = zone5. //=>99% of HRR+minHR = serious risk of heart attack let minzone2 = hrr * 0.6 + minhr; let maxzone2 = hrr * 0.7 + minhr; @@ -207,9 +207,9 @@ initDraw(); // check for updates every second. - karvonnenInterval = setInterval(function() { - if (!isMenuDisplayed && karvonnenActive) updateUI(); + karvonenInterval = setInterval(function() { + if (!isMenuDisplayed && karvonenActive) updateUI(); }, 1000); - return karvonnenInterval; + return karvonenInterval; }) From 4199f8a4fcd0ce7b4e33a27ed2583bbff060e107 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Sat, 25 Feb 2023 18:16:25 +0100 Subject: [PATCH 11/44] spelling karvonnen -> karvonen in metadata --- apps/runplus/metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/runplus/metadata.json b/apps/runplus/metadata.json index 2c221e0d4..017a52ac3 100644 --- a/apps/runplus/metadata.json +++ b/apps/runplus/metadata.json @@ -29,8 +29,8 @@ "url": "settings.js" }, { - "name": "runplus_karvonnen", - "url": "karvonnen.js" + "name": "runplus_karvonen", + "url": "karvonen.js" } ], "data": [ From 9403bf05b01176da217388ddb435f7cbadf2ab5c Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Sun, 29 Jan 2023 23:01:52 +0000 Subject: [PATCH 12/44] clock_info.d.ts .app addition --- typescript/types/clock_info.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/typescript/types/clock_info.d.ts b/typescript/types/clock_info.d.ts index 9b664a6dc..06a2d400b 100644 --- a/typescript/types/clock_info.d.ts +++ b/typescript/types/clock_info.d.ts @@ -44,6 +44,7 @@ declare module ClockInfo { w: number, h: number, draw(itm: MenuItem, info: Item, options: InteractiveOptions): void, + app?: string, // used to remember clock_info locations, per app }; type InteractiveOptions = From e44e4c0274df593da6fea68ed9a270329cd18c81 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Sat, 25 Feb 2023 22:23:10 +0000 Subject: [PATCH 13/44] Regenerate main.d.ts - fromEntries & getOwnPropertyDescriptors --- typescript/types/main.d.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/typescript/types/main.d.ts b/typescript/types/main.d.ts index 1505c6f5a..8a9273a76 100644 --- a/typescript/types/main.d.ts +++ b/typescript/types/main.d.ts @@ -8688,6 +8688,15 @@ interface ObjectConstructor { */ entries(object: any): Array<[string, any]>; + /** + * Transforms an array of key-value pairs into an object + * + * @param {any} entries - An array of `[key,value]` pairs to be used to create an object + * @returns {any} An object containing all the specified pairs + * @url http://www.espruino.com/Reference#l_Object_fromEntries + */ + fromEntries(entries: any): any; + /** * Creates a new object with the specified prototype object and properties. * properties are currently unsupported. @@ -8709,6 +8718,15 @@ interface ObjectConstructor { */ getOwnPropertyDescriptor(obj: any, name: any): any; + /** + * Get information on all properties in the object (from `Object.getOwnPropertyDescriptor`), or just `{}` if no properties + * + * @param {any} obj - The object + * @returns {any} An object containing all the property descriptors of an object + * @url http://www.espruino.com/Reference#l_Object_getOwnPropertyDescriptors + */ + getOwnPropertyDescriptors(obj: any): any; + /** * Add a new property to the Object. 'Desc' is an object with the following fields: * * `configurable` (bool = false) - can this property be changed/deleted (not From 9f4e4bc98137ca81e3b76ede8a84e555ad6c9db3 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Sat, 25 Feb 2023 23:20:53 +0000 Subject: [PATCH 14/44] Regenerate object.call types --- typescript/types/main.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/typescript/types/main.d.ts b/typescript/types/main.d.ts index 8a9273a76..a48ce7565 100644 --- a/typescript/types/main.d.ts +++ b/typescript/types/main.d.ts @@ -8963,32 +8963,32 @@ interface Function { /** * This executes the function with the supplied 'this' argument and parameters * - * @param {any} this - The value to use as the 'this' argument when executing the function + * @param {any} thisArg - The value to use as the 'this' argument when executing the function * @param {any} params - Optional Parameters * @returns {any} The return value of executing this function * @url http://www.espruino.com/Reference#l_Function_call */ - call(this: any, ...params: any[]): any; + call(thisArg: any, ...params: any[]): any; /** * This executes the function with the supplied 'this' argument and parameters * - * @param {any} this - The value to use as the 'this' argument when executing the function + * @param {any} thisArg - The value to use as the 'this' argument when executing the function * @param {any} args - Optional Array of Arguments * @returns {any} The return value of executing this function * @url http://www.espruino.com/Reference#l_Function_apply */ - apply(this: any, args: any): any; + apply(thisArg: any, args: ArrayLike): any; /** * This executes the function with the supplied 'this' argument and parameters * - * @param {any} this - The value to use as the 'this' argument when executing the function + * @param {any} thisArg - The value to use as the 'this' argument when executing the function * @param {any} params - Optional Default parameters that are prepended to the call * @returns {any} The 'bound' function * @url http://www.espruino.com/Reference#l_Function_bind */ - bind(this: any, ...params: any[]): any; + bind(thisArg: any, ...params: any[]): any; } /** From dd0f88245a2b791c2f5f2af50263a53941ef6803 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Sun, 26 Feb 2023 09:08:28 +0100 Subject: [PATCH 15/44] widalarmeta: use less cpu time each minute Remember next alarm to reduce calculation amount Redraw only every hour when no alarm in next 24h --- apps/widalarmeta/ChangeLog | 2 ++ apps/widalarmeta/metadata.json | 2 +- apps/widalarmeta/widget.js | 43 ++++++++++++++++++++++++---------- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/apps/widalarmeta/ChangeLog b/apps/widalarmeta/ChangeLog index 66b9a4b8e..4bcf6ec69 100644 --- a/apps/widalarmeta/ChangeLog +++ b/apps/widalarmeta/ChangeLog @@ -6,3 +6,5 @@ Update to match the default alarm widget, and not show itself when an alarm is hidden. 0.04: Fix check for active alarm 0.05: Convert Yes/No On/Off in settings to checkboxes +0.06: Remember next alarm to reduce calculation amount + Redraw only every hour when no alarm in next 24h diff --git a/apps/widalarmeta/metadata.json b/apps/widalarmeta/metadata.json index 20b54d7c8..a3d2e8adb 100644 --- a/apps/widalarmeta/metadata.json +++ b/apps/widalarmeta/metadata.json @@ -2,7 +2,7 @@ "id": "widalarmeta", "name": "Alarm & Timer ETA", "shortName": "Alarm ETA", - "version": "0.05", + "version": "0.06", "description": "A widget that displays the time to the next Alarm or Timer in hours and minutes, maximum 24h (configurable).", "icon": "widget.png", "type": "widget", diff --git a/apps/widalarmeta/widget.js b/apps/widalarmeta/widget.js index 3ad2e6ad2..d2e293bc7 100644 --- a/apps/widalarmeta/widget.js +++ b/apps/widalarmeta/widget.js @@ -1,6 +1,5 @@ (() => { require("Font5x9Numeric7Seg").add(Graphics); - const alarms = require("Storage").readJSON("sched.json",1) || []; const config = Object.assign({ maxhours: 24, drawBell: false, @@ -8,17 +7,37 @@ }, require("Storage").readJSON("widalarmeta.json",1) || {}); function draw() { - const times = alarms - .map(alarm => - alarm.hidden !== true - && require("sched").getTimeToAlarm(alarm) - ) - .filter(a => a !== undefined); - const next = times.length > 0 ? Math.min.apply(null, times) : 0; + if (this.nextAlarm === undefined) { + const getNextAlarm = (date) => { + const alarms = (require("Storage").readJSON("sched.json",1) || []).filter(alarm => alarm.on && alarm.hidden !== true); + this.numActiveAlarms = alarms.length; + const times = alarms.map(alarm => require("sched").getTimeToAlarm(alarm, date) || Number.POSITIVE_INFINITY); + const eta = times.length > 0 ? Math.min.apply(null, times) : 0; + if (eta !== Number.POSITIVE_INFINITY) { + const idx = times.indexOf(eta); + const alarm = alarms[idx]; + delete alarm.msg; delete alarm.id; delete alarm.data; // free some memory + return alarm; + } + }; // getNextAlarm + + let alarm = getNextAlarm(); + if (alarm === undefined) { + // try again with next hour + const nextHour = new Date(); + nextHour.setHours(nextHour.getHours()+1); + alarm = getNextAlarm(nextHour); + } + if (alarm !== undefined) { + this.nextAlarm = alarm; + } + } + const next = this.nextAlarm !== undefined ? require("sched").getTimeToAlarm(this.nextAlarm) : 0; + let calcWidth = 0; let drawSeconds = false; - if (next > 0 && next < config.maxhours*60*60*1000) { + if (next > 0 && next <= config.maxhours*60*60*1000) { const hours = Math.floor((next-1) / 3600000).toString(); const minutes = Math.floor(((next-1) % 3600000) / 60000).toString(); const seconds = Math.floor(((next-1) % 60000) / 1000).toString(); @@ -39,7 +58,7 @@ if (drawSeconds) { calcWidth += 3*5; } - } else if (config.drawBell && alarms.some(alarm=>alarm.on&&(alarm.hidden!==true))) { + } else if (config.drawBell && this.numActiveAlarms > 0) { // next alarm too far in future, draw only widalarm bell g.reset().drawImage(atob("GBgBAAAAAAAAABgADhhwDDwwGP8YGf+YMf+MM//MM//MA//AA//AA//AA//AA//AA//AB//gD//wD//wAAAAADwAABgAAAAAAAAA"),this.x,this.y); calcWidth = 24; @@ -51,8 +70,8 @@ Bangle.drawWidgets(); } - // redraw next full minute or second - const period = drawSeconds ? 1000 : 60000; + // redraw next hour when no alarm else full minute or second + const period = next === 0 ? 3600000 : (drawSeconds ? 1000 : 60000); let timeout = next > 0 ? next % period : period - (Date.now() % period); if (timeout === 0) { timeout += period; From 3ca236d83553e66eb09eac9f2262e95e0cc9e114 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Sun, 26 Feb 2023 09:28:45 +0100 Subject: [PATCH 16/44] widalarmeta: Move getNextAlarm --- apps/widalarmeta/widget.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/apps/widalarmeta/widget.js b/apps/widalarmeta/widget.js index d2e293bc7..8fab6fde7 100644 --- a/apps/widalarmeta/widget.js +++ b/apps/widalarmeta/widget.js @@ -6,21 +6,21 @@ showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute }, require("Storage").readJSON("widalarmeta.json",1) || {}); + function getNextAlarm(date) { + const alarms = (require("Storage").readJSON("sched.json",1) || []).filter(alarm => alarm.on && alarm.hidden !== true); + WIDGETS["widalarmeta"].numActiveAlarms = alarms.length; + const times = alarms.map(alarm => require("sched").getTimeToAlarm(alarm, date) || Number.POSITIVE_INFINITY); + const eta = times.length > 0 ? Math.min.apply(null, times) : 0; + if (eta !== Number.POSITIVE_INFINITY) { + const idx = times.indexOf(eta); + const alarm = alarms[idx]; + delete alarm.msg; delete alarm.id; delete alarm.data; // free some memory + return alarm; + } + } // getNextAlarm + function draw() { if (this.nextAlarm === undefined) { - const getNextAlarm = (date) => { - const alarms = (require("Storage").readJSON("sched.json",1) || []).filter(alarm => alarm.on && alarm.hidden !== true); - this.numActiveAlarms = alarms.length; - const times = alarms.map(alarm => require("sched").getTimeToAlarm(alarm, date) || Number.POSITIVE_INFINITY); - const eta = times.length > 0 ? Math.min.apply(null, times) : 0; - if (eta !== Number.POSITIVE_INFINITY) { - const idx = times.indexOf(eta); - const alarm = alarms[idx]; - delete alarm.msg; delete alarm.id; delete alarm.data; // free some memory - return alarm; - } - }; // getNextAlarm - let alarm = getNextAlarm(); if (alarm === undefined) { // try again with next hour From b8e0222315e9ae5d5976d3c17e3ffac3759bd739 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Sun, 26 Feb 2023 10:06:43 +0100 Subject: [PATCH 17/44] widbatpc: Only redraw when values change --- apps/widbatpc/ChangeLog | 1 + apps/widbatpc/metadata.json | 2 +- apps/widbatpc/widget.js | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/widbatpc/ChangeLog b/apps/widbatpc/ChangeLog index 97da2cba6..3592656a9 100644 --- a/apps/widbatpc/ChangeLog +++ b/apps/widbatpc/ChangeLog @@ -15,3 +15,4 @@ 0.16: Increase screen update rate when charging 0.17: Add option 'Remove Jitter'='Drop only' to prevent percentage from getting up again when not charging Add option to disable vibration when charger connects +0.18: Only redraw when values change diff --git a/apps/widbatpc/metadata.json b/apps/widbatpc/metadata.json index cb47475cb..d361da442 100644 --- a/apps/widbatpc/metadata.json +++ b/apps/widbatpc/metadata.json @@ -2,7 +2,7 @@ "id": "widbatpc", "name": "Battery Level Widget (with percentage)", "shortName": "Battery Widget", - "version": "0.17", + "version": "0.18", "description": "Show the current battery level and charging status in the top right of the clock, with charge percentage", "icon": "widget.png", "type": "widget", diff --git a/apps/widbatpc/widget.js b/apps/widbatpc/widget.js index 7f483c960..eff619f0e 100644 --- a/apps/widbatpc/widget.js +++ b/apps/widbatpc/widget.js @@ -86,7 +86,7 @@ return changed; } - function draw() { + function draw(fromIntervall) { // if hidden, don't draw if (!WIDGETS["batpc"].width) return; // else... @@ -103,6 +103,14 @@ l = prevMin; } } + + if (fromIntervall === true && this.prevLevel === l && this.prevCharging === Bangle.isCharging()) { + return; // unchanged, do nothing + } + + this.prevLevel = l; + this.prevCharging = Bangle.isCharging(); + const c = levelColor(l); if (Bangle.isCharging() && setting('charger')) { @@ -149,6 +157,8 @@ // can affect the width and mess with the whole widget layout setWidth(); g.clear(); + WIDGETS["batpc"].prevLevel = undefined; + WIDGETS["batpc"].prevCharging = undefined; Bangle.drawWidgets(); } @@ -173,7 +183,7 @@ if (on) update(); }); - var id = setInterval(()=>WIDGETS["batpc"].draw(), intervalLow); + var id = setInterval(()=>WIDGETS["batpc"].draw(true), intervalLow); WIDGETS["batpc"]={area:"tr",width:40,draw:draw,reload:reload}; setWidth(); From c835650c4422e7fc166e3e1ac0d8aae61bbd100c Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Sun, 26 Feb 2023 10:28:18 +0100 Subject: [PATCH 18/44] widbatpc fixes --- apps/widbatpc/widget.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/widbatpc/widget.js b/apps/widbatpc/widget.js index eff619f0e..b508cce8b 100644 --- a/apps/widbatpc/widget.js +++ b/apps/widbatpc/widget.js @@ -86,7 +86,7 @@ return changed; } - function draw(fromIntervall) { + function draw(fromInterval) { // if hidden, don't draw if (!WIDGETS["batpc"].width) return; // else... @@ -104,7 +104,7 @@ } } - if (fromIntervall === true && this.prevLevel === l && this.prevCharging === Bangle.isCharging()) { + if (fromInterval === true && this.prevLevel === l && this.prevCharging === Bangle.isCharging()) { return; // unchanged, do nothing } @@ -157,8 +157,6 @@ // can affect the width and mess with the whole widget layout setWidth(); g.clear(); - WIDGETS["batpc"].prevLevel = undefined; - WIDGETS["batpc"].prevCharging = undefined; Bangle.drawWidgets(); } From 9e7f22df008cc79587de22ab991473554f2bee7f Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 11:39:07 +0100 Subject: [PATCH 19/44] powermanager - Add powermanager.json to metadata --- apps/powermanager/metadata.json | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/powermanager/metadata.json b/apps/powermanager/metadata.json index 2229629a9..5487c2278 100644 --- a/apps/powermanager/metadata.json +++ b/apps/powermanager/metadata.json @@ -20,6 +20,7 @@ "data": [ {"name":"powermanager.hw.json"}, {"name":"powermanager.def.json"}, + {"name":"powermanager.json"}, {"name":"powermanager.log"} ] } From 11e31f4bbec74111ce5778257490ff86f8477a37 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sat, 25 Feb 2023 15:00:57 +0100 Subject: [PATCH 20/44] messagesoverlay - Initial fork of messages_light with drawing to overlay --- apps/messagesoverlay/ChangeLog | 1 + apps/messagesoverlay/README.md | 11 + apps/messagesoverlay/app-icon.js | 1 + apps/messagesoverlay/app-icon.png | Bin 0 -> 2841 bytes apps/messagesoverlay/app.png | Bin 0 -> 2300 bytes apps/messagesoverlay/boot.js | 7 + apps/messagesoverlay/lib.js | 438 +++++++++++++++++++++++++++++ apps/messagesoverlay/metadata.json | 18 ++ apps/messagesoverlay/settings.js | 1 + 9 files changed, 477 insertions(+) create mode 100644 apps/messagesoverlay/ChangeLog create mode 100644 apps/messagesoverlay/README.md create mode 100644 apps/messagesoverlay/app-icon.js create mode 100644 apps/messagesoverlay/app-icon.png create mode 100644 apps/messagesoverlay/app.png create mode 100644 apps/messagesoverlay/boot.js create mode 100644 apps/messagesoverlay/lib.js create mode 100644 apps/messagesoverlay/metadata.json create mode 100644 apps/messagesoverlay/settings.js diff --git a/apps/messagesoverlay/ChangeLog b/apps/messagesoverlay/ChangeLog new file mode 100644 index 000000000..da98bfbce --- /dev/null +++ b/apps/messagesoverlay/ChangeLog @@ -0,0 +1 @@ +0.01: Initial fork from messages_light \ No newline at end of file diff --git a/apps/messagesoverlay/README.md b/apps/messagesoverlay/README.md new file mode 100644 index 000000000..00fe39bd0 --- /dev/null +++ b/apps/messagesoverlay/README.md @@ -0,0 +1,11 @@ +# Messages app + +This app handles the display of messages and message notifications. + +It is a GUI replacement for the `messages` apps. + + +## Creator + +Rarder44 + diff --git a/apps/messagesoverlay/app-icon.js b/apps/messagesoverlay/app-icon.js new file mode 100644 index 000000000..7d1da35c9 --- /dev/null +++ b/apps/messagesoverlay/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEw4UA/4ACBIMQwhL/ABMBqoAEoALDioLFqgLDBQoABERIkEBZcFBY9QBYVe1QAB1YLGrSlC/YLGrYHCr4Lrr9drpLC1oLEAAN5rxKB/ILHEYV5EY4LIHYoLorRaBqoPCBYlfUoXrBYwGBrdeDIILIvXVBZFa1I+CBY/5BZIHBBwOq1ILGrXVvf//oLGq+trLLFBYVVvQxCBY9XJIQLCgILDHoVVoALHAAQLCgALHBQUAioKFqgLDEgwiDAH4AGA")) \ No newline at end of file diff --git a/apps/messagesoverlay/app-icon.png b/apps/messagesoverlay/app-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..c9b4b62ac2eadee63a98380856f9337d0050578a GIT binary patch literal 2841 zcmbVO2~<;O8VwW_P{0MW6~X6o5Ja<*9YV;4CXfY@e4Qhfi(JV|afbZ2e!VsnszzUX}CO1gXY%Dh4h$iL7 zCnNb9gr|aqQBb6X4-)85lM=G%w0eSX5y1U<`QY02m3=m`@Pj6CM$a-ReBZCwr5F=(VVYnW$WmIP3 zW|II0o!Tkr49>KAVn8M!7}cUQQ0Ww!jgkW>m;W_Xr*onSQzH7h-?t_vlJg8GH4!Cn zvk^f7e1fACVUp#576-__N3bjh)tj8*D#RIUFdMb~GN}+Mszr4GMgUfHXP<^_+=LU^ z_&Y>!zIIAs;7g3C(u5n6aa`+|a)KiZ#9&YuP^bdatMFW6l8w+n04i0QPyq}^4u(x9 z)49oXCO@3Zr*kLM=zJQ@4wd67Or7^OC~yZo{0%7Zn@VX?z7JR~=TFlUCZ!%hr%44c zXo`YiDn1iIkW7TmA}iH24w=hha>-mSM@>c$6`O&mG8sIcvcE47FU1kFO+H7w3dGCU zY;KH`$76t4KxYBnsu*a(2$(}2F zXDrp(Oe{tK$K(yH=_GXFz?BvQy#cTDm56P93SdGBdWHuczOCW+8<{<6ZZ-;1zUjC( zY-EQKxZ0GfG@_y`Fy8;|XnPQnt<-0sV85ioHkwr1&SK|9wd?|pq|Ft7J zg26UxyL9gF;Kun2f$9NGBiR4XM8;txk{eh8qU7wQe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4q`WJrm5PgEb^x|(lr-FAHx0d%)jb*mpX8l%mDc**=qs7T# z@15scZVL$s>73Kj)^FVk&)hv+Ac>7GX{o9xDk}OI0_47!c^8^jYQK7QR5RWBh|%bW jyarTfrTa(x45|?pvWZ*Y_2TYA-Tw%O?a!+8h}ilkNg2g} literal 0 HcmV?d00001 diff --git a/apps/messagesoverlay/boot.js b/apps/messagesoverlay/boot.js new file mode 100644 index 000000000..7731d608a --- /dev/null +++ b/apps/messagesoverlay/boot.js @@ -0,0 +1,7 @@ +//override require to filter require("message") +global.require_real=global.require; +global.require = (_require => file => { + if (file==="messages") file = "messagesoverlay"; + return _require(file); +})(require); + diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js new file mode 100644 index 000000000..167d68134 --- /dev/null +++ b/apps/messagesoverlay/lib.js @@ -0,0 +1,438 @@ +/* MESSAGES is a list of: + {id:int, + src, + title, + subject, + body, + sender, + tel:string, + new:true // not read yet + } +*/ + + +let lockListener; + +let LOG = function() { + print.apply(null, arguments); +}; + +let settings = (() => { + let tmp = {}; + tmp.NewEventFileName = "messagesoverlay.NewEvent.json"; + + tmp.fontSmall = "6x8"; + tmp.fontMedium = g.getFonts().includes("Vector") ? "Vector:16" : "6x8:2"; + tmp.fontBig = g.getFonts().includes("12x20") ? "12x20" : "6x8:2"; + tmp.fontLarge = g.getFonts().includes("6x15") ? "6x15:2" : "6x8:4"; + + tmp.colLock = g.theme.dark ? "#ff0000" : "#ff0000"; + + tmp.quiet = ((require('Storage').readJSON('settings.json', 1) || {}).quiet); + + return tmp; +})(); +let EventQueue = []; +let callInProgress = false; + + +let manageEvent = function(ovr, event) { + event.new = true; + + LOG("manageEvent"); + if (event.id == "call") { + showCall(ovr, event); + return; + } + switch (event.t) { + case "add": + EventQueue.unshift(event); + + if (!callInProgress) + showMessage(ovr, event); + break; + + case "modify": + let find = false; + EventQueue.forEach(element => { + if (element.id == event.id) { + find = true; + Object.assign(element, event); + } + }); + if (!find) + EventQueue.unshift(event); + + if (!callInProgress) + showMessage(ovr, event); + break; + + case "remove": + if (EventQueue.length == 0 && !callInProgress) + next(ovr); + + if (!callInProgress && EventQueue[0] !== undefined && EventQueue[0].id == event.id) + next(ovr); + + else { + let newEventQueue = []; + EventQueue.forEach(element => { + if (element.id != event.id) + newEventQueue.push(element); + }); + EventQueue = newEventQueue; + } + + break; + case "musicstate": + case "musicinfo": + + break; + } +}; + +let drawScreen = function(ovr, title, titleFont, src, iconcolor, icon){ + ovr.setBgColor(ovr.theme.bg2); + ovr.clearRect(0,0,ovr.getWidth(),40); + + ovr.setColor(ovr.theme.fg2); + ovr.setFont(settings.fontSmall); + ovr.setFontAlign(0,-1); + ovr.drawString(src, ovr.getWidth()/2, 2); + + ovr.setFont(titleFont); + ovr.drawString(title, ovr.getWidth()/2, 12); + + let x = 150; + let y = 5; + let w = 22; + let h = 30; + var poly = [ + x,y+4, + x+4,y, + x+w-5,y, + x+w-1,y+4, + x+w-1,y+h-5, + x+w-5,y+h-1, + x+4,y+h-1, + x,y+h-5, + x,y+4 + ]; + ovr.setColor(ovr.theme.fg2); + ovr.drawPoly(poly,true); + ovr.drawString("X",160,10); + + ovr.setColor(iconcolor); + ovr.setBgColor("#fff"); + ovr.drawImage(icon,10,10); +}; + +let showMessage = function(ovr, msg) { + LOG("showMessage"); + LOG(msg); + ovr.setBgColor(settings.colBg); + + + if (typeof msg.CanScrollDown === "undefined") + msg.CanScrollDown = false; + if (typeof msg.CanScrollUp === "undefined") + msg.CanScrollUp = false; + + // Normal text message display + let title = msg.title, + titleFont = settings.fontLarge, + lines; + if (title) { + let w = ovr.getWidth() - 48; + if (ovr.setFont(titleFont).stringWidth(title) > w) + titleFont = settings.fontMedium; + if (ovr.setFont(titleFont).stringWidth(title) > w) { + lines = ovr.wrapString(title, w); + title = (lines.length > 2) ? lines.slice(0, 2).join("\n") + "..." : lines.join("\n"); + } + } + + drawScreen(ovr, title, titleFont, msg.src || /*LANG*/ "Message", require("messageicons").getColor(msg), require("messageicons").getImage(msg)); + + if (!settings.quiet && msg.new) { + msg.new = false; + Bangle.buzz(); + } + + PrintMessageStrings(ovr, msg); +}; + +let DrawLock = function(ovr) { + if (Bangle.isLocked()) + ovr.setColor(settings.colLock); + else + ovr.setColor(ovr.theme.bg2); + ovr.drawRect(0,0,ovr.getWidth()-1,ovr.getHeight()-1); + ovr.drawRect(1,1,ovr.getWidth()-2,ovr.getHeight()-2); + Bangle.setLCDOverlay(ovr,0,0); +}; + +let showCall = function(ovr, msg) { + LOG("showCall"); + LOG(msg); + + if (msg.t == "remove") { + LOG("hide call screen"); + next(ovr); //dont shift + return; + } + + callInProgress = true; + + let title = msg.title, + titleFont = settings.fontLarge, + lines; + if (title) { + let w = ovr.getWidth() - 48; + if (ovr.setFont(titleFont).stringWidth(title) > w) + titleFont = settings.fontMedium; + if (ovr.setFont(titleFont).stringWidth(title) > w) { + lines = ovr.wrapString(title, w); + title = (lines.length > 2) ? lines.slice(0, 2).join("\n") + "..." : lines.join("\n"); + } + } + + drawScreen(ovr, title, titleFont, msg.src || /*LANG*/ "Message", require("messageicons").getColor(msg), require("messageicons").getImage(msg)); + + StopBuzzCall(); + if (!settings.quiet) { + if (msg.new) { + msg.new = false; + CallBuzzTimer = setInterval(function() { + Bangle.buzz(500); + }, 1000); + + Bangle.buzz(500); + } + } + PrintMessageStrings(ovr, msg); +}; + +let next = function(ovr) { + LOG("next"); + StopBuzzCall(); + + if (!callInProgress) + EventQueue.shift(); + + callInProgress = false; + if (EventQueue.length == 0) { + LOG("no element in queue - closing"); + cleanup(); + return; + } + + showMessage(ovr, EventQueue[0]); +}; + +let showMapMessage = function(ovr, msg) { + ovr.clearRect(Bangle.appRect); + PrintMessageStrings(ovr, { + body: "Not implemented!" + }); +}; + +let CallBuzzTimer = null; +let StopBuzzCall = function() { + if (CallBuzzTimer) { + clearInterval(CallBuzzTimer); + CallBuzzTimer = null; + } +}; + +let DrawTriangleUp = function(ovr) { + ovr.reset(); + ovr.fillPoly([169, 46, 164, 56, 174, 56]); +}; + +let DrawTriangleDown = function(ovr) { + ovr.reset(); + ovr.fillPoly([169, 170, 164, 160, 174, 160]); +}; + +let ScrollUp = function(ovr, msg) { + msg = EventQueue[0]; + + if (typeof msg.FirstLine === "undefined") + msg.FirstLine = 0; + if (typeof msg.CanScrollUp === "undefined") + msg.CanScrollUp = false; + + if (!msg.CanScrollUp) return; + + msg.FirstLine = msg.FirstLine > 0 ? msg.FirstLine - 1 : 0; + + PrintMessageStrings(ovr, msg); +}; + +let ScrollDown = function(ovr, msg) { + msg = EventQueue[0]; + if (typeof msg.FirstLine === "undefined") + msg.FirstLine = 0; + if (typeof msg.CanScrollDown === "undefined") + msg.CanScrollDown = false; + + if (!msg.CanScrollDown) return; + + msg.FirstLine = msg.FirstLine + 1; + PrintMessageStrings(ovr, msg); +}; + +let PrintMessageStrings = function(ovr, msg) { + let MyWrapString = function(str, maxWidth) { + str = str.replace("\r\n", "\n").replace("\r", "\n"); + return ovr.wrapString(str, maxWidth); + }; + + if (typeof msg.FirstLine === "undefined") msg.FirstLine = 0; + + let bodyFont = typeof msg.bodyFont === "undefined" ? settings.fontMedium : msg.bodyFont; + let Padding = 2; + if (typeof msg.lines === "undefined") { + ovr.setFont(bodyFont); + msg.lines = MyWrapString(msg.body, ovr.getWidth() - (Padding * 2)); + if (msg.lines.length <= 2) { + bodyFont = ovr.getFonts().includes("Vector") ? "Vector:20" : "6x8:3"; + ovr.setFont(bodyFont); + msg.lines = MyWrapString(msg.body, ovr.getWidth() - (Padding * 2)); + msg.bodyFont = bodyFont; + } + } + + let NumLines = 9; + let linesToPrint = (msg.lines.length > NumLines) ? msg.lines.slice(msg.FirstLine, msg.FirstLine + NumLines) : msg.lines; + + + let yText = 40; + + ovr.setBgColor(ovr.theme.bg); + ovr.clearRect(0, yText, 176, 176); + let xText = Padding; + yText += Padding; + ovr.setFont(bodyFont); + let HText = ovr.getFontHeight(); + + yText = ((176 - yText) / 2) - (linesToPrint.length * HText / 2) + yText; + + if (linesToPrint.length <= 2) { + ovr.setFontAlign(0, -1); + xText = ovr.getWidth() / 2; + } else + ovr.setFontAlign(-1, -1); + + + linesToPrint.forEach((line, i) => { + ovr.drawString(line, xText, yText + HText * i); + }); + + if (msg.FirstLine != 0) { + msg.CanScrollUp = true; + DrawTriangleUp(ovr); + } else + msg.CanScrollUp = false; + + if (msg.FirstLine + linesToPrint.length < msg.lines.length) { + msg.CanScrollDown = true; + DrawTriangleDown(ovr); + } else + msg.CanScrollDown = false; +}; + +let doubleTapUnlock = function(data) { + if (data.double) + { + Bangle.setLocked(false); + Bangle.setLCDPower(1); + } +}; + +let getTouchHandler = function(ovr){ + return (button, xy) => { + if (xy.y < 40){ + next(ovr); + } else if (xy.y < (ovr.getHeight() - 40)/2) { + ScrollUp(ovr); + } else { + ScrollDown(ovr); + } + }; +}; + +let touchHandler; + +let cleanup = function(){ + if (lockListener) { + Bangle.removeListener("lock", lockListener); + lockListener = undefined; + } + if (touchBack){ + Bangle["#ontouch"]=touchBack; + LOG("Restored touch handlers:", touchBack); + touchBack = undefined; + } + + Bangle.removeListener("tap", doubleTapUnlock); + if (touchHandler) Bangle.removeListener("touch", touchHandler); + Bangle.setLCDOverlay(); +}; + +let touchBack; + +let main = function(ovr, event) { + LOG("Main", event, settings); + if (!lockListener) { + lockListener = function (){ + DrawLock(ovr); + }; + Bangle.on('lock', lockListener); + } + + touchBack = Bangle["#ontouch"]; + Bangle.removeAllListeners("touch"); + + Bangle.on('tap', doubleTapUnlock); + if (touchHandler) Bangle.removeListener("touch",touchHandler); + touchHandler = getTouchHandler(ovr); + Bangle.on('touch', touchHandler); + + if (event !== undefined){ + manageEvent(ovr, event); + Bangle.setLCDPower(1); + DrawLock(ovr); + Bangle.setLCDOverlay(ovr,0,0); + } else { + LOG("No event given"); + cleanup(); + } +}; + +exports.pushMessage = function(event) { + if( event.id=="music") return require_real("messages").pushMessage(event); + + let ovr = Graphics.createArrayBuffer(g.getWidth(), g.getHeight(), 4, { + msb: true + }); + + let _g = g; + g = ovr; + + ovr.theme = g.theme; + if(event.t=="remove") return; + main(ovr, event); + Bangle.setLCDOverlay(ovr, 0, 0); + + g = _g; +}; + + +//Call original message library +exports.clearAll = function() { return require_real("messages").clearAll();}; +exports.getMessages = function() { return require_real("messages").getMessages();}; +exports.status = function() { return require_real("messages").status();}; +exports.buzz = function() { return require_real("messages").buzz(msgSrc);}; +exports.stopBuzz = function() { return require_real("messages").stopBuzz();}; \ No newline at end of file diff --git a/apps/messagesoverlay/metadata.json b/apps/messagesoverlay/metadata.json new file mode 100644 index 000000000..c1dc97bd9 --- /dev/null +++ b/apps/messagesoverlay/metadata.json @@ -0,0 +1,18 @@ +{ + "id": "messagesoverlay", + "name": "Messages Overlay", + "version": "0.01", + "description": "An overlay based implementation of a messages UI (display notifications from iOS and Gadgetbridge/Android)", + "icon": "app.png", + "type": "app", + "tags": "tool,system", + "supports": ["BANGLEJS2"], + "dependencies" : { "messageicons":"module","messages":"app" }, + "readme": "README.md", + "storage": [ + {"name":"messagesoverlay.settings.js","url":"settings.js"}, + {"name":"messagesoverlay.img","url":"app-icon.js","evaluate":true}, + {"name":"messagesoverlay","url":"lib.js"}, + {"name":"messagesoverlay.boot.js","url":"boot.js"} + ] +} diff --git a/apps/messagesoverlay/settings.js b/apps/messagesoverlay/settings.js new file mode 100644 index 000000000..b7197c70a --- /dev/null +++ b/apps/messagesoverlay/settings.js @@ -0,0 +1 @@ +eval(require("Storage").read("messages.settings.js")); From 730da3f52dd8f9d11880fced58e35607a1f820c0 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 09:51:45 +0100 Subject: [PATCH 21/44] messagesoverlay - Show popup a litte smaller than full screen --- apps/messagesoverlay/lib.js | 63 ++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index 167d68134..e79ab6264 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -10,6 +10,10 @@ } */ +const ovrx = 10; +const ovry = 10; +const ovrw = g.getWidth()-2*ovrx; +const ovrh = g.getHeight()-2*ovry; let lockListener; @@ -91,22 +95,7 @@ let manageEvent = function(ovr, event) { } }; -let drawScreen = function(ovr, title, titleFont, src, iconcolor, icon){ - ovr.setBgColor(ovr.theme.bg2); - ovr.clearRect(0,0,ovr.getWidth(),40); - - ovr.setColor(ovr.theme.fg2); - ovr.setFont(settings.fontSmall); - ovr.setFontAlign(0,-1); - ovr.drawString(src, ovr.getWidth()/2, 2); - - ovr.setFont(titleFont); - ovr.drawString(title, ovr.getWidth()/2, 12); - - let x = 150; - let y = 5; - let w = 22; - let h = 30; +let roundedRect = function(ovr, x,y,w,h,filled){ var poly = [ x,y+4, x+4,y, @@ -118,13 +107,29 @@ let drawScreen = function(ovr, title, titleFont, src, iconcolor, icon){ x,y+h-5, x,y+4 ]; - ovr.setColor(ovr.theme.fg2); ovr.drawPoly(poly,true); - ovr.drawString("X",160,10); + if (filled) ovr.fillPoly(poly,true); +}; + +let drawScreen = function(ovr, title, titleFont, src, iconcolor, icon){ + ovr.setBgColor(ovr.theme.bg2); + ovr.clearRect(0,0,ovr.getWidth(),40); + + ovr.setColor(ovr.theme.fg2); + ovr.setFont(settings.fontSmall); + ovr.setFontAlign(0,-1); + ovr.drawString(src, (ovr.getWidth()-ovrx)/2, 2); + + ovr.setFont(titleFont); + ovr.drawString(title, (ovr.getWidth()-ovrx)/2, 12); + + ovr.setColor(ovr.theme.fg2); + roundedRect(ovr, ovr.getWidth()-26,5,22,30,false); + ovr.drawString("X",ovr.getWidth()-16,10); ovr.setColor(iconcolor); ovr.setBgColor("#fff"); - ovr.drawImage(icon,10,10); + ovr.drawImage(icon,8,8); }; let showMessage = function(ovr, msg) { @@ -169,7 +174,7 @@ let DrawLock = function(ovr) { ovr.setColor(ovr.theme.bg2); ovr.drawRect(0,0,ovr.getWidth()-1,ovr.getHeight()-1); ovr.drawRect(1,1,ovr.getWidth()-2,ovr.getHeight()-2); - Bangle.setLCDOverlay(ovr,0,0); + Bangle.setLCDOverlay(ovr,10,10); }; let showCall = function(ovr, msg) { @@ -188,7 +193,7 @@ let showCall = function(ovr, msg) { titleFont = settings.fontLarge, lines; if (title) { - let w = ovr.getWidth() - 48; + let w = ovr.getWidth() - 40; if (ovr.setFont(titleFont).stringWidth(title) > w) titleFont = settings.fontMedium; if (ovr.setFont(titleFont).stringWidth(title) > w) { @@ -304,20 +309,20 @@ let PrintMessageStrings = function(ovr, msg) { } } - let NumLines = 9; + let NumLines = 7; let linesToPrint = (msg.lines.length > NumLines) ? msg.lines.slice(msg.FirstLine, msg.FirstLine + NumLines) : msg.lines; let yText = 40; ovr.setBgColor(ovr.theme.bg); - ovr.clearRect(0, yText, 176, 176); + ovr.clearRect(0, yText, ovrw, ovrh); let xText = Padding; yText += Padding; ovr.setFont(bodyFont); let HText = ovr.getFontHeight(); - yText = ((176 - yText) / 2) - (linesToPrint.length * HText / 2) + yText; + yText = ((ovrh - yText) / 2) - (linesToPrint.length * HText / 2) + yText; if (linesToPrint.length <= 2) { ovr.setFontAlign(0, -1); @@ -353,9 +358,9 @@ let doubleTapUnlock = function(data) { let getTouchHandler = function(ovr){ return (button, xy) => { - if (xy.y < 40){ + if (xy.y < ovry + 40){ next(ovr); - } else if (xy.y < (ovr.getHeight() - 40)/2) { + } else if (xy.y < (ovry + ovr.getHeight() - 40)/2) { ScrollUp(ovr); } else { ScrollDown(ovr); @@ -404,7 +409,7 @@ let main = function(ovr, event) { manageEvent(ovr, event); Bangle.setLCDPower(1); DrawLock(ovr); - Bangle.setLCDOverlay(ovr,0,0); + Bangle.setLCDOverlay(ovr,10,10); } else { LOG("No event given"); cleanup(); @@ -414,7 +419,7 @@ let main = function(ovr, event) { exports.pushMessage = function(event) { if( event.id=="music") return require_real("messages").pushMessage(event); - let ovr = Graphics.createArrayBuffer(g.getWidth(), g.getHeight(), 4, { + let ovr = Graphics.createArrayBuffer(ovrw, ovrh, 4, { msb: true }); @@ -424,7 +429,7 @@ exports.pushMessage = function(event) { ovr.theme = g.theme; if(event.t=="remove") return; main(ovr, event); - Bangle.setLCDOverlay(ovr, 0, 0); + Bangle.setLCDOverlay(ovr, 10, 10); g = _g; }; From a9fd2420e29dd12a37f06e1e2d52bfd2670ce6b8 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 10:19:31 +0100 Subject: [PATCH 22/44] messagesoverlay - Stop swipes and drags interacting with the running app --- apps/messagesoverlay/lib.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index e79ab6264..c64a23327 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -377,9 +377,16 @@ let cleanup = function(){ } if (touchBack){ Bangle["#ontouch"]=touchBack; - LOG("Restored touch handlers:", touchBack); touchBack = undefined; } + if (swipeBack){ + Bangle["#onswipe"]=swipeBack; + swipeBack = undefined; + } + if (dragBack){ + Bangle["#ondrag"]=dragBack; + dragBack = undefined; + } Bangle.removeListener("tap", doubleTapUnlock); if (touchHandler) Bangle.removeListener("touch", touchHandler); @@ -387,6 +394,8 @@ let cleanup = function(){ }; let touchBack; +let swipeBack; +let dragBack; let main = function(ovr, event) { LOG("Main", event, settings); @@ -399,6 +408,10 @@ let main = function(ovr, event) { touchBack = Bangle["#ontouch"]; Bangle.removeAllListeners("touch"); + swipeBack = Bangle["#onswipe"]; + Bangle.removeAllListeners("swipe"); + dragBack = Bangle["#ondrag"]; + Bangle.removeAllListeners("drag"); Bangle.on('tap', doubleTapUnlock); if (touchHandler) Bangle.removeListener("touch",touchHandler); From 8a3ab237fc85fb4681771c647b1c00b37e880993 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 10:25:29 +0100 Subject: [PATCH 23/44] messagesoverlay - Refactor backing up and restoring handlers --- apps/messagesoverlay/lib.js | 40 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index c64a23327..c36bfff51 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -370,32 +370,33 @@ let getTouchHandler = function(ovr){ let touchHandler; +let restoreHandler = function(event){ + if (backup[event]){ + Bangle["#on" + event]=backup[event]; + backup[event] = undefined; + } +}; + +let backupHandler = function(event){ + backup[event] = Bangle["#on" + event]; + Bangle.removeAllListeners(event); +}; + let cleanup = function(){ if (lockListener) { Bangle.removeListener("lock", lockListener); lockListener = undefined; } - if (touchBack){ - Bangle["#ontouch"]=touchBack; - touchBack = undefined; - } - if (swipeBack){ - Bangle["#onswipe"]=swipeBack; - swipeBack = undefined; - } - if (dragBack){ - Bangle["#ondrag"]=dragBack; - dragBack = undefined; - } + restoreHandler("touch"); + restoreHandler("swipe"); + restoreHandler("drag"); Bangle.removeListener("tap", doubleTapUnlock); if (touchHandler) Bangle.removeListener("touch", touchHandler); Bangle.setLCDOverlay(); }; -let touchBack; -let swipeBack; -let dragBack; +let backup = {}; let main = function(ovr, event) { LOG("Main", event, settings); @@ -406,12 +407,9 @@ let main = function(ovr, event) { Bangle.on('lock', lockListener); } - touchBack = Bangle["#ontouch"]; - Bangle.removeAllListeners("touch"); - swipeBack = Bangle["#onswipe"]; - Bangle.removeAllListeners("swipe"); - dragBack = Bangle["#ondrag"]; - Bangle.removeAllListeners("drag"); + backupHandler("touch"); + backupHandler("swipe"); + backupHandler("drag"); Bangle.on('tap', doubleTapUnlock); if (touchHandler) Bangle.removeListener("touch",touchHandler); From e5352839c0550887ac44d63d946f3cdcbd340b94 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 10:43:46 +0100 Subject: [PATCH 24/44] messagesoverlay - Use only theme colors --- apps/messagesoverlay/lib.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index c36bfff51..7b207785b 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -30,8 +30,6 @@ let settings = (() => { tmp.fontBig = g.getFonts().includes("12x20") ? "12x20" : "6x8:2"; tmp.fontLarge = g.getFonts().includes("6x15") ? "6x15:2" : "6x8:4"; - tmp.colLock = g.theme.dark ? "#ff0000" : "#ff0000"; - tmp.quiet = ((require('Storage').readJSON('settings.json', 1) || {}).quiet); return tmp; @@ -169,9 +167,9 @@ let showMessage = function(ovr, msg) { let DrawLock = function(ovr) { if (Bangle.isLocked()) - ovr.setColor(settings.colLock); + ovr.setColor(ovr.theme.fgH); else - ovr.setColor(ovr.theme.bg2); + ovr.setColor(ovr.theme.fg); ovr.drawRect(0,0,ovr.getWidth()-1,ovr.getHeight()-1); ovr.drawRect(1,1,ovr.getWidth()-2,ovr.getHeight()-2); Bangle.setLCDOverlay(ovr,10,10); From f055b642a93cd064b6c30e0315c8f5ea551a148b Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 11:03:25 +0100 Subject: [PATCH 25/44] messagesoverlay - Fix scrolling --- apps/messagesoverlay/lib.js | 145 +++++++++++++++++++----------------- 1 file changed, 78 insertions(+), 67 deletions(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index 7b207785b..fab4709d4 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -18,12 +18,11 @@ const ovrh = g.getHeight()-2*ovry; let lockListener; let LOG = function() { - print.apply(null, arguments); + //print.apply(null, arguments); }; let settings = (() => { let tmp = {}; - tmp.NewEventFileName = "messagesoverlay.NewEvent.json"; tmp.fontSmall = "6x8"; tmp.fontMedium = g.getFonts().includes("Vector") ? "Vector:16" : "6x8:2"; @@ -34,9 +33,9 @@ let settings = (() => { return tmp; })(); -let EventQueue = []; -let callInProgress = false; +let eventQueue = []; +let callInProgress = false; let manageEvent = function(ovr, event) { event.new = true; @@ -48,7 +47,7 @@ let manageEvent = function(ovr, event) { } switch (event.t) { case "add": - EventQueue.unshift(event); + eventQueue.unshift(event); if (!callInProgress) showMessage(ovr, event); @@ -56,33 +55,33 @@ let manageEvent = function(ovr, event) { case "modify": let find = false; - EventQueue.forEach(element => { + eventQueue.forEach(element => { if (element.id == event.id) { find = true; Object.assign(element, event); } }); if (!find) - EventQueue.unshift(event); + eventQueue.unshift(event); if (!callInProgress) showMessage(ovr, event); break; case "remove": - if (EventQueue.length == 0 && !callInProgress) + if (eventQueue.length == 0 && !callInProgress) next(ovr); - if (!callInProgress && EventQueue[0] !== undefined && EventQueue[0].id == event.id) + if (!callInProgress && eventQueue[0] !== undefined && eventQueue[0].id == event.id) next(ovr); else { - let newEventQueue = []; - EventQueue.forEach(element => { + let neweventQueue = []; + eventQueue.forEach(element => { if (element.id != event.id) - newEventQueue.push(element); + neweventQueue.push(element); }); - EventQueue = newEventQueue; + eventQueue = neweventQueue; } break; @@ -132,14 +131,13 @@ let drawScreen = function(ovr, title, titleFont, src, iconcolor, icon){ let showMessage = function(ovr, msg) { LOG("showMessage"); - LOG(msg); ovr.setBgColor(settings.colBg); - if (typeof msg.CanScrollDown === "undefined") - msg.CanScrollDown = false; - if (typeof msg.CanScrollUp === "undefined") - msg.CanScrollUp = false; + if (typeof msg.CanscrollDown === "undefined") + msg.CanscrollDown = false; + if (typeof msg.CanscrollUp === "undefined") + msg.CanscrollUp = false; // Normal text message display let title = msg.title, @@ -162,10 +160,10 @@ let showMessage = function(ovr, msg) { Bangle.buzz(); } - PrintMessageStrings(ovr, msg); + drawMessage(ovr, msg); }; -let DrawLock = function(ovr) { +let drawBorder = function(ovr) { if (Bangle.isLocked()) ovr.setColor(ovr.theme.fgH); else @@ -202,91 +200,92 @@ let showCall = function(ovr, msg) { drawScreen(ovr, title, titleFont, msg.src || /*LANG*/ "Message", require("messageicons").getColor(msg), require("messageicons").getImage(msg)); - StopBuzzCall(); + stopCallBuzz(); if (!settings.quiet) { if (msg.new) { msg.new = false; - CallBuzzTimer = setInterval(function() { + callBuzzTimer = setInterval(function() { Bangle.buzz(500); }, 1000); Bangle.buzz(500); } } - PrintMessageStrings(ovr, msg); + drawMessage(ovr, msg); }; let next = function(ovr) { LOG("next"); - StopBuzzCall(); + stopCallBuzz(); if (!callInProgress) - EventQueue.shift(); + eventQueue.shift(); callInProgress = false; - if (EventQueue.length == 0) { + if (eventQueue.length == 0) { LOG("no element in queue - closing"); cleanup(); return; } - showMessage(ovr, EventQueue[0]); + showMessage(ovr, eventQueue[0]); }; let showMapMessage = function(ovr, msg) { ovr.clearRect(Bangle.appRect); - PrintMessageStrings(ovr, { + drawMessage(ovr, { body: "Not implemented!" }); }; -let CallBuzzTimer = null; -let StopBuzzCall = function() { - if (CallBuzzTimer) { - clearInterval(CallBuzzTimer); - CallBuzzTimer = null; +let callBuzzTimer = null; +let stopCallBuzz = function() { + if (callBuzzTimer) { + clearInterval(callBuzzTimer); + callBuzzTimer = null; } }; -let DrawTriangleUp = function(ovr) { +let drawTriangleUp = function(ovr) { ovr.reset(); - ovr.fillPoly([169, 46, 164, 56, 174, 56]); + ovr.fillPoly([ovr.getWidth()-9, 46,ovr.getWidth()-14, 56,ovr.getWidth()-4, 56]); }; -let DrawTriangleDown = function(ovr) { +let drawTriangleDown = function(ovr) { ovr.reset(); - ovr.fillPoly([169, 170, 164, 160, 174, 160]); + ovr.fillPoly([ovr.getWidth()-9, ovr.getHeight()-6, ovr.getWidth()-14, ovr.getHeight()-16, ovr.getWidth()-4, ovr.getHeight()-16]); }; -let ScrollUp = function(ovr, msg) { - msg = EventQueue[0]; - +let scrollUp = function(ovr) { + msg = eventQueue[0]; + LOG("up", msg); if (typeof msg.FirstLine === "undefined") msg.FirstLine = 0; - if (typeof msg.CanScrollUp === "undefined") - msg.CanScrollUp = false; + if (typeof msg.CanscrollUp === "undefined") + msg.CanscrollUp = false; - if (!msg.CanScrollUp) return; + if (!msg.CanscrollUp) return; msg.FirstLine = msg.FirstLine > 0 ? msg.FirstLine - 1 : 0; - PrintMessageStrings(ovr, msg); + drawMessage(ovr, msg); }; -let ScrollDown = function(ovr, msg) { - msg = EventQueue[0]; +let scrollDown = function(ovr) { + msg = eventQueue[0]; + LOG("down", msg); if (typeof msg.FirstLine === "undefined") msg.FirstLine = 0; - if (typeof msg.CanScrollDown === "undefined") - msg.CanScrollDown = false; + if (typeof msg.CanscrollDown === "undefined") + msg.CanscrollDown = false; - if (!msg.CanScrollDown) return; + if (!msg.CanscrollDown) return; msg.FirstLine = msg.FirstLine + 1; - PrintMessageStrings(ovr, msg); + drawMessage(ovr, msg); }; -let PrintMessageStrings = function(ovr, msg) { +let drawMessage = function(ovr, msg) { let MyWrapString = function(str, maxWidth) { str = str.replace("\r\n", "\n").replace("\r", "\n"); return ovr.wrapString(str, maxWidth); @@ -295,7 +294,7 @@ let PrintMessageStrings = function(ovr, msg) { if (typeof msg.FirstLine === "undefined") msg.FirstLine = 0; let bodyFont = typeof msg.bodyFont === "undefined" ? settings.fontMedium : msg.bodyFont; - let Padding = 2; + let Padding = 3; if (typeof msg.lines === "undefined") { ovr.setFont(bodyFont); msg.lines = MyWrapString(msg.body, ovr.getWidth() - (Padding * 2)); @@ -308,13 +307,13 @@ let PrintMessageStrings = function(ovr, msg) { } let NumLines = 7; - let linesToPrint = (msg.lines.length > NumLines) ? msg.lines.slice(msg.FirstLine, msg.FirstLine + NumLines) : msg.lines; + let linesToPrint = (msg.lines.length > NumLines) ? msg.lines.slice(msg.FirstLine, msg.FirstLine + NumLines) : msg.lines; let yText = 40; ovr.setBgColor(ovr.theme.bg); - ovr.clearRect(0, yText, ovrw, ovrh); + ovr.clearRect(2, yText, ovrw-2, ovrh-2); let xText = Padding; yText += Padding; ovr.setFont(bodyFont); @@ -334,16 +333,17 @@ let PrintMessageStrings = function(ovr, msg) { }); if (msg.FirstLine != 0) { - msg.CanScrollUp = true; - DrawTriangleUp(ovr); + msg.CanscrollUp = true; + drawTriangleUp(ovr); } else - msg.CanScrollUp = false; + msg.CanscrollUp = false; if (msg.FirstLine + linesToPrint.length < msg.lines.length) { - msg.CanScrollDown = true; - DrawTriangleDown(ovr); + msg.CanscrollDown = true; + drawTriangleDown(ovr); } else - msg.CanScrollDown = false; + msg.CanscrollDown = false; + Bangle.setLCDOverlay(ovr,ovrx,ovry); }; let doubleTapUnlock = function(data) { @@ -354,19 +354,26 @@ let doubleTapUnlock = function(data) { } }; +let getSwipeHandler = function(ovr){ + return (lr, ud) => { + if (ud == 1) { + scrollUp(ovr); + } else if (ud == -1){ + scrollDown(ovr); + } + }; +}; + let getTouchHandler = function(ovr){ - return (button, xy) => { + return (_, xy) => { if (xy.y < ovry + 40){ next(ovr); - } else if (xy.y < (ovry + ovr.getHeight() - 40)/2) { - ScrollUp(ovr); - } else { - ScrollDown(ovr); } }; }; let touchHandler; +let swipeHandler; let restoreHandler = function(event){ if (backup[event]){ @@ -391,6 +398,7 @@ let cleanup = function(){ Bangle.removeListener("tap", doubleTapUnlock); if (touchHandler) Bangle.removeListener("touch", touchHandler); + if (swipeHandler) Bangle.removeListener("swipe", swipeHandler); Bangle.setLCDOverlay(); }; @@ -400,7 +408,7 @@ let main = function(ovr, event) { LOG("Main", event, settings); if (!lockListener) { lockListener = function (){ - DrawLock(ovr); + drawBorder(ovr); }; Bangle.on('lock', lockListener); } @@ -411,13 +419,16 @@ let main = function(ovr, event) { Bangle.on('tap', doubleTapUnlock); if (touchHandler) Bangle.removeListener("touch",touchHandler); + if (swipeHandler) Bangle.removeListener("swipe",swipeHandler); touchHandler = getTouchHandler(ovr); + swipeHandler = getSwipeHandler(ovr); Bangle.on('touch', touchHandler); + Bangle.on('swipe', swipeHandler); if (event !== undefined){ manageEvent(ovr, event); Bangle.setLCDPower(1); - DrawLock(ovr); + drawBorder(ovr); Bangle.setLCDOverlay(ovr,10,10); } else { LOG("No event given"); From 6944fcece4ff1213bdfb7758a7ddb44581f17adf Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 11:51:16 +0100 Subject: [PATCH 26/44] messagesoverlay - Remove unused icon --- apps/messagesoverlay/app-icon.js | 1 - apps/messagesoverlay/metadata.json | 1 - 2 files changed, 2 deletions(-) delete mode 100644 apps/messagesoverlay/app-icon.js diff --git a/apps/messagesoverlay/app-icon.js b/apps/messagesoverlay/app-icon.js deleted file mode 100644 index 7d1da35c9..000000000 --- a/apps/messagesoverlay/app-icon.js +++ /dev/null @@ -1 +0,0 @@ -require("heatshrink").decompress(atob("mEw4UA/4ACBIMQwhL/ABMBqoAEoALDioLFqgLDBQoABERIkEBZcFBY9QBYVe1QAB1YLGrSlC/YLGrYHCr4Lrr9drpLC1oLEAAN5rxKB/ILHEYV5EY4LIHYoLorRaBqoPCBYlfUoXrBYwGBrdeDIILIvXVBZFa1I+CBY/5BZIHBBwOq1ILGrXVvf//oLGq+trLLFBYVVvQxCBY9XJIQLCgILDHoVVoALHAAQLCgALHBQUAioKFqgLDEgwiDAH4AGA")) \ No newline at end of file diff --git a/apps/messagesoverlay/metadata.json b/apps/messagesoverlay/metadata.json index c1dc97bd9..4b9966adb 100644 --- a/apps/messagesoverlay/metadata.json +++ b/apps/messagesoverlay/metadata.json @@ -11,7 +11,6 @@ "readme": "README.md", "storage": [ {"name":"messagesoverlay.settings.js","url":"settings.js"}, - {"name":"messagesoverlay.img","url":"app-icon.js","evaluate":true}, {"name":"messagesoverlay","url":"lib.js"}, {"name":"messagesoverlay.boot.js","url":"boot.js"} ] From 86fce14cc62bb35dbd5a797182a92d9ca899c3f7 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 11:55:18 +0100 Subject: [PATCH 27/44] messagesoverlay - Set type to bootloader --- apps/messagesoverlay/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/messagesoverlay/metadata.json b/apps/messagesoverlay/metadata.json index 4b9966adb..7474cf4c1 100644 --- a/apps/messagesoverlay/metadata.json +++ b/apps/messagesoverlay/metadata.json @@ -4,7 +4,7 @@ "version": "0.01", "description": "An overlay based implementation of a messages UI (display notifications from iOS and Gadgetbridge/Android)", "icon": "app.png", - "type": "app", + "type": "bootloader", "tags": "tool,system", "supports": ["BANGLEJS2"], "dependencies" : { "messageicons":"module","messages":"app" }, From 72d440a20ca2d0e176e370ed864ada9b760cbe34 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 13:07:00 +0100 Subject: [PATCH 28/44] messagesoverlay - Adds screenshots and more README --- apps/messagesoverlay/README.md | 14 ++++++++++---- apps/messagesoverlay/metadata.json | 3 ++- apps/messagesoverlay/screen_call.png | Bin 0 -> 3778 bytes apps/messagesoverlay/screen_message.png | Bin 0 -> 4510 bytes 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 apps/messagesoverlay/screen_call.png create mode 100644 apps/messagesoverlay/screen_message.png diff --git a/apps/messagesoverlay/README.md b/apps/messagesoverlay/README.md index 00fe39bd0..aa4c0d49e 100644 --- a/apps/messagesoverlay/README.md +++ b/apps/messagesoverlay/README.md @@ -1,11 +1,17 @@ -# Messages app +# Messages overlay app -This app handles the display of messages and message notifications. +This app handles the display of messages and message notifications as an overlay pop up. -It is a GUI replacement for the `messages` apps. +It is a GUI replacement for the `messages` apps. +Messages are ephemeral and not stored on the Bangle. + +## Usage + +Close app by tapping the X and scroll by swiping. The border of the pop up changes color if the Bangle is locked. The color depends on your currently active theme. ## Creator -Rarder44 +[halemmerich](https://github.com/halemmerich) +Forked from messages_light by Rarder44 diff --git a/apps/messagesoverlay/metadata.json b/apps/messagesoverlay/metadata.json index 7474cf4c1..9efe95d26 100644 --- a/apps/messagesoverlay/metadata.json +++ b/apps/messagesoverlay/metadata.json @@ -13,5 +13,6 @@ {"name":"messagesoverlay.settings.js","url":"settings.js"}, {"name":"messagesoverlay","url":"lib.js"}, {"name":"messagesoverlay.boot.js","url":"boot.js"} - ] + ], + "screenshots": [{"url":"screen_call.png"} ,{"url":"screen_message.png"} ] } diff --git a/apps/messagesoverlay/screen_call.png b/apps/messagesoverlay/screen_call.png new file mode 100644 index 0000000000000000000000000000000000000000..45326b37ee8a68a5f8c011537549cfd8ce7d8c0a GIT binary patch literal 3778 zcmV;z4n6USP)$W+3uf+%Fhn(XUT@UfWXeU}yUPN=DUltRa}$uE#N#Vp$vXja zP*EK_zAWQeZYrUkP+}nS)$3K_8AoTd+i9i9=39ADdbR$=0Co0l7M>n z_rLu1L@IC;c>$moZ+$ll@%0Cerw<>0+X%jr4{ljF-GzH$;*a%;(|rN4VAZN5|>uQ-fhF(yMpUZa|KflV%0*; zZRIB8$KU(w?4;T4dsE|FmPYSqbRegdSPHWg-;fH^+L0lDcq>AUvKw_YGWFL|7{nz(ltwN3f#--H0o;TljzHRi}J9icnq{a-cF?bXj z69@Pad(f}g3|E@WwVs$ZJshLZZ!dAtfxsC~kbRP3^1OB%`!l&6-?~R2ap`PLRRWKe zM!Tc5F(=H`CbV3Sof@q%)gtN>$cvnBnhMv*mCv?WZasmrq z5}KK}*IVsEEQwsoQ%cp|Y9m}coI;HyvF}=mC#BZTNc?vD;tJwYA-N~{XOnogKP+h> zKEHiBmDxq^9uz!8nkyuZ4cb~Z%%9&rAKM`U zq+16qvXaO_3!(k+RS$edVi5GXfvZ&8v;29g0v|kZNOf~6^HYO5z)#*BB$jr;Whbi6 zPT5191ct=72{Nx7=a@VHWH%~3rTzC`-w(ALct|&n6^)@A-)^T zomz;qEJTaZ!B@BG>WBBTByY(owN@m)>nTT4$T#Gf4Je1il7--ijHh{E;DHK^Lja7Daqudz z&-<1vrv!iyH0RE^H-*Rx3jy>%;vj*2WojTTFam;uI$&y)XcDYax6i zG5}x*3jqL+u@JtwApoFD0!yD8ni~QDx+O3GfWQC%0s{aD41mA@00IL52n+xqFaQDr zK(_>TRinwz(3K2yOW@GpO$;dldWUy%KL8lULP(`8F)I1%pRdE~X?W^>#qMjX{SVdy z!$JVC5CBk;z&_IEB=X1nVccGxI7v1p{%)9sP|Rw1(|=1Jtp5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{h6qY9i^H0ib(HHc31kjfQx7J!6(BpjUyG4?1L%#REGC z;8AM3BygEYWXkr5Ot$%foxL7LEiq&mXhC5zQV~YFcYD;V?D9}9)nzC#&=;|px7TDc z+?*9nrz;@9KpUUS-hb=oeNRSkXES)Ki+}_J_30}~OV*eSonV-^&s;&9<(mPZW(cPa zb3)MmzH)Y2swU(VmF66*0MLgTJ1Tp$g>7w>Q25{^9M0%Q&EfZl4EutqpMHv`Xc_n$bCw219$!TNn`qX;bNGmM} zvJgOJ*Gu{(9=D}r47YYV!B6alO``IWjvYQc*X{fCeYGL9J~c@9(dMVXGvAUV zD$#)Mlv&$hrlpvNSU!)Fjd>xUz(7mom6Q6p71*c+771gPv+{t%KsyqwrSb7Z_IH;c;q+Gk^U};2HH6~$+1Md zlG%8IJ@gmoz%sb&$wGFP^fx*j>q#a?&JKKYjQ?Q_cVvA_GyK9@SaS24G~f_x;%NxGPJyRV{b z`*n4ldfB_bE42TZ21f$v_us}_bIGTkz;;WXdhj7xR`Z^ z?ijU{c^-+pXD6bRb?}`;d3(*FT33%lDuH5tr@e2f$M=y6>{FFH9yj;x-ghF-JgZBQ zu9C6!KG%vX9^rv|Q27!kBX*r7ww)3n-z9TvOudq-=ZoX&3BR*!%WcbLdpnO^6BQKRr4=gQMiJmH+?%07*qoM6N<$f_Sr5hX4Qo literal 0 HcmV?d00001 diff --git a/apps/messagesoverlay/screen_message.png b/apps/messagesoverlay/screen_message.png new file mode 100644 index 0000000000000000000000000000000000000000..f3cc3b6e52ed0d643a34fc9d81d44e06a493205d GIT binary patch literal 4510 zcmV;P5n=9$P)YMf0?CTAFbf057&J_?2ZB*k8^a(4 zV9cmQO>GzeV?||ZvWAFb0S2IF=j}|^B|g|wQmWv; z`eR^b4A@wMxVr~ZL8+GX!1g0Z6H)+Qa=@$nR_%6hWd|L8Tg*ML2UgG3ZTE&qaZZ$Jp7>KsgZ z0GAtuP!Q*VI0R<<34O1|pbap(d5V!KY3gWhQ zi6R89eT%Wh(y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e)YGY_6?jkY~BNM1C>uUZ7Sy}?Vr1t4)?gkANs z?_6I?8fF;%mb6iKBI+E8@CRp>73^+!IXQ=y2}QRSPaVqC-jfS_hoRo%mIwp*Gd=?ksSK+Yb!qOon zE|5!Jc|G;BHP__n{*4Y~e|DJuZuk3MoWY%s;6s0@GZ||A;Y&dajvnny8N43fg_5y@ z!>6Yi06fY4dR&v)xh;PP2SM;2$#{;fW}Qu4(4iBlo75^PbSY?3`s3I!(&uVU-4&aY`Xix@BlbXA?ON zcx$x2T-|U^?zP%HxS@08^2gjZNb%F$ezn#S=gtDAj`6p@077kHUwynB;Ee#bGzQGc zC(FHwt){AH*9%DQEuC9$Zap;*YIIrswxsCHixvWLjuNd!K3NGJFSm^;y|47Ew6^}5 z9LFtm#3dT>(*7TG7-19h0Mh+9(b;yZ!~@ST$a~vhaTFbKO30LZ&8fl{q8`}M0+WC- z(yTlvdXbx?<5YX)z%G{98o(F?Fsr-6iyyAQJ-Odpyl(_<+q(@?*QK`I96D2T4tG;} zx}*rnWQI96wtspx21my$rS+|;i(9U>E}8RMZ=oa3(L+}c=*Sir%aNA-_=~%)NP5ff z(8cS;-CFZw$^Nver=^a#Jsrd?&;Tb!*K;k=zMX*02uwD8@kw;8c)a9qEwr#Lw6m>1 zETun|yeBc@weZ5L}temF{Rcum Date: Sun, 26 Feb 2023 13:09:36 +0100 Subject: [PATCH 29/44] messagesoverlay - Tweak font sizes and positions --- apps/messagesoverlay/lib.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index fab4709d4..8ba1a17a3 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -25,9 +25,9 @@ let settings = (() => { let tmp = {}; tmp.fontSmall = "6x8"; - tmp.fontMedium = g.getFonts().includes("Vector") ? "Vector:16" : "6x8:2"; - tmp.fontBig = g.getFonts().includes("12x20") ? "12x20" : "6x8:2"; - tmp.fontLarge = g.getFonts().includes("6x15") ? "6x15:2" : "6x8:4"; + tmp.fontMedium = "Vector:16"; + tmp.fontBig = "Vector:20"; + tmp.fontLarge = "Vector:30"; tmp.quiet = ((require('Storage').readJSON('settings.json', 1) || {}).quiet); @@ -110,22 +110,26 @@ let roundedRect = function(ovr, x,y,w,h,filled){ let drawScreen = function(ovr, title, titleFont, src, iconcolor, icon){ ovr.setBgColor(ovr.theme.bg2); - ovr.clearRect(0,0,ovr.getWidth(),40); + ovr.clearRect(0,0,ovr.getWidth(),39); ovr.setColor(ovr.theme.fg2); ovr.setFont(settings.fontSmall); ovr.setFontAlign(0,-1); - ovr.drawString(src, (ovr.getWidth()-ovrx)/2, 2); + ovr.drawString(src, (ovr.getWidth()+35-26)/2, 2); + ovr.setFontAlign(0,0); ovr.setFont(titleFont); - ovr.drawString(title, (ovr.getWidth()-ovrx)/2, 12); + ovr.drawString(title, (ovr.getWidth()+35-26)/2, 39/2 + 6); ovr.setColor(ovr.theme.fg2); - roundedRect(ovr, ovr.getWidth()-26,5,22,30,false); - ovr.drawString("X",ovr.getWidth()-16,10); + ovr.setFont(settings.fontMedium); + roundedRect(ovr, ovr.getWidth()-26,5,22,30,false); + ovr.drawString("X",ovr.getWidth()-14,21); + + ovr.setColor("#888"); + roundedRect(ovr, 5,5,30,30,true); ovr.setColor(iconcolor); - ovr.setBgColor("#fff"); ovr.drawImage(icon,8,8); }; @@ -144,7 +148,7 @@ let showMessage = function(ovr, msg) { titleFont = settings.fontLarge, lines; if (title) { - let w = ovr.getWidth() - 48; + let w = ovr.getWidth() - 35 - 26; if (ovr.setFont(titleFont).stringWidth(title) > w) titleFont = settings.fontMedium; if (ovr.setFont(titleFont).stringWidth(title) > w) { @@ -189,7 +193,7 @@ let showCall = function(ovr, msg) { titleFont = settings.fontLarge, lines; if (title) { - let w = ovr.getWidth() - 40; + let w = ovr.getWidth() - 35 -26; if (ovr.setFont(titleFont).stringWidth(title) > w) titleFont = settings.fontMedium; if (ovr.setFont(titleFont).stringWidth(title) > w) { @@ -313,6 +317,7 @@ let drawMessage = function(ovr, msg) { let yText = 40; ovr.setBgColor(ovr.theme.bg); + ovr.setColor(ovr.theme.fg); ovr.clearRect(2, yText, ovrw-2, ovrh-2); let xText = Padding; yText += Padding; @@ -321,7 +326,7 @@ let drawMessage = function(ovr, msg) { yText = ((ovrh - yText) / 2) - (linesToPrint.length * HText / 2) + yText; - if (linesToPrint.length <= 2) { + if (linesToPrint.length <= 3) { ovr.setFontAlign(0, -1); xText = ovr.getWidth() / 2; } else From 54e9704e3cb6d18843d6a6389bd62aabcf47c7a2 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 13:47:39 +0100 Subject: [PATCH 30/44] messagesoverlay - Tweak source and title texts --- apps/messagesoverlay/lib.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index 8ba1a17a3..286e5e26f 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -115,11 +115,17 @@ let drawScreen = function(ovr, title, titleFont, src, iconcolor, icon){ ovr.setColor(ovr.theme.fg2); ovr.setFont(settings.fontSmall); ovr.setFontAlign(0,-1); - ovr.drawString(src, (ovr.getWidth()+35-26)/2, 2); + + let textCenter = (ovr.getWidth()+35-26)/2; + + if (src) { + while (ovr.stringWidth(src) > ovr.getWidth()-80) src = src.substring(0,src.length-2); + ovr.drawString(src + "...", textCenter, 2); + } ovr.setFontAlign(0,0); ovr.setFont(titleFont); - ovr.drawString(title, (ovr.getWidth()+35-26)/2, 39/2 + 6); + if (title) ovr.drawString(title, textCenter, 39/2 + 6); ovr.setColor(ovr.theme.fg2); From 7ff5796fde259cb8c0048d7995eb04c2f8f501d9 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 14:05:01 +0100 Subject: [PATCH 31/44] powermanager - Catch the case of the wrapped function being a string --- apps/powermanager/boot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/powermanager/boot.js b/apps/powermanager/boot.js index 40487a5bf..f3e3f718f 100644 --- a/apps/powermanager/boot.js +++ b/apps/powermanager/boot.js @@ -77,7 +77,7 @@ let functions = {}; let wrapDeferred = ((o,t) => (a) => { - if (a == eval){ + if (a == eval || typeof a == "string") { return o.apply(this, arguments); } else { let wrapped = a; From c16a9b11033dc8b97fe4ad37c278d16ce799c65a Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 15:23:41 +0100 Subject: [PATCH 32/44] messagesoverlay - Use less memory if messages are stacked --- apps/messagesoverlay/lib.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index 286e5e26f..6a4dd7e26 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -411,6 +411,7 @@ let cleanup = function(){ if (touchHandler) Bangle.removeListener("touch", touchHandler); if (swipeHandler) Bangle.removeListener("swipe", swipeHandler); Bangle.setLCDOverlay(); + ovr = undefined; }; let backup = {}; @@ -447,12 +448,18 @@ let main = function(ovr, event) { } }; +let ovr; + exports.pushMessage = function(event) { if( event.id=="music") return require_real("messages").pushMessage(event); - let ovr = Graphics.createArrayBuffer(ovrw, ovrh, 4, { - msb: true - }); + if (!ovr) { + ovr = Graphics.createArrayBuffer(ovrw, ovrh, 4, { + msb: true + }); + } else { + ovr.clear(); + } let _g = g; g = ovr; From 3ef8ede109a0cf1f0044eed7f810e64cf8a76d42 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 15:53:00 +0100 Subject: [PATCH 33/44] messagesoverlay - Fix leaking memory --- apps/messagesoverlay/lib.js | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index 6a4dd7e26..e953022b3 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -76,12 +76,11 @@ let manageEvent = function(ovr, event) { next(ovr); else { - let neweventQueue = []; + eventQueue.length = 0; // empty existing queue eventQueue.forEach(element => { if (element.id != event.id) neweventQueue.push(element); }); - eventQueue = neweventQueue; } break; @@ -143,7 +142,6 @@ let showMessage = function(ovr, msg) { LOG("showMessage"); ovr.setBgColor(settings.colBg); - if (typeof msg.CanscrollDown === "undefined") msg.CanscrollDown = false; if (typeof msg.CanscrollUp === "undefined") @@ -214,6 +212,7 @@ let showCall = function(ovr, msg) { if (!settings.quiet) { if (msg.new) { msg.new = false; + if (callBuzzTimer) clearInterval(callBuzzTimer); callBuzzTimer = setInterval(function() { Bangle.buzz(500); }, 1000); @@ -252,7 +251,7 @@ let callBuzzTimer = null; let stopCallBuzz = function() { if (callBuzzTimer) { clearInterval(callBuzzTimer); - callBuzzTimer = null; + callBuzzTimer = undefined; } }; @@ -357,14 +356,6 @@ let drawMessage = function(ovr, msg) { Bangle.setLCDOverlay(ovr,ovrx,ovry); }; -let doubleTapUnlock = function(data) { - if (data.double) - { - Bangle.setLocked(false); - Bangle.setLCDPower(1); - } -}; - let getSwipeHandler = function(ovr){ return (lr, ud) => { if (ud == 1) { @@ -394,6 +385,7 @@ let restoreHandler = function(event){ }; let backupHandler = function(event){ + if (eventQueue.length > 1 && ovr) return; // do not backup, overlay is already up backup[event] = Bangle["#on" + event]; Bangle.removeAllListeners(event); }; @@ -407,9 +399,14 @@ let cleanup = function(){ restoreHandler("swipe"); restoreHandler("drag"); - Bangle.removeListener("tap", doubleTapUnlock); - if (touchHandler) Bangle.removeListener("touch", touchHandler); - if (swipeHandler) Bangle.removeListener("swipe", swipeHandler); + if (touchHandler) { + Bangle.removeListener("touch", touchHandler); + touchHandler = undefined; + } + if (swipeHandler) { + Bangle.removeListener("swipe", swipeHandler); + swipeHandler = undefined; + } Bangle.setLCDOverlay(); ovr = undefined; }; @@ -418,18 +415,17 @@ let backup = {}; let main = function(ovr, event) { LOG("Main", event, settings); + if (!lockListener) { lockListener = function (){ drawBorder(ovr); }; Bangle.on('lock', lockListener); } - backupHandler("touch"); backupHandler("swipe"); backupHandler("drag"); - Bangle.on('tap', doubleTapUnlock); if (touchHandler) Bangle.removeListener("touch",touchHandler); if (swipeHandler) Bangle.removeListener("swipe",swipeHandler); touchHandler = getTouchHandler(ovr); @@ -441,7 +437,10 @@ let main = function(ovr, event) { manageEvent(ovr, event); Bangle.setLCDPower(1); drawBorder(ovr); - Bangle.setLCDOverlay(ovr,10,10); + if (eventQueue.length>=1) + Bangle.setLCDOverlay(ovr,10,10); + else + Bangle.setLCDOverlay(); } else { LOG("No event given"); cleanup(); @@ -465,9 +464,7 @@ exports.pushMessage = function(event) { g = ovr; ovr.theme = g.theme; - if(event.t=="remove") return; main(ovr, event); - Bangle.setLCDOverlay(ovr, 10, 10); g = _g; }; From b14afaa891e0e826c451e5fec7fe4c7ee1e2a14f Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 17:00:48 +0100 Subject: [PATCH 34/44] messageoverlay - Fix call notification not being shown --- apps/messagesoverlay/lib.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index e953022b3..123a42def 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -109,7 +109,7 @@ let roundedRect = function(ovr, x,y,w,h,filled){ let drawScreen = function(ovr, title, titleFont, src, iconcolor, icon){ ovr.setBgColor(ovr.theme.bg2); - ovr.clearRect(0,0,ovr.getWidth(),39); + ovr.clearRect(2,2,ovr.getWidth()-3,37); ovr.setColor(ovr.theme.fg2); ovr.setFont(settings.fontSmall); @@ -434,13 +434,9 @@ let main = function(ovr, event) { Bangle.on('swipe', swipeHandler); if (event !== undefined){ + drawBorder(ovr); manageEvent(ovr, event); Bangle.setLCDPower(1); - drawBorder(ovr); - if (eventQueue.length>=1) - Bangle.setLCDOverlay(ovr,10,10); - else - Bangle.setLCDOverlay(); } else { LOG("No event given"); cleanup(); From 420c839a5be8584c37c3815d151070fd70272584 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 18:40:37 +0100 Subject: [PATCH 35/44] messagesoverlay - Add hint regarding wrong colors --- apps/messagesoverlay/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/messagesoverlay/README.md b/apps/messagesoverlay/README.md index aa4c0d49e..e267d4481 100644 --- a/apps/messagesoverlay/README.md +++ b/apps/messagesoverlay/README.md @@ -10,6 +10,9 @@ Messages are ephemeral and not stored on the Bangle. Close app by tapping the X and scroll by swiping. The border of the pop up changes color if the Bangle is locked. The color depends on your currently active theme. +## Firmware hint +Current stable firmware draws incorrect colors for emojis. Nightly firmware builds correct this. + ## Creator [halemmerich](https://github.com/halemmerich) From 0a9d8eb9b32b9ad3683aed03259a7676d99f1120 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 18:51:23 +0100 Subject: [PATCH 36/44] messagesoverlay - Fix quiet mode being ignored --- apps/messagesoverlay/lib.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index 123a42def..80e79f2d7 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -21,6 +21,10 @@ let LOG = function() { //print.apply(null, arguments); }; +let isQuiet = function(){ + return (require('Storage').readJSON('setting.json', 1) || {}).quiet; +}; + let settings = (() => { let tmp = {}; @@ -29,8 +33,6 @@ let settings = (() => { tmp.fontBig = "Vector:20"; tmp.fontLarge = "Vector:30"; - tmp.quiet = ((require('Storage').readJSON('settings.json', 1) || {}).quiet); - return tmp; })(); @@ -163,7 +165,7 @@ let showMessage = function(ovr, msg) { drawScreen(ovr, title, titleFont, msg.src || /*LANG*/ "Message", require("messageicons").getColor(msg), require("messageicons").getImage(msg)); - if (!settings.quiet && msg.new) { + if (!isQuiet() && msg.new) { msg.new = false; Bangle.buzz(); } @@ -209,7 +211,7 @@ let showCall = function(ovr, msg) { drawScreen(ovr, title, titleFont, msg.src || /*LANG*/ "Message", require("messageicons").getColor(msg), require("messageicons").getImage(msg)); stopCallBuzz(); - if (!settings.quiet) { + if (!isQuiet()) { if (msg.new) { msg.new = false; if (callBuzzTimer) clearInterval(callBuzzTimer); From c184687089e71500a23dac2d8ff2789f90e9d6a8 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 19:09:21 +0100 Subject: [PATCH 37/44] messagesoverlay - Do not light up LCD if quiet mode is on --- apps/messagesoverlay/lib.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index 80e79f2d7..f77aa87e4 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -180,7 +180,8 @@ let drawBorder = function(ovr) { ovr.setColor(ovr.theme.fg); ovr.drawRect(0,0,ovr.getWidth()-1,ovr.getHeight()-1); ovr.drawRect(1,1,ovr.getWidth()-2,ovr.getHeight()-2); - Bangle.setLCDOverlay(ovr,10,10); + Bangle.setLCDOverlay(ovr,ovrx,ovry); + if (!isQuiet()) Bangle.setLCDPower(1); }; let showCall = function(ovr, msg) { @@ -356,6 +357,7 @@ let drawMessage = function(ovr, msg) { } else msg.CanscrollDown = false; Bangle.setLCDOverlay(ovr,ovrx,ovry); + if (!isQuiet()) Bangle.setLCDPower(1); }; let getSwipeHandler = function(ovr){ @@ -438,7 +440,6 @@ let main = function(ovr, event) { if (event !== undefined){ drawBorder(ovr); manageEvent(ovr, event); - Bangle.setLCDPower(1); } else { LOG("No event given"); cleanup(); From 16a3af8d1b9f28294adbc50fefee2920d915d178 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 19:22:11 +0100 Subject: [PATCH 38/44] messagesoverlay - Finetune fonts --- apps/messagesoverlay/lib.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index f77aa87e4..71926ce59 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -16,20 +16,22 @@ const ovrw = g.getWidth()-2*ovrx; const ovrh = g.getHeight()-2*ovry; let lockListener; +let quiet; let LOG = function() { //print.apply(null, arguments); }; let isQuiet = function(){ - return (require('Storage').readJSON('setting.json', 1) || {}).quiet; + if (quiet == undefined) quiet = (require('Storage').readJSON('setting.json', 1) || {}).quiet; + return quiet; }; let settings = (() => { let tmp = {}; tmp.fontSmall = "6x8"; - tmp.fontMedium = "Vector:16"; + tmp.fontMedium = "Vector:14"; tmp.fontBig = "Vector:20"; tmp.fontLarge = "Vector:30"; @@ -126,12 +128,13 @@ let drawScreen = function(ovr, title, titleFont, src, iconcolor, icon){ ovr.setFontAlign(0,0); ovr.setFont(titleFont); - if (title) ovr.drawString(title, textCenter, 39/2 + 6); + if (title) ovr.drawString(title, textCenter, 38/2 + 5); ovr.setColor(ovr.theme.fg2); ovr.setFont(settings.fontMedium); roundedRect(ovr, ovr.getWidth()-26,5,22,30,false); + ovr.setFont("Vector:16"); ovr.drawString("X",ovr.getWidth()-14,21); ovr.setColor("#888"); @@ -244,7 +247,7 @@ let next = function(ovr) { }; let showMapMessage = function(ovr, msg) { - ovr.clearRect(Bangle.appRect); + ovr.clearRect(2,2,ovr.getWidth()-3,ovr.getHeight()-3); drawMessage(ovr, { body: "Not implemented!" }); @@ -326,7 +329,7 @@ let drawMessage = function(ovr, msg) { ovr.setBgColor(ovr.theme.bg); ovr.setColor(ovr.theme.fg); - ovr.clearRect(2, yText, ovrw-2, ovrh-2); + ovr.clearRect(2, yText, ovrw-3, ovrh-3); let xText = Padding; yText += Padding; ovr.setFont(bodyFont); @@ -413,6 +416,7 @@ let cleanup = function(){ } Bangle.setLCDOverlay(); ovr = undefined; + quiet = undefined; }; let backup = {}; From 22259d13bea6528dce4339bb73619c628ab76b84 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Sun, 26 Feb 2023 20:00:20 +0100 Subject: [PATCH 39/44] widalarmeta: Draw bell only once --- apps/widalarmeta/widget.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/widalarmeta/widget.js b/apps/widalarmeta/widget.js index 8fab6fde7..750ae5d98 100644 --- a/apps/widalarmeta/widget.js +++ b/apps/widalarmeta/widget.js @@ -19,7 +19,7 @@ } } // getNextAlarm - function draw() { + function draw(fromInterval) { if (this.nextAlarm === undefined) { let alarm = getNextAlarm(); if (alarm === undefined) { @@ -58,10 +58,14 @@ if (drawSeconds) { calcWidth += 3*5; } + this.bellVisible = false; } else if (config.drawBell && this.numActiveAlarms > 0) { - // next alarm too far in future, draw only widalarm bell - g.reset().drawImage(atob("GBgBAAAAAAAAABgADhhwDDwwGP8YGf+YMf+MM//MM//MA//AA//AA//AA//AA//AA//AB//gD//wD//wAAAAADwAABgAAAAAAAAA"),this.x,this.y); calcWidth = 24; + // next alarm too far in future, draw only widalarm bell + if (this.bellVisible !== true || fromInterval !== true) { + g.reset().drawImage(atob("GBgBAAAAAAAAABgADhhwDDwwGP8YGf+YMf+MM//MM//MA//AA//AA//AA//AA//AA//AB//gD//wD//wAAAAADwAABgAAAAAAAAA"),this.x,this.y); + this.bellVisible = true; + } } if (this.width !== calcWidth) { @@ -81,8 +85,8 @@ clearTimeout(this.timeoutId); } this.timeoutId = setTimeout(()=>{ - this.timeoutId = undefined; - this.draw(); + WIDGETS["widalarmeta"].timeoutId = undefined; + WIDGETS["widalarmeta"].draw(true); }, timeout); } /* draw */ From f62da73c55ab4255624cad036e621e4ea49f250d Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 20:02:20 +0100 Subject: [PATCH 40/44] messagesoverlay - Remove unused settings --- apps/messagesoverlay/lib.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index 71926ce59..c8fefc190 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -27,16 +27,12 @@ let isQuiet = function(){ return quiet; }; -let settings = (() => { - let tmp = {}; - - tmp.fontSmall = "6x8"; - tmp.fontMedium = "Vector:14"; - tmp.fontBig = "Vector:20"; - tmp.fontLarge = "Vector:30"; - - return tmp; -})(); +let settings = { + fontSmall:"6x8", + fontMedium:"Vector:14", + fontBig:"Vector:20", + fontLarge:"Vector:30", +}; let eventQueue = []; let callInProgress = false; @@ -145,7 +141,7 @@ let drawScreen = function(ovr, title, titleFont, src, iconcolor, icon){ let showMessage = function(ovr, msg) { LOG("showMessage"); - ovr.setBgColor(settings.colBg); + ovr.setBgColor(ovr.theme.bg); if (typeof msg.CanscrollDown === "undefined") msg.CanscrollDown = false; From 54051d5ab1bde2d87bbb7f53c5d9b8ff89b02889 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 20:03:35 +0100 Subject: [PATCH 41/44] messagesoverlay - Do not add ... to every source --- apps/messagesoverlay/lib.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index c8fefc190..bb7580750 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -118,8 +118,10 @@ let drawScreen = function(ovr, title, titleFont, src, iconcolor, icon){ let textCenter = (ovr.getWidth()+35-26)/2; if (src) { - while (ovr.stringWidth(src) > ovr.getWidth()-80) src = src.substring(0,src.length-2); - ovr.drawString(src + "...", textCenter, 2); + let shortened = src; + while (ovr.stringWidth(shortened) > ovr.getWidth()-80) shortened = shortened.substring(0,shortened.length-2); + if (shortened.length != src.length) shortened += "..."; + ovr.drawString(shortened, textCenter, 2); } ovr.setFontAlign(0,0); From 4ea368416d51c6ebfc8709a845244d7eb3e08575 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 21:17:58 +0100 Subject: [PATCH 42/44] messagesoverlay - Add low memory mode --- apps/messagesoverlay/README.md | 4 ++++ apps/messagesoverlay/lib.js | 28 ++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/apps/messagesoverlay/README.md b/apps/messagesoverlay/README.md index e267d4481..8ce1cc64d 100644 --- a/apps/messagesoverlay/README.md +++ b/apps/messagesoverlay/README.md @@ -13,6 +13,10 @@ Close app by tapping the X and scroll by swiping. The border of the pop up chang ## Firmware hint Current stable firmware draws incorrect colors for emojis. Nightly firmware builds correct this. +## Low memory mode + +If free memory is below 2000 blocks, the overlay automatically only uses 1 bit depth. Default uses roundabout 1300 blocks, while low memory mode uses about 600. + ## Creator [halemmerich](https://github.com/halemmerich) diff --git a/apps/messagesoverlay/lib.js b/apps/messagesoverlay/lib.js index bb7580750..cc6b63176 100644 --- a/apps/messagesoverlay/lib.js +++ b/apps/messagesoverlay/lib.js @@ -14,6 +14,7 @@ const ovrx = 10; const ovry = 10; const ovrw = g.getWidth()-2*ovrx; const ovrh = g.getHeight()-2*ovry; +let _g = g; let lockListener; let quiet; @@ -37,6 +38,15 @@ let settings = { let eventQueue = []; let callInProgress = false; +let show = function(ovr){ + let img = ovr; + if (ovr.getBPP() == 1) { + img = ovr.asImage(); + img.palette = new Uint16Array([_g.theme.fg,_g.theme.bg]); + } + Bangle.setLCDOverlay(img, ovrx, ovry); +}; + let manageEvent = function(ovr, event) { event.new = true; @@ -137,7 +147,7 @@ let drawScreen = function(ovr, title, titleFont, src, iconcolor, icon){ ovr.setColor("#888"); roundedRect(ovr, 5,5,30,30,true); - ovr.setColor(iconcolor); + ovr.setColor(ovr.getBPP() != 1 ? iconcolor : ovr.theme.bg2); ovr.drawImage(icon,8,8); }; @@ -181,7 +191,7 @@ let drawBorder = function(ovr) { ovr.setColor(ovr.theme.fg); ovr.drawRect(0,0,ovr.getWidth()-1,ovr.getHeight()-1); ovr.drawRect(1,1,ovr.getWidth()-2,ovr.getHeight()-2); - Bangle.setLCDOverlay(ovr,ovrx,ovry); + show(ovr); if (!isQuiet()) Bangle.setLCDPower(1); }; @@ -357,7 +367,7 @@ let drawMessage = function(ovr, msg) { drawTriangleDown(ovr); } else msg.CanscrollDown = false; - Bangle.setLCDOverlay(ovr,ovrx,ovry); + show(ovr); if (!isQuiet()) Bangle.setLCDPower(1); }; @@ -453,18 +463,24 @@ let ovr; exports.pushMessage = function(event) { if( event.id=="music") return require_real("messages").pushMessage(event); + bpp = 4; + if (process.memory().free < 2000) bpp = 1; + if (!ovr) { - ovr = Graphics.createArrayBuffer(ovrw, ovrh, 4, { + ovr = Graphics.createArrayBuffer(ovrw, ovrh, bpp, { msb: true }); } else { ovr.clear(); } - let _g = g; g = ovr; - ovr.theme = g.theme; + if (bpp == 4) + ovr.theme = g.theme; + else + ovr.theme = { fg:0, bg:1, fg2:1, bg2:0, fgH:1, bgH:0 }; + main(ovr, event); g = _g; From 868e5edc49d26b861781c29f17652c62fc2664ca Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 26 Feb 2023 22:19:57 +0100 Subject: [PATCH 43/44] powermanager - Adds some todos to readme --- apps/powermanager/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/powermanager/README.md b/apps/powermanager/README.md index 043b5ca8c..804e986e7 100644 --- a/apps/powermanager/README.md +++ b/apps/powermanager/README.md @@ -19,6 +19,14 @@ You can switch on logging in the options to diagnose unexpected power use. Curre Do not use trace logging for extended time, it uses a lot of storage and can fill up the flash quite quick. +### TODO + +* Wrap functions given as strings to setTimeout/setInterval +* Handle eval in setTimeout/setInterval +* Track functions executed as event handlers +* Track buzzer +* Modify browser interface to estimate power use like widget does + ## Internals Battery calibration offset is set by writing `batFullVoltage` in setting.json From 9b46c300f2598b1910f499dc393c9175a1eb8a42 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Mon, 27 Feb 2023 09:38:22 +0000 Subject: [PATCH 44/44] oops --- apps/runplus/app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/runplus/app.js b/apps/runplus/app.js index fef851602..9d7010e6c 100644 --- a/apps/runplus/app.js +++ b/apps/runplus/app.js @@ -63,7 +63,6 @@ function setStatus(running) { function onStartStop() { let running = !exs.state.active; let prepPromises = []; -https://github.com/espruino/BangleApps/pull/2600/conflict?name=apps%252Frunplus%252Fapp.js&ancestor_oid=15e0427592259f3112ee70d43bc7ce6fab20e1d8&base_oid=06270850f707ea94957a2990fb83425e7dc68d7f&head_oid=633e47983e015446796f69837501c8fc72255031 // start/stop recording // Do this first in case recorder needs to prompt for // an overwrite before we start tracking exstats