22
33logger = getLogger (__name__ )
44
5- from ui import UiFrame , Vect , ZERO
5+ from ui import UiFrame , Vect , ZERO , with_forecast
66from display .epd import BLACK , GREEN
77from micropython import const
88from lang import day_of_week
99from config import api
1010
1111
1212class UiCalendar (UiFrame ):
13- def draw ( self , show_days ):
14- forecast = self . ui . forecast . forecast
13+ @ with_forecast
14+ def draw ( self , forecast , show_days ):
1515 block = self .ui .block
1616 h_space = const (4 )
1717
@@ -27,18 +27,18 @@ def draw(self, show_days):
2727 self .canvas .hline (ZERO , self .dim .x - 1 )
2828
2929 # Find time related to next day
30- week_day = self . ui . forecast .time .get_date_time (forecast [0 ].dt )[6 ]
30+ week_day = forecast .time .get_date_time (forecast . forecast [0 ].dt )[6 ]
3131
32- for i in range (len (forecast )):
33- dt = self . ui . forecast .time .get_date_time (forecast [i ].dt )
32+ for i in range (len (forecast . forecast )):
33+ dt = forecast .time .get_date_time (forecast . forecast [i ].dt )
3434 if not week_day == dt [6 ]:
3535 dh = dt [3 ]
3636 break
3737
3838 # Draw all items related to forecast
3939 first = True
4040 for x , f in self .ui .forecast_singles ():
41- dt = self . ui . forecast .time .get_date_time (f .dt )
41+ dt = forecast .time .get_date_time (f .dt )
4242 hour = dt [3 ] - dh
4343
4444 # Draw weekends
0 commit comments