I’m currently going through my Pi’s to update the older OS images to new ones. As part of that I have a Pi Zero with a Display Hat Mini that was running Buster Lite, and I’ve now updated it to Trixie Lite.
Unfortunately in doing so, the script which used to run fine on Buster is now having all sorts of issues on Trixie. From what I can see, a lot of the dependency packages (PIL and numpy at least) have updated, and now things are going bad on me and I’m in need of some help.
The current error that’s giving me grief is
File "/home/darren/display/display.py", line 755, in <module>
display_hat.display(img)
~~~~~~~~~~~~~~~~~~~^^^^^
TypeError: DisplayHATMini.display() takes 1 positional argument but 2 were given
as I can’t see how to work around it?
The relevant bits of the script are
WIDTH = DisplayHATMini.WIDTH
HEIGHT = DisplayHATMini.HEIGHT
def clear_display():
global img, draw, disp
img = Image.new('RGB', (WIDTH, HEIGHT), color=(0, 0, 0))
draw = ImageDraw.Draw(img)
return
display_hat = DisplayHATMini(buffer=None, backlight_pwm=True)
display_hat.on_button_pressed(button_callback)
while True:
while DISPLAYSCREEN == "clock":
clear_display()
display_hat.set_backlight(True)
x = datetime.datetime.now()
today = datetime.date.today()
date_string = today.strftime('%-d{suffix} %B')
if (x.second / 2) == int(x.second / 2):
draw_centred_text(img, x.strftime("%H:%M:%S"), 48, clockfont, 255, 255, 255)
else:
draw_centred_text(img, x.strftime("%H %M %S"), 48, clockfont, 255, 255, 255)
draw_centred_text(img, x.strftime('%A'), 144, font28, 255, 255, 255)
draw_centred_text(img, date_string.format(suffix=ordinal_suffix(today.day)), 192, font28, 255, 255, 255)
draw_tags()
display_hat.display(img)
sleep(0.1)
draw_centred_text() and draw_tags() are defined elsewhere in the script and seem to be working (after some fixes), but the display line just before the sleep is giving the error above.
Can anyone share some guidance here, as I’m stuck :(
I assume it’s something around the definition in the clear_display() function, but what should the img set-up be?