DEV Community

Aris
Aris

Posted on • Originally published at blog.arisamiga.rocks on

Making a retro bag!

So today we have something a bit different. This is a project that I always wanted to do as I wanted to work with the Raspberry Pi Zero W.

Raspberry Pi Zero W

Now you might ask me "Aris, Why didn't you get the Raspberry Pi Zero W 2 which is faster and more powerful?"

Well, I didn't get the Pi Zero W 2 because it came out 2 days after I bought the Pi Zero W and I had no idea that a Pi Zero W was even in the works... so yea, Fun!

The Raspberry Pi Zero W is an amazing system tho. Some of Its features include:

  • 802.11 b/g/n wireless LAN
  • Bluetooth 4.1
  • 1GHz, single-core CPU
  • 512MB RAM
  • Mini HDMI port and micro USB On-The-Go (OTG) port
  • Micro USB power
  • HAT-compatible 40-pin header etc.

Which makes it the perfect candidate for a Project that I wanted to do ever since I saw this amazing device.

A Remote Retropie Powered School Bag Ah yes.

The Plan is to have the Raspberry Pi Zero W inside the bag and have the HDMI in the Bag's USB port which will display pictures when not in use and every time I want to play anything I just plug in the HDMI and press a button which will launch the Retropie's Emulationstation.

This is why I got this Button which I plan to use for entering Retropie.

Button

So let's Start!

The bag that I am gonna use for this project is a Sentio Backpack 15.6" Casual Series Gray Antitheft Bag which I bought from Plaisio in Greece.

Bag

For the OS I went with Raspberry Pi OS Lite which is basically like Raspberry Pi OS without the Desktop Interface so basically only a console.

I started with making a case for the Raspberry so it doesn't get damaged in the bag. I used this amazing design by adafruit

Pi's Case

And then I went on to work on the software for the button detection and the emulationstation.

I decided to write everything in Python which is a high-level, general-purpose programming language and the one I am most familiar with.

For the button detection, I needed to connect the button to 1 GPIO pin to detect the press and a Ground pin.

Tip: If your button has a LED make sure to put a 330-ohm resistor between it and the Voltage or else it will break. I forgot to do that.

Pi zero Pinout

To detect the button I used the following script:

# Import Rpi's Library for GPIO pins
import RPi.GPIO as GPIO
# Disables Warnings. 
# It's usually telling you that the gpio is already in use, 
# that's because you have stopped the program and started it again.
GPIO.setwarnings(False)
# The GPIO.BCM option means that you are referring to the pins by the 
# "Broadcom SOC channel" number, these are the numbers after "GPIO" 
# around the outside of the above diagram
GPIO.setmode(GPIO.BCM)
# It tells the library which pins you want to use
GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# Waits till the Button is Pressed
GPIO.wait_for_edge(3,GPIO.FALLING)
# The rest of the script gets executed when the button is pressed
Enter fullscreen mode Exit fullscreen mode

As I wanted to display pictures on the Raspberry when it's not in use I had to find something that doesn't need an interface to display an image which was quite hard to do.

After a lot of searches, I found a package called FBI a Linux frame buffer image viewer which from my understanding is something used to show graphics on a computer monitor, typically on the system console which also includes Pictures!

The problem with having Fbi running is that it completely freezes the console meaning that if I run it and tell it to run a log after 2 seconds of opening the fbi it will wait till fbi exits and then it will wait 2 seconds to execute the command I want.

The script for detecting the Button press also had the same thing, you couldn't run any command while it was doing something and that is when I stumbled into something called "Subprocess" which was a lifesaver.

Subprocess is a python module that allows you to spawn new processes, connect to their input/output/error, and obtain their return codes. What it does is it allows you to create a different console/process from your current process so you don't have to wait for other tasks to finish.

This was amazing, so instead of having 1 Python file, I ended up with 3 different Python files.

I would say what each of them is and what it does but I realized that it's just gonna be a big paragraph of complicated things so here is a diagram to explain how it works (Note that main.py always gets executed first):

Retropie Diagram

Also when working with Retropie's Themes I had a problem where when I started the emulationstation the theme would glitch out and I couldn't change it back to normal.

Retropie Theme Glitch

The problem that caused this for me was having a limit on the VRAM on retropie and probably the many times I restarted which might have corrupted the theme.

I fixed it with a reinstall of Retropie which thankfully didn't delete any of my ROMs and by putting the Vram limit to at least 80 so the menu can load normally. Which fixed the problem.

Retropie Vram Limit

Also, another problem I encountered was that Retropie didn't want to run the games and put me back in the menu when it was opened using a subprocess script.

The solution that worked for me was that I added all the scripts inside a Screen which is a way that you can start a session and then open any number of windows (virtual terminals) inside that session which allowed Retropie to launch the games that way.

Then, After adding around 5000 ROMs and waiting like 4hours for the Retropie Scraper to add Titles and Images I finished with the software part of this project.

Also, I went with the Famicom-Mini theme as I liked the design of it!

~ Also tip for anyone that does the project make sure to at least keep ssh on in case any problems occur and you need to manually start emulationstation or restart the pi.

I use an app called Termius. Termius is the SSH client that works on Desktop and Mobile so if anything breaks I can ssh into the RPI from my phone.

Termius

Also, quick tip, if you are a student you can get Termius Premium using the Github Student Developer Pack which I highly recommend.

Time to go to the bag.

Right now out of the bat there is a problem where the port that it has on the side is a USB port and if I try to put an HDMI the cable is sticking out.

I decided to sew a cover around the port at the side and have that along with an HDMI dust cap glued at the end of it to prevent anything from going inside the cable and damaging it.

And after a couple of hours and a lot of accidental piercings from sewing.

I finally finished it!

Bag Port Image 1
Bag Port Image 2

I also added a small button to hold it in place at the end of the HDMI.

Overall I think it ended up pretty nice!

This Project was a pretty interesting one to work on I was able to work with the Raspberry Pi Zero W and with all the debugging I also discovered a lot of new things like Subprocessing and Screens and learned to work more on the Linux command line which I always wanted to do.

I am gonna be continuing this project in the future and I am thinking of using Java to make some kind of app that shows statistics from the Raspberry Pi which will be very interesting.

I know this post is a quite long one but thanks for reading my Blog :D

-
Originally Posted on: https://blog.arisamiga.rocks/post/retrobag/

Top comments (1)

Collapse
 
gordonlakey profile image
GordonLakey

i don't have much knowledge about it thanks for sharing its quite impressive and valuable . mantra to destroy enemies