• Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
RetroPie forum home
  • Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

Syncing button leds with gameplay

Scheduled Pinned Locked Moved Help and Support
led buttonsled cledspicer
68 Posts 5 Posters 7.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H
    hopwon @Folly
    last edited by 22 Sept 2023, 18:53

    @Folly I use craft profiles, it only works for mame. You need a profile in the profiles dir called profile_arcade.xml and then you call emitter from "runcommand_onstart.sh" with LoadProfileByEmulator

    Craft profiles really take the heavy lifting out of LEDSpicer config and its an awesome feature.

    This is my profile_arcade.xml - there is nothing in it...

    <?xml version="1.0" encoding="UTF-8"?>
    <LEDSpicer
    	version="1.0"
    	type="Profile"
    	backgroundColor="Black"
    >
    </LEDSpicer>
    

    After that LEDSpicer takes care of the rest.

    I'll try and do a bit more of a write up but Friday night is calling! But check out this link for a guide on as I used it to eventually decode and get LEDSpicer running...

    LEDSpicer on attractmode

    F 3 Replies Last reply 22 Sept 2023, 19:12 Reply Quote 0
    • F
      Folly @hopwon
      last edited by Folly 22 Sept 2023, 19:12

      @hopwon

      I want to get it working before I implement in emulationstation.

      Ok, so I do need the emitter.

      First I started with :

      sudo ledspicerd -f
      

      So for galaga I tried the command but got an error :

      pi@raspberrypi:~ $ emitter LoadProfileByEmulator galaga arcade
      Error: Failed to open device 0xd209:0x1700 id 1
      Failed to execute rotator 2 1 '2' 1 1 '2'
      

      The led that I attached burns but there is no other effect when starting galaga.
      Any ideas ?

      All commands are done over 3 terminal consoles.

      1 Reply Last reply Reply Quote 0
      • F
        Folly @hopwon
        last edited by Folly 22 Sept 2023, 20:21

        @hopwon

        I am really not sure if I should spend more time on this.
        Ledspicer seems a really nice and advanced program but I am missing the bigger picture on how it works and how all configs and xml's are connected to each other.
        Perhaps I will ditch the elements from the ledspicer.conf except one.
        That way I can see if 1 element will react if not I will probably stop trying.

        Ps.
        I have send a message to @MeduZaPaT hope he can help.

        M 1 Reply Last reply 25 Sept 2023, 00:46 Reply Quote 0
        • M
          MeduZaPaT @hopwon
          last edited by MeduZaPaT 24 Sept 2023, 18:35

          @hopwon
          Hey, I just read this, yes you will be able to do this, I read the whole section and looks like you are close:
          you have this:
          1 mame is sending the network data
          2 ledspicer is set and running
          3 you have a profile to load the galaga input.
          4 you got the mapping names from mame (led0 and led1)

          • Create a profile called galaga.xml inside arcade inside profiles
          • Create a input called galaga.xml inside inputs
          • test the profile by running ledspicerd -p galaga

          profile file galaga.xml:

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

          Input file galaga.xml:

          <?xml version="1.0" encoding="UTF-8"?>
          <LEDSpicer
              version="1.0"
              type="Input"
              name="Mame"
          >
                  <map
                      type="Element"
                      target="P1_START"
                      trigger="led0"
                      color="White"                      <!-- <<< The color to change -->
                      filter="Normal"                    <!-- <<< Filter to use -->
                  />
                  <map
                      type="Element"
                      target="P2_START"
                      trigger="led1"
                      color="White"                      <!-- <<< The color to change -->
                      filter="Normal"                    <!-- <<< Filter to use -->
                  />
          </LEDSpicer>
          
          

          you need to place the files in the correct directories:

          ledspicer
             |----animations
             |----inputs
             |----profiles
                   |----arcade
                   |----nes
                   |----[another emulator system name here and so on]
          

          Sorry for the late response, I am working on the LEDSpicer UI to make your life much, much easier

          LEDSpicer

          F 1 Reply Last reply 24 Sept 2023, 21:06 Reply Quote 1
          • F
            Folly @MeduZaPaT
            last edited by Folly 24 Sept 2023, 21:06

            @MeduZaPaT

            Thank you for your reply !

            I used your xml's.

            I understand your post like this :

            • create a profile galaga.xml file inside /usr/share/ledspicer/profiles/arcade/
            • create an input galaga.xml file inside /usr/share/ledspicer/input/
            • run mame with galaga and "-output network" (tested and working)
            • run ledspicerd -p galaga to test and get it working (got errors)

            Now I got this output :

            pi@raspberrypi:~ $ ledspicerd -p galaga
            Program terminated by error: Unable to read the file /usr/share/ledspicer/profiles/galaga.xml
            Error=XML_ERROR_FILE_NOT_FOUND ErrorID=3 (0x3) Line number=0: filename=/usr/share/ledspicer/profiles/galaga.xml
            
            • so I moved the profile file one folder up in /usr/share/ledspicer/profiles/ (solved not finding the file)
              (edit : another solution is not moving the file and use ' ledspicerd -p arcade/galaga')

            Then got this output :

            pi@raspberrypi:~ $ ledspicerd -p galaga
            Program terminated by error: Unable to read the file /usr/share/ledspicer/inputs/galaga.xml Error=XML_ERROR_PARSING_ELEMENT ErrorID=6 (0x6) Line number=7
            

            My ledspicer.conf is in /etc/ and I connected one green led to gpio 4 :

            <?xml version="1.0" encoding="UTF-8"?>
            <LEDSpicer
                version="1.0"
                type="Configuration"
                fps="30"
                port="16161"
                colors="basicColors"
                loglevel="Info"
                userId="1000"
                groupId="1000"
                craftProfile="true"
            >
                <devices>
                    <device
                        name="RaspberryPi"
                        boardId="1"
                    >
                        <element
                            name="P1_START"
            		green="4"
                            red="5"
                            blue="6"		
            		defaultColor="Green"
                        />
                    </device>
                </devices>
                <layout defaultProfile="profile_arcade">
                    <group name="Player1">
                        <element name="P1_START"/>
                    </group>    
                </layout>
            </LEDSpicer>
            

            Can you see where the error is ?

            Btw. using "sudo ledspicer -p galaga" did not make any difference.

            1 Reply Last reply Reply Quote 0
            • M
              MeduZaPaT @Folly
              last edited by 25 Sept 2023, 00:46

              @Folly sorry, I wrote that out of my head :D

              Yes, I can see the error "XML_ERROR_PARSING_ELEMENT" means that P2_START does not exist :D

              My 1st mistake was with the run command, please run ledspicerd -p galaga, you already solved that by moving the file to the correct place.
              My 2nd mistake was to assume that you have a full LEDSpicer config, I added the player 2 start button, but does not exist in the conf (that is why it error out), here is the correct input file:
              Input file galaga.xml:

              <?xml version="1.0" encoding="UTF-8"?>
              <LEDSpicer
                  version="1.0"
                  type="Input"
                  name="Mame"
              >
                      <map
                          type="Element"
                          target="P1_START"
                          trigger="led0"
                          color="White"
                          filter="Normal"
                      />
              </LEDSpicer>
              

              Try that and let me know!
              I can help you to setup your ledspicer, do you like to chat with me on slack? I can send you an invitation to the LEDSpicer group.

              LEDSpicer

              F 1 Reply Last reply 25 Sept 2023, 04:26 Reply Quote 1
              • F
                Folly @MeduZaPaT
                last edited by 25 Sept 2023, 04:26

                @MeduZaPaT said in Syncing button leds with gameplay:

                I can help you to setup your ledspicer, do you like to chat with me on slack? I can send you an invitation to the LEDSpicer group.

                That's very nice of you. ;)
                I wouldn't mind but then nobody can see the progress over here.
                There are probably more people in the future that want to use this.
                With this topic they will be able to find the information more easily.
                Also I will be able to use the information to get using it to a higher level.
                Do you agree ?

                My 1st mistake was with the run command, please run ledspicerd -p galaga, you already solved that by moving the file to the correct place.

                I found that this will also work keeping galaga.xml inside /usr/share/ledspicer/profiles/arcade/ :

                pi@raspberrypi:~ $ ledspicerd -p arcade/galaga
                
                Default Profile:arcade/galaga
                * Background color: Black
                
                * Input plugins:
                ------------------------------
                Type: Mame
                Elements and Groups mapping:
                Target: P1_START
                Trigger: led0
                Color: White
                Filter: Normal
                
                ------------------------------
                

                So I got a working test output now.

                What is the next phase to get the led blink ?
                Do I use run mame and use "sudo ledspicerd -f" together with 'emitter LoadProfileByEmulator galaga arcade' ?
                Tried above but it didn't work.

                M 1 Reply Last reply 25 Sept 2023, 21:03 Reply Quote 1
                • M
                  MeduZaPaT @Folly
                  last edited by MeduZaPaT 25 Sept 2023, 21:03

                  @Folly I complete agree :)
                  anything we do, should be posted here for future use.

                  Based on your results, looks like the profile it is working fine, it passed the test
                  I discourage running ledspicer with sudo, but is up to you :)

                  Now we can try it on the real hardware.

                  The next phase is to run ledspicer daemon and check if that profile is doing what it should do.

                  • Just to be sure that ledspicer is not running, use this command:
                  killall -15 ledspicerd
                  
                  • Now run ledspicerd in foreground mode, so we can check debug data and errors.
                  ledspicerd -f
                  
                  • That command will launch the ledspicer service and keep the terminal busy displaying some debug data.
                  • open Galaga with MAME, so we get the MAME output.
                  • now open a second terminal and type this
                  emitter LoadProfile arcade/galaga
                  

                  or

                  emitter LoadProfileByEmulator galaga arcade
                  
                  • emitter will ask ledspicer to run the Galaga profile.
                    At this point, you will see the P1_START element been controlled by MAME
                  • To stop ledspicer just press CONTROL C on the terminal that is running.

                  Let me know the results.

                  LEDSpicer

                  F 2 Replies Last reply 26 Sept 2023, 07:12 Reply Quote 1
                  • F
                    Folly @MeduZaPaT
                    last edited by Folly 26 Sept 2023, 07:12

                    @MeduZaPaT said in Syncing button leds with gameplay:

                    @Folly I complete agree :)
                    anything we do, should be posted here for future use.

                    Perfect !

                    Based on your results, looks like the profile it is working fine, it passed the test

                    I agree, I think it should work now.
                    Although in my ledspicer.conf the default color is Green.
                    Not sure how this works but in the galaga.xml we use White.
                    Does that matter ?

                    I discourage running ledspicer with sudo, but is up to you :)

                    Sure, running without that should be the case.
                    However the when using the GPIO of the raspberrypi with your program the led doesn't blink using it without sudo.
                    Here you can find the information of that test.
                    Perhaps I need to add the GPIO to the user pi group.
                    Strange thing is that raspi-gpio will work without sudo
                    Will have a look at that later.

                    Now we can try it on the real hardware.
                    Let me know the results.

                    Edit :
                    Great !!!
                    It works ;-)
                    Will take some time tomorrow to see If I can add some more stuff to it.

                    Just as you said, I got it working with :

                    sudo ledspicerd -f
                    

                    &

                    emitter LoadProfile arcade/galaga
                    or
                    emitter LoadProfileByEmulator galaga arcade

                    I looked again at the permissions and groups for gpio.
                    Seems pi is part of the gpio group, also is dialout as I read that has to be in it as well to use the gpio as regular user.
                    As raspi-gpio also works without sudo one would expect ledspicer would too.
                    Is your check ok in LEDSpicer-development/src/devices/RaspberryPiGPIO/RaspberryPi.cpp as this throws a failed to initialized.
                    (see that there is a typo should be failed to initialise)

                    1 Reply Last reply Reply Quote 1
                    • F
                      Folly @hopwon
                      last edited by 27 Sept 2023, 17:41

                      @hopwon

                      Are you still around ?

                      H 1 Reply Last reply 29 Sept 2023, 13:37 Reply Quote 0
                      • F
                        Folly @MeduZaPaT
                        last edited by Folly 27 Sept 2023, 17:55

                        @MeduZaPaT @hopwon

                        I added Player2 and P2_START to the ledspicer.conf and the galaga.xml.
                        I also assigned all green,red and blue from P1_START to GPIO 4 and P2_START to 5.
                        So now the full mame network output works and outputting it to two GPIO's.
                        I can confirm that MAME and lr-mame works and most likely lr-mess does too.
                        We are now at version 258.

                        I integrated ledspicer into RetroPie in a different way by using
                        (paste them in /opt/retropie/configs/all) :

                        • runcommand-onstart.sh
                        • runcommand-onlaunch.sh
                        • runcommand-onend.sh

                        runcommand-onstart.sh :

                        echo Load LEDSpicer deamon
                        #sudo ledspicerd -f &
                        sudo ledspicerd #edit : changed, see next post !

                        runcommand-onlaunch.sh :

                        # Get system name
                        system=$1
                        emulator=$2
                        rom=$3
                        command=$4
                        # rom_bn receives $rom excluding everything from the first char to the last slash '/'
                        rom_bn="${rom##*/}"
                        # rom_bn receives $rom_bn excluding everything from the last char to the first dot '.'
                        rom_bn="${rom_bn%.*}"
                        emitter LoadProfile $system/$rom_bn

                        runcommand-onend.sh

                        echo Kill LEDSpicer deamon
                        killall -15 ledspicerd

                        Would like to add some impulse / Blinker xml's too.
                        Tried some stuff but it did not work.
                        If I want to combine "mame imput" and "impulse" or "Blinker" xml's how do I do that.
                        Must I load multiple profiles with emitter to accomplish that ?

                        M 1 Reply Last reply 27 Sept 2023, 20:16 Reply Quote 1
                        • M
                          MeduZaPaT @Folly
                          last edited by MeduZaPaT 27 Sept 2023, 20:16

                          @Folly said in Syncing button leds with gameplay:

                          @MeduZaPaT @hopwon

                          I added Player2 and P2_START to the ledspicer.conf and the galaga.xml.
                          I also assigned all green,red and blue from P1_START to GPIO 4 and P2_START to 5.
                          So now the full mame network output works and outputting it to two GPIO's.
                          I can confirm that MAME and lr-mame works and most likely lr-mess does too.
                          We are now at version 258.

                          Excellent news!

                          I integrated ledspicer into RetroPie in a different way by using
                          (paste them in /opt/retropie/configs/all) :

                          • runcommand-onstart.sh
                          • runcommand-onlaunch.sh
                          • runcommand-onend.sh

                          runcommand-onstart.sh :

                          echo Load LEDSpicer deamon
                          sudo ledspicerd -f &

                          runcommand-onlaunch.sh :

                          # Get system name
                          system=$1
                          emulator=$2
                          rom=$3
                          command=$4
                          # rom_bn receives $rom excluding everything from the first char to the last slash '/'
                          rom_bn="${rom##*/}"
                          # rom_bn receives $rom_bn excluding everything from the last char to the first dot '.'
                          rom_bn="${rom_bn%.*}"
                          emitter LoadProfile $system/$rom_bn

                          runcommand-onend.sh

                          echo Kill LEDSpicer deamon
                          killall -15 ledspicerd

                          Good Work.
                          Just note that ledspicerd -f is only for testing,
                          What I mean is, the -f is not necessary for normal use (just ledspicerd is more than ok) but, while testing, gives nice debug output.
                          Also for normal use, when you get everything the way you want working, in the config, set LogLevel to Warning, so the log file don't eat too much space.
                          So change:

                          sudo ledspicerd -f &
                          

                          with

                          sudo ledspicerd
                          

                          I will check on my RPI how I did the permissions so the GPIO was accessible to the user and come back to you.

                          Would like to add some impulse / Blinker xml's too.
                          Tried some stuff but it did not work.
                          If I want to combine "mame imput" and "impulse" or "Blinker" xml's how do I do that.
                          Must I load multiple profiles with emitter to accomplish that ?

                          Paste the other plugins you need help with, I will fix the errors for you.

                          BTW, I am working on the dialog to add Input plugins right now :)

                          a78fbb24-fec3-46f0-918d-4515c59a243c-image.png

                          LEDSpicer

                          H 1 Reply Last reply 3 Oct 2023, 17:23 Reply Quote 1
                          • H
                            hopwon @Folly
                            last edited by 29 Sept 2023, 13:37

                            @Folly Sorry, was tied up all week. Am back now and busy catching up. I can put some time in this weekend to work on this. @MeduZaPaT Thanks for joining in!

                            F 1 Reply Last reply 29 Sept 2023, 17:01 Reply Quote 2
                            • F
                              Folly @hopwon
                              last edited by 29 Sept 2023, 17:01

                              @hopwon

                              Sure, welcome back again ;-)

                              H 1 Reply Last reply 30 Sept 2023, 08:18 Reply Quote 1
                              • H
                                hopwon @Folly
                                last edited by 30 Sept 2023, 08:18

                                @Folly @MeduZaPaT I have it nearly working but I think my issue now is network.
                                Following the instructions above, I have created the profile for the game, ledspicerd -p arcade/invaders works and produces output but nothing in game.
                                Whilst I have the game up and running, trying netcat (nc -v 127.0.0.1 8000) produces an error:

                                nc: connect to 127.0.0.1 port 8000 (tcp) failed: Connection refused
                                

                                Running with -output console, I see the led0 & led1 in the runcommand.log.

                                I think this is a network rather than configuration issue. NC works if I set up a server on another screen (nc -l -p localhost) then run nc -v localhost, the command is accepted but no output fro mame.
                                I can confirm mame is running and the game is loaded OK.
                                Where to look now, any ideas?

                                M F 3 Replies Last reply 30 Sept 2023, 14:33 Reply Quote 0
                                • M
                                  MeduZaPaT @hopwon
                                  last edited by 30 Sept 2023, 14:33

                                  @hopwon That looks like MAME is not opening the network port.
                                  Can you check the MAME configuration? It is some replies above.
                                  Yo need to set MAME to send output data using the network, so nc or ledspicer can pick that info.

                                  LEDSpicer

                                  1 Reply Last reply Reply Quote 0
                                  • F
                                    Folly @hopwon
                                    last edited by Folly 30 Sept 2023, 15:37

                                    removed double post

                                    1 Reply Last reply Reply Quote 0
                                    • F
                                      Folly @hopwon
                                      last edited by Folly 30 Sept 2023, 15:37

                                      @hopwon said in Syncing button leds with gameplay:

                                      @Folly @MeduZaPaT I have it nearly working but I think my issue now is network.
                                      Following the instructions above, I have created the profile for the game, ledspicerd -p arcade/invaders works and produces output but nothing in game.
                                      Whilst I have the game up and running, trying netcat (nc -v 127.0.0.1 8000) produces an error:

                                      nc: connect to 127.0.0.1 port 8000 (tcp) failed: Connection refused
                                      

                                      Running with -output console, I see the led0 & led1 in the runcommand.log.

                                      I think this is a network rather than configuration issue. NC works if I set up a server on another screen (nc -l -p localhost) then run nc -v localhost, the command is accepted but no output fro mame.
                                      I can confirm mame is running and the game is loaded OK.
                                      Where to look now, any ideas?

                                      I checked invaders on my laptop.
                                      I had no output in both situations (network and console).
                                      I am not able to check the source code of invaders now as I cannot download it now.
                                      I will check it on my pi.
                                      I checked other drivers yesterday and you will be able to find whether there is led output or not in the source code.
                                      For now it seems invaders doesn't have it.

                                      Did you load nc after mame or before ?
                                      Make sure you run mame first and then nc.
                                      I use socat now for checking, it works much better as it will output line by line with : ,cr .
                                      Make sure you install it first :

                                      sudo apt install socat
                                      

                                      Then use :

                                      socat - TCP4:0:8000,cr
                                      

                                      You will get the same output as you get when outputting to the console.

                                      Edit :
                                      I looked at the source of invaders :

                                      pi@raspberrypi:~ $ /opt/retropie/emulators/mame/mame -listsource invaders
                                      invaders         midw8080/mw8080bw.cpp
                                      

                                      (is in src/mame/.....)
                                      Searching in mw8080bw.h on "output_finder" looks like it can output to lamps :

                                      output_finder<16> m_exp_lamps;
                                      output_finder<4> m_torp_lamps;
                                      

                                      Not sure why there is no output either.

                                      H 1 Reply Last reply 2 Oct 2023, 06:40 Reply Quote 0
                                      • H
                                        hopwon @Folly
                                        last edited by 2 Oct 2023, 06:40

                                        @Folly Thanks for the info, I just assuumed Invaders would work! I will download the correct version of Galaga (not sure what version I have but it doesn't work with lr-mame) then I am working on the same game.
                                        @MeduZaPaT You are correct I had not configured mame for network output. Thanks for the tip

                                        H 1 Reply Last reply 2 Oct 2023, 10:29 Reply Quote 1
                                        • H
                                          hopwon @hopwon
                                          last edited by 2 Oct 2023, 10:29

                                          @hopwon Waaaahooooooo! I did it. Well I have now got -network working for mame and lr-mame

                                          I could not get the correct ROM version for mame/lr-mame for Galaga so I used Galaxians instead:

                                          socat - TCP4:0:8000,cr
                                          mame_start = galaxian
                                          lamp0 = 1
                                          lamp0 = 0
                                          lamp0 = 1
                                          lamp0 = 0
                                          lamp0 = 1
                                          lamp0 = 0
                                          ...
                                          ...
                                          
                                          

                                          This behavior is the games starts, put a coin in and it start flashing Start (lamp0 on and off) until Start is pressed and then it stops flashing. As long as there is credit in, when a game ends it starts flashing the Start button (if there is credit, if not, it stays off).
                                          Now to set up LEDSpicer mame plugin...
                                          I will update later

                                          1 Reply Last reply Reply Quote 1
                                          52 out of 68
                                          • First post
                                            52/68
                                            Last post

                                          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.

                                            This community forum collects and processes your personal information.
                                            consent.not_received