Atari 2600 difficulty toggles on raspberry Pi gpio
-
I'm converting an old Atari 2600 (dead) into a game box and I was wondering if anyone has already come up with a way to make the toggle switches work for the difficulty settings.
I have an idea which involves a wrapper around Stella that reads the gpio on startup and calls the emulator with the proper command line options then sends key presses any time a change is detected but maybe someone has already done the work? So far I haven't been able to find anything.
-
@suaveant the idea sounds right proper. If it can't be handled in code in sure a microcontroller/Arduino could probably help with the toggle switch. I haven't really done anything hardware wise but I do know anything is possible with enough motivation ;) the configs are easy enough, it's the hardware integration that will probably be the difficult part.
-
@suaveant i have a friend who has already done this and created a python script. It works in stella, but im not sure if he got it working in lr-stella. For some reason retroarch has (or at least had) issues with some gpio keyboard functions. I will contact him to get all the info and the python script.
-
@suaveant so my buddy is going to give me the script and instructions in a few days. He lives in the u.s. but he is in tokyo at the moment.
-
@edmaul69 Thanks
-
@suaveant i dont have python install instruction yet but if you can figure it out this python script is new and needs to be tested. Here is also the info on what each gpio pin does:
GPIO19 = Color/B&W
GPIO16 = Left Difficulty
GPIO20 = Right Difficulty
GPIO21 = Reset
GPIO26 = SelectSending ground to 16 or 20 would change the status to B.
Sending ground to 19 would change it to B&W
So you need to ensure that these three switches are wired correctly.
Pressing both Reset and Select should send the CTRL-Q combo for exit.
And here is the script:
Key configuration is listed at top of script
-
For the installation from the terminal do this stuff to get everything installed:
-
Update (the update may take some time, especially if you have a slow connection):
$ sudo apt-get update -
Install Python and pip (this will install Python 2 and Python 3, and PIP):
$ sudo apt-get install python{,3}-pip -
Install gpiozero – this is the Python gpiozero support used in the script for monitoring the buttons:
$ sudo apt-get install python-gpiozero -
Install uinput – Python keyboard press support used in the script:
$ sudo pip install python-uinput
Once this stuff is installed, then you will be ready for the script.
-
-
@suaveant please note the images were made for a different script so make sure you use atarigpio.py
Here is the script and notes on installation and testing
I couldn't post a Python file, so create a text file and rename it atarigpio. Put the info from pastebin that i posted. You need to make sure the file extension is .py
Copy the script into the /home/pi folder
place python file in the home-pi folder.jpgNow you can go to the terminal and test it. Please note that if you are using a Putty terminal, it may not work right. You will need to do it directly with a monitor and keyboard on the Pi.
In the terminal, you run the script, sudo python Atarigpio.py and when you press the buttons, then you should see the correct output. When you are done testing, you can press Ctrl-C to stop the script.
manually test in terminal.jpgIf the script doesn't run, let me know the error, but it typically means that either Python, or gpiozero, or uinput, wasn't installed properly.
If the script does run and you can see the button outputs, then we can get it to load during boot.
Locate the rc.local file in the /etc/ folder
find rc.local.jpgModify the rc.local with the command line to run the script: python home/pi/Atarigpio.py &
modify rc.local to run script.jpgAdding the & (ampersand) at the end tells it to run in the background, so that is important to add that. Otherwise the booting process will seemingly stop with a black screen as your script will be running in the foreground.
Reboot and now the script should be running automatically. Please note that you need to give 0777 permissions to the script.
So after reboot, go back to the terminal and press your buttons and you should see them working. These should now appear directly on the command line.
test after boot.jpg -
@edmaul69 Thanks!
-
@suaveant yup. Let me know if it all works or if there are any issues. They use stellas default keys.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.