mirror of https://github.com/espruino/BangleApps
Merge pull request #949 from johan-m-o/master
Update Spirit Level to work on Bangle.js 2pull/952/head
commit
db1c5b7481
|
@ -734,11 +734,11 @@
|
|||
{
|
||||
"id": "slevel",
|
||||
"name": "Spirit Level",
|
||||
"version": "0.01",
|
||||
"version": "0.02",
|
||||
"description": "Show the current angle of the watch, so you can use it to make sure something is absolutely flat",
|
||||
"icon": "spiritlevel.png",
|
||||
"tags": "tool",
|
||||
"supports": ["BANGLEJS"],
|
||||
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||
"storage": [
|
||||
{"name":"slevel.app.js","url":"spiritlevel.js"},
|
||||
{"name":"slevel.img","url":"spiritlevel-icon.js","evaluate":true}
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
0.01: New App!
|
||||
0.02: Updated to work with both Bangle.js 1 and 2.
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
g.clear();
|
||||
var old = {x:0,y:0};
|
||||
var W = g.getWidth();
|
||||
var H = g.getHeight();
|
||||
Bangle.on('accel',function(v) {
|
||||
var max = Math.max(Math.abs(v.x),Math.abs(v.y),Math.abs(v.z));
|
||||
if (Math.abs(v.y)==max) {
|
||||
|
@ -14,17 +16,17 @@ Bangle.on('accel',function(v) {
|
|||
g.setColor(1,1,1);
|
||||
g.setFont("6x8",2);
|
||||
g.setFontAlign(0,-1);
|
||||
g.clearRect(60,0,180,16);
|
||||
g.drawString(ang.toFixed(1),120,0);
|
||||
g.clearRect(W*(1/4),0,W*(3/4),H*(1/16));
|
||||
g.drawString(ang.toFixed(1),W/2,0);
|
||||
var n = {
|
||||
x:E.clip(120+v.x*256,4,236),
|
||||
y:E.clip(120+v.y*256,4,236)};
|
||||
x:E.clip(W/2+v.x*256,4,W-4),
|
||||
y:E.clip(H/2+v.y*256,4,H-4)};
|
||||
g.clearRect(old.x-3,old.y-3,old.x+6,old.y+6);
|
||||
g.setColor(1,1,1);
|
||||
g.fillRect(n.x-3,n.y-3,n.x+6,n.y+6);
|
||||
g.setColor(1,0,0);
|
||||
g.drawCircle(120,120,20);
|
||||
g.drawCircle(120,120,60);
|
||||
g.drawCircle(120,120,100);
|
||||
g.drawCircle(W/2,H/2,W*(1/12));
|
||||
g.drawCircle(W/2,H/2,W*(1/4));
|
||||
g.drawCircle(W/2,H/2,W*(5/12));
|
||||
old = n;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue