From db3eb8985abf29a81b4d56ebb3a34d16149a9178 Mon Sep 17 00:00:00 2001 From: Ben Jabituya <74158243+jabituyaben@users.noreply.github.com> Date: Tue, 5 Jan 2021 19:04:50 +0000 Subject: [PATCH] Add files via upload --- apps/hrmdataexport/README.md | 7 +++ apps/hrmdataexport/app-icon.js | 2 + apps/hrmdataexport/app-icon.png | Bin 0 -> 956 bytes apps/hrmdataexport/app.js | 97 ++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 apps/hrmdataexport/README.md create mode 100644 apps/hrmdataexport/app-icon.js create mode 100644 apps/hrmdataexport/app-icon.png create mode 100644 apps/hrmdataexport/app.js diff --git a/apps/hrmdataexport/README.md b/apps/hrmdataexport/README.md new file mode 100644 index 000000000..122b7f21e --- /dev/null +++ b/apps/hrmdataexport/README.md @@ -0,0 +1,7 @@ +Extract hrm raw signal data to CSV file +======================================= + +Simple app that will run the heart rate monitor for a defined period of time you set at the start. The max time value is 60 minutes but you can increase this just by changing the value in the app's script code if you wanted to - be mindful that your log file can get large and there are storage limitations if you start trying to log beyond this max. + +The hrm sensor is sampled @50Hz and this app does not do any processing on it, the array is written as-is. There is an example Python script that can process this signal, smooth it and also extract a myriad of heart rate variability metrics using the hrvanalysis library: +https://github.com/jabituyaben/BangleJS-HRM-Signal-Processing \ No newline at end of file diff --git a/apps/hrmdataexport/app-icon.js b/apps/hrmdataexport/app-icon.js new file mode 100644 index 000000000..356be780a --- /dev/null +++ b/apps/hrmdataexport/app-icon.js @@ -0,0 +1,2 @@ +E.toArrayBuffer(atob("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/AA/AAAD/4H/wAAP/8P/8AAf/+f/+AA/A//B/AA+AP8A/AB8AH4B/gB4ADwD/gDwABgH3wDwAAAPjwDwAAAfDwDwDAA+DwDwHgB8DwDwHwD4DwB4D4HwHgB4B8PgHgB8A+fAPgA8Af+APAA+AP8AfAAfAH4A+AAPgDwB8AAPwBgD8AAH4AAH4AAD4AAHwAAB+AAfgAAA/AA/AAAAfgB+AAAAPwD8AAAAH4H4AAAAD8PwAAAAB+fgAAAAA//AAAAAAf+AAAAAAP8AAAAAADwAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")) +} \ No newline at end of file diff --git a/apps/hrmdataexport/app-icon.png b/apps/hrmdataexport/app-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..6ad50930bd239c8da1fe367da4b142f9e619adfc GIT binary patch literal 956 zcmV;t14I0YP)!Y=lst9^BhKu7%^g)jJ2?x#KU+HTd*njKZ99(fsgQ4L!6D+i5-~21}xze zPU0wLaJGfETGrwK{>>|@D;M!Du8+jofWx^>Q=ECcl-E5FoA7Nyg<<&{_m<+^mw#&; z=QwU0MEt1^m6k_i7oNhU0pk4Lr4ehzd;T;I;!aFp9JgXG<|6i&^Adia!wb3ZIM(BC zypD4b`{TH-O#==@f*irR8lN?}-$KN{(pdp^eFSS-a@%)hk}e_8)@dOD@@nZW5_OYsG}aV0OiYwW7T zPvec?`zI+C{~S2o(Mf*Be)V&=PCRT6{{56vX*g^t(`PCra6prIvh`U0e=a5Pg}|xl zG(05RU3R5w_n3b13wR>1n+R;qrvwl8^Q|?uhgA1o6)8PmaC>0)Yf1x-22Rgc*lleg zq>Fg6!>(*QlhS~_fz#{?32G}IehloNOKHGn%lGgl+&^F=x`^Kq*e}TLXGw(9=sWak z>>rH?EEaa^f-Td-iNGi63@F&9e-xf=@TuzMwmlDf0-r_P)usXPK@jAEY*(lwHWF=m zp6pCHANU<^E1oR%3omuEvc0*Es!Lf)&rjfoz;9lb&2?gDM963A*8}|{k<#-$d>X0m z$&T9pjN|)A@K+Ojr=^L1EfW8P6-ep}Zj$AuVI?oG zK%vUjme3DCOSCiFX_!$~_RTku;%%s1i(&m_Kz*#CjsRzYu+ z8^pKRUvNvwZnG?(4ed_i=2g@iWfEWN7x$;^1#e1x3;tUC5qKy};Fx}qXY&$%Kc@Lk zwd(X_x5lcQXi+}IwL{X_$e87ce(cb@W@zeKu*dR*=nD1?RZ#~XktIPF)xV4WuX!LZ eBSwrE5$7sm(k>&$u9r3d0000 1) + counter -= 1; + else + counter = 60; + update_timer(); + } +} + +function btn2Pressed() { + launchtime = 0 | getTime(); + file.write(launchtime + "," + "\n"); + logging_started = true; + counter = counter * 60; + interval = setInterval(countDown, 1000); + Bangle.setHRMPower(1); +} + +function fmtMSS(e) { + var m = Math.floor(e % 3600 / 60).toString().padStart(2, '0'), + s = Math.floor(e % 60).toString().padStart(2, '0'); + return m + ':' + s; +} + +function countDown() { + g.clear(); + counter--; + if (counter == 0) { + Bangle.setHRMPower(0); + clearInterval(interval); + g.drawString("Finished", g.getWidth() / 2, g.getHeight() / 2); + Bangle.buzz(500, 1); + } + else + g.drawString(fmtMSS(counter), g.getWidth() / 2, g.getHeight() / 2); +} + +update_timer(); + +setWatch(btn1Pressed, BTN1, { repeat: true }); +setWatch(btn2Pressed, BTN2, { repeat: true }); +setWatch(btn3Pressed, BTN3, { repeat: true }); + +Bangle.on('HRM', function (hrm) { + for (let i = 0; i < hrm.raw.length; i++) { + value = hrm.raw[i]; + if (value < -2) + value = -2; + if (value > 6) + value = 6; + file.write(value + "," + "\n"); + } +}); \ No newline at end of file