summaryrefslogtreecommitdiff
path: root/wasp/boards/pinetime/watch.py.in
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-06-30 22:04:01 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-06-30 22:04:01 (GMT)
commitae5743529f82d398876456b7e175defb19a6ccfc (patch)
treeabaebb87754a952a15d7b062d36bfd9b668794e3 /wasp/boards/pinetime/watch.py.in
parent11be7ca3280134cf4e565198f87c316179cf2dc9 (diff)
wasp: Switch to scheduling from interrupt
This has two useful properties. Firstly it means the watch will be maintained in the background, allowing the REPL to be used for notifications and other updates. Secondly it will save a little bit of power by reducing the work needed to handle spurious wake ups. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/boards/pinetime/watch.py.in')
-rw-r--r--wasp/boards/pinetime/watch.py.in12
1 files changed, 10 insertions, 2 deletions
diff --git a/wasp/boards/pinetime/watch.py.in b/wasp/boards/pinetime/watch.py.in
index d98c99d..aaed767 100644
--- a/wasp/boards/pinetime/watch.py.in
+++ b/wasp/boards/pinetime/watch.py.in
@@ -1,10 +1,16 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (C) 2020 Daniel Thompson
+def nop():
+ pass
+schedule = nop
+def _callback(obj):
+ schedule()
+
# Start measuring time (and feeding the watchdog) before *anything* else
from machine import RTCounter
from drivers.nrf_rtc import RTC
-rtc = RTC(RTCounter(1, mode=RTCounter.PERIODIC))
+rtc = RTC(RTCounter(1, mode=RTCounter.PERIODIC, period=1, callback=_callback))
rtc.counter.start()
import os
@@ -83,7 +89,9 @@ try:
i2c = I2C(1, scl='I2C_SCL', sda='I2C_SDA')
accel = BMA421(i2c)
hrs = HRS3300(i2c)
- touch = CST816S(i2c, Pin('TP_INT', Pin.IN), Pin('TP_RST', Pin.OUT, value=0))
+ touch = CST816S(i2c,
+ Pin('TP_INT', Pin.IN), Pin('TP_RST', Pin.OUT, value=0),
+ _callback)
vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True)
# Release flash from deep power-down