summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2021-06-19 07:22:20 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2021-06-19 07:22:20 (GMT)
commitf221e2f8a4e52f0d14e7d59ceddf65785195129a (patch)
tree03ff97f097f40ae0f20b4eac2cb686aa791f1300
parent33ff7dc91e33f503f9855e01b4255fe43b548516 (diff)
rtc: Undo the once-per-second wake up
So... waking up once per second turns out to be a dumb idea because it regresses the stop watch and HRS tools (which now also only wake up once per second). Undo this change but sprinkle a few more micropython.native decorations on methods used on the wakeup path to minimise power. Fixes: fb18705b9b9cc ("manager/rtc: Experimental power saving technique") Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
-rw-r--r--wasp/drivers/battery.py2
-rw-r--r--wasp/drivers/nrf_rtc.py9
-rw-r--r--wasp/drivers/touch.py2
3 files changed, 9 insertions, 4 deletions
diff --git a/wasp/drivers/battery.py b/wasp/drivers/battery.py
index 5bf06cd..e866920 100644
--- a/wasp/drivers/battery.py
+++ b/wasp/drivers/battery.py
@@ -4,6 +4,7 @@
"""Generic lithium ion battery driver
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""
+import micropython
from machine import Pin, ADC
class Battery(object):
@@ -26,6 +27,7 @@ class Battery(object):
self._charging = charging
self._power = power
+ @micropython.native
def charging(self):
"""Get the charging state of the battery.
diff --git a/wasp/drivers/nrf_rtc.py b/wasp/drivers/nrf_rtc.py
index 38263c8..274bbad 100644
--- a/wasp/drivers/nrf_rtc.py
+++ b/wasp/drivers/nrf_rtc.py
@@ -62,11 +62,11 @@ class RTC(object):
self.lastcount += split
self.lastcount &= (1 << 24) - 1
uptime = self._uptime
- self._uptime += split
- machine.mem32[0x200039c8] = self._uptime * 125
+ uptime += split
+ machine.mem32[0x200039c8] = uptime * 125
+ self._uptime = uptime
- # Has the seconds count changed
- return bool((self._uptime ^ uptime) & 0x08)
+ return True
def set_localtime(self, t):
"""Set the current wall time.
@@ -117,6 +117,7 @@ class RTC(object):
"""Provide the current uptime in seconds."""
return self._uptime // 8
+ @micropython.native
def get_uptime_ms(self):
"""Return the current uptime in milliseconds."""
return self._uptime * 125
diff --git a/wasp/drivers/touch.py b/wasp/drivers/touch.py
index ec97e3d..624cf0e 100644
--- a/wasp/drivers/touch.py
+++ b/wasp/drivers/touch.py
@@ -6,6 +6,7 @@
"""
import array
+import micropython
import time
from machine import Pin
from watch import rtc
@@ -45,6 +46,7 @@ class TouchButton:
if self.schedule:
self.schedule(self)
+ @micropython.native
def get_event(self):
"""Receive a touch event.