summaryrefslogtreecommitdiff
path: root/wasp/apps
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2021-05-05 20:06:39 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2021-05-05 20:06:39 (GMT)
commit92812e5ad255452535c0d95e4427df443d2ec134 (patch)
tree68eaae5d014b118b1cd97cea992866af66e1ff81 /wasp/apps
parent3bbd808115d99e2738135cb1acbfc5bd14380f9d (diff)
apps: heart: Implement a debug mode to copy out raw data
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/apps')
-rw-r--r--wasp/apps/heart.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/wasp/apps/heart.py b/wasp/apps/heart.py
index 541e57d..5d181b0 100644
--- a/wasp/apps/heart.py
+++ b/wasp/apps/heart.py
@@ -8,6 +8,28 @@ A graphing heart rate monitor using a PPG sensor.
.. figure:: res/HeartApp.png
:width: 179
+
+This program also implements some (entirely optional) debug features to
+store the raw heart data to the filesystem so that the samples can be used
+to further refine the heart rate detection algorithm.
+
+To enable the logging feature select the heart rate application using the
+watch UI and then run the following command via wasptool:
+
+.. code-block:: sh
+
+ ./tools/wasptool --eval 'wasp.system.app.debug = True'
+
+Once debug has been enabled then the watch will automatically log heart
+rate data whenever the heart rate application is running (and only
+when it is running). Setting the debug flag to False will disable the
+logging when the heart rate monitor next exits.
+
+Finally to download the logs for analysis try:
+
+.. code-block:: sh
+
+ ./tools/wasptool --pull hrs.data
"""
import wasp
@@ -18,6 +40,10 @@ class HeartApp():
"""Heart rate monitor application."""
NAME = 'Heart'
+ def __init__(self):
+ self._debug = False
+ self._hrdata = None
+
def foreground(self):
"""Activate the application."""
wasp.watch.hrs.enable()
@@ -32,11 +58,13 @@ class HeartApp():
wasp.system.request_tick(1000 // 8)
self._hrdata = ppg.PPG(wasp.watch.hrs.read_hrs())
+ if self._debug:
+ self._hrdata.enable_debug()
self._x = 0
def background(self):
wasp.watch.hrs.disable()
- del self._hrdata
+ self._hrdata = None
def _subtick(self, ticks):
"""Notify the application that its periodic tick is due."""
@@ -87,3 +115,13 @@ class HeartApp():
t.stop()
del t
+
+ @property
+ def debug(self):
+ return self._debug
+
+ @debug.setter
+ def debug(self, value):
+ self._debug = value
+ if value and self._hrdata:
+ self._hrdata.enable_debug()