Skip to content

Commit

Permalink
Make temperature above threshold show in colour.
Browse files Browse the repository at this point in the history
  • Loading branch information
gantonayde committed Oct 6, 2022
1 parent a279ae1 commit c40363b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions inkyshot/update-display.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def create_mask(source):
# Declare non pip fonts here ** Note: ttf files need to be in the /fonts dir of application repo
Grand9KPixel = "/usr/app/fonts/Grand9KPixel.ttf"

def draw_weather(weather, img, scale):
def draw_weather(weather, img, scale, fill):
"""Draw the weather info on screen"""
logging.info("Prepare the weather data for drawing")
# Draw today's date on left side below today's name
Expand All @@ -90,7 +90,7 @@ def draw_weather(weather, img, scale):
draw.text((3, 3), today, BLACK, font=date_font)
# Draw current temperature to right of today
temp_font = ImageFont.truetype(WEATHER_FONT, 24)
draw.text((3, 30), f"{temp_to_str(weather['temperature'], scale)}°", BLACK, font=temp_font)
draw.text((3, 30), f"{temp_to_str(weather['temperature'], scale)}°", fill, font=temp_font)
# Draw today's high and low temps on left side below date
small_font = ImageFont.truetype(WEATHER_FONT, 14)
draw.text(
Expand Down Expand Up @@ -354,7 +354,9 @@ def celcius_to_fahrenheit(temp):
os.environ['LATLONG'] = f"{LAT},{LONG}"
# If weather is empty dictionary, fall back to drawing quote
if len(weather) > 0:
img = draw_weather(weather, img, SCALE)
temperature = weather['temperature'] if SCALE == 'C' else celcius_to_fahrenheit(weather['temperature'])
fill = COLOUR if temperature >= TEMP_THRESHOLD else BLACK
img = draw_weather(weather, img, SCALE, fill)
else:
target_display = 'quote'
elif target_display == 'quote':
Expand Down

0 comments on commit c40363b

Please sign in to comment.