1
0
Fork 0

Optimize flash usage of weather app

Signed-off-by: Francesco Gazzetta <fgaz@fgaz.me>
This commit is contained in:
Francesco Gazzetta 2021-12-26 16:58:28 +01:00 committed by Daniel Thompson
parent fc756bccc9
commit 5c714ea075

View file

@ -63,11 +63,12 @@ class WeatherApp(object):
def foreground(self): def foreground(self):
"""Activate the application.""" """Activate the application."""
temp = wasp.system.weatherinfo.get('temp') get_info = wasp.system.weatherinfo.get
hum = wasp.system.weatherinfo.get('hum') temp = get_info('temp')
txt = wasp.system.weatherinfo.get('txt') hum = get_info('hum')
wind = wasp.system.weatherinfo.get('wind') txt = get_info('txt')
loc = wasp.system.weatherinfo.get('loc') wind = get_info('wind')
loc = get_info('loc')
if temp: if temp:
self._temp = temp self._temp = temp
if hum: if hum:
@ -92,11 +93,12 @@ class WeatherApp(object):
def tick(self, ticks): def tick(self, ticks):
wasp.system.keep_awake() wasp.system.keep_awake()
temp_now = wasp.system.weatherinfo.get('temp') get_info = wasp.system.weatherinfo.get
hum_now = wasp.system.weatherinfo.get('hum') temp_now = get_info('temp')
txt_now = wasp.system.weatherinfo.get('txt') hum_now = get_info('hum')
wind_now = wasp.system.weatherinfo.get('wind') txt_now = get_info('txt')
loc_now = wasp.system.weatherinfo.get('loc') wind_now = get_info('wind')
loc_now = get_info('loc')
if temp_now: if temp_now:
if temp_now != self._temp: if temp_now != self._temp:
self._temp = temp_now self._temp = temp_now