1
0
Fork 0

Merge branch 'master' into master

master
Gordon Williams 2021-03-08 09:50:46 +00:00 committed by GitHub
commit 8ce54c2deb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 204 additions and 1 deletions

View File

@ -2945,5 +2945,31 @@
{"name":"UI4swatch.app.js","url":"app.js"},
{"name":"UI4swatch.img","url":"app-icon.js","evaluate":true}
]
}
},
{ "id": "simplest",
"name": "Simplest Clock",
"icon": "simplest.png",
"version":"0.01",
"description": "The simplest working clock, acts as a tutorial piece",
"tags": "clock",
"type":"clock",
"readme": "README.md",
"storage": [
{"name":"simplest.app.js","url":"app.js"},
{"name":"simplest.img","url":"icon.js","evaluate":true}
]
},
{ "id": "stepo",
"name": "Stepometer Clock",
"icon": "stepo.png",
"version":"0.01",
"description": "A large font watch, displays step count in a doughnut guage and warns of low battery",
"tags": "clock",
"type":"clock",
"readme": "README.md",
"storage": [
{"name":"stepo.app.js","url":"app.js"},
{"name":"stepo.img","url":"icon.js","evaluate":true}
]
}
]

2
apps/arrow/ChangeLog Normal file
View File

@ -0,0 +1,2 @@
0.01: First version
0.02: Moved arrow image load to global scope

5
apps/simplest/README.md Normal file
View File

@ -0,0 +1,5 @@
# Simplest Clock
The simplest working clock, acts as a tutorial piece
![](screenshot.jpg)

24
apps/simplest/app.js Normal file
View File

@ -0,0 +1,24 @@
function draw() {
var d = new Date();
var da = d.toString().split(" ");
var time = da[4].substr(0,5);
g.reset();
g.clearRect(0, 30, 239, 99);
g.setFontAlign(0, -1);
g.setFont("Vector", 80);
g.drawString(time, 120, 40);
}
// handle switch display on by pressing BTN1
Bangle.on('lcdPower', function(on) {
if (on) draw();
});
g.clear();
Bangle.loadWidgets();
Bangle.drawWidgets();
setInterval(draw, 15000); // refresh every 15s
draw();
setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"});

1
apps/simplest/icon.js Normal file
View File

@ -0,0 +1 @@
require("heatshrink").decompress(atob("mEwwIdah/wAof//4ECgYFB4AFBg4FB8AFBj/wh/4AoM/wEB/gFBvwCEBAU/AQP4gfAj8AgPwAoMPwED8AFBg/AAYIBDA4ngg4TB4EBApkPKgJSBJQIFTMgIFCJIIFDKoIFEvgFBGoMAnw7DP4IFEh+BAoItBg+DNIQwBMIaeCKoKxCPoIzCEgKVHUIqtFXIrFFaIrdFdIwAV"))

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

View File

@ -0,0 +1,7 @@
require("Storage").write("simplest.info",{
"id":"simplest",
"name":"Simplest Clock",
"src":"simplest.app.js",
"icon":"simplest.img",
"type":"clock"
});

BIN
apps/simplest/simplest.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 929 B

26
apps/stepo/README.md Normal file
View File

@ -0,0 +1,26 @@
# Stepometer Clock
A large font watch, displays step count in a doughnut guage and warns of low battery
## Features
- Displays the time in large font
- Display current step count in a doughnut guage
- Show step count in the middle of the doughnut guage
- The guage show percentage of steps out of a goal of 10000 steps
![](screenshot1.jpg)
- When the battery is less than 25% the doughnut turns red
![](screenshot2.jpg)
# Notes
* Uses an arrayBuffer to prepare the doughnut guage. The arrayBuffer
is 160*160 and is larger than required. The reason for this is that
I plan to use this watch face with others in a multiclock format
and want to be able to reuse the arrayBuffer with other clocks.

104
apps/stepo/app.js Normal file
View File

@ -0,0 +1,104 @@
var pal4color = new Uint16Array([0x0000,0xFFFF,0x7BEF,0xAFE5],0,2); // b,w,grey,greenyellow
var pal4red = new Uint16Array([0x0000,0xFFFF,0xF800,0xAFE5],0,2); // b,w,red,greenyellow
var buf = Graphics.createArrayBuffer(160,160,2,{msb:true});
function flip(x,y) {
g.drawImage({width:160,height:160,bpp:2,buffer:buf.buffer, palette:pal4color}, x, y);
buf.clear();
}
function flip_red(x,y) {
g.drawImage({width:160,height:160,bpp:2,buffer:buf.buffer, palette:pal4red}, x, y);
buf.clear();
}
function radians(a) {
return a*Math.PI/180;
}
function drawSteps() {
var i = 0;
var cx = 80;
var cy = 75;
var r = 56;
var steps = getSteps();
var percent = steps / 10000;
if (percent > 1) percent = 1;
var startrot = 0 - 180;
var midrot = -180 - (360 * percent);
var endrot = -360 - 180;
buf.setColor(3); // green-yellow
// draw guauge
for (i = startrot; i > midrot; i--) {
x = cx + r * Math.sin(radians(i));
y = cy + r * Math.cos(radians(i));
buf.fillCircle(x,y,4);
}
buf.setColor(2); // grey
// draw remainder of guage in grey
for (i = midrot; i > endrot; i--) {
x = cx + r * Math.sin(radians(i));
y = cy + r * Math.cos(radians(i));
buf.fillCircle(x,y,4);
}
// draw steps
buf.setColor(1); // white
buf.setFont("Vector", 24);
buf.setFontAlign(0,0);
buf.drawString(steps, 80, cy);
// change the remaining color to RED if battery is below 25%
if (E.getBattery() > 25)
flip(40,100);
else
flip_red(40,100);
}
function draw() {
var d = new Date();
var da = d.toString().split(" ");
var time = da[4].substr(0,5);
g.clearRect(0, 30, 239, 99);
g.setColor(1,1,1);
g.setFontAlign(0, -1);
g.setFont("Vector", 80);
g.drawString(time, 120, 30, true);
drawSteps();
}
function getSteps() {
if (stepsWidget() !== undefined)
return stepsWidget().getSteps();
return "-";
}
function stepsWidget() {
if (WIDGETS.activepedom !== undefined) {
return WIDGETS.activepedom;
} else if (WIDGETS.wpedom !== undefined) {
return WIDGETS.wpedom;
}
return undefined;
}
// handle switch display on by pressing BTN1
Bangle.on('lcdPower', function(on) {
if (on) draw();
});
g.reset();
g.clear();
Bangle.loadWidgets();
Bangle.drawWidgets();
setInterval(draw, 15000); // refresh every 15s
draw();
setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"});

1
apps/stepo/icon.js Normal file
View File

@ -0,0 +1 @@
require("heatshrink").decompress(atob("mEwwkDEkEF5nMoUhiAVSAAUikUhCyYwBDBwWGC4YYMCwxHCAAUgCxEMCw3CC4kiPg5FF4tVgEBiIXEJI4uE4oKEgMSGBQWD4BTHGBIuDFooxEDAYJErgXCqCbJgSSHFxhJFJAZGDFxQABPQYXGCxZhESIReCRhBIIMARGPJAgXFCxqRDPAMFC6JgDOwalMMAwXDOxwXZPAUQC/4X/ABcs5jXVCQPCgEFAgPMCxwSC4gcDC55CCC4tQC5tcOQgFFLxoRDGoRINOIZBCC4ZIMFA4GCVJgPHMAQwLFwZwEBAYwJLoZvGBIaSIBgYlGGAYLHBQZVHHQgYBqoIBqoJFNRYAKQhIWMfpRJFAArLMDBIWMDBIWODIb3CCqIAQA="))

BIN
apps/stepo/screenshot1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
apps/stepo/screenshot2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

7
apps/stepo/stepo.info.js Normal file
View File

@ -0,0 +1,7 @@
require("Storage").write("stepo.info",{
"id":"stepo",
"name":"Stepometer Clock",
"src":"stepo.app.js",
"icon":"stepo.img",
"type":"clock"
});

BIN
apps/stepo/stepo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB