Need Reverse cam setup Help - Printable Version +- BlueWave Studio forum (https://bluewavestudio.io/community) +-- Forum: OpenAuto Pro (https://bluewavestudio.io/community/forum-86.html) +--- Forum: Video features (https://bluewavestudio.io/community/forum-64.html) +--- Thread: Need Reverse cam setup Help (/thread-1882.html) |
Need Reverse cam setup Help - jizobizo - 08-13-2020 I am running a reverse cam from the OOP and I need the GPIO to trigger when it sees the circuit rising instead of falling or vice versa. Im assuming you have a python script that triggers when the gpio port you set has no load. I have setup my own reverse cam python script for when the gpio rises when triggered from an octocoupler, that is powered by my reverse lights. I want to use the reverse grid in OOP. can you point me to the script that runs the reverse cam so i can change it or give me a way to reverse the trigger? here is what im running to give you a better idea, https://youtu.be/PYI-8KDzQV8. my script is : #!/usr/bin/python # Dim the screen and switch to the reverse camera. # Remember, the switch or opto is switching to ground, so the logic is inverted... 0 = on 1 = off import RPi.GPIO as GPIO import time import subprocess, os import signal GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) RearView_Switch = 14 # pin 18 (You must use an optocoupler and resistor as shown in the video) Brightness_Switch = 15 # pin 16 (You must use an optocoupler and resistor as shown in the video) #Extra_Switch = 1 # pin 3 GPIO.setup(RearView_Switch,GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(Brightness_Switch,GPIO.IN, pull_up_down=GPIO.PUD_UP) print " Press Ctrl & C to Quit" try: run = 0 bright = 0 while True : time.sleep(0.25) #this restricts the script to check the lights every 1/4 second, There is no point in checking 10,000 times a second. # If the reverse reverse lights come on, do this: if GPIO.input(RearView_Switch)==0 and run == 0: print "Switching Rearview Camera On" rpistr = "raspivid -t 0 -vf -h 480 -w 800" p=subprocess.Popen(rpistr,shell=True, preexec_fn=os.setsid) run = 1 # When the reverse lights go off, do this: if GPIO.input(RearView_Switch)==1 and run == 1: os.killpg(p.pid, signal.SIGTERM) print "Killing the reverse camera feed" run = 0 #These next Two blocks monitor the headlights or marker light and adjust the screen brightness settings. if GPIO.input(Brightness_Switch)==0 and bright == 0: print "Setting Brightness to 20" # 20 is about 10% subprocess.call ("/usr/local/bin/backlight.sh 20", shell=True) bright = 1 if GPIO.input(Brightness_Switch)==1 and bright == 1: print "Setting Brightness back to 255" #255 is 100% subprocess.call ("/usr/local/bin/backlight.sh 255", shell=True) bright = 0 except KeyboardInterrupt: print " Quit" GPIO.cleanup() |