diff --git a/apps.json b/apps.json index 94c13ef9e..a228723cd 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..a909e9e7e --- /dev/null +++ b/apps/1button/README.md @@ -0,0 +1,25 @@ +# Widget Name + +Describe the app... + +Add screen shots (if possible) to the app folder and link then into this file with ![](.png) + +## Usage + +Describe how to use it + +## Features + +Name the function + +## Controls + +Name the buttons and what they are used for + +## Requests + +Name who should be contacted for support/update requests + +## Creator + +Your name diff --git a/apps/1button/interface.html b/apps/1button/interface.html new file mode 100644 index 000000000..42e8dcb1a --- /dev/null +++ b/apps/1button/interface.html @@ -0,0 +1,107 @@ + + + + + +
+ + + + + diff --git a/apps/1button/widget.js b/apps/1button/widget.js new file mode 100644 index 000000000..e0542137e --- /dev/null +++ b/apps/1button/widget.js @@ -0,0 +1,36 @@ +(() => { + var press_time = new Date(); + recFile = require("Storage").open("one_button_presses.csv","a"); + + // 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: 50 }); + + // 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.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