Skip to content

Commit 685fc33

Browse files
author
Brandon Nolet
committed
Implement pedometer tap to reset
**This commit relies on the PR wasp-os/bma42x-upy#1 * Implement touch action in pedometer app * Impelement more efficient step counter reset
1 parent 8824646 commit 685fc33

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

wasp/apps/steps.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ def _reset(self):
7878
self._wake += 24 * 60 * 60
7979
wasp.system.set_alarm(self._wake, self._reset)
8080

81+
def touch(self, event):
82+
draw = wasp.watch.drawable
83+
draw.fill(0x0000,60,112,180,40)
84+
watch.accel.steps = 0
85+
86+
self._update()
87+
8188
def tick(self, ticks):
8289
self._count += 686;
8390
self._update()

wasp/drivers/bma421.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ def steps(self):
4848
def steps(self, value):
4949
if value != 0:
5050
raise ValueError()
51-
# TODO: There is a more efficient way to reset the step counter
52-
# but I haven't looked it up yet!
53-
self.reset()
51+
# TODO once bma42x.py and the library it relies
52+
# on are modified to correctly implement
53+
# reset_step_counter, remove this useless param
54+
self._dev.reset_step_counter(1)
55+
time.sleep(0.05)

0 commit comments

Comments
 (0)