renaming and fiddling to ensure you can have differnt types of clock app, even more than one installed at the same time
parent
041a539390
commit
966c1c4b1e
35
apps.json
35
apps.json
|
|
@ -9,19 +9,31 @@
|
||||||
],
|
],
|
||||||
"sortorder" : -1
|
"sortorder" : -1
|
||||||
},
|
},
|
||||||
{ "id": "clock",
|
{ "id": "mclock",
|
||||||
"name": "Morphing Clock",
|
"name": "Morphing Clock",
|
||||||
"icon": "clock-morphing.png",
|
"icon": "clock-morphing.png",
|
||||||
"description": "7 segment clock that morphs between minutes and hours",
|
"description": "7 segment clock that morphs between minutes and hours",
|
||||||
"tags": "clock",
|
"tags": "clock",
|
||||||
|
"type":"clock",
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"+clock","url":"clock.json"},
|
{"name":"+mclock","url":"clock-morphing.json"},
|
||||||
{"name":"-clock","url":"clock-morphing.js"},
|
{"name":"-mclock","url":"clock-morphing.js"},
|
||||||
{"name":"*clock","url":"clock-icon.js","evaluate":true}
|
{"name":"*mclock","url":"clock-morphing-icon.js","evaluate":true}
|
||||||
],
|
],
|
||||||
"sortorder" : -1
|
"sortorder" : -1
|
||||||
},
|
},
|
||||||
|
{ "id": "wclock",
|
||||||
|
"name": "Word Clock",
|
||||||
|
"icon": "clock-word.png",
|
||||||
|
"description": "Display Time as Text",
|
||||||
|
"tags": "clock",
|
||||||
|
"type":"clock",
|
||||||
|
"storage": [
|
||||||
|
{"name":"+wclock","url":"clock-word.json"},
|
||||||
|
{"name":"-wclock","url":"clock-word.js"},
|
||||||
|
{"name":"*wclock","url":"clock-word-icon.js","evaluate":true}
|
||||||
|
]
|
||||||
|
},
|
||||||
{ "id": "trex",
|
{ "id": "trex",
|
||||||
"name": "T-Rex",
|
"name": "T-Rex",
|
||||||
"icon": "trex.png",
|
"icon": "trex.png",
|
||||||
|
|
@ -134,7 +146,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ "id": "sbt",
|
{ "id": "sbt",
|
||||||
"name": "c Widget",
|
"name": "Bluetooth Widget",
|
||||||
"icon": "widget-bluetooth.png",
|
"icon": "widget-bluetooth.png",
|
||||||
"description": "Show the current Bluetooth connection status in the top right of the clock",
|
"description": "Show the current Bluetooth connection status in the top right of the clock",
|
||||||
"tags": "widget,bluetooth",
|
"tags": "widget,bluetooth",
|
||||||
|
|
@ -242,16 +254,5 @@
|
||||||
{"name":"+route"},
|
{"name":"+route"},
|
||||||
{"name":"=route"}
|
{"name":"=route"}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{ "id": "wclock",
|
|
||||||
"name": "Word Clock",
|
|
||||||
"icon": "word-clock.png",
|
|
||||||
"description": "Display Time as Text",
|
|
||||||
"tags": "",
|
|
||||||
"storage": [
|
|
||||||
{"name":"+wclock","url":"word-clock.json"},
|
|
||||||
{"name":"-wclock","url":"word-clock.js"},
|
|
||||||
{"name":"*wclock","url":"word-clock-icon.js","evaluate":true}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ setWatch(function() {
|
||||||
apps = s.list().filter(a=>a[0]=='+').map(app=>{
|
apps = s.list().filter(a=>a[0]=='+').map(app=>{
|
||||||
try { return s.readJSON(app); }
|
try { return s.readJSON(app); }
|
||||||
catch (e) { return {name:"DEAD: "+app.substr(1)} }
|
catch (e) { return {name:"DEAD: "+app.substr(1)} }
|
||||||
}).filter(app=>app.type=="app" || !app.type);
|
}).filter(app=>app.type=="app" || app.type=="clock" || !app.type);
|
||||||
var selected = 0;
|
var selected = 0;
|
||||||
var menuScroll = 0;
|
var menuScroll = 0;
|
||||||
var menuShowing = false;
|
var menuShowing = false;
|
||||||
|
|
@ -75,6 +75,12 @@ var WIDGETS={};
|
||||||
function drawWidgets() {
|
function drawWidgets() {
|
||||||
Object.keys(WIDGETS).forEach(k=>WIDGETS[k].draw());
|
Object.keys(WIDGETS).forEach(k=>WIDGETS[k].draw());
|
||||||
}
|
}
|
||||||
eval(require("Storage").read("-clock"));
|
var clockApp = require("Storage").list().filter(a=>a[0]=='+').map(app=>{
|
||||||
|
try { return require("Storage").readJSON(app); }
|
||||||
|
catch (e) {}
|
||||||
|
}).find(app=>app.type=="clock");
|
||||||
|
if (clockApp) eval(require("Storage").read(clockApp.src));
|
||||||
|
else E.showMessage("No Clock Found");
|
||||||
|
delete clockApp;
|
||||||
require("Storage").list().filter(a=>a[0]=='=').forEach(widget=>eval(require("Storage").read(widget)));
|
require("Storage").list().filter(a=>a[0]=='=').forEach(widget=>eval(require("Storage").read(widget)));
|
||||||
setTimeout(drawWidgets,100);
|
setTimeout(drawWidgets,100);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"name":"Morphing Clock","type":"clock",
|
||||||
|
"icon":"*mclock",
|
||||||
|
"src":"-mclock"
|
||||||
|
}
|
||||||
|
|
@ -4,7 +4,8 @@
|
||||||
var buf = Graphics.createArrayBuffer(240, 240, 2, { msb: true });
|
var buf = Graphics.createArrayBuffer(240, 240, 2, { msb: true });
|
||||||
|
|
||||||
function flip() {
|
function flip() {
|
||||||
g.drawImage({ width: buf.getWidth(), height: buf.getHeight(), bpp: 2, transparent: 0, buffer: buf.buffer }, 0, 0);
|
var palette = new Uint16Array([0,,,0xFFFF]);
|
||||||
|
g.drawImage({ width: buf.getWidth(), height: buf.getHeight(), bpp: 2, palette : palette, buffer: buf.buffer }, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const allWords = [
|
const allWords = [
|
||||||
|
|
@ -53,8 +54,8 @@
|
||||||
// font size and color
|
// font size and color
|
||||||
const wordFontSize = 20;
|
const wordFontSize = 20;
|
||||||
const timeFontSize = 30;
|
const timeFontSize = 30;
|
||||||
const passivColor = 1;
|
const passivColor = 0x3186/*grey*/;
|
||||||
const activeColor = 2;
|
const activeColor = 0xF800/*red*/;
|
||||||
|
|
||||||
function drawWordClock() {
|
function drawWordClock() {
|
||||||
|
|
||||||
|
|
@ -66,7 +67,7 @@
|
||||||
|
|
||||||
var hidx;
|
var hidx;
|
||||||
var midx;
|
var midx;
|
||||||
var midxA;
|
var midxA=[];
|
||||||
|
|
||||||
buf.clear();
|
buf.clear();
|
||||||
buf.setFontVector(wordFontSize);
|
buf.setFontVector(wordFontSize);
|
||||||
|
|
@ -110,6 +111,7 @@
|
||||||
hours[hidx][0].split('').forEach((c, pos) => {
|
hours[hidx][0].split('').forEach((c, pos) => {
|
||||||
x = xs + (hours[hidx][pos + 1] / 10 | 0) * dx;
|
x = xs + (hours[hidx][pos + 1] / 10 | 0) * dx;
|
||||||
y = ys + (hours[hidx][pos + 1] % 10) * dy;
|
y = ys + (hours[hidx][pos + 1] % 10) * dy;
|
||||||
|
|
||||||
buf.drawString(c, x, y);
|
buf.drawString(c, x, y);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -129,6 +131,7 @@
|
||||||
|
|
||||||
// display buf
|
// display buf
|
||||||
flip();
|
flip();
|
||||||
|
drawWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bangle.on('lcdPower', function(on) {
|
Bangle.on('lcdPower', function(on) {
|
||||||
|
|
@ -142,4 +145,4 @@
|
||||||
setInterval(drawWordClock, 1E4);
|
setInterval(drawWordClock, 1E4);
|
||||||
drawWordClock();
|
drawWordClock();
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name":"Word Clock",
|
"name":"Word Clock","type":"clock",
|
||||||
"icon":"*wclock",
|
"icon":"*wclock",
|
||||||
"src":"-wclock"
|
"src":"-wclock"
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 843 B After Width: | Height: | Size: 843 B |
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"name":"Clock","type":"app",
|
|
||||||
"icon":"*clock",
|
|
||||||
"src":"-clock"
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue