From e10347fff061de6df414f68ae64cf2504f79e0cf Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Sun, 22 Dec 2024 18:46:31 -0500 Subject: [PATCH 01/25] initial commit of dsky_clock --- apps/dsky_clock/ChangeLog | 1 + apps/dsky_clock/README.md | 26 ++++ apps/dsky_clock/dsky_clock.app.js | 226 ++++++++++++++++++++++++++++++ apps/dsky_clock/dsky_clock.img | Bin 0 -> 1156 bytes apps/dsky_clock/metadata.json | 17 +++ apps/dsky_clock/screenshot1.png | Bin 0 -> 3169 bytes 6 files changed, 270 insertions(+) create mode 100644 apps/dsky_clock/ChangeLog create mode 100644 apps/dsky_clock/README.md create mode 100644 apps/dsky_clock/dsky_clock.app.js create mode 100644 apps/dsky_clock/dsky_clock.img create mode 100644 apps/dsky_clock/metadata.json create mode 100644 apps/dsky_clock/screenshot1.png diff --git a/apps/dsky_clock/ChangeLog b/apps/dsky_clock/ChangeLog new file mode 100644 index 0000000000..d18016d210 --- /dev/null +++ b/apps/dsky_clock/ChangeLog @@ -0,0 +1 @@ +0.01: Initial commit \ No newline at end of file diff --git a/apps/dsky_clock/README.md b/apps/dsky_clock/README.md new file mode 100644 index 0000000000..a710ae077a --- /dev/null +++ b/apps/dsky_clock/README.md @@ -0,0 +1,26 @@ +# DSKY Clock + +This is a clockface inspired by the Apollo DSKY interface. + +## Features +- battery level indicator (PROG indicator) +- month (VERB indicator) +- date (NOUN indicator) +- Current local time (DATA 1) +- UTC time (DATA 2) +- Step counter (DATA 3) + +Indicator lights are: +- COMP ACTY (GPS/HRM active) +- MSG (Messages waiting) +- LOCK (Screen is locked) +- BT (Bluetooth is disconnected) +- BATT (Low battery or battery charging) +- ALARM (Alarm is set) +- STEP (Reached STEP goal)) + +---- +This is my first watch face, may add features and customization later. + +## Creator +Written by Carl Chan | [github](https://github.com/carlchan) diff --git a/apps/dsky_clock/dsky_clock.app.js b/apps/dsky_clock/dsky_clock.app.js new file mode 100644 index 0000000000..62003f9fa9 --- /dev/null +++ b/apps/dsky_clock/dsky_clock.app.js @@ -0,0 +1,226 @@ +//Init +var Layout = require("Layout"); +require("Font7x11Numeric7Seg").add(Graphics); +require("FontTeletext5x9Ascii").add(Graphics); + +borders = 1; +Light_on='#fff'; +Light_off='#554'; +Light_warn='#f90'; +Light_COMPACTY='#0F0'; +Light_width=43; +Light_height=25; +EL7_height=30; +LightFont='Teletext5x9Ascii'; +DataFont='7x11Numeric7Seg:2'; + +var layout = new Layout( + {type:"h", c:[ + {type:"",width:6}, + { type:"v", c: [ + {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L1', label:"UPLINK\nACTY", width:Light_width, height:Light_height}, + {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L2', label:"TEMP", width:Light_width, height:Light_height }, + {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L3', label:"GIMBAL\nLOCK", width:Light_width, height:Light_height }, + {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L4', label:"STBY", width:Light_width, height:Light_height }, + {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L5', label:"PROG", width:Light_width, height:Light_height }, + {type:"txt", font:LightFont, col:"#000", bgCol:"#eee", id:'L6', label:"OPR ERR", width:Light_width, height:Light_height }, + ]}, + { type:"", width:20}, + { type:"v", c: [ + {type:"",height:2}, + {type:"h", c: [ + {type:"", width:50},{type:"txt", font:"6x8", col:"#000",bgCol:"#0F0", label:"PROG", width:25, height:10}, + ]}, + {type:"h", c: [ + {type:"",width:10}, + {type:"txt", font:"6x8", col:"#000", bgCol:"#000", id:"COMPACTY", label:"COMP\nACTY", width:26, height:26 }, + {type:"",width:17}, + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000",label:"00", id:"PROG", fillx:1, height:EL7_height }, + ]}, + {type:"",height:1}, + {type:"h", c: [ + {type:"txt", font:"6x8", col:"#000", bgCol:"#0F0",label:"VERB", width:25, height:10}, + {type:"",width:30}, + {type:"txt", font:"6x8", col:"#000",bgCol:"#0F0",label:"NOUN", width:25, height:10}, + ]}, + {type:"h", c: [ + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00", id:"VERB", fillx:1, height:EL7_height}, + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00", id:"NOUN", fillx:1, height:EL7_height}, + ]}, + { type:"",bgCol:'#070', width:80, height:2 }, + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R1", fillx:1, height:EL7_height}, + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R2", fillx:1, height:EL7_height}, + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R3", fillx:1, height:EL7_height}, + ]}, + {type:"",width:5}, + ]}, + {lazy:true}); +layout.update(); + +//support functions + +function getdatetime(){ + var datetime = []; + var d = new Date(); +// var meridian = require("locale").meridian(d); + datetime.clock = require("locale").time(d, 1); + datetime.month = d.getMonth()+1; + datetime.day = d.getDate(); + return datetime; +} + +function getSteps(){ + steps=Bangle.getHealthStatus("day").steps; + steps = typeof steps !== 'undefined' ? steps:0; + return steps; +} + +function getStepGoal(){ + let stepGoal = (require("Storage").readJSON("health.json",1)||10000).stepGoal; + stepGoal = typeof stepGoal !== 'undefined' ? stepGoal:10000; + return stepGoal; +} + +function isAlarmSet(){ + let alarmStatus = (require('Storage').readJSON('sched.json',1)||[]).some(alarm=>alarm.on); + return alarmStatus; +} + +function isMessagesNotify(){ + if (require("Storage").read("messages.json")!==undefined) { + return true; + } else { + return false; + } +} + +function getTemperature(){ + var temperature = E.getTemperature(); + temperature = typeof temperature !== 'undefined' ? temperature:99999; + return Math.round(temperature); +} + +function getHRM(){ + hrm=Bangle.getHealthStatus('10min').bpm; + hrm = typeof hrm !== 'undefined' ? hrm:0; + return hrm; +} + +function getGPS(){ + GPS=Bangle.getPressure(); + GPS = typeof GPS !== 'undefined' ? GPS:{temperature:0,pressure:0,altitude:0}; + return GPS; +} + +function isBTConnected(){ + return NRF.getSecurityStatus().connected; +} + +function getBattery(){ + battlevel = E.getBattery(); + if (Bangle.isCharging()) { + battlevel = -1; + } else if (battlevel >= 100) { + battlevel = 99; + } + battlevel=String(battlevel).padStart(2,'0'); + return battlevel; +} + +function isActive(){ + if (Bangle.isCompassOn() || Bangle.isGPSOn() || Bangle.isHRMOn() | Bangle.isBarometerOn() ) { + return true; + } else { + return false; + } +} + +function setLight(id,label,check,onColour,offColour){ + onColour = typeof onColour !== 'undefined' ? onColour:Light_on; + offColour = typeof offColour !== 'undefined' ? offColour:Light_off; + if (label !== '') { + layout[id].label=label; + } + if (check) { + layout[id].bgCol=onColour; + } else { + layout[id].bgCol=offColour; + } +} + +function draw_bg(){ + g.setColor('#666'); + g.fillRect(0,0,176,176); + g.setColor('#000'); + g.fillRect(69,2,172,174); + g.fillCircle(59,10,5); + g.fillCircle(59,166,5); +} + +// actual display +function draw(){ + datetime=getdatetime(); + var ds=new Date(); + datestring=String(String(ds.getHours()).padStart(2,'0')+String(ds.getMinutes()).padStart(2,'0')).padStart(5,'0'); + var offsets = require("Storage").readJSON("worldclock.settings.json") || []; + utchour=((ds.getHours()+(Math.round(ds.getTimezoneOffset()/60))) % 24); + utcstring=String(String(utchour).padStart(2,'0')+String(ds.getMinutes()).padStart(2,'0')).padStart(5,'0'); + + layout.R1.label=datestring; + layout.R2.label=utcstring; + layout.R3.label=String(getSteps()).padStart(5,'0'); + + layout.PROG.label=String(getBattery()).padStart(2,'0'); + layout.VERB.label=String(datetime.month).padStart(2,'0'); + layout.NOUN.label=String(datetime.day).padStart(2,'0'); + + setLight('COMPACTY','',isActive(),Light_COMPACTY); + setLight('L1','MSG',isMessagesNotify()); + setLight('L2','LOCK',Bangle.isLocked()); + setLight('L3','BT',!isBTConnected(),Light_warn); + setLight('L4','BATT',(getBattery()<=20),Light_warn); + setLight('L5','ALARM',isAlarmSet(),Light_warn); + setLight('L6','STEP',(getSteps()>=getStepGoal()),'#0a0'); + + layout.render(); + // layout.debug(); +} + +var drawTimeout; +// schedule a draw for the next minute +function queueDraw() { + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = setTimeout(function() { + drawTimeout = undefined; + draw(); + }, 60000 - (Date.now() % 60000)); +} + +//////////// Main + +// Show launcher when middle button pressed +Bangle.setUI({ + mode : "clock", + remove : function() { + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = undefined; + require("widget_utils").show(); // re-show widgets + }}); +Bangle.loadWidgets(); +require("widget_utils").swipeOn(); // hide widgets, make them visible with a swipe + +Bangle.on('lock',on=>{ + draw(); // draw immediately + }); + +Bangle.on('GPS',draw); +Bangle.on('HRM',draw); +Bangle.on("message",draw); +Bangle.on('charging',draw); +NRF.on('connect',draw); +NRF.on('disconnect',draw); + +g.clear(); +draw_bg(); +draw(); +queueDraw(); \ No newline at end of file diff --git a/apps/dsky_clock/dsky_clock.img b/apps/dsky_clock/dsky_clock.img new file mode 100644 index 0000000000000000000000000000000000000000..9e2fb3adb55a41dd88d89048b60c5735e33e2afc GIT binary patch literal 1156 zcmZ{kJ#vFE5QP^PtCWHpzzIA#gWGgYnHg1bONB3x6K34zE_wSSB;k0OLCnYF>1h$1 z&);v0)$HSOpoL1^?)Q}@7sSf%!cXPF_adj9a{?cw@EDO?l)L|P7JVEB*W(e>D<8+$ z`S424-9L_l>%)tAd;P0C2rkp|F~2U9C}1>y&-27Rk2XMka+ill{q@xLff6T~IN>-g zzfwQaHw8LKpBqlM1dNmEFCVT~EMCeVU&W{A)xXQr`orC;pSMuz@-SA!o84>mffH}M z1q!OaJ}#D%vEYmYuTgwHubvYen+I;j_nZOxjZ^X2Ib)yUl@*_z>#|bGBX8UGPfaiL zHattrT|Yz`bl*z;#H;&92#ia9Nn|;z4*-1Nr1>ik1anbqA1Y^UoZdO)A?bovm($QQ z&!U&G{kpJ`y?Ty3h`I85%!9^ZPr<0s@bVuBwp{lyP7~s3KP^xBZ_LZA I3oobX533WW&Hw-a literal 0 HcmV?d00001 diff --git a/apps/dsky_clock/metadata.json b/apps/dsky_clock/metadata.json new file mode 100644 index 0000000000..176cf48c5b --- /dev/null +++ b/apps/dsky_clock/metadata.json @@ -0,0 +1,17 @@ +{ "id": "dsky_clock", + "name": "DSKY Clock", + "shortName":"dsky_clock", + "icon": "dsky_clock.img", + "screenshots": [{"url":"screenshot1.png"}], + "version": "0.01", + "description": "A clockface inspired by the Apollo DSKY interface.", + "tags": "clock", + "type": "clock", + "supports":["BANGLEJS2"], + "readme": "README.md", + "allow_emulator": true, + "storage": [ + {"name":"dsky_clock.app.js","url":"app.js"}, + {"name":"dsky_clock.img","url":"app-icon.js","evaluate":true} + ] + } diff --git a/apps/dsky_clock/screenshot1.png b/apps/dsky_clock/screenshot1.png new file mode 100644 index 0000000000000000000000000000000000000000..949199a69b8e097468a24df9bee5622bb9b8e1c8 GIT binary patch literal 3169 zcmV-n44(6eP)Px>8%ab#RCr$Po$Z#ZAPhzA`#-d^>}abL%m+yfdgjl)Z2>VkY+?j`P17{b^E|y? zujN1Z7j_s+2a9@NuSLbvgnwa&(RA>-Gl8e|4>OBkW}OyE`2Nk4pg+`%csBx1rw*8z zGmXC!eI?S-`rJ{MTUB7*fB3X###<7&Wk-s{T>C$&+$QK!bbF!if0KSMFlN<%JOXFE zz$-^4J+xaR`kdSXE8n4LDZ=IR8+E&r+dgx@-`j1lW<_OzBzzPCqCGXZRD*~&LaCgIC1BuUL;OqqcC9y6G(P>ekKGGML2zWV}po_S#c)v66EeTwb7}*EG zkV%$CtM&ZW1lHY20)an5NiN_=#K07B%ijfjLeT^k0D*t*?0~=tbjj+1h`_8C6BLpX z7X(h=w2m%-z=j0w9X#6l9sVD>DhOOz-88gEAJ};i7z7?x_8>3_oI|{=Rc?&lfxsXz zLnh8elmZ5UL11TPGMiTl*ljJu*6r49-12wn?cVdN_1?W~`aCdozAd{*zrS7TPbpv! z7zAb_(z%#Y!0rTYopy^L+C1p7UOoc%lDRcwQA%^Fcz`Fj+cfP2-FRhqNz=(kn14||BQ$AY^97Ue`aqcWMd#O2pp+5mt%pzh6Hx;5E^Y-00ahshaVmwuqA=1^|BUnxnR-wyW0uR4Ft9( za6%_rjG3$g##)H#JE1!f$9XN)Mzq!o1Gz5}G*c(Dq1w4ERa3Fl2W4*xLkCzKi~44IApHTSU6pzB(RRWtv7Z`i7dpx z-r!FW@D|GS3V7d+B0K_tJqTPnrR5mP`Q^aa6HZ7ev*MDAIO)ZmLcr;>5IPb|i7S7{ za#IjUqxFpy;p7Jbdl9(Ljpwz6PB!aG(!rTB29{+V$|u=eNMJLypdpS0KwxVEbF7Xs zrWOE!E!RSrx(1C=765@kU`iwDe+Pjx5tzDAy5a&ZW1rSx1p;Rya7M9Y?9*;u0D-R{ zu<|(wpEbExkhm30TzD=Z@Kpr9(COwu?ZxK;0)xPPn!ZrLATS8rC*JpBgtZB2Sfj01 z^q5KD*Y7gH*1FD%zkj{vX|C?H;NGE=dP1QAt@E_?6kTLj(e_DO@8<&U>(}O6il)~x z&sNsDUM$w1wYUFgFuf{d<=&oVJFcgo)_K}`J$YWt+E2Le+h27xKf9)8yfQCklL zJ}0!udD_BS=V|L{`^l-N?US}12%LbxR8F<^d%)!IbLhl3GT2!N#K0UB8I;K=mW+Lp z--$yO!a$ziCd%p4XgYQ6qiN$E={Ll{31eUgSUo)4^T106ZvXf8)taX*d%fgu>!~sR z_e17^Az+n&Lt^01;{jH2QlI(9vAz+n&-z?nc{pWd}-}fwj?qum>;H|xltkh=^ zSnW&Oir$0Dp#3lcA3}&COel#A0^90P-I{^GPLFNWJ_wv)HJXt#)nctx^zM^E`(Xs$ zF5H&z05NbSg=FANQ}M1B+V3{KZk`yOa|nTJS%_9l{D>I1rM8SW4Kns=wOd~3j_=Td%Uf_bR>7# zAh#UVKDQn1&S-A?R6h*_4+2LJnCozEIZ7DZc5WbG5EumhE?CzJpG#71``q?E7jSqw z<>6_T0{iibavjGl2Lc}~fGmV}7J@5GZaE0}V*%3`xZFBbKBT0!7p~@u+7_(+o;rGm zN3tCmTw!v{LBKu)K6~Cn`5f%M2+MlCd*#xth2RR4TMh#DBXDi^F|`Z1^;`)3^CCdt zw}+|S#K=Od+rw9-ojn6>A5L(e%+n$>wYn`Gfq9pD_NBBpGPL#V&wy;vJO*wNxH{{t z>t=6HVA2gv1++rc)^j=ys#&uvM2oBxaS;QrF1k7frj)Y%Zq-lj@lMK_6L^2DEo?vx zyjn#XlX4wAN-V1tK4Awl0#mVR)bHtHV6Nl1<-D>G+5zKTFN(l)epdQ~9c_7JAyioi zZy{<2Cw)Pzb`hZXN9xx;%`GGgH2J$=Iy0D(c^;bn~&I4TC#-WiLoH;|-3 z;79^T3sHN#fdssC)r7!hKwS;6cVcOkr`n;~El1?Ct!dkH$N$%OkpOoQ3%6V;Fspjp zcDUuN`gt;-K;Q@ha~;ktXC;hL7Qz!VLKlI#B;5|eEl&bY0X=!93BC-$=u&c-s1AE87uI_tw;~;P(fuF54x3dR|rFbEtbHtPd{z#y=-ro!7ZCGgJzr2WH(8DgP!EAw`MNbkG_ zy(1&~j@l^4>ySJM%otQ1_B~b|MNrZG>@=_`fq8`V+6%X}n~cER#V^_g?W5M~6z)pB|zXe+^A6g>g)vwT(>~)pfRv(J^!0sP|+cak)e?X z###s?DaAK~7&syZj`!=MjtByK6F7Qm9_4rj!wdwDAn+)HiteX@fRP8TzR8oi+7enm zS{S1oPiV$kaS?%gukJ^wZ(vtsA*yOyzqIDVe#!1V@5KFDtQ@(=cPd+3nCZBy^Rm(8 zHXy|#2;8z$Yeq1zD+mk%%O1#g6ytU$jwWfH#B@E8$fLGsF z5|_jVb_Ib!;2RNmb7u5bol%b0L5y3+z+Ah8$HJ|SWqDy?wD7r(D#}&;Hg*<5zOJ{G zji8ruDXorbh8CEoWA^CZYm0`bd`l$ti`}`gZ+YH^mPS(!7EloQmvA}6PObly=7HrT zckmCIBrWg|0{0Fw(vB!_i3JP@Opy=2moXYXPltCKTifFg#ngnYuL-e^00000NkvXX Hu0mjf27}no literal 0 HcmV?d00001 From 0b4fe5f88982f94a2cd85119934e2f7d4fc9cb72 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Mon, 23 Dec 2024 08:43:03 -0500 Subject: [PATCH 02/25] renamed to app.js per @thyttan suggestion --- apps/dsky_clock/dsky_clock.app.js | 226 ------------------------------ apps/dsky_clock/metadata.json | 34 ++--- 2 files changed, 17 insertions(+), 243 deletions(-) delete mode 100644 apps/dsky_clock/dsky_clock.app.js diff --git a/apps/dsky_clock/dsky_clock.app.js b/apps/dsky_clock/dsky_clock.app.js deleted file mode 100644 index 62003f9fa9..0000000000 --- a/apps/dsky_clock/dsky_clock.app.js +++ /dev/null @@ -1,226 +0,0 @@ -//Init -var Layout = require("Layout"); -require("Font7x11Numeric7Seg").add(Graphics); -require("FontTeletext5x9Ascii").add(Graphics); - -borders = 1; -Light_on='#fff'; -Light_off='#554'; -Light_warn='#f90'; -Light_COMPACTY='#0F0'; -Light_width=43; -Light_height=25; -EL7_height=30; -LightFont='Teletext5x9Ascii'; -DataFont='7x11Numeric7Seg:2'; - -var layout = new Layout( - {type:"h", c:[ - {type:"",width:6}, - { type:"v", c: [ - {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L1', label:"UPLINK\nACTY", width:Light_width, height:Light_height}, - {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L2', label:"TEMP", width:Light_width, height:Light_height }, - {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L3', label:"GIMBAL\nLOCK", width:Light_width, height:Light_height }, - {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L4', label:"STBY", width:Light_width, height:Light_height }, - {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L5', label:"PROG", width:Light_width, height:Light_height }, - {type:"txt", font:LightFont, col:"#000", bgCol:"#eee", id:'L6', label:"OPR ERR", width:Light_width, height:Light_height }, - ]}, - { type:"", width:20}, - { type:"v", c: [ - {type:"",height:2}, - {type:"h", c: [ - {type:"", width:50},{type:"txt", font:"6x8", col:"#000",bgCol:"#0F0", label:"PROG", width:25, height:10}, - ]}, - {type:"h", c: [ - {type:"",width:10}, - {type:"txt", font:"6x8", col:"#000", bgCol:"#000", id:"COMPACTY", label:"COMP\nACTY", width:26, height:26 }, - {type:"",width:17}, - {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000",label:"00", id:"PROG", fillx:1, height:EL7_height }, - ]}, - {type:"",height:1}, - {type:"h", c: [ - {type:"txt", font:"6x8", col:"#000", bgCol:"#0F0",label:"VERB", width:25, height:10}, - {type:"",width:30}, - {type:"txt", font:"6x8", col:"#000",bgCol:"#0F0",label:"NOUN", width:25, height:10}, - ]}, - {type:"h", c: [ - {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00", id:"VERB", fillx:1, height:EL7_height}, - {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00", id:"NOUN", fillx:1, height:EL7_height}, - ]}, - { type:"",bgCol:'#070', width:80, height:2 }, - {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R1", fillx:1, height:EL7_height}, - {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R2", fillx:1, height:EL7_height}, - {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R3", fillx:1, height:EL7_height}, - ]}, - {type:"",width:5}, - ]}, - {lazy:true}); -layout.update(); - -//support functions - -function getdatetime(){ - var datetime = []; - var d = new Date(); -// var meridian = require("locale").meridian(d); - datetime.clock = require("locale").time(d, 1); - datetime.month = d.getMonth()+1; - datetime.day = d.getDate(); - return datetime; -} - -function getSteps(){ - steps=Bangle.getHealthStatus("day").steps; - steps = typeof steps !== 'undefined' ? steps:0; - return steps; -} - -function getStepGoal(){ - let stepGoal = (require("Storage").readJSON("health.json",1)||10000).stepGoal; - stepGoal = typeof stepGoal !== 'undefined' ? stepGoal:10000; - return stepGoal; -} - -function isAlarmSet(){ - let alarmStatus = (require('Storage').readJSON('sched.json',1)||[]).some(alarm=>alarm.on); - return alarmStatus; -} - -function isMessagesNotify(){ - if (require("Storage").read("messages.json")!==undefined) { - return true; - } else { - return false; - } -} - -function getTemperature(){ - var temperature = E.getTemperature(); - temperature = typeof temperature !== 'undefined' ? temperature:99999; - return Math.round(temperature); -} - -function getHRM(){ - hrm=Bangle.getHealthStatus('10min').bpm; - hrm = typeof hrm !== 'undefined' ? hrm:0; - return hrm; -} - -function getGPS(){ - GPS=Bangle.getPressure(); - GPS = typeof GPS !== 'undefined' ? GPS:{temperature:0,pressure:0,altitude:0}; - return GPS; -} - -function isBTConnected(){ - return NRF.getSecurityStatus().connected; -} - -function getBattery(){ - battlevel = E.getBattery(); - if (Bangle.isCharging()) { - battlevel = -1; - } else if (battlevel >= 100) { - battlevel = 99; - } - battlevel=String(battlevel).padStart(2,'0'); - return battlevel; -} - -function isActive(){ - if (Bangle.isCompassOn() || Bangle.isGPSOn() || Bangle.isHRMOn() | Bangle.isBarometerOn() ) { - return true; - } else { - return false; - } -} - -function setLight(id,label,check,onColour,offColour){ - onColour = typeof onColour !== 'undefined' ? onColour:Light_on; - offColour = typeof offColour !== 'undefined' ? offColour:Light_off; - if (label !== '') { - layout[id].label=label; - } - if (check) { - layout[id].bgCol=onColour; - } else { - layout[id].bgCol=offColour; - } -} - -function draw_bg(){ - g.setColor('#666'); - g.fillRect(0,0,176,176); - g.setColor('#000'); - g.fillRect(69,2,172,174); - g.fillCircle(59,10,5); - g.fillCircle(59,166,5); -} - -// actual display -function draw(){ - datetime=getdatetime(); - var ds=new Date(); - datestring=String(String(ds.getHours()).padStart(2,'0')+String(ds.getMinutes()).padStart(2,'0')).padStart(5,'0'); - var offsets = require("Storage").readJSON("worldclock.settings.json") || []; - utchour=((ds.getHours()+(Math.round(ds.getTimezoneOffset()/60))) % 24); - utcstring=String(String(utchour).padStart(2,'0')+String(ds.getMinutes()).padStart(2,'0')).padStart(5,'0'); - - layout.R1.label=datestring; - layout.R2.label=utcstring; - layout.R3.label=String(getSteps()).padStart(5,'0'); - - layout.PROG.label=String(getBattery()).padStart(2,'0'); - layout.VERB.label=String(datetime.month).padStart(2,'0'); - layout.NOUN.label=String(datetime.day).padStart(2,'0'); - - setLight('COMPACTY','',isActive(),Light_COMPACTY); - setLight('L1','MSG',isMessagesNotify()); - setLight('L2','LOCK',Bangle.isLocked()); - setLight('L3','BT',!isBTConnected(),Light_warn); - setLight('L4','BATT',(getBattery()<=20),Light_warn); - setLight('L5','ALARM',isAlarmSet(),Light_warn); - setLight('L6','STEP',(getSteps()>=getStepGoal()),'#0a0'); - - layout.render(); - // layout.debug(); -} - -var drawTimeout; -// schedule a draw for the next minute -function queueDraw() { - if (drawTimeout) clearTimeout(drawTimeout); - drawTimeout = setTimeout(function() { - drawTimeout = undefined; - draw(); - }, 60000 - (Date.now() % 60000)); -} - -//////////// Main - -// Show launcher when middle button pressed -Bangle.setUI({ - mode : "clock", - remove : function() { - if (drawTimeout) clearTimeout(drawTimeout); - drawTimeout = undefined; - require("widget_utils").show(); // re-show widgets - }}); -Bangle.loadWidgets(); -require("widget_utils").swipeOn(); // hide widgets, make them visible with a swipe - -Bangle.on('lock',on=>{ - draw(); // draw immediately - }); - -Bangle.on('GPS',draw); -Bangle.on('HRM',draw); -Bangle.on("message",draw); -Bangle.on('charging',draw); -NRF.on('connect',draw); -NRF.on('disconnect',draw); - -g.clear(); -draw_bg(); -draw(); -queueDraw(); \ No newline at end of file diff --git a/apps/dsky_clock/metadata.json b/apps/dsky_clock/metadata.json index 176cf48c5b..c4fc450943 100644 --- a/apps/dsky_clock/metadata.json +++ b/apps/dsky_clock/metadata.json @@ -1,17 +1,17 @@ -{ "id": "dsky_clock", - "name": "DSKY Clock", - "shortName":"dsky_clock", - "icon": "dsky_clock.img", - "screenshots": [{"url":"screenshot1.png"}], - "version": "0.01", - "description": "A clockface inspired by the Apollo DSKY interface.", - "tags": "clock", - "type": "clock", - "supports":["BANGLEJS2"], - "readme": "README.md", - "allow_emulator": true, - "storage": [ - {"name":"dsky_clock.app.js","url":"app.js"}, - {"name":"dsky_clock.img","url":"app-icon.js","evaluate":true} - ] - } +{ "id": "dsky_clock", + "name": "DSKY Clock", + "shortName":"dsky_clock", + "icon": "dsky_clock.img", + "screenshots": [{"url":"screenshot1.png"}], + "version": "0.01", + "description": "A clockface inspired by the Apollo DSKY interface.", + "tags": "clock", + "type": "clock", + "supports":["BANGLEJS2"], + "readme": "README.md", + "allow_emulator": true, + "storage": [ + {"name":"app.js","url":"app.js"}, + {"name":"dsky_clock.img","url":"app-icon.js","evaluate":true} + ] + } From 663eaa06ba77c7f709ec9e8bf64e22c8e33969e3 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Mon, 23 Dec 2024 08:44:58 -0500 Subject: [PATCH 03/25] renamed to app.js per @thyttan suggestion - forgot to add renamed file --- apps/dsky_clock/app.js | 226 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 apps/dsky_clock/app.js diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js new file mode 100644 index 0000000000..62003f9fa9 --- /dev/null +++ b/apps/dsky_clock/app.js @@ -0,0 +1,226 @@ +//Init +var Layout = require("Layout"); +require("Font7x11Numeric7Seg").add(Graphics); +require("FontTeletext5x9Ascii").add(Graphics); + +borders = 1; +Light_on='#fff'; +Light_off='#554'; +Light_warn='#f90'; +Light_COMPACTY='#0F0'; +Light_width=43; +Light_height=25; +EL7_height=30; +LightFont='Teletext5x9Ascii'; +DataFont='7x11Numeric7Seg:2'; + +var layout = new Layout( + {type:"h", c:[ + {type:"",width:6}, + { type:"v", c: [ + {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L1', label:"UPLINK\nACTY", width:Light_width, height:Light_height}, + {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L2', label:"TEMP", width:Light_width, height:Light_height }, + {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L3', label:"GIMBAL\nLOCK", width:Light_width, height:Light_height }, + {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L4', label:"STBY", width:Light_width, height:Light_height }, + {type:"txt", font:LightFont, col:"#000", bgCol:"#555", id:'L5', label:"PROG", width:Light_width, height:Light_height }, + {type:"txt", font:LightFont, col:"#000", bgCol:"#eee", id:'L6', label:"OPR ERR", width:Light_width, height:Light_height }, + ]}, + { type:"", width:20}, + { type:"v", c: [ + {type:"",height:2}, + {type:"h", c: [ + {type:"", width:50},{type:"txt", font:"6x8", col:"#000",bgCol:"#0F0", label:"PROG", width:25, height:10}, + ]}, + {type:"h", c: [ + {type:"",width:10}, + {type:"txt", font:"6x8", col:"#000", bgCol:"#000", id:"COMPACTY", label:"COMP\nACTY", width:26, height:26 }, + {type:"",width:17}, + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000",label:"00", id:"PROG", fillx:1, height:EL7_height }, + ]}, + {type:"",height:1}, + {type:"h", c: [ + {type:"txt", font:"6x8", col:"#000", bgCol:"#0F0",label:"VERB", width:25, height:10}, + {type:"",width:30}, + {type:"txt", font:"6x8", col:"#000",bgCol:"#0F0",label:"NOUN", width:25, height:10}, + ]}, + {type:"h", c: [ + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00", id:"VERB", fillx:1, height:EL7_height}, + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00", id:"NOUN", fillx:1, height:EL7_height}, + ]}, + { type:"",bgCol:'#070', width:80, height:2 }, + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R1", fillx:1, height:EL7_height}, + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R2", fillx:1, height:EL7_height}, + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R3", fillx:1, height:EL7_height}, + ]}, + {type:"",width:5}, + ]}, + {lazy:true}); +layout.update(); + +//support functions + +function getdatetime(){ + var datetime = []; + var d = new Date(); +// var meridian = require("locale").meridian(d); + datetime.clock = require("locale").time(d, 1); + datetime.month = d.getMonth()+1; + datetime.day = d.getDate(); + return datetime; +} + +function getSteps(){ + steps=Bangle.getHealthStatus("day").steps; + steps = typeof steps !== 'undefined' ? steps:0; + return steps; +} + +function getStepGoal(){ + let stepGoal = (require("Storage").readJSON("health.json",1)||10000).stepGoal; + stepGoal = typeof stepGoal !== 'undefined' ? stepGoal:10000; + return stepGoal; +} + +function isAlarmSet(){ + let alarmStatus = (require('Storage').readJSON('sched.json',1)||[]).some(alarm=>alarm.on); + return alarmStatus; +} + +function isMessagesNotify(){ + if (require("Storage").read("messages.json")!==undefined) { + return true; + } else { + return false; + } +} + +function getTemperature(){ + var temperature = E.getTemperature(); + temperature = typeof temperature !== 'undefined' ? temperature:99999; + return Math.round(temperature); +} + +function getHRM(){ + hrm=Bangle.getHealthStatus('10min').bpm; + hrm = typeof hrm !== 'undefined' ? hrm:0; + return hrm; +} + +function getGPS(){ + GPS=Bangle.getPressure(); + GPS = typeof GPS !== 'undefined' ? GPS:{temperature:0,pressure:0,altitude:0}; + return GPS; +} + +function isBTConnected(){ + return NRF.getSecurityStatus().connected; +} + +function getBattery(){ + battlevel = E.getBattery(); + if (Bangle.isCharging()) { + battlevel = -1; + } else if (battlevel >= 100) { + battlevel = 99; + } + battlevel=String(battlevel).padStart(2,'0'); + return battlevel; +} + +function isActive(){ + if (Bangle.isCompassOn() || Bangle.isGPSOn() || Bangle.isHRMOn() | Bangle.isBarometerOn() ) { + return true; + } else { + return false; + } +} + +function setLight(id,label,check,onColour,offColour){ + onColour = typeof onColour !== 'undefined' ? onColour:Light_on; + offColour = typeof offColour !== 'undefined' ? offColour:Light_off; + if (label !== '') { + layout[id].label=label; + } + if (check) { + layout[id].bgCol=onColour; + } else { + layout[id].bgCol=offColour; + } +} + +function draw_bg(){ + g.setColor('#666'); + g.fillRect(0,0,176,176); + g.setColor('#000'); + g.fillRect(69,2,172,174); + g.fillCircle(59,10,5); + g.fillCircle(59,166,5); +} + +// actual display +function draw(){ + datetime=getdatetime(); + var ds=new Date(); + datestring=String(String(ds.getHours()).padStart(2,'0')+String(ds.getMinutes()).padStart(2,'0')).padStart(5,'0'); + var offsets = require("Storage").readJSON("worldclock.settings.json") || []; + utchour=((ds.getHours()+(Math.round(ds.getTimezoneOffset()/60))) % 24); + utcstring=String(String(utchour).padStart(2,'0')+String(ds.getMinutes()).padStart(2,'0')).padStart(5,'0'); + + layout.R1.label=datestring; + layout.R2.label=utcstring; + layout.R3.label=String(getSteps()).padStart(5,'0'); + + layout.PROG.label=String(getBattery()).padStart(2,'0'); + layout.VERB.label=String(datetime.month).padStart(2,'0'); + layout.NOUN.label=String(datetime.day).padStart(2,'0'); + + setLight('COMPACTY','',isActive(),Light_COMPACTY); + setLight('L1','MSG',isMessagesNotify()); + setLight('L2','LOCK',Bangle.isLocked()); + setLight('L3','BT',!isBTConnected(),Light_warn); + setLight('L4','BATT',(getBattery()<=20),Light_warn); + setLight('L5','ALARM',isAlarmSet(),Light_warn); + setLight('L6','STEP',(getSteps()>=getStepGoal()),'#0a0'); + + layout.render(); + // layout.debug(); +} + +var drawTimeout; +// schedule a draw for the next minute +function queueDraw() { + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = setTimeout(function() { + drawTimeout = undefined; + draw(); + }, 60000 - (Date.now() % 60000)); +} + +//////////// Main + +// Show launcher when middle button pressed +Bangle.setUI({ + mode : "clock", + remove : function() { + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = undefined; + require("widget_utils").show(); // re-show widgets + }}); +Bangle.loadWidgets(); +require("widget_utils").swipeOn(); // hide widgets, make them visible with a swipe + +Bangle.on('lock',on=>{ + draw(); // draw immediately + }); + +Bangle.on('GPS',draw); +Bangle.on('HRM',draw); +Bangle.on("message",draw); +Bangle.on('charging',draw); +NRF.on('connect',draw); +NRF.on('disconnect',draw); + +g.clear(); +draw_bg(); +draw(); +queueDraw(); \ No newline at end of file From 19d37fec7adcc0163a509d6e5862bbfd0a573e63 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Mon, 23 Dec 2024 08:56:04 -0500 Subject: [PATCH 04/25] cleaned up draw and datetime functions and commented out unused functions --- apps/dsky_clock/app.js | 45 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index 62003f9fa9..8d33d1b2be 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -62,10 +62,14 @@ layout.update(); function getdatetime(){ var datetime = []; var d = new Date(); + var offsets = require("Storage").readJSON("worldclock.settings.json") || []; // var meridian = require("locale").meridian(d); datetime.clock = require("locale").time(d, 1); datetime.month = d.getMonth()+1; datetime.day = d.getDate(); + datetime.localtime=String(String(d.getHours()).padStart(2,'0')+String(d.getMinutes()).padStart(2,'0')).padStart(5,'0'); + utchour=((d.getHours()+(Math.round(d.getTimezoneOffset()/60))) % 24); + datetime.utctime=String(String(utchour).padStart(2,'0')+String(d.getMinutes()).padStart(2,'0')).padStart(5,'0'); return datetime; } @@ -93,24 +97,24 @@ function isMessagesNotify(){ return false; } } - -function getTemperature(){ - var temperature = E.getTemperature(); - temperature = typeof temperature !== 'undefined' ? temperature:99999; - return Math.round(temperature); -} -function getHRM(){ - hrm=Bangle.getHealthStatus('10min').bpm; - hrm = typeof hrm !== 'undefined' ? hrm:0; - return hrm; -} +//function getTemperature(){ +// var temperature = E.getTemperature(); +// temperature = typeof temperature !== 'undefined' ? temperature:99999; +// return Math.round(temperature); +//} -function getGPS(){ - GPS=Bangle.getPressure(); - GPS = typeof GPS !== 'undefined' ? GPS:{temperature:0,pressure:0,altitude:0}; - return GPS; -} +//function getHRM(){ +// hrm=Bangle.getHealthStatus('10min').bpm; +// hrm = typeof hrm !== 'undefined' ? hrm:0; +// return hrm; +//} + +//function getGPS(){ +// GPS=Bangle.getPressure(); +// GPS = typeof GPS !== 'undefined' ? GPS:{temperature:0,pressure:0,altitude:0}; +// return GPS; +//} function isBTConnected(){ return NRF.getSecurityStatus().connected; @@ -160,14 +164,9 @@ function draw_bg(){ // actual display function draw(){ datetime=getdatetime(); - var ds=new Date(); - datestring=String(String(ds.getHours()).padStart(2,'0')+String(ds.getMinutes()).padStart(2,'0')).padStart(5,'0'); - var offsets = require("Storage").readJSON("worldclock.settings.json") || []; - utchour=((ds.getHours()+(Math.round(ds.getTimezoneOffset()/60))) % 24); - utcstring=String(String(utchour).padStart(2,'0')+String(ds.getMinutes()).padStart(2,'0')).padStart(5,'0'); - layout.R1.label=datestring; - layout.R2.label=utcstring; + layout.R1.label=datetime.localtime; + layout.R2.label=datetime.utctime; layout.R3.label=String(getSteps()).padStart(5,'0'); layout.PROG.label=String(getBattery()).padStart(2,'0'); From b330596991538479b84747e91ea3f7ec9ddb4a03 Mon Sep 17 00:00:00 2001 From: Carl Chan <2922311+carlchan@users.noreply.github.com> Date: Mon, 23 Dec 2024 13:40:51 -0500 Subject: [PATCH 05/25] Update apps/dsky_clock/metadata.json Co-authored-by: thyttan <97237430+thyttan@users.noreply.github.com> --- apps/dsky_clock/metadata.json | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/dsky_clock/metadata.json b/apps/dsky_clock/metadata.json index c4fc450943..9c38bec135 100644 --- a/apps/dsky_clock/metadata.json +++ b/apps/dsky_clock/metadata.json @@ -1,6 +1,5 @@ { "id": "dsky_clock", "name": "DSKY Clock", - "shortName":"dsky_clock", "icon": "dsky_clock.img", "screenshots": [{"url":"screenshot1.png"}], "version": "0.01", From 8fde4d05d51322a1c2fefd70b19f749c2fafdcfb Mon Sep 17 00:00:00 2001 From: Carl Chan <2922311+carlchan@users.noreply.github.com> Date: Mon, 23 Dec 2024 13:40:58 -0500 Subject: [PATCH 06/25] Update apps/dsky_clock/metadata.json Co-authored-by: thyttan <97237430+thyttan@users.noreply.github.com> --- apps/dsky_clock/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dsky_clock/metadata.json b/apps/dsky_clock/metadata.json index 9c38bec135..d66a99a736 100644 --- a/apps/dsky_clock/metadata.json +++ b/apps/dsky_clock/metadata.json @@ -10,7 +10,7 @@ "readme": "README.md", "allow_emulator": true, "storage": [ - {"name":"app.js","url":"app.js"}, + {"name":"dsky_clock.app.js","url":"app.js"}, {"name":"dsky_clock.img","url":"app-icon.js","evaluate":true} ] } From 7c06bf454f6dc8124a1eb56129db0277e70cbd94 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Mon, 23 Dec 2024 23:49:11 -0500 Subject: [PATCH 07/25] added app-icon.js --- apps/dsky_clock/app-icon.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 apps/dsky_clock/app-icon.js diff --git a/apps/dsky_clock/app-icon.js b/apps/dsky_clock/app-icon.js new file mode 100644 index 0000000000..12249608fb --- /dev/null +++ b/apps/dsky_clock/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwwkIkQAFkIEDiQMGABUAiQtIu1nu9wgETC40QDIIAHu4ABC4MCkURiVCAAMimQXJswABAgMDC4IADLIQLBBAYcHF4QXSg4XDiEBgIXCkIXCAQgADgwvFBwIXFF4sGuwXHI4cxCIQ4CF5gXCR4ZfJF5SPXI4S4EFgQGBsAvMdAikCAwJ5BF5YXJu7vMI4RABI4gvCmQXJDIQEIL5YRBgxHDAgR3D7vd6gCB6QXEHwIXDCoQGBC4YACC4sGs5fDAgQvE6lEpvd6YXECwkGAgQvFrovDU4QXJL4pHIRQtnR4oXGkIlCAAK6BDwgvPgwEDSIgXLgynBAYhHMC4UHOQIWBAIMHBAIXCmXdqioBC4UyIoYXBeQNmCoJOCF4VVCwJHGH4UHGAQXEF4JHFF4ZHEAYJHEU5RCBI4SoBC4JHFpoBCC4jWDdoaPFiIADiS/FABIXIL4QvCRwK/IisAiEAgIXBL4ZzCPIZfDCAIVBAAIXCU4gXEX4xfJBwNmXoS/GC40yd4hcCIoa/EF40xdYS9BMQNnC5ovER4JFDU6K/NgJHHXoQBBSQbzCI5C/Cg9mAAQaBAYSnNNwJcBMANwAIQXKlS/EbIIBDC4UDa5gvBMAYvFAAsQI4bsCPQYFBC5MAC4RcCCgZiCBQNTXAIXEiMikJOCiBUEBAcTA=")) \ No newline at end of file From a1bcd0dbad2e89d3ca2cf11ef6b23b94c6c055df Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Mon, 23 Dec 2024 23:53:28 -0500 Subject: [PATCH 08/25] replaced app-icon.js --- apps/dsky_clock/app.js | 259 ++++++++++++++++++++++++++++++++++------- 1 file changed, 216 insertions(+), 43 deletions(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index 8d33d1b2be..fd3143f897 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -13,6 +13,7 @@ Light_height=25; EL7_height=30; LightFont='Teletext5x9Ascii'; DataFont='7x11Numeric7Seg:2'; +mode = 0; var layout = new Layout( {type:"h", c:[ @@ -53,12 +54,35 @@ var layout = new Layout( {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R3", fillx:1, height:EL7_height}, ]}, {type:"",width:5}, - ]}, - {lazy:true}); + ], + lazy:true}); layout.update(); //support functions +function getWeather() { + try { + var weatherLib = require("weather"); + weather = weatherLib.get(); + } catch(e) { + console.log("Weather lib not found." ); + } + if (weather) { + weather.temp = Math.round(require("locale").temp(weather.temp-273.15)); + weather.hum = weather.hum; + weather.wind = Math.round(require("locale").speed(weather.wind).match(/^(\D*\d*)(.*)$/)); + weather.wind = Math.round(weather.wind[1]); + } else { + weather = { + temp: "-----", + hum: "-----", + wind: "-----", + txt: "-----", + }; + } + return weather; +} + function getdatetime(){ var datetime = []; var d = new Date(); @@ -67,9 +91,9 @@ function getdatetime(){ datetime.clock = require("locale").time(d, 1); datetime.month = d.getMonth()+1; datetime.day = d.getDate(); - datetime.localtime=String(String(d.getHours()).padStart(2,'0')+String(d.getMinutes()).padStart(2,'0')).padStart(5,'0'); + datetime.localtime=String(d.getHours()).padStart(2,'0')+String(d.getMinutes()).padStart(2,'0'); utchour=((d.getHours()+(Math.round(d.getTimezoneOffset()/60))) % 24); - datetime.utctime=String(String(utchour).padStart(2,'0')+String(d.getMinutes()).padStart(2,'0')).padStart(5,'0'); + datetime.utctime=String(utchour).padStart(2,'0')+String(d.getMinutes()).padStart(2,'0'); return datetime; } @@ -98,23 +122,17 @@ function isMessagesNotify(){ } } -//function getTemperature(){ -// var temperature = E.getTemperature(); -// temperature = typeof temperature !== 'undefined' ? temperature:99999; -// return Math.round(temperature); -//} - -//function getHRM(){ -// hrm=Bangle.getHealthStatus('10min').bpm; -// hrm = typeof hrm !== 'undefined' ? hrm:0; -// return hrm; -//} +function getTemperature(){ + var temperature = E.getTemperature(); + temperature = typeof temperature !== 'undefined' ? temperature:99999; + return Math.round(temperature); +} -//function getGPS(){ -// GPS=Bangle.getPressure(); -// GPS = typeof GPS !== 'undefined' ? GPS:{temperature:0,pressure:0,altitude:0}; -// return GPS; -//} +function getHRM(){ + hrm=Bangle.getHealthStatus('last'); + hrm = typeof hrm !== 'undefined' ? hrm:0; + return hrm; +} function isBTConnected(){ return NRF.getSecurityStatus().connected; @@ -127,7 +145,7 @@ function getBattery(){ } else if (battlevel >= 100) { battlevel = 99; } - battlevel=String(battlevel).padStart(2,'0'); + battlevel=String(battlevel); return battlevel; } @@ -140,6 +158,8 @@ function isActive(){ } function setLight(id,label,check,onColour,offColour){ + // print('setlight:',id); //debug + layout.clear(layout[id]); onColour = typeof onColour !== 'undefined' ? onColour:Light_on; offColour = typeof offColour !== 'undefined' ? offColour:Light_off; if (label !== '') { @@ -150,6 +170,38 @@ function setLight(id,label,check,onColour,offColour){ } else { layout[id].bgCol=offColour; } + layout.render(layout[id]); +} + +function setDATA(id,label){ + layout.clear(layout[id]); + try { + if (isNaN(label)) { + data='-----'; + } else { + data=String(String(label).toString(16)).toUpperCase().padStart(5,'0').substring(0,5); + } + } catch(e) { + data='-----'; + } + layout[id].label=data; + layout.render(layout[id]); +} + +function setWORD(id,label){ + layout.clear(layout[id]); + try { + if (isNaN(label)) { + data='--'; + } else { + data=String(String(label).toString(16)).toUpperCase().padStart(2,'0').substring(0,2); + } + } catch(e) { + data='--'; + } +// print(id, data); //debug + layout[id].label=data; + layout.render(layout[id]); } function draw_bg(){ @@ -162,16 +214,17 @@ function draw_bg(){ } // actual display -function draw(){ +function drawMain(){ + remove_alt_events(); datetime=getdatetime(); - - layout.R1.label=datetime.localtime; - layout.R2.label=datetime.utctime; - layout.R3.label=String(getSteps()).padStart(5,'0'); - - layout.PROG.label=String(getBattery()).padStart(2,'0'); - layout.VERB.label=String(datetime.month).padStart(2,'0'); - layout.NOUN.label=String(datetime.day).padStart(2,'0'); + + setDATA('R1',datetime.localtime); + setDATA('R2',datetime.utctime); + setDATA('R3',getSteps()); + + setWORD('PROG',getBattery()); + setWORD('VERB',datetime.month); + setWORD('NOUN',datetime.day); setLight('COMPACTY','',isActive(),Light_COMPACTY); setLight('L1','MSG',isMessagesNotify()); @@ -179,10 +232,10 @@ function draw(){ setLight('L3','BT',!isBTConnected(),Light_warn); setLight('L4','BATT',(getBattery()<=20),Light_warn); setLight('L5','ALARM',isAlarmSet(),Light_warn); - setLight('L6','STEP',(getSteps()>=getStepGoal()),'#0a0'); - + setLight('L6','STEP',(getSteps()>=getStepGoal()),'#0a0'); + + // layout.forgetLazyState(); layout.render(); - // layout.debug(); } var drawTimeout; @@ -191,10 +244,120 @@ function queueDraw() { if (drawTimeout) clearTimeout(drawTimeout); drawTimeout = setTimeout(function() { drawTimeout = undefined; - draw(); + let mode = 0; + remove_alt_events(); + drawMain(); }, 60000 - (Date.now() % 60000)); } +////// ALT modes ///// +function drawAlt(mode) { + remove_alt_events(); + mode = typeof mode !== 'undefined' ? mode:0; + // print('drawAlt: ', mode); // debug + // Show mode in PROG + setWORD('PROG',mode); + setWORD('NOUN',''); + setWORD('VERB',''); + // Disable Battery warning light in to show PROG no longer shows battery level + setLight('L4','BATT',false); + switch (mode) { + case 1: + setLight('L6','HRM',true); + mode_HRM(); + break; + case 2: + setLight('L6','GPS',true); + mode_GPS(); + break; + case 3: + setLight('L6','TEMP',true); + mode_weather(); + break; + case 4: + setLight('L6','ACCEL',true); + mode_accel(); + break; + case 5: + setLight('L6','HDG',true); + mode_compass(); + break; + default: + drawMain(); + } + layout.render(); +} + + +function mode_weather() { + weather=getWeather(); + setDATA('R1',weather.temp); + setDATA('R2',weather.hum); + setDATA('R3',weather.wind); +} + +function mode_compass() { + Bangle.setCompassPower(1); + Bangle.on('mag', show_compass); +} +function mode_accel() { + Bangle.on('accel', show_accel); +} +function mode_GPS() { + Bangle.setGPSPower(1,'dsky_clock'); + Bangle.on('GPS', show_GPS); +} + +function mode_HRM() { + Bangle.setHRMPower(true, 'dsky_clock'); + Bangle.on('HRM', show_HRM); +} +function show_HRM() { + setLight('COMPACTY','',isActive(),Light_COMPACTY); + hrm=getHRM(); + setDATA('R1',hrm.bpm); + setDATA('R2',hrm.bpmConfidence); +// setDATA('R3',hrm.steps); +} + +function show_GPS() { + setLight('COMPACTY','',isActive(),Light_COMPACTY); + gps=Bangle.getGPSFix(); + setWORD('NOUN',gps.fix); + setWORD('VERB',gps.satellites); + setDATA('R1',gps.lat); + setDATA('R2',gps.lon); + setDATA('R3',gps.speed); +} + +function show_compass() { + setLight('COMPACTY','',isActive(),Light_COMPACTY); + compass=Bangle.getCompass(); + setDATA('R1',compass.heading); + setDATA('R2'); + setDATA('R3'); +} + +function show_accel() { + setLight('COMPACTY','',isActive(),Light_COMPACTY); + accel=Bangle.getAccel(); + setDATA('R1',accel.x); + setDATA('R2',accel.y); + setDATA('R3',accel.z); +} + + +function remove_alt_events() { + Bangle.removeListener('accel', show_accel); + Bangle.removeListener('mag', show_compass); + Bangle.setCompassPower(0); + Bangle.removeListener('GPS', show_GPS); + Bangle.setGPSPower(0); + Bangle.removeListener('HRM', show_HRM); + Bangle.setHRMPower(0); + setLight('COMPACTY','',isActive(),Light_COMPACTY); +} + //////////// Main // Show launcher when middle button pressed @@ -209,17 +372,27 @@ Bangle.loadWidgets(); require("widget_utils").swipeOn(); // hide widgets, make them visible with a swipe Bangle.on('lock',on=>{ - draw(); // draw immediately + mode = 0; + remove_alt_events(); + drawMain(); // draw immediately }); - -Bangle.on('GPS',draw); -Bangle.on('HRM',draw); -Bangle.on("message",draw); -Bangle.on('charging',draw); -NRF.on('connect',draw); -NRF.on('disconnect',draw); +Bangle.on('HRM',function() { setLight('COMPACTY','',isActive(),Light_COMPACTY);}); +Bangle.on("message",function() { setLight('COMPACTY','',isActive(),Light_COMPACTY);}); +Bangle.on('charging',drawMain); +NRF.on('connect',function() { setLight('L3','BT',!isBTConnected(),Light_warn); }); +NRF.on('disconnect',function() { setLight('L3','BT',!isBTConnected(),Light_warn); }); +Bangle.on('tap', function(data) { + if (!Bangle.isLocked() && data.double) { + if (mode > 5 ) { + mode = 0; + } else { + mode=mode+1; + } + } + drawAlt(mode); +}); g.clear(); draw_bg(); -draw(); +drawMain(); queueDraw(); \ No newline at end of file From 3d02e826442283325e6ab56fb57d55175b327e72 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Tue, 24 Dec 2024 12:38:01 -0500 Subject: [PATCH 09/25] v2 with altmodes --- apps/dsky_clock/app.js | 194 +++++++++++++++++++---------------------- 1 file changed, 90 insertions(+), 104 deletions(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index fd3143f897..d0476f1b50 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -49,9 +49,9 @@ var layout = new Layout( {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00", id:"NOUN", fillx:1, height:EL7_height}, ]}, { type:"",bgCol:'#070', width:80, height:2 }, - {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R1", fillx:1, height:EL7_height}, - {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R2", fillx:1, height:EL7_height}, - {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R3", fillx:1, height:EL7_height}, + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R1", halign:1, fillx:1, height:EL7_height}, + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R2", halign:1, fillx:1, height:EL7_height}, + {type:"txt", font:DataFont, col:"#0F0", bgCol:"#000", label:"00000", id:"R3", halign:1, fillx:1, height:EL7_height}, ]}, {type:"",width:5}, ], @@ -61,25 +61,7 @@ layout.update(); //support functions function getWeather() { - try { - var weatherLib = require("weather"); - weather = weatherLib.get(); - } catch(e) { - console.log("Weather lib not found." ); - } - if (weather) { - weather.temp = Math.round(require("locale").temp(weather.temp-273.15)); - weather.hum = weather.hum; - weather.wind = Math.round(require("locale").speed(weather.wind).match(/^(\D*\d*)(.*)$/)); - weather.wind = Math.round(weather.wind[1]); - } else { - weather = { - temp: "-----", - hum: "-----", - wind: "-----", - txt: "-----", - }; - } + weather = require("Storage").readJSON('weather.json', 1).weather; return weather; } @@ -173,13 +155,20 @@ function setLight(id,label,check,onColour,offColour){ layout.render(layout[id]); } -function setDATA(id,label){ +function setDATA(id,label) { layout.clear(layout[id]); try { if (isNaN(label)) { data='-----'; } else { + if (label < 0) { + label=Math.abs(label); + sign='-'; + } else { + sign=''; + } data=String(String(label).toString(16)).toUpperCase().padStart(5,'0').substring(0,5); + data=sign+data; } } catch(e) { data='-----'; @@ -215,7 +204,6 @@ function draw_bg(){ // actual display function drawMain(){ - remove_alt_events(); datetime=getdatetime(); setDATA('R1',datetime.localtime); @@ -236,24 +224,15 @@ function drawMain(){ // layout.forgetLazyState(); layout.render(); -} - -var drawTimeout; -// schedule a draw for the next minute -function queueDraw() { - if (drawTimeout) clearTimeout(drawTimeout); - drawTimeout = setTimeout(function() { - drawTimeout = undefined; - let mode = 0; - remove_alt_events(); - drawMain(); - }, 60000 - (Date.now() % 60000)); + queueDraw(); } ////// ALT modes ///// +var AltDrawTimer; function drawAlt(mode) { - remove_alt_events(); + if (AltDrawTimer) clearTimeout(AltDrawTimer); mode = typeof mode !== 'undefined' ? mode:0; + mode=Math.abs(mode); // print('drawAlt: ', mode); // debug // Show mode in PROG setWORD('PROG',mode); @@ -261,6 +240,9 @@ function drawAlt(mode) { setWORD('VERB',''); // Disable Battery warning light in to show PROG no longer shows battery level setLight('L4','BATT',false); + setDATA('R1'); + setDATA('R2'); + setDATA('R3'); switch (mode) { case 1: setLight('L6','HRM',true); @@ -288,78 +270,82 @@ function drawAlt(mode) { layout.render(); } +function mode_HRM() { + setLight('COMPACTY','',true,Light_COMPACTY); + AltDrawTimer = setTimeout( function() { + Bangle.setHRMPower(true, 'dsky_clock'); + hrm=getHRM(); + setDATA('R1',hrm.bpm); + setDATA('R2',hrm.bpmConfidence); + setDATA('R3',getSteps()); + mode_HRM(); + }, 5000); + Bangle.setHRMPower(false); +} function mode_weather() { weather=getWeather(); + weather.temp = Math.round(weather.temp-273.15); setDATA('R1',weather.temp); setDATA('R2',weather.hum); - setDATA('R3',weather.wind); + setDATA('R3',weather.code); + setWORD('NOUN',weather.hum); + setWORD('VERB',weather.rain); } function mode_compass() { - Bangle.setCompassPower(1); - Bangle.on('mag', show_compass); -} -function mode_accel() { - Bangle.on('accel', show_accel); -} -function mode_GPS() { - Bangle.setGPSPower(1,'dsky_clock'); - Bangle.on('GPS', show_GPS); -} - -function mode_HRM() { - Bangle.setHRMPower(true, 'dsky_clock'); - Bangle.on('HRM', show_HRM); -} -function show_HRM() { - setLight('COMPACTY','',isActive(),Light_COMPACTY); - hrm=getHRM(); - setDATA('R1',hrm.bpm); - setDATA('R2',hrm.bpmConfidence); -// setDATA('R3',hrm.steps); -} - -function show_GPS() { - setLight('COMPACTY','',isActive(),Light_COMPACTY); - gps=Bangle.getGPSFix(); - setWORD('NOUN',gps.fix); - setWORD('VERB',gps.satellites); - setDATA('R1',gps.lat); - setDATA('R2',gps.lon); - setDATA('R3',gps.speed); + AltDrawTimer = setTimeout ( function() { + setLight('COMPACTY','',true,Light_COMPACTY); //isCompassOn seems to be incorrect? + Bangle.setCompassPower(1); + compass=Bangle.getCompass(); + setDATA('R1',compass.heading); + setDATA('R2'); + setDATA('R3'); + mode_compass(); + }, 200); + Bangle.setCompassPower(0); } -function show_compass() { - setLight('COMPACTY','',isActive(),Light_COMPACTY); - compass=Bangle.getCompass(); - setDATA('R1',compass.heading); - setDATA('R2'); - setDATA('R3'); +function mode_GPS() { + setLight('COMPACTY','',true,Light_COMPACTY); + AltDrawTimer = setTimeout( function() { + Bangle.setGPSPower(1,'dsky_clock'); + gps=Bangle.getGPSFix(); + setWORD('NOUN',gps.fix); + setWORD('VERB',gps.satellites); + setDATA('R1',gps.lat); + setDATA('R2',gps.lon); + setDATA('R3',gps.speed); + mode_GPS(); + }, 5000); + Bangle.setGPSPower(0); } -function show_accel() { - setLight('COMPACTY','',isActive(),Light_COMPACTY); - accel=Bangle.getAccel(); - setDATA('R1',accel.x); - setDATA('R2',accel.y); - setDATA('R3',accel.z); +function mode_accel() { + AltDrawTimer = setTimeout( function() { + setLight('COMPACTY','',isActive(),Light_COMPACTY); + accel=Bangle.getAccel(); + setDATA('R1',accel.x); + setDATA('R2',accel.y); + setDATA('R3',accel.z); + mode_accel(); + }, 100); } +//////////// Main -function remove_alt_events() { - Bangle.removeListener('accel', show_accel); - Bangle.removeListener('mag', show_compass); - Bangle.setCompassPower(0); - Bangle.removeListener('GPS', show_GPS); - Bangle.setGPSPower(0); - Bangle.removeListener('HRM', show_HRM); - Bangle.setHRMPower(0); - setLight('COMPACTY','',isActive(),Light_COMPACTY); +var drawTimeout; +// schedule a draw for the next minute +function queueDraw() { + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = setTimeout(function() { + drawTimeout = undefined; + mode = 0; + if (AltDrawTimer) clearTimeout(AltDrawTimer); + drawMain(); + }, 60000 - (Date.now() % 60000)); } -//////////// Main - // Show launcher when middle button pressed Bangle.setUI({ mode : "clock", @@ -373,26 +359,26 @@ require("widget_utils").swipeOn(); // hide widgets, make them visible with a swi Bangle.on('lock',on=>{ mode = 0; - remove_alt_events(); drawMain(); // draw immediately }); -Bangle.on('HRM',function() { setLight('COMPACTY','',isActive(),Light_COMPACTY);}); +//Bangle.on('HRM',function() { setLight('COMPACTY','',isActive(),Light_COMPACTY);}); Bangle.on("message",function() { setLight('COMPACTY','',isActive(),Light_COMPACTY);}); Bangle.on('charging',drawMain); -NRF.on('connect',function() { setLight('L3','BT',!isBTConnected(),Light_warn); }); -NRF.on('disconnect',function() { setLight('L3','BT',!isBTConnected(),Light_warn); }); -Bangle.on('tap', function(data) { - if (!Bangle.isLocked() && data.double) { - if (mode > 5 ) { - mode = 0; - } else { - mode=mode+1; - } +NRF.on('connect',function() { setLight('L3','BT',!isBTConnected(),Light_warn); }); +NRF.on('disconnect',function() { setLight('L3','BT',!isBTConnected(),Light_warn); }); + +Bangle.on('swipe', function(directionLR) { + if (directionLR == 1) { + mode=mode+1; + } + if (directionLR == -1) { + mode=mode-1; } + if (mode < 0 ) { mode=5; } + mode=(mode % 6); drawAlt(mode); }); g.clear(); draw_bg(); drawMain(); -queueDraw(); \ No newline at end of file From 92fe968e94cd2d345ca5a42e52889d78f57b5ed8 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Tue, 24 Dec 2024 12:41:56 -0500 Subject: [PATCH 10/25] updated metadata to reflect new features --- apps/dsky_clock/README.md | 12 ++++++++++++ apps/dsky_clock/dsky_clock.img | Bin 1156 -> 0 bytes apps/dsky_clock/metadata.json | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) delete mode 100644 apps/dsky_clock/dsky_clock.img diff --git a/apps/dsky_clock/README.md b/apps/dsky_clock/README.md index a710ae077a..d85f826eae 100644 --- a/apps/dsky_clock/README.md +++ b/apps/dsky_clock/README.md @@ -19,6 +19,18 @@ Indicator lights are: - ALARM (Alarm is set) - STEP (Reached STEP goal)) +---- +## Alt Modes +Swipe left/right to switch between different PROGRAM modes. + +- HRM (BPM/Confidence) +- GPS (Latitude/Longitude/Speed) +- Weather (Humidity/Rain/Temperature/Wind/Condition Code) +- Accelerometer (X/Y/Z) +- Compass (HEADING) + +In the interests of usability these change the "LIGHT" on the left side to show the current mode. + ---- This is my first watch face, may add features and customization later. diff --git a/apps/dsky_clock/dsky_clock.img b/apps/dsky_clock/dsky_clock.img deleted file mode 100644 index 9e2fb3adb55a41dd88d89048b60c5735e33e2afc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1156 zcmZ{kJ#vFE5QP^PtCWHpzzIA#gWGgYnHg1bONB3x6K34zE_wSSB;k0OLCnYF>1h$1 z&);v0)$HSOpoL1^?)Q}@7sSf%!cXPF_adj9a{?cw@EDO?l)L|P7JVEB*W(e>D<8+$ z`S424-9L_l>%)tAd;P0C2rkp|F~2U9C}1>y&-27Rk2XMka+ill{q@xLff6T~IN>-g zzfwQaHw8LKpBqlM1dNmEFCVT~EMCeVU&W{A)xXQr`orC;pSMuz@-SA!o84>mffH}M z1q!OaJ}#D%vEYmYuTgwHubvYen+I;j_nZOxjZ^X2Ib)yUl@*_z>#|bGBX8UGPfaiL zHattrT|Yz`bl*z;#H;&92#ia9Nn|;z4*-1Nr1>ik1anbqA1Y^UoZdO)A?bovm($QQ z&!U&G{kpJ`y?Ty3h`I85%!9^ZPr<0s@bVuBwp{lyP7~s3KP^xBZ_LZA I3oobX533WW&Hw-a diff --git a/apps/dsky_clock/metadata.json b/apps/dsky_clock/metadata.json index d66a99a736..a00602b5c5 100644 --- a/apps/dsky_clock/metadata.json +++ b/apps/dsky_clock/metadata.json @@ -2,7 +2,7 @@ "name": "DSKY Clock", "icon": "dsky_clock.img", "screenshots": [{"url":"screenshot1.png"}], - "version": "0.01", + "version": "0.02", "description": "A clockface inspired by the Apollo DSKY interface.", "tags": "clock", "type": "clock", From 32dc122a3a2c52ede93518dff9ae4902a4b23608 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Tue, 24 Dec 2024 12:46:30 -0500 Subject: [PATCH 11/25] update changelog --- apps/dsky_clock/ChangeLog | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/dsky_clock/ChangeLog b/apps/dsky_clock/ChangeLog index d18016d210..294dee60bd 100644 --- a/apps/dsky_clock/ChangeLog +++ b/apps/dsky_clock/ChangeLog @@ -1 +1,2 @@ -0.01: Initial commit \ No newline at end of file +0.01: Initial commit +0.02: Added Alt modes From c03d38517a03bfd3c48695ce3bfdd59f17f19975 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Tue, 24 Dec 2024 12:51:50 -0500 Subject: [PATCH 12/25] remove altdrawtimer on exit to launcher --- apps/dsky_clock/app.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index d0476f1b50..0fd61965ff 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -351,7 +351,9 @@ Bangle.setUI({ mode : "clock", remove : function() { if (drawTimeout) clearTimeout(drawTimeout); + if (AltDrawTimer) clearTimeout(AltDrawTimer); drawTimeout = undefined; + AltDrawTimer = undefined; require("widget_utils").show(); // re-show widgets }}); Bangle.loadWidgets(); From cb8d3ddce1bcf0ffb6a36476d4d2b7f04f78beee Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Tue, 24 Dec 2024 12:54:53 -0500 Subject: [PATCH 13/25] ensure UI resets properly after return from launcher --- apps/dsky_clock/app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index 0fd61965ff..9c47005b14 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -222,7 +222,8 @@ function drawMain(){ setLight('L5','ALARM',isAlarmSet(),Light_warn); setLight('L6','STEP',(getSteps()>=getStepGoal()),'#0a0'); - // layout.forgetLazyState(); + layout.setUI(); + layout.forgetLazyState(); layout.render(); queueDraw(); } From c0e117392557be18ca313d755f5672a767591a06 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Tue, 24 Dec 2024 13:03:04 -0500 Subject: [PATCH 14/25] change swipe direction --- apps/dsky_clock/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index 9c47005b14..412d3e1beb 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -372,10 +372,10 @@ NRF.on('disconnect',function() { setLight('L3','BT',!isBTConnected(),Light_warn) Bangle.on('swipe', function(directionLR) { if (directionLR == 1) { - mode=mode+1; + mode=mode-1; } if (directionLR == -1) { - mode=mode-1; + mode=mode+1; } if (mode < 0 ) { mode=5; } mode=(mode % 6); From 31e9ee5c1928e9ea2c303d7cbb7bbfc31f0c00f0 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Tue, 24 Dec 2024 18:13:36 -0500 Subject: [PATCH 15/25] add altdraw modes, moved around order of modes --- apps/dsky_clock/app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index 412d3e1beb..245513d5d3 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -250,13 +250,13 @@ function drawAlt(mode) { mode_HRM(); break; case 2: - setLight('L6','GPS',true); - mode_GPS(); - break; - case 3: setLight('L6','TEMP',true); mode_weather(); break; + case 3: + setLight('L6','GPS',true); + mode_GPS(); + break; case 4: setLight('L6','ACCEL',true); mode_accel(); From 0c64bdac682833c8a66dcb5722032952deeebe6c Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Tue, 24 Dec 2024 20:59:54 -0500 Subject: [PATCH 16/25] try fix restore from launcher --- apps/dsky_clock/app.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index 245513d5d3..25bc9027e8 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -347,24 +347,10 @@ function queueDraw() { }, 60000 - (Date.now() % 60000)); } -// Show launcher when middle button pressed -Bangle.setUI({ - mode : "clock", - remove : function() { - if (drawTimeout) clearTimeout(drawTimeout); - if (AltDrawTimer) clearTimeout(AltDrawTimer); - drawTimeout = undefined; - AltDrawTimer = undefined; - require("widget_utils").show(); // re-show widgets - }}); -Bangle.loadWidgets(); -require("widget_utils").swipeOn(); // hide widgets, make them visible with a swipe - Bangle.on('lock',on=>{ mode = 0; drawMain(); // draw immediately }); -//Bangle.on('HRM',function() { setLight('COMPACTY','',isActive(),Light_COMPACTY);}); Bangle.on("message",function() { setLight('COMPACTY','',isActive(),Light_COMPACTY);}); Bangle.on('charging',drawMain); NRF.on('connect',function() { setLight('L3','BT',!isBTConnected(),Light_warn); }); @@ -384,4 +370,18 @@ Bangle.on('swipe', function(directionLR) { g.clear(); draw_bg(); + +// Show launcher when middle button pressed +Bangle.setUI({ + mode : "clock", + remove : function() { + if (drawTimeout) clearTimeout(drawTimeout); + if (AltDrawTimer) clearTimeout(AltDrawTimer); + drawTimeout = undefined; + AltDrawTimer = undefined; + require("widget_utils").show(); // re-show widgets + }}); +Bangle.loadWidgets(); +require("widget_utils").swipeOn(); // hide widgets, make them visible with a swipe + drawMain(); From a5c6c6d1e3600a23fdec738cf32907d23a3276a9 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Wed, 25 Dec 2024 11:39:38 -0500 Subject: [PATCH 17/25] update app icon with png version --- apps/dsky_clock/app-icon.png | Bin 0 -> 2303 bytes apps/dsky_clock/metadata.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 apps/dsky_clock/app-icon.png diff --git a/apps/dsky_clock/app-icon.png b/apps/dsky_clock/app-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..be7195743826ef401821e015b7c7837938f296e5 GIT binary patch literal 2303 zcmWlXc|6pK8^@pd&eu)Cgfc~#lylr-jB(b;Q7F0AQHD^im58~FbCoOQs)l~rT=BEX zjB|8iRpdxg3Q4QhQCUZ2?els)*MHCF`Mfg^yBv@b-yseFQq+TXZkwI>Uy5QkYrwcz z695(tJ9*e|t`}@TLqo&U(;dtJ&Ou5_6379JL2PW5qB!{J~TAeYep?m7$z3x#`_4F&)T3`Q1gfsn{dI{jXHdLKl>+e93j-R9+$ zP~#3@16I0LRyOwW@zq8~MlLQfbqqF&3PBJ&3xSOkFe8~!^eJZ8%P5%20y;Ozv*d?j*c#HHir&S2PU%#kH-TQ zkSplnx|opQ3kaYVWD*82mX>B}N)84lMqmg+hC&QRRdjR(%s9U~R8K}Ch~Isy_B z>InpbgoMOExX^Oq<{z*S2e!7h3Y!p1&0940dYd%5H!n9ECUF&Q0=Te z4ray`O8dGW#XWWv57gZ5Nbr&D6&=ZTcDu(srrnn@68&D%7FSMK z%U^yXtUWX1g!2+Ua=2yxRF1Ak1o2_et?f7LgXcOvw>KZS?%LUWeu6w7+c{qr`;7m= z`g0~Tn<}E9R1kK(thQ)9lHZuLx}@cg&rWzY3e+3(NiLyX10l~hbp3eZhH) zvlCOEU7>A@+T}`~O8#qnLt%sJs>)&BmidIKVavt5kZQw#M|;(WpRQ&Mm5pU2U%$^`XV#Xmy^JLofdX6b3?mf`-^t@%4lxAat0oHTfu8*ySPwLm7ED>+$BbjqUEeWzYK zCB4qn(HSXUTU&}L_DK9#BcY-2PH?fI@Z0Rx4B`wQ71RZs5%;M^|Z(k}zuaqrE$Ow43sCtoyYEzJI zb|W{;t*+EG+|e^Z1@vdl_fjVFdA_n#$nbeSmKfTTe~TETU(hqfy0{IZ_@VM=+e(*? zJ398(Cr!RTd2E&`ale~uNbzxtIY8}ss#p53#Kmi)1tku3-gD07XH|_ zuITHj125+~HJa$lIrS?r-TF|9IN60Mi{@Z|9ZeEgwmu&moXhRkNq*smY{hDfKfgNV zulHJOT7ZKRQ zp*7buz5O+-xSxD;kR`WgT0P2}zr1>)wa`~Kbh*=fXt%1PY6x3ylz@M$Id{od*EAq- zJYptFvSimEFF!e0r5p^L;XR4yMPAf{K(5L@!kNdaqy07%=FD?Ym#vaAH|Kh2o&t(> z2LY36KrVZ&7s8geiZi-mGPKVWZ*lg5aCUr3)K-CqjCgIaQ2#sDqRCb{X3XCc{P@U; zpAVWp-tlW>BAvSTKm? z5DT!nJFj=FzvOolyeFq$bGwm+k#k)aDbxAi4a7dVX$}^i^W*Zcl`^DGp0dD_rdJk# zl??AX=7^NuB~!xY_EfC&@76LdpCJf0Q&{<=RVQUfXXhV;;j9^3pNyrOBMY;ZOw`*~ zAz0T-`L70@>C9Mmkh-+EVrBmunoVl3+|&UMGV3gg8~tJ)$R`94`-RvBShzer*tVj+Wc^5M|j`VqXagoxZZhxc3#l$hECQ zGb~jJNt{%p&dY}#8aO7kR`D-GkD3QMM2fq|r{9cZ3YRmsOz-^qG(G;95dwOhzfS~y z*emESsDy3_Olj)hvTw4n?b{{@&hip{Yk1D3)j!~s+6r6&MMED+{-_7np<2f+OzG4%B`sTZ~16wiXf!94gaHm=!N3{a~g6b zuk|9tqC}>9Pa4-zCx;}hv8!awq^jzw)K$H8@R84OKvhnj3uJb&f|5l~<}nvPg*hH* zu3LL6viHx>pI?UNJ9nPJqoZmA1Em8Q7cP?7IZswB eO_uqutkxBD)8pwY#EOfs8B}{0yW2Ja?0*3U&$c)K literal 0 HcmV?d00001 diff --git a/apps/dsky_clock/metadata.json b/apps/dsky_clock/metadata.json index a00602b5c5..1c286f2bec 100644 --- a/apps/dsky_clock/metadata.json +++ b/apps/dsky_clock/metadata.json @@ -1,6 +1,6 @@ { "id": "dsky_clock", "name": "DSKY Clock", - "icon": "dsky_clock.img", + "icon": "app-icon.png", "screenshots": [{"url":"screenshot1.png"}], "version": "0.02", "description": "A clockface inspired by the Apollo DSKY interface.", From ae23db51369e85a699b2712c18d7f7818feab272 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Wed, 25 Dec 2024 17:02:01 -0500 Subject: [PATCH 18/25] learning how to declar variables in js --- apps/dsky_clock/app.js | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index 25bc9027e8..884dcdd7d4 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -3,17 +3,17 @@ var Layout = require("Layout"); require("Font7x11Numeric7Seg").add(Graphics); require("FontTeletext5x9Ascii").add(Graphics); -borders = 1; -Light_on='#fff'; -Light_off='#554'; -Light_warn='#f90'; -Light_COMPACTY='#0F0'; -Light_width=43; -Light_height=25; -EL7_height=30; -LightFont='Teletext5x9Ascii'; -DataFont='7x11Numeric7Seg:2'; -mode = 0; +const borders = 1; +const Light_on='#fff'; +const Light_off='#554'; +const Light_warn='#f90'; +const Light_COMPACTY='#0F0'; +const Light_width=43; +const Light_height=25; +const EL7_height=30; +const LightFont='Teletext5x9Ascii'; +const DataFont='7x11Numeric7Seg:2'; +var mode = 0; var layout = new Layout( {type:"h", c:[ @@ -61,7 +61,7 @@ layout.update(); //support functions function getWeather() { - weather = require("Storage").readJSON('weather.json', 1).weather; + var weather = require("Storage").readJSON('weather.json', 1).weather; return weather; } @@ -80,7 +80,7 @@ function getdatetime(){ } function getSteps(){ - steps=Bangle.getHealthStatus("day").steps; + let steps=Bangle.getHealthStatus("day").steps; steps = typeof steps !== 'undefined' ? steps:0; return steps; } @@ -111,7 +111,7 @@ function getTemperature(){ } function getHRM(){ - hrm=Bangle.getHealthStatus('last'); + let hrm=Bangle.getHealthStatus('last'); hrm = typeof hrm !== 'undefined' ? hrm:0; return hrm; } @@ -121,7 +121,7 @@ function isBTConnected(){ } function getBattery(){ - battlevel = E.getBattery(); + let battlevel = E.getBattery(); if (Bangle.isCharging()) { battlevel = -1; } else if (battlevel >= 100) { @@ -157,10 +157,9 @@ function setLight(id,label,check,onColour,offColour){ function setDATA(id,label) { layout.clear(layout[id]); + let data='-----'; try { - if (isNaN(label)) { - data='-----'; - } else { + if (!isNaN(label)) { if (label < 0) { label=Math.abs(label); sign='-'; @@ -204,7 +203,7 @@ function draw_bg(){ // actual display function drawMain(){ - datetime=getdatetime(); + let datetime=getdatetime(); setDATA('R1',datetime.localtime); setDATA('R2',datetime.utctime); @@ -285,7 +284,7 @@ function mode_HRM() { } function mode_weather() { - weather=getWeather(); + let weather=getWeather(); weather.temp = Math.round(weather.temp-273.15); setDATA('R1',weather.temp); setDATA('R2',weather.hum); From b71480ef89def98d6926feb77e6d32e2143d2072 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Wed, 25 Dec 2024 17:08:51 -0500 Subject: [PATCH 19/25] more cleanup after some lint checking --- apps/dsky_clock/app.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index 884dcdd7d4..bd154b7446 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -74,7 +74,7 @@ function getdatetime(){ datetime.month = d.getMonth()+1; datetime.day = d.getDate(); datetime.localtime=String(d.getHours()).padStart(2,'0')+String(d.getMinutes()).padStart(2,'0'); - utchour=((d.getHours()+(Math.round(d.getTimezoneOffset()/60))) % 24); + let utchour=((d.getHours()+(Math.round(d.getTimezoneOffset()/60))) % 24); datetime.utctime=String(utchour).padStart(2,'0')+String(d.getMinutes()).padStart(2,'0'); return datetime; } @@ -158,13 +158,12 @@ function setLight(id,label,check,onColour,offColour){ function setDATA(id,label) { layout.clear(layout[id]); let data='-----'; + let sign=''; try { if (!isNaN(label)) { if (label < 0) { label=Math.abs(label); sign='-'; - } else { - sign=''; } data=String(String(label).toString(16)).toUpperCase().padStart(5,'0').substring(0,5); data=sign+data; @@ -179,13 +178,12 @@ function setDATA(id,label) { function setWORD(id,label){ layout.clear(layout[id]); try { - if (isNaN(label)) { - data='--'; - } else { + let data='--'; + if (!isNaN(label)) { data=String(String(label).toString(16)).toUpperCase().padStart(2,'0').substring(0,2); } } catch(e) { - data='--'; + let data='--'; } // print(id, data); //debug layout[id].label=data; @@ -274,7 +272,7 @@ function mode_HRM() { setLight('COMPACTY','',true,Light_COMPACTY); AltDrawTimer = setTimeout( function() { Bangle.setHRMPower(true, 'dsky_clock'); - hrm=getHRM(); + let hrm=getHRM(); setDATA('R1',hrm.bpm); setDATA('R2',hrm.bpmConfidence); setDATA('R3',getSteps()); @@ -297,7 +295,7 @@ function mode_compass() { AltDrawTimer = setTimeout ( function() { setLight('COMPACTY','',true,Light_COMPACTY); //isCompassOn seems to be incorrect? Bangle.setCompassPower(1); - compass=Bangle.getCompass(); + let compass=Bangle.getCompass(); setDATA('R1',compass.heading); setDATA('R2'); setDATA('R3'); @@ -310,7 +308,7 @@ function mode_GPS() { setLight('COMPACTY','',true,Light_COMPACTY); AltDrawTimer = setTimeout( function() { Bangle.setGPSPower(1,'dsky_clock'); - gps=Bangle.getGPSFix(); + let gps=Bangle.getGPSFix(); setWORD('NOUN',gps.fix); setWORD('VERB',gps.satellites); setDATA('R1',gps.lat); @@ -324,7 +322,7 @@ function mode_GPS() { function mode_accel() { AltDrawTimer = setTimeout( function() { setLight('COMPACTY','',isActive(),Light_COMPACTY); - accel=Bangle.getAccel(); + let accel=Bangle.getAccel(); setDATA('R1',accel.x); setDATA('R2',accel.y); setDATA('R3',accel.z); From 3e24a5c599188f6d33c437858755c8da090e6515 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Wed, 25 Dec 2024 19:06:49 -0500 Subject: [PATCH 20/25] remove more unused variables and functions from previous versions --- apps/dsky_clock/app.js | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index bd154b7446..3c90634d9f 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -3,7 +3,6 @@ var Layout = require("Layout"); require("Font7x11Numeric7Seg").add(Graphics); require("FontTeletext5x9Ascii").add(Graphics); -const borders = 1; const Light_on='#fff'; const Light_off='#554'; const Light_warn='#f90'; @@ -68,7 +67,7 @@ function getWeather() { function getdatetime(){ var datetime = []; var d = new Date(); - var offsets = require("Storage").readJSON("worldclock.settings.json") || []; +// var offsets = require("Storage").readJSON("worldclock.settings.json") || []; // var meridian = require("locale").meridian(d); datetime.clock = require("locale").time(d, 1); datetime.month = d.getMonth()+1; @@ -104,12 +103,6 @@ function isMessagesNotify(){ } } -function getTemperature(){ - var temperature = E.getTemperature(); - temperature = typeof temperature !== 'undefined' ? temperature:99999; - return Math.round(temperature); -} - function getHRM(){ let hrm=Bangle.getHealthStatus('last'); hrm = typeof hrm !== 'undefined' ? hrm:0; @@ -177,15 +170,11 @@ function setDATA(id,label) { function setWORD(id,label){ layout.clear(layout[id]); - try { - let data='--'; - if (!isNaN(label)) { - data=String(String(label).toString(16)).toUpperCase().padStart(2,'0').substring(0,2); - } - } catch(e) { - let data='--'; + let data='--'; + if (!isNaN(label)) { + let data=String(String(label).toString(16)).toUpperCase().padStart(2,'0').substring(0,2); } -// print(id, data); //debug + // print(id, data); //debug layout[id].label=data; layout.render(layout[id]); } From d2f8d172fe178590e8e93055e5b8cd8a7af96946 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Wed, 25 Dec 2024 19:07:24 -0500 Subject: [PATCH 21/25] remove more unused variables and functions from previous versions --- apps/dsky_clock/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index 3c90634d9f..d9a0a41a46 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -172,7 +172,7 @@ function setWORD(id,label){ layout.clear(layout[id]); let data='--'; if (!isNaN(label)) { - let data=String(String(label).toString(16)).toUpperCase().padStart(2,'0').substring(0,2); + data=String(String(label).toString(16)).toUpperCase().padStart(2,'0').substring(0,2); } // print(id, data); //debug layout[id].label=data; From 4a93991fc6eec571e4976d8b04f44b7874c31ed5 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Wed, 25 Dec 2024 19:08:02 -0500 Subject: [PATCH 22/25] fix type in isActive check --- apps/dsky_clock/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index d9a0a41a46..c68b8ce493 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -125,7 +125,7 @@ function getBattery(){ } function isActive(){ - if (Bangle.isCompassOn() || Bangle.isGPSOn() || Bangle.isHRMOn() | Bangle.isBarometerOn() ) { + if (Bangle.isCompassOn() || Bangle.isGPSOn() || Bangle.isHRMOn() || Bangle.isBarometerOn() ) { return true; } else { return false; From 9dec0643e1bfafdb7ae436ae8becbb741af56074 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Fri, 27 Dec 2024 17:24:24 -0500 Subject: [PATCH 23/25] handle missing weather libs per https://github.com/espruino/BangleApps/pull/3700\#discussion_r1898658072 --- apps/dsky_clock/app.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index c68b8ce493..eb4854981d 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -60,7 +60,12 @@ layout.update(); //support functions function getWeather() { - var weather = require("Storage").readJSON('weather.json', 1).weather; + var weather = {}; + try { + weather = require("Storage").readJSON('weather.json', 1).weather; + } catch(e) { + return {}; + } return weather; } From ebb2f7dc5fa5299241049f78b9b435df120378b0 Mon Sep 17 00:00:00 2001 From: Carl Chan Date: Fri, 27 Dec 2024 18:04:36 -0500 Subject: [PATCH 24/25] remove fast-load and layout.setUI to so launcher load works again --- apps/dsky_clock/app.js | 44 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index eb4854981d..05d7473130 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -57,7 +57,7 @@ var layout = new Layout( lazy:true}); layout.update(); -//support functions +//support functioe_ns function getWeather() { var weather = {}; @@ -213,7 +213,7 @@ function drawMain(){ setLight('L5','ALARM',isAlarmSet(),Light_warn); setLight('L6','STEP',(getSteps()>=getStepGoal()),'#0a0'); - layout.setUI(); +// layout.setUI(); layout.forgetLazyState(); layout.render(); queueDraw(); @@ -277,12 +277,20 @@ function mode_HRM() { function mode_weather() { let weather=getWeather(); - weather.temp = Math.round(weather.temp-273.15); - setDATA('R1',weather.temp); - setDATA('R2',weather.hum); - setDATA('R3',weather.code); - setWORD('NOUN',weather.hum); - setWORD('VERB',weather.rain); + try { + weather.temp = Math.round(weather.temp-273.15); + setDATA('R1',weather.temp); + setDATA('R2',weather.hum); + setDATA('R3',weather.code); + setWORD('NOUN',weather.hum); + setWORD('VERB',weather.rain); + } catch(e) { + setDATA('R1','-----'); + setDATA('R2','-----'); + setDATA('R3','-----'); + setDATA('R1','--'); + setDATA('R1','--'); + } } function mode_compass() { @@ -338,6 +346,12 @@ function queueDraw() { }, 60000 - (Date.now() % 60000)); } +// Show launcher when middle button pressed +Bangle.setUI("clock"); + +Bangle.loadWidgets(); +require("widget_utils").swipeOn(); // hide widgets, make them visible with a swipe + Bangle.on('lock',on=>{ mode = 0; drawMain(); // draw immediately @@ -361,18 +375,4 @@ Bangle.on('swipe', function(directionLR) { g.clear(); draw_bg(); - -// Show launcher when middle button pressed -Bangle.setUI({ - mode : "clock", - remove : function() { - if (drawTimeout) clearTimeout(drawTimeout); - if (AltDrawTimer) clearTimeout(AltDrawTimer); - drawTimeout = undefined; - AltDrawTimer = undefined; - require("widget_utils").show(); // re-show widgets - }}); -Bangle.loadWidgets(); -require("widget_utils").swipeOn(); // hide widgets, make them visible with a swipe - drawMain(); From 005329e3881acee3277232233fb922739e16ff41 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.comā©> Date: Sat, 28 Dec 2024 20:16:15 +0100 Subject: [PATCH 25/25] dsky_clock: hide widgets before building layout so that the layout doesn't account for the widget bar when `dsky_clock` is fast loaded into. Also handle the hardware button through the layout library instead of `Bangle.setUI`. Also set `Bangle.CLOCK` directly. --- apps/dsky_clock/app.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/dsky_clock/app.js b/apps/dsky_clock/app.js index 05d7473130..64e00d333e 100644 --- a/apps/dsky_clock/app.js +++ b/apps/dsky_clock/app.js @@ -14,6 +14,8 @@ const LightFont='Teletext5x9Ascii'; const DataFont='7x11Numeric7Seg:2'; var mode = 0; +if (global.WIDGETS) {require("widget_utils").swipeOn();} // If `dsky_clock` was fast loaded into we seemingly need to hide the widgets before setting the layout so elements are not moved down. + var layout = new Layout( {type:"h", c:[ {type:"",width:6}, @@ -54,7 +56,10 @@ var layout = new Layout( ]}, {type:"",width:5}, ], - lazy:true}); + lazy:true}, + {btns:[ + {label:"", cb: Bangle.showLauncher} + ], lazy:true}); layout.update(); //support functioe_ns @@ -346,12 +351,6 @@ function queueDraw() { }, 60000 - (Date.now() % 60000)); } -// Show launcher when middle button pressed -Bangle.setUI("clock"); - -Bangle.loadWidgets(); -require("widget_utils").swipeOn(); // hide widgets, make them visible with a swipe - Bangle.on('lock',on=>{ mode = 0; drawMain(); // draw immediately @@ -376,3 +375,7 @@ Bangle.on('swipe', function(directionLR) { g.clear(); draw_bg(); drawMain(); + +Bangle.CLOCK = 1; +Bangle.loadWidgets(); // loading widgets after drawing the layout in `drawMain()` to display the app UI ASAP. +require("widget_utils").swipeOn(); // hide widgets, make them visible with a swipe