Skip to content

Commit ec51398

Browse files
committed
init
1 parent d376a7a commit ec51398

File tree

7 files changed

+252
-0
lines changed

7 files changed

+252
-0
lines changed
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
require("Font8x16").add(Graphics);
2+
require("Font7x11Numeric7Seg").add(Graphics);
3+
require("Font5x7Numeric7Seg").add(Graphics);
4+
require("Font5x9Numeric7Seg").add(Graphics);
5+
require("Font4x5").add(Graphics);
6+
7+
8+
const width = g.getWidth();
9+
const height = g.getHeight();
10+
const timeTextY = 4;
11+
const timeDataY = timeTextY+19;
12+
const DateTextY = 48;
13+
const DateDataY = DateTextY+19;
14+
const stepGoalBatTextY = 100;
15+
const stepGoalBatdataY = stepGoalBatTextY+19;
16+
const statusTextY = 140;
17+
const statusDataY = statusTextY+19;
18+
let stepGoal = 7000;
19+
let steps = 0;
20+
21+
22+
let bOn = require("heatshrink").decompress(atob("iEQwYROg3AAokYAgUMg0DAoUBwwFDgE2CIYdHAogREDoopFGoodGABI="));
23+
24+
let bOff = require("heatshrink").decompress(atob("iEQwYLIgwFF4ADBgYFBjAKCsEGBAIABhgFEgOA7AdDmApKmwpCC4OGFIYjFGoVgIIkMEZAAD"));
25+
26+
27+
28+
//the following 2 sections are used from waveclk to schedule minutely updates
29+
// timeout used to update every minute
30+
var drawTimeout;
31+
32+
// schedule a draw for the next minute
33+
function queueDraw() {
34+
if (drawTimeout) clearTimeout(drawTimeout);
35+
drawTimeout = setTimeout(function() {
36+
drawTimeout = undefined;
37+
draw();
38+
}, 60000 - (Date.now() % 60000));
39+
}
40+
41+
function getSteps() {
42+
steps = Bangle.getHealthStatus("day").steps;
43+
}
44+
45+
function drawBackground() {
46+
//g.setBgColor(1,1,1);
47+
g.setBgColor('#555555');
48+
g.setColor(1,1,1);
49+
g.clear();
50+
//g.drawImage(imgBg,0,0);
51+
g.reset();
52+
}
53+
function drawBlackBox() {
54+
g.reset();
55+
g.setBgColor(1,0,0);
56+
g.setColor(0,0,0);
57+
58+
//Hour, Min and Sec
59+
g.fillRect(50, timeDataY,50+33,timeDataY+22);
60+
g.fillRect(90, timeDataY,90+33, timeDataY+22);
61+
g.fillRect(128, timeDataY+8,130+24, timeDataY+8+14);
62+
//Day, Month, Day and Year
63+
g.fillRect(9, DateDataY,9+24, DateDataY+15);
64+
g.fillRect(42, DateDataY,42+40, DateDataY+15);
65+
g.fillRect(91, DateDataY,91+24, DateDataY+15);
66+
g.fillRect(124, DateDataY,124+43, DateDataY+15);
67+
//Present day
68+
g.fillRect(60, 86,60+47, 86+7);
69+
//Middle line
70+
g.drawLine(0,95,176,95);
71+
//Step and bat
72+
g.fillRect(3, stepGoalBatdataY-1, 62, stepGoalBatdataY+15);
73+
g.fillRect(121, stepGoalBatdataY-1, 150, stepGoalBatdataY+15);
74+
75+
//Status
76+
g.fillRect(62, statusDataY-1, 62+49, statusDataY+15);
77+
}
78+
function drawGoal() {
79+
var goal = stepGoal <= steps;
80+
g.reset();
81+
g.setColor(0,0,0);
82+
83+
g.fillRect(84, stepGoalBatdataY-1, 92, stepGoalBatdataY+15);
84+
85+
if (goal){
86+
g.reset();
87+
g.setColor(0,1,0);
88+
g.fillRect(84, stepGoalBatdataY, 92, stepGoalBatdataY+7);
89+
} else {
90+
g.reset();
91+
g.setColor(1,0,0);
92+
g.fillRect(84, stepGoalBatdataY+7, 92, stepGoalBatdataY+14);
93+
}
94+
}
95+
function drawRedkBox() {
96+
g.reset();
97+
g.setBgColor(1,0,0);
98+
g.setColor(1,0,0);
99+
//Hour, Min and Sec
100+
g.fillRect(50, timeTextY,50+33,timeTextY+15);
101+
g.fillRect(90, timeTextY,90+33, timeTextY+15);
102+
g.fillRect(128, timeTextY+8,130+24, timeTextY+8+15);
103+
//Day, Month, Day and Year
104+
g.fillRect(9, DateTextY,9+24, DateTextY+15);
105+
g.fillRect(42, DateTextY,42+40, DateTextY+15);
106+
g.fillRect(91, DateTextY,91+24, DateTextY+15);
107+
g.fillRect(124, DateTextY,124+43, DateTextY+15);
108+
//Step, Goal and Bat
109+
g.fillRect(2, stepGoalBatTextY,2+61, stepGoalBatTextY+15);
110+
g.fillRect(70, stepGoalBatTextY,72+33, stepGoalBatTextY+15);
111+
g.fillRect(120, stepGoalBatTextY,120+31, stepGoalBatTextY+15);
112+
//Status
113+
g.fillRect(62, statusTextY,62+49, statusTextY+15);
114+
}
115+
116+
function draw(){
117+
drawBackground();
118+
getSteps();
119+
drawBlackBox();
120+
drawRedkBox();
121+
drawGoal();
122+
var date = new Date();
123+
var h = date.getHours(), m = date.getMinutes(), s = date.getSeconds();
124+
var d = date.getDate(), w = date.getDay(), y = date.getFullYear();
125+
126+
if (h<10) {
127+
h = ("0"+h).substr(-2);
128+
}
129+
if (m<10) {
130+
m = ("0"+m).substr(-2);
131+
}
132+
if (s<10) {
133+
s = ("0"+s).substr(-2);
134+
}
135+
if (d<10) {
136+
d = ("0"+d).substr(-2);
137+
}
138+
139+
g.reset();
140+
g.setBgColor(1,0,0);
141+
g.setColor(1,1,1);
142+
//Draw text
143+
//g.drawRect(x1, y1, x2, y2);
144+
g.setFont("8x16");
145+
g.drawString('HOUR', 51, timeTextY+1);
146+
g.drawString('MIN', 96, timeTextY+1);
147+
g.drawString('SEC', 130, timeTextY+9);
148+
149+
g.drawString('DAY', 10, DateTextY+1);
150+
g.drawString('MONTH', 43, DateTextY+1);
151+
g.drawString('DAY', 92, DateTextY+1);
152+
g.drawString(' YEAR ', 125, DateTextY+1);
153+
154+
g.drawString('STEPS', 15, stepGoalBatTextY+1);
155+
g.drawString('GOAL', 72, stepGoalBatTextY+1);
156+
g.drawString(' BAT ', 120, stepGoalBatTextY+1);
157+
g.drawString('STATUS', 64, statusTextY+1);
158+
159+
//time
160+
g.reset();
161+
g.setBgColor(0,0,0);
162+
g.setColor(1,0,0);
163+
g.setFont("5x7Numeric7Seg",2);
164+
g.drawString(s, 131, timeDataY+8);
165+
g.setFont("7x11Numeric7Seg",2);
166+
g.drawString(h, 53, timeDataY);
167+
g.drawString(m, 93, timeDataY);
168+
//Date
169+
g.reset();
170+
g.setBgColor(0,0,0);
171+
g.setColor(0,1,0);
172+
g.setFont("5x7Numeric7Seg",2);
173+
g.drawString(d, 13, DateDataY);
174+
g.drawString(y, 127, DateDataY);
175+
g.setFont("8x16");
176+
g.drawString(require("locale").month(new Date(), 2).toUpperCase(), 52, DateDataY);
177+
g.drawString(require("locale").dow(new Date(), 2).toUpperCase(), 92, DateDataY);
178+
179+
180+
//status
181+
g.reset();
182+
g.setBgColor(0,0,0);
183+
g.setColor(1,1,0);
184+
g.setFont("5x7Numeric7Seg",2);
185+
var step = steps;
186+
var stepl = steps.toString().length;
187+
var stepdDrawX = 4+(36-(stepl*6))+(4*(6-stepl));
188+
g.drawString(step, stepdDrawX, stepGoalBatdataY);
189+
var bat = E.getBattery();
190+
var batl = bat.toString().length;
191+
var batDrawX = 122+(18-(batl*6))+(4*(3-batl));
192+
g.drawString(bat, batDrawX, stepGoalBatdataY);
193+
194+
//status
195+
var b = bOff;
196+
if (NRF.getSecurityStatus().connected){
197+
b = bOn;
198+
}
199+
g.drawImage(b, 64, statusDataY);
200+
201+
202+
g.reset();
203+
g.setBgColor(0,0,0);
204+
g.setColor(1,1,1);
205+
g.setFont("4x5");
206+
g.drawString('Present day', 62, 88);
207+
208+
queueDraw();
209+
}
210+
211+
/**
212+
* This watch is mostly dark, it does not make sense to respect the
213+
* light theme as you end up with a white strip at the top for the
214+
* widgets and black watch. So set the colours to the dark theme.
215+
*
216+
*/
217+
g.setTheme({bg:"#000",fg:"#fff",dark:true}).clear();
218+
//draw();
219+
220+
//the following section is also from waveclk
221+
Bangle.on('lcdPower',on=>{
222+
if (on) {
223+
draw(); // draw immediately, queue redraw
224+
} else { // stop draw timer
225+
if (drawTimeout) clearTimeout(drawTimeout);
226+
drawTimeout = undefined;
227+
}
228+
});
229+
Bangle.setUI("clock");
230+
// Load widgets, but don't show them
231+
Bangle.loadWidgets();
232+
require("widget_utils").swipeOn(); // hide widgets, make them visible with a swipe
233+
g.clear(1);
234+
draw();

apps/bttfclock/ChangeLog.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.01: Back to the future clock first version

apps/bttfclock/README.md

Whitespace-only changes.

apps/bttfclock/bttf_clock_icon.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/bttfclock/bttf_icon.png

6.49 KB
Loading

apps/bttfclock/bttf_screenshot.png

4.04 KB
Loading

apps/bttfclock/metadata.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"id": "bttfclock",
3+
"name": "Back To The Future",
4+
"version": "0.01",
5+
"description": "My favorit Garmin watchface",
6+
"icon": "bttf_clock.png",
7+
"screenshots": [{"url":"bttf_screenshot.png"}],
8+
"type": "clock",
9+
"tags": "clock",
10+
"supports": ["BANGLEJS2"],
11+
"allow_emulator": true,
12+
"storage": [
13+
{"name":"BackToTheFuture.app.js","url":"BackToTheFuture.app.js"},
14+
{"name":"bttfclock.img","url":"bttf_clock_icon.js","evaluate":true}
15+
]
16+
}

0 commit comments

Comments
 (0)