1
0
Fork 0

system: Move free memory capture into the switch method

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
Daniel Thompson 2021-01-15 20:07:09 +00:00
parent 64d03fcc11
commit f4f7aac7fd

View file

@ -208,6 +208,8 @@ class Manager():
def switch(self, app): def switch(self, app):
"""Switch to the requested application. """Switch to the requested application.
""" """
global free
if self.app: if self.app:
if 'background' in dir(self.app): if 'background' in dir(self.app):
try: try:
@ -226,6 +228,9 @@ class Manager():
watch.display.mute(True) watch.display.mute(True)
watch.backlight.set(self._brightness) watch.backlight.set(self._brightness)
self.sleep_at = watch.rtc.uptime + 90 self.sleep_at = watch.rtc.uptime + 90
if watch.free:
gc.collect()
free = gc.mem_free()
# Clear out any configuration from the old application # Clear out any configuration from the old application
self.event_mask = 0 self.event_mask = 0
@ -462,17 +467,12 @@ class Manager():
normal execution context meaning any exceptions and other problems normal execution context meaning any exceptions and other problems
can be observed interactively via the console. can be observed interactively via the console.
""" """
global free
if self._scheduling: if self._scheduling:
print('Watch already running in the background') print('Watch already running in the background')
return return
if not self.app: if not self.app:
self.switch(self.quick_ring[0]) self.switch(self.quick_ring[0])
if watch.free:
gc.collect()
free = gc.mem_free()
# Reminder: wasptool uses this string to confirm the device has # Reminder: wasptool uses this string to confirm the device has
# been set running again. # been set running again.
@ -520,13 +520,8 @@ class Manager():
def schedule(self, enable=True): def schedule(self, enable=True):
"""Run the system manager synchronously.""" """Run the system manager synchronously."""
global free
if not self.app: if not self.app:
self.switch(self.quick_ring[0]) self.switch(self.quick_ring[0])
if watch.free:
gc.collect()
free = gc.mem_free()
if enable: if enable:
watch.schedule = self._schedule watch.schedule = self._schedule