From 5d1905df00b56b90ba69cbda8ef406277c996139 Mon Sep 17 00:00:00 2001 From: Tomasz Torcz Date: Fri, 28 Jan 2022 16:46:12 +0100 Subject: [PATCH] refactor: extract data resolution logic into config --- config.py | 4 ++++ epaper.py | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config.py b/config.py index 5abde13..b65366b 100755 --- a/config.py +++ b/config.py @@ -13,3 +13,7 @@ AIRLY_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 diff --git a/epaper.py b/epaper.py index 2c33bf8..cfddbc7 100755 --- a/epaper.py +++ b/epaper.py @@ -45,7 +45,7 @@ class ClockSegment(DisplaySegment): def update(self): now = datetime.datetime.now() - if now.hour >= 6 and now.hour < 7: + if not config.low_resolution: self.validity = 60 self.time_display = f"{now.hour}:{now.minute}" return @@ -66,7 +66,7 @@ class TrafficSegment(DisplaySegment): def update(self): now = datetime.datetime.now() - if now.hour >= 6 and now.hour < 7: + if not config.low_resolution: self.validity = 60 else: self.validity = 60*60 @@ -240,3 +240,10 @@ if __name__ == "__main__": for segment in segments: print(segment.get_data_text()) print("---") + + now = datetime.datetime.now() + if now.hour >= 6 and now.hour < 7: + config.low_resolution = False + else: + config.low_resolution = True +