font color var, normal rotation, fix margin
This commit is contained in:
parent
c3675b74bd
commit
33b8041ef6
1 changed files with 7 additions and 3 deletions
|
|
@ -6,6 +6,8 @@
|
|||
Display quote from the Adafruit quotes API as text scrolling across the
|
||||
matrices.
|
||||
|
||||
Requires the requests library to be installed.
|
||||
|
||||
Run like this:
|
||||
|
||||
$ python quote_scroller.py
|
||||
|
|
@ -23,6 +25,8 @@ total_height = 32
|
|||
|
||||
bottom_half_shift_compensation = 1
|
||||
|
||||
font_color = (0, 128, 128)
|
||||
|
||||
# Load the font
|
||||
font = ImageFont.truetype("LindenHill-webfont.ttf", 26)
|
||||
|
||||
|
|
@ -35,12 +39,12 @@ x, y, text_width, text_height = font.getbbox(text)
|
|||
|
||||
full_txt_img = Image.new("RGB", (int(text_width) + 6, int(text_height) + 6), (0, 0, 0))
|
||||
draw = ImageDraw.Draw(full_txt_img)
|
||||
draw.text((3, 0), text, font=font, fill=(0, 128, 128))
|
||||
draw.text((3, 3), text, font=font, fill=font_color)
|
||||
full_txt_img.save("quote.png")
|
||||
|
||||
single_frame_img = Image.new("RGB", (total_width, total_height), (0, 0, 0))
|
||||
|
||||
geometry = adafruit_raspberry_pi5_piomatter.Geometry(width=total_width, height=total_height, n_addr_lines=4, rotation=adafruit_raspberry_pi5_piomatter.Orientation.R180)
|
||||
geometry = adafruit_raspberry_pi5_piomatter.Geometry(width=total_width, height=total_height, n_addr_lines=4, rotation=adafruit_raspberry_pi5_piomatter.Orientation.Normal)
|
||||
framebuffer = np.asarray(single_frame_img) + 0 # Make a mutable copy
|
||||
|
||||
matrix = adafruit_raspberry_pi5_piomatter.AdafruitMatrixBonnetRGB888Packed(framebuffer, geometry)
|
||||
|
|
@ -55,7 +59,7 @@ while True:
|
|||
else:
|
||||
# top half
|
||||
single_frame_img.paste(full_txt_img.crop((x_pixel, 0, x_pixel + total_width, total_height//2)), (0, 0))
|
||||
# bottom half shift right 1 px
|
||||
# bottom half shift compensation
|
||||
single_frame_img.paste(full_txt_img.crop((x_pixel, total_height//2, x_pixel + total_width, total_height)), (bottom_half_shift_compensation, total_height//2))
|
||||
|
||||
framebuffer[:] = np.asarray(single_frame_img)
|
||||
|
|
|
|||
Loading…
Reference in a new issue