Aviation Units #7
4 changed files with 42 additions and 16 deletions
|
@ -19,14 +19,14 @@ class OwmForecasts (WeatherInterface):
|
||||||
return self.api.is_API_online()
|
return self.api.is_API_online()
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def reload(self):
|
def reload(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_today_forecast (self, location=None):
|
def get_today_forecast (self, location=None):
|
||||||
if self.is_available() is False:
|
if self.is_available() is False:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
location = self.location if location is None else location
|
location = self.location if location is None else location
|
||||||
|
|
||||||
|
@ -40,10 +40,10 @@ class OwmForecasts (WeatherInterface):
|
||||||
def get_forecast_in_days (self, offset_by_days, location=None):
|
def get_forecast_in_days (self, offset_by_days, location=None):
|
||||||
if offset_by_days is 0:
|
if offset_by_days is 0:
|
||||||
return self.get_today_forecast(location)
|
return self.get_today_forecast(location)
|
||||||
|
|
||||||
if self.is_available() is False:
|
if self.is_available() is False:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
location = self.location if location is None else location
|
location = self.location if location is None else location
|
||||||
try:
|
try:
|
||||||
forecast = self.api.daily_forecast(location, limit=offset_by_days)
|
forecast = self.api.daily_forecast(location, limit=offset_by_days)
|
||||||
|
@ -66,16 +66,21 @@ class OwmForecasts (WeatherInterface):
|
||||||
forecast_object.short_description = translate(str(weather.get_status()))
|
forecast_object.short_description = translate(str(weather.get_status()))
|
||||||
forecast_object.detailed_description = str(weather.get_detailed_status())
|
forecast_object.detailed_description = str(weather.get_detailed_status())
|
||||||
forecast_object.air_pressure = str(weather.get_pressure()['press'])
|
forecast_object.air_pressure = str(weather.get_pressure()['press'])
|
||||||
|
forecast_object.wind_deg = str(int(weather.get_wind()['deg']))
|
||||||
|
|
||||||
if forecast_object.units == "metric":
|
if forecast_object.units == "metric":
|
||||||
forecast_object.air_temperature = str(int(weather.get_temperature(unit='celsius')['temp']))
|
forecast_object.air_temperature = str(int(weather.get_temperature(unit='celsius')['temp']))
|
||||||
forecast_object.wind_speed = str(int(weather.get_wind()['speed']))
|
forecast_object.wind_speed = str(int(weather.get_wind()['speed'])) #kmh
|
||||||
|
|
||||||
|
if forecast_object.units == "aviation":
|
||||||
|
forecast_object.air_temperature = str(int(weather.get_temperature(unit='celsius')['temp']))
|
||||||
|
forecast_object.wind_speed = str(int(weather.get_wind()['speed'] * 1.94384)) #knots
|
||||||
|
|
||||||
if forecast_object.units == "imperial":
|
if forecast_object.units == "imperial":
|
||||||
forecast_object.air_temperature = str(int(weather.get_temperature('fahrenheit')['temp']))
|
forecast_object.air_temperature = str(int(weather.get_temperature('fahrenheit')['temp']))
|
||||||
forecast_object.wind_speed = str(int(weather.get_wind()['speed'] * 0.621))
|
forecast_object.wind_speed = str(int(weather.get_wind()['speed'] * 0.621)) #mph
|
||||||
|
|
||||||
forecast_object.sunrise = datetime.fromtimestamp(int(weather.get_sunrise_time(timeformat='unix')))
|
forecast_object.sunrise = datetime.fromtimestamp(int(weather.get_sunrise_time(timeformat='unix')))
|
||||||
forecast_object.sunset = datetime.fromtimestamp(int(weather.get_sunset_time(timeformat='unix')))
|
forecast_object.sunset = datetime.fromtimestamp(int(weather.get_sunset_time(timeformat='unix')))
|
||||||
|
|
||||||
return forecast_object
|
return forecast_object
|
||||||
|
|
|
@ -30,16 +30,27 @@ class WeatherColumnDesign (DesignEntity):
|
||||||
def __draw_infos__ (self, forecast):
|
def __draw_infos__ (self, forecast):
|
||||||
temperature = forecast.air_temperature + " " + self.__get_unit__(("°C", "°F"))
|
temperature = forecast.air_temperature + " " + self.__get_unit__(("°C", "°F"))
|
||||||
humidity = forecast.air_humidity + "%"
|
humidity = forecast.air_humidity + "%"
|
||||||
windspeed = forecast.wind_speed + " " + self.__get_unit__(("km/h", "mph"))
|
if self.forecast.units== "aviation":
|
||||||
|
if len(forecast.wind_deg)==1:
|
||||||
|
forecast.wind_deg = "00" + forecast.wind_deg
|
||||||
|
elif len(forecast.wind_deg)==2:
|
||||||
|
forecast.wind_deg = "0" + forecast.wind_deg
|
||||||
|
if int(forecast.wind_speed)<10:
|
||||||
|
windspeed = forecast.wind_deg + "@" + "0" + forecast.wind_speed + self.__get_unit__(("", "")) #added degrees, if wind<10 add a 0 to make two digit
|
||||||
|
else:
|
||||||
|
windspeed = forecast.wind_deg + "@" + forecast.wind_speed + self.__get_unit__(("", "")) #added degrees
|
||||||
|
else:
|
||||||
|
windspeed = forecast.wind_speed + " " + self.__get_unit__(("km/h", "mph"))
|
||||||
|
|
||||||
numbers_list = [ [ forecast.short_description ],
|
numbers_list = [ [ forecast.short_description ],
|
||||||
[ temperature ],
|
[ temperature ],
|
||||||
[ humidity ],
|
[ humidity ],
|
||||||
[ windspeed ]]
|
[ windspeed ] ]
|
||||||
|
|
||||||
ypos = info_x_ypos * self.size[0]
|
ypos = info_x_ypos * self.size[0]
|
||||||
pos = (0, ypos)
|
pos = (0, ypos)
|
||||||
size = (self.size[0], self.size[1] + info_yresize * self.size[1] - pos[1])
|
size = (self.size[0], self.size[1] + info_yresize * self.size[1] - pos[1])
|
||||||
|
print(size)
|
||||||
line_spacing = (size[1] - len(numbers_list) * fontsize_static) / (len(numbers_list) + 1)
|
line_spacing = (size[1] - len(numbers_list) * fontsize_static) / (len(numbers_list) + 1)
|
||||||
|
|
||||||
table = TableDesign(size, numbers_list, fontsize=fontsize_static, line_spacing=line_spacing, column_horizontal_alignments=[ "center" ], max_col_size=[ size[0] ], truncate_text=False, truncate_rows=False)
|
table = TableDesign(size, numbers_list, fontsize=fontsize_static, line_spacing=line_spacing, column_horizontal_alignments=[ "center" ], max_col_size=[ size[0] ], truncate_text=False, truncate_rows=False)
|
||||||
|
@ -75,7 +86,7 @@ class WeatherColumnDesign (DesignEntity):
|
||||||
|
|
||||||
|
|
||||||
def __get_unit__ (self, tuple):
|
def __get_unit__ (self, tuple):
|
||||||
if self.forecast.units == "metric":
|
if self.forecast.units == "metric" or self.forecast.units == "aviation":
|
||||||
return tuple[0]
|
return tuple[0]
|
||||||
else:
|
else:
|
||||||
return tuple[1]
|
return tuple[1]
|
||||||
|
@ -87,4 +98,4 @@ class WeatherColumnDesign (DesignEntity):
|
||||||
if hours == "24":
|
if hours == "24":
|
||||||
return time.strftime('%H:%M')
|
return time.strftime('%H:%M')
|
||||||
else:
|
else:
|
||||||
return time.strftime('%I:%M')
|
return time.strftime('%I:%M')
|
||||||
|
|
|
@ -29,7 +29,17 @@ class WeatherHeaderDesign (DesignEntity):
|
||||||
return
|
return
|
||||||
|
|
||||||
temperature = cur_weather.air_temperature + " " + self.__get_unit__(("°C", "°F"))
|
temperature = cur_weather.air_temperature + " " + self.__get_unit__(("°C", "°F"))
|
||||||
windspeed = cur_weather.wind_speed + " " + self.__get_unit__(("km/h", "mph"))
|
if units== "aviation": #pick up aviation
|
||||||
|
if len(forecast.wind_deg)==1: #if deg is 2, add two zeros for format
|
||||||
|
forecast.wind_deg = "00" + forecast.wind_deg
|
||||||
|
elif len(forecast.wind_deg)==2:
|
||||||
|
forecast.wind_deg = "0" + forecast.wind_deg
|
||||||
|
if int(cur_weather.wind_speed)<10:
|
||||||
|
windspeed = cur_weather.wind_deg + "@" + "0" + cur_weather.wind_speed + self.__get_unit__(("", "")) #added degrees, if wind<10 add a 0 to make two digit
|
||||||
|
else:
|
||||||
|
windspeed = cur_weather.wind_deg + "@" + cur_weather.wind_speed + self.__get_unit__(("", "")) #added degrees
|
||||||
|
else:
|
||||||
|
windspeed = cur_weather.wind_speed + " " + self.__get_unit__(("km/h", "mph"))
|
||||||
|
|
||||||
self.__draw_text__(temperature, self.__abs_pos__((0.87, 0)), (50,35))
|
self.__draw_text__(temperature, self.__abs_pos__((0.87, 0)), (50,35))
|
||||||
self.__draw_text__(windspeed, self.__abs_pos__((0.297, 0.05)), (100,35))
|
self.__draw_text__(windspeed, self.__abs_pos__((0.297, 0.05)), (100,35))
|
||||||
|
@ -57,7 +67,7 @@ class WeatherHeaderDesign (DesignEntity):
|
||||||
self.draw_design(txt)
|
self.draw_design(txt)
|
||||||
|
|
||||||
def __get_unit__ (self, tuple):
|
def __get_unit__ (self, tuple):
|
||||||
if units == "metric":
|
if units == "metric" or units == "aviation":
|
||||||
return tuple[0]
|
return tuple[0]
|
||||||
else:
|
else:
|
||||||
return tuple[1]
|
return tuple[1]
|
||||||
|
@ -66,4 +76,4 @@ class WeatherHeaderDesign (DesignEntity):
|
||||||
if hours == "24":
|
if hours == "24":
|
||||||
return time.strftime('%H:%M')
|
return time.strftime('%H:%M')
|
||||||
else:
|
else:
|
||||||
return time.strftime('%I:%M')
|
return time.strftime('%I:%M')
|
||||||
|
|
|
@ -18,7 +18,7 @@ week_starts_on = "Monday"
|
||||||
display_colours = "bwr"
|
display_colours = "bwr"
|
||||||
language = "en"
|
language = "en"
|
||||||
datetime_encoding = "UTF-8" # UTF-8
|
datetime_encoding = "UTF-8" # UTF-8
|
||||||
units = "metric"
|
units = "metric" #aviation (celcius,degrees/knots), metric (celcius,kmh), imperial(f,mph)
|
||||||
hours = "24"
|
hours = "24"
|
||||||
update_interval = 60
|
update_interval = 60
|
||||||
|
|
||||||
|
@ -38,4 +38,4 @@ general_settings = { # General settings that designs may use
|
||||||
render_to_display = True
|
render_to_display = True
|
||||||
render_to_file = False # Will be called "design_exported.png" in Calendar-directory
|
render_to_file = False # Will be called "design_exported.png" in Calendar-directory
|
||||||
calibrate_hours = [0, 12, 18]
|
calibrate_hours = [0, 12, 18]
|
||||||
print_technical_data = False
|
print_technical_data = False
|
||||||
|
|
Loading…
Reference in a new issue