slevel 0.04: Now work with different themes

pull/1312/head
Gordon Williams 2022-01-18 14:47:44 +00:00
parent 991fd5c78f
commit ec850868c9
4 changed files with 11 additions and 19 deletions

View File

@ -838,7 +838,7 @@
{
"id": "slevel",
"name": "Spirit Level",
"version": "0.03",
"version": "0.04",
"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",
@ -854,6 +854,7 @@
"version": "0.07",
"description": "Show currently installed apps, free space, and allow their deletion from the watch",
"icon": "files.png",
"screenshots": [{"url":"screenshot.png"}],
"tags": "tool,system,files",
"supports": ["BANGLEJS","BANGLEJS2"],
"storage": [

View File

@ -1,3 +1,4 @@
0.01: New App!
0.02: Updated to work with both Bangle.js 1 and 2.
0.03: Now also visible on Bangle.js 2
0.04: Now work with different themes

BIN
apps/slevel/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -3,12 +3,6 @@ var old = {x:0,y:0};
var W = g.getWidth();
var H = g.getHeight();
// colour definitions for Bangle.js 2
const RED = "#ff0000";
const GRN = "#00ff00";
const BLU = "#0000ff";
const HwVer = process.env.HWVERSION;
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) {
@ -20,21 +14,17 @@ Bangle.on('accel',function(v) {
var d = Math.sqrt(v.x*v.x+v.y*v.y);
var ang = Math.atan2(d,Math.abs(v.z))*180/Math.PI;
if (2 == HwVer) g.setColor(RED); else
g.setColor(1,1,1);
g.setFont("6x8",2);
g.setFontAlign(0,-1);
g.clearRect(W*(1/4),0,W*(3/4),H*(1/16));
g.drawString(ang.toFixed(1),W/2,0);
g.reset();
g.clearRect(W*(1/4),0,W*(3/4),16);// clear behind text
g.setFont("6x8",2).setFontAlign(0,-1).drawString(ang.toFixed(1),W/2,0);
var n = {
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);
if (2 == HwVer) g.setColor(GRN); else
g.setColor(1,1,1);
g.fillRect(n.x-3,n.y-3,n.x+6,n.y+6);
if (2 == HwVer) g.setColor(BLU); else
g.setColor(1,0,0);
g.clearRect(old.x-3,old.y-3,old.x+6,old.y+6); // clear old marker
g.setColor("#0f0");
g.fillRect(n.x-3,n.y-3,n.x+6,n.y+6); // draw new marker
// draw rings
g.setColor("#f00");
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));