refactor: extract data resolution logic into config
This commit is contained in:
@@ -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
|
||||
|
||||
11
epaper.py
11
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user