Merge branch 'master' of github.com:espruino/BangleApps
commit
2b409db904
13
apps.json
13
apps.json
|
|
@ -743,6 +743,19 @@
|
|||
{"name":"+demoapp","url":"app.json"},
|
||||
{"name":"-demoapp","url":"app.js"},
|
||||
{"name":"*demoapp","url":"app-icon.js","evaluate":true}
|
||||
],
|
||||
"sortorder" : -9
|
||||
},
|
||||
{ "id": "flagrse",
|
||||
"name": "Espruino Flag Raiser",
|
||||
"icon": "app.png",
|
||||
"description": "App to send a command to another Espruino to cause it to raise a flag",
|
||||
"tags": "",
|
||||
"storage": [
|
||||
{"name":"+flagrse","url":"app.json"},
|
||||
{"name":"-flagrse","url":"app.js"},
|
||||
{"name":"*flagrse","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
|
|
|
|||
|
|
@ -19,6 +19,22 @@ Bangle.setLCDTimeout(s.timeout);
|
|||
if (!s.timeout) Bangle.setLCDPower(1);
|
||||
E.setTimeZone(s.timezone);
|
||||
delete s;
|
||||
// check to see if our clock is wrong - if it is use GPS time
|
||||
if ((new Date()).getFullYear()==1970) {
|
||||
console.log("Searching for GPS time");
|
||||
Bangle.on('GPS',function cb(g) {
|
||||
Bangle.setGPSPower(0);
|
||||
Bangle.removeListener("GPS",cb);
|
||||
if (!g.time || (g.time.getFullYear()<2000) ||
|
||||
(g.time.getFullYear()==2250)) {
|
||||
console.log("GPS receiver's time not set");
|
||||
return;
|
||||
}
|
||||
setTime(g.time.getTime()/1000);
|
||||
console.log("GPS time",g.time.toString());
|
||||
});
|
||||
Bangle.setGPSPower(1);
|
||||
}
|
||||
// All of this is just shim for older Bangles
|
||||
if (!Bangle.loadWidgets) {
|
||||
Bangle.loadWidgets = function(){
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ var scenes = [
|
|||
y+=step;
|
||||
if (y>70) {
|
||||
clearInterval(i);
|
||||
|
||||
i = undefined;
|
||||
}
|
||||
g.clearRect(0,y-(step+1),240,y-1);
|
||||
|
|
@ -159,10 +160,13 @@ var scenes = [
|
|||
];
|
||||
var sceneNo = scenes.length-1;
|
||||
|
||||
var stop = scenes[sceneNo]();
|
||||
setInterval(function() {
|
||||
var stop;
|
||||
function next() {
|
||||
sceneNo++;
|
||||
if (sceneNo>=scenes.length) sceneNo=0;
|
||||
stop();
|
||||
if (stop) stop();
|
||||
clearInterval();
|
||||
stop = scenes[sceneNo]();
|
||||
}, 10000);
|
||||
setTimeout(next, 10000);
|
||||
}
|
||||
next()
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwxH+AH4A/AH4AJmUyF/4Adstl1ovvAAIvvGNQvGGNAvIGMwvKGMgvMGMQvOGMAvQGLwvSGLgvUGLQvWGLAvYGKwv/R+zvtFrAvUFrQvSFrgvQFrwvOFsAvMFsQvKFsgvIFswvGFtAvEFtQABmUyF1gv/F/4v/F/4v/F/4v/F/4A/AH4A/AAwA="))
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
function redraw() {
|
||||
var img = require("heatshrink").decompress(atob("sFgxH+AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/ACcyAARD/L/5f/If5f/AHdlAAWtIn5ffAAJG/L75h/L8Jh/L8Jh/L8Jh/L8Jh/L8Jh/L8Jh/L8Jh/L8Jh/L8Jh/L8Jh/L8Jh/L8Jh/L8Jh+L8Rh8L8hh6L8xh4L9Bh2L9Rh0L9hhyL9xhwL+BhuL+RhsL+hhqL/5f/Lvpf0LtRfyLthfwLtxfuLuBfsLuRfqLuhfoLuxfmLvBfkLvRfiLvhfgLvxfeLn5fdLX5fdLH5fdK35fdKn5fdKX5fdKH5fdJ35fdJn5fdJX5fdJH5fdI35fdIn4AamQACIf5f/L/5D/L/5f/If5f/L/5D/L/5f/If5f/L/5D/L/5f/If5f/L/5D/L/5f/If5f/L/5D/L/5f/If5f/L/5D/L/4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4AnA"));
|
||||
g.clear();
|
||||
g.drawImage(img, 120-96, 120-96, {scale:2});
|
||||
}
|
||||
|
||||
// Code for button (Puck.js)
|
||||
var busy = false;
|
||||
|
||||
var lastTry = getTime();
|
||||
|
||||
function flag() {
|
||||
E.showMessage("Working...");
|
||||
if (busy && lastTry+5<getTime()) busy=false;
|
||||
lastTry = getTime();
|
||||
|
||||
if (busy) {
|
||||
digitalPulse(LED1,1,[10,200,10,200,10]);
|
||||
return;
|
||||
}
|
||||
busy = true;
|
||||
var gatt;
|
||||
NRF.requestDevice({ filters: [{ name: 'Flag' }] })
|
||||
.then(function(device) {
|
||||
console.log("Found");
|
||||
return device.gatt.connect();
|
||||
}).then(function(g) {
|
||||
console.log("Connected");
|
||||
gatt = g;
|
||||
return gatt.getPrimaryService(
|
||||
"3e440001-f5bb-357d-719d-179272e4d4d9");
|
||||
}).then(function(service) {
|
||||
console.log("Found service");
|
||||
return service.getCharacteristic(
|
||||
"3e440002-f5bb-357d-719d-179272e4d4d9");
|
||||
}).then(function(characteristic) {
|
||||
console.log("Found characteristic");
|
||||
return characteristic.writeValue(1);
|
||||
}).then(function() {
|
||||
console.log("Found service");
|
||||
gatt.disconnect();
|
||||
console.log("Done!");
|
||||
busy=false;
|
||||
redraw();
|
||||
}).catch(function(e) {
|
||||
console.log("ERROR",e);
|
||||
busy=false;
|
||||
gatt.disconnect();
|
||||
redraw();
|
||||
});
|
||||
}
|
||||
|
||||
setWatch(flag, BTN, {repeat:true});
|
||||
|
||||
Bangle.on("touch", flag);
|
||||
redraw();
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name":"Flag Raiser",
|
||||
"icon":"*flagrse",
|
||||
"src":"-flagrse"
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 326 B |
Loading…
Reference in New Issue