From 223668faa069bd3eb8a0500183e8c11ff657073b Mon Sep 17 00:00:00 2001 From: Bastian Greshake Tzovaras Date: Wed, 17 Jun 2020 12:07:47 +0200 Subject: [PATCH] first add of 1button --- apps.json | 16 ++++++ apps/1button/ChangeLog | 1 + apps/1button/README.md | 25 +++++++++ apps/1button/interface.html | 107 ++++++++++++++++++++++++++++++++++++ apps/1button/widget.js | 36 ++++++++++++ apps/1button/widget.png | Bin 0 -> 4433 bytes 6 files changed, 185 insertions(+) create mode 100644 apps/1button/ChangeLog create mode 100644 apps/1button/README.md create mode 100644 apps/1button/interface.html create mode 100644 apps/1button/widget.js create mode 100644 apps/1button/widget.png 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 0000000000000000000000000000000000000000..6a827c392eb485bfb870d1cdbb06dbb26bba9f5a GIT binary patch literal 4433 zcmY*dXE+>Mw;tUf(R+l9UWbUzBpAI#?>)NFLm1^m5F*igl!y|djuPF7=ruA*5Js?|z=O_gZVe>wVYSKX=SiZIwGDOe6pR;EtLqRPXi_{$s?1x4SX!`Rm&Q z$5&590Z=(|Z}T<)da0WF0sy4ce+&nZmCbMqFm*97@iWoVl(zST3E4jLv~v)80rR>= z0|2rwq;FlAgP$$i3z)lyuk;H!(BBB@TmMfQ3}X8m;^!s@GSPa%l)e(3;rYif13Gc(!aB}qe4hz z!T)_W2#IDVw%>%VJH&2EknQ)ck^oVHPMDVMP}m0=dYv{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