topher_csr
Posts: 8
Joined: Fri Jan 05, 2018 1:27 am

Confused on why only some of my run command code is working

Thu Jan 11, 2018 4:45 pm

Hello,

I am working on a project linking a Blinkt! LED board to functionality in RetroPie. The basic idea being that launching a game in each individual system, will change the color that Blinkt! displays. I have gotten 2 systems to work so far, but the rest for some reason will turn off the LED's that were on before it, but not light their assigned color. the Python scripts are identical to each other, expect for the color values and will all work when i execute them manually. Here is what i have so far.

in
/opt/retropie/configs/all/runcommand-onstart.sh.

Code: Select all

#!/bin/bash

# get system from parameters
system=$1

# run special python script for each system
case "$system" in
    nes) python /path/to/nes.py
        ;;
    snes) python /path/to/snes.py
        ;;
    sega) python /path/to/sega.py
        ;;
   n64)   python /path/to/n64.py
       ;;
    *) python /path/to/reset.py
        ;;

esac
The NES and SNES script will work well, and the reset.py script works on exit (resets to white). I have tried to changing the positions of the file paths and no matter where the NES and SNES file paths are in the list they work, and no matter where the "Sega" path is, it will not. i have 2 of the 5 systems loaded working currently.

Would anyone have any ideas what i could be missing?

thanks!

scotty101
Posts: 3100
Joined: Fri Jun 08, 2012 6:03 pm

Re: Confused on why only some of my run command code is working

Thu Jan 11, 2018 5:36 pm

Why not pass the system name to a single python program and have python decide what to do with the blinkt LEDs rather than doing this with a bash script?
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

topher_csr
Posts: 8
Joined: Fri Jan 05, 2018 1:27 am

Re: Confused on why only some of my run command code is working

Thu Jan 11, 2018 6:53 pm

Why not pass the system name to a single python program and have python decide what to do with the blinkt LEDs rather than doing this with a bash script?
Any idea what that would look like? i am really new to all of this!

scotty101
Posts: 3100
Joined: Fri Jun 08, 2012 6:03 pm

Re: Confused on why only some of my run command code is working

Fri Jan 12, 2018 9:37 am

Code: Select all

import sys
#import blinkt code here

def set_colour(colour):
    ##Your code to set the blinkt colour
    pass

if __name__ == '__main__':
    if len(sys.argv) >= 1:
        platform = sys.argv[1]
    else:
        platform = ''

    if platform == 'snes':
        set_colour((255,0,0))
        print("Setting SNES Colours")
    elif platform == 'n64':
        set_colour((0,0,255))
        print("Setting N64 Colours")
    else:
        set_colour((0,0,0))
        print("Setting Default Colours")
If this code is called with the command

Code: Select all

python retro.py snes

it will set the colour to red.
The line "platform = sys.argv[1]" reads in the first argument passed to the python script and it expects this to be the name of a platform.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

topher_csr
Posts: 8
Joined: Fri Jan 05, 2018 1:27 am

Re: Confused on why only some of my run command code is working

Fri Jan 12, 2018 2:10 pm

That looks a little simpler than how i have it setup. I actually got it working last night by redoing the whole thing and making sure the system names matched up. thanks!

Return to “Add-ons”

Who is online

Users browsing this forum: No registered users and 3 guests