refactor: extract data resolution logic into config

This commit is contained in:
2022-01-28 16:46:12 +01:00
parent 27a6846c64
commit 5d1905df00
2 changed files with 13 additions and 2 deletions

View File

@@ -13,3 +13,7 @@ AIRLY_API_KEY = "…"
OPENWEATHERMAP_API_KEY = "" OPENWEATHERMAP_API_KEY = ""
# the plan is to have morning high resolution information display
# and refresh, and lower resolution during rest of the day
# (at night potentially off)
low_resolution = False

View File

@@ -45,7 +45,7 @@ class ClockSegment(DisplaySegment):
def update(self): def update(self):
now = datetime.datetime.now() now = datetime.datetime.now()
if now.hour >= 6 and now.hour < 7: if not config.low_resolution:
self.validity = 60 self.validity = 60
self.time_display = f"{now.hour}:{now.minute}" self.time_display = f"{now.hour}:{now.minute}"
return return
@@ -66,7 +66,7 @@ class TrafficSegment(DisplaySegment):
def update(self): def update(self):
now = datetime.datetime.now() now = datetime.datetime.now()
if now.hour >= 6 and now.hour < 7: if not config.low_resolution:
self.validity = 60 self.validity = 60
else: else:
self.validity = 60*60 self.validity = 60*60
@@ -240,3 +240,10 @@ if __name__ == "__main__":
for segment in segments: for segment in segments:
print(segment.get_data_text()) print(segment.get_data_text())
print("---") print("---")
now = datetime.datetime.now()
if now.hour >= 6 and now.hour < 7:
config.low_resolution = False
else:
config.low_resolution = True