Python RGB Matrix games and animations https://www.xythobuz.de/ledmatrix_v2.html
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

weather.py 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env python
  2. from pyowm.owm import OWM
  3. from pyowm.utils.config import get_default_config
  4. import time
  5. api_key = "API_KEY_HERE"
  6. class WeatherScreen:
  7. def __init__(self, gui, latitude = 47.7174, longitude = 9.3924, language = "de", refresh = 600, width = 32, height = 32):
  8. self.gui = gui
  9. self.latitude = latitude
  10. self.longitude = longitude
  11. self.language = language
  12. self.refresh = refresh
  13. self.width = width
  14. self.height = height
  15. self.lastTime = time.time()
  16. self.data = ""
  17. self.fetchData()
  18. def fetchData(self):
  19. config_dict = get_default_config()
  20. config_dict['language'] = self.language
  21. owm = OWM(api_key, config_dict)
  22. mgr = owm.weather_manager()
  23. observation = mgr.weather_at_place("Tuttlingen, DE")
  24. print(observation.weather.rain)
  25. print(observation.weather.snow)
  26. print(observation.weather.wind)
  27. print(observation.weather.humidity)
  28. print(observation.weather.pressure)
  29. print(observation.weather.temperature)
  30. print(observation.weather.clouds)
  31. print(observation.weather.status)
  32. print(observation.weather.detailed_status)
  33. print(observation.weather.weather_icon_name)
  34. print(observation.weather.precipitation_probability)
  35. #self.data = mgr.one_call(lat=self.latitude, lon=self.longitude)
  36. #print(self.data.forecast_hourly[0].wind().get("speed", 0))
  37. def draw(self):
  38. if (time.time() - self.lastTime) > self.refresh:
  39. self.fetchData()
  40. self.lastTime = time.time()
  41. # TODO text location
  42. # TODO text data
  43. def finished(self):
  44. return True
  45. def restart(self):
  46. pass
  47. if __name__ == "__main__":
  48. from test import TestGUI
  49. t = TestGUI()
  50. s = WeatherScreen(t)
  51. s.draw()
  52. t.debug_loop(s.draw)