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: fb18705b9b ("manager/rtc: Experimental power saving technique")
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
Daniel Thompson 2021-06-19 08:22:20 +01:00
parent 33ff7dc91e
commit f221e2f8a4
3 changed files with 9 additions and 4 deletions

View file

@ -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.

View file

@ -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

View file

@ -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.