diff options
-rw-r--r-- | app/index.js | 36 | ||||
-rw-r--r-- | package.json | 4 | ||||
-rw-r--r-- | resources/icons/stat_hr_solid_24px.png | bin | 0 -> 351 bytes | |||
-rw-r--r-- | resources/index.gui | 12 | ||||
-rw-r--r-- | resources/quantifier/0.png (renamed from resources/dates/0.png) | bin | 506 -> 506 bytes | |||
-rw-r--r-- | resources/quantifier/1.png (renamed from resources/dates/1.png) | bin | 2008 -> 2008 bytes | |||
-rw-r--r-- | resources/quantifier/2.png (renamed from resources/dates/2.png) | bin | 456 -> 456 bytes | |||
-rw-r--r-- | resources/quantifier/3.png (renamed from resources/dates/3.png) | bin | 418 -> 418 bytes | |||
-rw-r--r-- | resources/quantifier/4.png (renamed from resources/dates/4.png) | bin | 291 -> 291 bytes | |||
-rw-r--r-- | resources/quantifier/5.png (renamed from resources/dates/5.png) | bin | 391 -> 391 bytes | |||
-rw-r--r-- | resources/quantifier/6.png (renamed from resources/dates/6.png) | bin | 531 -> 531 bytes | |||
-rw-r--r-- | resources/quantifier/7.png (renamed from resources/dates/7.png) | bin | 215 -> 215 bytes | |||
-rw-r--r-- | resources/quantifier/8.png (renamed from resources/dates/8.png) | bin | 523 -> 523 bytes | |||
-rw-r--r-- | resources/quantifier/9.png (renamed from resources/dates/9.png) | bin | 537 -> 537 bytes | |||
-rw-r--r-- | resources/quantifier/fri.png (renamed from resources/dates/fri.png) | bin | 3547 -> 3547 bytes | |||
-rw-r--r-- | resources/quantifier/mon.png (renamed from resources/dates/mon.png) | bin | 755 -> 755 bytes | |||
-rw-r--r-- | resources/quantifier/sat.png (renamed from resources/dates/sat.png) | bin | 4152 -> 4152 bytes | |||
-rw-r--r-- | resources/quantifier/sun.png (renamed from resources/dates/sun.png) | bin | 4386 -> 4386 bytes | |||
-rw-r--r-- | resources/quantifier/thu.png (renamed from resources/dates/thu.png) | bin | 2905 -> 2905 bytes | |||
-rw-r--r-- | resources/quantifier/tue.png (renamed from resources/dates/tue.png) | bin | 3665 -> 3665 bytes | |||
-rw-r--r-- | resources/quantifier/wed.png (renamed from resources/dates/wed.png) | bin | 815 -> 815 bytes |
21 files changed, 46 insertions, 6 deletions
diff --git a/app/index.js b/app/index.js index 6c8d4cc..cc64479 100644 --- a/app/index.js +++ b/app/index.js @@ -5,6 +5,8 @@ import * as fs from "fs"; import * as messaging from "messaging"; import { preferences } from "user-settings"; import * as util from "./utils"; +import { HeartRateSensor } from "heart-rate"; +import { display } from "display"; // const SETTINGS_TYPE = "cbor"; // const SETTINGS_FILE = "settings.cbor"; @@ -23,6 +25,11 @@ let day = document.getElementById("day"); let date1 = document.getElementById("date1"); let date2 = document.getElementById("date2"); +// Heart Rate +let hr1 = document.getElementById("hr1"); +let hr2 = document.getElementById("hr2"); +let hr3 = document.getElementById("hr3"); + clock.granularity = "seconds"; clock.ontick = evt => { @@ -50,6 +57,21 @@ clock.ontick = evt => { setMins(minute); } +if (HeartRateSensor && me.permissions.granted("access_heart_rate")) { + let hrm = new HeartRateSensor({ frequency: 1 }); + hrm.addEventListener("reading", () => { + setHeartRate(hrm.heartRate); + }); + display.addEventListener("change", () => { + display.on ? hrm.start() : hrm.stop(); + }); + hrm.start(); +} else { + hr1.style.visibility = "hidden"; + hr2.style.visibility = "hidden"; + hr3.style.visibility = "hidden"; +} + // Apply theme colors to elements function applyTheme(background, foreground) { let items = document.getElementsByClassName("background"); @@ -87,17 +109,27 @@ function setDay(val) { day.image = getDayImg(val); } +function setHeartRate(val) { + drawDateDigit(val % 10, hr3); + val = Math.floor(val / 10); + + drawDateDigit(val % 10, hr2); + val = Math.floor(val / 10); + + drawDateDigit(val % 10, hr1); +} + function drawDigit(val, place) { place.image = `numerals/${val}.png`; } function drawDateDigit(val, place) { - place.image = `dates/${val}.png` + place.image = `quantifier/${val}.png` } function getDayImg(index) { let days = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]; - return `dates/${days[index]}.png`; + return `quantifier/${days[index]}.png`; } // Listen for the onmessage event diff --git a/package.json b/package.json index a319dc5..b7c3c18 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,9 @@ "appDisplayName": "CPU", "iconFile": "resources/icon.png", "wipeColor": "#8bc34a", - "requestedPermissions": [], + "requestedPermissions": [ + "access_heart_rate" + ], "buildTargets": [ "meson", "gemini" diff --git a/resources/icons/stat_hr_solid_24px.png b/resources/icons/stat_hr_solid_24px.png Binary files differnew file mode 100644 index 0000000..4b6a20f --- /dev/null +++ b/resources/icons/stat_hr_solid_24px.png diff --git a/resources/index.gui b/resources/index.gui index 5c83b1d..a54b30d 100644 --- a/resources/index.gui +++ b/resources/index.gui @@ -1,7 +1,7 @@ <svg class="background"> - <image id="day" href="dates/mon.png" x="60" y="50" width="110" height="35" fill="#FFFFFF" class="foreground" /> - <image id="date1" href="dates/3.png" x="180" y="50" width="30" height="35" fill="#FFFFFF" class="foreground" /> - <image id="date2" href="dates/0.png" x="210" y="50" width="30" height="35" fill="#FFFFFF" class="foreground" /> + <image id="day" href="quantifier/mon.png" x="60" y="50" width="110" height="35" fill="#FFFFFF" class="foreground" /> + <image id="date1" href="quantifier/3.png" x="180" y="50" width="30" height="35" fill="#FFFFFF" class="foreground" /> + <image id="date2" href="quantifier/0.png" x="210" y="50" width="30" height="35" fill="#FFFFFF" class="foreground" /> <svg> <image id="separator" href="numerals/separator.png" x="143" y="110" width="13" height="104" fill="#FFFFFF" class="foreground" /> <image id="hours1" href="numerals/8.png" x="6" y="100" width="60" height="122" fill="#FFFFFF" class="foreground" /> @@ -9,4 +9,10 @@ <image id="mins1" href="numerals/8.png" x="167" y="100" width="60" height="122" fill="#FFFFFF" class="foreground" /> <image id="mins2" href="numerals/8.png" x="234" y="100" width="60" height="122" fill="#FFFFFF" class="foreground" /> </svg> + <svg x="6" y="237"> + <image id="hr-icon" href="icons/stat_hr_solid_24px.png" width="24" height="24" fill="#ffffff" class="foreground" /> + <image id="hr1" href="quantifier/0.png" x="$+3" width="19" height="21" fill="#ffffff" class="foreground" /> + <image id="hr2" href="quantifier/0.png" x="$+3" width="19" height="21" fill="#ffffff" class="foreground" /> + <image id="hr3" href="quantifier/0.png" x="$+3" width="19" height="21" fill="#ffffff" class="foreground" /> + </svg> </svg> diff --git a/resources/dates/0.png b/resources/quantifier/0.png Binary files differindex 519fa91..519fa91 100644 --- a/resources/dates/0.png +++ b/resources/quantifier/0.png diff --git a/resources/dates/1.png b/resources/quantifier/1.png Binary files differindex cd072cf..cd072cf 100644 --- a/resources/dates/1.png +++ b/resources/quantifier/1.png diff --git a/resources/dates/2.png b/resources/quantifier/2.png Binary files differindex 0dac9e1..0dac9e1 100644 --- a/resources/dates/2.png +++ b/resources/quantifier/2.png diff --git a/resources/dates/3.png b/resources/quantifier/3.png Binary files differindex 8440537..8440537 100644 --- a/resources/dates/3.png +++ b/resources/quantifier/3.png diff --git a/resources/dates/4.png b/resources/quantifier/4.png Binary files differindex 0968921..0968921 100644 --- a/resources/dates/4.png +++ b/resources/quantifier/4.png diff --git a/resources/dates/5.png b/resources/quantifier/5.png Binary files differindex d0bfe7d..d0bfe7d 100644 --- a/resources/dates/5.png +++ b/resources/quantifier/5.png diff --git a/resources/dates/6.png b/resources/quantifier/6.png Binary files differindex 413d6fe..413d6fe 100644 --- a/resources/dates/6.png +++ b/resources/quantifier/6.png diff --git a/resources/dates/7.png b/resources/quantifier/7.png Binary files differindex 7d0ec4d..7d0ec4d 100644 --- a/resources/dates/7.png +++ b/resources/quantifier/7.png diff --git a/resources/dates/8.png b/resources/quantifier/8.png Binary files differindex afc1f42..afc1f42 100644 --- a/resources/dates/8.png +++ b/resources/quantifier/8.png diff --git a/resources/dates/9.png b/resources/quantifier/9.png Binary files differindex d4f1aa1..d4f1aa1 100644 --- a/resources/dates/9.png +++ b/resources/quantifier/9.png diff --git a/resources/dates/fri.png b/resources/quantifier/fri.png Binary files differindex 72747ac..72747ac 100644 --- a/resources/dates/fri.png +++ b/resources/quantifier/fri.png diff --git a/resources/dates/mon.png b/resources/quantifier/mon.png Binary files differindex c86e423..c86e423 100644 --- a/resources/dates/mon.png +++ b/resources/quantifier/mon.png diff --git a/resources/dates/sat.png b/resources/quantifier/sat.png Binary files differindex 870d692..870d692 100644 --- a/resources/dates/sat.png +++ b/resources/quantifier/sat.png diff --git a/resources/dates/sun.png b/resources/quantifier/sun.png Binary files differindex 7981730..7981730 100644 --- a/resources/dates/sun.png +++ b/resources/quantifier/sun.png diff --git a/resources/dates/thu.png b/resources/quantifier/thu.png Binary files differindex 32bc6be..32bc6be 100644 --- a/resources/dates/thu.png +++ b/resources/quantifier/thu.png diff --git a/resources/dates/tue.png b/resources/quantifier/tue.png Binary files differindex f527d0f..f527d0f 100644 --- a/resources/dates/tue.png +++ b/resources/quantifier/tue.png diff --git a/resources/dates/wed.png b/resources/quantifier/wed.png Binary files differindex 2860182..2860182 100644 --- a/resources/dates/wed.png +++ b/resources/quantifier/wed.png |