diff options
Diffstat (limited to 'wasp/boards/simulator/watch.py')
| -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() |
