diff --git a/apps.json b/apps.json index 3afbebdc6..d447aa18c 100644 --- a/apps.json +++ b/apps.json @@ -1958,5 +1958,21 @@ {"name":"miclock2.app.js","url":"clock-mixed.js"}, {"name":"miclock2.img","url":"clock-mixed-icon.js","evaluate":true} ] + }, + { "id": "1button", + "name": "One-Button-Tracker", + "icon": "widget.png", + "version":"0.01", + "interface": "interface.html", + "description": "A widget that turns BTN1 into a tracker, records time of button press/release.", + "tags": "tool,quantifiedself,widget", + "type": "widget", + "readme": "README.md", + "storage": [ + {"name":"1button.wid.js","url":"widget.js"} + ], + "data": [ + {"name":"one_button_presses.csv","storageFile": true} + ] } ] diff --git a/apps/1button/ChangeLog b/apps/1button/ChangeLog new file mode 100644 index 000000000..4c21f3ace --- /dev/null +++ b/apps/1button/ChangeLog @@ -0,0 +1 @@ +0.01: New Widget! diff --git a/apps/1button/README.md b/apps/1button/README.md new file mode 100644 index 000000000..13a2724c0 --- /dev/null +++ b/apps/1button/README.md @@ -0,0 +1,31 @@ +# The One Button tracker + +A simple widget that turns the `BTN1` of your Bangle.js into a one-button-tracker that can be used right from the clock face and everywhere else. Record when you're sneezing, yawning, eating, or whatever you think the button should track for you. + + + +## Usage + +Every time you press & release the `BTN1` from the clockface this widget will record the time you pressed & released. While you press the button the Bangle will briefly vibrate and the green LED in the display will light up while you're keeping the button pressed. + +Once you release `BTN1` both the start & end time of your button press will be saved in 2-column `one_button_presses.csv` CSV file on your _Bangle.js_. The CSV file can [be downloaded from the _My Apps_ tab on the Bangle.js app store](https://banglejs.com/apps/). + +To not interfere with alternative usages of `BTN1` (eg when using it for menu navigation) you need to keep the button pressed for at least 130 milliseconds before it triggers a recording (the vibration & LED will inform you about having triggered it). + +## Features + +- Track whatever events you want with a simple button press on your wrist +- Track multiple things with a single button by using different length of button presses +- Easily export the data to visualize your presses in a tool of your choice + +## Controls + +Only makes use of `BTN1` (the top one) right now. + +## Requests + +[Reach out to Bastian](https://www.github.com/gedankenstuecke) if you have feature requests or notice bugs. + +## Creator + +Made by [Bastian Greshake Tzovaras](https://tzovar.as), inspired by the one-button tracker project by Thomas Blomseth Christiansen and Jakob Eg Larsen. diff --git a/apps/1button/interface.html b/apps/1button/interface.html new file mode 100644 index 000000000..04c7dfdb9 --- /dev/null +++ b/apps/1button/interface.html @@ -0,0 +1,84 @@ + +
+ + + + + + + + + diff --git a/apps/1button/one-button.GIF b/apps/1button/one-button.GIF new file mode 100644 index 000000000..a6adfdb8a Binary files /dev/null and b/apps/1button/one-button.GIF differ diff --git a/apps/1button/widget.js b/apps/1button/widget.js new file mode 100644 index 000000000..cce099309 --- /dev/null +++ b/apps/1button/widget.js @@ -0,0 +1,36 @@ +(() => { + var press_time = new Date(); + + // set widget text + function draw() { + g.reset(); // reset the graphics context to defaults (color/font/etc) + // add your code + g.fillCircle(this.x+6,this.y+6,4); + g.drawString("1BUTTON", this.x+13, this.y+4); + } + + // listen to button press to get start time + setWatch(function(e) { + console.log("Button pressed"); + digitalWrite(LED2,1); + press_time = new Date(); + Bangle.buzz(); + }, BTN1, { repeat: true, edge: 'rising', debounce: 130 }); + + // listen to button go to get end time & write data + setWatch(function(e) { + console.log("Button let go"); + digitalWrite(LED2,0); + var unpress_time = new Date(); + recFile = require("Storage").open("one_button_presses.csv","a"); + recFile.write([press_time.getTime(),unpress_time.getTime()].join(",")+"\n"); + }, BTN1, { repeat: true, edge: 'falling', debounce: 50 }); + + + // add your widget + WIDGETS["1button"]={ + area:"tl", // tl (top left), tr (top right), bl (bottom left), br (bottom right) + width: 100, // how wide is the widget? You can change this and call Bangle.drawWidgets() to re-layout + draw:draw // called to draw the widget + }; +})() diff --git a/apps/1button/widget.png b/apps/1button/widget.png new file mode 100644 index 000000000..6a827c392 Binary files /dev/null and b/apps/1button/widget.png differ