From b691676fad34849ae9e917ce5486e8f9016b84c7 Mon Sep 17 00:00:00 2001 From: Ben Jabituya <74158243+jabituyaben@users.noreply.github.com> Date: Fri, 8 Jan 2021 16:34:50 +0000 Subject: [PATCH] Add files via upload --- apps/breath/README.md | 12 ++ apps/breath/app-icon.js | 1 + apps/breath/app-icon.png | Bin 0 -> 1336 bytes apps/breath/app.js | 225 ++++++++++++++++++++++++++++++ apps/breath/breather_settings.txt | 1 + 5 files changed, 239 insertions(+) create mode 100644 apps/breath/README.md create mode 100644 apps/breath/app-icon.js create mode 100644 apps/breath/app-icon.png create mode 100644 apps/breath/app.js create mode 100644 apps/breath/breather_settings.txt diff --git a/apps/breath/README.md b/apps/breath/README.md new file mode 100644 index 000000000..e31d3701c --- /dev/null +++ b/apps/breath/README.md @@ -0,0 +1,12 @@ +Breathing App +============= +This app attempts to aid relaxation and train breath syncronicity by providing a visualisation of a circle that expands and contracts to guide breathing rate. The app also modulates the vibration motor so you don't neccessarily have to look at the screen. Your HR is displayed in the lower left and there are a few parameters you can change to tailor what works best for you. + +Resonance frequency breathing is a way of breathing (slow relaxed diaphragmatic breathing at around 3-7 breaths per minute) that has a regulating effect on the autonomic nervous system and other key body systems such as the circulatory system. This has many benefits, supported by numerous studies e.g.: + +Increases pulmonary function +Lowers blood pressure +Improves baroreflex gain +Improves heart rate variability +Increases the ability to handle stress +Clinical improvements in asthma \ No newline at end of file diff --git a/apps/breath/app-icon.js b/apps/breath/app-icon.js new file mode 100644 index 000000000..c1373e414 --- /dev/null +++ b/apps/breath/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwxH+AH4A/AH4AFqoAFF94zoF5QxkF5gxiF/t5F92k5wvt5AvtvXOAAIvqvJeBF9i9BAAYvoFwovnvQuGF816XYYwiFw4tIF8qMHF86NJF8iOLGDqOMztV0YvOxIABF5qIB0l6RxFPp1VMBgtCGB4eDvTtH0dPL4gwHFQYwPXBjBTGBwvVYTIv/FyAviFpYuOF6bsOF8wqFFpxffACIuuF7llL99lGKKPeGKAvgGBzufF6XHAAPNFzIvUAAZqEFqC/SF44AkF/4A/AH4A/ADIA=")) \ No newline at end of file diff --git a/apps/breath/app-icon.png b/apps/breath/app-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..740eb698f32bcf5435923df1e82a68ff80010d4d GIT binary patch literal 1336 zcmV-81;_e{P)BKMW8~1mU4^e2C=O|P)kx;(iR)6 zv`zX#P*hBSYEY8K=!(9Oc&Pt0on0R6@2Pvv|NGAQcITWqCj};$;QtL7bu?6!cY`qngxdjJ0dN_NO8}oG z!bu3}lw$~|ylrj%)J^whVg+Cm`T&3<46*N=aJTtRofS#&G{p7*cT5t@oliUL_BF!x0Qb(4Gtt}k zn%%xe*cyNcSTxT8fVc2x)x~yt8)0hzPo9j)x6z0%(+>7}ld;DBgKYz-ZbJDI=Zyx& zJS;x@xLy86*b+bzKy9%bX-b40@n$>xV=?XkvINu=yOB3Tiq>7oM{1{!cZ^t!D?pke zu%=waf?V0Cgur@I-wO!`xaV#O8=i0@_s)10^k|}En8EO?i$(Tifx1$~Trpv8B4d~( zpCR)*m~sj6J0C*(i6Aar)gc71r7jKWYIK>m>01nIVYr+!yc?E8b_c-v z0xI?W9!TPxeh#2sTxim z0G8(Gz~zvzG=E04ZUsbd8EG}Q_AO_ z3Bcu4(t0?uwefrHk@`Z%vC%4Kdbcy!0>&Py>6rv>NdV3^TS+2(Va!KYw3<{0=mqg6v&A}#v6rGV(P|PpN?3Pew?#8gMS!l+c@Qyx-?n!S&kwOElAW%FT1fX0aW1jQX25xU zTO{Br1D`YN?>%3rd|_msf&knV+4AFG&ObG2;L_f*j6I`O%(Sy(a9WULHB7F)&H40? z8TaG|VCs%+YFkbF%Sm!AuhmR6b7l6O5+Na<}rWa9(?`xyp^#`wHY2?}n za2XR0u%_(aQ%U`1-IE_6q)(+X-^F-kYd;;FPBJwSungc=a#VGfcNvA^>5?6whe}#< ztO%YuyIgGocq_mwbm89-uRfUpG=SesM5qht z!;!yealBenyHN1*X^`ZCkkdet3X&C&6!TKg0B@w_tv{LZU){=5W_n;%#(;7tvm3+b z^}w2u`O~pDQj^;#hrpo_!l4_d01^(6q(aWfdliKH!B_|&6QC}T{st{?HU0Sbsww>B z!Tz)T>QG020nY@G0j9&k8F(q4*3=>n_MS2{aMk{5`GRbO*UO@(V0bo%LRWWJreBD! uNZDb|99}Q!0DiHexdr!u2_~4pPW}a#P==mUQ_`;h0000= 0 && angle < 90) { + if (angle == 2) { + clearInterval(); + g.setFontAlign(-1, -1); + g.drawString("<<", 220, 40); + status = 7; + timeout = setTimeout(function () { + interval = restart_interval(); + }, settings.inhale_pause * 1000); + } + direction = 0; + } + else { + if (angle == 90) + angle = -90; + if (angle == -90) { + clearInterval(); + g.setFontAlign(-1, -1); + g.drawString("<<", 220, 40); + status = 7; + timeout = setTimeout(function () { + interval = restart_interval(); + }, settings.exhale_pause * 1000); + } + direction = 1; + } + g.drawString(display_HR, 20, 200); + + g.flip(); + + if (settings.vibrate == "forward") + Bangle.buzz(50, Math.abs(origin)/1.5); + else if (settings.vibrate == "backward") + Bangle.buzz(50, (1.6 - (Math.abs(origin)))); +} + +function restart_interval() { + status = 6; + var calc = 5 - settings.period; + calc *= 15; + calc += 120; + if(direction == 1 && settings.ex_in_ration == "5:6"){ + calc -= calc*0.2; + } + interval = setInterval(circle, calc); +} + +function update_menu() { + g.clear(); + g.setColor(settings.colour[0]); + g.setFontAlign(-1, -1); + g.drawString("+/-", 200, 200); + g.drawString("<>", 220, 40); + g.drawString("GO", 210, 120); + g.setFontAlign(-1, -1); + var cursor = 60; + + while (cursor < 180) { + var key = Object.keys(settings)[(cursor - 60) / 20]; + var value = settings[key]; + + if (status == ((cursor - 60) / 20)) { + g.setColor(colours.white[0]); + } + else + g.setColor(settings.colour[0]); + + var display_txt = selection[(cursor - 60) / 20] + ": " + value; + + if(((cursor - 60) / 20) == 3) + display_txt = selection[(cursor - 60) / 20] + ": " + value[1]; + + g.drawString(display_txt, 10, cursor); + cursor += 20; + } +} + +function btn1Pressed() { + if (status < 6) { + status += 1; + if (status == 6) + status = 0; + + update_menu(); + } + else if (status == 7) { + clearTimeout(timeout); + clearInterval(); + status = 0; + update_menu(); + } +} + +function btn2Pressed() { + if (status < 6) { + settings_file = require("Storage").open("breather_settings.txt", "w"); + settings_file.write(JSON.stringify(settings)); + Bangle.setHRMPower(1); + g.setColor(settings.colour[0]); + restart_interval(); + } +} + +function btn3Pressed() { + if (status < 6) { + if (status == 0) { + settings.period += 1; + if (settings.period > 6) + settings.period = 1; + } + else if (status == 1) { + settings.exhale_pause += 1; + if (settings.exhale_pause > 4) + settings.exhale_pause = 1; + } + else if (status == 2) { + settings.inhale_pause += 1; + if (settings.inhale_pause > 4) + settings.inhale_pause = 1; + } + else if (status == 3) { + if (settings.colour[0] == colours.green[0]) { + settings.colour = colours.blue; + } + else if (settings.colour[0] == colours.blue[0]) + settings.colour = colours.red; + else if (settings.colour[0] == colours.red[0]) + settings.colour = colours.yellow; + else if (settings.colour[0] == colours.yellow[0]) + settings.colour = colours.green; + } + else if (status == 4) { + if (settings.vibrate == "forward") + settings.vibrate = "backward"; + else if (settings.vibrate == "backward") + settings.vibrate = "off"; + else if (settings.vibrate == "off") + settings.vibrate = "forward"; + } + else if(status == 5){ + if(settings.ex_in_ratio == "1:1") + settings.ex_in_ratio = "5:6"; + else + settings.ex_in_ratio = "1:1"; + } + update_menu(); + } +} + +update_menu(); + +setWatch(btn1Pressed, BTN1, { repeat: true }); +setWatch(btn2Pressed, BTN2, { repeat: true }); +setWatch(btn3Pressed, BTN3, { repeat: true }); + +Bangle.on('HRM', function (hrm) { + if (first_signal) + first_signal = false; + else{ + var signal = hrm.bpm; + if(signal > 50 && signal < 180) + display_HR = signal; + } +}); \ No newline at end of file diff --git a/apps/breath/breather_settings.txt b/apps/breath/breather_settings.txt new file mode 100644 index 000000000..1a717ddc9 --- /dev/null +++ b/apps/breath/breather_settings.txt @@ -0,0 +1 @@ +{"period":3,"exhale_pause":1,"inhale_pause":2,"colour":["#00abff","blue"],"vibrate":"forward"} \ No newline at end of file