diff --git a/apps/cassioWatch/app.js b/apps/cassioWatch/app.js index 6bbb9e823..3f5cfee40 100644 --- a/apps/cassioWatch/app.js +++ b/apps/cassioWatch/app.js @@ -4,8 +4,11 @@ require("Font6x12").add(Graphics); require("Font8x12").add(Graphics); require("Font7x11Numeric7Seg").add(Graphics); + +const TIMER_IDX = "cassioWatch"; + + function bigThenSmall(big, small, x, y) { - g.setFont("7x11Numeric7Seg", 2); g.drawString(big, x, y); x += g.stringWidth(big); g.setFont("8x12"); @@ -71,6 +74,7 @@ function drawClock() { } function drawBattery() { + g.setFont("7x11Numeric7Seg", 2); bigThenSmall(E.getBattery(), "%", 135, 21); } @@ -117,6 +121,59 @@ function getSteps() { return steps + "k"; } +function isAlarmEnabled(){ + try{ + var alarm = require('sched'); + var alarmObj = alarm.getAlarm(TIMER_IDX); + if(alarmObj===undefined || !alarmObj.on){ + return false; + } + + return true; + + } catch(ex){ } + return false; +} + +function getAlarmMinutes(){ + if(!isAlarmEnabled()){ + return -1; + } + + var alarm = require('sched'); + var alarmObj = alarm.getAlarm(TIMER_IDX); + return Math.round(alarm.getTimeToAlarm(alarmObj)/(60*1000)); +} + +function increaseAlarm(){ + try{ + var minutes = isAlarmEnabled() ? getAlarmMinutes() : 0; + var alarm = require('sched') + alarm.setAlarm(TIMER_IDX, { + timer : (minutes+5)*60*1000, + }); + alarm.reload(); + } catch(ex){ } +} + +function decreaseAlarm(){ + try{ + var minutes = getAlarmMinutes(); + minutes -= 5; + + var alarm = require('sched') + alarm.setAlarm(TIMER_IDX, undefined); + + if(minutes > 0){ + alarm.setAlarm(TIMER_IDX, { + timer : minutes*60*1000, + }); + } + + alarm.reload(); + } catch(ex){ } +} + function draw() { queueDraw(); @@ -128,10 +185,17 @@ function draw() { let background = getBackgroundImage(); g.drawImage(background, 0, 0, { scale: 1 }); g.setColor(0, 0, 0); - g.setFont("6x12"); - g.drawString("Launching Process", 30, 20); - g.setFont("8x12"); - g.drawString("ACTIVATE", 40, 35); + + if(!isAlarmEnabled()){ + g.setFont("6x12"); + g.drawString("Launching Process", 30, 20); + g.setFont("8x12"); + g.drawString("ACTIVATE", 40, 35); + } else { + g.setFont("8x12", 2); + // g.drawString("T-" + getAlarmMinutes()+ "min", 30, 23); + bigThenSmall("T-" + getAlarmMinutes(), " min.", 30, 23); + } g.setFontAlign(0,-1); g.setFont("8x12", 2); @@ -166,6 +230,32 @@ Bangle.on("lock", (locked) => { }); +Bangle.on('touch', function(btn, e){ + var left = parseInt(g.getWidth() * 0.2); + var right = g.getWidth() - left; + var upper = parseInt(g.getHeight() * 0.2); + var lower = g.getHeight() - upper; + + var is_left = e.x < left; + var is_right = e.x > right; + var is_upper = e.y < upper; + var is_lower = e.y > lower; + + if(is_upper){ + Bangle.buzz(40, 0.6); + increaseAlarm(); + draw(); + } + + if(is_lower){ + Bangle.buzz(40, 0.6); + decreaseAlarm(); + draw(); + } +}); + + + // Load widgets, but don't show them Bangle.loadWidgets(); Bangle.setUI("clock"); diff --git a/apps/homeassistant/ChangeLog b/apps/homeassistant/ChangeLog new file mode 100644 index 000000000..07afedd21 --- /dev/null +++ b/apps/homeassistant/ChangeLog @@ -0,0 +1 @@ +0.01: Release \ No newline at end of file diff --git a/apps/homeassistant/README.md b/apps/homeassistant/README.md new file mode 100644 index 000000000..6466febe3 --- /dev/null +++ b/apps/homeassistant/README.md @@ -0,0 +1,17 @@ +# 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 new file mode 100644 index 000000000..e0a59547c --- /dev/null +++ b/apps/homeassistant/homeassistant.app.js @@ -0,0 +1,34 @@ +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 diff --git a/apps/homeassistant/homeassistant.icon.js b/apps/homeassistant/homeassistant.icon.js new file mode 100644 index 000000000..8dbab8357 --- /dev/null +++ b/apps/homeassistant/homeassistant.icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwwcBkmSpICDBwcJBYwCDpAhFggRJGg8SCI+ABgU//gSDCI4JBj//AAX4JRAIBg4QDAAPgBIJWGgIQFAAI+BLglAgEPCI/wEgJoEgYQHAAPANwhWFAApcBCIWQgAQJAAMAgSMDCJiSCwB6GQA6eCn5TFL4q5BUgIRF/wuBv4RGkCeGO4IREUgMBCJCVGCISwIWw0BYRLIICLBHHCJRrGCIQIFR44I5LIoRaPpARcdIwRJfYMBCJuACKUkgE/a5f8gEJCJD7FCIeAg78FAAvggFJCIMACJZOBCIOQCJsCCIOSgEfCBP4gESCIZTFOIwRDoDIGaguSCIVIgCkFTwcAggRDpIYBQAx6BgAOCAQYIBLghWBTwQRFFgIABXIIFDBwgCDBYQAENAYCFLgIAEKwpKIIhA=")) diff --git a/apps/homeassistant/homeassistant.png b/apps/homeassistant/homeassistant.png new file mode 100644 index 000000000..c73813025 Binary files /dev/null and b/apps/homeassistant/homeassistant.png differ diff --git a/apps/homeassistant/metadata.json b/apps/homeassistant/metadata.json new file mode 100644 index 000000000..4b17722f9 --- /dev/null +++ b/apps/homeassistant/metadata.json @@ -0,0 +1,19 @@ +{ + "id": "homeassistant", + "name": "HomeAssistant", + "version": "0.01", + "description": "An application that displays information such as battery level, steps etc.", + "icon": "homeassistant.png", + "type": "app", + "tags": "tool", + "readme": "README.md", + "supports": ["BANGLEJS2"], + "screenshots": [ + {"url":"screenshot_1.png"}, + {"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} + ] +} diff --git a/apps/homeassistant/screenshot_1.png b/apps/homeassistant/screenshot_1.png new file mode 100644 index 000000000..97d42a896 Binary files /dev/null and b/apps/homeassistant/screenshot_1.png differ diff --git a/apps/homeassistant/screenshot_2.png b/apps/homeassistant/screenshot_2.png new file mode 100644 index 000000000..2d25dd4e6 Binary files /dev/null and b/apps/homeassistant/screenshot_2.png differ diff --git a/apps/homeassistant/screenshot_3.png b/apps/homeassistant/screenshot_3.png new file mode 100644 index 000000000..782e4a195 Binary files /dev/null and b/apps/homeassistant/screenshot_3.png differ