mirror of https://github.com/espruino/BangleApps
Merge pull request #316 from Purple-Tentacle/master
Compass 0.02 - show text if uncalibratedpull/312/head
commit
745e4d38a9
|
@ -235,7 +235,7 @@
|
||||||
{ "id": "compass",
|
{ "id": "compass",
|
||||||
"name": "Compass",
|
"name": "Compass",
|
||||||
"icon": "compass.png",
|
"icon": "compass.png",
|
||||||
"version":"0.01",
|
"version":"0.02",
|
||||||
"description": "Simple compass that points North",
|
"description": "Simple compass that points North",
|
||||||
"tags": "tool,outdoors",
|
"tags": "tool,outdoors",
|
||||||
"storage": [
|
"storage": [
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
0.01: New App!
|
||||||
|
0.02: Show text if uncalibrated
|
|
@ -1,34 +1,43 @@
|
||||||
g.clear();
|
g.clear();
|
||||||
g.setColor(0,0.5,1);
|
g.setColor(0,0.5,1);
|
||||||
g.fillCircle(120,130,80,80);
|
g.fillCircle(120,130,80,80);
|
||||||
g.setColor(0,0,0);
|
g.setColor(0,0,0);
|
||||||
g.fillCircle(120,130,70,70);
|
g.fillCircle(120,130,70,70);
|
||||||
|
|
||||||
function arrow(r,c) {
|
function arrow(r,c) {
|
||||||
r=r*Math.PI/180;
|
r=r*Math.PI/180;
|
||||||
var p = Math.PI/2;
|
var p = Math.PI/2;
|
||||||
g.setColor(c);
|
g.setColor(c);
|
||||||
g.fillPoly([
|
g.fillPoly([
|
||||||
120+60*Math.sin(r), 130-60*Math.cos(r),
|
120+60*Math.sin(r), 130-60*Math.cos(r),
|
||||||
120+10*Math.sin(r+p), 130-10*Math.cos(r+p),
|
120+10*Math.sin(r+p), 130-10*Math.cos(r+p),
|
||||||
120+10*Math.sin(r+-p), 130-10*Math.cos(r-p),
|
120+10*Math.sin(r+-p), 130-10*Math.cos(r-p),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldHeading = 0;
|
var oldHeading = 0;
|
||||||
Bangle.on('mag', function(m) {
|
Bangle.on('mag', function(m) {
|
||||||
if (!Bangle.isLCDOn()) return;
|
if (!Bangle.isLCDOn()) return;
|
||||||
g.setFont("6x8",3);
|
g.setFont("6x8",3);
|
||||||
g.setColor(0);
|
g.setColor(0);
|
||||||
g.fillRect(70,0,170,24);
|
g.fillRect(0,0,230,40);
|
||||||
g.setColor(0xffff);
|
g.setColor(0xffff);
|
||||||
g.setFontAlign(0,0);
|
if (isNaN(m.heading)) {
|
||||||
g.drawString(isNaN(m.heading)?"---":Math.round(m.heading),120,12);
|
g.setFontAlign(-1,-1);
|
||||||
g.setColor(0,0,0);
|
g.setFont("6x8",2);
|
||||||
arrow(oldHeading,0);
|
g.drawString("Uncalibrated",50,12);
|
||||||
arrow(oldHeading+180,0);
|
g.drawString("turn 360° around",25,26);
|
||||||
arrow(m.heading,0xF800);
|
}
|
||||||
arrow(m.heading+180,0x001F);
|
else {
|
||||||
oldHeading = m.heading;
|
g.setFontAlign(0,0);
|
||||||
});
|
g.setFont("6x8",3);
|
||||||
Bangle.setCompassPower(1);
|
g.drawString(Math.round(m.heading),120,12);
|
||||||
|
}
|
||||||
|
g.setColor(0,0,0);
|
||||||
|
arrow(oldHeading,0);
|
||||||
|
arrow(oldHeading+180,0);
|
||||||
|
arrow(m.heading,0xF800);
|
||||||
|
arrow(m.heading+180,0x001F);
|
||||||
|
oldHeading = m.heading;
|
||||||
|
});
|
||||||
|
Bangle.setCompassPower(1);
|
||||||
|
|
Loading…
Reference in New Issue