Attract-Mode Support > Scripting

LEDSpicer Emitter Plugin & LEDSpicer Tutorial

<< < (2/3) > >>

MV19:
Hi. I've got this installed and all seems OK but there's no rom profiles set up. There is a gameData.xml file that comes with LEDSpicer but I don't think that's useable in the way your plugin needs it. Do we have to create all the profiles for each game manually?

Also, does this work with Retroarch or do I have to use a standalone MAME emulator?

Cheers.

Sinistar:

--- Quote from: mahuti on December 12, 2020, 09:49:02 PM ---This was built just for  LEDSpicer. It currently calls LEDspicer's Emitter's LoadProfileByEmulator command based on the rom, either by a command key, or automatically while browsing the romlist.

I am adding the ability to load a profile at game launch as well (which will be useful for also driving U360s and Servostiks, etc.) I should have that up in the next day or so.

It has been tested on Rpi3 and Rpi4. I use Raspberry Pi 4s and 3s on my cabs, so yep.

--- End quote ---

Hey I hate to ask you to link me to the LED Spicer for PI 4 script as i know google is a thing but i want to make sure im using exactly what you're using (good job by the way) .

mahuti:

--- Quote ---Hey I hate to ask you to link me to the LED Spicer for PI 4 script as i know google is a thing but i want to make sure im using exactly what you're using (good job by the way) .
--- End quote ---

In the end of my first post, there's an "About LEDSpicer" area with a link to it.

mahuti:
@MV19. All of your questions are related to how LEDSpicer works. My plugin doesn't pull anything FROM  LEDSpicer, it just pushes data TO LEDSPicer. That said, I'll do my best to answer your questions anyway. I'll admit that LEDSpicer isn't the easiest thing to set up... it takes a bit of understanding to see how things go together. But I think I can give a quick tutorial on it to get anyone interested moving along.


--- Quote --- there's no rom profiles set up.

--- End quote ---

By default no, there aren't. You don't have to set up ANY rom profiles in LEDSpicer, unless you want to, though you do need a default.xml file in the profiles folder. You can use the "craftProfiles" option in the config file for use with arcade games (more on that later) and LEDSpicer will attempt to use the pre-scraped data from mame (gameData.xml) along with controls.ini (if available) and colors.ini (if available) to set lighting based on the games control scheme. So... one profile_arcade.xml file to manage thousands of roms.


--- Quote ---There is a gameData.xml file that comes with LEDSpicer but I don't think that's useable in the way your plugin needs it.

--- End quote ---

My plugin doesn't use anything from LEDSpicer, it just passes the information along to LEDSpicer, and then that does all of the work. gameData.xml is prescraped mame controls data which is used by LEDSpicer to try to dynamically set button configurations based on MAME's reported control scheme for each rom. It's pre-scraped and streamlined to make it work fast and use little memory.


--- Quote --- Do we have to create all the profiles for each game manually?
--- End quote ---

No. For a setup that uses arcade games along side consoles, likely you'd just need one profile per console, and one profile_arcade.xml file for arcades.


--- Quote ---Also, does this work with Retroarch or do I have to use a standalone MAME emulator?
--- End quote ---

It really doesn't interact with the system in any way, it just reacts to information that is passed to it. So, it works with Retroarch (which I use) as well as standalone MAME (which the author of LEDSpicer uses) and can work within AM, and really anything that can call the LEDSpicer Emitter or Rotator apps.

LEDSpicer Setup Tutorial
Before I begin, let me just say, there is a lot of documentation on the LEDSpicer site already. I'm not the author of LEDSpicer, but I do assist on the documentation somewhat, but there's a LOT of capabilities to document. Even though Patricio and I work on the docs to clarify things from time to time, there's just a lot to cover. The following tutorial should get you going with minimal effort hopefully.

Overall concepts
LEDSpicer requires you to:

1. Configure
configure how your LEDs are hooked up to devices, and what you want to call them
configure your logical groupings of LEDs (player1 group, player2 group, marquee, admin button group... whatever. naming is up to you... just know you'll refer to those groups in animations and things. You can have overlapping groups.
configure some options on how you'd like to handle arcade stuff... for instance craftProfiles and some of the other options makes it so you don't have to have a profile for every rom because it will use info from controls.ini and mame (gameData.xml) to try to dynamically light the right leds.

2. Create profiles
create a default profile named default.xml doesn't need much in it...
create a profile_arcade.xml file if you're running craft profiles

3. (optional) Create animations
(if you want animations) create some animation files. refer to them by name in your profiles

4. (optional) Use other plugins
There are a few other plugins available like "input"... if you wanna do that stuff, take a look at the LEDSpicer website for more info.

Step 1: Compile and Install LEDSpicer

Update Retropie to the latest version (Buster as of this writing). LEDSPicer requires tinyxml2 6.0+, which I could not get working on Stretch 4.3(ish) for the life of me due to and endless amount of missing dependencies. Soon as I udpated one thing, I had to update something else. The easiest route is on a fresh install, or a system with tinyxml2 6.0+ already set up.

Download to development folder


--- Code: --- cd ~/
mkdir develop
cd ~/develop
git clone https://github.com/meduzapat/LEDSpicer.git
cd LEDSpicer

--- End code ---
   
Load prerequisites & get tinyxml2


--- Code: ---sudo apt install build-essential pkg-config libtool libtinyxml2-dev libusb-1.0-0-dev libpthread-stubs0-dev -y
sudo apt install libpulse-dev -y
--- End code ---

Compile
my configure options include the boards that I'll use. These are all of the available options: --enable-nanoled--enable-pacdrive --enable-pacled64 --enable-ultimateio --enable-ledwiz32  --enable-howler --enable-raspberrypi Enables RaspberryPi GPIO


--- Code: ---sudo sh autogen.sh
 ./configure --enable-ultimateio --enable-ledwiz32 --enable-pacdrive --enable-alsaaudio
make clean
make -j5
sudo make install
--- End code ---


Figure out where your files are stored
LEDSpicer has 2 important things to edit. 1. ledspicer.conf (configuration file) and 2. ledspicer profile files
The configuration file is either in /etc/ledspicer.conf for most linux systems or the default for raspberry pi is /usr/local/etc/ledspicer.conf
The profiles for ledspicer is either stored in /usr/share/ledspicer  for most linux systems or the default for raspberry pi is /usr/local/share/ledspicer
The rest of the tutorial ASSUMES YOU'RE USING A RASPBERRY PI.

Install UDEV Rules
   

--- Code: ---sudo cp /usr/local/share/doc/ledspicer/examples/21-ledspicer.rules /etc/udev/rules.d/
sudo chmod 744 /etc/udev/rules.d/21-ledspicer.rules
sudo udevadm control --reload-rules && sudo udevadm trigger
--- End code ---

Add your user to users and input groups

--- Code: ---sudo usermod -a -G users pi #replace user with your username
sudo usermod -a -G input pi #replace user with your username
--- End code ---

Step 2: Configure

Copy & edit basic configuration
Here's the raspberry pi version of copying an example ledspicer.conf configuration file. For reference I've also attached my personal configuration file & profiles to this post

--- Code: ---sudo cp /usr/local/share/doc/ledspicer/examples/ledspicer.conf /usr/local/etc/ledspicer.conf
sudo pico /usr/local/etc/ledspicer.conf

--- End code ---
   


Once you have some of the basic files set up, you'll need to configure them. See my ledspicer.conf file for how I use it. Here's some of what i have set up in my conf file:


--- Code: ---<?xml version="1.0" encoding="UTF-8"?>
<LEDSpicer
    logLevel="Error"
    port="16161"
    version="1.0"
    type="Configuration"
    fps="30"
    userId="1000"
    groupId="1000"
    colors="myColors" <!-- I add stuff (like the colors ON(white) and OFF (black) to the basicColors.xml file, so I use one called myColors.xml -->
    craftProfile="true" <!-- I use craftProfile because this parameter makes it so arcade games can utilize controls.ini, gameData.xml and colors.ini to generate led lighting configurations for multiple roms using a  single profile -->
    colorsFile="true" <!-- uses colors.ini -->
    dataSource="controls.ini,file"  <!-- looks in controls.ini first, then gameData.xml (file) . see craftProfile above-->
>
--- End code ---


Add default profile

Profiles basically just tell LEDSpicer if you want to use animations or music or input plugins or whatever. Most of mine are pretty minimal. Check LEDSpicer's docs for more information. Things like "alwaysOnGroups" or "alwaysOnElements" may be important details for you, but i don't use them much. 


--- Code: ---sudo pico /usr/local/share/ledspicer/profiles/default.xml
--- End code ---

Mine has basically just this:


--- Code: ---<?xml version="1.0" encoding="UTF-8"?>
<LEDSpicer
        version="1.0"
        type="Profile"
        backgroundColor="Off"
>
<!-- whatever animations, plugins, etc goes here -->
</LEDSpicer>
--- End code ---

Create a "profile_arcade.xml" profile to use with craftProfile

The file can have basically nothing in it like my default.xml file. Mine says to use the "INPUT" plugin for 3 roms. You wouldn't need to have those in there though.

Here's my profile_arcade.xml file that I use:

--- Code: ---<?xml version="1.0" encoding="UTF-8"?>
<LEDSpicer
version="1.0"
type="Profile"
backgroundColor="Black"
>
<inputs>
    <input name="digdug"/>
<input name="galaga"/>
<input name="qbert" />
</inputs>
</LEDSpicer>

--- End code ---

Craft profile does the heavy lifting for arcade stuff so you don't have to have a profile for EVERY rom. If there is a profile for a specific rom you want to override the craft profile with, just add something like this: profiles/arcade/digdug.xml

Set up profiles for any consoles you want to run
you can name them whatever you'd like: "nes.xml" or "Nintendo Entertainment System.xml"... just remember that the name of the file will be used to load the profile. When using the Emitter plugin I made, whatever the "System Name" is set to in AttractMode will be used to call the profile. They NEED to match otherwise LEDSpicer won't know what you're looking for.

Set up any animations you want.
   
 Take a look at mine for an example.

Step 3: Setup LEDSpicer daemon to run as root at startup

Once you have some basic profiles and the configuration done, set up the system to run as a service. This is OPTIONAL, but if you have a dedicated cabinet, probably a good idea. If you don't want to run it like this, there are instructions further down on just running it in the background
   

--- Code: ---sudo cp /usr/local/share/doc/ledspicer/examples/ledspicerd.service /etc/systemd/system
sudo systemctl enable ledspicerd.service
--- End code ---

Restart.

Once you've restarted you can stop, restart or start the ledspicerd (yes ledspicerd with a d) daemon using:


--- Code: ---sudo service ledspicerd restart
sudo service ledspicerd stop
sudo service ledspicerd start

--- End code ---

ANY TIME a profile is edited, or the conf file is edited, you need to restart the service to use it.

Step 4: Use LEDSpicer's Emitter app to launch profiles

The Emitter app is what sends commands to LEDSPicer. LEDSPICER MUST BE RUNNING FOR THIS TO WORK. Here's an example that will launch a craft profile. All arcade systems (mame, daphne, fba, etc) should be called with "arcade" to use the craft profile system. Any other name will look for profiles in a folder of that name within the profiles folder.


--- Code: ---    emitter LoadProfileByEmulator digdug arcade
--- End code ---

example to load a specific profile. This profile would be named "attract.xml" within the profiles folder


--- Code: ---    emitter LoadProfile attract
--- End code ---

Additional Information and Useful Commands
You can also just launch the daemon any time (if the service is not set up, or not already running)

EACH OF THESE COMMANDS REQUIRES THE SERVICE NOT BE RUNNING ALREADY, so
--- Code: --- sudo service ledspicerd stop
--- End code ---
if you want to use these testing capabilities
Run LEDSpicer daemon in the backround

--- Code: ---    ledspicerd 
--- End code ---

Run LEDSpicer daemon in the foreground to check what it's doing

--- Code: ---    ledspicerd  -f
--- End code ---

Get help

--- Code: ---    ledspicerd  -h
--- End code ---

--- Code: ---    emitter -h
--- End code ---

Test Individual Leds

--- Code: ---    ledspicerd -l
--- End code ---
   
Test Configured Elements

--- Code: ---    ledspicerd -e
--- End code ---
   
Test profile
this is a good way to tell if your profile xml works or not if you're having problems.

--- Code: ---ledspicerd -p default
--- End code ---
if this errors out, it's likely due to an XML configuration issue.

Look at logs


--- Code: ---    cat /var/log/syslog | grep ledspicer
    cat /var/log/syslog | grep LEDSpicer
--- End code ---

To capture inputs of gamepads

   
--- Code: --- inputseeker
--- End code ---
   
To scan for events in MAME games (for the input profile), run this in a separate terminal window while running a mame rom
   
   
--- Code: ---nc -v localhost 8000
--- End code ---

To update: git pull from the development folder, then compile


Sinistar:

--- Quote from: mahuti on December 18, 2020, 07:36:19 PM ---
--- Quote ---Hey I hate to ask you to link me to the LED Spicer for PI 4 script as i know google is a thing but i want to make sure im using exactly what you're using (good job by the way) .
--- End quote ---

In the end of my first post, there's an "About LEDSpicer" area with a link to it.

--- End quote ---

Mahuti is this your software? great job by the way

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version