tiro-notes 0.51.15 → 0.51.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"static/js/7.72c1f2ed.chunk.js": "/static/js/7.72c1f2ed.chunk.js",
|
|
11
11
|
"static/js/8.6e1aa7d7.chunk.js": "/static/js/8.6e1aa7d7.chunk.js",
|
|
12
12
|
"static/js/9.93889121.chunk.js": "/static/js/9.93889121.chunk.js",
|
|
13
|
-
"main.js": "/static/js/main.
|
|
13
|
+
"main.js": "/static/js/main.feb7293b.chunk.js",
|
|
14
14
|
"runtime-main.js": "/static/js/runtime-main.15586395.js",
|
|
15
15
|
"static/css/12.394917b1.chunk.css": "/static/css/12.394917b1.chunk.css",
|
|
16
16
|
"static/js/12.da359bd1.chunk.js": "/static/js/12.da359bd1.chunk.js",
|
|
@@ -138,6 +138,6 @@
|
|
|
138
138
|
"static/js/runtime-main.15586395.js",
|
|
139
139
|
"static/css/12.394917b1.chunk.css",
|
|
140
140
|
"static/js/12.da359bd1.chunk.js",
|
|
141
|
-
"static/js/main.
|
|
141
|
+
"static/js/main.feb7293b.chunk.js"
|
|
142
142
|
]
|
|
143
143
|
}
|
package/client/b.js
ADDED
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
const storage = require('Storage');
|
|
2
|
+
|
|
3
|
+
require("Font6x12").add(Graphics);
|
|
4
|
+
require("Font6x8").add(Graphics);
|
|
5
|
+
require("Font8x12").add(Graphics);
|
|
6
|
+
require("Font7x11Numeric7Seg").add(Graphics);
|
|
7
|
+
|
|
8
|
+
function bigThenSmall(big, small, x, y) {
|
|
9
|
+
g.setFont("7x11Numeric7Seg", 2);
|
|
10
|
+
g.drawString(big, x, y);
|
|
11
|
+
x += g.stringWidth(big);
|
|
12
|
+
g.setFont("8x12");
|
|
13
|
+
g.drawString(small, x, y);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
// encode https://www.espruino.com/Image+Converter
|
|
18
|
+
// best params > compress + nearest color + optimal 4b
|
|
19
|
+
// decode g.clear(1).drawImage(img).dump();
|
|
20
|
+
function getClockBg() {
|
|
21
|
+
return require("heatshrink").decompress(atob("icVgf/ABv8v4DBx4CB+PH8F+nAGB48fwEHBwXjxwqBuPH//+nAGBBwIjCAwI2D/wGBgIyDI4QGDwAGBHYX/4AGBn4UFEYQpCEYYpCAAMfMhP4FIgABwJ8OEBIA=="));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
// sun, cloud, rain, thunder
|
|
26
|
+
var iconsWeather = [
|
|
27
|
+
require("heatshrink").decompress(atob("i8Ugf/ACcfA434BA/AAwsAv0/8F/BAcDwEHHIpECFI3wn4GC/gOC+PAGoXggEH/+ODQgXBGQv/wAbBBAnguEACIn4gfxI4JXFwJmG/kPBA3jSynw")), require("heatshrink").decompress(atob("i0Ugf/AEXggIGE/0A/kPBAmBCIN/A4Y8CgAICwEHBYoUE/ACCj4sDn4CBC4YyDwBrDCgYA3A")), require("heatshrink").decompress(atob("h8Rgf/AAuBAgf8h4FDCwM/AgPA/gFC/0HgEBBQPwnEfDoWAg4jC/gOCAoQmBAQXjFIV//8f//4IQP4j/+gAIB4EcHII4CAoI+DLQJXF/AA==")), require("heatshrink").decompress(atob("h0Pgf/AA8fAYX+g4EC8EBAgXADAeAgAECgAOC/wrCDQIOBBYfwgAaC/kAn4EB/EAv4aDHAeBIg38"))
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
function getBackgroundImage() {
|
|
32
|
+
return require("heatshrink").decompress(atob("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"));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
////////////////////////////
|
|
39
|
+
// SAVING HEALTH DATA
|
|
40
|
+
//
|
|
41
|
+
let minuteCounter = 0;
|
|
42
|
+
let cPeriodTrack = {};
|
|
43
|
+
// { "heart": [10,20,30,40,50,60, etc....] }
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
function deduceSleep(hrm, hour, movement){
|
|
47
|
+
// ds = deep sleep // ls = light sleep
|
|
48
|
+
let result = " "
|
|
49
|
+
// ds = < 60 // ls = < 74
|
|
50
|
+
let hrmStatus = "x" // "x"|"ds"|"ls"
|
|
51
|
+
if (hrm !== 0) {
|
|
52
|
+
if (hrm < 60) hrmStatus = "ds"
|
|
53
|
+
else if (hrm < 74) hrmStatus = "ls"
|
|
54
|
+
else hrmStatus = "x"
|
|
55
|
+
}
|
|
56
|
+
// ds = < 150 // ls = < 300
|
|
57
|
+
let movementStatus = "x"
|
|
58
|
+
if (movement !== 0) {
|
|
59
|
+
if (movement < 150) movementStatus = "ds"
|
|
60
|
+
else if (movement < 300) movementStatus = "ls"
|
|
61
|
+
else movementStatus = "x"
|
|
62
|
+
}
|
|
63
|
+
// only run if currentHour < 11 or currentHour > 20
|
|
64
|
+
if (hour > 20 || hour < 11) {
|
|
65
|
+
|
|
66
|
+
if (movementStatus === "ls") result = "-"
|
|
67
|
+
if (movementStatus === "ds") result = "_"
|
|
68
|
+
|
|
69
|
+
if (movementStatus === "ls" && hrmStatus === "ls") result = "-"
|
|
70
|
+
if (movementStatus === "ds" && hrmStatus === "ds") result = "_"
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return result
|
|
74
|
+
}
|
|
75
|
+
function execEvery10m() {
|
|
76
|
+
let healthNow = Bangle.getHealthStatus();
|
|
77
|
+
if (!cPeriodTrack["heart"]) cPeriodTrack["heart"] = [];
|
|
78
|
+
if (!cPeriodTrack["movement"]) cPeriodTrack["movement"] = [];
|
|
79
|
+
if (!cPeriodTrack["sleep"]) cPeriodTrack["sleep"] = "";
|
|
80
|
+
cPeriodTrack["heart"].push(healthNow.bpm);
|
|
81
|
+
cPeriodTrack["movement"].push(healthNow.movement);
|
|
82
|
+
|
|
83
|
+
let currH = formatDate("h");
|
|
84
|
+
cPeriodTrack["sleep"] += deduceSleep(healthNow.bpm, currH, healthNow.movement);
|
|
85
|
+
}
|
|
86
|
+
function execEveryXHours() {
|
|
87
|
+
// get current month data
|
|
88
|
+
let monthJson = getHistDataJson();
|
|
89
|
+
let currD = formatDate("d");
|
|
90
|
+
let currH = formatDate("h");
|
|
91
|
+
if (!monthJson || !monthJson["heart"]) monthJson = { "heart": {}, "steps": {}, "movement": {}, "sleep": {} };
|
|
92
|
+
if (!monthJson["steps"]) monthJson["steps"] = {};
|
|
93
|
+
if (!monthJson["movement"]) monthJson["movement"] = {};
|
|
94
|
+
if (!monthJson["sleep"]) monthJson["sleep"] = {};
|
|
95
|
+
|
|
96
|
+
if (!monthJson["heart"][currD]) monthJson["heart"][currD] = {};
|
|
97
|
+
if (!monthJson["movement"][currD]) monthJson["movement"][currD] = {};
|
|
98
|
+
if (!monthJson["sleep"][currD]) monthJson["sleep"][currD] = {};
|
|
99
|
+
|
|
100
|
+
monthJson["heart"][currD][currH] = cPeriodTrack["heart"]
|
|
101
|
+
monthJson["movement"][currD][currH] = cPeriodTrack["movement"]
|
|
102
|
+
monthJson["sleep"][currD][currH] = cPeriodTrack["sleep"]
|
|
103
|
+
|
|
104
|
+
cPeriodTrack = {}; // reset hour data
|
|
105
|
+
steps = Bangle.getHealthStatus("day").steps;
|
|
106
|
+
monthJson["steps"][currD] = steps
|
|
107
|
+
|
|
108
|
+
setHistDataJson(monthJson);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
// FOR STORING HEALTH DATA EVERY HOURS 6*24 = 144
|
|
113
|
+
function formatDate(format) {
|
|
114
|
+
const date = new Date();
|
|
115
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
116
|
+
const dayInt = parseInt(day);
|
|
117
|
+
const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed
|
|
118
|
+
const year = String(date.getFullYear()).slice(-2); // Last 2 digits of year
|
|
119
|
+
const hourInt = date.getHours();
|
|
120
|
+
if (format === "mm-yy") return `${month}-${year}`;
|
|
121
|
+
if (format === "dd-mm-yy") return `${day}-${month}-${year}`;
|
|
122
|
+
if (format === "mmyy") return `${month}${year}`;
|
|
123
|
+
if (format === "d") return dayInt;
|
|
124
|
+
if (format === "h") return hourInt;
|
|
125
|
+
}
|
|
126
|
+
// will look like { "heart": {"1":{"1":[70,20,30],"2":[...]},"2":{...}}} }
|
|
127
|
+
function getHistFilePath(){
|
|
128
|
+
let currentMMYY = formatDate("mmyy");
|
|
129
|
+
return `advcasio.${currentMMYY}.json`;
|
|
130
|
+
}
|
|
131
|
+
function getHistDataJson(){
|
|
132
|
+
var res = { "heart": {}, "steps": {} };
|
|
133
|
+
try { res = storage.readJSON(getHistFilePath()); } catch(ex) { return res; }
|
|
134
|
+
return res;
|
|
135
|
+
}
|
|
136
|
+
function setHistDataJson(resJson){
|
|
137
|
+
try { res = storage.writeJSON(getHistFilePath(), resJson); } catch(ex) { return res; }
|
|
138
|
+
return res;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
// schedule a draw for the next minute
|
|
152
|
+
let rocketInterval;
|
|
153
|
+
var drawTimeout;
|
|
154
|
+
|
|
155
|
+
function queueDraw() {
|
|
156
|
+
if (drawTimeout) clearTimeout(drawTimeout);
|
|
157
|
+
drawTimeout = setTimeout(function() {
|
|
158
|
+
minuteCounter++;
|
|
159
|
+
|
|
160
|
+
// for testing purposes
|
|
161
|
+
// execEvery10m();
|
|
162
|
+
// execEvery10m();
|
|
163
|
+
// execEvery10m();
|
|
164
|
+
// execEvery10m();
|
|
165
|
+
// execEvery10m();
|
|
166
|
+
// execEvery10m();
|
|
167
|
+
// execEvery10m();
|
|
168
|
+
// execEvery10m();
|
|
169
|
+
// execEvery10m();
|
|
170
|
+
// execEvery10m();
|
|
171
|
+
// execEveryXHours();
|
|
172
|
+
|
|
173
|
+
if (minuteCounter % 10 === 0) {
|
|
174
|
+
execEvery10m();
|
|
175
|
+
}
|
|
176
|
+
// every 6 hours
|
|
177
|
+
if (minuteCounter % (6*60) === 0) {
|
|
178
|
+
execEveryXHours();
|
|
179
|
+
minuteCounter = 0;
|
|
180
|
+
}
|
|
181
|
+
drawTimeout = undefined;
|
|
182
|
+
draw();
|
|
183
|
+
}, 60000 - (Date.now() % 60000));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
function clearIntervals() {
|
|
190
|
+
if (rocketInterval) clearInterval(rocketInterval);
|
|
191
|
+
rocketInterval = undefined;
|
|
192
|
+
if (drawTimeout) clearTimeout(drawTimeout);
|
|
193
|
+
drawTimeout = undefined;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
////////////////////////////////////////////
|
|
197
|
+
// TIMER FUNC
|
|
198
|
+
//
|
|
199
|
+
var timer_time = 0;
|
|
200
|
+
var alreadyListenTouch = false;
|
|
201
|
+
function initTouchTimer () {
|
|
202
|
+
if (alreadyListenTouch) return;
|
|
203
|
+
alreadyListenTouch = true;
|
|
204
|
+
|
|
205
|
+
Bangle.on('swipe', function(dirX,dirY) {
|
|
206
|
+
if (canTouch === false) return;
|
|
207
|
+
var njson = getDataJson();
|
|
208
|
+
if (!njson) return;
|
|
209
|
+
|
|
210
|
+
if (dirX === -1) {
|
|
211
|
+
timer_time = 0;
|
|
212
|
+
delete njson.timer;
|
|
213
|
+
setDataJson(njson);
|
|
214
|
+
}
|
|
215
|
+
else if (dirX === 1) {
|
|
216
|
+
var now = new Date().getTime();
|
|
217
|
+
njson.timer = now + (timer_time * 1000 * 60);
|
|
218
|
+
Bangle.setLocked(true);
|
|
219
|
+
setDataJson(njson);
|
|
220
|
+
Bangle.buzz(200, 0);
|
|
221
|
+
timer_time = 0;
|
|
222
|
+
}
|
|
223
|
+
else if (dirY === -1) {
|
|
224
|
+
if (canTouch === false || njson.timer) return;
|
|
225
|
+
timer_time = timer_time + 5;
|
|
226
|
+
}
|
|
227
|
+
else if (dirY === 1) {
|
|
228
|
+
if (canTouch === false || njson.timer) return;
|
|
229
|
+
timer_time = timer_time - 5;
|
|
230
|
+
}
|
|
231
|
+
draw();
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
setTimeout(() => {
|
|
235
|
+
initTouchTimer ();
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
function getTimerTime() {
|
|
239
|
+
// if timer_time !== -1, take it
|
|
240
|
+
if (timer_time !== 0) {
|
|
241
|
+
return timer_time + "m";
|
|
242
|
+
} else {
|
|
243
|
+
// else, show diff between njsontime and now
|
|
244
|
+
var njson = getDataJson();
|
|
245
|
+
if (!njson) return false;
|
|
246
|
+
var now = new Date().getTime();
|
|
247
|
+
var diff = Math.round((njson.timer - now) / (1000 * 60));
|
|
248
|
+
//console.log(123, njson, diff, now, njson.timer - now);
|
|
249
|
+
if (diff > 0) return diff + "m";
|
|
250
|
+
else if (njson.timer) {
|
|
251
|
+
Bangle.buzz(1000, 1);
|
|
252
|
+
console.log("END OF TIMER");
|
|
253
|
+
delete njson.timer;
|
|
254
|
+
setDataJson(njson);
|
|
255
|
+
return false;
|
|
256
|
+
} else {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
// if diff is <0, delete timer from json
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function drawTimer() {
|
|
263
|
+
//g.drawString(getTimerTime(), 100, 100);
|
|
264
|
+
g.setFont("8x12", 2);
|
|
265
|
+
var t = 97;
|
|
266
|
+
var l = 105;
|
|
267
|
+
var time = getTimerTime();
|
|
268
|
+
if (time || timer_time !== 0) g.drawString(time, l+5, t+0);
|
|
269
|
+
if (time && timer_time === 0) g.drawImage(getClockBg(), l-20, t+2, { scale: 1 });
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
////////////////////////////////////////////
|
|
274
|
+
// DATA READING
|
|
275
|
+
//
|
|
276
|
+
function getDataJson(){
|
|
277
|
+
var res = {"tasks":"", "weather":[]};
|
|
278
|
+
try { res = storage.readJSON('advcasio.data.json'); } catch(ex) { return res; }
|
|
279
|
+
return res;
|
|
280
|
+
}
|
|
281
|
+
function setDataJson(resJson){
|
|
282
|
+
try { res = storage.writeJSON('advcasio.data.json', resJson); } catch(ex) { return res; }
|
|
283
|
+
return res;
|
|
284
|
+
}
|
|
285
|
+
var dataJson = getDataJson();
|
|
286
|
+
|
|
287
|
+
////////////////////////////////////////////
|
|
288
|
+
// WEATHER!
|
|
289
|
+
//
|
|
290
|
+
function drawWeather(arr) {
|
|
291
|
+
if (!arr || !Array.isArray(arr)) return; // Exit if invalid
|
|
292
|
+
g.setFont("6x8", 1);
|
|
293
|
+
var p = { l: 8, tText: 40, tIcon: 20, decal: 25 };
|
|
294
|
+
var today = new Date().getTime();
|
|
295
|
+
var yesterday = today - (1000 * 60 * 60 * 24);
|
|
296
|
+
var j = 0;
|
|
297
|
+
|
|
298
|
+
for (var i = 0; i < arr.length; i++) {
|
|
299
|
+
if (!arr[i] || arr[i].length < 3) continue; // Skip malformed entries
|
|
300
|
+
var iconIndex = arr[i][1];
|
|
301
|
+
if (iconIndex < 0 || iconIndex >= iconsWeather.length) {
|
|
302
|
+
iconIndex = 0; // Fallback to first icon
|
|
303
|
+
}
|
|
304
|
+
if (arr[i][2] > yesterday && j < 4) {
|
|
305
|
+
g.drawString(arr[i][0], p.l + p.decal * j + 4, p.tText);
|
|
306
|
+
g.drawImage(iconsWeather[iconIndex], p.l + p.decal * j, p.tIcon, { scale: 1 });
|
|
307
|
+
j++;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
////////////////////////////////////////////
|
|
313
|
+
// DRAWING FUNCS
|
|
314
|
+
//
|
|
315
|
+
|
|
316
|
+
function test() {
|
|
317
|
+
let img = getBackgroundImage();
|
|
318
|
+
g.clear(1).drawImage(img).dump();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function drawTasks(str) {
|
|
322
|
+
g.setFont("6x8", 1);
|
|
323
|
+
var t = 57;
|
|
324
|
+
var l = 0;
|
|
325
|
+
g.drawString(str, l+5, t+0);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function drawSteps() {
|
|
329
|
+
g.setFont("8x12", 2);
|
|
330
|
+
var t = 132;
|
|
331
|
+
var l = 150;
|
|
332
|
+
g.drawString(getSteps(), l+5, t+0);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function drawHistSleep() {
|
|
336
|
+
if (!cPeriodTrack || !cPeriodTrack["sleep"]) return "";
|
|
337
|
+
let lastMeasures = [];
|
|
338
|
+
if (cPeriodTrack["sleep"].length > 8) { lastMeasures = cPeriodTrack["sleep"].slice(-8); } else { lastMeasures = cPeriodTrack["sleep"]; }
|
|
339
|
+
return lastMeasures
|
|
340
|
+
}
|
|
341
|
+
function drawHeartHist() {
|
|
342
|
+
if (!cPeriodTrack || !cPeriodTrack["heart"]) return "";
|
|
343
|
+
let lastMeasures = [];
|
|
344
|
+
if (cPeriodTrack["heart"].length > 8) { lastMeasures = cPeriodTrack["heart"].slice(-8); } else { lastMeasures = cPeriodTrack["heart"]; }
|
|
345
|
+
let result = ""
|
|
346
|
+
for (let i = 0; i < lastMeasures.length; i++) {
|
|
347
|
+
if (lastMeasures[i] > 120) result += "*";
|
|
348
|
+
else if (lastMeasures[i] === 100) result += "=";
|
|
349
|
+
else if (lastMeasures[i] < 80) result += "-";
|
|
350
|
+
else result += ".";
|
|
351
|
+
}
|
|
352
|
+
return result
|
|
353
|
+
}
|
|
354
|
+
function drawText(text,x,y,fontSize) {
|
|
355
|
+
g.setFont(fontSize, 1);
|
|
356
|
+
g.drawString(text, x+5, y+0);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function drawHeartandSleep() {
|
|
360
|
+
let d = Bangle.getHealthStatus();
|
|
361
|
+
let out = d.bpm;
|
|
362
|
+
if (d.bpm < 1) out = "--";
|
|
363
|
+
g.setFont("8x12", 2);
|
|
364
|
+
g.drawString(out , 18, 130);
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
let hist = drawHeartHist();
|
|
368
|
+
drawText(hist, 0, 150, "6x8");
|
|
369
|
+
|
|
370
|
+
let histSleep = drawHistSleep();
|
|
371
|
+
drawText(histSleep, 0, 120, "6x8");
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function drawClock() {
|
|
377
|
+
g.setFont("7x11Numeric7Seg", 3);
|
|
378
|
+
g.clearRect(80, 57, 170, 96);
|
|
379
|
+
g.setColor(255, 255, 255);
|
|
380
|
+
var l = 77;
|
|
381
|
+
var t = 57;
|
|
382
|
+
var w = 170;
|
|
383
|
+
var h = 116;
|
|
384
|
+
g.drawRect(l, t, w, h);
|
|
385
|
+
g.fillRect(l, t, w, h);
|
|
386
|
+
g.setColor(0, 0, 0);
|
|
387
|
+
g.drawString(require("locale").time(new Date(), 1), 76, 60);
|
|
388
|
+
|
|
389
|
+
// day
|
|
390
|
+
//g.setFont("8x12", 1);
|
|
391
|
+
//g.setFont("9x18", 1);
|
|
392
|
+
//g.drawString(require("locale").dow(new Date(), 2).toUpperCase(), 25, 136);
|
|
393
|
+
// g.setFont("8x12", 2);
|
|
394
|
+
// g.drawString(require("locale").dow(new Date(), 2), 18, 130);
|
|
395
|
+
|
|
396
|
+
// month
|
|
397
|
+
g.setFont("8x12");
|
|
398
|
+
g.drawString(require("locale").month(new Date(), 2).toUpperCase(), 80, 127);
|
|
399
|
+
|
|
400
|
+
// day nb
|
|
401
|
+
g.setFont("8x12", 2);
|
|
402
|
+
const time = new Date().getDate();
|
|
403
|
+
g.drawString(time < 10 ? "0" + time : time, 78, 137);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function drawBattery() {
|
|
407
|
+
bigThenSmall(E.getBattery(), "%", 140, 23);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
function getSteps() {
|
|
412
|
+
var steps = 0;
|
|
413
|
+
try{
|
|
414
|
+
if (WIDGETS.wpedom !== undefined) {
|
|
415
|
+
steps = WIDGETS.wpedom.getSteps();
|
|
416
|
+
} else if (WIDGETS.activepedom !== undefined) {
|
|
417
|
+
steps = WIDGETS.activepedom.getSteps();
|
|
418
|
+
} else {
|
|
419
|
+
steps = Bangle.getHealthStatus("day").steps;
|
|
420
|
+
}
|
|
421
|
+
} catch(ex) {
|
|
422
|
+
// In case we failed, we can only show 0 steps.
|
|
423
|
+
return "? k";
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
steps = Math.round(steps/1000);
|
|
427
|
+
return steps + "k";
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
function draw() {
|
|
432
|
+
|
|
433
|
+
// console.log("Draw called");
|
|
434
|
+
queueDraw();
|
|
435
|
+
|
|
436
|
+
g.reset();
|
|
437
|
+
g.clear();
|
|
438
|
+
g.setColor(255, 255, 255);
|
|
439
|
+
g.fillRect(0, 0, g.getWidth(), g.getHeight());
|
|
440
|
+
let background = getBackgroundImage();
|
|
441
|
+
g.drawImage(background, 0, 0, { scale: 1 });
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
g.setColor(0, 0, 0);
|
|
445
|
+
g.setFont("6x12");
|
|
446
|
+
if(dataJson && dataJson.weather) drawWeather(dataJson.weather);
|
|
447
|
+
if(dataJson && dataJson.tasks) drawTasks(dataJson.tasks);
|
|
448
|
+
|
|
449
|
+
g.setFontAlign(0,-1);
|
|
450
|
+
g.setFont("8x12", 2);
|
|
451
|
+
|
|
452
|
+
drawSteps();
|
|
453
|
+
g.setFontAlign(-1,-1);
|
|
454
|
+
drawClock();
|
|
455
|
+
drawHeartandSleep();
|
|
456
|
+
// test();
|
|
457
|
+
drawBattery();
|
|
458
|
+
drawTimer();
|
|
459
|
+
// Hide widgets
|
|
460
|
+
for (let wd of WIDGETS) {wd.draw=()=>{};wd.area="";}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// save batt power, does not seem to work although...
|
|
464
|
+
var canTouch = true;
|
|
465
|
+
Bangle.on("lcdPower", (on) => {
|
|
466
|
+
if (on) {
|
|
467
|
+
draw();
|
|
468
|
+
} else {
|
|
469
|
+
canTouch = false;
|
|
470
|
+
clearIntervals();
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
Bangle.on("lock", (locked) => {
|
|
476
|
+
clearIntervals();
|
|
477
|
+
draw();
|
|
478
|
+
if (!locked) {
|
|
479
|
+
canTouch = true;
|
|
480
|
+
} else {
|
|
481
|
+
canTouch = false;
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
// Load widgets, but don't show them
|
|
487
|
+
Bangle.loadWidgets();
|
|
488
|
+
Bangle.setUI("clock");
|
|
489
|
+
|
|
490
|
+
g.reset();
|
|
491
|
+
g.clear();
|
|
492
|
+
draw();
|
package/client/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><meta name="theme-color" content="#000000"/><title>Tiro</title><link href="/static/css/12.394917b1.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function a(a){for(var r,c,o=a[0],b=a[1],d=a[2],i=0,l=[];i<o.length;i++)c=o[i],Object.prototype.hasOwnProperty.call(n,c)&&n[c]&&l.push(n[c][0]),n[c]=0;for(r in b)Object.prototype.hasOwnProperty.call(b,r)&&(e[r]=b[r]);for(u&&u(a);l.length;)l.shift()();return f.push.apply(f,d||[]),t()}function t(){for(var e,a=0;a<f.length;a++){for(var t=f[a],r=!0,o=1;o<t.length;o++){var b=t[o];0!==n[b]&&(r=!1)}r&&(f.splice(a--,1),e=c(c.s=t[0]))}return e}var r={},n={11:0},f=[];function c(a){if(r[a])return r[a].exports;var t=r[a]={i:a,l:!1,exports:{}};return e[a].call(t.exports,t,t.exports,c),t.l=!0,t.exports}c.e=function(e){var a=[],t=n[e];if(0!==t)if(t)a.push(t[2]);else{var r=new Promise((function(a,r){t=n[e]=[a,r]}));a.push(t[2]=r);var f,o=document.createElement("script");o.charset="utf-8",o.timeout=120,c.nc&&o.setAttribute("nonce",c.nc),o.src=function(e){return c.p+"static/js/"+({}[e]||e)+"."+{0:"4ac3861a",1:"05eb3543",2:"7cf6642a",3:"06359356",4:"d2ba5d13",5:"5404a000",6:"fd04a339",7:"72c1f2ed",8:"6e1aa7d7",9:"93889121",13:"93fcf37e",14:"e311c46d",15:"b6574f61",16:"6b180369",17:"22c2c7b4",18:"f2c9665f",19:"ae8eb500",20:"77e43c39",21:"899d2566",22:"63c729c1",23:"673ada6f",24:"71c055dd",25:"be3c4b44",26:"cfaf27ca",27:"f13733d3",28:"8c6a3155",29:"722cb358",30:"48e01237",31:"9ea42fa4",32:"6563a6c1",33:"f93906e3",34:"5fa96d2d",35:"2a6b8626",36:"8372ab61",37:"05e6b840",38:"ef1e8b6e",39:"f6af19fe",40:"66e41aba",41:"84c439d8",42:"5ac2ef26",43:"4be36402",44:"f28a0ba3",45:"fc2fb432",46:"c2538eba",47:"69a0f6a8",48:"e47338c9",49:"d3efb6b1",50:"48d37962",51:"97c5b6b3",52:"ea08ba65",53:"94eea8d8",54:"a10b9a17",55:"72a882e4",56:"2b4182d6",57:"86f78960",58:"8024e82f",59:"658384b7",60:"07d8d79d",61:"33308e15",62:"5a0938d8",63:"db3bc219",64:"17ca596d",65:"d8e29d95",66:"120d73ff",67:"a9882580",68:"0fa490e2",69:"4b92413b",70:"3f605b88",71:"c3336ebb",72:"a5c9fab6",73:"1a2ba67f",74:"09e0f4a7",75:"73197bed",76:"dec671e4",77:"d53868dc",78:"903f8358",79:"df33598a",80:"eb252c0b",81:"956d9f28",82:"8ab70ef1",83:"6c9f5698",84:"2f98aaf3",85:"5a641049",86:"9510812d",87:"ff71caba",88:"ea121a9a",89:"36b34946",90:"b449c621",91:"8b0abe0e",92:"c3947b9d",93:"3fa57af0",94:"7d86d4ac",95:"8b60a77b",96:"dbc3a8ff",97:"4e9dc762",98:"a9e91c3f",99:"2468ced5",100:"be8f030a",101:"5abe87a7",102:"63129618",103:"bfbb050e",104:"d897c30a",105:"5a606996",106:"84aa441f",107:"501b9ba8",108:"9e2d03cf",109:"608f9256",110:"9318a94c"}[e]+".chunk.js"}(e);var b=new Error;f=function(a){o.onerror=o.onload=null,clearTimeout(d);var t=n[e];if(0!==t){if(t){var r=a&&("load"===a.type?"missing":a.type),f=a&&a.target&&a.target.src;b.message="Loading chunk "+e+" failed.\n("+r+": "+f+")",b.name="ChunkLoadError",b.type=r,b.request=f,t[1](b)}n[e]=void 0}};var d=setTimeout((function(){f({type:"timeout",target:o})}),12e4);o.onerror=o.onload=f,document.head.appendChild(o)}return Promise.all(a)},c.m=e,c.c=r,c.d=function(e,a,t){c.o(e,a)||Object.defineProperty(e,a,{enumerable:!0,get:t})},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.t=function(e,a){if(1&a&&(e=c(e)),8&a)return e;if(4&a&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(c.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&a&&"string"!=typeof e)for(var r in e)c.d(t,r,function(a){return e[a]}.bind(null,r));return t},c.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(a,"a",a),a},c.o=function(e,a){return Object.prototype.hasOwnProperty.call(e,a)},c.p="/",c.oe=function(e){throw console.error(e),e};var o=this["webpackJsonptiro-notes-client"]=this["webpackJsonptiro-notes-client"]||[],b=o.push.bind(o);o.push=a,o=o.slice();for(var d=0;d<o.length;d++)a(o[d]);var u=b;t()}([])</script><script src="/static/js/12.da359bd1.chunk.js"></script><script src="/static/js/main.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><meta name="theme-color" content="#000000"/><title>Tiro</title><link href="/static/css/12.394917b1.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function a(a){for(var r,c,o=a[0],b=a[1],d=a[2],i=0,l=[];i<o.length;i++)c=o[i],Object.prototype.hasOwnProperty.call(n,c)&&n[c]&&l.push(n[c][0]),n[c]=0;for(r in b)Object.prototype.hasOwnProperty.call(b,r)&&(e[r]=b[r]);for(u&&u(a);l.length;)l.shift()();return f.push.apply(f,d||[]),t()}function t(){for(var e,a=0;a<f.length;a++){for(var t=f[a],r=!0,o=1;o<t.length;o++){var b=t[o];0!==n[b]&&(r=!1)}r&&(f.splice(a--,1),e=c(c.s=t[0]))}return e}var r={},n={11:0},f=[];function c(a){if(r[a])return r[a].exports;var t=r[a]={i:a,l:!1,exports:{}};return e[a].call(t.exports,t,t.exports,c),t.l=!0,t.exports}c.e=function(e){var a=[],t=n[e];if(0!==t)if(t)a.push(t[2]);else{var r=new Promise((function(a,r){t=n[e]=[a,r]}));a.push(t[2]=r);var f,o=document.createElement("script");o.charset="utf-8",o.timeout=120,c.nc&&o.setAttribute("nonce",c.nc),o.src=function(e){return c.p+"static/js/"+({}[e]||e)+"."+{0:"4ac3861a",1:"05eb3543",2:"7cf6642a",3:"06359356",4:"d2ba5d13",5:"5404a000",6:"fd04a339",7:"72c1f2ed",8:"6e1aa7d7",9:"93889121",13:"93fcf37e",14:"e311c46d",15:"b6574f61",16:"6b180369",17:"22c2c7b4",18:"f2c9665f",19:"ae8eb500",20:"77e43c39",21:"899d2566",22:"63c729c1",23:"673ada6f",24:"71c055dd",25:"be3c4b44",26:"cfaf27ca",27:"f13733d3",28:"8c6a3155",29:"722cb358",30:"48e01237",31:"9ea42fa4",32:"6563a6c1",33:"f93906e3",34:"5fa96d2d",35:"2a6b8626",36:"8372ab61",37:"05e6b840",38:"ef1e8b6e",39:"f6af19fe",40:"66e41aba",41:"84c439d8",42:"5ac2ef26",43:"4be36402",44:"f28a0ba3",45:"fc2fb432",46:"c2538eba",47:"69a0f6a8",48:"e47338c9",49:"d3efb6b1",50:"48d37962",51:"97c5b6b3",52:"ea08ba65",53:"94eea8d8",54:"a10b9a17",55:"72a882e4",56:"2b4182d6",57:"86f78960",58:"8024e82f",59:"658384b7",60:"07d8d79d",61:"33308e15",62:"5a0938d8",63:"db3bc219",64:"17ca596d",65:"d8e29d95",66:"120d73ff",67:"a9882580",68:"0fa490e2",69:"4b92413b",70:"3f605b88",71:"c3336ebb",72:"a5c9fab6",73:"1a2ba67f",74:"09e0f4a7",75:"73197bed",76:"dec671e4",77:"d53868dc",78:"903f8358",79:"df33598a",80:"eb252c0b",81:"956d9f28",82:"8ab70ef1",83:"6c9f5698",84:"2f98aaf3",85:"5a641049",86:"9510812d",87:"ff71caba",88:"ea121a9a",89:"36b34946",90:"b449c621",91:"8b0abe0e",92:"c3947b9d",93:"3fa57af0",94:"7d86d4ac",95:"8b60a77b",96:"dbc3a8ff",97:"4e9dc762",98:"a9e91c3f",99:"2468ced5",100:"be8f030a",101:"5abe87a7",102:"63129618",103:"bfbb050e",104:"d897c30a",105:"5a606996",106:"84aa441f",107:"501b9ba8",108:"9e2d03cf",109:"608f9256",110:"9318a94c"}[e]+".chunk.js"}(e);var b=new Error;f=function(a){o.onerror=o.onload=null,clearTimeout(d);var t=n[e];if(0!==t){if(t){var r=a&&("load"===a.type?"missing":a.type),f=a&&a.target&&a.target.src;b.message="Loading chunk "+e+" failed.\n("+r+": "+f+")",b.name="ChunkLoadError",b.type=r,b.request=f,t[1](b)}n[e]=void 0}};var d=setTimeout((function(){f({type:"timeout",target:o})}),12e4);o.onerror=o.onload=f,document.head.appendChild(o)}return Promise.all(a)},c.m=e,c.c=r,c.d=function(e,a,t){c.o(e,a)||Object.defineProperty(e,a,{enumerable:!0,get:t})},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.t=function(e,a){if(1&a&&(e=c(e)),8&a)return e;if(4&a&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(c.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&a&&"string"!=typeof e)for(var r in e)c.d(t,r,function(a){return e[a]}.bind(null,r));return t},c.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(a,"a",a),a},c.o=function(e,a){return Object.prototype.hasOwnProperty.call(e,a)},c.p="/",c.oe=function(e){throw console.error(e),e};var o=this["webpackJsonptiro-notes-client"]=this["webpackJsonptiro-notes-client"]||[],b=o.push.bind(o);o.push=a,o=o.slice();for(var d=0;d<o.length;d++)a(o[d]);var u=b;t()}([])</script><script src="/static/js/12.da359bd1.chunk.js"></script><script src="/static/js/main.feb7293b.chunk.js"></script></body><style>html{position:fixed}body>iframe{display:none!important}</style><script>setTimeout(()=>{console.info("[DEV NOTICE] Live Reload Has Been Disabled"),window.webpackHotUpdate=()=>{}},1e3);{var WS=window.WebSocket;function DevWebSocket(e){return"ws://localhost:3000/sockjs-node"===e?(console.info("[DEV NOTICE] Live Reload Has Been Disabled"),{}):new WS(e)}window.WebSocket=DevWebSocket}</script></html>
|