示例#1
0
文件: run.py 项目: Jarrey/BotEyePi
def capture():
    try:
        while True: 
            time.sleep(0.1)           
            # Monitor GPIO to get the control signal
            signal = gpio_utilities.getGPIOInput(s.switchInPin, 5) 
            if signal == s.signal_control:
                
                # Turn on light and capture image
                GPIO.output(s.lightPin, GPIO.HIGH)
                result = capturer.cap()
                
                if result != None :
                    ids.insert(0, result.getData())                
                    GPIO.output(s.outputPin, GPIO.HIGH)
                GPIO.output(s.lightPin, GPIO.LOW)
                
                if s.debug_mode : print "IDs: ", ids
                
                while gpio_utilities.getGPIOInput(s.switchInPin, 5) == s.signal_control: pass
                GPIO.output(s.outputPin, GPIO.LOW)
    except Exception as error:
        l.logger.info(error)
        if s.debug_mode : print error
        pass
示例#2
0
def capture():
    try:
        while True:
            time.sleep(0.1)
            # Monitor GPIO to get the control signal
            signal = gpio_utilities.getGPIOInput(s.switchInPin, 5)
            if signal == s.signal_control:

                # Turn on light and capture image
                GPIO.output(s.lightPin, GPIO.HIGH)
                result = capturer.cap()

                if result != None:
                    ids.insert(0, result.getData())
                    GPIO.output(s.outputPin, GPIO.HIGH)
                GPIO.output(s.lightPin, GPIO.LOW)

                if s.debug_mode: print "IDs: ", ids

                while gpio_utilities.getGPIOInput(s.switchInPin,
                                                  5) == s.signal_control:
                    pass
                GPIO.output(s.outputPin, GPIO.LOW)
    except Exception as error:
        l.logger.info(error)
        if s.debug_mode: print error
        pass
示例#3
0
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import os
import gpio_utilities

power_pin = 43

# Can comment this line to enable the warning for GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

# Setup light sensor pin status
GPIO.setup(power_pin, GPIO.IN)

try:
    while True:
        if gpio_utilities.getGPIOInput(power_pin1, 20) == GPIO.LOW:
            # print GPIO.input(power_pin)
            os.system("halt")
        time.sleep(1)
except KeyboardInterrupt:
    pass