From f221e2f8a4e52f0d14e7d59ceddf65785195129a Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Sat, 19 Jun 2021 08:22:20 +0100 Subject: [PATCH] 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 --- wasp/drivers/battery.py | 2 ++ wasp/drivers/nrf_rtc.py | 9 +++++---- wasp/drivers/touch.py | 2 ++ 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.