diff --git a/apps/neonx/ChangeLog b/apps/neonx/ChangeLog index 7ac033fe8..968d6d629 100644 --- a/apps/neonx/ChangeLog +++ b/apps/neonx/ChangeLog @@ -1,2 +1,3 @@ 0.01: Initial release -0.02: Optional fullscreen mode \ No newline at end of file +0.02: Optional fullscreen mode +0.03: Optional show lock status via color \ No newline at end of file diff --git a/apps/neonx/README.md b/apps/neonx/README.md index f205b702f..c3eb982c6 100644 --- a/apps/neonx/README.md +++ b/apps/neonx/README.md @@ -21,4 +21,9 @@ Shows the current date as DD MM on touch and reverts back to time after 5 second ### Fullscreen Shows the watchface in fullscreen mode. -Note: In fullscreen mode, widgets are hidden, but still loaded. \ No newline at end of file +Note: In fullscreen mode, widgets are hidden, but still loaded. + +### Show lock status +In fullscreen mode it can be useful to detect, whether the BangleJs is locked or not. +If these settings are enabled, the first digit is shown red if the BangleJs is locked +and purple otherwise. \ No newline at end of file diff --git a/apps/neonx/metadata.json b/apps/neonx/metadata.json index ffa4d1b8e..4ac7c4cea 100644 --- a/apps/neonx/metadata.json +++ b/apps/neonx/metadata.json @@ -2,7 +2,7 @@ "id": "neonx", "name": "Neon X & IO X Clock", "shortName": "Neon X Clock", - "version": "0.02", + "version": "0.03", "description": "Pebble Neon X & Neon IO X for Bangle.js", "icon": "neonx.png", "type": "clock", diff --git a/apps/neonx/neonx.app.js b/apps/neonx/neonx.app.js index 4ef0986fe..165ec32a6 100644 --- a/apps/neonx/neonx.app.js +++ b/apps/neonx/neonx.app.js @@ -8,6 +8,19 @@ * Created: February 2022 */ +let settings = { + thickness: 4, + io: 0, + showDate: 1, + fullscreen: false, + showLock: false, +}; +let saved_settings = require('Storage').readJSON('neonx.json', 1) || settings; +for (const key in saved_settings) { + settings[key] = saved_settings[key] +} + + const digits = { 0:[[15,15,85,15,85,85,15,85,15,15]], 1:[[85,15,85,85]], @@ -21,6 +34,7 @@ const digits = { 9:[[15,50,15,15,85,15,85,85,15,85]], }; + const colors = { x: [ ["#FF00FF", "#00FFFF"], @@ -31,17 +45,19 @@ const colors = { ["#00FF00", "#00FFFF"] ] }; +const unlockColor = "#FF0000"; const is12hour = (require("Storage").readJSON("setting.json",1)||{})["12hour"]||false; const screenWidth = g.getWidth(); const screenHeight = g.getHeight(); const halfWidth = screenWidth / 2; const scale = screenWidth / 240; -const REFRESH_RATE = 10E3; +const REFRESH_RATE = 60E3; let interval = 0; let showingDate = false; + function drawLine(poly, thickness){ for (let i = 0; i < poly.length; i = i + 2){ if (poly[i + 2] === undefined) { @@ -59,18 +75,6 @@ function drawLine(poly, thickness){ } } -let settings = { - thickness: 4, - io: 0, - showDate: 1, - fullscreen: false, -}; -let saved_settings = require('Storage').readJSON('neonx.json', 1) || settings; -for (const key in saved_settings) { - settings[key] = saved_settings[key] -} - - function drawClock(num){ let tx, ty; @@ -80,7 +84,11 @@ function drawClock(num){ const current = ((y + 1) * 2 + x - 1); let newScale = scale; - g.setColor(colors[settings.io ? 'io' : 'x'][y][x]); + let c = colors[settings.io ? 'io' : 'x'][y][x]; + if(x == 0 && y == 0 && settings.showLock){ + c = Bangle.isLocked() ? c : unlockColor; + } + g.setColor(c); if (!settings.io) { newScale *= settings.fullscreen ? 1.18 : 1.0; @@ -101,6 +109,7 @@ function drawClock(num){ } } + function draw(date){ let d = new Date(); let l1, l2; @@ -131,6 +140,7 @@ function draw(date){ drawClock([l1, l2]); } + function setUpdateInt(set){ if (interval) { clearInterval(interval); @@ -148,15 +158,22 @@ Bangle.setUI("clock"); setUpdateInt(1); draw(); + if (settings.showDate) { Bangle.on('touch', () => draw(!showingDate)); } Bangle.on('lcdPower', function(on){ if (on){ - draw(); setUpdateInt(1); - } else setUpdateInt(0); + draw(); + } else { + setUpdateInt(0); + } +}); + +Bangle.on('lock', function(isLocked) { + draw(); }); Bangle.loadWidgets(); diff --git a/apps/neonx/neonx.settings.js b/apps/neonx/neonx.settings.js index 3af2e0fa5..e01ceb4d3 100644 --- a/apps/neonx/neonx.settings.js +++ b/apps/neonx/neonx.settings.js @@ -9,6 +9,7 @@ io: 0, showDate: 1, fullscreen: false, + showLock: false, }; updateSettings(); @@ -58,6 +59,14 @@ updateSettings(); }, }, + 'Show lock': { + value: false | neonXSettings.showLock, + format: () => (neonXSettings.showLock ? 'Yes' : 'No'), + onchange: () => { + neonXSettings.showLock = !neonXSettings.showLock; + updateSettings(); + }, + }, }; E.showMenu(menu); })