Programmable?
-
Hi,
Sorry if this is such a noobie question, I'm new to raspberry pi as well.I know raspberry pi is a tiny computer and therefore is completely programmable to do whatever I want. But with retropie running I imagine I have to modify it in some way in order to add functionality. Specifically, I'm thinking about turning a different set of LEDs depending on which emulator you select.
Is there a built-in way of doing these kinds of things? a script system maybe? Again, sorry for noobiness, my rapsberry pi hasn't even arrived yet, so I'm pretty clueless on the details.
-
First I would recommend you familiarize yourself with the basics of attaching and activating LED lights through software commands as a separate venture. Perhaps with a simple Raspbian install as there are plenty of guides out there for such a thing. From there you can install Retropie and alter the launch parameters in each "emulators.cfg" for the emulators you wish to associate with a light. These cfgs can be found in a folder for each respective emulator in /opt/retropie/configs/.
-
A cfg for each software is a good start. Does this allow for more than one software to be launched at the same time? That would be one way of doing it.
-
It depends on the situation. Most launch commands from the menu happen game by game, whereas others launch a governing emulator responsible for launching individual games. Either way can be scripted for your purposes though. Things will become clearer once you start to learn the specifics of turning an LED on and off with a terminal command. From there, if it's not obvious how to reuse that information within the individual "emulator.cgf" files, I'll be happy to help you to see it to conclusion.
-
Thanks :)
From what I read so far doesn't look hard to make a py program that controls stuff connected to the pins. I guess I'll now in a few days. I'll be back! :P -
It's a great idea for a project. I've got a smaller arcade build in the wings and I might use a similar method to have dynamic lcd-base marquee artwork based on the selected game.
-
I still haven't started playing with LEDs yet, but I did install raspbian and retropie to test the whole thing. I'll reinstall it with just raspbian in a minute but first I'd like to ask you, how would I edit anything with retropie installed? it seems to take over the system completely. I couldn't find a way to return to a regular raspbian terminal.
By the way I was kinda trying to avoid buying a mouse and keyboard for this since it would be used for a short time only, but I don't think there's any way to do the coding on my desktop, is there? I mean, surely it's possible, this is a tiny computer and I could even email the code to myself etc, but no convenient way of doing it.
-
You can SSH into Retropie and use the terminal from a different device like a computer or a smart phone. Do a search for a program called Putty also I use an app called Connectbot on my Android phone.
I've thought about this before but I don't have much experience in such cases. You might be interested in an addon board called PiGlow. It has 18 leds of different colors in a vortex shape with 6 leds on each "arm" or "wing" that you can program to do whatever you want. Run patterns. Blink certain colors to run in sequence. Whatever. I used to use it for Raspbmc with my granddaddy pi model b before the newer models came out. There was a piglow script it ran and an addon for Raspbmc that would let you monitor temperature, volume, memory, etc.
Here is a link I found where this guy has got it working on a Pi2: https://blog.robseder.com/2015/04/12/getting-a-piglow-to-work-with-a-raspberry-pi-2/
-
Oh, thanks! apparently I won't have to buy mouse and keyboard after all :) Putty works nicely here. I can browse files and edit them with those primitive but fully functional software, like nano and... actually, that's the only one I know of so far.
Made a dumb python code too :P small steps! Tomorrow I'll get me some LEDs and I should have them blinking in no time. I still can't find the cfg files though.
edit: I did find a few cfg files. They seem to be in different formats. I recognized xml in one. I still don't know how this can be used to create extra logic.
-
I think you want to look in to the various .sh files in /home/pi/RetroPie-Setup. these are what launch games, etc. you can probably trigger your own bash/etc scripts via these.
-
@dankcushions said in Programmable?:
I think you want to look in to the various .sh files in /home/pi/RetroPie-Setup.
As I look more and more into doing this same thing with dynamic marquees, it would seem that you're right in most cases. However, I have noticed that some "emulators.sh" files call out to the "/RetroPie-Setup" .sh files and others launch items directly. Depending on exactly what systems someone wants to represent with this feature might ultimately require using a hybrid approach where the need arises.
-
I googled sh file and it's like a windows bat file. That means we can run any kind of terminal commands from it, including starting background softwares or even directly controlling the LEDs from there. I haven't tested anything yet but this sounds promising.
I'm swamped with stuff to do until saturday, unfortunately. Oh well.
-
Anyone had any luck finding an useful sh file? I found a few but nothing that seems to get called when launching specific game or system etc.
-
I'm going from memory and it's late, but it would seem that in most cases, a system's "/opt/retropi/configs/*/emulators.sh" calls out to "/opt/retropie/supplementary/runcommand/runcommand.sh" for instructions on how to launch a given file based on which emulator you have chosen to launch it with. I've only noticed a few "ports" to deviate from from that, but there are probably only a few others.
I imagine that if you added the LED behavior to "runcommand.sh", then a specified system could theoretically initiate a certain LED despite the emulator chosen. I might be 167% off base with this as it's gleaned from a cursory examination and is now being relayed from memory at 3AM, but it's at least a place to start looking at more closely.
-
First: I didn't even realize that folder existed. "opt" seemed to uncharacteristic. Doh! Well, that runcommand.sh is a big wall of code, so it might take some time to decipher what it's doing and how to tweak it.
I didn't find any emulators.sh but .cfg instead, so I believe what happens is the opposite: runcommand gets called when you open a system, which then reads the corresponding cfg for what exactly to do. Therefore, I foresee this will be a lot more complicated than I first thought because it means we have to add logic to both files; add a new parameter to the cfg containing which leds to lit up, and then logic to the sh to read these values and do something about it.
I'm starting to get a bit pessimistic here. You know what would be ideal? if whatever launches the system looked for a file called customscript.py at the system folder and executed it if existed. That would be neat.
Anyway, I'll keep digging.
-
@diegzumillo said in Programmable?:
so I believe what happens is the opposite
I have been a little unsure of that from the beginning. Good to know.
Anyway, I'll keep digging.
Always the best way to find gold.
-
I hope this isn't considered spamming. But I can't seem to run a python script from the shell. I mean, it runs just fine if I execute the sh from the terminal (ssh) but when I open some random game (and I know it is calling runcommand) the python script doesn't get called apparently.
For example, if I just call ./runcommand.sh it lights up my LED (and nothing else happens, of course, because that's not how runcommand is supposed to be called normally). And the reason I know runcommand is getting called when I open a game is because I can break the file by adding gibberish, so the game throws an error if I try to launch it. So I'm confused.
-
Have you checked "/tmp/runcommand.log"? It might give some insight.
-
Just did. Nothing unusual there though.
edit: I just made a tiny itty bitty progress. I noticed some text flashed at the screen when I launched a game. I was under the impression anything printed to the terminal would appear on my ssh screen, but no. So I tried snapping a picture (only took me like 50 tries) and discovered it wasn't finding the py file! but only when launching a game. So this sh must be called from some other directory. So I added a pwn command, and 50 pictures later I got the result: it's being called from the supplementary/emulationstation/ directory. Putting the py file there works! I launch a game and my LED lits up.
Now to follow the trail. There are two files there that could be calling runcommands. The emulationstation.sh is way too simple and doesn't seem to be it. Then there's a emulationstation file without extension that seems to be some kind of complex file. It's not readable or editable, so there isn't much that can be done there.
-
SUCCESS!! It works!!
Oh boy, I was losing hope on this. OK, so here's how I solved this: I figured this runcommand had to be called by everything, every emulator, port etc, would call runcommand. But I didn't realize immediately that they were calling it with arguments specifying everything. It just so happens that argument $3 is the system. So all I have to do is add the line
sudo python mydumbassscript.py $3 &
and do whatever I want with this information there. Quick note: There might be a more elegant way of doing this but I put the script at the opt/retropie/supplementary/emulationstation/ because that's where the call always comes from apparently. Ideally I would specify a path but I can't seem to make that work.
Anyway, I'm happy this is kinda working! :)
edit: added "&" at the end of the line to make it run in the background.
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.