refactor: small changes and reformats
This commit is contained in:
19
epaper.py
19
epaper.py
@@ -64,14 +64,12 @@ class TrafficSegment(DisplaySegment):
|
|||||||
duration = {}
|
duration = {}
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
now = datetime.datetime.now()
|
if config.low_resolution:
|
||||||
|
|
||||||
if not config.low_resolution:
|
|
||||||
self.validity = 60
|
|
||||||
else:
|
|
||||||
self.validity = 60*60
|
self.validity = 60*60
|
||||||
logging.debug(f"{type(self)}: Not in the morning, skipping update")
|
logging.debug(f"{type(self)}: Not in the morning, skipping update")
|
||||||
return
|
return ""
|
||||||
|
else:
|
||||||
|
self.validity = 60
|
||||||
|
|
||||||
url = "https://maps.googleapis.com/maps/api/directions/json?"
|
url = "https://maps.googleapis.com/maps/api/directions/json?"
|
||||||
travel_parameters = {
|
travel_parameters = {
|
||||||
@@ -178,7 +176,7 @@ class AirSegment(DisplaySegment):
|
|||||||
return "[]"
|
return "[]"
|
||||||
per_character = (end - start) / (length - 2)
|
per_character = (end - start) / (length - 2)
|
||||||
middle = (end - start) / 2
|
middle = (end - start) / 2
|
||||||
fill_char = "+"
|
fill_char = "#"
|
||||||
|
|
||||||
gauge = "["
|
gauge = "["
|
||||||
for i in range(0, length - 2):
|
for i in range(0, length - 2):
|
||||||
@@ -192,9 +190,10 @@ class AirSegment(DisplaySegment):
|
|||||||
return gauge
|
return gauge
|
||||||
|
|
||||||
def _get_data_text(self):
|
def _get_data_text(self):
|
||||||
ret = f"{self.text_gauge(value=self.percent_pm25)} PM2,5: {self.percent_pm25}% ; "
|
ret = f"{self.text_gauge(value=self.percent_pm25)} PM2,5: {self.percent_pm25}% "
|
||||||
ret+= f"{self.text_gauge(value=self.percent_pm10)} PM10: {self.percent_pm10}% \n "
|
ret+= f"{self.text_gauge(value=self.percent_pm10)} PM10: {self.percent_pm10}%\n"
|
||||||
ret+= f"{self.description} / {self.advice}"
|
ret+= f"{self.description}\n"
|
||||||
|
ret+= f"{self.advice}"
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user