1
0
Fork 0

Optional settings to show a different color for (0,0) whenever the bangle is locked.

master
David Peer 2022-02-18 15:12:13 +01:00
parent ece775bb8e
commit f8eebb80ec
5 changed files with 51 additions and 19 deletions

View File

@ -1,2 +1,3 @@
0.01: Initial release 0.01: Initial release
0.02: Optional fullscreen mode 0.02: Optional fullscreen mode
0.03: Optional show lock status via color

View File

@ -21,4 +21,9 @@ Shows the current date as DD MM on touch and reverts back to time after 5 second
### Fullscreen ### Fullscreen
Shows the watchface in fullscreen mode. Shows the watchface in fullscreen mode.
Note: In fullscreen mode, widgets are hidden, but still loaded. 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.

View File

@ -2,7 +2,7 @@
"id": "neonx", "id": "neonx",
"name": "Neon X & IO X Clock", "name": "Neon X & IO X Clock",
"shortName": "Neon X Clock", "shortName": "Neon X Clock",
"version": "0.02", "version": "0.03",
"description": "Pebble Neon X & Neon IO X for Bangle.js", "description": "Pebble Neon X & Neon IO X for Bangle.js",
"icon": "neonx.png", "icon": "neonx.png",
"type": "clock", "type": "clock",

View File

@ -8,6 +8,19 @@
* Created: February 2022 * 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 = { const digits = {
0:[[15,15,85,15,85,85,15,85,15,15]], 0:[[15,15,85,15,85,85,15,85,15,15]],
1:[[85,15,85,85]], 1:[[85,15,85,85]],
@ -21,6 +34,7 @@ const digits = {
9:[[15,50,15,15,85,15,85,85,15,85]], 9:[[15,50,15,15,85,15,85,85,15,85]],
}; };
const colors = { const colors = {
x: [ x: [
["#FF00FF", "#00FFFF"], ["#FF00FF", "#00FFFF"],
@ -31,17 +45,19 @@ const colors = {
["#00FF00", "#00FFFF"] ["#00FF00", "#00FFFF"]
] ]
}; };
const unlockColor = "#FF0000";
const is12hour = (require("Storage").readJSON("setting.json",1)||{})["12hour"]||false; const is12hour = (require("Storage").readJSON("setting.json",1)||{})["12hour"]||false;
const screenWidth = g.getWidth(); const screenWidth = g.getWidth();
const screenHeight = g.getHeight(); const screenHeight = g.getHeight();
const halfWidth = screenWidth / 2; const halfWidth = screenWidth / 2;
const scale = screenWidth / 240; const scale = screenWidth / 240;
const REFRESH_RATE = 10E3; const REFRESH_RATE = 60E3;
let interval = 0; let interval = 0;
let showingDate = false; let showingDate = false;
function drawLine(poly, thickness){ function drawLine(poly, thickness){
for (let i = 0; i < poly.length; i = i + 2){ for (let i = 0; i < poly.length; i = i + 2){
if (poly[i + 2] === undefined) { 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){ function drawClock(num){
let tx, ty; let tx, ty;
@ -80,7 +84,11 @@ function drawClock(num){
const current = ((y + 1) * 2 + x - 1); const current = ((y + 1) * 2 + x - 1);
let newScale = scale; 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) { if (!settings.io) {
newScale *= settings.fullscreen ? 1.18 : 1.0; newScale *= settings.fullscreen ? 1.18 : 1.0;
@ -101,6 +109,7 @@ function drawClock(num){
} }
} }
function draw(date){ function draw(date){
let d = new Date(); let d = new Date();
let l1, l2; let l1, l2;
@ -131,6 +140,7 @@ function draw(date){
drawClock([l1, l2]); drawClock([l1, l2]);
} }
function setUpdateInt(set){ function setUpdateInt(set){
if (interval) { if (interval) {
clearInterval(interval); clearInterval(interval);
@ -148,15 +158,22 @@ Bangle.setUI("clock");
setUpdateInt(1); setUpdateInt(1);
draw(); draw();
if (settings.showDate) { if (settings.showDate) {
Bangle.on('touch', () => draw(!showingDate)); Bangle.on('touch', () => draw(!showingDate));
} }
Bangle.on('lcdPower', function(on){ Bangle.on('lcdPower', function(on){
if (on){ if (on){
draw();
setUpdateInt(1); setUpdateInt(1);
} else setUpdateInt(0); draw();
} else {
setUpdateInt(0);
}
});
Bangle.on('lock', function(isLocked) {
draw();
}); });
Bangle.loadWidgets(); Bangle.loadWidgets();

View File

@ -9,6 +9,7 @@
io: 0, io: 0,
showDate: 1, showDate: 1,
fullscreen: false, fullscreen: false,
showLock: false,
}; };
updateSettings(); updateSettings();
@ -58,6 +59,14 @@
updateSettings(); updateSettings();
}, },
}, },
'Show lock': {
value: false | neonXSettings.showLock,
format: () => (neonXSettings.showLock ? 'Yes' : 'No'),
onchange: () => {
neonXSettings.showLock = !neonXSettings.showLock;
updateSettings();
},
},
}; };
E.showMenu(menu); E.showMenu(menu);
}) })