Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/mk1_faceplate_not_clearing #61

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 45 additions & 36 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,24 +595,29 @@ def _display_current_conditions(self, weather: WeatherReport, weather_location:
weather: current weather conditions from Open Weather Maps
weather_location: the geographical location of the reported weather
"""
if self.gui.connected:
self.gui["weatherCode"] = weather.current.condition.animated_code
self.gui["currentTimezone"] = self._format_dt(weather.current.date_time.now(),
incl_time=True)
self.gui["currentTemperature"] = weather.current.temperature
self.gui["weatherCondition"] = weather.current.condition.image
self.gui["weatherLocation"] = weather_location
self.gui["highTemperature"] = weather.daily[0].temperature_high
self.gui["lowTemperature"] = weather.daily[0].temperature_low
self.gui["chanceOfPrecipitation"] = weather.current.chance_of_precipitation
self.gui["windSpeed"] = weather.current.wind_speed
self.gui["humidity"] = weather.current.humidity
self.gui.show_page("CurrentWeather", override_idle=20)
else:
self.enclosure.deactivate_mouth_events()
self.enclosure.weather_display(
weather.current.condition.code, weather.current.temperature
)
# display in GUI
self.gui["weatherCode"] = weather.current.condition.animated_code
self.gui["currentTimezone"] = self._format_dt(weather.current.date_time.now(),
incl_time=True)
self.gui["currentTemperature"] = weather.current.temperature
self.gui["weatherCondition"] = weather.current.condition.image
self.gui["weatherLocation"] = weather_location
self.gui["highTemperature"] = weather.daily[0].temperature_high
self.gui["lowTemperature"] = weather.daily[0].temperature_low
self.gui["chanceOfPrecipitation"] = weather.current.chance_of_precipitation
self.gui["windSpeed"] = weather.current.wind_speed
self.gui["humidity"] = weather.current.humidity
self.gui.show_page("CurrentWeather", override_idle=20)

# display in mk1
self.enclosure.deactivate_mouth_events()
self.enclosure.weather_display(
weather.current.condition.code, weather.current.temperature
)
sleep(5)
self.enclosure.eyes_blink("b")
self.enclosure.mouth_reset()
self.enclosure.activate_mouth_events()

def _report_hourly_weather(self, intent_data: WeatherIntent):
"""Handles requests for a one hour forecast.
Expand Down Expand Up @@ -684,27 +689,31 @@ def _report_one_day_forecast(self, intent_data: WeatherIntent):
self._speak_weather(dialog, wait=True)

def _display_one_day(self, forecast: Weather, intent_data: WeatherIntent):
"""Display the forecast for a single day on a Mark II.
"""Display the forecast for a single day

:param forecast: daily forecasts to display
"""
if self.gui.connected:
self.gui.clear()
self.gui["weatherLocation"] = intent_data.display_location
self.gui["weatherCode"] = forecast.condition.animated_code
self.gui["weatherDate"] = self._format_dt(forecast.date_time)
self.gui["highTemperature"] = forecast.temperature_high
self.gui["lowTemperature"] = forecast.temperature_low
self.gui["chanceOfPrecipitation"] = str(forecast.chance_of_precipitation)
self.gui["windSpeed"] = forecast.wind_speed_max
self.gui["humidity"] = forecast.humidity
self.gui.show_page("SingleDay")
else:
self.enclosure.deactivate_mouth_events()
self.enclosure.weather_display(
forecast.condition.code,
(forecast.temperature_high + forecast.temperature_low) / 2
)
# display in the GUI
self.gui.clear()
self.gui["weatherLocation"] = intent_data.display_location
self.gui["weatherCode"] = forecast.condition.animated_code
self.gui["weatherDate"] = self._format_dt(forecast.date_time)
self.gui["highTemperature"] = forecast.temperature_high
self.gui["lowTemperature"] = forecast.temperature_low
self.gui["chanceOfPrecipitation"] = str(forecast.chance_of_precipitation)
self.gui["windSpeed"] = forecast.wind_speed_max
self.gui["humidity"] = forecast.humidity
self.gui.show_page("SingleDay")
# and display in the mk1 faceplate
self.enclosure.deactivate_mouth_events()
self.enclosure.weather_display(
forecast.condition.code,
(forecast.temperature_high + forecast.temperature_low) / 2
)
sleep(5)
self.enclosure.eyes_blink("b")
self.enclosure.mouth_reset()
self.enclosure.activate_mouth_events()

def _report_multi_day_forecast(self, message: Message, days: int):
"""Handles all requests for multiple day forecasts.
Expand Down
Loading