Forum Replies Created
-
AuthorPosts
-
04/02/2016 at 13:37 in reply to: Simple 1 button GPIO on off switch: 1 switch, 2 wires, 10 lines of code #122204kiwijam777Participant
So what did you guys do differently to get it to work without the I/o error?
03/31/2016 at 21:24 in reply to: Simple 1 button GPIO on off switch: 1 switch, 2 wires, 10 lines of code #122117kiwijam777ParticipantSorry about the misspell in RC.local. I have mine named something sightly different so I made a quick edit before I copied it over. Again, my apologies.
With the switch you have to hold it down in order for it to turn off or on. I set the timing to 0 so it would be the quickest possible. Are you holding it down or just pressing it?
And this is for a momentary switch by the way that could also be your problem. I have another version I use for a toggle on and off switch.
03/30/2016 at 17:51 in reply to: Simple 1 button GPIO on off switch: 1 switch, 2 wires, 10 lines of code #121989kiwijam777ParticipantHere are copies of my files, in the attached zip:
/etc/rc.local
/home/pi/scripts/shutdown.shI drop these into every new pi i have, and then i reboot and they work. If they dont work for you i am not sure what to suggest. Do you have the the folders “/sys/class/gpio”? If not, I think you can do:
sudo apt-get update
and
sudo apt-get install rpi.gpio03/27/2016 at 01:42 in reply to: Simple 1 button GPIO on off switch: 1 switch, 2 wires, 10 lines of code #121587kiwijam777ParticipantAre you sure you named the file correctly? Check by typing:
ls /home/pi/scripts/
<enter>
Do you see it? Is it spelled correctly?If not, Did you first create the folder and then the shutdown.sh file?
cd /home/pi/
<enter>
sudo mkdir scripts
<enter>
sudo nano shutdown.sh
<enter>
From here, you are in the file where you put all the text above. Exit and save. Now you are back at the command line. Try this to change permissions:
sudo chown pi shutdown.sh
<enter>
Now test it out again.03/26/2016 at 23:44 in reply to: Simple 1 button GPIO on off switch: 1 switch, 2 wires, 10 lines of code #121579kiwijam777ParticipantIt worked for me until it didn’t for one particular switch. After troubleshooting I found out there was an error in the code; it didn’t need the line to go “high” since the 6 pins on that end are always high. Try this one:
Create a file called “/home/pi/scripts/shutdown.sh”
Inside the file, type.#!/bin/bash
echo “3” > /sys/class/gpio/export
echo “in” > /sys/class/gpio/gpio3/direction
while [ “$(cat /sys/class/gpio/gpio3/value)” != ‘0’ ]
do
sleep 1
done
poweroff &
exit 0Remember you still have to refer to this file in RC.local
ADD SCRIPT TO LOAD AT STARTUP BY ADDING COMMAND TO /ETC/RC.LOCAL:
sudo nano /etc/rc.local
TYPE THE FOLLOWING IN RC.LOCAL AFTER THE LINE “#By default this script does nothing”:
sudo /home/pi/scripts/shutdown.sh &If you still can’t get it, I will email you the files.
04/22/2015 at 23:31 in reply to: Simple 1 button GPIO on off switch: 1 switch, 2 wires, 10 lines of code #95934kiwijam777Participantwhat version of RPI are you using? I have used the code above in its exact form on RPI2 and RPI B+, I have used it on the latest beta version of retropie and a 6 month old version of retropie. In all cases, I used the code as stated above and it worked, quotes and all. Also in all cases rc.local had to have the ampersand at the end or the pi would never fully boot because it would be stuck waiting for the shutdown command. I needed rc.local to be exactly:
sudo /home/pi/scripts/shutdown.sh &kiwijam777ParticipantHere is the code for launching to MAME emulator only:
1. from command line type:
sudo nano /etc/rc.local
2. add the following text to the bottom:
sudo /opt/retropie/emulators/mame4all-pi/mame
3. Save the file and reboot.I looked all over for this answer and most of the things I found were out of date, so specific folders or files were not where the forums directed. I got it to work for MAME using the code above; it puts the script for launching MAME emulator from command line into the rc.local file. I dont think each emulator launches the same way, so you may want to search for the code to launch whatever emulator you choose from command line, and put that into the rc.local file.
This will bypass emulation station going straight to the emulator. If i press esc on my keyboard (or the equivalent mapped button press for controllers) I can still get back to emulation station (if I really want to). That way I can still take advantage of the awesomeness of ES and all the ROM/controller/button configurations, or F4 to access command line.
If you want to launch to a single game, I think you just have to list the ROM file aafter the emulator command:
sudo /opt/retropie/emulators/mame4all-pi/mame ROMFILENAME
kiwijam777ParticipantHere is the code:
1. from command line type:
sudo nano /etc/rc.local
2. add the following text to the bottom:
sudo /opt/retropie/emulators/mame4all-pi/mame
3. Save the file and reboot.I looked all over for this answer and most of the things I found were out of date, so specific folders or files were not where the forums directed. I got it to work for MAME using the code above; it puts the script for launching MAME emulator from command line into the rc.local file. I dont think each emulator launches the same way, so you may want to search for the code to launch whatever emulator you choose from command line, and put that into the rc.local file.
This will bypass emulation station going straight to the emulator. If i press esc on my keyboard (or the equivalent mapped button press for controllers) I can still get back to emulation station (if I really want to). That way I can still take advantage of the awesomeness of ES and all the ROM/controller/button configurations, or F4 to access command line.
I set up my pi this way so my arcade station boots just to mame where i only have 4 player games loaded for my 4 player arcade station i built for our church youth group. Since they are only interacting with a single emulator with no buttons for exiting, nobody can accidentally go into configuration menus and mess things up. I have a GPIO button for shutdown command so they dont have to use the emulation station “shutdown” menus. I really wish the ES menus for shutdown were configurable. :(
kiwijam777ParticipantI looked all over for this answer and most of the things I found were out of date, so specific folders or files were not where the forums directed.
I got it to work for mame using the code below; it puts the script for launching mame from command line into the rc.local file. I dont think each emulator launches the same way, so you may want to search for the code to launch whatever emulator you choose from command line, and put that into the rc.local file.
Here is the code:
1. from command line type:
sudo nano /etc/rc.local
2. add the following text to the bottom (check your pi to see if “mame4all-pi” or just “mame4all”):
sudo /opt/retropie/emulators/mame4all-pi/mame
3. Save the file and reboot.
4. Go to mame config file to setup joystick to correct input so you can use your joystick/controller to secect a game in the MAME emulator game menu:
sudo nano /opt/retropie/emulators/mame4all-pi/mame.cfg
Scroll to the bottom to see the contoller/js code.This will bypass emulation station going straight to the emulator. If i press esc on my keyboard (or the equivalent mapped button press for controllers) I can get back to emulation station if I really want. That way I can still take advantage of the awesomeness of ES and all the ROM/controller/button configurations, or F4 to access command line.
I set up my pi this way so my arcade station boots just to mame where i only have 4 player games loaded for my 4 player arcade station i built for our church youth group. Since they are only interacting with a single emulator with no buttons for exiting, nobody can accidentally go into configuration menus and mess things up. I have a GPIO button for shutdown command so they dont have to use the emulation station “shutdown” menus. I really wish the ES menus for shutdown were configurable. :(
kiwijam777Participant“Its there on version 2.4”???
What is where? There is a config file listing all hotkey commands? Where?kiwijam777ParticipantSame Mame ROM issue. Must be in .zip folders.to get them to work. I found I had to rename .ZIP to .zip (lowercase) to get them to work. Had to make sure no upper case anywhere in filename. not sure if you have the same issue but that resolve my issue.
For hotkeys, I disabled them by using “input_enable_hotkey = false” and disabled hotkey button “#input_enable_hotkey_btn = ” 8″ “. _btn is for joysticks and controllers. Without _btn is for keyboard. With this configuration in have dedicated buttons to load, save, reset, exit emulator, vol up, and vol down.
kiwijam777ParticipantYou could mix and match if you were able to define your hotkey commands, like in a config file or something where you could list which commands are subject to a hotkey. Maybe it could be a new command called magickey and you could define several magic keys (magickey1_btn=”9″, magickey2_btn=”8″) and magickey lists (lists of commands available when a particular magickey is pressed). By the way, I think that video is old, I don’t see the hotkey.sh because the directory from the video doesn’t exist.
kiwijam777ParticipantDoes anyone know if there a way to get the “shutdown system” option in the first menu window? Or how to map “sudo shutdown -h now” to a button or combo of buttons?
-
AuthorPosts