Thanks Hel for the tips! I realised that i was short of Wifi connection info too. Now i have it functioning but the font is rather small and the weather icon also small so getting there but needs more work! I have tried adding scale = 2 to the text display line but that doesn’t seem to change the size of the displayed font.
Also i read that jpegdec doesn’t support image upscaling so i tried to resize the original weather icons (64x64 px i think they were) to 150x150 (and adding a splash of colour to them) but these don’t load and calling them causes the program to stop. I did export them properly (not progressive or enhanced) so i don’t think it’s that.
I have included the relevant part of the code (draw_page) regarding the text displaying and image rendering in case anyone has any suggestions as to how i can increase font sizing and render double (ish) sized images.
Ignore the lower panel, i am adding an instant drone flying status panel too which will take wind and possibly precipitation into account and give a symbol for the day. These are WIP and need more contrast and would be better at 150x150 if i can get them to work.
When it’s a bit more sorted i’ll post the whole code if anyone is interested in it (without typos on screen :) )
def draw_page():
graphics.set_pen(inky_frame.WHITE) #Set white pen
graphics.clear() #Set all screen to white
graphics.set_font("bitmap12") #set font for weather header
graphics.set_pen(inky_frame.BLUE) # set colour for top box
graphics.rectangle(0, 0, 640, 20)
graphics.rectangle(0, 200, 640, 20) # draw top box rectangle - x,y,width, height
graphics.set_pen(inky_frame.WHITE)
graphics.text("Weather", 3, 4, scale = 2) #x,y,scaling from 8 pixel
graphics.text("Drone Operting Status", 3, 204, scale = 2) # Write 'Weather' in top box - Text parameters are position offset x,y from 0,0 (top left)
graphics.set_pen(inky_frame.BLACK) # set colour to black
graphics.set_font("bitmap8") #set font for next bit
# graphics.update() # Refresh Display - remd out as seems too many updates
if temperature is not None:
# Choose an appropriate icon based on the weather code
# Weather codes from https://open-meteo.com/en/docs
# Weather icons from https://fontawesome.com/
if weathercode in [71, 73, 75, 77, 85, 86]: # codes for snow
jpeg.open_file("/icons/icon-snow.jpg")
elif weathercode in [51, 53, 55, 56, 57, 61, 63, 65, 66, 67, 80, 81, 82]: # codes for rain
jpeg.open_file("/icons/icon-rain.jpg")
elif weathercode in [1, 2, 3, 45, 48]: # codes for cloud
jpeg.open_file("/icons/icon-cloud.jpg")
elif weathercode in [0]: # codes for sun
jpeg.open_file("/icons/icon-sun.jpg")
elif weathercode in [95, 96, 99]: # codes for storm
jpeg.open_file("/icons/icon-storm.jpg")
jpeg.decode(13, 60, jpegdec.JPEG_SCALE_FULL) #x,y position of jpeg
graphics.set_pen(0)
graphics.text(f"Temperature: {temperature}°C", int(WIDTH / 3), 48, WIDTH - 105, 2)
graphics.text(f"Wind Speed: {windspeed}kmph", int(WIDTH / 3), 68, WIDTH - 105, 2)
graphics.text(f"Wind Direction: {winddirection}", int(WIDTH / 3), 88, WIDTH - 105, 2)
graphics.text(f"Last update: {date}, {time}", int(WIDTH / 3), 108, WIDTH - 105, 2)
if windspeed > 10:
jpeg.open_file("/icons/no-drone.jpg") #windspeed is too high for drone flight
elif weathercode <=10: # windsspeed is low enough for drone flight
jpeg.open_file("/icons/go-drone.jpg")
jpeg.decode(13, 250, jpegdec.JPEG_SCALE_FULL) #x,y position of jpeg
graphics.update()
else:
graphics.set_pen(0)
graphics.rectangle(0, 60, WIDTH, 25)
graphics.set_pen(15)
graphics.text("Unable to display weather! Check your network settings in WIFI_CONFIG.py", 5, 65, WIDTH, 1)
graphics.update()