From d356d6e482e8a5c12ebc2bb1de8556d1fdb6debf Mon Sep 17 00:00:00 2001 From: Grant Stankaitis <36576510+grantukas@users.noreply.github.com> Date: Fri, 31 Dec 2021 16:08:55 -1000 Subject: [PATCH 01/12] Create app.js --- apps/slash/app.js | 104 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 apps/slash/app.js diff --git a/apps/slash/app.js b/apps/slash/app.js new file mode 100644 index 000000000..22bce1191 --- /dev/null +++ b/apps/slash/app.js @@ -0,0 +1,104 @@ +// Get 12 hour status, from barclock +const is12Hour = (require("Storage").readJSON("setting.json", 1) || {})["12hour"]; + +// Used from waveclk to schedule updates every minute +var drawTimeout; + +// Schedule a draw for the next minute +function queueDraw() { + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = setTimeout(function() { + drawTimeout = undefined; + draw(); + }, 60000 - (Date.now() % 60000)); +} + +// From forum conversation 348275 +function fillLine(x1, y1, x2, y2, lineWidth) { + var dx, dy, d; + if (!lineWidth) { + g.drawLine(x1, y1, x2, y2); + } else { + lineWidth = (lineWidth - 1) / 2; + dx = x2 - x1; + dy = y2 - y1; + d = Math.sqrt(dx * dx + dy * dy); + dx = Math.round(dx * lineWidth / d, 0); + dy = Math.round(dy * lineWidth / d, 0); + g.fillPoly([x1 + dx, y1 - dy, x1 - dx, y1 + dy, x2 - dx, y2 + dy, x2 + dx, y2 - dy], true); + } +} + +// Mainly to convert day number to day of the week +function convertDate(date) { + var dayNum = date.getDay(); + var month = date.getMonth(); + var dayOfMonth = date.getDate(); + var dayChar; + + month += 1; + + switch (dayNum) { + case 0 : dayChar = "Sun"; break; + case 1 : dayChar = "Mon"; break; + case 2 : dayChar = "Tue"; break; + case 3 : dayChar = "Wed"; break; + case 4 : dayChar = "Thur"; break; + case 5 : dayChar = "Fri"; break; + case 6 : dayChar = "Sat"; break; + } + + return dayChar + " " + month + "/" + dayOfMonth; +} + +function draw() { + var d = new Date(); + var h = d.getHours(), m = d.getMinutes(); + var hour = (" "+h).substr(-2); + var minutes = ("0"+m).substr(-2); + g.reset(); + + // Convert to 12hr time mode + if (is12Hour && hour > 12) { + hour = hour - 12; + hour = "0" + hour; + } else if (hour == 0) { + hour = 12; + } + + // Draw the time, vector font + g.setFont("Vector", 50); + g.setFontAlign(1,1); // Align right bottom + g.drawString(hour, 85, 80, true); + g.drawString(minutes, 155, 140, true); + + // Draw slash, width 6 + fillLine(57, 120, 112, 40, 6); + + // Convert date then draw + g.setFont("Vector", 20); + g.setFontAlign(0,1); // Align center bottom + var convertedDate = convertDate(d); + g.drawString(convertedDate, g.getWidth()/2, 170, true); + + Bangle.drawWidgets(); + queueDraw(); +} + +// Clear screen and draw +g.clear(); +draw(); + +// From waveclk +Bangle.on('lcdPower',on=>{ + if (on) { + draw(); // Draw immediately, queue redraw + } else { // Stop draw timer + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = undefined; + } +}); + +Bangle.setUI("clock"); +Bangle.loadWidgets(); +Bangle.drawWidgets(); From 5113348ecbfa408f6fbc2563a0439ed2678b9704 Mon Sep 17 00:00:00 2001 From: Grant Stankaitis <36576510+grantukas@users.noreply.github.com> Date: Fri, 31 Dec 2021 16:26:58 -1000 Subject: [PATCH 02/12] Create app-icon.js --- apps/slash/app-icon.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 apps/slash/app-icon.js diff --git a/apps/slash/app-icon.js b/apps/slash/app-icon.js new file mode 100644 index 000000000..a0737974a --- /dev/null +++ b/apps/slash/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwwgEBgUiACUgC4IWTAAIuVGAQWVAH4A/AH4AmmQWVl//C6s//4wPkfzAof/F4U/DRgpFC4Uj/4hEFw4RBC4QTDBIouJEoYrEBQouLRwXyBZAuKAwQXCGBQiHPgowJEI6mDGBYXXHIy6GPBQhFRwJ9GVBAiFUwjYNEYiOFa5YkFC4guMFYqOEPgwwIBoSmFn4uLJYopMABKOEACUjCyoA/AH4A/AE0CCysggAXVgEAGCguB")) From d7b9e261b774cbfbe10fe1f1dc5657bb5b4ac819 Mon Sep 17 00:00:00 2001 From: Grant Stankaitis <36576510+grantukas@users.noreply.github.com> Date: Fri, 31 Dec 2021 16:35:03 -1000 Subject: [PATCH 03/12] Add slash.png --- apps/slash/slash.png | Bin 0 -> 1068 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 apps/slash/slash.png diff --git a/apps/slash/slash.png b/apps/slash/slash.png new file mode 100644 index 0000000000000000000000000000000000000000..cbfc8693d9d4ca64c0a43114962d199b88e7f526 GIT binary patch literal 1068 zcmV+{1k?M8P) zvIWHhz&4pGBUAzDw_1sDNIzY_VYezx6xEkDdJw493M!>$z-np+tfpq59GV+l=zDh` znj7CXy|-w3#{!xgT{!XiVF&_+^nr{sS0)f&S~ji!E58Eoz0(O{{c$4-0y=zNQ~T?_ z0#1h=pB~(gPG1Xti_YWnnB#{k2p>b{riVKu@3@4!aFK9qs7d8{m#_a&1S$o7?hrCMzNGIFYY=y8`Ix*ywe1XaG)! z{nZ%AiT8WTfA{O&=~LB_*a9-y?8XMB9`E7+R^i_xpm3usVRau=d}HYD*{? mK!OnjnIL~Me){-*0C)kZL%4jR3{M;Y0000 Date: Fri, 31 Dec 2021 16:36:21 -1000 Subject: [PATCH 04/12] Create ChangeLog --- apps/slash/ChangeLog | 1 + 1 file changed, 1 insertion(+) create mode 100644 apps/slash/ChangeLog diff --git a/apps/slash/ChangeLog b/apps/slash/ChangeLog new file mode 100644 index 000000000..f3fae1785 --- /dev/null +++ b/apps/slash/ChangeLog @@ -0,0 +1 @@ +0.01: First version for upload From e81125d1cc5f40f8e0f0921c38fc29af77eaaba1 Mon Sep 17 00:00:00 2001 From: Grant Stankaitis <36576510+grantukas@users.noreply.github.com> Date: Fri, 31 Dec 2021 16:52:18 -1000 Subject: [PATCH 05/12] Update apps.json --- apps.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps.json b/apps.json index e5e9f8f02..8a1ff94ab 100644 --- a/apps.json +++ b/apps.json @@ -5062,5 +5062,19 @@ {"name":"ltherm.app.js","url":"app.js"}, {"name":"ltherm.img","url":"icon.js","evaluate":true} ] + }, + { + "id": "slash", + "name": "Slash Watch", + "shortName":"Slash", + "icon": "app.png", + "version":"0.01", + "description": "Slash Watch based on Pebble watch face by Nikki.", + "tags": "clock", + "supports" : ["BANGLEJS2"], + "storage": [ + {"name":"slash.app.js","url":"app.js"}, + {"name":"slash.img","url":"app-icon.js","evaluate":true} + ] } ] From 4f9b3de702a9fb4a67c73f626156ab30c6d5f3ad Mon Sep 17 00:00:00 2001 From: Grant Stankaitis <36576510+grantukas@users.noreply.github.com> Date: Fri, 31 Dec 2021 17:05:19 -1000 Subject: [PATCH 06/12] Change icon to slash.png --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 8a1ff94ab..11827a5f0 100644 --- a/apps.json +++ b/apps.json @@ -5067,7 +5067,7 @@ "id": "slash", "name": "Slash Watch", "shortName":"Slash", - "icon": "app.png", + "icon": "slash.png", "version":"0.01", "description": "Slash Watch based on Pebble watch face by Nikki.", "tags": "clock", From e77ea1f200295e506e8a10e9a8b690e5cd299150 Mon Sep 17 00:00:00 2001 From: Grant Stankaitis <36576510+grantukas@users.noreply.github.com> Date: Fri, 31 Dec 2021 17:16:43 -1000 Subject: [PATCH 07/12] Create README.md --- apps/slash/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 apps/slash/README.md diff --git a/apps/slash/README.md b/apps/slash/README.md new file mode 100644 index 000000000..5fcd72bb8 --- /dev/null +++ b/apps/slash/README.md @@ -0,0 +1,11 @@ +# Slash Watch + +![](slash.png) + +Slash Watch, a recreation of the Slash watch face for Pebble watches by Nikki. +Simple watchface with a slash through the hours and minutes. Date shown at the bottom. + +This watch face was made using Espruino documentation, Espruino forum threads, the 93 Dub watch face, the barclock watch face, and the waveclk app. + +Contributors: +* Ray Holder (93 Dub watchface helped create this one) From 7272389b5b373086a76bf7861af3bfa1d8e223b2 Mon Sep 17 00:00:00 2001 From: Grant Stankaitis <36576510+grantukas@users.noreply.github.com> Date: Fri, 31 Dec 2021 17:23:05 -1000 Subject: [PATCH 08/12] Add files via upload --- apps/slash/screenshot.png | Bin 0 -> 2343 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 apps/slash/screenshot.png diff --git a/apps/slash/screenshot.png b/apps/slash/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..41008d76c0619806bb2386524bcd25d46e2192f5 GIT binary patch literal 2343 zcmc&$c{r4f79Vf#Fr!a*#?V9*ra_YLN?DU_7{*pwjHNMGi!Tyl%)FtzZqX=YE&C@T zvhT7@g=85fMPD&Z_9at|y)4(g_wW1nJc(l?AQtFEHb<0l6=o0!)E66)*%=mXKJ!!Xm^BJ9w6(?iYs@ZbjAuRi zHk?x$roh~xLCHI;#(zDuO}Ex1;2dxt>Uecv(uO?(#{T1|7`SibL^PSMuxHyQ*Ts!u z_efabOa;98To%{?^FRzM=$HCFIDr2DO1*|({lUrrdNzggMuBm)`KNx=p+kv%S&r46 zX~R5&y-VvQl!JIGp-=7$s<3*EaJ@PCp#AUpcJvZ`d53)s#cRd}M{BB7Q%u>Mb5Ndb zb=Sljzh33{J#z-2mE<}p2irpsM!Mik3W%f{j5VH`FilBHE&!cq=(ix8J*1!Gz+UQ_ ztCK8-za>+pS5rUj4MDQr@k@fGUOmlF9LtkbAa=Sa^ex^T!JYMBTv%b;s%$F+$hw0X zKX^aGauWfR~ z;K0j2X>m`30ozfl%~EqF9Phlj_K_l>Kx%gMEW_WV>s|RmKqu@H)EctNSTF)g>gD!p z1sR(wl{xS~AqTtC8F37mJdt1)-_~U?$Zia_l^^n=av~()F{Q{XbA}(@n@06l(ZAMECH- z;1N)Gb63wIqfW@YFsl}jS@3NHw+9-Uus1Qc2FUIaQ-9MXh)PcsOip74?zpM>w-N1R z9?k6Kt(jDgB;1<3r}a6D6N zvHcuK6BNnrf$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{9(at5_D+nUOZiL;wW@RWnsFkeg@wH3&du#6AL3L5zN) zR>i>f2pD=wUz9c#*gbD^Pz&eG+_iaNgZOVDXG`yws%zY Date: Fri, 31 Dec 2021 17:24:16 -1000 Subject: [PATCH 09/12] Update README.md --- apps/slash/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/slash/README.md b/apps/slash/README.md index 5fcd72bb8..9bef104cc 100644 --- a/apps/slash/README.md +++ b/apps/slash/README.md @@ -1,9 +1,9 @@ # Slash Watch -![](slash.png) +![](screenshot.png) Slash Watch, a recreation of the Slash watch face for Pebble watches by Nikki. -Simple watchface with a slash through the hours and minutes. Date shown at the bottom. +Simple watchface with a slash through the hours and minutes. Date shown at the bottom. Theme will change (light/dark) based on watch theme. This watch face was made using Espruino documentation, Espruino forum threads, the 93 Dub watch face, the barclock watch face, and the waveclk app. From 364512266bc7421a1b64285212841efd42945012 Mon Sep 17 00:00:00 2001 From: Grant Stankaitis <36576510+grantukas@users.noreply.github.com> Date: Fri, 31 Dec 2021 17:29:48 -1000 Subject: [PATCH 10/12] Update apps.json --- apps.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 11827a5f0..29a9a208e 100644 --- a/apps.json +++ b/apps.json @@ -5068,10 +5068,14 @@ "name": "Slash Watch", "shortName":"Slash", "icon": "slash.png", + "screenshots": [{"url":"screenshot.png"}], "version":"0.01", "description": "Slash Watch based on Pebble watch face by Nikki.", "tags": "clock", - "supports" : ["BANGLEJS2"], + "type": "clock", + "supports":["BANGLEJS2"], + "readme": "README.md", + "allow_emulator": true, "storage": [ {"name":"slash.app.js","url":"app.js"}, {"name":"slash.img","url":"app-icon.js","evaluate":true} From 03f5daba90a107dc90b3b2bc228daf5bc472ce07 Mon Sep 17 00:00:00 2001 From: Grant Stankaitis <36576510+grantukas@users.noreply.github.com> Date: Fri, 31 Dec 2021 18:07:48 -1000 Subject: [PATCH 11/12] Fix extra 0 added for hour conversion --- apps/slash/app.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/slash/app.js b/apps/slash/app.js index 22bce1191..53ff2640a 100644 --- a/apps/slash/app.js +++ b/apps/slash/app.js @@ -61,7 +61,9 @@ function draw() { // Convert to 12hr time mode if (is12Hour && hour > 12) { hour = hour - 12; - hour = "0" + hour; + if (hour < 10) { + hour = "0" + hour; + } } else if (hour == 0) { hour = 12; } From aa7938162fffccc9054cecab033d6ce7f455beee Mon Sep 17 00:00:00 2001 From: Grant Stankaitis <36576510+grantukas@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:19:06 -1000 Subject: [PATCH 12/12] Fix leading zero for hours < 12 --- apps/slash/app.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/slash/app.js b/apps/slash/app.js index 53ff2640a..f548bcaf7 100644 --- a/apps/slash/app.js +++ b/apps/slash/app.js @@ -54,20 +54,23 @@ function convertDate(date) { function draw() { var d = new Date(); var h = d.getHours(), m = d.getMinutes(); - var hour = (" "+h).substr(-2); var minutes = ("0"+m).substr(-2); g.reset(); // Convert to 12hr time mode - if (is12Hour && hour > 12) { - hour = hour - 12; - if (hour < 10) { - hour = "0" + hour; + if (is12Hour && h > 12) { + h = h - 12; + if (h < 10) { + h = "0" + h; } - } else if (hour == 0) { - hour = 12; + } else if (h < 12) { + h = "0" + h; + } else if (h == 0) { + h = 12; } + var hour = (" "+h).substr(-2); + // Draw the time, vector font g.setFont("Vector", 50); g.setFontAlign(1,1); // Align right bottom