Inky Frame slide show

I wrote a very basic slide show program in MicroPython for the Inky Frame so I could preload them with some images to make them a better gift. It just shows every (600x448) JPEG in the /slides directory on the SD card in a loop: sdslideshow.py.

1 Like

Thank you for sharing. I don’t own an inky, so I can’t try it. But I like when people share there code so thumbs up from me. =)

I wrote that quickly in late July just after my Inky Frames turned up. Pimoroni posted a more elaborate example while I was on holiday: Pimoroni MicroPython Examples: Inky Frame: Image Gallery.

I needed a retry loop for mounting the SD card at power up. It’s fine afterwards but my code throws an OSError if I don’t have something like this in there.

sd = None
last_exception = None
### First one often fails at power up
for _ in range(15):
    try:
        sd = sdcard.SDCard(sd_spi, Pin(22))
        uos.mount(sd, SD_MOUNTPOINT)
        break
    except OSError as ex:
        last_exception = ex
    time.sleep(4)
if sd is None:
    raise last_exception

Perhaps there’s a better way to achieve the same thing there?

Oh, and I know I’m not necessarily handling uos.mount errors well.

I have a Pico RGB Keypad running Circuit Python. It’s set up as a USB HID device. It errors out waiting for my Windows PC to boot up. I ended up putting a time.sleep as my first statement in my while true loop. My code doesn’t run until the PC is booted up and waiting at the log in screen. I know the keypad is ready when all the pads light up a dim white.
Long story made short, It’s not an elegant or sophisticated solution, but it works. ;)

I just updated the code. It now has:

  • sleep support on battery power with next image every 4 hours (possibly a bit less on my Inky Frame as my clock appears to run fast),
  • buttons for navigation and
  • an introduction/instructions screen currently implemented as a JPEG image (see below).

introduction

This is cool! I tried to do this aswell, sadly I think the ram prevents me from running this with 3k images on the sdcard:
Traceback (most recent call last):
File “”, line 158, in
MemoryError: memory allocation failed, allocating 8192 bytes

at:
files = list(filter(JPEG_RE.search, uos.listdir(SLIDE_DIR)))

How many images do you have on the sd?

I’ve been giving them away as gifts with 10-50 images on, nowhere near 3000!

It turns out there’s an uos.ilistdir function which is an iterator and that makes it possible to read the directory without loading large chunks of FAT32 directory content into memory. I’ve just re-coded my slide show to use that. I don’t have time at the moment to setup a test with a large number of images but you’re welcome to have a play with it. Same location on github, it’s v1.6 in the code comments.

1 Like

jup that works! thank you!

Nice. You printed that frame yourself? Do you share it somewhere?

Sure: Printables

2 Likes

Thanks for sharing. I already downloaded it and I will give it a try. Since I own a MKS3+, I expect no problems.

Glad it worked. The frame looks really nice. Does that have room for AA batteries or are you using something slimmer?

I wrote Instructables: Battery-Powered Digital Picture Frame Using Pimoroni Inky Frame for a bit more detail on using the slide show program including a bit of power profiling with Nordic Power Profiler Kit II. I mentioned @ingurum 3D-printed frame as it looks really good. I don’t have a printer to try it out myself.

1 Like

Very good writeup!

Judging from the PPK2-graph, the wlan-part of the pico is active. These spikes at 150mA suggest activity from the radio. Also, a normal pico needs something like 25mA while active, and the difference to 50mA is probably not due to the inky.

So it would be interesting if there is a means of shutting down the radio or maybe even starting with a deactivated radio. The wlan-chip on the picow does have the necessary interfaces, but I’m not sure if they are exposed by MicroPython.

Great instructable kevin!

I used a lipo and I am working on V2 for the case to include an amigo pro for charging. Also I’ll deepen the case for the included AA batteries. I am planning to improve the snapfit as well (maybe screws)

Could be directory naming, you mentioned slide but program looks for slides (plural)?

I just checked the SD card and it was empty. Not sure how the directory got deleted,but that solved the loading problem. I am not getting any lights from buttons interaction. Is that normal ?
The introduction.jpg must be on the root of sd card?
SLIDE_INTROFILE = SD_MOUNTPOINT + “/introduction.jpg”

Yes, root directory for the introduction.jpg. There’s an image of layout in step 3 of https://www.instructables.com/Battery-Powered-Digital-Picture-Frame-Using-Pimoro/

There’s no current use of LEDs but it’s on todo list. It would useful to indicate button presses as Inky Frame (using MicroPython?) requires an unusually long press to wake.

Thanks again for the script and the replies. It works good now.
I appreciate the effort you put into it and the fact that you made it so easy to understand.