• Shutdown circuit advice

    Help and Support
    3
    0 Votes
    3 Posts
    333 Views
    K

    @Ashpool thanks for the pointer :)

    Got it working using that script.

    If it helps anyone else my /opt/retropie/configs/all/autostart.sh file looks like:

    sudo /home/pi/RetroPie/scripts/multi_switch.sh --mausberry & emulationstation #auto

    (All on one line in the file)

    I suspect my missing piece with the 'stock' mausberry install script was adding it to the autostart file, but this alternative script works so will stick with it. 👍

  • Mausberry changed?

    Help and Support
    3
    0 Votes
    3 Posts
    430 Views
    S

    OK so my mausberry finally came. And it looks like it is different but not too different as the 3V LED pad is present so my concern is null. I can confirm that they have terrible communication and shipping took forever. I only got an order confirmation after I threatened to dispute the credit card charge. never even got an initial email saying my order was received.
    IMG_8565 (1).jpg

  • 0 Votes
    11 Posts
    1k Views
    mituM

    @jamrom2 said in Issues with Mausberry shutdown script.:

    Have a safe and prosperous New Year!

    Glad you sorted it out and thank you for the nice words - Happy New Year to you too !

  • 0 Votes
    1 Posts
    290 Views
    No one has replied
  • 0 Votes
    2 Posts
    323 Views
    mituM

    @robertybob Check out @cyperghost's shutdown script - https://retropie.org.uk/forum/topic/17415/ - it supports multiple switches and can be adapted to work like you want w.r.t the reset switch.

  • 7 Votes
    10 Posts
    3k Views
    y-elloY

    @Clyde said in My SEGA Master System RetroPie build (in progress - almost done):

    Very nice! I always liked the design of the Sega Master System, much more than the JP & US versions of the Famicom/NES. The LEGO is a nice geeky way to fix things. 🤓

    Thanks!
    I love the SMS design too. The SG-1000II and the Mark III are beautiful too.
    The LEGOs, super glue and hot glue did the job great!

  • 0 Votes
    3 Posts
    694 Views
    P

    Does the GanepadBlock work with your PC?
    If not, it would seem to be an hardware issue with the GamepadBlock.

    Also, can you post an image of your hardware setup here?

  • 3 Votes
    12 Posts
    3k Views
    caver01C

    @cyperghost said in My second project--another Nespi case build:

    Can you post the script here please?
    Would like to use it as I up to now use the bash script....

    Here is the python script I am using to watch both buttons. This script is effectively my Mausberry script and my RESET script:

    #!/usr/bin/env python # Import the RPi.GPIO and OS import RPi.GPIO as GPIO import os import time # Define which GPIO pins u're using for the Mausberry IN, OUT # (which are reversed in the script because mbOut comes to pi as input), # and reset buttons (change this to whatever pin you use) mbIn = 24 mbOut = 23 resetBtn = 25 # GPIO port setup GPIO.setmode(GPIO.BCM) # Set pin numbering to BROADCOM GPIO numbering GPIO.setup(mbOut, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set up pin as an input, pulled down GPIO.setup(mbIn, GPIO.OUT) GPIO.output(mbIn, 1) # Set pin value to 1. Mausberry watches for this to change to zero GPIO.setup(resetBtn, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Set up pin as an input, pulled UP since shorting to GND # Define a function which will be called when Mausberry switch is triggered def interrupt_mbShutdown(channel): # Print indication to console print "You pressed the power button!" # Code for shutdown would go here os.system('sudo shutdown -h now') # Define a function which will be called when Mausberry switch is triggered def interrupt_resetBtn(channel): # Print indication to console print "You pressed the reset button!" # Code for reset would go here os.system('/home/pi/bin/exitemu.sh') # Enable shutdown switch interrupt to trigger on a raising edge (i.e. low-to-high transition) GPIO.add_event_detect(mbOut, GPIO.RISING, callback = interrupt_mbShutdown, bouncetime=1000) # Enable RESET button interrupt to trigger on a raising edge (i.e. low-to-high transition) GPIO.add_event_detect(resetBtn, GPIO.FALLING, callback = interrupt_resetBtn, bouncetime=1000) # -------------------------------------------------------------------- # Now just wait forever for the user to press a button # The sleep time doesn't really matter, make it long enough so it isn't wasting cpu cycles while 1: time.sleep(5)

    This gets called from my /etc/rc.local
    It also relies on the exitemu.sh which is a bash script that leverages insights from all of the previous work to kill the PID for whatever emulator might be running (returns you back to ES). I am just using the same script @lostless posted a while back. You could also just issue a sudo reboot. In any case, the second part I need to add is meleu's shutdown service to completely exit stuff when doing the full shutdown.

    So, I am not doing anything with soft shutdown requiring a diode/transistor. I have not gone that far yet because I am still using a sticky pushbutton instead of a momentary.

  • 0 Votes
    3 Posts
    913 Views
    retroprogrammerR

    Or get the proper raspberry pi power supply

  • Nespi Case help

    Help and Support
    6
    0 Votes
    6 Posts
    2k Views
    T

    @mitu True. I forgot they added the favorites/recents. I was referring to just the metadata. Good catch

  • 6 Votes
    57 Posts
    17k Views
    cyperghostC
    How to perform a software shutdown with the Mausberry and the diode/transistor hack?

    NOTE: This does only work on momentary switches!

    1. Prerequisites
    You need to solder a diode (1N400x type 1N4001 or 1N4002) or a transistor (NPN-Type, 2N3904, BC547 or BC337) to the Mausberry on/off switch.
    For the diode: Connect it between a GPIO and the mausberry button ground.
    The transistors needs to soldered between ground and positive to the switch and the base line is connected to the GPIO (maybe you need a resistor to control current flow)

    Therefore I strongly recommand the DIODE hack!

    Don't be afraid the Raspberry is in both ways protected against current backdraws! Use the diode or the right direction as shown in the box above....

    GPIO MAUSBERRY from Pie DIODE switch ground O---------------->|----------------O 1N4002

    More to read here

    2. Software part

    Create gpio-shutoff with sudo nano /lib/systemd/system-shutdown/gpio-shutoff Enter code from box below Make the script executable with sudo chmod +x /lib/systemd/system-shutdown/gpio-shutoff

    GPIO16 (or PIN 36 ) is just an example here and is my real setup

    #!/bin/sh # Perform Software Shutdown with Mausberry switch # cyperghost for retropie.org.uk # This is the GPIO pinconnected to the diode or transistor GPIOpinDIODE=16 if [ "$1" = "poweroff" ]; then echo $GPIOpinDIODE > /sys/class/gpio/export echo out > /sys/class/gpio/gpio$GPIOpinDIODE/direction echo 1 > /sys/class/gpio/gpio$GPIOpinDIODE/value sleep 0.5 echo 0 > /sys/class/gpio/gpio$GPIOpinDIODE/value sleep 0.5 fi

    3. Software script with proper Reset and Shutdown
    This is the full working bash script
    Installation:

    add it to /etc/rc.local/ add it to /opt/retropie/configs/all/autostart.sh` whatever case you select make the script executable with chmod +x scriptname.shand add sudo yourscript.sh & to choosen autostart

    This script adds:

    Working Reset button
    1.1 if an emulator is running it will end this
    1.2 if ES is running (without emulator) a restart of ES will be made Working shutdown button #!/bin/bash # Mausberry shutdown script v3 # # extended by cyperghost for # Yet annother NESPi case # Tested version 15/01/18 es_action() { case $1 in check) [[ -f "/dev/shm/runcommand.info" ]] && \ emu="$(sed '4!d; s/\([\\"]\|[[:alnum:]_]\+=[^ ]* \)//g; s/[][(){}^$*.|+? ]/\\&/g' /dev/shm/runcommand.info)" && \ [[ -n "$emu" ]] && emupid="$(pgrep -f "$emu")" && \ rcpid="$(pgrep -f -o runcommand.sh)" espid="$(pgrep -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)")" ;;#" restart_es) touch /tmp/es-restart && chown pi:pi /tmp/es-restart [[ -n $emupid ]] && kill $emupid && es_wait $emupid && es_wait $rcpid [[ -z $emupid ]] && kill $espid && sleep 5 ;; shutdown_es) touch /tmp/es-shutdown && chown pi:pi /tmp/es-shutdown ;; esac } es_wait() #Wait function for finishing running emulators { while [ -e /proc/$1 ] do sleep 0.15 done } #this is the GPIO pin connected to the duoLed RED GPIOpinLED=21 #this is the GPIO pin connected to NESPi RESET siwtch GPIOpinRESET=20 #this is the GPIO pin connected to the lead on switch labeled OUT GPIOpin1=19 #this is the GPIO pin connected to the lead on switch labeled IN GPIOpin2=26 #SWITCH LED ON echo "$GPIOpinLED" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio$GPIOpinLED/direction echo "1" > /sys/class/gpio/gpio$GPIOpinLED/value #Initiate RESET echo "$GPIOpinRESET" > /sys/class/gpio/export echo "in" > /sys/class/gpio/gpio$GPIOpinRESET/direction #Initiate MAUSBERRY SWITCH echo "$GPIOpin1" > /sys/class/gpio/export echo "in" > /sys/class/gpio/gpio$GPIOpin1/direction echo "$GPIOpin2" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio$GPIOpin2/direction echo "1" > /sys/class/gpio/gpio$GPIOpin2/value power=$(cat /sys/class/gpio/gpio$GPIOpin1/value) reset=$(cat /sys/class/gpio/gpio$GPIOpinRESET/value) until [ $power = 1 ]; do power=$(cat /sys/class/gpio/gpio$GPIOpin1/value) reset=$(cat /sys/class/gpio/gpio$GPIOpinRESET/value) [ $reset = 0 ] && es_action check && es_action restart_es sleep 1 done # Power button pressed? if [ $power = 1 ]; then es_action check [[ -n $emupid ]] && kill $emupid && es_wait $emupid && es_wait $rcpid es_action shutdown_es kill $espid && es_wait $espid exit #Give back maincontrol to emulationstation.sh fi poweroff

    4. Why are you doing this?
    The Mausberry gots a little design issue. If you performing a software shutdown (maybe via ES > Shutdown system or via SSH sudo poweroff) the PI will shut down but the Mausberry will stay active (LED is on). Furthermore it won't respond to a power button press anymore - it's stuck! So you have to switch it off completly by removing your wall plug or by resetting the Mausberry.

    The diode or transistor just simulates a button press and the Mausberry will properly shutdown ;)

    5. Closing words
    It would be better to use @meleu's nice shutdown service in addition with the gpio-shutdown in section 1 and 2. The great benefit of this is you don't need to modify any scripts that are part of ES or to edit any script in meleus package.

    The button-script is intended to give an example how to perform faster shutdowns (by bypassing sleep timers) and to show the difference between a while-loop with enclousured if-clause in it and a better choosen until-loop with external if-clause ;) - I recommand a script that is python powered ;)

    Link to meleus shutdown service is here

  • 0 Votes
    39 Posts
    9k Views
    demesauceD

    How about you use the reset on the Raspberry Pi itself?

  • 0 Votes
    11 Posts
    2k Views
    R

    Apologies @caver01 , electronics are a new experience for me :)

    @ortsac I'm unsure (bought it as 'for spares or repair' from eBay) but presumably it's possible to change it?

    @space-cadet So you soldered the LED directly onto the Mausberry circuit, rather than put it back to its original location? Thanks for letting me know, I wish the Mausberry website made that clear (!). I couldn't see any mention of de-soldering on their website.

  • 2 Votes
    33 Posts
    8k Views
    lostlessL

    @diy_glenn said in Replacing Mausberry Script with a Python script:

    But I've connected the Reset button on my NESPi to GPIO instead, so it can be used for something more useful. F.ex. one click = reset ROM, double click = reboot etc.

    sorry all for the slight derailment, but this forum has no private message system. @DIY_glenn, im looking to do something similar with my reset button on my nespi but lost on how to hook up the gpio and how to wright a script. Many you can make a thread to explain how you did it and help us others out. I really want to learn this stuff.

  • 0 Votes
    72 Posts
    16k Views
    caver01C

    @meleu said in Powering off via UI while using a Mausberry Circuit:

    Do all the steps I showed on that topic and try to reboot your system. Describe here what happens.

    And then perform this command: sudo systemctl disable killes; sudo systemctl stop killes and reboot your system. Describe here what happens.

    SO, for starters, I have already done what you prescribed in the other thread to build the service and the killes.sh. Mine is till in the ~/bin folder, which is fine by me for now. After setting the killes.sh as executable, it works great! That is to say, I can do a software shutdown from command line for instance, and it definitely saves my metadata. Favorites and custom collections are awesome. Moreover, my additional line which triggers the NPN transistor does indeed let the Mausberry circuit know that a shutdown is imminent and it properly notices the drop on the GPIO it is monitoring and it cuts power. I really like this clever solution.

    It also cuts power when I initiate a reboot. That makes sense to me, and for now I am willing to live with it. The point is that software shutdown requests properly exit ES and no longer lock up my Mausberry circuit.

    Seems to me, the improvement to this would be to set a conditional statement before my GPIO command to trigger the transistor such that it checks to see if this is a shutdown/poweroff or if this is a reboot. I just don't know what to check to verify one way or the other--yet.

    As for your command above, I initiated the command as you suggested and the system immediately did a shutdown, mausberry circuit powered off.

  • 1 Votes
    251 Posts
    90k Views
    lostlessL

    @meleu My nespi is practically done. The reset is working wonderfully,

  • 0 Votes
    2 Posts
    874 Views
    B

    hey guys!

    so i managed to get this to work to some capacity but few things are a tad wrong and was hoping for your help.

    when i power the NES on, the push button is OUT when the unit is on and when i push the POWER IN, it turns OFF.
    is there something anyone can think of to reverse that? I've tried moving cables around and can't seem to get it.

    how does one get the LED to work with the unit if its built in on the board? should it just not turn on and off if i ave properly tapped into the power?

    thanks everyone

  • mausberry circuit wire gauge

    Help and Support
    1
    0 Votes
    1 Posts
    728 Views
    No one has replied
  • Doing business with Mausberry?!

    Help and Support
    23
    1 Votes
    23 Posts
    6k Views
    R

    @sfc_k Mine arrived in the end and I'm very happy with the product, hopefully yours turns up soon :)

  • VGA666 and Mausberry?

    Help and Support
    5
    0 Votes
    5 Posts
    2k Views
    CapemanC

    Actually looking at the Mausberry, it says it uses pins 23 and 24. Im no genius with schematics, but those pins above look to be dead considering they are X'ed out. Worth looking into, but even still you better be comfortable with soldering because the vga666 doesn't have exposed pins so you'll probably have to solder the mausberry wires to the pin bases on top of the vga hat