From 0140cb91509aab8a08b10435f924bdf123d15ff4 Mon Sep 17 00:00:00 2001 From: Hugh Barney Date: Tue, 31 Jan 2023 22:18:15 +0000 Subject: [PATCH 01/25] Settings.log, off,display,log, both --- apps/boot/ChangeLog | 1 + apps/boot/bootupdate.js | 11 ++++++----- apps/boot/metadata.json | 2 +- apps/setting/ChangeLog | 1 + apps/setting/README.md | 5 +++-- apps/setting/settings.js | 8 ++++---- apps/simplest/simplest.app.js | 1 + 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/apps/boot/ChangeLog b/apps/boot/ChangeLog index 780d9cc7d..a63a54eaf 100644 --- a/apps/boot/ChangeLog +++ b/apps/boot/ChangeLog @@ -64,3 +64,4 @@ 0.55: Add toLocalISOString polyfill for pre-2v15 firmwares Only add boot info comments if settings.bootDebug was set If settings.bootDebug is set, output timing for each section of .boot0 +0.56: Settings.log = 0,1,2,3 for off,display, log, both diff --git a/apps/boot/bootupdate.js b/apps/boot/bootupdate.js index 112dfeba8..72eb4afab 100644 --- a/apps/boot/bootupdate.js +++ b/apps/boot/bootupdate.js @@ -32,14 +32,15 @@ if (s.ble!==false) { boot += `bleServiceOptions.hid=Bangle.HID;\n`; } } -if (s.log==2) { // logging to file +// settings.log 0-off, 1-display, 2-log, 3-both +if (s.log>=2) { // logging to file boot += `_DBGLOG=require("Storage").open("log.txt","a"); `; } if (s.blerepl===false) { // If not programmable, force terminal off Bluetooth - if (s.log==2) boot += `_DBGLOG=require("Storage").open("log.txt","a"); + if (s.log>=2) boot += `_DBGLOG=require("Storage").open("log.txt","a"); LoopbackB.on('data',function(d) {_DBGLOG.write(d);Terminal.write(d);}); LoopbackA.setConsole(true);\n`; - else if (s.log) boot += `Terminal.setConsole(true);\n`; // if showing debug, force REPL onto terminal + else if (s.log==1||s.log==3) boot += `Terminal.setConsole(true);\n`; // if showing debug, force REPL onto terminal else boot += `E.setConsole(null,{force:true});\n`; // on new (2v05+) firmware we have E.setConsole which allows a 'null' console /* If not programmable add our own handler for Bluetooth data to allow Gadgetbridge commands to be received*/ @@ -56,10 +57,10 @@ Bluetooth.on('line',function(l) { try { global.GB(JSON.parse(l.slice(3,-1))); } catch(e) {} });\n`; } else { - if (s.log==2) boot += `_DBGLOG=require("Storage").open("log.txt","a"); + if (s.log>=2) boot += `_DBGLOG=require("Storage").open("log.txt","a"); LoopbackB.on('data',function(d) {_DBGLOG.write(d);Terminal.write(d);}); if (!NRF.getSecurityStatus().connected) LoopbackA.setConsole();\n`; - else if (s.log) boot += `if (!NRF.getSecurityStatus().connected) Terminal.setConsole();\n`; // if showing debug, put REPL on terminal (until connection) + else if (s.log==1||s.log==3) boot += `if (!NRF.getSecurityStatus().connected) Terminal.setConsole();\n`; // if showing debug, put REPL on terminal (until connection) else boot += `Bluetooth.setConsole(true);\n`; // else if no debug, force REPL to Bluetooth } // we just reset, so BLE should be on. diff --git a/apps/boot/metadata.json b/apps/boot/metadata.json index 455563a16..9f64b672b 100644 --- a/apps/boot/metadata.json +++ b/apps/boot/metadata.json @@ -1,7 +1,7 @@ { "id": "boot", "name": "Bootloader", - "version": "0.55", + "version": "0.56", "description": "This is needed by Bangle.js to automatically load the clock, menu, widgets and settings", "icon": "bootloader.png", "type": "bootloader", diff --git a/apps/setting/ChangeLog b/apps/setting/ChangeLog index 85ccfa1a7..9a5579f07 100644 --- a/apps/setting/ChangeLog +++ b/apps/setting/ChangeLog @@ -62,3 +62,4 @@ 0.55: More strings tagged for automatic translation. 0.56: make System menu items shorter and more consistant, Eg 'Clock', intead of 'Select Clock' +0.57: Settings.log = 0,1,2,3 for off,display,log,both diff --git a/apps/setting/README.md b/apps/setting/README.md index e5ea2b43d..2a7f7ee9c 100644 --- a/apps/setting/README.md +++ b/apps/setting/README.md @@ -56,9 +56,10 @@ The exact effects depend on the app. In general the watch will not wake up by i * **Debug Info** should debug info be shown on the watch's screen or not? - * `Hide` (default) do not show debug information - * `Show` Show on the Bangle's screen (when not connected to Bluetooth or `Programmable:off`) + * `Off` (default) do not show debug information + * `Display` Show on the Bangle's screen (when not connected to Bluetooth or `Programmable:off`) * `Log` Show on the Bangle's screen **and** write to a file called `log.txt` on Storage (when not connected to Bluetooth or `Programmable:off`). Warning - this file is appended to so may grow to be large if this is left enabled. + * `Both` Log and display on Bangle's screen * **Compact Storage** Removes deleted/old files from Storage - this will speed up your Bangle.js * **Rewrite Settings** Should not normally be required, but if `.boot0` has been deleted/corrupted (and so no settings are being loaded) this will fix it. * **Flatten Battery** Turns on all devices and draws as much power as possible, attempting to flatten the Bangle.js battery. This can still take 5+ hours. diff --git a/apps/setting/settings.js b/apps/setting/settings.js index a877ec79c..bc5f2a74a 100644 --- a/apps/setting/settings.js +++ b/apps/setting/settings.js @@ -557,11 +557,11 @@ function showUtilMenu() { var menu = { '': { 'title': /*LANG*/'Utilities' }, '< Back': ()=>showMainMenu(), - /*LANG*/'Debug Info': { - value: E.clip(0|settings.log,0,2), + /*LANG*/'Debug': { + value: E.clip(0|settings.log,0,3), min: 0, - max: 2, - format: v => [/*LANG*/"Hide",/*LANG*/"Show",/*LANG*/"Log"][E.clip(0|v,0,2)], + max: 3, + format: v => [/*LANG*/"Off",/*LANG*/"Display",/*LANG*/"Log", /*LANG*/"Both"][E.clip(0|v,0,3)], onchange: v => { settings.log = v; updateSettings(); diff --git a/apps/simplest/simplest.app.js b/apps/simplest/simplest.app.js index 4038212d0..b1e22743d 100644 --- a/apps/simplest/simplest.app.js +++ b/apps/simplest/simplest.app.js @@ -13,6 +13,7 @@ function draw() { g.setFontAlign(0, 0); g.setColor(g.theme.fg); g.drawString(timeStr, w/2, h/2); + console.log(timeStr + ", simplest"); queueDraw(); } From 8aabecd53c232fccab57670456b8fd4d7a02b703 Mon Sep 17 00:00:00 2001 From: Hugh Barney Date: Tue, 31 Jan 2023 23:46:58 +0000 Subject: [PATCH 02/25] fixed setting version --- apps/setting/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/setting/metadata.json b/apps/setting/metadata.json index 92fc75915..6d5739d03 100644 --- a/apps/setting/metadata.json +++ b/apps/setting/metadata.json @@ -1,7 +1,7 @@ { "id": "setting", "name": "Settings", - "version": "0.56", + "version": "0.57", "description": "A menu for setting up Bangle.js", "icon": "settings.png", "tags": "tool,system", From e0929fb90e2d2b27d98aceea5e1b86b038359159 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 1 Feb 2023 08:47:48 +0000 Subject: [PATCH 03/25] Tweaks to maybe make this work --- apps/boot/bootupdate.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/boot/bootupdate.js b/apps/boot/bootupdate.js index 72eb4afab..f8fab16a1 100644 --- a/apps/boot/bootupdate.js +++ b/apps/boot/bootupdate.js @@ -37,10 +37,10 @@ if (s.log>=2) { // logging to file boot += `_DBGLOG=require("Storage").open("log.txt","a"); `; } if (s.blerepl===false) { // If not programmable, force terminal off Bluetooth - if (s.log>=2) boot += `_DBGLOG=require("Storage").open("log.txt","a"); -LoopbackB.on('data',function(d) {_DBGLOG.write(d);Terminal.write(d);}); + if (s.log>=2) { boot += `_DBGLOG=require("Storage").open("log.txt","a");`; +LoopbackB.on('data',function(d) {_DBGLOG.write(d);${(s.log==3)?"Terminal.write(d);":""}}); LoopbackA.setConsole(true);\n`; - else if (s.log==1||s.log==3) boot += `Terminal.setConsole(true);\n`; // if showing debug, force REPL onto terminal + } else if (s.log==1) boot += `Terminal.setConsole(true);\n`; // if showing debug, force REPL onto terminal else boot += `E.setConsole(null,{force:true});\n`; // on new (2v05+) firmware we have E.setConsole which allows a 'null' console /* If not programmable add our own handler for Bluetooth data to allow Gadgetbridge commands to be received*/ From 07f83d50df9d24d1d1da07693d7853e20987ea33 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 1 Feb 2023 08:48:56 +0000 Subject: [PATCH 04/25] one more tweak --- apps/boot/bootupdate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/boot/bootupdate.js b/apps/boot/bootupdate.js index f8fab16a1..4e4af928d 100644 --- a/apps/boot/bootupdate.js +++ b/apps/boot/bootupdate.js @@ -58,7 +58,7 @@ Bluetooth.on('line',function(l) { });\n`; } else { if (s.log>=2) boot += `_DBGLOG=require("Storage").open("log.txt","a"); -LoopbackB.on('data',function(d) {_DBGLOG.write(d);Terminal.write(d);}); +LoopbackB.on('data',function(d) {_DBGLOG.write(d);${(s.log==3)?"Terminal.write(d);":""}}); if (!NRF.getSecurityStatus().connected) LoopbackA.setConsole();\n`; else if (s.log==1||s.log==3) boot += `if (!NRF.getSecurityStatus().connected) Terminal.setConsole();\n`; // if showing debug, put REPL on terminal (until connection) else boot += `Bluetooth.setConsole(true);\n`; // else if no debug, force REPL to Bluetooth From 6befce43e50ec5853b7759985496072862827a4c Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 1 Feb 2023 08:56:42 +0000 Subject: [PATCH 05/25] oops --- apps/boot/bootupdate.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/boot/bootupdate.js b/apps/boot/bootupdate.js index 4e4af928d..d929b26a0 100644 --- a/apps/boot/bootupdate.js +++ b/apps/boot/bootupdate.js @@ -33,11 +33,8 @@ if (s.ble!==false) { } } // settings.log 0-off, 1-display, 2-log, 3-both -if (s.log>=2) { // logging to file - boot += `_DBGLOG=require("Storage").open("log.txt","a"); -`; -} if (s.blerepl===false) { // If not programmable, force terminal off Bluetooth - if (s.log>=2) { boot += `_DBGLOG=require("Storage").open("log.txt","a");`; +if (s.blerepl===false) { // If not programmable, force terminal off Bluetooth + if (s.log>=2) { boot += `_DBGLOG=require("Storage").open("log.txt","a"); LoopbackB.on('data',function(d) {_DBGLOG.write(d);${(s.log==3)?"Terminal.write(d);":""}}); LoopbackA.setConsole(true);\n`; } else if (s.log==1) boot += `Terminal.setConsole(true);\n`; // if showing debug, force REPL onto terminal @@ -60,7 +57,7 @@ Bluetooth.on('line',function(l) { if (s.log>=2) boot += `_DBGLOG=require("Storage").open("log.txt","a"); LoopbackB.on('data',function(d) {_DBGLOG.write(d);${(s.log==3)?"Terminal.write(d);":""}}); if (!NRF.getSecurityStatus().connected) LoopbackA.setConsole();\n`; - else if (s.log==1||s.log==3) boot += `if (!NRF.getSecurityStatus().connected) Terminal.setConsole();\n`; // if showing debug, put REPL on terminal (until connection) + else if (s.log==1) boot += `if (!NRF.getSecurityStatus().connected) Terminal.setConsole();\n`; // if showing debug, put REPL on terminal (until connection) else boot += `Bluetooth.setConsole(true);\n`; // else if no debug, force REPL to Bluetooth } // we just reset, so BLE should be on. From 1174faafbf2db3c4397ff4ed3158045109b2f8fe Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Fri, 3 Feb 2023 18:03:44 +0100 Subject: [PATCH 06/25] sleepphasealarm 0.14 Reduce update interval of current time when seconds are not shown --- apps/sleepphasealarm/ChangeLog | 1 + apps/sleepphasealarm/app.js | 26 ++++++++++++++++++++------ apps/sleepphasealarm/metadata.json | 2 +- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/apps/sleepphasealarm/ChangeLog b/apps/sleepphasealarm/ChangeLog index 4815e5e75..5a7be5b20 100644 --- a/apps/sleepphasealarm/ChangeLog +++ b/apps/sleepphasealarm/ChangeLog @@ -14,3 +14,4 @@ 0.11: Minor tweaks 0.12: Support javascript command to execute as defined in scheduler 'js' configuration 0.13: Fix dated events alarm on wrong date +0.14: Reduce update interval of current time when seconds are not shown diff --git a/apps/sleepphasealarm/app.js b/apps/sleepphasealarm/app.js index 0aef07760..c74303b76 100644 --- a/apps/sleepphasealarm/app.js +++ b/apps/sleepphasealarm/app.js @@ -14,6 +14,7 @@ const active = alarms.filter(alarm => require("sched").getTimeToAlarm(alarm)); const schedSettings = require("sched").getSettings(); let buzzCount = schedSettings.buzzCount; let logs = []; +let drawTimeTimeout; // Sleep/Wake detection with Estimation of Stationary Sleep-segments (ESS): // Marko Borazio, Eugen Berlin, Nagihan Kücükyildiz, Philipp M. Scholl and Kristof Van Laerhoven, "Towards a Benchmark for Wearable Sleep Analysis with Inertial Wrist-worn Sensing Units", ICHI 2014, Verona, Italy, IEEE Press, 2014. @@ -26,7 +27,7 @@ const nomothresh=0.023; // Original implementation: 6, resolution 11 bit, scale const sleepthresh=600; var ess_values = []; var slsnds = 0; -function calc_ess(acc_magn) { +function calc_ess(acc_magn) {"ram" ess_values.push(acc_magn); if (ess_values.length == winwidth) { @@ -90,10 +91,12 @@ function drawApp() { layout.alarm_date.label = `${LABEL_WAKEUP_TIME}: ${alarmHour}:${alarmMinute}`; layout.render(); - function drawTime() { + function drawTime() {"ram" + const drawSeconds = !Bangle.isLocked(); + if (Bangle.isLCDOn()) { const now = new Date(); - layout.date.label = locale.time(now, BANGLEJS2 && Bangle.isLocked() ? 1 : 0); // hide seconds on bangle 2 + layout.date.label = locale.time(now, !drawSeconds); // hide seconds on bangle 2 const diff = nextAlarmDate - now; const diffHour = Math.floor((diff % 86400000) / 3600000).toString(); const diffMinutes = Math.floor(((diff % 86400000) % 3600000) / 60000).toString(); @@ -101,11 +104,22 @@ function drawApp() { layout.render(); } - setTimeout(()=>{ + const period = drawSeconds ? 1000 : 60000; + if (this.drawTimeTimeout !== undefined) { + clearTimeout(this.drawTimeTimeout); + } + drawTimeTimeout = setTimeout(()=>{ + drawTimeTimeout = undefined; drawTime(); - }, 1000 - (Date.now() % 1000)); + }, period - (Date.now() % period)); } + Bangle.on('lock', function(on) { + if (on === false) { + drawTime(); + } + }); + drawTime(); } @@ -146,7 +160,7 @@ if (nextAlarmDate !== undefined) { layout.render(); Bangle.setOptions({powerSave: false}); // do not dynamically change accelerometer poll interval Bangle.setPollInterval(80); // 12.5Hz - Bangle.on('accel', (accelData) => { + Bangle.on('accel', (accelData) => {"ram" const now = new Date(); const acc = accelData.mag; const swest = calc_ess(acc); diff --git a/apps/sleepphasealarm/metadata.json b/apps/sleepphasealarm/metadata.json index 5382160c0..7e8d2b1a0 100644 --- a/apps/sleepphasealarm/metadata.json +++ b/apps/sleepphasealarm/metadata.json @@ -2,7 +2,7 @@ "id": "sleepphasealarm", "name": "SleepPhaseAlarm", "shortName": "SleepPhaseAlarm", - "version": "0.13", + "version": "0.14", "description": "Uses the accelerometer to estimate sleep and wake states with the principle of Estimation of Stationary Sleep-segments (ESS, see https://ubicomp.eti.uni-siegen.de/home/datasets/ichi14/index.html.en). This app will read the next alarm from the alarm application and will wake you up to 30 minutes early at the best guessed time when you are almost already awake.", "icon": "app.png", "tags": "alarm", From aedac6a4293b8a48c5e06dbd108dbab82895a96c Mon Sep 17 00:00:00 2001 From: CarlR9 <108166078+CarlR9@users.noreply.github.com> Date: Sat, 4 Feb 2023 16:05:00 +1300 Subject: [PATCH 07/25] Add files via upload --- apps/tempgraph/ChangeLog | 2 +- apps/tempgraph/app.js | 789 +++++++++++++++++++-------------------- 2 files changed, 395 insertions(+), 396 deletions(-) diff --git a/apps/tempgraph/ChangeLog b/apps/tempgraph/ChangeLog index 58dd75a19..d21f32e9a 100644 --- a/apps/tempgraph/ChangeLog +++ b/apps/tempgraph/ChangeLog @@ -1,2 +1,2 @@ 0.01: 3/Feb/2023 Added 'Temperature Graph' app to depository. - +0.02: 4/Feb/2023 Rewrote the widget handling after discovering there's a 'widget_utils' module to properly hide and show them. diff --git a/apps/tempgraph/app.js b/apps/tempgraph/app.js index a0bb3016b..d88222112 100644 --- a/apps/tempgraph/app.js +++ b/apps/tempgraph/app.js @@ -1,395 +1,394 @@ -// Temperature Graph -// BangleJS Script - -Bangle.setBarometerPower(true,"tempgraph"); -Bangle.loadWidgets(); -var wids=WIDGETS; -var widsOn=true; -var rm=null; -var gt=null; -var dg=null; -var Layout=require("Layout"); -var C=true; -var temp,tempMode,readErrCnt,watchButton2; - -var graph=require("Storage").readJSON("tempgraph.json",true); -if(graph==undefined) { - graph=[]; -} - -var timesData=[ - // dur=duration, u=time units, d=divisions on graph, s=seconds per unit. - {dur:10,u:"Mins",d:5,s:60}, - {dur:20,u:"Mins",d:4,s:60}, - {dur:30,u:"Mins",d:3,s:60}, - {dur:40,u:"Mins",d:4,s:60}, - {dur:1,u:"Hr",d:4,s:3600}, - {dur:2,u:"Hrs",d:4,s:3600}, - {dur:3,u:"Hrs",d:3,s:3600}, - {dur:4,u:"Hrs",d:4,s:3600}, - {dur:6,u:"Hrs",d:6,s:3600}, - {dur:8,u:"Hrs",d:4,s:3600}, - {dur:12,u:"Hrs",d:6,s:3600}, - {dur:16,u:"Hrs",d:4,s:3600}, - {dur:20,u:"Hrs",d:5,s:3600}, - {dur:1,u:"Day",d:4,s:3600}, - {dur:2,u:"Days",d:4,s:86400}, - {dur:3,u:"Days",d:3,s:86400}, - {dur:4,u:"Days",d:4,s:86400}, - {dur:5,u:"Days",d:5,s:86400}, - {dur:6,u:"Days",d:6,s:86400}, - {dur:7,u:"Days",d:7,s:86400} -]; -var times=[]; -for(n=0;n{ - temp=p.temperature; - if(tempMode=="drawGraph"&&graph.length>0&&Math.abs(graph[graph.length-1].temp-temp)>10&&readErrCnt<2){ - // A large change in temperature may be a reading error. ie. A 0C or less reading after - // a 20C reading. So if this happens, the reading is repeated up to 2 times to hopefully - // skip such errors. - readErrCnt++; - print("readErrCnt "+readErrCnt); - return; - } - clearInterval(gt); - readErrCnt=0; - switch (tempMode){ - case "showTemp": - showT(); - break; - case "drawGraph": - var date=new Date(); - var dateStr=require("locale").date(date).trim(); - var hrs=date.getHours(); - var mins=date.getMinutes(); - var secs=date.getSeconds(); - graph.push({ - temp:temp, - date:dateStr, - hrs:hrs, - mins:mins, - secs:secs - }); - if(graph.length==1){ - graph[0].dur=durInd; - } - require("Storage").writeJSON("tempgraph.json", graph); - if(graph.length==150){ - clearInterval(dg); - } - drawG(); - } - }); -} - -function getTemp(){ - readErrCnt=0; - gt = setInterval(getT,800); -} - -function setButton(){ - var watchButton=setWatch(function(){ - clearInterval(gt); - clearInterval(dg); - clearWatch(watchButton); - Bangle.removeListener("touch",screenTouch); - openMenu(); - },BTN); - Bangle.on('touch',screenTouch); -} - -function setButton2(){ - watchButton2=setWatch(function(){ - clearWatch(watchButton2); - openMenu(); - },BTN); -} - -function zPad(n){ - return n.toString().padStart(2,0); -} - -function screenTouch(n,ev){ - if(ev.y>23&&ev.y<152){ - C=C==false; - drawG(false); - } -} - -function drawG(){ - function cf(t){ - if(C){ - return t; - } - return getF(t); - } - drawWids(); - var top=1; - var bar=21; - var barBot=175-22; - if(widsOn){ - top=25; - bar=bar+24; - barBot=barBot-24; - } - var low=graph[0].temp; - var hi=low; - for(n=0;nt){ - low=t; - } - if(hi10){ - div=5; - } - if(C){ - g.setColor(1,0,0); - }else{ - g.setColor(0,0,1); - } - var step=(barBot-bar)/((tempHi-tempLow)/div); - for(n=0;nexit()}, - ],lazy:true - }); - drawWids(); - messageLO.render(); -} - -function showT(){ - tempLO.lab1.label=tempLO.lab3.label; - tempLO.lab2.label=tempLO.lab4.label; - tempLO.lab3.label=tempLO.lab5.label; - tempLO.lab4.label=tempLO.lab6.label; - tempLO.lab5.label=temp.toFixed(2)+"C"; - tempLO.lab6.label=getF(temp).toFixed(2)+"F"; - tempLO.render(); -} - -function exit(){ - clearWatch(watchButton2); - openMenu(); -} - -function showTemp(){ - tempMode="showTemp"; - setButton2(); - tempLO=new Layout({ - type:"v",c:[ - {type:"h",c:[ - {type:"txt",pad:5,col:"#f77",font:"6x8:2",label:" ",id:"lab1"}, - {type:"txt",pad:5,col:"#77f",font:"6x8:2",label:" ",id:"lab2"} - ]}, - {type:"h",c:[ - {type:"txt",pad:5,col:"#f77",font:"6x8:2",label:" ",id:"lab3"}, - {type:"txt",pad:5,col:"#77f",font:"6x8:2",label:" ",id:"lab4"} - ]}, - {type:"h",c:[ - {type:"txt",pad:5,col:"#f00",font:"6x8:2",label:" ",id:"lab5"}, - {type:"txt",pad:5,col:"#00f",font:"6x8:2",label:" ",id:"lab6"} - ]}, - {type:"h",c:[ - {type:"btn",pad:2,font:"6x8:2",label:"Temp",cb:l=>getTemp()}, - {type:"btn",pad:2,font:"6x8:2",label:"Exit",cb:l=>exit()} - ]} - ] - },{lazy:true}); - tempLO.render(); - getTemp(); -} - -var menu={ - "":{ - "title":" Temp. Graph" - }, - - "Widgets":{ - value:widsOn, - format:vis=>vis?"Hide":"Show", - onchange:vis=>{ - widsOn=vis; - refreshMenu(); - } - }, - - "Duration":{ - value:times.indexOf(duration), - min:0,max:times.length-1,step:1,wrap:true, - format:tim=>times[tim], - onchange:(dur)=>{ - duration=times[dur]; - } - }, - - "Draw Graph":function(){ - E.showMenu(); - drawGraph(); - }, - - "Show Graph" : function(){ - E.showMenu(); - if(graph.length>0){ - showGraph(); - }else{ - message("No graph to\nshow as no\ngraph has been\ndrawn yet."); - } - }, - - "Save Graph" : function(){ - E.showMenu(); - if(graph.length>0){ - saveGraph(); - }else{ - message("No graph to\nsave as no\ngraph has been\ndrawn yet."); - } - }, - - "Save Data" : function(){ - E.showMenu(); - if(graph.length>0){ - saveData(); - }else{ - message("No data to\nsave as no\ngraph has been\ndrawn yet."); - } - }, - - "Show Temp":function(){ - E.showMenu(); - showTemp(); - } -}; - -openMenu(); +// Temperature Graph +// BangleJS Script + +Bangle.setBarometerPower(true,"tempgraph"); +Bangle.loadWidgets(); +var widsOn=true; +var rm=null; +var gt=null; +var dg=null; +var Layout=require("Layout"); +var C=true; +var temp,tempMode,readErrCnt,watchButton2; + +var graph=require("Storage").readJSON("tempgraph.json",true); +if(graph==undefined) { + graph=[]; +} + +var timesData=[ + // dur=duration, u=time units, d=divisions on graph, s=seconds per unit. + {dur:10,u:"Mins",d:5,s:60}, + {dur:20,u:"Mins",d:4,s:60}, + {dur:30,u:"Mins",d:3,s:60}, + {dur:40,u:"Mins",d:4,s:60}, + {dur:1,u:"Hr",d:4,s:3600}, + {dur:2,u:"Hrs",d:4,s:3600}, + {dur:3,u:"Hrs",d:3,s:3600}, + {dur:4,u:"Hrs",d:4,s:3600}, + {dur:6,u:"Hrs",d:6,s:3600}, + {dur:8,u:"Hrs",d:4,s:3600}, + {dur:12,u:"Hrs",d:6,s:3600}, + {dur:16,u:"Hrs",d:4,s:3600}, + {dur:20,u:"Hrs",d:5,s:3600}, + {dur:1,u:"Day",d:4,s:3600}, + {dur:2,u:"Days",d:4,s:86400}, + {dur:3,u:"Days",d:3,s:86400}, + {dur:4,u:"Days",d:4,s:86400}, + {dur:5,u:"Days",d:5,s:86400}, + {dur:6,u:"Days",d:6,s:86400}, + {dur:7,u:"Days",d:7,s:86400} +]; +var times=[]; +for(n=0;n{ + temp=p.temperature; + if(tempMode=="drawGraph"&&graph.length>0&&Math.abs(graph[graph.length-1].temp-temp)>10&&readErrCnt<2){ + // A large change in temperature may be a reading error. ie. A 0C or less reading after + // a 20C reading. So if this happens, the reading is repeated up to 2 times to hopefully + // skip such errors. + readErrCnt++; + print("readErrCnt "+readErrCnt); + return; + } + clearInterval(gt); + readErrCnt=0; + switch (tempMode){ + case "showTemp": + showT(); + break; + case "drawGraph": + var date=new Date(); + var dateStr=require("locale").date(date).trim(); + var hrs=date.getHours(); + var mins=date.getMinutes(); + var secs=date.getSeconds(); + graph.push({ + temp:temp, + date:dateStr, + hrs:hrs, + mins:mins, + secs:secs + }); + if(graph.length==1){ + graph[0].dur=durInd; + } + require("Storage").writeJSON("tempgraph.json", graph); + if(graph.length==150){ + clearInterval(dg); + } + drawG(); + } + }); +} + +function getTemp(){ + readErrCnt=0; + gt = setInterval(getT,800); +} + +function setButton(){ + var watchButton=setWatch(function(){ + clearInterval(gt); + clearInterval(dg); + clearWatch(watchButton); + Bangle.removeListener("touch",screenTouch); + openMenu(); + },BTN); + Bangle.on('touch',screenTouch); +} + +function setButton2(){ + watchButton2=setWatch(function(){ + clearWatch(watchButton2); + openMenu(); + },BTN); +} + +function zPad(n){ + return n.toString().padStart(2,0); +} + +function screenTouch(n,ev){ + if(ev.y>23&&ev.y<152){ + C=C==false; + drawG(false); + } +} + +function drawG(){ + function cf(t){ + if(C){ + return t; + } + return getF(t); + } + drawWids(); + var top=1; + var bar=21; + var barBot=175-22; + if(widsOn){ + top=25; + bar=bar+24; + barBot=barBot-24; + } + var low=graph[0].temp; + var hi=low; + for(n=0;nt){ + low=t; + } + if(hi10){ + div=5; + } + if(C){ + g.setColor(1,0,0); + }else{ + g.setColor(0,0,1); + } + var step=(barBot-bar)/((tempHi-tempLow)/div); + for(n=0;nexit()}, + ],lazy:true + }); + drawWids(); + messageLO.render(); +} + +function showT(){ + tempLO.lab1.label=tempLO.lab3.label; + tempLO.lab2.label=tempLO.lab4.label; + tempLO.lab3.label=tempLO.lab5.label; + tempLO.lab4.label=tempLO.lab6.label; + tempLO.lab5.label=temp.toFixed(2)+"C"; + tempLO.lab6.label=getF(temp).toFixed(2)+"F"; + tempLO.render(); +} + +function exit(){ + clearWatch(watchButton2); + openMenu(); +} + +function showTemp(){ + tempMode="showTemp"; + setButton2(); + tempLO=new Layout({ + type:"v",c:[ + {type:"h",c:[ + {type:"txt",pad:5,col:"#f77",font:"6x8:2",label:" ",id:"lab1"}, + {type:"txt",pad:5,col:"#77f",font:"6x8:2",label:" ",id:"lab2"} + ]}, + {type:"h",c:[ + {type:"txt",pad:5,col:"#f77",font:"6x8:2",label:" ",id:"lab3"}, + {type:"txt",pad:5,col:"#77f",font:"6x8:2",label:" ",id:"lab4"} + ]}, + {type:"h",c:[ + {type:"txt",pad:5,col:"#f00",font:"6x8:2",label:" ",id:"lab5"}, + {type:"txt",pad:5,col:"#00f",font:"6x8:2",label:" ",id:"lab6"} + ]}, + {type:"h",c:[ + {type:"btn",pad:2,font:"6x8:2",label:"Temp",cb:l=>getTemp()}, + {type:"btn",pad:2,font:"6x8:2",label:"Exit",cb:l=>exit()} + ]} + ] + },{lazy:true}); + tempLO.render(); + getTemp(); +} + +var menu={ + "":{ + "title":" Temp. Graph" + }, + + "Widgets":{ + value:widsOn, + format:vis=>vis?"Hide":"Show", + onchange:vis=>{ + widsOn=vis; + refreshMenu(); + } + }, + + "Duration":{ + value:times.indexOf(duration), + min:0,max:times.length-1,step:1,wrap:true, + format:tim=>times[tim], + onchange:(dur)=>{ + duration=times[dur]; + } + }, + + "Draw Graph":function(){ + E.showMenu(); + drawGraph(); + }, + + "Show Graph" : function(){ + E.showMenu(); + if(graph.length>0){ + showGraph(); + }else{ + message("No graph to\nshow as no\ngraph has been\ndrawn yet."); + } + }, + + "Save Graph" : function(){ + E.showMenu(); + if(graph.length>0){ + saveGraph(); + }else{ + message("No graph to\nsave as no\ngraph has been\ndrawn yet."); + } + }, + + "Save Data" : function(){ + E.showMenu(); + if(graph.length>0){ + saveData(); + }else{ + message("No data to\nsave as no\ngraph has been\ndrawn yet."); + } + }, + + "Show Temp":function(){ + E.showMenu(); + showTemp(); + } +}; + +openMenu(); From 46c1ffa89311bbbb1aab22c85eec30d0b6be3cd9 Mon Sep 17 00:00:00 2001 From: CarlR9 <108166078+CarlR9@users.noreply.github.com> Date: Sat, 4 Feb 2023 19:05:16 +1300 Subject: [PATCH 08/25] Add files via upload --- apps/tempgraph/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/tempgraph/metadata.json b/apps/tempgraph/metadata.json index 6772429a5..ceb6e565f 100644 --- a/apps/tempgraph/metadata.json +++ b/apps/tempgraph/metadata.json @@ -1,7 +1,7 @@ { "id": "tempgraph", "name": "Temperature Graph", "shortName":"Temp Graph", - "version":"0.01", + "version":"0.02", "description": "An app for recording the temperature for time periods ranging from 10 minutes to 7 days.", "icon": "app.png", "type": "app", From 3ada5934776d2058926b62f5c87e836f4c428e6f Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Sat, 4 Feb 2023 09:53:05 +0100 Subject: [PATCH 09/25] sleepphasealarm: loggin on Bangle 1 Limit logging on Bangle.js 1 to one day due to low memory --- apps/sleepphasealarm/ChangeLog | 1 + apps/sleepphasealarm/README.md | 1 + apps/sleepphasealarm/app.js | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/sleepphasealarm/ChangeLog b/apps/sleepphasealarm/ChangeLog index 5a7be5b20..1d4331042 100644 --- a/apps/sleepphasealarm/ChangeLog +++ b/apps/sleepphasealarm/ChangeLog @@ -15,3 +15,4 @@ 0.12: Support javascript command to execute as defined in scheduler 'js' configuration 0.13: Fix dated events alarm on wrong date 0.14: Reduce update interval of current time when seconds are not shown + Limit logging on Bangle.js 1 to one day due to low memory diff --git a/apps/sleepphasealarm/README.md b/apps/sleepphasealarm/README.md index 574e84e1e..bbf1d84ab 100644 --- a/apps/sleepphasealarm/README.md +++ b/apps/sleepphasealarm/README.md @@ -23,6 +23,7 @@ Replacing the watch strap with a more comfortable one (e.g. made of nylon) is re ## Logging For each day of month (1..31) the ESS states are logged. An entry will be overwritten in the next month, e.g. an entry on the 4th May will overwrite an entry on the 4th April. +On Bangle.js 1 only one day is logged due to low memory. The logs can be viewed with the download button: ![](screenshot.jpg) diff --git a/apps/sleepphasealarm/app.js b/apps/sleepphasealarm/app.js index c74303b76..25ca7e781 100644 --- a/apps/sleepphasealarm/app.js +++ b/apps/sleepphasealarm/app.js @@ -146,8 +146,9 @@ function addLog(time, type) { var minAlarm = new Date(); var measure = true; if (nextAlarmDate !== undefined) { - config.logs[nextAlarmDate.getDate()] = []; // overwrite log on each day of month - logs = config.logs[nextAlarmDate.getDate()]; + const logday = BANGLEJS2 ? nextAlarmDate.getDate() : 0; + config.logs[logday] = []; // overwrite log on each day of month + logs = config.logs[logday]; g.clear(); Bangle.loadWidgets(); Bangle.drawWidgets(); From de20a40100ecd75c94f557b7df91cc6fc0007a17 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Sat, 4 Feb 2023 22:36:16 +0100 Subject: [PATCH 10/25] check for existing swipe handlers --- apps/backswipe/ChangeLog | 1 + apps/backswipe/boot.js | 4 ++-- apps/backswipe/metadata.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/backswipe/ChangeLog b/apps/backswipe/ChangeLog index 5560f00bc..1e5479d6e 100644 --- a/apps/backswipe/ChangeLog +++ b/apps/backswipe/ChangeLog @@ -1 +1,2 @@ 0.01: New App! +0.02: Don't fire if the app uses swipes already. diff --git a/apps/backswipe/boot.js b/apps/backswipe/boot.js index 523149e8c..31b277620 100644 --- a/apps/backswipe/boot.js +++ b/apps/backswipe/boot.js @@ -15,8 +15,8 @@ var currentFile = global.__FILE__ || ""; - if(global.BACK) delete global.BACK; - if (options && options.back && enabledForApp(currentFile)) { + if (global.BACK) delete global.BACK; + if (options && options.back && enabledForApp(currentFile) && (Bangle["#onswipe"] instanceof Array)&&Bangle["#onswipe"].length>1 ) { global.BACK = options.back; } setUI(mode, cb); diff --git a/apps/backswipe/metadata.json b/apps/backswipe/metadata.json index 7aa9f6247..0274ec8d7 100644 --- a/apps/backswipe/metadata.json +++ b/apps/backswipe/metadata.json @@ -1,7 +1,7 @@ { "id": "backswipe", "name": "Back Swipe", "shortName":"BackSwipe", - "version":"0.01", + "version":"0.02", "description": "Service that allows you to use an app's back button using left to right swipe gesture", "icon": "app.png", "tags": "back,gesture,swipe", From 12c75117820f164d9670e1afff3b162ce1e50e02 Mon Sep 17 00:00:00 2001 From: CarlR9 <108166078+CarlR9@users.noreply.github.com> Date: Sun, 5 Feb 2023 16:07:35 +1300 Subject: [PATCH 11/25] Add files via upload --- apps/tempgraph/ChangeLog | 1 + apps/tempgraph/app.js | 2 +- apps/tempgraph/metadata.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/tempgraph/ChangeLog b/apps/tempgraph/ChangeLog index d21f32e9a..74f2d7255 100644 --- a/apps/tempgraph/ChangeLog +++ b/apps/tempgraph/ChangeLog @@ -1,2 +1,3 @@ 0.01: 3/Feb/2023 Added 'Temperature Graph' app to depository. 0.02: 4/Feb/2023 Rewrote the widget handling after discovering there's a 'widget_utils' module to properly hide and show them. +0.03: 4/Feb/2023 Fixed number error in timesData array. diff --git a/apps/tempgraph/app.js b/apps/tempgraph/app.js index d88222112..b8dd231ae 100644 --- a/apps/tempgraph/app.js +++ b/apps/tempgraph/app.js @@ -31,7 +31,7 @@ var timesData=[ {dur:12,u:"Hrs",d:6,s:3600}, {dur:16,u:"Hrs",d:4,s:3600}, {dur:20,u:"Hrs",d:5,s:3600}, - {dur:1,u:"Day",d:4,s:3600}, + {dur:1,u:"Day",d:4,s:86400}, {dur:2,u:"Days",d:4,s:86400}, {dur:3,u:"Days",d:3,s:86400}, {dur:4,u:"Days",d:4,s:86400}, diff --git a/apps/tempgraph/metadata.json b/apps/tempgraph/metadata.json index ceb6e565f..63d4feddd 100644 --- a/apps/tempgraph/metadata.json +++ b/apps/tempgraph/metadata.json @@ -1,7 +1,7 @@ { "id": "tempgraph", "name": "Temperature Graph", "shortName":"Temp Graph", - "version":"0.02", + "version":"0.03", "description": "An app for recording the temperature for time periods ranging from 10 minutes to 7 days.", "icon": "app.png", "type": "app", From b0b1eefb01ba600e8bda0e3848498e7dd932bfcf Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Sun, 5 Feb 2023 11:38:22 +0100 Subject: [PATCH 12/25] sleepphasealarm Add plot logged data to settings --- apps/sleepphasealarm/ChangeLog | 1 + apps/sleepphasealarm/settings.js | 117 +++++++++++++++++++++++++------ 2 files changed, 98 insertions(+), 20 deletions(-) diff --git a/apps/sleepphasealarm/ChangeLog b/apps/sleepphasealarm/ChangeLog index 1d4331042..4b119b571 100644 --- a/apps/sleepphasealarm/ChangeLog +++ b/apps/sleepphasealarm/ChangeLog @@ -16,3 +16,4 @@ 0.13: Fix dated events alarm on wrong date 0.14: Reduce update interval of current time when seconds are not shown Limit logging on Bangle.js 1 to one day due to low memory + Add plot logged data to settings diff --git a/apps/sleepphasealarm/settings.js b/apps/sleepphasealarm/settings.js index a79abb598..b6fbdf60b 100644 --- a/apps/sleepphasealarm/settings.js +++ b/apps/sleepphasealarm/settings.js @@ -13,25 +13,102 @@ require('Storage').writeJSON(CONFIGFILE, config); } - // Show the menu - E.showMenu({ - "" : { "title" : "SleepPhaseAlarm" }, - 'Keep alarm enabled': { - value: !!config.settings.disableAlarm, - format: v => v?"No":"Yes", - onchange: v => { - config.settings.disableAlarm = v; - writeSettings(); + function draw(log) { + const step = 10*60*1000; // resolution 10min + const yTicks = ["sleep", "awake", "alarm"]; + const starttime = new Date(log[0].time); + const endtime = new Date(log[log.length-1].time); + + let logidx = 0; + let curtime = starttime; + const data = new Uint8Array(Math.ceil((endtime-curtime)/step) + 1); + let curval; + let logtime; + let i=0; + while(curtime < endtime) { + if (logtime === undefined || curtime > logtime) { + curval = yTicks.indexOf(log[logidx].type); + logidx++; + logtime = new Date(log[logidx].time); } - }, "< Back" : () => back(), - 'Run before alarm': { - format: v => v === 0 ? 'disabled' : v+'h', - value: config.settings.startBeforeAlarm, - min: 0, max: 23, - onchange: v => { - config.settings.startBeforeAlarm = v; - writeSettings(); - } - }, - }); + + data[i++] = curval; + curtime = new Date(curtime + step); + } + data[i] = 1; // always end with awake + + Bangle.setUI({ + mode: "custom", + back: () => selectday(), + }); + g.reset().setFont("6x8",1); + + require("graph").drawLine(g, data, { + axes: true, + x: 4, + y: Bangle.appRect.y+8, + height: Bangle.appRect.h-20, + gridx: 1, + gridy: 1, + miny: -1, + maxy: 2, + title: /*LANG*/"Wakeup " + require("locale").date(endtime, 1), + ylabel: y => y >= 0 && y <= 1 ? yTicks[y] : "", + xlabel: x => { + if (x === Math.round(data.length/10)) { + return require("locale").time(starttime, 1); + } else if (x === (data.length-2)-Math.round(data.length/10)) { + return require("locale").time(endtime, 1); + } + return ""; + }, + }); + } + + function selectday() { + E.showMessage(/*LANG*/"Loading..."); + + const logs = config.logs.filter(log => log != null && log.filter(entry => entry.type === "alarm").length > 0); + logs.sort(function(a, b) { // sort by alarm date desc + const adate = new Date(a.filter(entry => entry.type === "alarm")[0].time); + const bdate = new Date(b.filter(entry => entry.type === "alarm")[0].time); + return bdate - adate; + }); + + const menu = {}; + menu[""] = { title: /*LANG*/"Select day" }; + menu["< Back"] = () => settingsmenu(); + logs.forEach((log, i) => { + const date = new Date(log.filter(entry => entry.type === "alarm")[0].time); + menu[require("locale").date(date, 1)] = () => { E.showMenu(); draw(log); }; + }); + E.showMenu(menu); + } + + function settingsmenu() { + // Show the menu + E.showMenu({ + "" : { "title" : "SleepPhaseAlarm" }, + 'Keep alarm enabled': { + value: !!config.settings.disableAlarm, + format: v => v?"No":"Yes", + onchange: v => { + config.settings.disableAlarm = v; + writeSettings(); + } + }, "< Back" : () => back(), + 'Run before alarm': { + format: v => v === 0 ? 'disabled' : v+'h', + value: config.settings.startBeforeAlarm, + min: 0, max: 23, + onchange: v => { + config.settings.startBeforeAlarm = v; + writeSettings(); + } + }, + /*LANG*/'Select day': () => selectday(), + }); + } + + settingsmenu(); }) From 853c99e8891c0ad1ca93f4d963ecf04dbc246489 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Sun, 5 Feb 2023 14:25:37 +0100 Subject: [PATCH 13/25] check for NOT more than one swipe handler --- apps/backswipe/boot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/backswipe/boot.js b/apps/backswipe/boot.js index 31b277620..12910fbb5 100644 --- a/apps/backswipe/boot.js +++ b/apps/backswipe/boot.js @@ -16,7 +16,7 @@ var currentFile = global.__FILE__ || ""; if (global.BACK) delete global.BACK; - if (options && options.back && enabledForApp(currentFile) && (Bangle["#onswipe"] instanceof Array)&&Bangle["#onswipe"].length>1 ) { + if (options && options.back && enabledForApp(currentFile) && !((Bangle["#onswipe"] instanceof Array)&&Bangle["#onswipe"].length>1 )) { global.BACK = options.back; } setUI(mode, cb); From 0c29640dfdc96e1e2fd3c20e8a0c3399825c1621 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Sun, 5 Feb 2023 14:43:43 +0100 Subject: [PATCH 14/25] ud is not used --- apps/backswipe/boot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/backswipe/boot.js b/apps/backswipe/boot.js index 12910fbb5..1369c1949 100644 --- a/apps/backswipe/boot.js +++ b/apps/backswipe/boot.js @@ -22,7 +22,7 @@ setUI(mode, cb); }; - function goBack(lr, ud) { + function goBack(lr, _) { // if it is a left to right swipe if (lr === 1) { // if we're in an app that has a back button, run the callback for it From aa7fdc3966c5ead721f0002746215cf6806524ae Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 6 Feb 2023 19:19:38 +0100 Subject: [PATCH 15/25] sleepphasealarm Added screenshot_log.png --- apps/sleepphasealarm/README.md | 8 ++++++-- .../{screenshot.jpg => interface.jpg} | Bin apps/sleepphasealarm/metadata.json | 3 ++- apps/sleepphasealarm/screenshot.png | Bin 0 -> 3404 bytes apps/sleepphasealarm/screenshot_log.png | Bin 0 -> 3179 bytes 5 files changed, 8 insertions(+), 3 deletions(-) rename apps/sleepphasealarm/{screenshot.jpg => interface.jpg} (100%) create mode 100644 apps/sleepphasealarm/screenshot.png create mode 100644 apps/sleepphasealarm/screenshot_log.png diff --git a/apps/sleepphasealarm/README.md b/apps/sleepphasealarm/README.md index bbf1d84ab..5aded316e 100644 --- a/apps/sleepphasealarm/README.md +++ b/apps/sleepphasealarm/README.md @@ -24,6 +24,10 @@ Replacing the watch strap with a more comfortable one (e.g. made of nylon) is re For each day of month (1..31) the ESS states are logged. An entry will be overwritten in the next month, e.g. an entry on the 4th May will overwrite an entry on the 4th April. On Bangle.js 1 only one day is logged due to low memory. -The logs can be viewed with the download button: +The logs can be plotted from the settings menu: -![](screenshot.jpg) +![](screenshot_log.png) + +The logs can also be viewed with the download button in the App Loader: + +![](interface.jpg) diff --git a/apps/sleepphasealarm/screenshot.jpg b/apps/sleepphasealarm/interface.jpg similarity index 100% rename from apps/sleepphasealarm/screenshot.jpg rename to apps/sleepphasealarm/interface.jpg diff --git a/apps/sleepphasealarm/metadata.json b/apps/sleepphasealarm/metadata.json index 7e8d2b1a0..fabd9f135 100644 --- a/apps/sleepphasealarm/metadata.json +++ b/apps/sleepphasealarm/metadata.json @@ -15,5 +15,6 @@ {"name":"sleepphasealarm.img","url":"app-icon.js","evaluate":true} ], "data": [{"name":"sleepphasealarm.json"}], - "interface": "interface.html" + "interface": "interface.html", + "screenshots": [ {"url":"screenshot.png"}, {"url":"screenshot_log.png"} ] } diff --git a/apps/sleepphasealarm/screenshot.png b/apps/sleepphasealarm/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..769ebbbbc85b4147cced277ba7bc4afdc49f3db2 GIT binary patch literal 3404 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 literal 0 HcmV?d00001 diff --git a/apps/sleepphasealarm/screenshot_log.png b/apps/sleepphasealarm/screenshot_log.png new file mode 100644 index 0000000000000000000000000000000000000000..3442e36ca1a2c33e0e7d21f91d638893aa012386 GIT binary patch literal 3179 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 m(K#%(59R+l3H<|acMdS1z8d8 Date: Tue, 7 Feb 2023 19:33:57 +0100 Subject: [PATCH 16/25] count # of handlers when deciding whether to go back --- apps/backswipe/boot.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/backswipe/boot.js b/apps/backswipe/boot.js index 1369c1949..8acd5244c 100644 --- a/apps/backswipe/boot.js +++ b/apps/backswipe/boot.js @@ -22,11 +22,21 @@ setUI(mode, cb); }; + function countHandlers(eventType) { + if (Bangle["#on"+eventType] === undefined) { + return 0; + } else if (Bangle["#on"+eventType] instanceof Array) { + return Bangle["#on"+eventType].length; + } else if (Bangle["#on"+eventType] !== undefiened) { + return 1; + } + } + function goBack(lr, _) { // if it is a left to right swipe if (lr === 1) { // if we're in an app that has a back button, run the callback for it - if (global.BACK) { + if (global.BACK && countHandlers("swipe")<4 && countHandlers("drag")<1) { // # of allowed handlers should be user configurable in settings global.BACK(); } } From 23e345202aedf2e85556efd2e98ff54c22aadc74 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Tue, 7 Feb 2023 19:40:07 +0100 Subject: [PATCH 17/25] remove some bool --- apps/backswipe/boot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/backswipe/boot.js b/apps/backswipe/boot.js index 8acd5244c..337718dec 100644 --- a/apps/backswipe/boot.js +++ b/apps/backswipe/boot.js @@ -16,7 +16,7 @@ var currentFile = global.__FILE__ || ""; if (global.BACK) delete global.BACK; - if (options && options.back && enabledForApp(currentFile) && !((Bangle["#onswipe"] instanceof Array)&&Bangle["#onswipe"].length>1 )) { + if (options && options.back && enabledForApp(currentFile)) { global.BACK = options.back; } setUI(mode, cb); From 4649f908d075f9a5ac09311d49d2b2560a5f07d4 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Tue, 7 Feb 2023 20:28:22 +0100 Subject: [PATCH 18/25] add settings for standard # of swipe and drag handlers --- apps/backswipe/boot.js | 4 ++-- apps/backswipe/settings.js | 46 ++++++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/apps/backswipe/boot.js b/apps/backswipe/boot.js index 337718dec..e46f902eb 100644 --- a/apps/backswipe/boot.js +++ b/apps/backswipe/boot.js @@ -27,7 +27,7 @@ return 0; } else if (Bangle["#on"+eventType] instanceof Array) { return Bangle["#on"+eventType].length; - } else if (Bangle["#on"+eventType] !== undefiened) { + } else if (Bangle["#on"+eventType] !== undefined) { return 1; } } @@ -36,7 +36,7 @@ // if it is a left to right swipe if (lr === 1) { // if we're in an app that has a back button, run the callback for it - if (global.BACK && countHandlers("swipe")<4 && countHandlers("drag")<1) { // # of allowed handlers should be user configurable in settings + if (global.BACK && countHandlers("swipe")<=settings.standardNumSwipeHandlers && countHandlers("drag")<=settings.standardNumDragHandlers) { global.BACK(); } } diff --git a/apps/backswipe/settings.js b/apps/backswipe/settings.js index 2c29e86f8..3eb1fb377 100644 --- a/apps/backswipe/settings.js +++ b/apps/backswipe/settings.js @@ -4,19 +4,21 @@ // Apps is an array of app info objects, where all the apps that are there are either blocked or allowed, depending on the mode var DEFAULTS = { 'mode': 0, - 'apps': [] + 'apps': [], + 'standardNumSwipeHandlers': 0, + 'standardNumDragHandlers': 0 }; - + var settings = {}; - + var loadSettings = function() { settings = require('Storage').readJSON(FILE, 1) || DEFAULTS; - } - + }; + var saveSettings = function(settings) { require('Storage').write(FILE, settings); - } - + }; + // Get all app info files var getApps = function() { var apps = require('Storage').list(/\.info$/).map(appInfoFileName => { @@ -35,8 +37,8 @@ return 0; }); return apps; - } - + }; + var showMenu = function() { var menu = { '': { 'title': 'Backswipe' }, @@ -55,11 +57,31 @@ }, 'App List': () => { showAppSubMenu(); + }, + 'standard # of swipe handlers' : { // If more than this many handlers are present backswipe will not go back + value: 0|settings.standardNumSwipeHandlers, + min: 0, + max: 10, + format: v=>v, + onchange: v => { + settings.standardNumSwipeHandlers = v; + saveSettings(settings); + }, + }, + 'standard # of drag handlers' : { // If more than this many handlers are present backswipe will not go back + value: 0|settings.standardNumDragHandlers, + min: 0, + max: 10, + format: v=>v, + onchange: v => { + settings.standardNumDragHandlers = v; + saveSettings(settings); + }, } }; - + E.showMenu(menu); - } + }; var showAppSubMenu = function() { var menu = { @@ -101,4 +123,4 @@ loadSettings(); showMenu(); -}) \ No newline at end of file +}) From 3873f9c14b7a7d29f4a2e787c9cee418e0504e60 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Wed, 8 Feb 2023 12:29:49 +0100 Subject: [PATCH 19/25] add readme --- apps/backswipe/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 apps/backswipe/README.md diff --git a/apps/backswipe/README.md b/apps/backswipe/README.md new file mode 100644 index 000000000..7f0e2f6be --- /dev/null +++ b/apps/backswipe/README.md @@ -0,0 +1,16 @@ +Service that allows you to use an app's back button using left to right swipe gesture. + +## Settings + +Mode: Blacklist/Whitelist/Always On/Disabled +App List: Black-/whitelisted apps +standard # of swipe handlers: 0-10 +standard # of drag handlers: 0-10 + +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. + +## Creator +Kedlub + +## Contributors +thyttan From c9dabdf680b8da0f5da3b93899db84337aabd9ff Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Wed, 8 Feb 2023 12:39:27 +0100 Subject: [PATCH 20/25] Capitalization --- apps/backswipe/README.md | 4 ++-- apps/backswipe/settings.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/backswipe/README.md b/apps/backswipe/README.md index 7f0e2f6be..fd6dd29b6 100644 --- a/apps/backswipe/README.md +++ b/apps/backswipe/README.md @@ -4,8 +4,8 @@ Service that allows you to use an app's back button using left to right swipe ge Mode: Blacklist/Whitelist/Always On/Disabled App List: Black-/whitelisted apps -standard # of swipe handlers: 0-10 -standard # of drag handlers: 0-10 +Standard # of swipe handlers: 0-10 +Standard # of drag handlers: 0-10 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. diff --git a/apps/backswipe/settings.js b/apps/backswipe/settings.js index 3eb1fb377..42ca7ae7d 100644 --- a/apps/backswipe/settings.js +++ b/apps/backswipe/settings.js @@ -58,7 +58,7 @@ 'App List': () => { showAppSubMenu(); }, - 'standard # of swipe handlers' : { // If more than this many handlers are present backswipe will not go back + 'Standard # of swipe handlers' : { // If more than this many handlers are present backswipe will not go back value: 0|settings.standardNumSwipeHandlers, min: 0, max: 10, @@ -68,7 +68,7 @@ saveSettings(settings); }, }, - 'standard # of drag handlers' : { // If more than this many handlers are present backswipe will not go back + 'Standard # of drag handlers' : { // If more than this many handlers are present backswipe will not go back value: 0|settings.standardNumDragHandlers, min: 0, max: 10, From 8b7e152c83933b56c626d271439354478071fea5 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Wed, 8 Feb 2023 12:42:02 +0100 Subject: [PATCH 21/25] add to readme --- apps/backswipe/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/backswipe/README.md b/apps/backswipe/README.md index fd6dd29b6..1611263bb 100644 --- a/apps/backswipe/README.md +++ b/apps/backswipe/README.md @@ -4,8 +4,9 @@ Service that allows you to use an app's back button using left to right swipe ge Mode: Blacklist/Whitelist/Always On/Disabled App List: Black-/whitelisted apps -Standard # of swipe handlers: 0-10 -Standard # of drag handlers: 0-10 +Standard # of swipe handlers: 0-10 (Default: 0, must be changed for backswipe to work at all) +Standard # of drag handlers: 0-10 (Default: 0, must be changed for backswipe to work at all) + 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. From 2538d417ad9336f22410628e2c4e0dd1f3545036 Mon Sep 17 00:00:00 2001 From: KungPhoo Date: Wed, 8 Feb 2023 13:59:38 +0100 Subject: [PATCH 22/25] Change colour Changes the to yellow on < 50% and red on < 20% battery percentage. --- apps/widbat/widget.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/widbat/widget.js b/apps/widbat/widget.js index a8a0c5382..7fce16335 100644 --- a/apps/widbat/widget.js +++ b/apps/widbat/widget.js @@ -31,7 +31,11 @@ x+=16; } g.setColor(g.theme.fg).fillRect(x,y+2,x+s-4,y+21).clearRect(x+2,y+4,x+s-6,y+19).fillRect(x+s-3,y+10,x+s,y+14); - g.setColor("#0f0").fillRect(x+4,y+6,x+4+E.getBattery()*(s-12)/100,y+17); + var battery = E.getBattery(); + if(battery < 20) {g.setColor("#f00");} + else if (battery < 50) {g.setColor("#ff0");} + else {g.setColor("#0f0");} + g.fillRect(x+4,y+6,x+4+battery*(s-12)/100,y+17); }}; setWidth(); })() From 26589fa779c0a3a34679c36a214dbb4c14ffa1cb Mon Sep 17 00:00:00 2001 From: KungPhoo Date: Wed, 8 Feb 2023 14:06:46 +0100 Subject: [PATCH 23/25] Update ChangeLog --- apps/widbat/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/widbat/ChangeLog b/apps/widbat/ChangeLog index 5986ecf3f..59c58af32 100644 --- a/apps/widbat/ChangeLog +++ b/apps/widbat/ChangeLog @@ -6,3 +6,4 @@ 0.07: Move CHARGING variable to more readable string 0.08: Ensure battery updates every 60s even if LCD was on at boot and stays on 0.09: Misc speed/memory tweaks +0.10: Color changes due to the battery level From 50a66490909fd7bbc2cb20c57e2e7a5196f81dd3 Mon Sep 17 00:00:00 2001 From: KungPhoo Date: Wed, 8 Feb 2023 14:10:10 +0100 Subject: [PATCH 24/25] Update version --- apps/widbat/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/widbat/metadata.json b/apps/widbat/metadata.json index 993310eb2..5f0d1b7d1 100644 --- a/apps/widbat/metadata.json +++ b/apps/widbat/metadata.json @@ -1,7 +1,7 @@ { "id": "widbat", "name": "Battery Level Widget", - "version": "0.09", + "version": "0.10", "description": "Show the current battery level and charging status in the top right of the clock", "icon": "widget.png", "type": "widget", From 6439062d922cea0fdedcecef3a6480c4ea3ff652 Mon Sep 17 00:00:00 2001 From: Sam Sorensen <825813+sabrsorensen@users.noreply.github.com> Date: Wed, 8 Feb 2023 22:37:39 -0700 Subject: [PATCH 25/25] Addressed undefined weather timestamp --- apps/mtnclock/ChangeLog | 1 + apps/mtnclock/app.js | 2 +- apps/mtnclock/metadata.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/mtnclock/ChangeLog b/apps/mtnclock/ChangeLog index cbf5c7f40..98cd0cc94 100644 --- a/apps/mtnclock/ChangeLog +++ b/apps/mtnclock/ChangeLog @@ -1,2 +1,3 @@ 0.01: New App! 0.02: Get weather from weather.json +0.03: Address unexpected undefined when reading weather.json \ No newline at end of file diff --git a/apps/mtnclock/app.js b/apps/mtnclock/app.js index c6adc7706..a65382dec 100644 --- a/apps/mtnclock/app.js +++ b/apps/mtnclock/app.js @@ -326,7 +326,7 @@ function setWeather() { function readWeather() { var weatherJson = require("Storage").readJSON('weather.json', 1); // save updated weather data if available and it has been an hour since last updated - if (weatherJson !== undefined && (data.time === undefined || (data.time + 3600000) < weatherJson.weather.time)) { + if (weatherJson && weatherJson.weather && weatherJson.weather.time && (data.time === undefined || (data.time + 3600000) < weatherJson.weather.time)) { data = { time: weatherJson.weather.time, temp: weatherJson.weather.temp, diff --git a/apps/mtnclock/metadata.json b/apps/mtnclock/metadata.json index 82a0cccab..2d3d0a02f 100644 --- a/apps/mtnclock/metadata.json +++ b/apps/mtnclock/metadata.json @@ -2,7 +2,7 @@ "id": "mtnclock", "name": "Mountain Pass Clock", "shortName": "Mtn Clock", - "version": "0.02", + "version": "0.03", "description": "A clock that changes scenery based on time and weather.", "readme":"README.md", "icon": "app.png",