pissflaps
This commit is contained in:
17
display.py
17
display.py
@@ -97,8 +97,10 @@ def _fetch_weather(lat: float, lon: float) -> None:
|
||||
now = datetime.now()
|
||||
hours = []
|
||||
for i, ts in enumerate(hourly['time']):
|
||||
if len(hours) >= 5:
|
||||
break
|
||||
t = datetime.strptime(ts, '%Y-%m-%dT%H:%M')
|
||||
if t < now or t.date() != now.date():
|
||||
if t <= now:
|
||||
continue
|
||||
hours.append({
|
||||
'label': t.strftime('%-I%p').lower(),
|
||||
@@ -211,17 +213,18 @@ def draw_weather(surface: pygame.Surface, fonts: dict, x: int, y: int) -> None:
|
||||
surface.blit(fonts['tiny'].render(row2_fn(item), True, WHITE), (cx, start_y + row))
|
||||
surface.blit(fonts['tiny'].render(row3_fn(item), True, DIM_GRAY), (cx, start_y + 2*row))
|
||||
|
||||
# Town name header
|
||||
# Town name header (small font — bigger than the grid text)
|
||||
town_h = fonts['small'].get_height()
|
||||
if town:
|
||||
surface.blit(fonts['tiny'].render(town, True, GRAY), (x, y))
|
||||
surface.blit(fonts['small'].render(town, True, GRAY), (x, y))
|
||||
|
||||
if not week:
|
||||
surface.blit(fonts['tiny'].render('Loading…', True, DIM_GRAY), (x, y + row))
|
||||
surface.blit(fonts['tiny'].render('Loading…', True, DIM_GRAY), (x, y + town_h + 4))
|
||||
return
|
||||
|
||||
# 5-day section
|
||||
_col(week,
|
||||
y + row + 2,
|
||||
y + town_h + 4,
|
||||
lambda d: 'Today' if d['day'] == 'Today' else d['day'][:3],
|
||||
lambda d: f"{d['high']}°/{d['low']}°",
|
||||
lambda d: _trunc(d['desc']))
|
||||
@@ -229,7 +232,7 @@ def draw_weather(surface: pygame.Surface, fonts: dict, x: int, y: int) -> None:
|
||||
# 5-hour section
|
||||
if hours:
|
||||
_col(hours[:_WEATHER_COLS],
|
||||
y + row + 2 + 3*row + 8,
|
||||
y + town_h + 4 + 3*row + 8,
|
||||
lambda h: h['label'],
|
||||
lambda h: f"{h['temp']}°",
|
||||
lambda h: _trunc(h['desc']))
|
||||
@@ -321,7 +324,7 @@ def main() -> None:
|
||||
|
||||
draw_clock(screen, fonts, 20, clock_y)
|
||||
draw_weather(screen, fonts, weather_x,
|
||||
clock_y - fonts['tiny'].get_height() - 2)
|
||||
clock_y - fonts['small'].get_height() - 4)
|
||||
draw_dot(screen, W // 2, dot_y)
|
||||
|
||||
pygame.display.flip()
|
||||
|
||||
Reference in New Issue
Block a user