summaryrefslogtreecommitdiff
path: root/wasp/boards
diff options
context:
space:
mode:
Diffstat (limited to 'wasp/boards')
-rw-r--r--wasp/boards/pinetime/manifest.py2
-rw-r--r--wasp/boards/pinetime/watch.py.in2
-rw-r--r--wasp/boards/simulator/watch.py23
3 files changed, 27 insertions, 0 deletions
diff --git a/wasp/boards/pinetime/manifest.py b/wasp/boards/pinetime/manifest.py
index f7cb9d9..61cc24a 100644
--- a/wasp/boards/pinetime/manifest.py
+++ b/wasp/boards/pinetime/manifest.py
@@ -9,10 +9,12 @@ freeze('../..',
'apps/launcher.py',
'apps/pager.py',
'apps/settings.py',
+ 'apps/steps.py',
'apps/stopwatch.py',
'apps/testapp.py',
'boot.py',
'draw565.py',
+ 'drivers/bma421.py',
'drivers/battery.py',
'drivers/cst816s.py',
'drivers/nrf_rtc.py',
diff --git a/wasp/boards/pinetime/watch.py.in b/wasp/boards/pinetime/watch.py.in
index 46fc6f6..d064d8f 100644
--- a/wasp/boards/pinetime/watch.py.in
+++ b/wasp/boards/pinetime/watch.py.in
@@ -18,6 +18,7 @@ from machine import Pin
from machine import SPI
from drivers.battery import Battery
+from drivers.bma421 import BMA421
from drivers.cst816s import CST816S
from drivers.signal import Signal
from drivers.st7789 import ST7789_SPI
@@ -65,6 +66,7 @@ battery = Battery(
Signal(Pin('USB_PWR', Pin.IN), invert=True))
button = Pin('BUTTON', Pin.IN)
i2c = I2C(1, scl='I2C_SCL', sda='I2C_SDA')
+accel = BMA421(i2c)
touch = CST816S(i2c)
vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True)
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()