This code scrolls .bmp images from the bottom of the screen to the top. I've placed the screen upside-down inside my project so it looks like the images are scrolling downwards.
The images also fade in and out, and can weave back and forth for a more organic feel. The code has variables to make it easy to customize the way each of your images behaves.
Look at the bottom of the code to find the while True
section.
while True: show_next = random.randint(1, 5) #change to reflect how many images you add if show_next == 1: crawl_down(display, "/ray.bmp") elif show_next == 2: crawl_down(display, "/waves1.bmp", speed=7, weave=0, pulse=.35) elif show_next == 3: crawl_down(display, "/waves2.bmp", speed=9, weave=1, pulse=.35) elif show_next == 4: pulse(display, "/heart.bmp", duration=4, pulse=.45) elif show_next == 5: crawl_down(display, "/dark.bmp")
To customize your image scroller:
- Save your 64px wide .bmp images at the root of the CIRCUITPY drive along with the sample images we've included.
- Update this part of your code so the .bmp names match the names of your files.
- If you have more or fewer than 5 files, change the
random.randint(1, 5)
line to reflect the number of images (or separate instances of the same image) you want to add. For example, if you have only 3 files, it should readrandom.randint(1, 3)
- Customize the behavior of each image by modifying the
speed
,weave
,pulse
, andduration
variables. Thepulse
variable should be between 0 and 0.5. A value of .45 seems to work well for an image that doesn't fade out completely.
Page last edited March 08, 2024
Text editor powered by tinymce.