aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/index.js36
-rw-r--r--package.json4
-rw-r--r--resources/icons/stat_hr_solid_24px.pngbin0 -> 351 bytes
-rw-r--r--resources/index.gui12
-rw-r--r--resources/quantifier/0.png (renamed from resources/dates/0.png)bin506 -> 506 bytes
-rw-r--r--resources/quantifier/1.png (renamed from resources/dates/1.png)bin2008 -> 2008 bytes
-rw-r--r--resources/quantifier/2.png (renamed from resources/dates/2.png)bin456 -> 456 bytes
-rw-r--r--resources/quantifier/3.png (renamed from resources/dates/3.png)bin418 -> 418 bytes
-rw-r--r--resources/quantifier/4.png (renamed from resources/dates/4.png)bin291 -> 291 bytes
-rw-r--r--resources/quantifier/5.png (renamed from resources/dates/5.png)bin391 -> 391 bytes
-rw-r--r--resources/quantifier/6.png (renamed from resources/dates/6.png)bin531 -> 531 bytes
-rw-r--r--resources/quantifier/7.png (renamed from resources/dates/7.png)bin215 -> 215 bytes
-rw-r--r--resources/quantifier/8.png (renamed from resources/dates/8.png)bin523 -> 523 bytes
-rw-r--r--resources/quantifier/9.png (renamed from resources/dates/9.png)bin537 -> 537 bytes
-rw-r--r--resources/quantifier/fri.png (renamed from resources/dates/fri.png)bin3547 -> 3547 bytes
-rw-r--r--resources/quantifier/mon.png (renamed from resources/dates/mon.png)bin755 -> 755 bytes
-rw-r--r--resources/quantifier/sat.png (renamed from resources/dates/sat.png)bin4152 -> 4152 bytes
-rw-r--r--resources/quantifier/sun.png (renamed from resources/dates/sun.png)bin4386 -> 4386 bytes
-rw-r--r--resources/quantifier/thu.png (renamed from resources/dates/thu.png)bin2905 -> 2905 bytes
-rw-r--r--resources/quantifier/tue.png (renamed from resources/dates/tue.png)bin3665 -> 3665 bytes
-rw-r--r--resources/quantifier/wed.png (renamed from resources/dates/wed.png)bin815 -> 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
new file mode 100644
index 0000000..4b6a20f
--- /dev/null
+++ b/resources/icons/stat_hr_solid_24px.png
Binary files differ
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
index 519fa91..519fa91 100644
--- a/resources/dates/0.png
+++ b/resources/quantifier/0.png
Binary files differ
diff --git a/resources/dates/1.png b/resources/quantifier/1.png
index cd072cf..cd072cf 100644
--- a/resources/dates/1.png
+++ b/resources/quantifier/1.png
Binary files differ
diff --git a/resources/dates/2.png b/resources/quantifier/2.png
index 0dac9e1..0dac9e1 100644
--- a/resources/dates/2.png
+++ b/resources/quantifier/2.png
Binary files differ
diff --git a/resources/dates/3.png b/resources/quantifier/3.png
index 8440537..8440537 100644
--- a/resources/dates/3.png
+++ b/resources/quantifier/3.png
Binary files differ
diff --git a/resources/dates/4.png b/resources/quantifier/4.png
index 0968921..0968921 100644
--- a/resources/dates/4.png
+++ b/resources/quantifier/4.png
Binary files differ
diff --git a/resources/dates/5.png b/resources/quantifier/5.png
index d0bfe7d..d0bfe7d 100644
--- a/resources/dates/5.png
+++ b/resources/quantifier/5.png
Binary files differ
diff --git a/resources/dates/6.png b/resources/quantifier/6.png
index 413d6fe..413d6fe 100644
--- a/resources/dates/6.png
+++ b/resources/quantifier/6.png
Binary files differ
diff --git a/resources/dates/7.png b/resources/quantifier/7.png
index 7d0ec4d..7d0ec4d 100644
--- a/resources/dates/7.png
+++ b/resources/quantifier/7.png
Binary files differ
diff --git a/resources/dates/8.png b/resources/quantifier/8.png
index afc1f42..afc1f42 100644
--- a/resources/dates/8.png
+++ b/resources/quantifier/8.png
Binary files differ
diff --git a/resources/dates/9.png b/resources/quantifier/9.png
index d4f1aa1..d4f1aa1 100644
--- a/resources/dates/9.png
+++ b/resources/quantifier/9.png
Binary files differ
diff --git a/resources/dates/fri.png b/resources/quantifier/fri.png
index 72747ac..72747ac 100644
--- a/resources/dates/fri.png
+++ b/resources/quantifier/fri.png
Binary files differ
diff --git a/resources/dates/mon.png b/resources/quantifier/mon.png
index c86e423..c86e423 100644
--- a/resources/dates/mon.png
+++ b/resources/quantifier/mon.png
Binary files differ
diff --git a/resources/dates/sat.png b/resources/quantifier/sat.png
index 870d692..870d692 100644
--- a/resources/dates/sat.png
+++ b/resources/quantifier/sat.png
Binary files differ
diff --git a/resources/dates/sun.png b/resources/quantifier/sun.png
index 7981730..7981730 100644
--- a/resources/dates/sun.png
+++ b/resources/quantifier/sun.png
Binary files differ
diff --git a/resources/dates/thu.png b/resources/quantifier/thu.png
index 32bc6be..32bc6be 100644
--- a/resources/dates/thu.png
+++ b/resources/quantifier/thu.png
Binary files differ
diff --git a/resources/dates/tue.png b/resources/quantifier/tue.png
index f527d0f..f527d0f 100644
--- a/resources/dates/tue.png
+++ b/resources/quantifier/tue.png
Binary files differ
diff --git a/resources/dates/wed.png b/resources/quantifier/wed.png
index 2860182..2860182 100644
--- a/resources/dates/wed.png
+++ b/resources/quantifier/wed.png
Binary files differ