From d0088522b843dfb70827b471a1bdb1603f3e5e34 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Fri, 18 Sep 2020 11:51:17 +0100 Subject: [PATCH 01/14] more GPS functionality added --- testing/GPS-comms.js | 77 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 12 deletions(-) diff --git a/testing/GPS-comms.js b/testing/GPS-comms.js index 67df178f8..b9c2c645c 100644 --- a/testing/GPS-comms.js +++ b/testing/GPS-comms.js @@ -1,22 +1,13 @@ -/* This code allows you to communicate with the GPS -receiver in Bangle.js in order to set it up. - -Protocol spec: - -https://cdn.sparkfun.com/assets/0/b/0/f/7/u-blox8-M8_ReceiverDescrProtSpec__UBX-13003221__Public.pdf - -*/ - Bangle.setGPSPower(1) //Bangle.on('GPS',print); -Bangle.on('GPS-raw',function (d) { +/*Bangle.on('GPS-raw',function (d) { if (d[0]=="$") return; if (d.startsWith("\xB5\x62\x05\x01")) print("GPS ACK"); else if (d.startsWith("\xB5\x62\x05\x00")) print("GPS NACK"); // 181,98 sync chars else print("GPS",E.toUint8Array(d).join(",")); -}); +});*/ function writeGPScmd(cmd) { var d = [0xB5,0x62]; // sync chars d = d.concat(cmd); @@ -28,6 +19,23 @@ function writeGPScmd(cmd) { d.push(a,b); Serial1.write(d); } +function readGPScmd(cmd, callback) { + var prefix = String.fromCharCode(0xb5,0x62,cmd[0],cmd[1]); + function handler(d) { + if (!d.startsWith(prefix)) return; + clearInterval(timeout); + var a = E.toUint8Array(d); + // cut off id + length + a = new Uint8Array(a.buffer,6, a.length-8); + callback(a); + } + Bangle.on('GPS-raw',handler); + var timeout = setTimeout(function() { + callback(); + Bangle.removeListener('GPS-raw',handler); + }, 2000); + writeGPScmd(cmd); +} function UBX_CFG_PMS() { // UBX-CFG-PMS - enable power management - Super-E writeGPScmd([0x06,0x86, // msg class + type @@ -64,4 +72,49 @@ function UBX_CFG_MSG(msg,enable) { // Enter super-e low power // UBX_CFG_PMS() // Disable DTM messages (see UBX_CFG_MSG comments): -UBX_CFG_MSG("DTM",false); \ No newline at end of file +//UBX_CFG_MSG("DTM",false); +// UBX-CFG-HNR (0x06 0x5C) - high rate (up to 30hz) + + +// GPS 181,98,6,62,60,0,0,32,32,7,0,8,16,0,1,0,1,1,1,1,3,0,0,0,1,1,2,4,8,0,0,0,1,1,3,8,16,0,1,0,1,1,4,0,8,0,0,0,1,3,5,0,3,0,1,0,1,5,6,8,14,0,0,0,1,1,84,27 +//GPS ACK + +function getUBX_CFG_GNSS() { + // + readGPScmd([0x06,0x3E,0,0], function(a) { + print("CFG_GNSS",a.join(","), a.length); + var info = { + numTrkChHw : a[1], + numTrkChUse : a[2], + configs : [] + }; + for (var i=4;i Date: Mon, 21 Sep 2020 15:24:18 +0100 Subject: [PATCH 02/14] 0.05: Fix `g` corruption issue if .hide gets called twice --- apps.json | 2 +- apps/notifyfs/ChangeLog | 3 ++- apps/notifyfs/notify.js | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps.json b/apps.json index 07aa644f6..726b9d14b 100644 --- a/apps.json +++ b/apps.json @@ -93,7 +93,7 @@ "name": "Fullscreen Notifications", "shortName":"Notifications", "icon": "notify.png", - "version":"0.04", + "version":"0.05", "description": "A handler for displaying notifications that displays them fullscreen. This may not fully restore the screen after on some apps. See `Notifications (default)` for more information about the notifications library.", "tags": "widget", "type": "notify", diff --git a/apps/notifyfs/ChangeLog b/apps/notifyfs/ChangeLog index bf5c73161..b359d314b 100644 --- a/apps/notifyfs/ChangeLog +++ b/apps/notifyfs/ChangeLog @@ -1,4 +1,5 @@ 0.01: New Library! 0.02: Add notification ID option 0.03: Fix custom render callback -0.04: Pass `area{x,y,w,h}` to render callback instead of just `y` \ No newline at end of file +0.04: Pass `area{x,y,w,h}` to render callback instead of just `y` +0.05: Fix `g` corruption issue if .hide gets called twice diff --git a/apps/notifyfs/notify.js b/apps/notifyfs/notify.js index 7d317fa43..74a8d4912 100644 --- a/apps/notifyfs/notify.js +++ b/apps/notifyfs/notify.js @@ -106,8 +106,10 @@ exports.hide = function(options) { options = options||{}; if ("id" in options && options.id!==id) return; id = null; - g=oldg; - oldg = undefined; + if (oldg) { + g=oldg; + oldg = undefined; + } Bangle.removeListener("touch", exports.hide); g.clear(); Bangle.drawWidgets(); From 867fcf6c9ba5997d54b483253d8b7ba88d855ea7 Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Mon, 21 Sep 2020 18:39:25 +0200 Subject: [PATCH 03/14] Add JetBrains IDE Files to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 757619ec5..a454fec09 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ package-lock.json *.js.bak appdates.csv .vscode +.idea/ From de1bfb5ad0160e5c95f5f7f0fc0b5b9c97185f29 Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Mon, 21 Sep 2020 19:38:07 +0200 Subject: [PATCH 04/14] DANE Watchface v0.08: Reduced RAM usage --- apps.json | 2 +- apps/dane/ChangeLog | 3 +- apps/dane/app.js | 113 ++++++++++++++++++++++++-------------------- 3 files changed, 65 insertions(+), 53 deletions(-) diff --git a/apps.json b/apps.json index 726b9d14b..665a73d5b 100644 --- a/apps.json +++ b/apps.json @@ -1421,7 +1421,7 @@ "name": "Digital Assistant, not EDITH", "shortName": "DANE", "icon": "app.png", - "version": "0.07", + "version": "0.08", "description": "A Watchface inspired by Tony Stark's EDITH", "tags": "clock", "type": "clock", diff --git a/apps/dane/ChangeLog b/apps/dane/ChangeLog index 419109ec1..6c70a07dd 100644 --- a/apps/dane/ChangeLog +++ b/apps/dane/ChangeLog @@ -2,4 +2,5 @@ 0.04: Added Icon to watchface 0.05: bugfix 0.06: moved and resized icon -0.07: Added Description \ No newline at end of file +0.07: Added Description +0.08: Removed Image, Reduced RAM usage \ No newline at end of file diff --git a/apps/dane/app.js b/apps/dane/app.js index 5f7a48fbc..a2aa85cf3 100644 --- a/apps/dane/app.js +++ b/apps/dane/app.js @@ -3,7 +3,9 @@ const timeFontSize = 4; const dateFontSize = 3; const smallFontSize = 2; const yOffset = 23; -const xyCenter = g.getWidth()/2; +const width = g.getWidth(); +const height = g.getHeight(); +const xyCenter = width/2; const cornerSize = 14; const cornerOffset = 3; const borderWidth = 1; @@ -12,55 +14,64 @@ const yposDate = 65+yOffset; const mainColor = "#26dafd"; const mainColorDark = "#029dbb"; -const mainColorLight = "#8bebfe"; +// const mainColorLight = "#8bebfe"; -const secondaryColor = "#df9527"; -const secondaryColorDark = "#8b5c15"; +// const secondaryColor = "#df9527"; +// const secondaryColorDark = "#8b5c15"; const secondaryColorLight = "#ecc180"; const success = "#00ff00"; -const successDark = "#000900"; -const successLight = "#060f06"; +// const successDark = "#000900"; +// const successLight = "#060f06"; const alert = "#ff0000"; -const alertDark = "#090000"; +// const alertDark = "#090000"; const alertLight = "#0f0606"; -var img = { - width : 120, height : 120, bpp : 8, - transparent : 254, - buffer : require("heatshrink").decompress(atob("/wA/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AAdCABhN/OFM8ABU2P35zkM4U2hkAABwSBCwJ6/OjZxBgxyPABAZBPgJ6/OqbnBOg8rAAJyNCBEGhk2PX51PmBhHOhEGmwACPRQXFCoL1DOP51HdIh0IhkwnhcDAAoKBm0wDwYdEDwp5/Oo8MKxjQEABwiEkp5/Oxs2OpBTDOgwjOEyEMPHrJFJwxPCmx0QPRM8PIQpJFQjs8JZLEDJa55EUYMGFpMwPG5ICgzsQUrimCkryKnh40OyYxfPAQxIGQMGPGZ2EIZJ2iPCLxyOwRBMO0Z4/IIp2yPH4/Dhg9JHwJ2nPAg5Mgx3sFgMwgEqHhMMO1B4EeBQ7EO1U8HZSzBni0rHh0AmyzqHPB4FmDwLgC1BHGsMB4J3uWxY/Ed2ivBO1h4DmxAOG00MV2jwYmBBld354DmB3LeEo0Bgzu9eCMGIcYzOm1DoZ3wPAUMeF4yNg8Bn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8O5IyBmFCO+lCoRELgwOBGUcMGRUAGUZDSO5TuleBozDPGQzBmxDKd0jwPmB31IRLunGocGVhh4wGIM8dxUMIE4nBmw2IVoZ3ymDuyG4cMG5TwwdxYIBmw+qHBjwvU4S2Khg9rWJrwuFoM2HhMGHfSyCWdlCOxU8O9p4LA4M2PFQqCgx2IHIZ2sPBy1CH8x2/PGwlBnkMO3p4zEYU8dpMGO2q8EIoJGFAwMwPEIhCmx2HGAMGVMZIYmBABg54GeQQtiOw7sCO25KEnkMIYJMEYAJKdFQQpHAAMMUgR25PAlCmx5GAoR5BFLM8gx1IUIh27PAp5BJYRUCKIgoXEYZ0EToZ2/PA7MBeYZ5DmBPWoTtBOos2ngxFO/5FGPQUwPAcMO64cEOhB2xnh3XPITPDKCocBDYZ1JPCEwO78MO7JbEZKqTGABhBLnk2O78Amw1KJBp3bmwaCHIwASDoJ3ggw+aO4c8O+M8hgbBhg2UIB0wIKx3DDQI2YLYLZCACEMZIIADO8YAEhgAEGgoAHlZ3bDgQAWlYaCO8QmDH7B3WmAcCGyoXCO9AAZgEMICdCoUMGrh3DPDp3iICR3/d+42BO8J2cO/53/IDU8GykGO/88O+g1ggB2dIIgAdO64AeO/cwmwACGyoZDADU8VqhBPEoIADoQATG7IuUGsBCjHswA/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A1"); +// } + +// function makeImg() { +// return { +// width : 120, height : 120, bpp : 8, +// transparent : 254, +// buffer : require("heatshrink").decompress(getImg()) +// } +// } + + function drawTopLeftCorner(x,y) { g.setColor(mainColor); - var x1 = x-cornerOffset; - var y1 = y-cornerOffset; + const x1 = x - cornerOffset; + const y1 = y - cornerOffset; g.fillRect(x1,y1,x1+cornerSize,y1+cornerSize); g.setColor("#000000"); g.fillRect(x,y,x+cornerSize-cornerOffset,y+cornerSize-cornerOffset); } function drawTopRightCorner(x,y) { g.setColor(mainColor); - var x1 = x+cornerOffset; - var y1 = y-cornerOffset; + const x1 = x + cornerOffset; + const y1 = y - cornerOffset; g.fillRect(x1,y1,x1-cornerSize,y1+cornerSize); g.setColor("#000000"); g.fillRect(x,y,x-cornerSize-cornerOffset,y+cornerSize-cornerOffset); } function drawBottomLeftCorner(x,y) { g.setColor(mainColor); - var x1 = x-cornerOffset; - var y1 = y+cornerOffset; + const x1 = x - cornerOffset; + const y1 = y + cornerOffset; g.fillRect(x1,y1,x1+cornerSize,y1-cornerSize); g.setColor("#000000"); g.fillRect(x,y,x+cornerSize-cornerOffset,y-cornerSize+cornerOffset); } function drawBottomRightCorner(x,y) { g.setColor(mainColor); - var x1 = x+cornerOffset; - var y1 = y+cornerOffset; + const x1 = x + cornerOffset; + const y1 = y + cornerOffset; g.fillRect(x1,y1,x1-cornerSize,y1-cornerSize); g.setColor("#000000"); g.fillRect(x,y,x-cornerSize+cornerOffset,y-cornerSize+cornerOffset); @@ -85,31 +96,28 @@ function drawTopFrame(x1,y1,x2,y2) { g.setColor("#000000"); g.fillRect(x1+borderWidth,y1+borderWidth,x2-borderWidth,y2-borderWidth); } -function drawBottomFrame(x1,y1,x2,y2) { - drawTopLeftCorner(x1,y1); - drawTopRightCorner(x2,y1); - g.setColor(mainColorDark); - g.drawRect(x1,y1,x2,y2); - g.setColor("#000000"); - g.fillRect(x1+borderWidth,y1+borderWidth,x2-borderWidth,y2-borderWidth); -} +// function drawBottomFrame(x1,y1,x2,y2) { +// drawTopLeftCorner(x1,y1); +// drawTopRightCorner(x2,y1); +// g.setColor(mainColorDark); +// g.drawRect(x1,y1,x2,y2); +// g.setColor("#000000"); +// g.fillRect(x1+borderWidth,y1+borderWidth,x2-borderWidth,y2-borderWidth); +// } -function getUTCTime(d) { - return d.toUTCString().split(' ')[4].split(':').map(function(d){return Number(d);}); -} +// function getUTCTime(d) { +// return d.toUTCString().split(' ')[4].split(':').map(function(d){return Number(d);}); +// } +function drawTimeText(d) { + const da = d.toString().split(" "); + // var dutc = getUTCTime(d); -function drawTimeText() { - g.setFontAlign(0, 0); - var d = new Date(); - var da = d.toString().split(" "); - var dutc = getUTCTime(d); - - var time = da[4].split(":"); - var hours = time[0], + const time = da[4].split(":"); + const hours = time[0], minutes = time[1], seconds = time[2]; g.setColor(mainColor); @@ -117,9 +125,7 @@ function drawTimeText() { g.drawString(`${hours}:${minutes}:${seconds}`, xyCenter, yposTime, true); g.setFont(font, smallFontSize); } -function drawDateText() { - g.setFontAlign(0, 0); - var d = new Date(); +function drawDateText(d) { g.setFont(font, dateFontSize); g.drawString(`${d.getDate()}.${d.getMonth()+1}.${d.getFullYear()}`, xyCenter, yposDate, true); } @@ -128,36 +134,41 @@ function drawDateText() { function drawClock() { // main frame - drawFrame(3,10+yOffset,g.getWidth()-3,g.getHeight()-3); + drawFrame(3,10+yOffset,width-3,height-3); // time frame drawTopFrame(20,10+yOffset,220,46+yOffset); // date frame drawTopFrame(28,46+yOffset,212,46+yOffset+35); - // texts - drawTimeText(); - drawDateText(); - g.drawImage(img,g.getWidth()/2-(img.width/2),g.getHeight()/2); + updateClock(); + + // const img = makeImg(); + // g.drawImage(img,width/2-(img.width/2),height/2); } function updateClock() { - drawTimeText(); - drawDateText(); + g.setFontAlign(0, 0); + const date = new Date(); + drawTimeText(date); + drawDateText(date); } Bangle.on('lcdPower', function(on) { if (on) drawClock(); + }); + + g.clear(); Bangle.loadWidgets(); Bangle.drawWidgets(); - drawClock(); + setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"}); // refesh every 100 milliseconds -setInterval(updateClock, 100); +setInterval(updateClock, 500); From 4bd7f5bb3d48a7f26b6c6478512fe812e049ba68 Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Mon, 21 Sep 2020 22:25:33 +0200 Subject: [PATCH 05/14] DANE Watchface v0.09: Added Unix Time display --- apps.json | 2 +- apps/dane/ChangeLog | 3 ++- apps/dane/app.js | 16 ++++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps.json b/apps.json index 665a73d5b..3dcb0a8f7 100644 --- a/apps.json +++ b/apps.json @@ -1421,7 +1421,7 @@ "name": "Digital Assistant, not EDITH", "shortName": "DANE", "icon": "app.png", - "version": "0.08", + "version": "0.09", "description": "A Watchface inspired by Tony Stark's EDITH", "tags": "clock", "type": "clock", diff --git a/apps/dane/ChangeLog b/apps/dane/ChangeLog index 6c70a07dd..421123a1b 100644 --- a/apps/dane/ChangeLog +++ b/apps/dane/ChangeLog @@ -3,4 +3,5 @@ 0.05: bugfix 0.06: moved and resized icon 0.07: Added Description -0.08: Removed Image, Reduced RAM usage \ No newline at end of file +0.08: Removed Image, Reduced RAM usage +0.09: Added Unix Time \ No newline at end of file diff --git a/apps/dane/app.js b/apps/dane/app.js index a2aa85cf3..c3d51cd14 100644 --- a/apps/dane/app.js +++ b/apps/dane/app.js @@ -1,5 +1,6 @@ const font = "6x8"; const timeFontSize = 4; +const unixTimeFontSize = 2; const dateFontSize = 3; const smallFontSize = 2; const yOffset = 23; @@ -10,13 +11,13 @@ const cornerSize = 14; const cornerOffset = 3; const borderWidth = 1; const yposTime = 27+yOffset; -const yposDate = 65+yOffset; +const yposDate = 65+yOffset+12; const mainColor = "#26dafd"; const mainColorDark = "#029dbb"; // const mainColorLight = "#8bebfe"; -// const secondaryColor = "#df9527"; +const secondaryColor = "#df9527"; // const secondaryColorDark = "#8b5c15"; const secondaryColorLight = "#ecc180"; @@ -123,22 +124,29 @@ function drawTimeText(d) { g.setColor(mainColor); g.setFont(font, timeFontSize); g.drawString(`${hours}:${minutes}:${seconds}`, xyCenter, yposTime, true); + const unix = Math.round(d.getTime()); + + g.setFont(font, unixTimeFontSize); + g.setColor(secondaryColor); + g.drawString(`${unix}`, xyCenter, yposTime +22, true); g.setFont(font, smallFontSize); } function drawDateText(d) { + g.setColor(mainColor); g.setFont(font, dateFontSize); g.drawString(`${d.getDate()}.${d.getMonth()+1}.${d.getFullYear()}`, xyCenter, yposDate, true); } + function drawClock() { // main frame drawFrame(3,10+yOffset,width-3,height-3); // time frame - drawTopFrame(20,10+yOffset,220,46+yOffset); + drawTopFrame(20,10+yOffset,220,46+12+yOffset); // date frame - drawTopFrame(28,46+yOffset,212,46+yOffset+35); + drawTopFrame(28,46+12+yOffset,212,46+12+yOffset+35); updateClock(); From 01dc95520687d657732ad0d841f7b27ad85a75bc Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Mon, 21 Sep 2020 23:21:41 +0200 Subject: [PATCH 06/14] DANE Watchface v0.10: Added Counter, Added Battery Display --- apps.json | 2 +- apps/dane/ChangeLog | 3 ++- apps/dane/app.js | 66 ++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 63 insertions(+), 8 deletions(-) diff --git a/apps.json b/apps.json index 3dcb0a8f7..4c9826a0f 100644 --- a/apps.json +++ b/apps.json @@ -1421,7 +1421,7 @@ "name": "Digital Assistant, not EDITH", "shortName": "DANE", "icon": "app.png", - "version": "0.09", + "version": "0.10", "description": "A Watchface inspired by Tony Stark's EDITH", "tags": "clock", "type": "clock", diff --git a/apps/dane/ChangeLog b/apps/dane/ChangeLog index 421123a1b..0ba1d848b 100644 --- a/apps/dane/ChangeLog +++ b/apps/dane/ChangeLog @@ -4,4 +4,5 @@ 0.06: moved and resized icon 0.07: Added Description 0.08: Removed Image, Reduced RAM usage -0.09: Added Unix Time \ No newline at end of file +0.09: Added Unix Time +0.10: Added Counter, Added Battery Display \ No newline at end of file diff --git a/apps/dane/app.js b/apps/dane/app.js index c3d51cd14..81e1bf5fa 100644 --- a/apps/dane/app.js +++ b/apps/dane/app.js @@ -6,20 +6,21 @@ const smallFontSize = 2; const yOffset = 23; const width = g.getWidth(); const height = g.getHeight(); -const xyCenter = width/2; +const xyCenter = width/2+4; const cornerSize = 14; const cornerOffset = 3; const borderWidth = 1; const yposTime = 27+yOffset; const yposDate = 65+yOffset+12; +const yposCounter = 58+yOffset+35+40; const mainColor = "#26dafd"; const mainColorDark = "#029dbb"; // const mainColorLight = "#8bebfe"; const secondaryColor = "#df9527"; -// const secondaryColorDark = "#8b5c15"; -const secondaryColorLight = "#ecc180"; +const secondaryColorDark = "#8b5c15"; +// const secondaryColorLight = "#ecc180"; const success = "#00ff00"; // const successDark = "#000900"; @@ -27,7 +28,9 @@ const success = "#00ff00"; const alert = "#ff0000"; // const alertDark = "#090000"; -const alertLight = "#0f0606"; +// const alertLight = "#0f0606"; + +let count = 100; // function getImg() { @@ -97,6 +100,13 @@ function drawTopFrame(x1,y1,x2,y2) { g.setColor("#000000"); g.fillRect(x1+borderWidth,y1+borderWidth,x2-borderWidth,y2-borderWidth); } + +function drawFrameNoCorners(x1,y1,x2,y2) { + g.setColor(mainColorDark); + g.drawRect(x1,y1,x2,y2); + g.setColor("#000000"); + g.fillRect(x1+borderWidth,y1+borderWidth,x2-borderWidth,y2-borderWidth); +} // function drawBottomFrame(x1,y1,x2,y2) { // drawTopLeftCorner(x1,y1); // drawTopRightCorner(x2,y1); @@ -137,6 +147,32 @@ function drawDateText(d) { g.drawString(`${d.getDate()}.${d.getMonth()+1}.${d.getFullYear()}`, xyCenter, yposDate, true); } +function drawCounterText() { + if(count>999) count = 999; + if(count<0) count = 0; + g.setColor("#000000"); + g.fillRect(37,58+yOffset+36,203,58+80+yOffset+34); + g.setFontAlign(0, 0); + g.setColor(alert); + g.setFont(font, 8); + g.drawString(`${count}`, xyCenter, yposCounter, true); + + +} + +function levelColor(l) { + // no icon -> brightest green to indicate charging, even when showing percentage + if (Bangle.isCharging()) return success; + if (l >= 50) return success; + if (l >= 15) return secondaryColorDark; + return alert; +} + +function drawBattery() { + const l = E.getBattery(), c = levelColor(l); + const xl = 45+l*(194-46)/100; + g.setColor(c).fillRect(46,58+80+yOffset+37,xl, height-5); +} @@ -144,9 +180,16 @@ function drawClock() { // main frame drawFrame(3,10+yOffset,width-3,height-3); // time frame - drawTopFrame(20,10+yOffset,220,46+12+yOffset); + drawTopFrame(20,10+yOffset,220,58+yOffset); // date frame - drawTopFrame(28,46+12+yOffset,212,46+12+yOffset+35); + drawTopFrame(28,58+yOffset,212,58+yOffset+35); + + // counter frame + drawTopFrame(36,58+yOffset+35,204,58+80+yOffset+35); + + // battery frame + drawFrameNoCorners(44,58+80+yOffset+35,196, height-3); + updateClock(); @@ -158,6 +201,8 @@ function updateClock() { const date = new Date(); drawTimeText(date); drawDateText(date); + drawCounterText(); + drawBattery(); } @@ -178,5 +223,14 @@ drawClock(); setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"}); +setWatch(function() { + count+=1; + drawCounterText(); +}, BTN1, {repeat:true,edge:"falling"}); +setWatch(function() { + count--; + drawCounterText(); +}, BTN3, {repeat:true,edge:"falling"}); + // refesh every 100 milliseconds setInterval(updateClock, 500); From a0b2aa30d217ecbcda4ef4012ca9d9ad5a3f9395 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 22 Sep 2020 09:07:27 +0100 Subject: [PATCH 07/14] Adjust position of notification src text and notifications without title --- apps.json | 4 ++-- apps/notify/ChangeLog | 3 ++- apps/notify/notify.js | 4 ++-- apps/notifyfs/ChangeLog | 1 + apps/notifyfs/notify.js | 8 ++++---- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/apps.json b/apps.json index 726b9d14b..6a9a73d30 100644 --- a/apps.json +++ b/apps.json @@ -80,7 +80,7 @@ "name": "Notifications (default)", "shortName":"Notifications", "icon": "notify.png", - "version":"0.03", + "version":"0.05", "description": "A handler for displaying notifications that displays them in a bar at the top of the screen", "tags": "widget", "type": "notify", @@ -93,7 +93,7 @@ "name": "Fullscreen Notifications", "shortName":"Notifications", "icon": "notify.png", - "version":"0.05", + "version":"0.06", "description": "A handler for displaying notifications that displays them fullscreen. This may not fully restore the screen after on some apps. See `Notifications (default)` for more information about the notifications library.", "tags": "widget", "type": "notify", diff --git a/apps/notify/ChangeLog b/apps/notify/ChangeLog index cb974e12d..558d62b31 100644 --- a/apps/notify/ChangeLog +++ b/apps/notify/ChangeLog @@ -1,3 +1,4 @@ 0.01: New Library! 0.02: Add notification ID option -0.03: Pass `area{x,y,w,h}` to render callback instead of just `y` \ No newline at end of file +0.03: Pass `area{x,y,w,h}` to render callback instead of just `y` +0.04: Adjust position of notification src text diff --git a/apps/notify/notify.js b/apps/notify/notify.js index d8168e048..6f5261de1 100644 --- a/apps/notify/notify.js +++ b/apps/notify/notify.js @@ -94,8 +94,8 @@ exports.show = function(options) { g.setColor(-1).setFontAlign(-1, -1, 0).setFont("6x8", 2); g.drawString(title.trim().substring(0, 13), x+25,y+3); if (options.title && options.src) { - g.setFont("6x8", 1); - g.drawString(options.src.substring(0, 10), x+215,y+5); + g.setFont("6x8", 1).setFontAlign(1, 1, 0); + g.drawString(options.src.substring(0, 10), g.getWidth()-23,y+18); } y += 20;h -= 20; } diff --git a/apps/notifyfs/ChangeLog b/apps/notifyfs/ChangeLog index b359d314b..16bc0ebb3 100644 --- a/apps/notifyfs/ChangeLog +++ b/apps/notifyfs/ChangeLog @@ -3,3 +3,4 @@ 0.03: Fix custom render callback 0.04: Pass `area{x,y,w,h}` to render callback instead of just `y` 0.05: Fix `g` corruption issue if .hide gets called twice +0.06: Adjust position of notification src text and notifications without title diff --git a/apps/notifyfs/notify.js b/apps/notifyfs/notify.js index 74a8d4912..2c622f624 100644 --- a/apps/notifyfs/notify.js +++ b/apps/notifyfs/notify.js @@ -49,14 +49,13 @@ exports.show = function(options) { if (size>120) {size=120} Bangle.setLCDMode("direct"); let x = 0, - y = 0, + y = 40, w = 240, - h = 240; + h = size; // clear screen g.clear(1); // top bar if (options.title||options.src) { - y=40;h=size; const title = options.title || options.src g.setColor(0x39C7).fillRect(x, y, x+w-1, y+30); g.setColor(-1).setFontAlign(-1, -1, 0).setFont("6x8", 3); @@ -64,7 +63,8 @@ exports.show = function(options) { if (options.title && options.src) { g.setColor(-1).setFontAlign(1, 1, 0).setFont("6x8", 2); // above drawing area, but we are fullscreen - g.drawString(options.src.substring(0, 10), x+235, y-32); + print(options.src.substring(0, 10), w-23, y-4); + g.drawString(options.src.substring(0, 10), w-16, y-4); } y += 30;h -= 30; } From 8623bc7f968fdd671cd94e16ccffdfcc9c0e355b Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 22 Sep 2020 09:07:53 +0100 Subject: [PATCH 08/14] more GPS config --- testing/GPS-comms.js | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/testing/GPS-comms.js b/testing/GPS-comms.js index b9c2c645c..38d4c9dde 100644 --- a/testing/GPS-comms.js +++ b/testing/GPS-comms.js @@ -1,13 +1,13 @@ Bangle.setGPSPower(1) //Bangle.on('GPS',print); -/*Bangle.on('GPS-raw',function (d) { +Bangle.on('GPS-raw',function (d) { if (d[0]=="$") return; if (d.startsWith("\xB5\x62\x05\x01")) print("GPS ACK"); else if (d.startsWith("\xB5\x62\x05\x00")) print("GPS NACK"); // 181,98 sync chars else print("GPS",E.toUint8Array(d).join(",")); -});*/ +}); function writeGPScmd(cmd) { var d = [0xB5,0x62]; // sync chars d = d.concat(cmd); @@ -91,9 +91,9 @@ function getUBX_CFG_GNSS() { for (var i=4;i Date: Tue, 22 Sep 2020 15:33:55 +0100 Subject: [PATCH 09/14] tweak for making firmware --- bin/firmwaremaker.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/firmwaremaker.js b/bin/firmwaremaker.js index ce885c394..4e22dd168 100755 --- a/bin/firmwaremaker.js +++ b/bin/firmwaremaker.js @@ -19,6 +19,13 @@ var APPS = [ // IDs of apps to install var MINIFY = true; var fs = require("fs"); +global.Const = { + /* Are we only putting a single app on a device? If so + apps should all be saved as .bootcde and we write info + about the current app into app.info */ + SINGLE_APP_ONLY : false, +}; + var AppInfo = require(ROOTDIR+"/core/js/appinfo.js"); var appjson = JSON.parse(fs.readFileSync(APPJSON).toString()); var appfiles = []; From cdf5748fa641d88738ec110d50c8d60dc7fb7c1f Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 23 Sep 2020 08:44:42 +0100 Subject: [PATCH 10/14] tweak based on sanity check --- apps/notify/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/notify/ChangeLog b/apps/notify/ChangeLog index 558d62b31..a1e8e4418 100644 --- a/apps/notify/ChangeLog +++ b/apps/notify/ChangeLog @@ -1,4 +1,4 @@ 0.01: New Library! 0.02: Add notification ID option 0.03: Pass `area{x,y,w,h}` to render callback instead of just `y` -0.04: Adjust position of notification src text +0.05: Adjust position of notification src text From 23cb4ea18ed9deab5c502fe7fdbe9b1a02646fbc Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 23 Sep 2020 08:44:58 +0100 Subject: [PATCH 11/14] Added vibrate clock --- apps.json | 13 ++++ apps/vibrclock/ChangeLog | 1 + apps/vibrclock/app-icon.js | 1 + apps/vibrclock/app.js | 125 +++++++++++++++++++++++++++++++++++++ apps/vibrclock/app.png | Bin 0 -> 2850 bytes 5 files changed, 140 insertions(+) create mode 100644 apps/vibrclock/ChangeLog create mode 100644 apps/vibrclock/app-icon.js create mode 100644 apps/vibrclock/app.js create mode 100644 apps/vibrclock/app.png diff --git a/apps.json b/apps.json index 104609ae6..7f97b6f84 100644 --- a/apps.json +++ b/apps.json @@ -692,6 +692,19 @@ {"name":"sclock.img","url":"clock-simple-icon.js","evaluate":true} ] }, + { "id": "vibrclock", + "name": "Vibrate Clock", + "icon": "app.png", + "version":"0.01", + "description": "When BTN1 is pressed, vibrate out the time as a series of buzzes, one digit at a time. Hours, then Minutes. Zero is signified by one long buzz. Otherwise a simple digital clock.", + "tags": "clock", + "type":"clock", + "allow_emulator":true, + "storage": [ + {"name":"vibrclock.app.js","url":"app.js"}, + {"name":"vibrclock.img","url":"app-icon.js","evaluate":true} + ] + }, { "id": "svclock", "name": "Simple V-Clock", "icon": "vclock-simple.png", diff --git a/apps/vibrclock/ChangeLog b/apps/vibrclock/ChangeLog new file mode 100644 index 000000000..b4d1ae593 --- /dev/null +++ b/apps/vibrclock/ChangeLog @@ -0,0 +1 @@ +0.01: First commit diff --git a/apps/vibrclock/app-icon.js b/apps/vibrclock/app-icon.js new file mode 100644 index 000000000..c41aa0f9c --- /dev/null +++ b/apps/vibrclock/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwxH+AH4A/AH4ATlgAGFlgylEQUyq1WwOB1msAYIHBmQxeDwQrB1nXABA0BqwxaP4eBFhIAFwIwYLgYtPAAZiWCgMrLhS7BMRUrGCQuN1gvBYxQwCF6S6LF5rEDFyC7MF5zDDF50rD5gvP1iRORpovRSJ6NNF6SRCLzQvSMBksmQdOF6OsmQvLRxwvSSBZqBF5+BmUyUJwvCGBC+QwMrCQMrCZ4vZxErLoJhBGAOsAAgvTwR6OH4QfBmTEBAAYwGwQv7R5uCR8DbOrrvSOoIuHF4VWDZ2CQwOICR3XFxAwCF54ATF5cyUo4vmYB4AM63P53O5/Q6wvKSDfW52j44AC0YFBMEnPFgYAGGBcrYKvWFAnP64wPMAKRV5wuE63W6HIMB6RU6y7E5HO6BfF0aRMGCS9D54EBF4I3BTIhgMGCSOCXYIwBSAICC6ySCF5QwCYYL0PF4fW53OAYjzDF5ZiTR4g0BR4OiR4LxDF5piEwJjLW4QACLgLvBFobvMGJEyqwzBwOCwQ3E6wvFXYLtEF6QxEAAtWBoYmEeYReERx4yNBYowFAAouWABouuAATDE0a7TAH4ASA")) diff --git a/apps/vibrclock/app.js b/apps/vibrclock/app.js new file mode 100644 index 000000000..817a69815 --- /dev/null +++ b/apps/vibrclock/app.js @@ -0,0 +1,125 @@ +/* jshint esversion: 6 */ +const timeFontSize = 6; +const dateFontSize = 3; +const gmtFontSize = 2; +const font = "6x8"; + +const xyCenter = g.getWidth() / 2; +const yposTime = 75; +const yposDate = 130; +const yposYear = 175; + +// Check settings for what type our clock should be +var is12Hour = (require("Storage").readJSON("setting.json",1)||{})["12hour"]; +var d, da, time, hours, minutes, meridian = ""; + +function drawSimpleClock() { + // get date + var d = new Date(); + var da = d.toString().split(" "); + + g.reset(); // default draw styles + // drawSting centered + g.setFontAlign(0, 0); + + // draw time + var time = da[4].substr(0, 5).split(":"); + var hours = time[0], + minutes = time[1]; + var meridian = ""; + if (is12Hour) { + hours = parseInt(hours,10); + meridian = "AM"; + if (hours == 0) { + hours = 12; + meridian = "AM"; + } else if (hours >= 12) { + meridian = "PM"; + if (hours>12) hours -= 12; + } + hours = (" "+hours).substr(-2); + } + + g.setFont(font, timeFontSize); + g.drawString(`${hours}:${minutes}`, xyCenter, yposTime, true); + g.setFont(font, gmtFontSize); + g.drawString(meridian, xyCenter + 102, yposTime + 10, true); + + // draw Day, name of month, Date + var date = [da[0], da[1], da[2]].join(" "); + g.setFont(font, dateFontSize); + + g.drawString(date, xyCenter, yposDate, true); + + // draw year + g.setFont(font, dateFontSize); + g.drawString(d.getFullYear(), xyCenter, yposYear, true); + + // draw gmt + var gmt = da[5]; + g.setFont(font, gmtFontSize); + g.drawString(gmt, xyCenter, yposGMT, true); +} + +// handle switch display on by pressing BTN1 +Bangle.on('lcdPower', function(on) { + if (on) drawSimpleClock(); +}); + +// clean app screen +g.clear(); +Bangle.loadWidgets(); +Bangle.drawWidgets(); + +// refesh every 15 sec +setInterval(drawSimpleClock, 15E3); + +// draw now +drawSimpleClock(); + +// vibrate 0..9 +function vibrateDigit(num) { + if (num==0) return Bangle.buzz(500); + return new Promise(function f(resolve){ + if (num--<=0) return resolve(); + Bangle.buzz(100).then(()=>{ + setTimeout(()=>f(resolve), 200); + }); + }); +} +// vibrate multiple digits (num must be a string) +function vibrateNumber(num) { + return new Promise(function f(resolve){ + if (!num.length) return resolve(); + var digit = num[0]; + num = num.substr(1); + vibrateDigit(digit).then(()=>{ + setTimeout(()=>f(resolve),500); + }); + }); +} + +var vibrateBusy; +function vibrateTime() { + if (vibrateBusy) return; + vibrateBusy = true; + + var d = new Date(); + var hours = d.getHours(), minutes = d.getMinutes(); + if (is12Hour) { + if (hours == 0) hours = 12; + else if (hours>12) hours -= 12; + } + + vibrateNumber(hours.toString()). + then(() => new Promise(resolve=>setTimeout(resolve,500))). + then(() => vibrateNumber(minutes.toString())). + then(() => vibrateBusy=false); +} + + + +// Show launcher when middle button pressed +setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"}); +// when BTN1 pressed, vibrate +setWatch(vibrateTime, BTN1, {repeat:true,edge:"rising"}); diff --git a/apps/vibrclock/app.png b/apps/vibrclock/app.png new file mode 100644 index 0000000000000000000000000000000000000000..79ff0b9922dd1c5310ea7d737df3079bb231f27d GIT binary patch literal 2850 zcmV+-3*GdIP)W_Z>ckbr5 zf4|@U?%(j;@Q3^%mn7m+6-<~ggYDZtZ1rtiN}5fYScQ}dfE2Witupad&dzI6Nx)C6o9(=dX672 zr}XHzoT#d%u~9?QG=vZ+LewJV!(PK!vv2z*EoE*7o7b%PWgQrvl0rXQ94j^~BPls` z6!0vNsOvhB5mzwcrbLDf9m2r=eF+T>X;)W${b>#zF5zJQf7$o1&nU0>3A@b(@NX%^ zW4pGl-#aU5K9yZO>{-A5mpy@`$*D__ERs?>yk4EV({E?$2#bMIU%sy?F>p7$fOBl`KsU$Cr_SIg%G3S;s;v$_a3mX^qXRH zR9YIxii_K{QEAVCezrIOycW3xc&xEeW8B!0y!_%*L`6ol8=1-zRowl+Bi!@gBUGNK zYIkj9#1$-iVF}3-$DwH&2)Wp+@Fc($RiVM1z|>h8tXcm?6Kr5{qo#51!aKNk;rwRI zwkzKsKhE~t-57?!@EfnEdw92Y*ITVt5^orW!{Ol5&kta=syD~Q50qPWzQ1?soODWx z@-OZLve&I3X;Rv#0Opx;%LL}lo{6F;m#?Y{!JM>dOiQ^1DJ2N`Xi{?Oi0pr6T^xia zrQXh{aZ?=#`HYm((X&S^_usSNvKrrFkfLzk!uj;ulnTr<@65{&R`Wu(aMdsp1@Or%f!&Qf4_O|u!b=&~}A$dvHb<*#c z%at+Fzj~8)WlS{bcg#cAb%f-V4nb&a%G@*C19$iEZp=tY{>?hg=~I*G-aQ;C&9J28 z)cczoz&0J&wRugT$Z)@uCN~XF#O)6K%^YyML%Df)V$+3&2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gohSA&awZMUD_S+H8!P6p&$(}W@8mbeHo^95>r2oG<2j^gQ?e{eYXSE9g8&eGwYZA zg6#B>BS!!z{ifLbwzN1eE`FdCf*Wh=>eO`~WaIbyiR;w^yWMutcSEoF8ejS62#W(> zRS{~pei)t;G#0HwN)v16tEt`p1ZHCmT}C`hRnDFGYmOik6~F_$zBIeC($bO5Mx~{3 zLqsB5cD}ziF24UKLWn+AtM#g{3W~_xy^r#WN_;*)E>|Zyb#iv>1dw=2H=!sh2=JEe z!>B)wEpix&-HqBc9=-A_EbbT@ir&SjJ%&)5XnI2^Rd(rr@`cSO{1^AcG;0Cb>sB%{ zX^KO2IA#mUD-ttIni9L+j??KN%pFQxub#xlMB@t3ksgnSF(Yp}li{oNoh)5_V&k+q zimejM)P~ zBoG1w9{J4XF%T)CbC$a{DiRBIb+b(kc^4SDEzcMD}ku=!b^8xY|7jgO0rqTB&XUGDXl^@S1HUB zmIlvgPrQ72*Q)^hn3X_udLiFuUE{E!ERo1X=gh&a6N4WqZ;r|+`mB6K0#O--{Guli ztW;zTA~L;zAF>9`_6y}Pn>3 Date: Wed, 23 Sep 2020 08:51:24 +0100 Subject: [PATCH 12/14] fix regression where apps weren't scanned for modules --- apps/vibrclock/app.js | 114 ++++++++++++++++-------------------------- core | 2 +- 2 files changed, 44 insertions(+), 72 deletions(-) diff --git a/apps/vibrclock/app.js b/apps/vibrclock/app.js index 817a69815..188470cdc 100644 --- a/apps/vibrclock/app.js +++ b/apps/vibrclock/app.js @@ -1,82 +1,58 @@ -/* jshint esversion: 6 */ -const timeFontSize = 6; -const dateFontSize = 3; -const gmtFontSize = 2; -const font = "6x8"; - -const xyCenter = g.getWidth() / 2; -const yposTime = 75; -const yposDate = 130; -const yposYear = 175; - +// Simple clock from https://www.espruino.com/Bangle.js+Clock +// Load fonts +require("Font7x11Numeric7Seg").add(Graphics); // Check settings for what type our clock should be var is12Hour = (require("Storage").readJSON("setting.json",1)||{})["12hour"]; -var d, da, time, hours, minutes, meridian = ""; +// position on screen +const X = 160, Y = 140; -function drawSimpleClock() { - // get date +function draw() { + // work out how to display the current time var d = new Date(); - var da = d.toString().split(" "); - - g.reset(); // default draw styles - // drawSting centered - g.setFontAlign(0, 0); - - // draw time - var time = da[4].substr(0, 5).split(":"); - var hours = time[0], - minutes = time[1]; - var meridian = ""; + var h = d.getHours(), m = d.getMinutes(); if (is12Hour) { - hours = parseInt(hours,10); - meridian = "AM"; - if (hours == 0) { - hours = 12; - meridian = "AM"; - } else if (hours >= 12) { - meridian = "PM"; - if (hours>12) hours -= 12; - } - hours = (" "+hours).substr(-2); + if (h == 0) h = 12; + else if (h>12) h -= 12; } - - g.setFont(font, timeFontSize); - g.drawString(`${hours}:${minutes}`, xyCenter, yposTime, true); - g.setFont(font, gmtFontSize); - g.drawString(meridian, xyCenter + 102, yposTime + 10, true); - - // draw Day, name of month, Date - var date = [da[0], da[1], da[2]].join(" "); - g.setFont(font, dateFontSize); - - g.drawString(date, xyCenter, yposDate, true); - - // draw year - g.setFont(font, dateFontSize); - g.drawString(d.getFullYear(), xyCenter, yposYear, true); - - // draw gmt - var gmt = da[5]; - g.setFont(font, gmtFontSize); - g.drawString(gmt, xyCenter, yposGMT, true); + var time = (" "+h).substr(-2) + ":" + ("0"+m).substr(-2); + // Reset the state of the graphics library + g.reset(); + // draw the current time (4x size 7 segment) + g.setFont("7x11Numeric7Seg",4); + g.setFontAlign(1,1); // align right bottom + g.drawString(time, X, Y, true /*clear background*/); + // draw the seconds (2x size 7 segment) + g.setFont("7x11Numeric7Seg",2); + g.drawString(("0"+d.getSeconds()).substr(-2), X+30, Y, true /*clear background*/); + // draw the date, in a normal font + g.setFont("6x8"); + g.setFontAlign(0,1); // align center bottom + // pad the date - this clears the background if the date were to change length + var dateStr = " "+require("locale").date(d)+" "; + g.drawString(dateStr, g.getWidth()/2, Y+15, true /*clear background*/); } -// handle switch display on by pressing BTN1 -Bangle.on('lcdPower', function(on) { - if (on) drawSimpleClock(); -}); - -// clean app screen +// Clear the screen once, at startup g.clear(); +// draw immediately at first +draw(); +var secondInterval = setInterval(draw, 1000); +// Stop updates when LCD is off, restart when on +Bangle.on('lcdPower',on=>{ + if (secondInterval) clearInterval(secondInterval); + secondInterval = undefined; + if (on) { + secondInterval = setInterval(draw, 1000); + draw(); // draw immediately + } +}); +// Load widgets Bangle.loadWidgets(); Bangle.drawWidgets(); +// Show launcher when middle button pressed +setWatch(Bangle.showLauncher, BTN2, { repeat: false, edge: "falling" }); -// refesh every 15 sec -setInterval(drawSimpleClock, 15E3); - -// draw now -drawSimpleClock(); - +// ====================================== Vibration // vibrate 0..9 function vibrateDigit(num) { if (num==0) return Bangle.buzz(500); @@ -117,9 +93,5 @@ function vibrateTime() { then(() => vibrateBusy=false); } - - -// Show launcher when middle button pressed -setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"}); // when BTN1 pressed, vibrate setWatch(vibrateTime, BTN1, {repeat:true,edge:"rising"}); diff --git a/core b/core index 9708e1a15..c99967381 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 9708e1a15ee20734a24f6f2913078aa8bba625dc +Subproject commit c99967381280f483877c3f11ae7b0d4dc8c53e0e From 063929f75094dc77ca12810cefe43b757f9d68c7 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 23 Sep 2020 11:18:20 +0100 Subject: [PATCH 13/14] Handle 'RAM' as filename to allow direct uploads Add ability to upload assisted GPS data --- README.md | 3 +- apps.json | 11 ++++ apps/assistedgps/ChangeLog | 1 + apps/assistedgps/app.png | Bin 0 -> 1549 bytes apps/assistedgps/custom.html | 113 +++++++++++++++++++++++++++++++++++ core | 2 +- testing/GPS-comms.js | 4 +- 7 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 apps/assistedgps/ChangeLog create mode 100644 apps/assistedgps/app.png create mode 100644 apps/assistedgps/custom.html diff --git a/README.md b/README.md index 22a12bd5b..326599d14 100644 --- a/README.md +++ b/README.md @@ -241,7 +241,8 @@ and which gives information about the app for the Launcher. // add an icon to allow your app to be tested "storage": [ // list of files to add to storage - {"name":"appid.js", // filename to use in storage + {"name":"appid.js", // filename to use in storage. + // If name=='RAM', the code is sent directly to Bangle.js and is not saved to a file "url":"", // URL of file to load (currently relative to apps/) "content":"..." // if supplied, this content is loaded directly "evaluate":true // if supplied, data isn't quoted into a String before upload diff --git a/apps.json b/apps.json index 7f97b6f84..284116c5e 100644 --- a/apps.json +++ b/apps.json @@ -895,6 +895,17 @@ {"name":"gpsinfo.img","url": "gps-info-icon.js","evaluate": true} ] }, + { "id": "assistedgps", + "name": "Assisted GPS Update", + "icon": "app.png", + "version":"0.01", + "description": "Downloads assisted GPS data to Bangle.js for faster GPS startup and more accurate fixes", + "custom": "custom.html", + "tags": "tool,outdoors", + "readme": "README.md", + "storage": [ + ] + }, { "id": "pomodo", "name":"Pomodoro", diff --git a/apps/assistedgps/ChangeLog b/apps/assistedgps/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/assistedgps/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/apps/assistedgps/app.png b/apps/assistedgps/app.png new file mode 100644 index 0000000000000000000000000000000000000000..970e851397d87a1e47af18285c6fbc7cc256d634 GIT binary patch literal 1549 zcmV+o2J-odP)CE&t({iyuEG@K=f~Lq#3qgS_q|Fdp|SnnX{J< zy;wT8a|S3p^n04wd#$zqHEZp2_H1B?A%+;@L9t->l9c?ti`Ry;5rZYhDhqZmNwF!$ zA!ge2Vp-wpP z3T6MuwUCsev`73Y8`HdS;(o}y%(xC)GHX5j>oZ^hqq0;>*bGkjj`Bp?ysMlc-&lr5!;V$NGu-9uqn zp}PzG69L%(YJ`w0t;R6bLWiq)*l#yFcU^9k&kdMjCX_RYbz2uYs;w+sSXSuPfl30V zqFel2tL+1r+{AvnvC*MYT#zXuMuCv>%!&$a<6DQ>VRm61c)dq_wJyb+Xv70168NQ- zQ^EYk2p4(7nAsUvXVbKkD=ONv%`99|w0AR@-qod;d+?<_*GwxOK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a9<&BkP)QiZYl`E+Yn zGW{{1K!tW3-Pa&}+-}!#vC)SXufH!?PMWJ``Lwt#f-#eco+NNG10Dc=fUgp$o(V@8 z{N4OC`>AM!N0UIv9&OV6xN^G_H(Pb6f^gxzlz_PFnZ + + + + + +

Assisted GPS

+

GPS can take a long time (~5 minutes) to get an accurate position the first time it is used. + AGPS uploads a few hints to the GPS receiver about satellite positions that allow it + to get a faster, more accurate fix - however they are only valid for a short period of time.

+

You can upload data that covers a longer period of time, but the upload will take longer.

+
+ + + + + +
+

Click

+ + + + + + diff --git a/core b/core index c99967381..1b66c4ce1 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit c99967381280f483877c3f11ae7b0d4dc8c53e0e +Subproject commit 1b66c4ce1ba71036bcb612a2f16bbd7fbc2c66de diff --git a/testing/GPS-comms.js b/testing/GPS-comms.js index 38d4c9dde..ca0db16b6 100644 --- a/testing/GPS-comms.js +++ b/testing/GPS-comms.js @@ -16,7 +16,7 @@ function writeGPScmd(cmd) { a += d[i]; b += a; } - d.push(a,b); + d.push(a&255,b&255); Serial1.write(d); } function readGPScmd(cmd, callback) { @@ -131,7 +131,7 @@ function setUBX_MGA_INI_TIME_UTC() { dv.setUint8(9, d.getMinutes()); dv.setUint8(10, d.getSeconds()); dv.setUint16(16, 10*60); // seconds part of accuracy - 10 minutes - writeGPScmd(a.slice()); + writeGPScmd([].slice.call(a)); } setUBX_MGA_INI_TIME_UTC(); From 2e45174d4a87d9cb47e6c47d7e28f96394c01b05 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 23 Sep 2020 11:38:02 +0100 Subject: [PATCH 14/14] Fix sanity check - handle 'to RAM' uploads better, allowing the app loader to upload stuff that doesn't actually ever stay in storage --- README.md | 7 ++++++- apps.json | 5 ++--- core | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 326599d14..240163f6c 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,12 @@ and which gives information about the app for the Launcher. "shortName": "Short name", // short name for launcher "icon": "icon.png", // icon in apps/ "description": "...", // long description (can contain markdown) - "type":"...", // optional(if app) - 'app'/'widget'/'launch'/'bootloader' + "type":"...", // optional(if app) - + // 'app' - an application + // 'widget' - a widget + // 'launch' - replacement launcher app + // 'bootloader' - code that runs at startup only + // 'RAM' - code that runs and doesn't upload anything to storage "tags": "", // comma separated tag list for searching "dependencies" : { "notify":"type" } // optional, app 'types' we depend on // for instance this will use notify/notifyfs is they exist, or will pull in 'notify' diff --git a/apps.json b/apps.json index 284116c5e..50f76f875 100644 --- a/apps.json +++ b/apps.json @@ -902,9 +902,8 @@ "description": "Downloads assisted GPS data to Bangle.js for faster GPS startup and more accurate fixes", "custom": "custom.html", "tags": "tool,outdoors", - "readme": "README.md", - "storage": [ - ] + "type": "RAM", + "storage": [ ] }, { "id": "pomodo", diff --git a/core b/core index 1b66c4ce1..62615f6ea 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 1b66c4ce1ba71036bcb612a2f16bbd7fbc2c66de +Subproject commit 62615f6ea4855381e0b4b4b74f8ca69aa594181e