TheMWord
Published © GPL3+

SNES Style RetroPie Build with Raspberry Pi Zero W

Squeezing a Pi Zero W into an SNES cartridge form factor for portable retro gaming! Oh, and let's throw some rainbows in there too...

IntermediateShowcase (no instructions)5 hours5,120
SNES Style RetroPie Build with Raspberry Pi Zero W

Things used in this project

Hardware components

Raspberry Pi Zero W
×1
16GB Micro SD Card
×1
Mini HDMI to HDMI Converter
×1
Micro USB-B Breakout Board
×1
Micro USB Male to 2xUSB Female Hub
×1
Frosted Acetate
×1
SNES Gamecard Case (European Edition)
×1
LED SHIM
Pimoroni LED SHIM
×1

Software apps and online services

Prebuilt RetroPie Image (Based on Raspian)

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Hot glue gun (generic)
Hot glue gun (generic)
Stanley Knife (or sharp craft knife)
Electric Drill + Different sized drill bits

Story

Read more

Code

Pulse while loading

Python
#!/usr/bin/env python3

import signal
import time
import ledshim
import psutil
import sys
import signal

# Clear up on exit
ledshim.set_clear_on_exit()

# Wrap the fuctions in a class for help with signal handling
class MyShim(object):

    def init(self):
        r, g, b = 255, 0, 0
        delay = 0.05
        half_way = int(ledshim.NUM_PIXELS / 2)
        PROCNAME = "emulationstation"

        # Catch signals
        signal.signal(signal.SIGINT, self.catch)
        signal.signal(signal.SIGHUP, self.catch)
        signal.signal(signal.SIGTERM, self.catch)

        started = False
        # wait for main prog to start
        while not started:

            # Turn pixels on
            for x in range(half_way):
                ledshim.set_pixel(half_way - 1 - x, r, g, b)
                ledshim.set_pixel(half_way + x, r, g, b)
                ledshim.show()
                time.sleep(delay)

            # Turn pixels off
            for x in range(half_way):
                ledshim.set_pixel(x, 0, 0, 0)
                ledshim.set_pixel(ledshim.NUM_PIXELS - 1 - x, 0, 0, 0)
                ledshim.show()
                time.sleep(delay)

            # Check started
            for proc in psutil.process_iter():
                if proc.name() == PROCNAME:
                    started = True
                    break
                
            time.sleep(delay)

        # flash green for loaded
        r, g, b = 0, 255, 0
        # Turn pixels on
        for x in range(half_way):
            ledshim.set_pixel(half_way - 1 - x, r, g, b)
            ledshim.set_pixel(half_way + x, r, g, b)
            ledshim.show()
            time.sleep(delay)

        # Turn pixels off
        for x in range(half_way):
            ledshim.set_pixel(x, 0, 0, 0)
            ledshim.set_pixel(ledshim.NUM_PIXELS - 1 - x, 0, 0, 0)
            ledshim.show()
            time.sleep(delay)

                

    # Catch exit signal and tidy up
    def catch(self, signum, frame):
        sys.stderr.write("{} : Caught signal {} : Exiting...\n".format(sys.argv[0], signum))
        
        # turn off the LEDs
        ledshim.clear()
        sys.exit()



if __name__ == "__main__":

    shim = MyShim()
    shim.init()

Credits

TheMWord

TheMWord

1 project • 0 followers
Thanks to GroupGets.

Comments