diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-06-09 20:29:00 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-06-09 20:31:55 (GMT) |
| commit | ccaf12750ba39fe0bc1fa6d2425ef2d1831ded9a (patch) | |
| tree | 4a34126a5afa06c1178527a9e9268396b17811db /wasp/boards/simulator | |
| parent | dea2ba8d65f03c6c203f58d5db4bfdccda6f7c25 (diff) | |
wasp: apps: Step counter application
Currently there's no fancy algorithms to estimate stride length. Just
pure simple step counting directly from the hardware's "intelligence
engine".
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/boards/simulator')
| -rw-r--r-- | wasp/boards/simulator/watch.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/wasp/boards/simulator/watch.py b/wasp/boards/simulator/watch.py index 178b1eb..b9de73d 100644 --- a/wasp/boards/simulator/watch.py +++ b/wasp/boards/simulator/watch.py @@ -22,6 +22,28 @@ from drivers.cst816s import CST816S from drivers.st7789 import ST7789_SPI from drivers.vibrator import Vibrator +class Accelerometer: + """Simulated accelerometer. + + Accelerometers such as BMA421 are complex and most of the driver + is written in C. For that reason we simulate the accelerometer + rather than emulate (by comparison we emulate the ST7789). + """ + def reset(self): + self._steps = 3 + + @property + def steps(self): + """Report the number of steps counted.""" + if self._steps < 10000: + self._steps = int(self._steps * 1.34) + else: + self._steps += 1 + return self._steps + + @steps.setter + def steps(self, value): + self.reset() class Backlight(object): def __init__(self, level=1): @@ -105,6 +127,7 @@ display = ST7789_SPI(240, 240, spi, res=Pin("DISP_RST", Pin.OUT, quiet=True)) drawable = draw565.Draw565(display) +accel = Accelerometer() battery = Battery() button = Pin('BUTTON', Pin.IN, quiet=True) rtc = RTC() |
