diff --git a/apps/homeassistant/ChangeLog b/apps/ha/ChangeLog similarity index 100% rename from apps/homeassistant/ChangeLog rename to apps/ha/ChangeLog diff --git a/apps/ha/README.md b/apps/ha/README.md new file mode 100644 index 000000000..520d562d8 --- /dev/null +++ b/apps/ha/README.md @@ -0,0 +1,8 @@ +# Home Assistant + + +## Creator +- [David Peer](https://github.com/peerdavid). + +## Thanks To +Info icons created by Freepik - Flaticon diff --git a/apps/ha/ha.app.js b/apps/ha/ha.app.js new file mode 100644 index 000000000..f919d3797 --- /dev/null +++ b/apps/ha/ha.app.js @@ -0,0 +1,59 @@ +var W = g.getWidth(), H = g.getHeight(); +var position=0; +var response="..."; + +function draw() { + g.reset().clearRect(Bangle.appRect); + + // Header + g.setFont("Vector", 32).setFontAlign(0,0); + var text = ""; + if(position == 0){ + text = "Door"; + } else if(position == 1){ + text = "Light"; + } + + g.drawString(text, W/2, H/3); + g.setFont("Vector", 24); + g.drawString(response, W/2, H/3+34); +} + + +draw(); +setWatch(_=>load(), BTN1); + +Bangle.on('touch', function(btn, e){ + var left = parseInt(g.getWidth() * 0.3); + var right = g.getWidth() - left; + var isLeft = e.x < left; + var isRight = e.x > right; + + if(isRight){ + position += 1; + position = position > 1 ? 0 : position; + draw(); + } + + if(isLeft){ + position -= 1; + position = position < 0 ? 1 : position; + draw(); + } + + if(!isRight && !isLeft){ + Bangle.buzz(40, 0.6); + + // Trigger HA bridge + response = "sending..."; + draw(); + + var url = "https://www.google.com/"; + response = Bluetooth.println(JSON.stringify({t:"http", url:url})); + } + + draw(); +}); + +Bangle.loadWidgets(); +Bangle.drawWidgets(); \ No newline at end of file diff --git a/apps/homeassistant/homeassistant.icon.js b/apps/ha/ha.icon.js similarity index 100% rename from apps/homeassistant/homeassistant.icon.js rename to apps/ha/ha.icon.js diff --git a/apps/homeassistant/homeassistant.png b/apps/ha/ha.png similarity index 100% rename from apps/homeassistant/homeassistant.png rename to apps/ha/ha.png diff --git a/apps/homeassistant/metadata.json b/apps/ha/metadata.json similarity index 64% rename from apps/homeassistant/metadata.json rename to apps/ha/metadata.json index 4b17722f9..d112fa297 100644 --- a/apps/homeassistant/metadata.json +++ b/apps/ha/metadata.json @@ -1,9 +1,9 @@ { - "id": "homeassistant", + "id": "ha", "name": "HomeAssistant", "version": "0.01", "description": "An application that displays information such as battery level, steps etc.", - "icon": "homeassistant.png", + "icon": "ha.png", "type": "app", "tags": "tool", "readme": "README.md", @@ -13,7 +13,7 @@ {"url":"screenshot_2.png"}, {"url":"screenshot_3.png"}], "storage": [ - {"name":"homeassistant.app.js","url":"homeassistant.app.js"}, - {"name":"homeassistant.img","url":"homeassistant.icon.js","evaluate":true} + {"name":"ha.app.js","url":"ha.app.js"}, + {"name":"ha.img","url":"ha.icon.js","evaluate":true} ] } diff --git a/apps/homeassistant/screenshot_1.png b/apps/ha/screenshot_1.png similarity index 100% rename from apps/homeassistant/screenshot_1.png rename to apps/ha/screenshot_1.png diff --git a/apps/homeassistant/screenshot_2.png b/apps/ha/screenshot_2.png similarity index 100% rename from apps/homeassistant/screenshot_2.png rename to apps/ha/screenshot_2.png diff --git a/apps/homeassistant/screenshot_3.png b/apps/ha/screenshot_3.png similarity index 100% rename from apps/homeassistant/screenshot_3.png rename to apps/ha/screenshot_3.png diff --git a/apps/homeassistant/README.md b/apps/homeassistant/README.md deleted file mode 100644 index 6466febe3..000000000 --- a/apps/homeassistant/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Info - -A very simple app that shows information on 3 different screens. -Go to the next screen via tab right, go to the previous screen -via tab left and reload the data via tab in the middle of the -screen. Very useful if combined with pattern launcher ;) - -![](screenshot_1.png) -![](screenshot_2.png) -![](screenshot_3.png) - - -## Creator -- [David Peer](https://github.com/peerdavid). - -## Thanks To -Info icons created by Freepik - Flaticon diff --git a/apps/homeassistant/homeassistant.app.js b/apps/homeassistant/homeassistant.app.js deleted file mode 100644 index e0a59547c..000000000 --- a/apps/homeassistant/homeassistant.app.js +++ /dev/null @@ -1,34 +0,0 @@ -var W = g.getWidth(), H = g.getHeight(); - - -function draw() { - g.reset().clearRect(Bangle.appRect); - - // Header - g.setFont("Vector", 22).setFontAlign(0,-1); - g.drawString("", W/2, H/2); -} - - -draw(); -setWatch(_=>load(), BTN1); - -Bangle.on('touch', function(btn, e){ - var left = parseInt(g.getWidth() * 0.3); - var right = g.getWidth() - left; - var isLeft = e.x < left; - var isRight = e.x > right; - - if(isRight){ - - } - - if(isLeft){ - - } - - draw(); -}); - -Bangle.loadWidgets(); -Bangle.drawWidgets(); \ No newline at end of file