Skip to content

Commit 0fb3228

Browse files
author
thyttan
committed
Merge remote-tracking branch 'NoobEjby/bttfclock' into app-loader
2 parents 6e61d59 + 848e62b commit 0fb3228

File tree

7 files changed

+287
-0
lines changed

7 files changed

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Back to the future Clock
2+
3+
![](bttf_screenshot.png)
4+
5+
A watchface inspierd by <a target="_blank" href="https://apps.garmin.com/apps/d181bcf9-5421-42a5-b460-863e5e76d798">this garmin watchface</a>.<br/>
6+
7+
## Todo
8+
9+
- Improving quality of Fonts.
10+
- More status icons.
11+
- A way to change step golas.
12+
- Improving bangle app performances (using functions for images and specialized array).
13+
14+
## Functionalities
15+
16+
- Current time
17+
- Current day and month
18+
- Steps
19+
- Battery
20+
- Step goal
21+
- Bluetooth connected icon
22+
23+
## Screenshots
24+
Clock:<br/>
25+
26+
27+
## Usage
28+
29+
30+
## Links
31+
### code ispired by
32+
advCasioBangleClock <a target="_blank" href="https://github.com/dotgreg/advCasioBangleClock">https://github.com/dotgreg/advCasioBangleClock</a>
33+
34+
93dub <a target="_blank" href="https://github.com/espruino/BangleApps/tree/master/apps/93dub">https://github.com/espruino/BangleApps/tree/master/apps/93dub</a>
35+
36+
### Creator
37+
<a target="_blank" href="https://github.com/NoobEjby">https://github.com/NoobEjby</a>

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)