mirror of https://github.com/espruino/BangleApps
Merge pull request #2494 from trufae/inspire
Initial import of the inspire breathing apppull/2495/head
commit
3261e22150
|
@ -0,0 +1 @@
|
|||
0.01: First public version
|
|
@ -0,0 +1,17 @@
|
|||
# Inspire
|
||||
|
||||
A minimalistic app that will help you practive breathing.
|
||||
|
||||
Author: Written by pancake in 2022, powered by insomnia
|
||||
|
||||
## Features
|
||||
|
||||
* [x] Practice breathing 3 times
|
||||
* [x] Tap to start
|
||||
* [x] Subtle vibrations
|
||||
* [x] Drag to pause breathing
|
||||
* [ ] Automatic buzz every hour during day
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwxH+AH4ACxIAIFlgyjFp4xdEI9lsteAAQFBGLosHFYYAHGQ4uYFpgxKFyotQGJIuTr4uTAANfGCIREFqoADGB4ueGCAufGAouMXazDMF5VlDptlCIRBNCIQvHRp4aC2fX6+zIhxgJLxwuBFoQADGIIWNF4xeNVAOtFooAD1rWLMA5eNLg5iHMCJeMspdKMIhKLF4iOMIYIuNAAJ7KSAqOMRpqROSAovLdgIuPMATyIF5BBJLyBgCSBgvNLyRgCF/6Pwd95BKMCGzPpQvHCRZeQRxgvCYBgwB1ouN1ouJXwqQOSJyNKRwyQOeQRhK1rsJRxBgPI4RiGLgIWNFwxgODIgxCFoIuMLxJgQSgQyCsqKKLxhgFDpoAQawIvKSKAARFxgvEGDggEF5IwfFx4wGYay7EFxowGsouTsouTGAwxRFoouRGA4xNFowuTGJIyBGYgFBB44tVGJYALFrIxTFroyOFkQAfA"))
|
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
|
@ -0,0 +1,125 @@
|
|||
// inspire breathing app -- by pancake
|
||||
|
||||
var w = g.getWidth();
|
||||
var h = g.getHeight();
|
||||
var w2 = w/2;
|
||||
var h2 = h/ 2;
|
||||
var fs = 24;
|
||||
var tx = (w/3)-10;
|
||||
var ty = (h)-fs;
|
||||
var radius = (w/2)-6;
|
||||
var breathing = false;
|
||||
var count = 0;
|
||||
var mode = 0;
|
||||
var sin = 0;
|
||||
var dragged = 0;
|
||||
var lastTime = Date.now();
|
||||
function breath(t) {
|
||||
var r = Math.abs(Math.sin(t / 100)) * w2;
|
||||
g.fillCircle(w/2,h/2, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
// subtle vibration
|
||||
Bangle.buzz(100);
|
||||
setTimeout(()=>{Bangle.buzz(60);}, 500);
|
||||
|
||||
function showTouchScreen() {
|
||||
g.setColor(1,1,1);
|
||||
g.fillCircle (w2, h2, h2-5);
|
||||
g.setColor(0,0,0);
|
||||
g.setFont("Vector", 32);
|
||||
g.drawString("Tap to", w/6, h2-fs);
|
||||
g.drawString("breath", w/4, h2);
|
||||
}
|
||||
|
||||
g.setBgColor(0,0,0);
|
||||
g.setColor(0);
|
||||
g.clear();
|
||||
|
||||
function animateCircle() {
|
||||
g.clear();
|
||||
g.setColor(1,1,1);
|
||||
g.fillCircle (w2, h2, radius);
|
||||
radius-=2;
|
||||
if (radius < 40) {
|
||||
breathing = true;
|
||||
startBreathing();
|
||||
return;
|
||||
}
|
||||
setTimeout(animateCircle, 50);
|
||||
}
|
||||
|
||||
Bangle.on("drag", function(pos) {
|
||||
if (breathing) {
|
||||
dragged = 1;
|
||||
if (pos.dx == -pos.dy) {
|
||||
count += pos.dx;
|
||||
} else {
|
||||
count+=(pos.dx + pos.dy);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function main() {
|
||||
var started = false;
|
||||
function onTouch() {
|
||||
if (started) {
|
||||
return;
|
||||
}
|
||||
started = true;
|
||||
animateCircle();
|
||||
Bangle.buzz(40);
|
||||
}
|
||||
Bangle.on("touch", onTouch);
|
||||
showTouchScreen();
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
function startBreathing() {
|
||||
var cicles = 3;
|
||||
g.setFont("Vector", fs);
|
||||
|
||||
var interval = setInterval(function() {
|
||||
if (lastTime + 10 > Date.now()) {
|
||||
return;
|
||||
}
|
||||
lastTime = Date.now();
|
||||
g.setColor(0, 0, 0);
|
||||
g.clear();
|
||||
|
||||
g.setColor(0, 0.5, 1);
|
||||
var b = breath(count);
|
||||
g.setColor(0.5, 0.5, 1);
|
||||
var c = breath(count + 50);
|
||||
count++;
|
||||
g.setColor(1, 1, 1);
|
||||
if (b < c) {
|
||||
g.drawString("inspire",8,ty);
|
||||
if (mode) {
|
||||
mode = 0;
|
||||
Bangle.buzz(20);
|
||||
if (!dragged ) {
|
||||
cicles--;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
g.drawString("expire",8,ty);
|
||||
if (!mode) {
|
||||
mode = 1;
|
||||
Bangle.buzz(20);
|
||||
}
|
||||
}
|
||||
g.drawString(cicles, w-fs, ty);
|
||||
if (cicles < 1) {
|
||||
clearInterval(interval);
|
||||
g.clear();
|
||||
g.drawString("Thanks for",20,h/3);
|
||||
g.drawString(" breathing!",20,(h/3) + 16);
|
||||
Bangle.showClock();
|
||||
}
|
||||
dragged = 0;
|
||||
|
||||
}, 4);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"id": "inspire",
|
||||
"name": "Inspire Breathing",
|
||||
"shortName": "Inspire",
|
||||
"version": "0.01",
|
||||
"description": "exercise breathing every now and then",
|
||||
"icon": "app-icon.png",
|
||||
"tags": "tools,health",
|
||||
"screenshots": [{"url":"screenshot.png"}],
|
||||
"supports": ["BANGLEJS"],
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"inspire.app.js","url":"app.js"},
|
||||
{"name":"inspire.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Loading…
Reference in New Issue