Python RPi.GPIO.RPI_INFO Examples

The following are 5 code examples of RPi.GPIO.RPI_INFO(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module RPi.GPIO , or try the search function .
Example #1
Source File: index.py    From rpiapi with MIT License 6 votes vote down vote up
def index(environ, response):

	modes = {
		-1: "MODE_UNKNOWN",
		10: "BOARD",
		11: "BCM",
		40: "SERIAL",
		41: "SPI",
		42: "I2C",
		43: "PWM"
	}
	
	status = "200 OK"
	
	header = [("Content-Type", "application/json")]
	
	result = {
		"GPIO.RPI_INFO": GPIO.RPI_INFO,
		"GPIO.VERSION": GPIO.VERSION,
		"MODE": modes[ GPIO.getmode() ]
	}
	
	response(status, header)
	
	return [json.dumps(result).encode()] 
Example #2
Source File: RFExplorer.py    From RFExplorer-for-Python with GNU Lesser General Public License v3.0 6 votes vote down vote up
def ResetIOT_HW(cls, bMode):
        """Set Raspberry pi GPIO pins and reset RF Explorer device

        Parameters: 
            bMode -- True if the baudrate is set to 500000bps, False to 2400bps
        """
        try:
            import RPi.GPIO as GPIO
       
            #print("RPi info: " + str(GPIO.RPI_INFO)) #information about your RPi:
            #print("RPi.GPio version: " + GPIO.VERSION) #version of RPi.GPIO:
            GPIO.setwarnings(False)
            GPIO.setmode(GPIO.BOARD)    #refer to the pin numbers on the P1 header of the Raspberry Pi board
            GPIO.setup(12, GPIO.OUT)    #set /reset (pin 12) to output 
            GPIO.output(12, False)      #set /reset (pin 12) to LOW
            GPIO.setup(21, GPIO.OUT)    #set GPIO2 (pin 21) to output
            GPIO.output(21, bMode)      #set GPIO2 (pin 21) to HIGH (for 500Kbps)
            time.sleep(0.1)             #wait 100ms
            GPIO.output(12, True)       #set /reset to HIGH
            time.sleep(2.5)             #wait 2.5sec
            GPIO.setup(21, GPIO.IN)     #set GPIO2 to input
            GPIO.cleanup()              #clean up GPIO channels 

        except RuntimeError:
            print("Error importing RPi.GPIO!  This is probably because you need superuser privileges.  You can achieve this by using 'sudo' to run your script") 
Example #3
Source File: 31_bmp280.py    From SunFounder_SensorKit_for_RPi2 with GNU General Public License v2.0 5 votes vote down vote up
def _get_bus_number(self):
		pi_type = GPIO.RPI_INFO['TYPE']
		if pi_type in self._BUS_0_TYPES:
			bus_number = 0
		elif pi_type in self._BUS_1_TYPES:
			bus_number = 1
		else:
			raise ValueError('Reading Pi type error, Your Pi "{0}"" is not in the list.\n  Please post an Issus at our Github Page or contract us\n    Github page: https://github.com/sunfounder/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/issues\n    Email: support@sunfounder.com\n    SunFounder'.format(pi_type))

		if self._DEBUG:
			print self._DEBUG_INFO, 'Get i2c bus number %d' % bus_number
		return bus_number 
Example #4
Source File: sample_board.py    From raspberry-gpio-emulator with Apache License 2.0 4 votes vote down vote up
def main():
    import RPi.GPIO as GPIO
    import time

    try:
        print(GPIO.VERSION)
        print(GPIO.RPI_INFO)

        GPIO.setmode(GPIO.BOARD)

        GPIO.setwarnings(False)

        GPIO.setup(12, GPIO.OUT)
        GPIO.setup(11, GPIO.OUT, initial=GPIO.HIGH)
        GPIO.setup(13, GPIO.IN)
        GPIO.setup(15, GPIO.OUT)
        GPIO.setup([16, 18], GPIO.OUT)
        GPIO.setup((8, 10), GPIO.OUT)
        GPIO.setup([21, 19], GPIO.IN)

        GPIO.setup(3, GPIO.IN)
        GPIO.cleanup(3)

        GPIO.setup([5, 7], GPIO.OUT)
        GPIO.cleanup([5, 7])

        GPIO.setup([5, 7], GPIO.IN)
        GPIO.cleanup((5, 7))

        while True:
            GPIO.output(12, GPIO.HIGH)
            GPIO.output(11, 0)
            GPIO.output(15, True)
            GPIO.output([16, 18], not GPIO.input(16))
            GPIO.output((8, 10), [GPIO.HIGH, GPIO.LOW])
            time.sleep(1)

            GPIO.output(12, GPIO.LOW)
            GPIO.output(11, 1)
            GPIO.output(15, False)
            GPIO.output((16, 18), not GPIO.input(16))
            GPIO.output([8, 10], (GPIO.LOW, GPIO.HIGH))
            time.sleep(1)
    finally:
        GPIO.cleanup() 
Example #5
Source File: sample_bcm.py    From raspberry-gpio-emulator with Apache License 2.0 4 votes vote down vote up
def main():
    import RPi.GPIO as GPIO
    import time

    try:
        print(GPIO.VERSION)
        print(GPIO.RPI_INFO)

        GPIO.setmode(GPIO.BCM)

        GPIO.setwarnings(False)

        GPIO.setup(18, GPIO.OUT)
        GPIO.setup(17, GPIO.OUT, initial=GPIO.HIGH)
        GPIO.setup(27, GPIO.IN)
        GPIO.setup(22, GPIO.OUT)
        GPIO.setup([23, 24], GPIO.OUT)
        GPIO.setup((14, 15), GPIO.OUT)
        GPIO.setup([9, 10], GPIO.IN)

        GPIO.setup(2, GPIO.IN)
        GPIO.cleanup(2)

        GPIO.setup([3, 4], GPIO.OUT)
        GPIO.cleanup([3, 4])

        GPIO.setup([3, 4], GPIO.IN)
        GPIO.cleanup((3, 4))

        while True:
            GPIO.output(18, GPIO.HIGH)
            GPIO.output(17, 0)
            GPIO.output(22, True)
            GPIO.output([23, 24], not GPIO.input(23))
            GPIO.output((14, 15), [GPIO.HIGH, GPIO.LOW])
            time.sleep(1)

            GPIO.output(18, GPIO.LOW)
            GPIO.output(17, 1)
            GPIO.output(22, False)
            GPIO.output((23, 24), not GPIO.input(23))
            GPIO.output([14, 15], (GPIO.LOW, GPIO.HIGH))
            time.sleep(1)
    finally:
        GPIO.cleanup()