• 0 Votes
    3 Posts
    2k Views
    N

    @b00stnv8 Thanks for your answer. I'm a bit confused about your ON/OFF LED. On which pins did you solder your LED ? Same for your Shutdown scripted button ? I found some interesting answers too here for the GPIO power state led and here for the safe shutdown switch. Tell me what do you think about it.

  • 0 Votes
    2 Posts
    1k Views
    obsidianspiderO

    I modified my Mausberry script to change the display on my TFT to show that the Pi is shutting down. That said, I've seen other python implementations to try to do the same thing. Most seemed to be less "foolproof" than the Mausberry method, so I didn't use python to manage the shutdown. I'm still quite a hack at this, I'm still cleaning things up, and I'm sure my code is messy, but this is my modified switch.sh

    #!/bin/bash #this is the GPIO pin connected to the lead on switch labeled OUT GPIOpin1=18 #this is the GPIO pin connected to the lead on switch labeled IN GPIOpin2=17 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 while [ 1 = 1 ]; do power=$(cat /sys/class/gpio/gpio$GPIOpin1/value) if [ $power = 0 ]; then sleep 1 else #load image sudo python /home/pi/Adafruit_Python_ILI9341/examples/imageparam2.py "/home/pi/Adafruit_Python_ILI9341/examples/powering-off.png" sudo poweroff fi done

    The Mausberry script is pretty inefficient if you want to monitor buttons as it's constantly polling. From my research the "wait for edge" method is less processor intensive. This is my "reset button" python script that controls the backlight on my secondary TFT. My code may be messy, but I noticed less CPU load when using this method compared to the Mausberry method.

    #!/usr/bin/python import RPi.GPIO as GPIO import time # set up BCM GPIO numbering GPIO.setmode(GPIO.BCM) # turn off warnings GPIO.setwarnings(False) # tell the script that we're going to output data on GPIO 23 GPIO.setup(23,GPIO.OUT) # tell the script we're going to use GPIO 27 for input and act as a pull up resistor GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP) # the default state of the light is on light = 1 # run this unless there's an exception try: # Turn ON Backlight by default GPIO.output(23,GPIO.HIGH) # do this forever while True: # use interrupt to wait for button to be pressed GPIO.wait_for_edge(27, GPIO.FALLING) # if the light is on, turn the light off if light == 1: #Turn OFF Backlight GPIO.output(23,GPIO.LOW) #change the state of the light variable so the script knows the light is off light = 0 # if the light is off, turn the light on elif light == 0: # Turn ON Backlight GPIO.output(23,GPIO.HIGH) #change the state of the light variable so the script knows the light is on light = 1 # wait a little while to account for bounce in the button time.sleep(0.2) # keep running unless you Ctrl+C to break out of it except KeyboardInterrupt: # reset the GPIO pins used in this program GPIO.cleanup()
  • Mausberry/Retropie?

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

    ok, thx for the help

    solved the spacebar problem with another keyboard (thank you Keyrah and C64 keyboard ;-) )

    the script for Raspian worked

  • 0 Votes
    5 Posts
    2k Views
    monstermadeofmanM

    @jsawhite cheer buddy :) that was part of my concern. Although relatively easy to build like you say JFET is an issue also the space it takes up. The premade PCB would be ideal but I'll just have to wait and see

  • 0 Votes
    4 Posts
    2k Views
    J

    Yes, the second one you linked. you would connect your power in to the microusb port. The full USB port would go to the PI's micro port. Blue/White would go to GPIO. Power switch would be soldered to switch +/- connections... If you could fashion something to use the reset switch, you could connect that to the reset connections. You can also connect the front led to the LED/Gnd ports as well... (GND is shared between reset and led)

  • 2 Votes
    1 Posts
    993 Views
    No one has replied
  • PiTari (Atari 2600)

    Projects and Themes
    1
    2 Votes
    1 Posts
    3k Views
    No one has replied