From 5e0b4a9703c554d045d63f6bf6de13535ceebd45 Mon Sep 17 00:00:00 2001 From: qucchia Date: Tue, 7 Dec 2021 19:32:49 +0100 Subject: [PATCH 01/42] Allow Calendar app to begin on Sunday. --- apps.json | 4 +++- apps/calendar/ChangeLog | 1 + apps/calendar/README.md | 5 +++++ apps/calendar/calendar.js | 13 +++++++++++-- apps/calendar/settings.js | 24 ++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 apps/calendar/settings.js diff --git a/apps.json b/apps.json index 13bb5892d..745389bd7 100644 --- a/apps.json +++ b/apps.json @@ -2392,7 +2392,7 @@ { "id": "calendar", "name": "Calendar", - "version": "0.02", + "version": "0.03", "description": "Simple calendar", "icon": "calendar.png", "screenshots": [{"url":"screenshot_calendar.png"}], @@ -2402,8 +2402,10 @@ "allow_emulator": true, "storage": [ {"name":"calendar.app.js","url":"calendar.js"}, + {"name":"calendar.settings.js","url":"settings.js"}, {"name":"calendar.img","url":"calendar-icon.js","evaluate":true} ] + "data": [{"name":"messages.json"}] }, { "id": "hidjoystick", diff --git a/apps/calendar/ChangeLog b/apps/calendar/ChangeLog index 8bafff34a..de887bfa7 100644 --- a/apps/calendar/ChangeLog +++ b/apps/calendar/ChangeLog @@ -1,2 +1,3 @@ 0.01: Basic calendar 0.02: Make Bangle 2 compatible +0.03: Add setting to start week on Sunday diff --git a/apps/calendar/README.md b/apps/calendar/README.md index 19a60afc0..e22d06573 100644 --- a/apps/calendar/README.md +++ b/apps/calendar/README.md @@ -6,3 +6,8 @@ Basic calendar - Use `BTN4` (left screen tap) to go to the previous month - Use `BTN5` (right screen tap) to go to the next month + +## Settings + +- Starts on Sunday: whether the calendar should start on Sunday (default is Monday). + diff --git a/apps/calendar/calendar.js b/apps/calendar/calendar.js index 6f3c33164..5707bd97a 100644 --- a/apps/calendar/calendar.js +++ b/apps/calendar/calendar.js @@ -18,6 +18,10 @@ const gray2 = "#888888"; const gray3 = "#bbbbbb"; const red = "#d41706"; +let settings = require('Storage').readJSON("calendar.json", true) || {}; +if (settings.startOnSun === undefined) + settings.startOnSun = false; + function drawCalendar(date) { g.setBgColor(color4); g.clearRect(0, 0, maxX, maxY); @@ -61,13 +65,18 @@ function drawCalendar(date) { ); g.setFont("6x8", fontSize); - const dowLbls = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"]; + let dowLbls; + if (settings.startOnSun) { + dowLbls = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]; + } else { + dowLbls = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"]; + } dowLbls.forEach((lbl, i) => { g.drawString(lbl, i * colW + colW / 2, headerH + rowH / 2); }); date.setDate(1); - const dow = date.getDay(); + const dow = date.getDay() + (settings.startOnSun ? 1 : 0); const dowNorm = dow === 0 ? 7 : dow; const monthMaxDayMap = { diff --git a/apps/calendar/settings.js b/apps/calendar/settings.js new file mode 100644 index 000000000..f9c7783a3 --- /dev/null +++ b/apps/calendar/settings.js @@ -0,0 +1,24 @@ +(function(back) { + var FILE = "calendar.json"; + var settings = require('Storage').readJSON(FILE, true) || {}; + if (settings.startOnSun === undefined) + settings.startOnSun = true; + + function writeSettings() { + require('Storage').writeJSON(FILE, settings); + } + + E.showMenu({ + "" : { "title" : "Calendar" }, + "< Back" : () => back(), + 'Start on Sunday': { + value: settings.startOnSun, + format: v => v?"Yes":"No", + onchange: v => { + settings.startOnSun = v; + writeSettings(); + } + }, + }); +}) + From bced3ec74970cd4eafc3a868f46d33e9e67404ae Mon Sep 17 00:00:00 2001 From: qucchia Date: Tue, 7 Dec 2021 19:39:53 +0100 Subject: [PATCH 02/42] Fix incorrect apps.json --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 745389bd7..ee8f6814f 100644 --- a/apps.json +++ b/apps.json @@ -2404,7 +2404,7 @@ {"name":"calendar.app.js","url":"calendar.js"}, {"name":"calendar.settings.js","url":"settings.js"}, {"name":"calendar.img","url":"calendar-icon.js","evaluate":true} - ] + ], "data": [{"name":"messages.json"}] }, { From 53cc58845abd00347f6c0ea25ebc5855be0b97ba Mon Sep 17 00:00:00 2001 From: jeffyactive Date: Wed, 8 Dec 2021 11:12:03 -0500 Subject: [PATCH 03/42] Advertise app name as Espruino manufacturer data when idle --- apps.json | 2 +- apps/emojuino/ChangeLog | 1 + apps/emojuino/emojuino.js | 20 +++++++++++++++++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/apps.json b/apps.json index e5d6dad8a..87f4e5dd2 100644 --- a/apps.json +++ b/apps.json @@ -4387,7 +4387,7 @@ "id": "emojuino", "name": "Emojuino", "shortName": "Emojuino", - "version": "0.02", + "version": "0.03", "description": "Emojis & Espruino: broadcast Unicode emojis via Bluetooth Low Energy.", "icon": "emojuino.png", "screenshots": [ diff --git a/apps/emojuino/ChangeLog b/apps/emojuino/ChangeLog index 1c99f1970..04367183f 100644 --- a/apps/emojuino/ChangeLog +++ b/apps/emojuino/ChangeLog @@ -1,2 +1,3 @@ 0.01: New App! 0.02: Upgraded text to images, added welcome screen and subtitles. +0.03: Advertise app name as Espruino manufacturer data when idle. diff --git a/apps/emojuino/emojuino.js b/apps/emojuino/emojuino.js index 5b7670652..d241063e6 100644 --- a/apps/emojuino/emojuino.js +++ b/apps/emojuino/emojuino.js @@ -32,6 +32,7 @@ const CYCLE_BUZZ_MILLISECONDS = 50; const WELCOME_MESSAGE = 'Emojuino:\r\n\r\n< Swipe >\r\nto select\r\n\r\nTap\r\nto transmit'; // Non-user-configurable constants +const APP_ID = 'emojuino'; const IMAGE_INDEX = 0; const CODE_POINT_INDEX = 1; const EMOJI_PX = 96; @@ -40,12 +41,11 @@ const EMOJI_Y = (g.getHeight() - EMOJI_PX) / 2; const TX_X = 68; const TX_Y = 12; const FONT_SIZE = 24; -const BTN_WATCH_OPTIONS = { repeat: true, debounce: 20, edge: "falling" }; +const ESPRUINO_COMPANY_CODE = 0x0590; const UNICODE_CODE_POINT_ELIDED_UUID = [ 0x49, 0x6f, 0x49, 0x44, 0x55, 0x54, 0x46, 0x2d, 0x33, 0x32 ]; - // Global variables let emojiIndex = 0; let isToggleOn = false; @@ -100,9 +100,22 @@ function transmitEmoji(image, codePoint, duration) { } +// Transmit the app name under the Espruino company code to facilitate discovery +function transmitAppName() { + let options = { + showName: false, + manufacturer: ESPRUINO_COMPANY_CODE, + manufacturerData: JSON.stringify({ name: APP_ID }), + interval: 2000 + } + + NRF.setAdvertising({}, options); +} + + // Terminate the emoji transmission function terminateEmoji(displayIntervalId) { - NRF.setAdvertising({ }); + transmitAppName(); isTransmitting = false; clearInterval(displayIntervalId); drawImage(EMOJIS[emojiIndex][IMAGE_INDEX], false); @@ -169,3 +182,4 @@ g.setFontAlign(0, 0); g.drawString(WELCOME_MESSAGE, g.getWidth() / 2, g.getHeight() / 2); Bangle.on('touch', handleTouch); Bangle.on('drag', handleDrag); +transmitAppName(); From f7a37288264fed375949d90097f6dfeee5781e23 Mon Sep 17 00:00:00 2001 From: jeffyactive Date: Wed, 8 Dec 2021 11:31:52 -0500 Subject: [PATCH 04/42] Added screenshots --- apps.json | 10 +++++++++- apps/sensible/ChangeLog | 1 + apps/sensible/screenshot-acc.png | Bin 0 -> 1093 bytes apps/sensible/screenshot-bar.png | Bin 0 -> 1297 bytes apps/sensible/screenshot-gps.png | Bin 0 -> 1253 bytes apps/sensible/screenshot-hrm.png | Bin 0 -> 1205 bytes apps/sensible/screenshot-mag.png | Bin 0 -> 1281 bytes apps/sensible/screenshot-top.png | Bin 0 -> 2861 bytes apps/sensible/sensible.js | 15 +++++++++++++++ 9 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 apps/sensible/screenshot-acc.png create mode 100644 apps/sensible/screenshot-bar.png create mode 100644 apps/sensible/screenshot-gps.png create mode 100644 apps/sensible/screenshot-hrm.png create mode 100644 apps/sensible/screenshot-mag.png create mode 100644 apps/sensible/screenshot-top.png diff --git a/apps.json b/apps.json index 87f4e5dd2..7e50fd94b 100644 --- a/apps.json +++ b/apps.json @@ -4605,9 +4605,17 @@ "id": "sensible", "name": "SensiBLE", "shortName": "SensiBLE", - "version": "0.02", + "version": "0.03", "description": "Collect, display and advertise real-time sensor data.", "icon": "sensible.png", + "screenshots": [ + { "url": "screenshot-top.png" }, + { "url": "screenshot-acc.png" }, + { "url": "screenshot-bar.png" }, + { "url": "screenshot-gps.png" }, + { "url": "screenshot-hrm.png" }, + { "url": "screenshot-mag.png" } + ], "type": "app", "tags": "tool,sensors", "supports" : [ "BANGLEJS2" ], diff --git a/apps/sensible/ChangeLog b/apps/sensible/ChangeLog index ba597a22f..baa93f297 100644 --- a/apps/sensible/ChangeLog +++ b/apps/sensible/ChangeLog @@ -1,2 +1,3 @@ 0.01: New App! 0.02: Corrected variable initialisation +0.03: Advertise app name, added screenshots diff --git a/apps/sensible/screenshot-acc.png b/apps/sensible/screenshot-acc.png new file mode 100644 index 0000000000000000000000000000000000000000..b286d1ed55b37ccbf406732238425a43630c1dfe GIT binary patch literal 1093 zcmeAS@N?(olHy`uVBq!ia0vp^8$g(Y4M?uv{v-}aaTa()7Bet#3xhBt!>lS)9LmJUYQ@?SKk&qGe7;j^{Vg1f4|6h=P5sEmbO}I zvSiAxTRYxA-}J5Rabj?Xzj8wahjHtJTee*d)^qi@?|QraeEz=YH-FjB|K{ZVefPJT zYwzB__;%x#b=+6BlY5Ux8^!09-oEwu=OpHpTkB`v&p(;1Rhj&zRyKS6>s84!!k1J` zuTxl?7hP@l|7~Q0*m2IS+m25?Zcuri`)%sHtq{qtv~D|*EP z!zO-j-=%KVaJKn13uJ>i1Po+mIPn}#;Bt((DIx*lb4V~YH#isvcT%Cg~eZg-`>si=XF=*yNkz-!|Thg zc-!B$*?aNUtT;DQr!$SwHI40p6TSH#EmQt{as9$odvEP9XKm+yly&5G(xUUmKXq6> zGH>g$T*#caF{r%za@5)|x8=RYVGaMc9{4&@J0^Ph-K=$HaYgf=9sirTlWC9WtwI5I zpm&rLKptf20ebL)&V#k*1%C7}x+P?Yevq6m)wE3cL(q{&OUvu+dd=ipk9x1L{9qFC zQAqE>Qcac?jtZ;iTQBi0WQwy&5H?g~+V)Ih`%GqMmAaL}$}l4pfTja2ao*hUH%Q$L zY!y5#@3O^gGL!o9;`!}Y#|ul2_U>TxcTZYu@a(_^=L6FsRF8-pGCv^vPl4}DBQ)&W z(mokXiO(!v)}+ULkL&W%ltX@sF`dde2Og>7!mIX}v_>cw?Ba=-ap#c&A20&j4q0wE zKQob~Esxpn<$rk&@ekH9%WrasZ>ZpuM#CEKyS9HRnPtwX?m0QXLQuYOxxo8^*ewcg z9Ora!%5Lc3lt;n}`S%WGnjY!{CKCYzo%4-n3k;b+sRkIfpj3kt%&6&zhsh1B1)9iE dlwbSH+#wY7aI&Dpb6^p`;OXk;vd$@?2>@-$<1GLH literal 0 HcmV?d00001 diff --git a/apps/sensible/screenshot-bar.png b/apps/sensible/screenshot-bar.png new file mode 100644 index 0000000000000000000000000000000000000000..781ddbaa63369ebb8dd1966564e486e185c2fea7 GIT binary patch literal 1297 zcmeAS@N?(olHy`uVBq!ia0vp^8$g(Y4M?uv{v-}aaTa()7Bet#3xhBt!>l+Ri(>lQ1BxIMh}lGW%PIRAt`?rtp>==<%FU$Y#&fP!JPWg7jf!^+!i+ksu zI<4w@F>vh=daXV-!0nqJ}&j{KNqtf7d49A?q%@Z-?n$v{mu8k z=53ame{14~G_{58ksO;P?%!s+U+~npi(%(wqsrev&X4Hr8jqBY2AywB_pjA@RHyO& zvfBam`H^Rsn-4HFHcwo5b?MWP{pm^G?|!da&Ru_VInSL98aH=0Tu4%1`peeZcE+!L z?w@y7&ySQpanbJmkrYR37mkJl4z4W~d*hT?j_E#fN$3z@Xk=sp8OO-P%)$mCIe3_u zYd?Hk<1W$I7~gx~|KHay?rmDEI^FxX_Vko(FNF82z6zas!2OZW<@@qZ4^J_^R9b)U zW?=r$x$27_pW6J=HE!zNu>3Da1tfQvonKSGeVT1)${eGq&DGOMzt7Es*Juyf5{v%NwcN`upe#9%`^x%p}NUlhR;o7OMFE`#0 z*WGigY;)zyD4XJE%kE~a+c4*4u-&_Uq4iq&3BLFKvAfDRBs3hTkdSATa7%a)uKeMb zysG|b>#B$MrcK%&_3T#7>(+aV_gTnjH};o3`XqMZ+WHFCRmv_|EJ`|UodWldX-da( z&Z##-=U1ba-gZZ%cksC3OA~~mMQrOvI|J;n0sKN zw2HF1_pXgX|6??Et}I@!(Ea4}rKHnSEkZbRj2&7SICumkK<+eI{$klVR$;LhK@Vna z-PgduC?L__FJL-n=giMJ(GR8^xM&{v?(UA6+0mEuKkW0mXB+74c4hVLCSZDORP44$ z;Aj*L5m00RCQ#9f4`=6Z+G55$J?+7r$%W@St}XJvGd(ZwmB}e5HgLMN6))7CP@4!$ z#NX4{*Hj;vz%={Tp$$xv#Se4&#PMhwR2r^1@Z=~+K>1VWiPw@@FM8`&U+g&`VdYfu zjj2ulkw?!$RyD&m@fk-X;u3_CD;hm}1W)K?n6GV1bO)vsEExrnT|jmdKI;Vst0Om45-v9sr literal 0 HcmV?d00001 diff --git a/apps/sensible/screenshot-gps.png b/apps/sensible/screenshot-gps.png new file mode 100644 index 0000000000000000000000000000000000000000..3fd1229e3d40c9e5a02f2360a165327766af2ed5 GIT binary patch literal 1253 zcmeAS@N?(olHy`uVBq!ia0vp^8$g(Y4M?uv{v-}aaTa()7Bet#3xhBt!>l}XPEYDQ1NDwa z&sR^k$o=~>$ZLLTq~CY*OV4GVR=?KzkYoAL=h~$6yUm|$(>eY4dG3?g{(^-iD-kpTs_|SzhOAb2Wpdje}7@;)S@P-TZ!z#tk*D z2^|6lf^|0pUoe>em#257pRCR{GOs}*yy}<*V3lu1J0*co2nJ8IN^}Q zj4Mp#_A_}H~FFx8V)EJ z7;sE?Q|#OH=BBW;XyxO=#_va>?fJgEJ8ajmPVmrU2SsM)waP7FV!ZNj>ySD3IFmaL*-7-C7)yk}99v&uZRt2bLgN+B=5691w zY`j;qoyBId`O+=X2i@Yn99iOb;s68C`eq>6XqUpfSXOkUyzY;pFLme4_8yzs8}F}B zkT-FcRUD7FVwUJi=6<)1dplB+H5!Y@y_=I%VJ;OXrYKUF+{ICN?bX?aj1NwY=ZiA()MEE<6Ah0_|1j@( z=F&@!tah&$a&1|j`aNG6#&e=iOwncx z50za`F1q8UDxk#tf7=<$pYQr^1lEb{Z2g#i^!>UV{*p&g_f~d&YJDd6{O01+(nngQ zj~Xs8&3@i`fob}heK(ULv`@L5n)LXJM#-!GKj%7kTi^V2>i!hJB{o*aR=?kBac=c< z4s#Z^l1B`{^vniI31@%Q*`=Cp*xGjf+HI+#L#d7HCq(ZIi&_yEB*-4pEAV>n%=EZz4mq{EK&3c%N`!W#Fs)clQ9hd%LdS#?CN`p>l^z#@vl)78&q Iol`;+0KlynVE_OC literal 0 HcmV?d00001 diff --git a/apps/sensible/screenshot-hrm.png b/apps/sensible/screenshot-hrm.png new file mode 100644 index 0000000000000000000000000000000000000000..aa6a0574fd89c1a9443ca8f3ec43454a2ddadd1c GIT binary patch literal 1205 zcmeAS@N?(olHy`uVBq!ia0vp^8$g(Y4M?uv{v-}aaTa()7Bet#3xhBt!>l{)yze(3 zGu5r$y5m@(3=sKLx^-L#l$Tw~%H!7YJN^9P%b)H|%=x)T26twe_Uko#JG4J5EbeyOoa0kB^Y;pf$9{c&rayXq_4ljQ z=f3ODou2*naDe-RE4)^pk9^;Bd0m(JE6qRe{FcSdzq0u9T~T|9@*|T!*)F~_bw|>F z+h0n0&r2%HMecJST0C>}RWp~pq2D_iiu7s9m)34j_{cBfn()at7@Z~}C{ybfst-3qy?d$1rQ>NzRpJR=C zX(wVJq3Cdc#hmYOLW{zhlN>#QOe{Q1ZU+<+1PnMN7@Hd$flQzX8{_A^|7*A>?%osF zUCK3Y&#WKOTVu?!t+Jdw8b$Q$EHyNL=`IBo}c<#&8Pj~9x%_zRVYnH{=>Y3B#Z`sN>ZLySM+5@rtZO=PS ztQ9X@sonm3-lzLJW?9JIX?QQov zj(UIX-m$rU-MmlXr`}myI2zk=>Bd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UsvtFoVJ9?nJY%<^4gRZ zU&T9}&Jm3#yEiaR7EfeV(?7)J6W1a-V-JV6L8V|=!Y3uIV!hTIO%Ei35|SQ?L4pAk z`wk3^%4>qAWH+bpbOa@W)iadM@9|2QaPOH~y>6-1uQOX`%_)mjTf6*e*^cNJ{K6I4 zpU&?No|<>R`q_tFZ|*Hw6tZcr`l;zIxwZaxRM_uXKQv9so%;7!&kpT-!tp%^l=z&u zYpw|~>+!U_JR<99+0lENW!*{Xr!yqh39}1G?C^SUDIn77;IqkzTk{iIFSS2Aur$>6 zy17wSdhgX~XU}?NpWV7PKx%g8#lx34r!q6Mh}C|aEAyjo(X^sUfeH@~tyYF(qBjJD z4{@zgZpP~Mi9b8`h_N2e_;b!pxKYrmbw`qu<%O-n?ny0TGmdcR8*~cBB?u|+IiTXk z(j|P0ceP>;3mbYIDHuRv&;giMKx|MFDm4Gcz>&4sdQXumu=HYJ@O1TaS?83{1OQ>{ BGa&!~ literal 0 HcmV?d00001 diff --git a/apps/sensible/screenshot-top.png b/apps/sensible/screenshot-top.png new file mode 100644 index 0000000000000000000000000000000000000000..e485933f004aa8d87e5f019b21c577b949786435 GIT binary patch literal 2861 zcmds({X5h9AICr28rhI?8zC~n+?;1Z}_w{% z6EDzXojU4e?co3hgTv)Oo-Iq0p--@y@1^u8c#(|-XHQDz)obzk;qesWN~eD z8>r`Y=IdQdCKW@Q3okGEn(v3?L~qx`r2Kj*()HkF$SRrMoT)PsFcP1C%5pONEg(+n z{*Y|qnw?9xf(a6>^ANiL43fzeLW10`xo+X;R*D>=o=1%SbhAY@B#1g% zGl*wz=PG?>hgX?Z^lqNTld@0)-|bfK5BRyBuNZ~!?CsTSHrTE*u9(!Wn-slM+sDdk z7;e_Y(K#bq{7M%3_#qjiFzSM_O-uEEE-B==&>#z|s=itmK>$`kQ?x49MSX(nIVYMI zLhsMCxm#i>d7eS)7%W3L6MoT26+^T5t?7T*e~px}1d;-Vi93Ix!xmW9a7o#{ycD4% z6!B6IL6*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_-wo}&;{~*@^tw4FpR5P{2X3U&cp4^pbXBf@vbPpg{uN_arZ-^0*CmG zl4)YByoiO(3mU+K{N_Q=E9eJ|@>aS`i^ z-^5K9Xx1(_AE{6B9?}0)zw7vScpRx9FC8~*e32wWgJ)hfZp%&N85$o0%AGu(mEwJQ zV3+}?Sa;~N(3#GZEVyV!c1{@EIr=8KYe2m@;6)|FK(|@DI?$lVyf^AsMt*d9^7^C% zPvM1f#(Hp$&J7loE8j^7t9eKC4PKvVn0}wSj)dVVlA32?181h_2;x%qt~9hhAVB*k zyY5^(sOVj4V$*IA0v8m7&(1fg?8ri|fi~4~s8(qxU~wiqCP5tQgY!Ln1_ZP_sz338 z0UUAiMf>SS=nC<0Eu=<&;H+1N32vNF1P9Hk+j7BU%>7U LtWCMKcl>_=8RaYN literal 0 HcmV?d00001 diff --git a/apps/sensible/sensible.js b/apps/sensible/sensible.js index c569ff720..45852adab 100644 --- a/apps/sensible/sensible.js +++ b/apps/sensible/sensible.js @@ -6,6 +6,7 @@ // Non-user-configurable constants const APP_ID = 'sensible'; +const ESPRUINO_COMPANY_CODE = 0x0590; // Global variables @@ -90,6 +91,19 @@ let magMenu = { }; +// Transmit the app name under the Espruino company code to facilitate discovery +function transmitAppName() { + let options = { + showName: false, + manufacturer: ESPRUINO_COMPANY_CODE, + manufacturerData: JSON.stringify({ name: APP_ID }), + interval: 2000 + } + + NRF.setAdvertising({}, options); +} + + // Update acceleration Bangle.on('accel', function(newAcc) { acc = newAcc; @@ -155,6 +169,7 @@ Bangle.on('mag', function(newMag) { // On start: enable sensors and display main menu g.clear(); +transmitAppName(); Bangle.setBarometerPower(isBarEnabled, APP_ID); Bangle.setGPSPower(isGpsEnabled, APP_ID); Bangle.setHRMPower(isHrmEnabled, APP_ID); From b9f636d9dbcd7a58df5b23c0eeb9e2a020e02aec Mon Sep 17 00:00:00 2001 From: crazysaem Date: Wed, 8 Dec 2021 16:37:42 +0000 Subject: [PATCH 05/42] Create Pattern Launcher app --- apps.json | 18 +- apps/ptlaunch/ChangeLog | 1 + apps/ptlaunch/README.md | 46 ++++ apps/ptlaunch/add_pattern.png | Bin 0 -> 2642 bytes apps/ptlaunch/app-icon.js | 1 + apps/ptlaunch/app.js | 416 ++++++++++++++++++++++++++++++++++ apps/ptlaunch/app.png | Bin 0 -> 1094 bytes apps/ptlaunch/boot.js | 194 ++++++++++++++++ apps/ptlaunch/main_menu.png | Bin 0 -> 2840 bytes apps/ptlaunch/select_app.png | Bin 0 -> 2551 bytes 10 files changed, 675 insertions(+), 1 deletion(-) create mode 100644 apps/ptlaunch/ChangeLog create mode 100644 apps/ptlaunch/README.md create mode 100644 apps/ptlaunch/add_pattern.png create mode 100644 apps/ptlaunch/app-icon.js create mode 100644 apps/ptlaunch/app.js create mode 100644 apps/ptlaunch/app.png create mode 100644 apps/ptlaunch/boot.js create mode 100644 apps/ptlaunch/main_menu.png create mode 100644 apps/ptlaunch/select_app.png diff --git a/apps.json b/apps.json index e5d6dad8a..89b46e301 100644 --- a/apps.json +++ b/apps.json @@ -4800,6 +4800,22 @@ "screenshots":[ { "url":"screenshot.png" } ] + }, + { + "id": "ptlaunch", + "name": "Pattern Launcher", + "shortName": "Pattern Launcher", + "version": "0.01", + "description": "Directly launch apps from the clock screen with custom patterns.", + "icon": "app.png", + "tags": "tools", + "supports": ["BANGLEJS2"], + "readme": "README.md", + "storage": [ + { "name": "ptlaunch.app.js", "url": "app.js" }, + { "name": "ptlaunch.boot.js", "url": "boot.js" }, + { "name": "ptlaunch.img", "url": "app-icon.js", "evaluate": true } + ], + "data": [{"name":"ptlaunch.patterns.json"}] } - ] diff --git a/apps/ptlaunch/ChangeLog b/apps/ptlaunch/ChangeLog new file mode 100644 index 000000000..4967d3207 --- /dev/null +++ b/apps/ptlaunch/ChangeLog @@ -0,0 +1 @@ +0.01: Initial creation of the pattern launch app \ No newline at end of file diff --git a/apps/ptlaunch/README.md b/apps/ptlaunch/README.md new file mode 100644 index 000000000..a69492782 --- /dev/null +++ b/apps/ptlaunch/README.md @@ -0,0 +1,46 @@ +# Pattern Launcher + +Directly launch apps from the clock screen with custom patterns. + +## Usage + +Create patterns and link them to apps in the Pattern Launcher app. + +Then launch the linked apps directly from the clock screen by simply drawing the desired pattern. + +## Screenshots and detailed steps + +![](main_menu.png) +![](add_pattern.png) +![](select_app.png) + +From the main menu you can: +- Add a new pattern and link it to an app (first entry) + - To create a new pattern first select "Add Pattern" + - Now draw any pattern you like, this will later launch the linked app from the clock screen + - If you don't like the pattern, simply re-draw it. The previous pattern will be discarded. + - If you are happy with the pattern tap on screen or press the button to continue + - Now select the app you want to launch with the pattern. + - Note, you can bind multiple patterns to the same app. +- Remove linked patterns (second entry) + - To remove a pattern first select "Remove Pattern" + - You will now see a list of apps that have patterns linked to them + - Simply select the app that you want to unlink. This will remove the saved pattern, but not the app itself! + - Note, that you can not actually preview the patterns. This makes removing patterns that are linked to the same app annoying. sorry! +- Disable the lock screen on the clock screen from the settings (third entry) + - To launch the app from the pattern on the clock screen the watch must be unlocked. + - If this annoys you, you can disable the lock on the clock screen from the setting here + +## FAQ + +1) Nothing happens when I draw on the clock screen! + +Please double-check if you actually have a pattern linked to an app. + +2) I have a pattern linked to an app and still nothing happens when I draw on the clock screen! + +Make sure the watch is unlocked before you start drawing. If this bothers you, you can permanently disable the watch-lock from within the Pattern Launcher app (via the Settings). + +3) I have done all that and still nothing happens! + +Please note that drawing on the clock screen will not visually show the pattern you drew. It will start the app as soon as the pattern was recognized - this might take 1 or 2 seconds! If still nothing happens, that might be a bug, sorry! diff --git a/apps/ptlaunch/add_pattern.png b/apps/ptlaunch/add_pattern.png new file mode 100644 index 0000000000000000000000000000000000000000..c7cc38e82c25b4661bc026ce7dd5901c77fb9f7f GIT binary patch literal 2642 zcma);c{tSDAIHD57-P+39c!Yg3>vAZAxlIOmm4y&B*G|E3{vi>Tx6-a-A2l&Ye~Y` z#S9vfwL4>PEW=o`32e=Lf|waw@c6NPrhId|^(JciJD@iVsy*Xc@rx|;~o zE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O${zCa@K+7^18G} a2vKOb@;L{iZz}pE0_SX { + if (DEBUG) { + console.log(JSON.stringify(message)); + } +}; + +var CIRCLE_RADIUS = 25; +var CIRCLE_RADIUS_2 = CIRCLE_RADIUS * CIRCLE_RADIUS; + +var CIRCLES = [ + { x: 25, y: 25, i: 0 }, + { x: 87, y: 25, i: 1 }, + { x: 150, y: 25, i: 2 }, + { x: 25, y: 87, i: 3 }, + { x: 87, y: 87, i: 4 }, + { x: 150, y: 87, i: 5 }, + { x: 25, y: 150, i: 6 }, + { x: 87, y: 150, i: 7 }, + { x: 150, y: 150, i: 8 }, +]; + +var showMainMenu = () => { + log("loading patterns"); + var storedPatterns = storage.readJSON("ptlaunch.patterns.json", 1) || {}; + + var mainmenu = { + "": { + title: "Pattern Launcher", + }, + "< Back": () => { + log("cancel"); + load(); + }, + "Add Pattern": () => { + log("creating pattern"); + createPattern().then((pattern) => { + log("got pattern"); + log(pattern); + log(pattern.length); + + var confirmPromise = new Promise((resolve) => resolve(true)); + + if (!!storedPatterns[pattern]) { + log("pattern already exists. show confirmation prompt"); + confirmPromise = E.showPrompt("Pattern already exists\nOverwrite?", { + title: "Confirm", + buttons: { Yes: true, No: false }, + }); + } + + confirmPromise.then((confirm) => { + log("confirmPromise resolved: " + confirm); + if (!confirm) { + showMainMenu(); + return; + } + + log("selecting app"); + getSelectedApp().then((app) => { + E.showMessage("Saving..."); + log("got app"); + log("saving pattern"); + + storedPatterns[pattern] = { + app: { name: app.name, src: app.src }, + }; + storage.writeJSON("ptlaunch.patterns.json", storedPatterns); + showMainMenu(); + }); + }); + }); + }, + "Remove Pattern": () => { + log("selecting pattern through app"); + getStoredPatternViaApp(storedPatterns).then((pattern) => { + E.showMessage("Deleting..."); + delete storedPatterns[pattern]; + storage.writeJSON("ptlaunch.patterns.json", storedPatterns); + showMainMenu(); + }); + }, + Settings: () => { + var settings = storedPatterns["settings"] || {}; + + var settingsmenu = { + "": { + title: "Pattern Settings", + }, + "< Back": () => { + log("cancel"); + load(); + }, + }; + + if (settings.lockDisabled) { + settingsmenu["Enable lock"] = () => { + settings.lockDisabled = false; + storedPatterns["settings"] = settings; + Bangle.setOptions({ lockTimeout: 1000 * 30 }); + storage.writeJSON("ptlaunch.patterns.json", storedPatterns); + showMainMenu(); + }; + } else { + settingsmenu["Disable lock"] = () => { + settings.lockDisabled = true; + storedPatterns["settings"] = settings; + storage.writeJSON("ptlaunch.patterns.json", storedPatterns); + Bangle.setOptions({ lockTimeout: 1000 * 60 * 60 * 24 * 365 }); + showMainMenu(); + }; + } + + E.showMenu(settingsmenu); + }, + }; + E.showMenu(mainmenu); +}; + +var drawCircle = (circle) => { + g.fillCircle(circle.x, circle.y, CIRCLE_RADIUS); +}; + +var positions = []; +var createPattern = () => { + return new Promise((resolve) => { + E.showMenu(); + g.clear(); + g.setColor(0, 0, 0); + CIRCLES.forEach((circle) => drawCircle(circle)); + + var pattern = []; + + var isFinished = false; + var finishHandler = () => { + if (pattern.length === 0 || isFinished) { + return; + } + log("Pattern is finished."); + isFinished = true; + Bangle.removeListener("drag", dragHandler); + Bangle.removeListener("tap", finishHandler); + resolve(pattern.join("")); + }; + setWatch(() => finishHandler(), BTN); + setTimeout(() => Bangle.on("tap", finishHandler), 250); + + var dragHandler = (position) => { + positions.push(position); + + debounce().then(() => { + if (isFinished) { + return; + } + E.showMessage("Calculating..."); + var t0 = Date.now(); + + log(positions.length); + + var circlesClone = cloneCirclesArray(); + pattern = []; + + var step = Math.floor(positions.length / 100) + 1; + + var p, a, b, circle; + + for (var i = 0; i < positions.length; i += step) { + p = positions[i]; + + circle = circlesClone[0]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(0, 1); + } + } + + circle = circlesClone[1]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(1, 1); + } + } + + circle = circlesClone[2]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(2, 1); + } + } + + circle = circlesClone[3]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(3, 1); + } + } + + circle = circlesClone[4]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(4, 1); + } + } + + circle = circlesClone[5]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(5, 1); + } + } + + circle = circlesClone[6]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(6, 1); + } + } + circle = circlesClone[7]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(7, 1); + } + } + + circle = circlesClone[8]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(8, 1); + } + } + } + var tx = Date.now(); + log(tx - t0); + positions = []; + var t1 = Date.now(); + log(t1 - t0); + + log("pattern:"); + log(pattern); + + log("redrawing"); + g.clear(); + g.setColor(0, 0, 0); + CIRCLES.forEach((circle) => drawCircle(circle)); + + g.setColor(1, 1, 1); + g.setFontAlign(0, 0); + g.setFont("6x8", 4); + pattern.forEach((circleIndex, patternIndex) => { + var circle = CIRCLES[circleIndex]; + g.drawString(patternIndex + 1, circle.x, circle.y); + }); + var t2 = Date.now(); + log(t2 - t0); + }); + }; + + Bangle.on("drag", dragHandler); + }); +}; + +var getAppList = () => { + var appList = storage + .list(/\.info$/) + .map((appInfoFileName) => { + var appInfo = storage.readJSON(appInfoFileName, 1); + return ( + appInfo && { + name: appInfo.name, + // type: appInfo.type, + // icon: appInfo.icon, + sortorder: appInfo.sortorder, + src: appInfo.src, + } + ); + }) + .filter((app) => app && !!app.src); + appList.sort((a, b) => { + var n = (0 | a.sortorder) - (0 | b.sortorder); + if (n) return n; // do sortorder first + if (a.name < b.name) return -1; + if (a.name > b.name) return 1; + return 0; + }); + + return appList; +}; + +var getSelectedApp = () => { + E.showMessage("Loading apps..."); + return new Promise((resolve) => { + var selectAppMenu = { + "": { + title: "Select App", + }, + "< Cancel": () => { + log("cancel"); + showMainMenu(); + }, + }; + + var appList = getAppList(); + appList.forEach((app) => { + selectAppMenu[app.name] = () => { + log("app selected"); + log(app); + resolve(app); + }; + }); + + E.showMenu(selectAppMenu); + }); +}; + +var getStoredPatternViaApp = (storedPatterns) => { + E.showMessage("Loading patterns..."); + log("getStoredPatternViaApp"); + return new Promise((resolve) => { + var selectPatternMenu = { + "": { + title: "Select App", + }, + "< Cancel": () => { + log("cancel"); + showMainMenu(); + }, + }; + + log(storedPatterns); + var patterns = Object.keys(storedPatterns); + log(patterns); + + patterns.forEach((pattern) => { + if (!!pattern) { + if (!!storedPatterns[pattern]) { + var app = storedPatterns[pattern].app; + if (!!app && !!app.name) { + var appName = app.name; + var i = 0; + while (appName in selectPatternMenu[app.name]) { + appName = app.name + i; + i++; + } + selectPatternMenu[appName] = () => { + log("pattern via app selected"); + log(pattern); + log(app); + resolve(pattern); + }; + } + } + } + }); + + E.showMenu(selectPatternMenu); + }); +}; + +showMainMenu(); + +////// +// lib functions +////// + +var debounceTimeoutId; +var debounce = (delay) => { + if (debounceTimeoutId) { + clearTimeout(debounceTimeoutId); + } + + return new Promise((resolve) => { + debounceTimeoutId = setTimeout(() => { + debounceTimeoutId = undefined; + resolve(); + }, delay || 500); + }); +}; + +var cloneCirclesArray = () => { + var circlesClone = Array(CIRCLES.length); + + for (var i = 0; i < CIRCLES.length; i++) { + circlesClone[i] = CIRCLES[i]; + } + + return circlesClone; +}; diff --git a/apps/ptlaunch/app.png b/apps/ptlaunch/app.png new file mode 100644 index 0000000000000000000000000000000000000000..14ed77f1d36f5f5c0b0c01f7da79c9b736431595 GIT binary patch literal 1094 zcmV-M1iAZ(P)Px#1ZP1_K>z@;j|==^1poj60#Hm;MgRZ*(b3UgUtb^~AOHXWCMG6jWo6sj+s4Mm zSy@>b85t}rENg3P=H}-8{rz@!b_NCp2nYy?iHZCB`(tBc1Ox;N3k#l}o{f!-prD`) z4GrPp;lRMa6B85i^70}gB1lL`aBy(U%*;18Hx(5XPEJmRg@r~&Mi&gxIV`Eqh{v9YmwdU~_7v)S3%FfcGfLqmgugYfY1 z_xJZfK|vlK9!yM30s;b$kB>h;KZ}ct?Ck7*etw6ChiPePTU%SHsi}B)c&n?cmX?;9 znwk#}55mI2U0q$dxw)8_m?|nNP*6~Afhs%z000SaNLh0L01m?d01m?e$8V@)0008b zNkl^bI~=1WhX z4>0d+CfV%H%!YuIagE95^44aS3Z5~`E2}Dr^0}-rZpLA;RxBCDFSDlgjZJY>w!}eY zUmT_48dOn)rOLw@RmN=A*ilspikOeRzbhBjw=ulKrm)+9W4o>jlpMa_tFj{+H=w4N zf_>(*DHxL>ysz8Z(||Tnqa&u!ML=6^#wGk@UiUO0APU7&A_N3#3pT)*Gyz!PML?fu zA6u|sfPlW*OqO!Syn&baQA7N9c|bXUW2iQhqr7h_fd%UD2;+M)!g$AU9383xKGLDA zHjsTfQH51MWk*dV;AE)k#vID^L}!`_osl|f`i#1y0&N%DLC_!C`3U3Ic@SJ&+HDq& zhW#LD7i}W^D;iYTU2;zm#tV3<60B1ZLUvKX2*>R>4Y@mL%9xc9|#0bW_$%OA(e}H4G+hW;V zqJo-C3**b%mo(p#+b<$q&wI469O)HNLi*8wU|qc4-kMqncG(wmpr7b z&}v0Z(6PHeR$*~% { + if (DEBUG) { + console.log(JSON.stringify(message)); + } +}; + +var CIRCLE_RADIUS = 25; +var CIRCLE_RADIUS_2 = CIRCLE_RADIUS * CIRCLE_RADIUS; + +var CIRCLES = [ + { x: 25, y: 25, i: 0 }, + { x: 87, y: 25, i: 1 }, + { x: 150, y: 25, i: 2 }, + { x: 25, y: 87, i: 3 }, + { x: 87, y: 87, i: 4 }, + { x: 150, y: 87, i: 5 }, + { x: 25, y: 150, i: 6 }, + { x: 87, y: 150, i: 7 }, + { x: 150, y: 150, i: 8 }, +]; + +var storedPatterns; +var positions = []; +var dragHandler = (position) => { + positions.push(position); + + debounce().then(() => { + log(positions.length); + + var circlesClone = cloneCirclesArray(); + var pattern = []; + + var step = Math.floor(positions.length / 100) + 1; + + var p, a, b, circle; + + for (var i = 0; i < positions.length; i += step) { + p = positions[i]; + + circle = circlesClone[0]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(0, 1); + } + } + + circle = circlesClone[1]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(1, 1); + } + } + + circle = circlesClone[2]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(2, 1); + } + } + + circle = circlesClone[3]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(3, 1); + } + } + + circle = circlesClone[4]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(4, 1); + } + } + + circle = circlesClone[5]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(5, 1); + } + } + + circle = circlesClone[6]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(6, 1); + } + } + circle = circlesClone[7]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(7, 1); + } + } + + circle = circlesClone[8]; + if (circle) { + a = p.x - circle.x; + b = p.y - circle.y; + if (CIRCLE_RADIUS_2 - (a * a + b * b) >= 0) { + pattern.push(circle.i); + circlesClone.splice(8, 1); + } + } + } + positions = []; + + pattern = pattern.join(""); + + if (!!pattern) { + if (!!storedPatterns[pattern]) { + var app = storedPatterns[pattern].app; + if (!!app && !!app.src) { + Bangle.removeListener("drag", dragHandler); + load(app.src); + } + } + } + }); +}; + +var debounceTimeoutId; +var debounce = (delay) => { + if (debounceTimeoutId) { + clearTimeout(debounceTimeoutId); + } + + return new Promise((resolve) => { + debounceTimeoutId = setTimeout(() => { + debounceTimeoutId = undefined; + resolve(); + }, delay || 500); + }); +}; + +var cloneCirclesArray = () => { + var circlesClone = Array(CIRCLES.length); + + for (var i = 0; i < CIRCLES.length; i++) { + circlesClone[i] = CIRCLES[i]; + } + + return circlesClone; +}; + +(function () { + var sui = Bangle.setUI; + Bangle.setUI = function (mode, cb) { + sui(mode, cb); + if (!mode) { + Bangle.removeListener("drag", dragHandler); + storedPatterns = {}; + return; + } + if (!mode.startsWith("clock")) { + storedPatterns = {}; + Bangle.removeListener("drag", dragHandler); + return; + } + + var storage = require("Storage"); + storedPatterns = storage.readJSON("ptlaunch.patterns.json", 1) || {}; + if (Object.keys(storedPatterns).length > 0) { + Bangle.on("drag", dragHandler); + if (storedPatterns.settings.lockDisabled) { + Bangle.setOptions({ lockTimeout: 1000 * 60 * 60 * 24 * 365 }); + } + } + }; +})(); diff --git a/apps/ptlaunch/main_menu.png b/apps/ptlaunch/main_menu.png new file mode 100644 index 0000000000000000000000000000000000000000..a4ecebb0f4ba586eba902bf1699e9b5f9dbe683a GIT binary patch literal 2840 zcmds3dpr|-7yr#-PjgG9o-ke1Qy$&Kw2i39LhdHHCAYb3%xyd`x%9lsWeut17PVY* zk8+tyE4hRwqQW*qh1lkjjj-N5f4+ad|Gs~mbN>0B&*yy3`F_ti$u?G4dAJH303dI6 z(Zo&?YyPp{WF)@2;fuQ@K*H>>=Rp-yZ59Cdpqa@zhbVVm{scW2C1-M4@az4^38Mej zj)xh?lI}eekG)9mqWw+UH(~g&e|p(SJaN_*rVd=6hjxo67^;l4E?S_4X&vXAO%tne z_`4IXVQMNRP+xjguIlJwkosw+wwU>#jE+cibj_7tNF#5S8<+D(blTrdbfP=Q_t;DD z11W(}kCM=Y2g<2x>ErTlAw+v1685bh=kY7qjqkoXZj7+Te$63vkNsCVf(uI3Jgz`uuKF|0)JS$DUj^X<+G zbMNBdBK~0TkdZ2vG->*ZZ7^_PUY-|0|e4vjsmyY^!sv52Yaf;BL9@KX(tWcQ$S80rkGIw632%@H~D`mFD zW151)XpH8$T2bmcKl*%J17*4<9(z}?{z+eW`CEjy8nb&>lbjlKp6VEUxOg~g2b3Ye zrAC>;_}i)}4pReXYI=6h-W~SD=8VqbYc?AO?mo&m&g%Kfd^E{Ys9Z9kgomQF`FUNg zR|3h)^pHv|^ZOi&`fb>ON;6i8jz&oCIeggOf)=0oECeb#M~J~bbl~g9^amF$6IzOz zMQ{52{YH@AgZ2-_-U(52dIxEH-{ySb{fN)2+pqim7l zGp>!jX%+efLxPib$|zTN>f8_SQrm-hn=!|@3ew^Wss63|rU;t+_5JQ$biq-ZpP|PN zjpZxIy;LQhI2EYKik|3HB8V!r8PSKWMExtO-0bssPU7b|n;eG_bZ53f(4vV z_Ts{q4;^0O_HlDZ(hE8J!V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uPxK_=@Ut&kbIOfv|YC z(mTTSXmp?GJAC;(^0VR~?)9M!%0lPZPU|T~<)Da>6V}BT)tBtm(~BqkW-KNGOL*KzMLpISO0PgLO&tmir|az0xy%%KG{ye~P9G8DJpuILJ$q&OdhciiV-&~L54 zR9O){pY*0E?vtI|>dU#WM2>#>u`wQnwlMucV$GNx?fD7AE0lUw6l4mK$Oww zvEKDzn|z0GaNA4vsy05V%~B}>8jhgc(0G9P%k0e3&}~L!ILG~bo=Z$1J|8hcyJK~%~^FVP|C-3 zqqgNv;GiR|ZrUdZSKO|71r^fH`I|$HnAqD7oJu; Date: Wed, 8 Dec 2021 20:44:25 +0000 Subject: [PATCH 06/42] ptlaunch: fix undefined error on boot.js if a pattern was saved but no setting was defined --- apps/ptlaunch/boot.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/ptlaunch/boot.js b/apps/ptlaunch/boot.js index 2440c561f..f30cb2921 100644 --- a/apps/ptlaunch/boot.js +++ b/apps/ptlaunch/boot.js @@ -186,8 +186,10 @@ var cloneCirclesArray = () => { storedPatterns = storage.readJSON("ptlaunch.patterns.json", 1) || {}; if (Object.keys(storedPatterns).length > 0) { Bangle.on("drag", dragHandler); - if (storedPatterns.settings.lockDisabled) { - Bangle.setOptions({ lockTimeout: 1000 * 60 * 60 * 24 * 365 }); + if (storedPatterns.settings) { + if (storedPatterns.settings.lockDisabled) { + Bangle.setOptions({ lockTimeout: 1000 * 60 * 60 * 24 * 365 }); + } } } }; From bbef0ded3f2fccb8e430a80c95d1e9c2ecb5b3b5 Mon Sep 17 00:00:00 2001 From: crazysaem Date: Wed, 8 Dec 2021 20:52:46 +0000 Subject: [PATCH 07/42] ptlaunch: fix eslint errors --- apps/ptlaunch/app.js | 6 +++--- apps/ptlaunch/boot.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/ptlaunch/app.js b/apps/ptlaunch/app.js index 07b471273..8ba1adf81 100644 --- a/apps/ptlaunch/app.js +++ b/apps/ptlaunch/app.js @@ -43,7 +43,7 @@ var showMainMenu = () => { var confirmPromise = new Promise((resolve) => resolve(true)); - if (!!storedPatterns[pattern]) { + if (storedPatterns[pattern]) { log("pattern already exists. show confirmation prompt"); confirmPromise = E.showPrompt("Pattern already exists\nOverwrite?", { title: "Confirm", @@ -360,8 +360,8 @@ var getStoredPatternViaApp = (storedPatterns) => { log(patterns); patterns.forEach((pattern) => { - if (!!pattern) { - if (!!storedPatterns[pattern]) { + if (pattern) { + if (storedPatterns[pattern]) { var app = storedPatterns[pattern].app; if (!!app && !!app.name) { var appName = app.name; diff --git a/apps/ptlaunch/boot.js b/apps/ptlaunch/boot.js index f30cb2921..1433f1700 100644 --- a/apps/ptlaunch/boot.js +++ b/apps/ptlaunch/boot.js @@ -131,8 +131,8 @@ var dragHandler = (position) => { pattern = pattern.join(""); - if (!!pattern) { - if (!!storedPatterns[pattern]) { + if (pattern) { + if (storedPatterns[pattern]) { var app = storedPatterns[pattern].app; if (!!app && !!app.src) { Bangle.removeListener("drag", dragHandler); From 26cb1e58a6322b7c976038d33d8f8197b335053f Mon Sep 17 00:00:00 2001 From: ps-igel <60899838+ps-igel@users.noreply.github.com> Date: Wed, 8 Dec 2021 23:17:06 +0100 Subject: [PATCH 08/42] enhance for use with Bangle2, add new draw mode --- apps.json | 3 +-- apps/numerals/ChangeLog | 1 + apps/numerals/README.md | 14 +++++++--- apps/numerals/numerals.app.js | 41 ++++++++++++++++++++++-------- apps/numerals/numerals.settings.js | 4 +-- 5 files changed, 45 insertions(+), 18 deletions(-) diff --git a/apps.json b/apps.json index e5d6dad8a..ef4ec7db6 100644 --- a/apps.json +++ b/apps.json @@ -2086,12 +2086,11 @@ "id": "numerals", "name": "Numerals Clock", "shortName": "Numerals Clock", - "version": "0.09", "description": "A simple big numerals clock", "icon": "numerals.png", "type": "clock", "tags": "numerals,clock", - "supports": ["BANGLEJS"], + "supports": ["BANGLEJS","BANGLEJS2"], "allow_emulator": true, "screenshots": [{"url":"bangle1-numerals-screenshot.png"}], "storage": [ diff --git a/apps/numerals/ChangeLog b/apps/numerals/ChangeLog index f94d719f4..57818c180 100644 --- a/apps/numerals/ChangeLog +++ b/apps/numerals/ChangeLog @@ -7,3 +7,4 @@ 0.07: Add date on touch and some improvements (see settings and readme) 0.08: Add new draw styles, tidy up draw functionality 0.09: Tweak for faster rendering +0.10: Enhance for use with Bangle2, insert new draw mode 'thickfill' \ No newline at end of file diff --git a/apps/numerals/README.md b/apps/numerals/README.md index ebf4c10fe..7a8c25212 100644 --- a/apps/numerals/README.md +++ b/apps/numerals/README.md @@ -7,14 +7,20 @@ Settings can be accessed through the app/widget settings menu of the Bangle.js ### Color: * rnd - shows numerals in different color combinations every time the watches wakes -* r/g - red/green -* y/w - yellow/white -* o/c - orange/cyan -* b/y - blue/yellow'ish +* r/g - red/green (Bangle1/Bangle2) +* y/w - yellow/white (Bangle1 only) +* o/c - orange/cyan (Bangle1 only) +* b/y - blue/yellow'ish (Bangle1 only) +* r/g - red/green (Bangle2 only) +* g/b - green/blue (Bangle2 only) +* r/c - red/cyan (Bangle2 only) +* m/g - magenta/green (Bangle2 only) ### Draw mode * fill - fill numerals * frame - only shows outline of numerals +* framefill - frame with lighter color fill +* thickfill - thick frame in theme foreground color ### Menu button * choose button to start launcher menu with diff --git a/apps/numerals/numerals.app.js b/apps/numerals/numerals.app.js index 3c7607eb1..baf859915 100644 --- a/apps/numerals/numerals.app.js +++ b/apps/numerals/numerals.app.js @@ -6,7 +6,7 @@ * + see README.md for details */ -var numerals = { + var numerals = { 0:[[9,1,82,1,90,9,90,92,82,100,9,100,1,92,1,9],[30,25,61,25,69,33,69,67,61,75,30,75,22,67,22,33]], 1:[[50,1,82,1,90,9,90,92,82,100,73,100,65,92,65,27,50,27,42,19,42,9]], 2:[[9,1,82,1,90,9,90,53,82,61,21,61,21,74,82,74,90,82,90,92,82,100,9,100,1,92,1,48,9,40,70,40,70,27,9,27,1,19,1,9]], @@ -19,8 +19,8 @@ var numerals = { 9:[[9,1,82,1,90,9,90,92,82,100,9,100,1,92,1,82,9,74,69,74,69,61,9,61,1,53,1,9],[22,27,69,27,69,41,22,41]], }; var _12hour = (require("Storage").readJSON("setting.json",1)||{})["12hour"]||false; -var _hCol = ["#ff5555","#ffff00","#FF9901","#2F00FF"]; -var _mCol = ["#55ff55","#ffffff","#00EFEF","#FFBF00"]; +var _hCol = []; +var _mCol = []; var _rCol = 0; var scale = g.getWidth()/240; var interval = 0; @@ -42,15 +42,23 @@ var drawFuncs = { }, thickframe : function(poly,isHole){ g.drawPoly(poly,true); - g.drawPoly(translate(1,0,poly),true); - g.drawPoly(translate(1,1,poly),true); - g.drawPoly(translate(0,1,poly),true); + g.drawPoly(translate(1,0,poly,1),true); + g.drawPoly(translate(1,1,poly,1),true); + g.drawPoly(translate(0,1,poly,1),true); + }, + thickfill : function(poly,isHole){ + if (isHole) g.setColor(g.theme.bg); + g.fillPoly(poly,true); + g.setColor(g.theme.fg); + g.drawPoly(translate(1,0,poly,1),true); + g.drawPoly(translate(1,1,poly,1),true); + g.drawPoly(translate(0,1,poly,1),true); } }; -function translate(tx, ty, p){ +function translate(tx, ty, p, ascale){ //return p.map((x, i)=> x+((i&1)?ty:tx)); - return g.transformVertices(p, {x:tx,y:ty,scale:scale}); + return g.transformVertices(p, {x:tx,y:ty,scale:ascale==undefined?scale:ascale}); } @@ -99,6 +107,18 @@ function setUpdateInt(set){ if (set) interval=setInterval(draw, REFRESH_RATE); } +function setUp(){ + if (process.env.HWVERSION==1){ + _hCol = ["#ff5555","#ffff00","#FF9901","#2F00FF"]; + _mCol = ["#55ff55","#ffffff","#00EFEF","#FFBF00"]; + } else { + _hCol = ["#ff0000","#00ff00","#ff0000","#ff00ff"]; + _mCol = ["#00ff00","#0000ff","#00ffff","#00ff00"]; + } + if (settings.color==0) _rCol = Math.floor(Math.random()*_hCol.length); +} + +setUp(); g.clear(1); // Show launcher when button pressed Bangle.setUI("clock"); @@ -111,11 +131,12 @@ if (settings.showDate) { } Bangle.on('lcdPower', function(on){ if (on){ - if (settings.color==0) _rCol = Math.floor(Math.random()*_hCol.length); + setUp(); draw(); setUpdateInt(1); } else setUpdateInt(0); }); +Bangle.on('lock', () => setUp()); Bangle.loadWidgets(); -Bangle.drawWidgets(); +Bangle.drawWidgets(); \ No newline at end of file diff --git a/apps/numerals/numerals.settings.js b/apps/numerals/numerals.settings.js index 70f6e0d98..ae321322a 100644 --- a/apps/numerals/numerals.settings.js +++ b/apps/numerals/numerals.settings.js @@ -12,8 +12,8 @@ } let numeralsSettings = storage.readJSON('numerals.json',1); if (!numeralsSettings) resetSettings(); - let dm = ["fill","frame","framefill","thickframe"]; - let col = ["rnd","r/g","y/w","o/c","b/y"]; + let dm = ["fill","frame","framefill","thickframe","thickfill"]; + let col = process.env.HWVERSION==1?["rnd","r/g","y/w","o/c","b/y"]:["rnd","r/g","g/b","r/c","m/g"]; let btn = [[24,"BTN1"],[22,"BTN2"],[23,"BTN3"],[11,"BTN4"],[16,"BTN5"]]; var menu={ "" : { "title":"Numerals"}, From 11cfd93c9cbbad697c59b636264129855e3f2fec Mon Sep 17 00:00:00 2001 From: ps-igel <60899838+ps-igel@users.noreply.github.com> Date: Wed, 8 Dec 2021 23:19:12 +0100 Subject: [PATCH 09/42] enhance for use with Bangle2, add new draw mode --- apps.json | 1 + 1 file changed, 1 insertion(+) diff --git a/apps.json b/apps.json index ef4ec7db6..c9f04fb4d 100644 --- a/apps.json +++ b/apps.json @@ -2086,6 +2086,7 @@ "id": "numerals", "name": "Numerals Clock", "shortName": "Numerals Clock", + "version": "0.10", "description": "A simple big numerals clock", "icon": "numerals.png", "type": "clock", From 602be413864abc7ce6729eac234c7a9e1c0d4d07 Mon Sep 17 00:00:00 2001 From: Ray Holder Date: Thu, 9 Dec 2021 00:51:36 -0600 Subject: [PATCH 10/42] Fix typo for Thursday image --- apps/93dub/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/93dub/app.js b/apps/93dub/app.js index 8f662a616..1b0f69a94 100644 --- a/apps/93dub/app.js +++ b/apps/93dub/app.js @@ -93,7 +93,7 @@ function draw(){ if (w == 1) {imgW = imgMon;} if (w == 2) {imgW = imgTue;} if (w == 3) {imgW = imgWed;} - if (w == 4) {imgW = imgThr;} + if (w == 4) {imgW = imgThu;} if (w == 5) {imgW = imgFri;} if (w == 6) {imgW = imgSat;} g.drawImage(imgW, 85, 63); From b3234a8e5cabf5316e870410f2250fa986fdcf74 Mon Sep 17 00:00:00 2001 From: Ray Holder Date: Thu, 9 Dec 2021 00:53:01 -0600 Subject: [PATCH 11/42] Update Changelog for 0.05 --- apps/93dub/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/93dub/ChangeLog b/apps/93dub/ChangeLog index 36859c060..c1b2588bb 100644 --- a/apps/93dub/ChangeLog +++ b/apps/93dub/ChangeLog @@ -2,3 +2,4 @@ 0.02: DiscoMinotaur's adjustments (removed battery and adjusted spacing) 0.03: Code style cleanup 0.04: Set 00:00 to 12:00 for 12 hour time +0.05: Display time, even on Thursday From 3de4a9145437186befb4aecbdb02c11478cfb3f4 Mon Sep 17 00:00:00 2001 From: Ray Holder Date: Thu, 9 Dec 2021 00:53:41 -0600 Subject: [PATCH 12/42] Update README.md to fix markdown rendering --- apps/93dub/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/93dub/README.md b/apps/93dub/README.md index 3830ee023..4d1ade582 100644 --- a/apps/93dub/README.md +++ b/apps/93dub/README.md @@ -5,8 +5,8 @@ Uses many portions from Espruino documentation, example watchfaces, and the waveclk app. It also sourced from Jon Barlow's 91 Dub v2.0 source code and resources and adapted for Bangle.js 2's screen. Time, date and the battery display works. It is not pixel perfect to the original. Contributors: -Leer10 -Orviwan (original watchface and assets) -Gordon Williams (Bangle.js, watchapps for reference code and documentation) -DiscoMinotaur (adjustments) -Ray Holder (minor 12 hour time rendering adjustment) +* Leer10 +* Orviwan (original watchface and assets) +* Gordon Williams (Bangle.js, watchapps for reference code and documentation) +* DiscoMinotaur (adjustments) +* Ray Holder (minor 12 hour time rendering adjustment, fix Thursdays) From 907d0a3f76b64ecf71dc08a3bc60abb385c7e049 Mon Sep 17 00:00:00 2001 From: Ray Holder Date: Thu, 9 Dec 2021 00:54:42 -0600 Subject: [PATCH 13/42] Bump 93dub version to 0.05 --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index e5d6dad8a..1d8d4c00a 100644 --- a/apps.json +++ b/apps.json @@ -4575,7 +4575,7 @@ "shortName":"93 Dub", "icon": "93dub.png", "screenshots": [{"url":"screenshot.png"}], - "version":"0.04", + "version":"0.05", "description": "Fan recreation of orviwan's 91 Dub app for the Pebble smartwatch. Uses assets from his 91-Dub-v2.0 repo", "tags": "clock", "type": "clock", From 73574201bfc107aba7fdf19b3d22af2b3cf97eeb Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 9 Dec 2021 09:13:11 +0000 Subject: [PATCH 14/42] gpsrec 0.27: Map drawing with light theme (fix #1023) --- apps.json | 6 +++--- apps/gpsrec/ChangeLog | 1 + apps/gpsrec/app.js | 11 +++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps.json b/apps.json index 9e3d862e8..c47d3cf6b 100644 --- a/apps.json +++ b/apps.json @@ -727,7 +727,7 @@ { "id": "gpsrec", "name": "GPS Recorder", - "version": "0.26", + "version": "0.27", "description": "Application that allows you to record a GPS track. Can run in background", "icon": "app.png", "tags": "tool,outdoors,gps,widget", @@ -4791,7 +4791,7 @@ "icon": "app.png", "allow_emulator": true, "tags": "tools, keyboard, text, scribble", - "supports" : ["BANGLEJS2"], + "supports" : ["BANGLEJS2"], "readme": "README.md", "storage": [ {"name":"scribble.app.js","url":"app.js"}, @@ -4801,5 +4801,5 @@ { "url":"screenshot.png" } ] } - + ] diff --git a/apps/gpsrec/ChangeLog b/apps/gpsrec/ChangeLog index cb22dd13f..365405846 100644 --- a/apps/gpsrec/ChangeLog +++ b/apps/gpsrec/ChangeLog @@ -28,3 +28,4 @@ 0.24: Better support for Bangle.js 2, avoid widget area for Graphs, smooth graphs more 0.25: Fix issue where if Bangle.js 2 got a GPS fix but no reported time, errors could be caused by the widget (fix #935) 0.26: Multiple bugfixes +0.27: Map drawing with light theme (fix #1023) diff --git a/apps/gpsrec/app.js b/apps/gpsrec/app.js index df3353930..833a816ea 100644 --- a/apps/gpsrec/app.js +++ b/apps/gpsrec/app.js @@ -197,15 +197,14 @@ function plotTrack(info) { g.setColor(1,0.5,0.5); g.setFont("Vector",16); g.drawString("Track"+info.fn.toString()+" - Loading",10,220); - g.setColor(0,0,0); + g.setColor(g.theme.bg); g.fillRect(0,220,239,239); if (!info.qOSTM) { g.setColor(1, 0, 0); g.fillRect(9,80,11,120); g.fillPoly([9,60,19,80,0,80]); - g.setColor(1,1,1); + g.setColor(g.theme.fg); g.drawString("N",2,40); - g.setColor(1,1,1); } else { osm.lat = info.lat; osm.lon = info.lon; @@ -228,7 +227,7 @@ function plotTrack(info) { g.setColor(0,1,0); g.fillCircle(mp.x,mp.y,5); if (info.qOSTM) g.setColor(1,0,0.55); - else g.setColor(1,1,1); + else g.setColor(g.theme.fg); l = f.readLine(f); while(l!==undefined) { c = l.split(","); @@ -248,11 +247,11 @@ function plotTrack(info) { g.setColor(1,0,0); g.fillCircle(ox,oy,5); if (info.qOSTM) g.setColor(0, 0, 0); - else g.setColor(1,1,1); + else g.setColor(g.theme.fg); g.drawString(require("locale").distance(dist),g.getWidth() / 2, g.getHeight() - 20); g.setFont("6x8",2); g.setFontAlign(0,0,3); - g.drawString("Back",g.getWidth() - 10, g.getHeight() - 40); + g.drawString("Back",g.getWidth() - 10, g.getHeight()/2); setWatch(function() { viewTrack(info.fn, info); }, global.BTN3||BTN1); From 68cef85b6be4e594fe7b8c72fd242bd42f3b21c0 Mon Sep 17 00:00:00 2001 From: Marco H Date: Thu, 9 Dec 2021 12:51:03 +0100 Subject: [PATCH 15/42] Poweroff app -> tool and emulator --- apps.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 8cbc755d0..173439c8b 100644 --- a/apps.json +++ b/apps.json @@ -4593,9 +4593,10 @@ "version":"0.01", "description": "Simple app to power off your Bangle.js", "icon": "app.png", - "tags": "poweroff, shutdown", + "tags": "tool, poweroff, shutdown", "supports" : ["BANGLEJS", "BANGLEJS2"], "readme": "README.md", + "allow_emulator": true, "storage": [ {"name":"poweroff.app.js","url":"app.js"}, {"name":"poweroff.img","url":"app-icon.js","evaluate":true} From b98a0d262cdc0babbb36bbeaacf5f67586c25c54 Mon Sep 17 00:00:00 2001 From: crazysaem Date: Thu, 9 Dec 2021 12:02:16 +0000 Subject: [PATCH 16/42] ptlaunch: Turn on lcd when launching an app if the lock screen was disabled in the settings --- apps.json | 2 +- apps/ptlaunch/ChangeLog | 3 ++- apps/ptlaunch/boot.js | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps.json b/apps.json index 89b46e301..aacac021d 100644 --- a/apps.json +++ b/apps.json @@ -4805,7 +4805,7 @@ "id": "ptlaunch", "name": "Pattern Launcher", "shortName": "Pattern Launcher", - "version": "0.01", + "version": "0.02", "description": "Directly launch apps from the clock screen with custom patterns.", "icon": "app.png", "tags": "tools", diff --git a/apps/ptlaunch/ChangeLog b/apps/ptlaunch/ChangeLog index 4967d3207..f50936885 100644 --- a/apps/ptlaunch/ChangeLog +++ b/apps/ptlaunch/ChangeLog @@ -1 +1,2 @@ -0.01: Initial creation of the pattern launch app \ No newline at end of file +0.01: Initial creation of the pattern launch app +0.02: Turn on lcd when launching an app if the lock screen was disabled in the settings diff --git a/apps/ptlaunch/boot.js b/apps/ptlaunch/boot.js index 1433f1700..14d390b13 100644 --- a/apps/ptlaunch/boot.js +++ b/apps/ptlaunch/boot.js @@ -135,6 +135,12 @@ var dragHandler = (position) => { if (storedPatterns[pattern]) { var app = storedPatterns[pattern].app; if (!!app && !!app.src) { + if (storedPatterns.settings) { + if (storedPatterns.settings.lockDisabled) { + Bangle.setLCDPower(true); + } + } + Bangle.removeListener("drag", dragHandler); load(app.src); } From 7df753a0f75df09f24a05b781e41334b59b336be Mon Sep 17 00:00:00 2001 From: Marco H Date: Thu, 9 Dec 2021 13:29:17 +0100 Subject: [PATCH 17/42] New clock: CLI complete --- apps/clicompleteclk/app.js | 183 +++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 apps/clicompleteclk/app.js diff --git a/apps/clicompleteclk/app.js b/apps/clicompleteclk/app.js new file mode 100644 index 000000000..487dbfa07 --- /dev/null +++ b/apps/clicompleteclk/app.js @@ -0,0 +1,183 @@ +const storage = require('Storage'); +const locale = require("locale"); + +const font = "12x20"; +const fontsize = 1; +const fontheight = 19; + +const marginTop = 10; +const marginLeftTopic = 3; // margin of topics +const marginLeftData = 68; // margin of data values + +const topicColor = g.theme.dark ? "#fff" : "#000"; +const textColor = g.theme.dark ? "#0f0" : "#080"; + +let hrtValue; +let localTempValue; +let weatherTempString; +let lastHeartRateRowIndex; + +// timeout used to update every minute +var drawTimeout; +// schedule a draw for the next minute +function queueDraw() { + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = setTimeout(function() { + drawTimeout = undefined; + drawAll(false); + }, 60000 - (Date.now() % 60000)); +} + +function drawAll(drawInfoToo){ + let now = new Date(); + updateTime(now); + if (drawInfoToo) { + drawInfo(now); + } + queueDraw(); +} + +function updateTime(now){ + if (!Bangle.isLCDOn()) return; + writeLineTopic("TIME", 1); + writeLine(locale.time(now,1),1); + if(now.getMinutes() == 0) + drawInfo(now); +} + +function drawInfo(now) { + if (now == undefined) + now = new Date(); + + let i = 2; + + writeLineTopic("DOWK", i); + writeLine(locale.dow(now),i); + i++; + + writeLineTopic("DATE", i); + writeLine(locale.date(now,1),i); + i++; + + /* + writeLineTopic("BAT", i); + const b = E.getBattery(); + writeLine(b + "%", i); // TODO make bars + i++; + */ + + // weather + var weatherJson = getWeather(); + if(weatherJson && weatherJson.weather){ + const currentWeather = weatherJson.weather; + + const weatherTempValue = locale.temp(currentWeather.temp-273.15); + weatherTempString = weatherTempValue; + writeLineTopic("WTHR", i); + writeLine(currentWeather.txt,i); + i++; + } + + // temperatures (local & weather) + if (localTempValue != undefined || weatherTempString != undefined) { + writeLineTopic("TEMP", i); + let tempString = ""; + if (localTempValue != undefined) + tempString += "l: " + localTempValue; + if (tempString != "") + tempString += ", "; + if (weatherTempString != undefined) + tempString += weatherTempString; + writeLine(tempString,i); + i++; + } + + // steps + if (stepsWidget() != undefined) { + writeLineTopic("STEP", i); + const steps = stepsWidget().getSteps(); + writeLine(steps, i); + i++; + } + + drawHeartRate(i); +} + +function drawHeartRate(i) { + if (hrtValue != undefined) { + writeLineTopic("HRTM", i); + writeLine(hrtValue,i); + } + lastHeartRateRowIndex = i; +} + + +function writeLineTopic(str, line) { + var y = marginTop+line*fontheight; + g.setFont(font,fontsize); + g.setColor(topicColor).setFontAlign(-1,-1); + + g.clearRect(0,y,g.getWidth(),y+fontheight-1); + g.drawString("[" + str + "]",marginLeftTopic,y); +} + +function writeLine(str,line){ + var y = marginTop+line*fontheight; + g.setFont(font,fontsize); + g.setColor(textColor).setFontAlign(-1,-1); + g.drawString(str,marginLeftData,y); +} + + +Bangle.on('HRM', function(hrm) { + //if(hrm.confidence > 90){ + hrtValue = hrm.bpm + " bpm"; + if (Bangle.isLCDOn()) + drawHeartRate(lastHeartRateRowIndex); + //} else { + // hrtValue = undefined; + //} +}); + + +function getTemperature() { + if (Bangle.getPressure) { + Bangle.getPressure().then(onTemperature); + } else { + onTemperature({ + temperature : E.getTemperature() + }); + } +} +function onTemperature(p) { + localTempValue = locale.temp(p.temperature.toFixed(1)); +} + +function stepsWidget() { + if (WIDGETS.activepedom !== undefined) { + return WIDGETS.activepedom; + } else if (WIDGETS.wpedom !== undefined) { + return WIDGETS.wpedom; + } + return undefined; +} + + +function getWeather() { + let jsonWeather = storage.readJSON('weather.json'); + return jsonWeather; +} + +g.clear(); +Bangle.setUI("clock"); +Bangle.loadWidgets(); +Bangle.drawWidgets(); +drawAll(true); +Bangle.on('lcdPower',function(on) { + if (on) { + drawAll(true); + } else { + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = undefined; + } +}); From a1599a967b0cf5223c0e96c041e14c98b6212ff7 Mon Sep 17 00:00:00 2001 From: Marco H Date: Thu, 9 Dec 2021 13:29:54 +0100 Subject: [PATCH 18/42] Adding icons, readme and changelog --- apps/clicompleteclk/ChangeLog | 1 + apps/clicompleteclk/README.md | 18 ++++++++++++++++++ apps/clicompleteclk/app-icon.js | 1 + apps/clicompleteclk/app.png | Bin 0 -> 258 bytes 4 files changed, 20 insertions(+) create mode 100644 apps/clicompleteclk/ChangeLog create mode 100644 apps/clicompleteclk/README.md create mode 100644 apps/clicompleteclk/app-icon.js create mode 100644 apps/clicompleteclk/app.png diff --git a/apps/clicompleteclk/ChangeLog b/apps/clicompleteclk/ChangeLog new file mode 100644 index 000000000..85b5360ad --- /dev/null +++ b/apps/clicompleteclk/ChangeLog @@ -0,0 +1 @@ +0.01: New clock! diff --git a/apps/clicompleteclk/README.md b/apps/clicompleteclk/README.md new file mode 100644 index 000000000..653123187 --- /dev/null +++ b/apps/clicompleteclk/README.md @@ -0,0 +1,18 @@ +# Command line complete clock + +Command line styled clock with lots of information: + +It can show the following (depending on availability) information: +* Time +* Day of week +* Date +* Weather condition (requires weather app) +* Temperature (requires weather app) +* Steps (requires a step widget) +* Heart rate + +## Creator +Marco ([myxor](https://github.com/myxor)) + +## Icon +Icon taken from [materialdesignicons](https://materialdesignicons.com) under Apache License 2.0 diff --git a/apps/clicompleteclk/app-icon.js b/apps/clicompleteclk/app-icon.js new file mode 100644 index 000000000..b874bb6fa --- /dev/null +++ b/apps/clicompleteclk/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwgI/8/4ACAqYv/F/PwAqgA6A==")) diff --git a/apps/clicompleteclk/app.png b/apps/clicompleteclk/app.png new file mode 100644 index 0000000000000000000000000000000000000000..104e6124afa8fcb86f8f8c625912eb4f933ca51a GIT binary patch literal 258 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC&H|6fVg?3oArNM~bhqvgP;iT< zi(^Oz>)RO@xf&FBTsQB3zkKr|^Te1V)3#eU@t2n79Y5=M`cMM{ivj~9$DbJo%8qUG zuhWx16zKF+>|508S;{^=CznpCii%LyUMQej@Y|0ePyN!b*XFKsLhv}Q9i~I>c#?<+C3pmbRd)r-MrtmGC#VF{-rk^(|_VTaz zZ?kt|VedDg>Z*Uw{T&!L>L-aZSb?43aA4K}#>F$3-mEKrrVn&KgQu&X%Q~loCIB;9 BV`cyV literal 0 HcmV?d00001 From 93361297bd23d90dde7538a64a32f456cdd4614a Mon Sep 17 00:00:00 2001 From: Marco H Date: Thu, 9 Dec 2021 13:31:12 +0100 Subject: [PATCH 19/42] Add clicompleteclk to apps.json --- apps.json | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 8cbc755d0..f9d417b95 100644 --- a/apps.json +++ b/apps.json @@ -4825,5 +4825,20 @@ { "name": "ptlaunch.img", "url": "app-icon.js", "evaluate": true } ], "data": [{"name":"ptlaunch.patterns.json"}] - } + }, + { "id": "clicompleteclk", + "name": "Command line complete clock", + "shortName":"Command line complete clock", + "version":"0.01", + "description": "Command line styled clock with lots of information", + "icon": "app.png", + "type": "clock", + "tags": "clock,cli,command,bash,shell,weather,hrt", + "supports" : ["BANGLEJS", "BANGLEJS2"], + "readme": "README.md", + "storage": [ + {"name":"clicompleteclk.app.js","url":"app.js"}, + {"name":"clicompleteclk.img","url":"app-icon.js","evaluate":true} + ] +} ] From 32107c668eda2e644560dd158a7b8e30a0db3f4a Mon Sep 17 00:00:00 2001 From: Marco H Date: Thu, 9 Dec 2021 13:34:33 +0100 Subject: [PATCH 20/42] Make shortName short --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index f9d417b95..231e40949 100644 --- a/apps.json +++ b/apps.json @@ -4828,7 +4828,7 @@ }, { "id": "clicompleteclk", "name": "Command line complete clock", - "shortName":"Command line complete clock", + "shortName":"Cli cmplt clk", "version":"0.01", "description": "Command line styled clock with lots of information", "icon": "app.png", From e5da5b8040963d060dfc88d22e39cfad04687e4b Mon Sep 17 00:00:00 2001 From: Jade Edward Date: Thu, 9 Dec 2021 23:34:52 +1100 Subject: [PATCH 21/42] Copy from widmp, flip phases --- apps.json | 13 +++++++++++++ apps/widmpsh/ChangeLog | 1 + apps/widmpsh/widget.js | 25 +++++++++++++++++++++++++ apps/widmpsh/widget.png | Bin 0 -> 2390 bytes 4 files changed, 39 insertions(+) create mode 100644 apps/widmpsh/ChangeLog create mode 100644 apps/widmpsh/widget.js create mode 100644 apps/widmpsh/widget.png diff --git a/apps.json b/apps.json index 8cbc755d0..32e944b44 100644 --- a/apps.json +++ b/apps.json @@ -1937,6 +1937,19 @@ {"name":"widmp.wid.js","url":"widget.js"} ] }, + { + "id": "widmpsh", + "name": "Moon Phase Widget Southern Hemisphere", + "version": "0.01", + "description": "Display the current moon phase in blueish for the southern hemisphere in eight phases", + "icon": "widget.png", + "type": "widget", + "tags": "widget,tools", + "supports": ["BANGLEJS","BANGLEJS2"], + "storage": [ + {"name":"widmpsh.wid.js","url":"widget.js"} + ] + }, { "id": "minionclk", "name": "Minion clock", diff --git a/apps/widmpsh/ChangeLog b/apps/widmpsh/ChangeLog new file mode 100644 index 000000000..e432f82e5 --- /dev/null +++ b/apps/widmpsh/ChangeLog @@ -0,0 +1 @@ +0.01: Copied from widmp and flipped the phase directions! diff --git a/apps/widmpsh/widget.js b/apps/widmpsh/widget.js new file mode 100644 index 000000000..9115a4719 --- /dev/null +++ b/apps/widmpsh/widget.js @@ -0,0 +1,25 @@ +WIDGETS["widmoonsh"] = { area: "tr", width: 24, draw: function() { + const MC = 29.5305882, NM = 694039.09; + var r = 11, mx = this.x + 12; my = this.y + 12; + + function moonPhase(d) { + var tmp, month = d.getMonth(), year = d.getFullYear(), day = d.getDate(); + if (month < 3) {year--; month += 12;} + tmp = ((365.25 * year + 30.6 * ++month + day - NM) / MC); + return Math.round(((tmp - (tmp | 0)) * 7)+1); + } + + const BLACK = g.theme.bg, MOON = 0x41f; + var moon = { + 0: () => { g.reset().setColor(BLACK).fillRect(mx - r, my - r, mx + r, my + r);}, + 1: () => { moon[0](); g.setColor(MOON).drawCircle(mx, my, r);}, + 2: () => { moon[3](); g.setColor(BLACK).fillEllipse(mx - r / 2, my - r, mx + r / 2, my + r);}, + 3: () => { moon[0](); g.setColor(MOON).fillCircle(mx, my, r).setColor(BLACK).fillRect(mx, my - r, mx + r, my + r);}, + 4: () => { moon[3](); g.setColor(MOON).fillEllipse(mx - r / 2, my - r, mx + r / 2, my + r);}, + 5: () => { moon[0](); g.setColor(MOON).fillCircle(mx, my, r);}, + 6: () => { moon[7](); g.setColor(MOON).fillEllipse(mx - r / 2, my - r, mx + r / 2, my + r);}, + 7: () => { moon[0](); g.setColor(MOON).fillCircle(mx, my, r).setColor(BLACK).fillRect(mx - r, my - r, mx, my + r);}, + 8: () => { moon[7](); g.setColor(BLACK).fillEllipse(mx - r / 2, my - r, mx + r / 2, my + r);} + }; + moon[moonPhase(Date())](); +} }; diff --git a/apps/widmpsh/widget.png b/apps/widmpsh/widget.png new file mode 100644 index 0000000000000000000000000000000000000000..aeaadea4bcfce546885d44d7f63c4495cf2e6a85 GIT binary patch literal 2390 zcmZ`*3p|ti8-FL0OCltfux6FhVVg@XYc3ON$L4MpMJ~gPZEUgRxTTQga@+Xg>@kzDwo7Y{5SQl^Y3%c@BO^*@A*C7=lgx0=l6R*pZ865a@Zp)ttJfs zfGl>ejf-$bif%~>;nPEmpDdijgD`ju09?+HS@H!7*AV}`E_eWl-Ua~iNdO=ay5h$G z;E<5`?jQi5H~_GTUUc0VEd-oML~I})59|=yl7JXU0azonK*9@1CIjNDHUJ2fgkw!9 z=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WVv7Tzwv;QlBalj+iF%z|FOU5N zew%mY!+=lw>^+zhuYV%m`!MXZe$9YKuDQ}cN`-Ck zQGIBO-O|CHvO1irV!iU&JOE*RCpPStrP*VVvk!F{J3uYBUwD;kK6{N#UwE&JZ!3(n zzE~v*J4Y$1vaFwDg#@QpiBEk7Zpsjdy()4qwx{WC+7fT|l&q&dcm1KvWBilLr7%F< z@O~Jr3|2Z(%2rwqh88K$_3TYJ5$fv0XfEgM+$cU(qmXD(Es6Uyvxnh=d{ZXYh&vIQ z_WFuJbClM&HwK`kVx4f?+O5oVy{FWm$_`qVQ=3MVxUq?BjJB2EvY`Rn(RR33a?m+D9HKi?d5fGnovgjSSLtUO-xlx+Ts#dYQGl$y57EeZG4dM_seF$Iy?kV3S9 z;$mRN#lU(2spqUiw;iwC2MlshiqpmzHT5ZawYlM&j23Ojerrjn9J=6$Db=}Btxl-O zvH`&}?xn{xz;2V>PeWXGAHbwB|_$6?WSDyAb-=Yl~(xR`y3TkzTJ*O~6-JzPel->a$ z9Iin$1cV0thjJ!a;?h|V zku#4kIad4gNg|zjddiV(lFmfN{KAxS)KOi^{tsj=B?&d-X98lZVnfly7{FeeYDS!% zAD!lbkJ63n)f)N=i)Aqr9+B&$DoS+fcPQ8L12{A*3GgK2BQ&)c(iM=pcD5o8r)0aq zB}Olcc+~(_5=TNWbmevwoJP@wmDB*BXLwk(-ZVt38$9070Z#|-&}Ey{KmHDjue zy+Irrl&j!ynKG_fAG&XN(tWzLQOm9(nB6PPVUM{M^P4A6s5V)6At_v0wG%DG70)B!Qw2O7kI6 P^xJ{8b+D Date: Thu, 9 Dec 2021 13:38:10 +0100 Subject: [PATCH 22/42] Make names even shorter + allow emulator --- apps.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps.json b/apps.json index 231e40949..340fb6f13 100644 --- a/apps.json +++ b/apps.json @@ -4827,11 +4827,12 @@ "data": [{"name":"ptlaunch.patterns.json"}] }, { "id": "clicompleteclk", - "name": "Command line complete clock", - "shortName":"Cli cmplt clk", + "name": "CLI cmplt clock", + "shortName":"CLI cmplt clk", "version":"0.01", "description": "Command line styled clock with lots of information", "icon": "app.png", + "allow_emulator": true, "type": "clock", "tags": "clock,cli,command,bash,shell,weather,hrt", "supports" : ["BANGLEJS", "BANGLEJS2"], From 7ce4ada3dff0e844cc1386ca9bb5a64a20ddf834 Mon Sep 17 00:00:00 2001 From: Marco H Date: Thu, 9 Dec 2021 13:40:33 +0100 Subject: [PATCH 23/42] Fix names (again) --- apps.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps.json b/apps.json index 340fb6f13..cb920f43d 100644 --- a/apps.json +++ b/apps.json @@ -4827,8 +4827,8 @@ "data": [{"name":"ptlaunch.patterns.json"}] }, { "id": "clicompleteclk", - "name": "CLI cmplt clock", - "shortName":"CLI cmplt clk", + "name": "CLI complete clock", + "shortName":"CLI cmplt clock", "version":"0.01", "description": "Command line styled clock with lots of information", "icon": "app.png", From 7b09fd9b4f7b9c998df6a4b644ce6d0b4dfb63b8 Mon Sep 17 00:00:00 2001 From: Marco H Date: Thu, 9 Dec 2021 14:53:22 +0100 Subject: [PATCH 24/42] Add todo to README --- apps/clicompleteclk/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/clicompleteclk/README.md b/apps/clicompleteclk/README.md index 653123187..e182b55fd 100644 --- a/apps/clicompleteclk/README.md +++ b/apps/clicompleteclk/README.md @@ -9,7 +9,12 @@ It can show the following (depending on availability) information: * Weather condition (requires weather app) * Temperature (requires weather app) * Steps (requires a step widget) -* Heart rate +* Heart rate (when screen is on and unlocked) + +## TODO +* Make time font bigger +* Show progress of steps (if any goal is set) +* Show trend of HRM out of history data ## Creator Marco ([myxor](https://github.com/myxor)) From 5903aed3e437f8a5bbc76bff49d12720ffe19940 Mon Sep 17 00:00:00 2001 From: Marco H Date: Thu, 9 Dec 2021 14:53:51 +0100 Subject: [PATCH 25/42] Turn on HRM when screen is on and unlocked --- apps/clicompleteclk/app.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/clicompleteclk/app.js b/apps/clicompleteclk/app.js index 487dbfa07..cc7fd5e41 100644 --- a/apps/clicompleteclk/app.js +++ b/apps/clicompleteclk/app.js @@ -104,9 +104,11 @@ function drawInfo(now) { } function drawHeartRate(i) { + writeLineTopic("HRTM", i); if (hrtValue != undefined) { - writeLineTopic("HRTM", i); writeLine(hrtValue,i); + } else { + writeLine("-",i); } lastHeartRateRowIndex = i; } @@ -129,6 +131,15 @@ function writeLine(str,line){ } +// turn on HRM when the LCD is unlocked +Bangle.on('lock', function(isLocked) { + if (!isLocked) { + Bangle.setHRMPower(1,"clicompleteclk"); + hrtValue = undefined; + } else { + Bangle.setHRMPower(0,"clicompleteclk"); + } +}); Bangle.on('HRM', function(hrm) { //if(hrm.confidence > 90){ hrtValue = hrm.bpm + " bpm"; @@ -173,6 +184,7 @@ Bangle.setUI("clock"); Bangle.loadWidgets(); Bangle.drawWidgets(); drawAll(true); + Bangle.on('lcdPower',function(on) { if (on) { drawAll(true); From 0a67d177bbf44f8ff2e8fc9a65e63222930eacb3 Mon Sep 17 00:00:00 2001 From: Marco H Date: Thu, 9 Dec 2021 15:35:17 +0100 Subject: [PATCH 26/42] Update app.js * Remove local temperature * Draw heart rate value in grey if the value is not up to date --- apps/clicompleteclk/app.js | 75 +++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 41 deletions(-) diff --git a/apps/clicompleteclk/app.js b/apps/clicompleteclk/app.js index cc7fd5e41..89dbce919 100644 --- a/apps/clicompleteclk/app.js +++ b/apps/clicompleteclk/app.js @@ -13,6 +13,7 @@ const topicColor = g.theme.dark ? "#fff" : "#000"; const textColor = g.theme.dark ? "#0f0" : "#080"; let hrtValue; +let hrtValueIsOld = false; let localTempValue; let weatherTempString; let lastHeartRateRowIndex; @@ -76,19 +77,9 @@ function drawInfo(now) { writeLineTopic("WTHR", i); writeLine(currentWeather.txt,i); i++; - } - // temperatures (local & weather) - if (localTempValue != undefined || weatherTempString != undefined) { writeLineTopic("TEMP", i); - let tempString = ""; - if (localTempValue != undefined) - tempString += "l: " + localTempValue; - if (tempString != "") - tempString += ", "; - if (weatherTempString != undefined) - tempString += weatherTempString; - writeLine(tempString,i); + writeLine(weatherTempValue,i); i++; } @@ -104,11 +95,16 @@ function drawInfo(now) { } function drawHeartRate(i) { + if (i == undefined) + i = lastHeartRateRowIndex; writeLineTopic("HRTM", i); if (hrtValue != undefined) { - writeLine(hrtValue,i); + if (!hrtValueIsOld) + writeLine(hrtValue,i); + else + writeLine(hrtValue,i, topicColor); } else { - writeLine("-",i); + writeLine("...",i); } lastHeartRateRowIndex = i; } @@ -123,47 +119,54 @@ function writeLineTopic(str, line) { g.drawString("[" + str + "]",marginLeftTopic,y); } -function writeLine(str,line){ +function writeLine(str,line,pColor){ + if (pColor == undefined) + pColor = textColor; var y = marginTop+line*fontheight; g.setFont(font,fontsize); - g.setColor(textColor).setFontAlign(-1,-1); + g.setColor(pColor).setFontAlign(-1,-1); g.drawString(str,marginLeftData,y); } +// EVENTS: // turn on HRM when the LCD is unlocked Bangle.on('lock', function(isLocked) { if (!isLocked) { Bangle.setHRMPower(1,"clicompleteclk"); - hrtValue = undefined; + if (hrtValue == undefined) + hrtValue = "..."; + else + hrtValueIsOld = true; + drawHeartRate(); } else { + hrtValueIsOld = true; Bangle.setHRMPower(0,"clicompleteclk"); } }); + +Bangle.on('lcdPower',function(on) { + if (on) { + drawAll(true); + } else { + hrtValueIsOld = true; + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = undefined; + } +}); + Bangle.on('HRM', function(hrm) { //if(hrm.confidence > 90){ - hrtValue = hrm.bpm + " bpm"; + hrtValueIsOld = false; + hrtValue = hrm.bpm; if (Bangle.isLCDOn()) - drawHeartRate(lastHeartRateRowIndex); + drawHeartRate(); //} else { // hrtValue = undefined; //} }); -function getTemperature() { - if (Bangle.getPressure) { - Bangle.getPressure().then(onTemperature); - } else { - onTemperature({ - temperature : E.getTemperature() - }); - } -} -function onTemperature(p) { - localTempValue = locale.temp(p.temperature.toFixed(1)); -} - function stepsWidget() { if (WIDGETS.activepedom !== undefined) { return WIDGETS.activepedom; @@ -173,7 +176,6 @@ function stepsWidget() { return undefined; } - function getWeather() { let jsonWeather = storage.readJSON('weather.json'); return jsonWeather; @@ -184,12 +186,3 @@ Bangle.setUI("clock"); Bangle.loadWidgets(); Bangle.drawWidgets(); drawAll(true); - -Bangle.on('lcdPower',function(on) { - if (on) { - drawAll(true); - } else { - if (drawTimeout) clearTimeout(drawTimeout); - drawTimeout = undefined; - } -}); From 978de345ee55a4f908930f4140b3b5d1e3a58a20 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 9 Dec 2021 14:56:36 +0000 Subject: [PATCH 27/42] fwupdate 0.02: Add support for ZIPs Find and download ZIPs direct from the Espruino website Take 'beta' tag off --- apps.json | 4 +- apps/fwupdate/ChangeLog | 3 + apps/fwupdate/custom.html | 151 ++++++++++++++++++++++++++++---------- 3 files changed, 117 insertions(+), 41 deletions(-) diff --git a/apps.json b/apps.json index c47d3cf6b..6deee8fa4 100644 --- a/apps.json +++ b/apps.json @@ -1,8 +1,8 @@ [ { "id": "fwupdate", - "name": "Firmware Update (BETA)", - "version": "0.01", + "name": "Firmware Update", + "version": "0.02", "description": "Uploads new Espruino firmwares to Bangle.js 2", "icon": "app.png", "type": "RAM", diff --git a/apps/fwupdate/ChangeLog b/apps/fwupdate/ChangeLog index ec66c5568..96e7e4e9b 100644 --- a/apps/fwupdate/ChangeLog +++ b/apps/fwupdate/ChangeLog @@ -1 +1,4 @@ 0.01: Initial version +0.02: Add support for ZIPs + Find and download ZIPs direct from the Espruino website + Take 'beta' tag off diff --git a/apps/fwupdate/custom.html b/apps/fwupdate/custom.html index 7230a77a8..4ee99479b 100644 --- a/apps/fwupdate/custom.html +++ b/apps/fwupdate/custom.html @@ -3,29 +3,44 @@ -

THIS IS CURRENTLY BETA - PLEASE USE THE NORMAL FIRMWARE UPDATE - INSTRUCTIONS FOR BANGLE.JS 1 AND BANGLE.JS 2

-

Firmware updates using the App Loader are only possible on +

Firmware updates using the App Loader are only possible on Bangle.js 2. For firmware updates on Bangle.js 1 please - see the Bangle.js 1 instructions

+ see the Bangle.js 1 instructions

+

Your current firmware version is unknown

+

Firmware updates via this tool work differently to the NRF Connect method mentioned on + the Bangle.js page. Firmware + is uploaded to a file on the Bangle. Once complete the Bangle reboots and the bootloader copies + the new firmware into internal Storage.

+

 
     
+    
+    
 
     
   

From 61553056da20cd3e1f126d732cb9043bbb126b8b Mon Sep 17 00:00:00 2001
From: Gordon Williams 
Date: Thu, 9 Dec 2021 15:56:37 +0000
Subject: [PATCH 28/42] app notes

---
 apps.json | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/apps.json b/apps.json
index 6deee8fa4..5abbfb1f8 100644
--- a/apps.json
+++ b/apps.json
@@ -79,7 +79,7 @@
     "name": "Android Integration",
     "shortName": "Android",
     "version": "0.04",
-    "description": "(BETA) App to display notifications from Gadgetbridge on Android. This will eventually replace the Gadgetbridge widget.",
+    "description": "Display notifications/music/etc from Gadgetbridge on Android. This replaces the old Gadgetbridge widget.",
     "icon": "app.png",
     "tags": "tool,system,messages,notifications",
     "dependencies": {"messages":"app"},
@@ -96,7 +96,7 @@
     "id": "ios",
     "name": "iOS Integration",
     "version": "0.06",
-    "description": "(BETA) App to display notifications from iOS devices",
+    "description": "Display notifications/music/etc from iOS devices",
     "icon": "app.png",
     "tags": "tool,system,ios,apple,messages,notifications",
     "dependencies": {"messages":"app"},
@@ -283,7 +283,7 @@
     "id": "gbridge",
     "name": "Gadgetbridge",
     "version": "0.24",
-    "description": "The default notification handler for Gadgetbridge notifications from Android. This will eventually be replaced by the 'Android' app.",
+    "description": "(NOT RECOMMENDED) Handles Gadgetbridge notifications from Android. This is now replaced by the 'Android' app.",
     "icon": "app.png",
     "type": "widget",
     "tags": "tool,system,android,widget",

From 52ed2c3b5d5bf447f6a21c252acf65ac5acb143e Mon Sep 17 00:00:00 2001
From: Gordon Williams 
Date: Thu, 9 Dec 2021 15:56:58 +0000
Subject: [PATCH 29/42] 0.04: Fix widget hiding code (fix #1046)

---
 apps.json                 |  6 +++---
 apps/pebble/ChangeLog     |  1 +
 apps/pebble/pebble.app.js | 11 ++++++-----
 apps/widviz/ChangeLog     |  6 +++---
 apps/widviz/widget.js     | 11 ++++++++---
 5 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/apps.json b/apps.json
index 5abbfb1f8..484ea6f7e 100644
--- a/apps.json
+++ b/apps.json
@@ -2642,12 +2642,12 @@
     "id": "widviz",
     "name": "Widget Visibility Widget",
     "shortName": "Viz Widget",
-    "version": "0.02",
+    "version": "0.03",
     "description": "Swipe left to hide top bar widgets, swipe right to redisplay.",
     "icon": "eye.png",
     "type": "widget",
     "tags": "widget",
-    "supports": ["BANGLEJS"],
+    "supports": ["BANGLEJS","BANGLESJ2"],
     "storage": [
       {"name":"widviz.wid.js","url":"widget.js"}
     ]
@@ -4670,7 +4670,7 @@
     "id": "pebble",
     "name": "Pebble Clock",
     "shortName": "Pebble",
-    "version": "0.03",
+    "version": "0.04",
     "description": "A pebble style clock to keep the rebellion going",
     "readme": "README.md",
     "icon": "pebble.png",
diff --git a/apps/pebble/ChangeLog b/apps/pebble/ChangeLog
index fc3ff3ba4..76f90de8b 100644
--- a/apps/pebble/ChangeLog
+++ b/apps/pebble/ChangeLog
@@ -1,3 +1,4 @@
 0.01: first release
 0.02: included deployment of pebble.settings.js in apps.json
 0.03: Changed time+calendar font to LECO1976Regular, changed to slanting boot
+0.04: Fix widget hiding code (fix #1046)
diff --git a/apps/pebble/pebble.app.js b/apps/pebble/pebble.app.js
index ce9ab3340..106e09b82 100644
--- a/apps/pebble/pebble.app.js
+++ b/apps/pebble/pebble.app.js
@@ -34,7 +34,7 @@ function draw() {
   // turn the warning on once we have dipped below 30%
   if (E.getBattery() < 30)
     batteryWarning = true;
-  
+
   // turn the warning off once we have dipped above 40%
   if (E.getBattery() > 40)
     batteryWarning = false;
@@ -57,7 +57,7 @@ function draw() {
   g.setFontAlign(0, -1);
   g.drawString(da[0].toUpperCase(), w/4, ha); // day of week
   g.drawString(getSteps(), 3*w/4, ha);
-  
+
   // time
   // white on red for battery warning
   g.setColor(!batteryWarning ? g.theme.bg : '#f00');
@@ -71,7 +71,7 @@ function draw() {
   // contrast bar
   g.setColor(g.theme.fg);
   g.fillRect(0, h3, w, h3 + t);
-  
+
   // the bottom
   g.setColor(settings.bg);
   g.fillRect(0, h3 + t, w, h);
@@ -111,9 +111,10 @@ g.clear();
 Bangle.loadWidgets();
 /*
  * we are not drawing the widgets as we are taking over the whole screen
- * so we will blank out the draw() functions of each widget
+ * so we will blank out the draw() functions of each widget and change the
+ * area to the top bar doesn't get cleared.
  */
-for (let wd of WIDGETS) {wd.draw=()=>{};}
+for (let wd of WIDGETS) {wd.draw=()=>{};wd.area="";}
 loadSettings();
 setInterval(draw, 15000); // refresh every 15s
 draw();
diff --git a/apps/widviz/ChangeLog b/apps/widviz/ChangeLog
index e1958b429..9785f4d84 100644
--- a/apps/widviz/ChangeLog
+++ b/apps/widviz/ChangeLog
@@ -1,3 +1,3 @@
- 0.01: New Widget
- 0.02: swipe left,right update
- 
+0.01: New Widget
+0.02: swipe left,right update
+0.03: Fix widget visibility code to the top bar isn't cleared by drawWidgets 
diff --git a/apps/widviz/widget.js b/apps/widviz/widget.js
index 241dabf61..1490cf11a 100644
--- a/apps/widviz/widget.js
+++ b/apps/widviz/widget.js
@@ -6,16 +6,21 @@
     if (!Bangle.isLCDOn() || saved) return;
     saved = [];
     for (var wd of WIDGETS) {
-      saved.push(wd.draw);
+      saved.push({d:wd.draw,a:wd.area});
       wd.draw=()=>{};
+      wd.area="";
     }
     g.setColor(0,0,0);
-    g.fillRect(0,0,239,23);
+    g.fillRect(0,0,g.getWidth(),23);
   }
 
   function reveal(){
     if (!Bangle.isLCDOn() || !saved) return;
-    for (var wd of WIDGETS) wd.draw = saved.shift();
+    for (var wd of WIDGETS) {
+      var o = saved.shift();
+      wd.draw = o.d;
+      wd.area = o.a;
+    }
     Bangle.drawWidgets();
     saved=null;
   }

From f8e04ad28a348787d53e2f7aea1ee558dfab5081 Mon Sep 17 00:00:00 2001
From: Gordon Williams 
Date: Thu, 9 Dec 2021 16:16:01 +0000
Subject: [PATCH 30/42] oops

---
 apps.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apps.json b/apps.json
index 4ffdfde9c..0e85f6e65 100644
--- a/apps.json
+++ b/apps.json
@@ -2660,7 +2660,7 @@
     "icon": "eye.png",
     "type": "widget",
     "tags": "widget",
-    "supports": ["BANGLEJS","BANGLESJ2"],
+    "supports": ["BANGLEJS","BANGLEJS2"],
     "storage": [
       {"name":"widviz.wid.js","url":"widget.js"}
     ]

From 59b06d5aef7d9da0884161b55c26e285d2f25add Mon Sep 17 00:00:00 2001
From: Gordon Williams 
Date: Thu, 9 Dec 2021 16:49:28 +0000
Subject: [PATCH 31/42] boot 0.38: Option to log to file if settings.log==2
 settings 0.36: Added 'Utils' menu with helpful utilities for restoring
 Bangle.js

---
 apps.json                |  4 +--
 apps/boot/ChangeLog      |  1 +
 apps/boot/bootupdate.js  | 15 +++++++--
 apps/setting/ChangeLog   |  1 +
 apps/setting/README.md   | 23 ++++++++++----
 apps/setting/settings.js | 68 ++++++++++++++++++++++++++++++----------
 6 files changed, 84 insertions(+), 28 deletions(-)

diff --git a/apps.json b/apps.json
index 0e85f6e65..50e14dec7 100644
--- a/apps.json
+++ b/apps.json
@@ -16,7 +16,7 @@
   {
     "id": "boot",
     "name": "Bootloader",
-    "version": "0.37",
+    "version": "0.38",
     "description": "This is needed by Bangle.js to automatically load the clock, menu, widgets and settings",
     "icon": "bootloader.png",
     "type": "bootloader",
@@ -146,7 +146,7 @@
   {
     "id": "setting",
     "name": "Settings",
-    "version": "0.35",
+    "version": "0.36",
     "description": "A menu for setting up Bangle.js",
     "icon": "settings.png",
     "tags": "tool,system",
diff --git a/apps/boot/ChangeLog b/apps/boot/ChangeLog
index ffc2be495..b941a9937 100644
--- a/apps/boot/ChangeLog
+++ b/apps/boot/ChangeLog
@@ -41,3 +41,4 @@
       Don't set beep vibration up on Bangle.js 2 (built in)
 0.36: Add comments to .boot0 to make debugging a bit easier
 0.37: Remove Quiet Mode settings: now handled by Quiet Mode Schedule app
+0.38: Option to log to file if settings.log==2
diff --git a/apps/boot/bootupdate.js b/apps/boot/bootupdate.js
index daf311fe6..3001bb5c1 100644
--- a/apps/boot/bootupdate.js
+++ b/apps/boot/bootupdate.js
@@ -23,8 +23,14 @@ if (s.ble!==false) {
     boot += `bleServiceOptions.hid=Bangle.HID;\n`;
   }
 }
-if (s.blerepl===false) { // If not programmable, force terminal off Bluetooth
-  if (s.log) boot += `Terminal.setConsole(true);\n`; // if showing debug, force REPL onto terminal
+if (s.log==2) { // logging to file
+    boot += `_DBGLOG=require("Storage").open("log.txt","a");
+`;
+} if (s.blerepl===false) { // If not programmable, force terminal off Bluetooth
+  if (s.log==2) boot += `_DBGLOG=require("Storage").open("log.txt","a");
+LoopbackB.on('data',function(d) {_DBGLOG.write(d);Terminal.write(d);});
+LoopbackA.setConsole(true);\n`;
+  else if (s.log) boot += `Terminal.setConsole(true);\n`; // if showing debug, force REPL onto terminal
   else boot += `E.setConsole(null,{force:true});\n`; // on new (2v05+) firmware we have E.setConsole which allows a 'null' console
   /* If not programmable add our own handler for Bluetooth data
   to allow Gadgetbridge commands to be received*/
@@ -41,7 +47,10 @@ Bluetooth.on('line',function(l) {
     try { global.GB(JSON.parse(l.slice(3,-1))); } catch(e) {}
 });\n`;
 } else {
-  if (s.log) boot += `if (!NRF.getSecurityStatus().connected) Terminal.setConsole();\n`; // if showing debug, put REPL on terminal (until connection)
+  if (s.log==2) boot += `_DBGLOG=require("Storage").open("log.txt","a");
+LoopbackB.on('data',function(d) {_DBGLOG.write(d);Terminal.write(d);});
+if (!NRF.getSecurityStatus().connected) LoopbackA.setConsole();\n`;
+  else if (s.log) boot += `if (!NRF.getSecurityStatus().connected) Terminal.setConsole();\n`; // if showing debug, put REPL on terminal (until connection)
   else boot += `Bluetooth.setConsole(true);\n`; // else if no debug, force REPL to Bluetooth
 }
 // we just reset, so BLE should be on.
diff --git a/apps/setting/ChangeLog b/apps/setting/ChangeLog
index b393dda00..c676e3828 100644
--- a/apps/setting/ChangeLog
+++ b/apps/setting/ChangeLog
@@ -38,3 +38,4 @@
 0.33: Really fix 'beep' menu on Bangle.js 2 this time
 0.34: Remove Quiet Mode LCD settings: now handled by Quiet Mode Schedule app
 0.35: Change App/Widget settings to 'App Settings' so it fits on Bangle screen
+0.36: Added 'Utils' menu with helpful utilities for restoring Bangle.js
diff --git a/apps/setting/README.md b/apps/setting/README.md
index fb567030f..305c0b610 100644
--- a/apps/setting/README.md
+++ b/apps/setting/README.md
@@ -2,27 +2,26 @@
 
 This is Bangle.js's settings menu
 
-* **Make Connectable** regardless of the current Bluetooth settings, makes Bangle.js so you can connect to it (while the window is up)
 * **App/Widget Settings** settings specific to installed applications
 * **BLE** Bluetooth Settings menu - see below.
-* **Debug Info** should debug info be shown on the watch's screen or not?
 * **Beep** most Bangle.js do not have a speaker inside, but they can use the vibration motor to beep in different pitches. You can change the behaviour here to use a Piezo speaker if one is connected
 * **Vibration** enable/disable the vibration motor
 * **Quiet Mode** prevent notifications/alarms from vibrating/beeping/turning the screen on - see below
 * **Locale** set time zone/whether the clock is 12/24 hour (for supported clocks)
 * **Select Clock** if you have more than one clock face, select the default one
-* **HID** When Bluetooth is enabled, Bangle.js can appear as a Bluetooth Keyboard/Joystick/etc to send keypresses to a connected device.
-  * **NOTE:** on some platforms enabling HID can cause you problems when trying to connect to Bangle.js to upload apps.
 * **Set Time** Configure the current time - Note that this can be done much more easily by choosing 'Set Time' from the App Loader
 * **LCD** Configure settings about the screen. How long it stays on, how bright it is, and when it turns on - see below.
 * **Theme** Adjust the colour scheme
-* **Reset Settings** Reset the settings to defaults
+* **Utils** Utilities - including resetting settings (see below)
 * **Turn Off** Turn Bangle.js off
 
 ## BLE - Bluetooth Settings
 
+* **Make Connectable** regardless of the current Bluetooth settings, makes Bangle.js so you can connect to it (while the window is up)
 * **BLE** is Bluetooth LE enabled and the watch connectable?
 * **Programmable** if BLE is on, can the watch be connected to in order to program/upload apps? As long as your watch firmware is up to date, Gadgetbridge will work even with `Programmable` set to `Off`.
+* **HID** When Bluetooth is enabled, Bangle.js can appear as a Bluetooth Keyboard/Joystick/etc to send keypresses to a connected device.
+  * **NOTE:** on some platforms enabling HID can cause you problems when trying to connect to Bangle.js to upload apps.
 * **Passkey BETA** allows you to set a passkey that is required to connect and pair to Bangle.js. **Note:** This is Beta and you will almost certainly encounter issues connecting with Web Bluetooth using this option.
 * **Whitelist** allows you to specify only specific devices that you will let connect to your Bangle.js. Simply choose the menu item, then `Add Device`, and then connect to Bangle.js with the device you want to add. If you are already connected you will have to disconnect first. Changes will take effect when you exit the `Settings` app.
   * **NOTE:** iOS devices and newer Android devices often implement Address Randomisation and change their Bluetooth address every so often. If you device's address changes, you will be unable to connect until you update the whitelist again.
@@ -44,4 +43,16 @@ The exact effects depend on the app.  In general the watch will not wake up by i
   - Off: Normal operation
   - Alarms: Stops notifications, but "alarm" apps will still work
   - Silent: Blocks even alarms
-  
\ No newline at end of file
+
+## Utils
+
+
+* **Debug Info** should debug info be shown on the watch's screen or not?
+  * `Hide` (default) do not show debug information
+  * `Show` Show on the Bangle's screen (when not connected to Bluetooth or `Programmable:off`)
+  * `Log` Show on the Bangle's screen **and** write to a file called `log.txt` on Storage (when not connected to Bluetooth or `Programmable:off`). Warning - this file is appended to so may grow to be large if this is left enabled.
+* **Compact Storage** Removes deleted/old files from Storage - this will speed up your Bangle.js
+* **Rewrite Settings** Should not normally be required, but if `.boot0` has been deleted/corrupted (and so no settings are being loaded) this will fix it.
+* **Flatten Battery** Turns on all devices and draws as much power as possible, attempting to flatten the Bangle.js battery. This can still take 5+ hours.  
+* **Reset Settings** Reset the settings (as set in this app) to defaults. Does not reset settings for other apps.
+* **Factory Reset** (not available on Bangle.js 1) - wipe **everything** and return to a factory state
diff --git a/apps/setting/settings.js b/apps/setting/settings.js
index e00c15462..8f95eb3bb 100644
--- a/apps/setting/settings.js
+++ b/apps/setting/settings.js
@@ -95,17 +95,8 @@ function showMainMenu() {
   const mainmenu = {
     '': { 'title': 'Settings' },
     '< Back': ()=>load(),
-    'Make Connectable': ()=>makeConnectable(),
     'App Settings': ()=>showAppSettingsMenu(),
     'BLE': ()=>showBLEMenu(),
-    'Debug Info': {
-      value: settings.log,
-      format: v => v ? "Show" : "Hide",
-      onchange: () => {
-        settings.log = !settings.log;
-        updateSettings();
-      }
-    },
     'Beep': beepMenuItem,
     'Vibration': {
       value: settings.vibrate,
@@ -134,7 +125,7 @@ function showMainMenu() {
     'Set Time': ()=>showSetTimeMenu(),
     'LCD': ()=>showLCDMenu(),
     'Theme': ()=>showThemeMenu(),
-    'Reset Settings': ()=>showResetMenu(),
+    'Utils': ()=>showUtilMenu(),
     'Turn Off': ()=>{ if (Bangle.softOff) Bangle.softOff(); else Bangle.off() },
   };
 
@@ -146,6 +137,7 @@ function showBLEMenu() {
   var hidN = ["Off", "Kbrd & Media", "Kbrd","Joystick"];
   E.showMenu({
     '< Back': ()=>showMainMenu(),
+    'Make Connectable': ()=>makeConnectable(),
     'BLE': {
       value: settings.ble,
       format: boolFormat,
@@ -476,21 +468,63 @@ function showLocaleMenu() {
   return E.showMenu(localemenu);
 }
 
-function showResetMenu() {
-  const resetmenu = {
-    '': { 'title': 'Reset' },
+function showUtilMenu() {
+  var menu = {
+    '': { 'title': 'Utilities' },
     '< Back': ()=>showMainMenu(),
+    'Debug Info': {
+      value: E.clip(0|settings.log,0,2),
+      format: v => ["Hide","Show","Log"][E.clip(0|v,0,2)],
+      onchange: v => {
+        settings.log = v;
+        updateSettings();
+      }
+    },
+    'Compact Storage': () => {
+      E.showMessage("Compacting...\nTakes approx\n1 minute",{title:"Storage"});
+      require("Storage").compact();
+      showUtilMenu();
+    },
+    'Rewrite Settings': () => {
+      require("Storage").write(".boot0","eval(require('Storage').read('bootupdate.js'));");
+      load("setting.app.js");
+    },
+    'Flatten Battery': () => {
+      E.showMessage('Flattening battery - this can take hours.\nLong-press button to cancel.');
+      Bangle.setLCDTimeout(0);
+      Bangle.setLCDPower(1);
+      if (Bangle.setGPSPower) Bangle.setGPSPower(1,"flat");
+      if (Bangle.setHRMPower) Bangle.setHRMPower(1,"flat");
+      if (Bangle.setCompassPower) Bangle.setCompassPower(1,"flat");
+      if (Bangle.setBarometerPower) Bangle.setBarometerPower(1,"flat");
+      if (Bangle.setHRMPower) Bangle.setGPSPower(1,"flat");
+      setInterval(function() {
+        var i=1000;while (i--);
+      }, 1);
+    },
     'Reset Settings': () => {
-      E.showPrompt('Reset Settings?').then((v) => {
+      E.showPrompt('Reset to Defaults?',{title:"Settings"}).then((v) => {
         if (v) {
           E.showMessage('Resetting');
           resetSettings();
-        }
-        setTimeout(showMainMenu, 50);
+          setTimeout(showMainMenu, 50);
+        } else showUtilMenu();
       });
     }
   };
-  return E.showMenu(resetmenu);
+  if (Bangle.factoryReset) {
+    menu['Factory Reset'] = ()=>{
+      E.showPrompt('This will remove everything!',{title:"Factory Reset"}).then((v) => {
+        if (v) {
+          E.showMessage();
+          Terminal.setConsole();
+          Bangle.factoryReset();
+        } else showUtilMenu();
+      });
+    }
+  }
+
+  return E.showMenu(menu);
 }
 
 function makeConnectable() {

From 845a962005297ef51c05745cd721ea2a698945a7 Mon Sep 17 00:00:00 2001
From: Gordon Williams 
Date: Thu, 9 Dec 2021 17:08:18 +0000
Subject: [PATCH 32/42] cliclocks - Load widgets after Bangle.setUI to ensure
 widgets know if they're on a clock or not (fix #970)

---
 apps.json                          |  4 ++--
 apps/cliclockJS2Enhanced/ChangeLog |  1 +
 apps/cliclockJS2Enhanced/app.js    | 13 +++++++------
 apps/cliock/ChangeLog              |  1 +
 apps/cliock/app.js                 |  8 ++++----
 5 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/apps.json b/apps.json
index 50e14dec7..65dfa3188 100644
--- a/apps.json
+++ b/apps.json
@@ -1755,7 +1755,7 @@
     "id": "cliock",
     "name": "Commandline-Clock",
     "shortName": "CLI-Clock",
-    "version": "0.14",
+    "version": "0.15",
     "description": "Simple CLI-Styled Clock",
     "icon": "app.png",
     "screenshots": [{"url":"screenshot_cli.png"}],
@@ -4422,7 +4422,7 @@
     "id": "cliclockJS2Enhanced",
     "name": "Commandline-Clock JS2 Enhanced",
     "shortName": "CLI-Clock JS2",
-    "version": "0.02",
+    "version": "0.03",
     "description": "Simple CLI-Styled Clock with enhancements. Modes that are hard to use and unneded are removed (BPM, battery info, memory ect) credit to hughbarney for the original code and design. Also added HID media controlls, just swipe on the clock face to controll the media! Gadgetbride support coming soon(hopefully) Thanks to t0m1o1 for media controls!",
     "icon": "app.png",
     "screenshots": [{"url":"screengrab.png"}],
diff --git a/apps/cliclockJS2Enhanced/ChangeLog b/apps/cliclockJS2Enhanced/ChangeLog
index c7cb9e2c6..f4d146d5f 100644
--- a/apps/cliclockJS2Enhanced/ChangeLog
+++ b/apps/cliclockJS2Enhanced/ChangeLog
@@ -1,2 +1,3 @@
 0.01: Submitted to App Loader
 0.02: Removed unneded code, added HID controlls thanks to t0m1o1 for his code :p
+0.03: Load widgets after Bangle.setUI to ensure widgets know if they're on a clock or not (fix #970)
diff --git a/apps/cliclockJS2Enhanced/app.js b/apps/cliclockJS2Enhanced/app.js
index 70e86f3d6..b6172b497 100644
--- a/apps/cliclockJS2Enhanced/app.js
+++ b/apps/cliclockJS2Enhanced/app.js
@@ -50,7 +50,7 @@ if (next) {
       setTimeout(drawApp, 1000);
       Bangle.setLocked(true);
   }, BTN1, { edge:"falling",repeat:true,debounce:50});
-  Bangle.on('drag', function(e) {  
+  Bangle.on('drag', function(e) {
     if(!e.b){
       console.log(lasty);
       console.log(lastx);
@@ -91,7 +91,7 @@ if (next) {
             lasty = lasty + e.dy;
   }
   });
-  
+
 }
 
 
@@ -144,14 +144,15 @@ function writeLine(str,line){
 }
 
 g.clear();
-Bangle.loadWidgets();
-Bangle.drawWidgets();
-drawAll();
+
 Bangle.on('lcdPower',function(on) {
   if (on) drawAll();
 });
 var click = setInterval(updateTime, 1000);
 // Show launcher when button pressed
 Bangle.setUI("clockupdown", btn=>{
-  drawAll();
+  drawAll(); // why do we redraw here??
 });
+Bangle.loadWidgets();
+Bangle.drawWidgets();
+drawAll();
diff --git a/apps/cliock/ChangeLog b/apps/cliock/ChangeLog
index 2a93a0d5f..68249b622 100644
--- a/apps/cliock/ChangeLog
+++ b/apps/cliock/ChangeLog
@@ -7,3 +7,4 @@
 0.13: Use setUI, work with smaller screens and themes
 0.14: Fix BTN1 (fix #853)
       Add light/dark theme support
+0.15: Load widgets after Bangle.setUI to ensure widgets know if they're on a clock or not (fix #970)
diff --git a/apps/cliock/app.js b/apps/cliock/app.js
index 0fd6ea580..d9271bf15 100644
--- a/apps/cliock/app.js
+++ b/apps/cliock/app.js
@@ -183,9 +183,6 @@ Bangle.on('HRM', function(hrm) {
 });
 
 g.clear();
-Bangle.loadWidgets();
-Bangle.drawWidgets();
-drawAll();
 Bangle.on('lcdPower',function(on) {
   if (on) drawAll();
 });
@@ -195,4 +192,7 @@ Bangle.setUI("clockupdown", btn=>{
   if (btn<0) changeInfoMode();
   if (btn>0) changeFunctionMode();
   drawAll();
-});
\ No newline at end of file
+});
+Bangle.loadWidgets();
+Bangle.drawWidgets();
+drawAll();

From cc79881719061f2f8bbca6c2888ae76dcbfff9b6 Mon Sep 17 00:00:00 2001
From: Gordon Williams 
Date: Thu, 9 Dec 2021 17:09:40 +0000
Subject: [PATCH 33/42] fix after #1018

---
 apps.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apps.json b/apps.json
index 62e317df1..cce0b3f36 100644
--- a/apps.json
+++ b/apps.json
@@ -2419,7 +2419,7 @@
       {"name":"calendar.settings.js","url":"settings.js"},
       {"name":"calendar.img","url":"calendar-icon.js","evaluate":true}
     ],
-    "data": [{"name":"messages.json"}]
+    "data": [{"name":"calendar.json"}]
   },
   {
     "id": "hidjoystick",

From a45f7506ffbbcb622ebf791605627eabce994888 Mon Sep 17 00:00:00 2001
From: Gordon Williams 
Date: Thu, 9 Dec 2021 17:16:55 +0000
Subject: [PATCH 34/42] more app.json fixes, remove warning about settings as
 it seems nobody cares

---
 apps.json          | 4 ++--
 bin/sanitycheck.js | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/apps.json b/apps.json
index cce0b3f36..1c37cfd56 100644
--- a/apps.json
+++ b/apps.json
@@ -4095,7 +4095,7 @@
       {"name":"carcrazy.img","url":"app-icon.js","evaluate":true},
       {"name":"carcrazy.settings.js","url":"settings.js"}
     ],
-    "data": [{"name":"app.json"}]
+    "data": [{"name":"CarCrazy.csv"}]
   },
   {
     "id": "shortcuts",
@@ -4537,7 +4537,7 @@
       {"name":"schoolCalendar.img","url":"app-icon.js","evaluate":true}
     ],
     "data": [
-      {"name":"app.json"}
+      {"name":"calendarItems.csv"}
     ]
   },
   { "id": "timecal",
diff --git a/bin/sanitycheck.js b/bin/sanitycheck.js
index ea45dc19b..572364224 100755
--- a/bin/sanitycheck.js
+++ b/bin/sanitycheck.js
@@ -207,10 +207,10 @@ apps.forEach((app,appIdx) => {
     }
   });
   // prefer "appid.json" over "appid.settings.json" (TODO: change to ERROR once all apps comply?)
-  if (dataNames.includes(app.id+".settings.json") && !dataNames.includes(app.id+".json"))
+ /* if (dataNames.includes(app.id+".settings.json") && !dataNames.includes(app.id+".json"))
     WARN(`App ${app.id} uses data file ${app.id+'.settings.json'} instead of ${app.id+'.json'}`)
   else if (dataNames.includes(app.id+".settings.json"))
-    WARN(`App ${app.id} uses data file ${app.id+'.settings.json'}`)
+    WARN(`App ${app.id} uses data file ${app.id+'.settings.json'}`)*/
   // settings files should be listed under data, not storage (TODO: change to ERROR once all apps comply?)
   if (fileNames.includes(app.id+".settings.json"))
     WARN(`App ${app.id} uses storage file ${app.id+'.settings.json'} instead of data file`)

From 4ce0e39263c9ac07b641a4a285f46f17cae9a04f Mon Sep 17 00:00:00 2001
From: Richard de Boer 
Date: Thu, 9 Dec 2021 20:17:11 +0100
Subject: [PATCH 35/42] gbmusic: Fix scrolling title background color

---
 apps.json              | 2 +-
 apps/gbmusic/ChangeLog | 1 +
 apps/gbmusic/app.js    | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/apps.json b/apps.json
index 1c37cfd56..50a731430 100644
--- a/apps.json
+++ b/apps.json
@@ -3795,7 +3795,7 @@
     "id": "gbmusic",
     "name": "Gadgetbridge Music Controls",
     "shortName": "Music Controls",
-    "version": "0.07",
+    "version": "0.08",
     "description": "Control the music on your Gadgetbridge-connected phone",
     "icon": "icon.png",
     "screenshots": [{"url":"screenshot_v1.png"},{"url":"screenshot_v2.png"}],
diff --git a/apps/gbmusic/ChangeLog b/apps/gbmusic/ChangeLog
index 9cebf0a31..316b98a84 100644
--- a/apps/gbmusic/ChangeLog
+++ b/apps/gbmusic/ChangeLog
@@ -5,3 +5,4 @@
 0.05: Setting to disable double/triple press control, remove touch controls setting, reduce fadeout flicker
 0.06: Bangle.js 2 support
 0.07: Fix "previous" button image
+0.08: Fix scrolling title background color
diff --git a/apps/gbmusic/app.js b/apps/gbmusic/app.js
index f514dfccd..1bddf70f7 100644
--- a/apps/gbmusic/app.js
+++ b/apps/gbmusic/app.js
@@ -91,7 +91,7 @@ function rScroller(l) {
     y = l.y+l.h/2;
   l.offset = l.offset%w;
   g.setClipRect(l.x, l.y, l.x+l.w-1, l.y+l.h-1)
-    .setColor(l.col)
+    .setColor(l.col).setBgColor(l.bgCol) // need to set colors: iScroll calls this function outside Layout
     .setFontAlign(-1, 0) // left center
     .clearRect(l.x, l.y, l.x+l.w-1, l.y+l.h-1)
     .drawString(l.label, l.x-l.offset+40, y)

From c9ffee04a74ac44896be2bc8baaa21c11122725f Mon Sep 17 00:00:00 2001
From: Richard de Boer 
Date: Thu, 9 Dec 2021 20:54:39 +0100
Subject: [PATCH 36/42] messages: Open app when touching the widget

---
 apps.json               | 2 +-
 apps/messages/ChangeLog | 3 ++-
 apps/messages/widget.js | 6 ++++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/apps.json b/apps.json
index 1c37cfd56..e7df56c13 100644
--- a/apps.json
+++ b/apps.json
@@ -57,7 +57,7 @@
   {
     "id": "messages",
     "name": "Messages",
-    "version": "0.10",
+    "version": "0.11",
     "description": "App to display notifications from iOS and Gadgetbridge",
     "icon": "app.png",
     "type": "app",
diff --git a/apps/messages/ChangeLog b/apps/messages/ChangeLog
index 269a2cf62..a3a4f377c 100644
--- a/apps/messages/ChangeLog
+++ b/apps/messages/ChangeLog
@@ -12,4 +12,5 @@
       buzz on new message (fix #999)
 0.09: Message now disappears after 60s if no action taken and clock loads (fix 922)
       Fix phone icon (#1014)
-0.10: Respect the 'new' attribute if it was set from iOS integrations
\ No newline at end of file
+0.10: Respect the 'new' attribute if it was set from iOS integrations
+0.11: Open app when touching the widget (Bangle.js 2 only)
\ No newline at end of file
diff --git a/apps/messages/widget.js b/apps/messages/widget.js
index 245a303fc..6403c6b8d 100644
--- a/apps/messages/widget.js
+++ b/apps/messages/widget.js
@@ -1,4 +1,5 @@
 WIDGETS["messages"]={area:"tl",width:0,draw:function() {
+  Bangle.removeListener('touch', this.touch);
   if (!this.width) return;
   var c = (Date.now()-this.t)/1000;
   g.reset().setBgColor((c&1) ? "#0f0" : "#030").setColor((c&1) ? "#000" : "#fff");
@@ -12,6 +13,7 @@ WIDGETS["messages"]={area:"tl",width:0,draw:function() {
     WIDGETS["messages"].buzz(); // buzz every 4 seconds
   }
   setTimeout(()=>WIDGETS["messages"].draw(), 1000);
+  if (process.env.HWVERSION>1) Bangle.on('touch', this.touch);
 },show:function(quiet) {
   WIDGETS["messages"].t=Date.now(); // first time
   WIDGETS["messages"].l=Date.now()-10000; // last buzz
@@ -33,6 +35,10 @@ WIDGETS["messages"]={area:"tl",width:0,draw:function() {
     if (c=="-") Bangle.buzz(500).then(()=>setTimeout(b,100));
   }
   b();
+},touch:function(b,c) {
+  var w=WIDGETS["messages"];
+  if (!w||!w.width||c.xw.x+w.width||c.yw.y+23) return;
+  load("messages.app.js");
 }};
 /* We might have returned here if we were in the Messages app for a
 message but then the watch was never viewed. In that case we don't

From f8628dd26d587edff90037bcd255aacbdddaafcc Mon Sep 17 00:00:00 2001
From: Marco H 
Date: Fri, 10 Dec 2021 08:58:44 +0100
Subject: [PATCH 37/42] Update app.js

Load steps from Health Tracking app (if installed)
---
 apps/clicompleteclk/app.js | 45 +++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/apps/clicompleteclk/app.js b/apps/clicompleteclk/app.js
index 89dbce919..77dc22db6 100644
--- a/apps/clicompleteclk/app.js
+++ b/apps/clicompleteclk/app.js
@@ -68,7 +68,7 @@ function drawInfo(now) {
   */
 
   // weather
-  var weatherJson = getWeather();
+  const weatherJson = getWeather();
   if(weatherJson && weatherJson.weather){
     const currentWeather = weatherJson.weather;
 
@@ -84,9 +84,9 @@ function drawInfo(now) {
   }
 
   // steps
-  if (stepsWidget() != undefined) {
+  const steps = getSteps();
+  if (steps != undefined) {
     writeLineTopic("STEP", i);
-    const steps = stepsWidget().getSteps();
     writeLine(steps, i);
     i++;
   }
@@ -128,6 +128,30 @@ function writeLine(str,line,pColor){
   g.drawString(str,marginLeftData,y);
 }
 
+
+function getSteps() {
+  var steps = 0;
+  let health;
+  try {
+    health = require("health");
+  } catch (e) {
+    // Module health not found
+  }
+  if (health != undefined) {
+    health.readDay(new Date(), h=>steps+=h.steps);
+  } else if (WIDGETS.wpedom !== undefined) {
+    return WIDGETS.wpedom.getSteps();
+  } else if (WIDGETS.activepedom !== undefined) {
+    return WIDGETS.activepedom.getSteps();
+  }
+  return steps;
+}
+
+function getWeather() {
+  let jsonWeather = storage.readJSON('weather.json');
+  return jsonWeather;
+}
+
 // EVENTS:
 
 // turn on HRM when the LCD is unlocked
@@ -166,21 +190,6 @@ Bangle.on('HRM', function(hrm) {
   //}
 });
 
-
-function stepsWidget() {
-  if (WIDGETS.activepedom !== undefined) {
-    return WIDGETS.activepedom;
-  } else if (WIDGETS.wpedom !== undefined) {
-    return WIDGETS.wpedom;
-  }
-  return undefined;
-}
-
-function getWeather() {
-  let jsonWeather = storage.readJSON('weather.json');
-  return jsonWeather;
-}
-
 g.clear();
 Bangle.setUI("clock");
 Bangle.loadWidgets();

From 87acbe83e59c2d3f1034e09a8467a3fd12e06348 Mon Sep 17 00:00:00 2001
From: Marco H 
Date: Fri, 10 Dec 2021 08:58:52 +0100
Subject: [PATCH 38/42] Update README.md

---
 apps/clicompleteclk/README.md | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/apps/clicompleteclk/README.md b/apps/clicompleteclk/README.md
index e182b55fd..62fdbbc61 100644
--- a/apps/clicompleteclk/README.md
+++ b/apps/clicompleteclk/README.md
@@ -6,9 +6,8 @@ It can show the following (depending on availability) information:
 * Time
 * Day of week
 * Date
-* Weather condition (requires weather app)
-* Temperature (requires weather app)
-* Steps (requires a step widget)
+* Weather conditions and temperature (requires app [Weather](https://banglejs.com/apps/#weather))
+* Steps (requires app [Health Tracking](https://banglejs.com/apps/#health%20tracking) or a step widget)
 * Heart rate (when screen is on and unlocked)
 
 ## TODO

From 24b5937295fc8f84288b3932656a2db187812cf3 Mon Sep 17 00:00:00 2001
From: Marco H 
Date: Fri, 10 Dec 2021 09:09:21 +0100
Subject: [PATCH 39/42] ChangeLog: v.0.02

---
 apps/clicompleteclk/ChangeLog | 1 +
 1 file changed, 1 insertion(+)

diff --git a/apps/clicompleteclk/ChangeLog b/apps/clicompleteclk/ChangeLog
index 85b5360ad..ee05bd582 100644
--- a/apps/clicompleteclk/ChangeLog
+++ b/apps/clicompleteclk/ChangeLog
@@ -1 +1,2 @@
 0.01: New clock!
+0.02: Load steps from Health Tracking app (if installed)

From f3531c81602ab35e5f15d16f4919d56dbfd2e4c9 Mon Sep 17 00:00:00 2001
From: Marco H 
Date: Fri, 10 Dec 2021 09:27:10 +0100
Subject: [PATCH 40/42] Update apps.json

---
 apps.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apps.json b/apps.json
index 1c37cfd56..1c8efd59b 100644
--- a/apps.json
+++ b/apps.json
@@ -4845,7 +4845,7 @@
   { "id": "clicompleteclk",
   "name": "CLI complete clock",
   "shortName":"CLI cmplt clock",
-  "version":"0.01",
+  "version":"0.02",
   "description": "Command line styled clock with lots of information",
   "icon": "app.png",
   "allow_emulator": true,

From 25543abb11401c11bbb982bc38adc87cef9690ee Mon Sep 17 00:00:00 2001
From: Marco H 
Date: Fri, 10 Dec 2021 11:39:16 +0100
Subject: [PATCH 41/42] Update app.js

Do not overwrite old heart rate value with '...'
---
 apps/clicompleteclk/app.js | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/apps/clicompleteclk/app.js b/apps/clicompleteclk/app.js
index 77dc22db6..7fbdabcc1 100644
--- a/apps/clicompleteclk/app.js
+++ b/apps/clicompleteclk/app.js
@@ -103,8 +103,6 @@ function drawHeartRate(i) {
       writeLine(hrtValue,i);
     else
       writeLine(hrtValue,i, topicColor);
-  } else {
-    writeLine("...",i);
   }
   lastHeartRateRowIndex = i;
 }
@@ -162,11 +160,11 @@ Bangle.on('lock', function(isLocked) {
       hrtValue = "...";
     else
       hrtValueIsOld = true;
-    drawHeartRate();
   } else {
     hrtValueIsOld = true;
     Bangle.setHRMPower(0,"clicompleteclk");
   }
+  drawHeartRate();
 });
 
 Bangle.on('lcdPower',function(on) {

From 6b2f8e98d3a36c392b901e673763f5daeeea59a3 Mon Sep 17 00:00:00 2001
From: Gordon Williams 
Date: Fri, 10 Dec 2021 20:09:14 +0000
Subject: [PATCH 42/42] oops - fix firmware loader issues

---
 apps/fwupdate/custom.html | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/apps/fwupdate/custom.html b/apps/fwupdate/custom.html
index 4ee99479b..b5c79a325 100644
--- a/apps/fwupdate/custom.html
+++ b/apps/fwupdate/custom.html
@@ -85,7 +85,7 @@ function checkForFileOnServer() {
   	});
   }
 
-  var regex = new RegExp("_banglejs2");
+  var regex = new RegExp("_banglejs2.*zip$");
 
 	var domFirmwareList = document.getElementById("latest-firmware-list");
   var domFirmware = document.getElementById("latest-firmware");
@@ -107,7 +107,7 @@ function checkForFileOnServer() {
 			});
       console.log("Finished check for firmware files...");
       var fwlinks = document.querySelectorAll(".fw-link");
-      for (var i=0;i {
           e.preventDefault();
           var url = e.target.href;