Python RPi.GPIO.RPI_REVISION Examples

The following are 4 code examples of RPi.GPIO.RPI_REVISION(). 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: i2c.py    From grove.py with MIT License 6 votes vote down vote up
def __init__(self, bus=None):
        if bus is None:
            try:
                import RPi.GPIO as GPIO
                # use the bus that matches your raspi version
                rev = GPIO.RPI_REVISION
            except:
                rev = 3
            if rev == 2 or rev == 3:
                bus = 1  # for Pi 2+
            else:
                bus = 0
        if not Bus.instance:
            Bus.instance = smbus.SMBus(bus)
        self.bus = bus
        self.msg = i2c_msg 
Example #2
Source File: __init__.py    From OctoPrint-PSUControl with GNU Affero General Public License v3.0 5 votes vote down vote up
def _gpio_board_to_bcm(self, pin):
        if GPIO.RPI_REVISION == 1:
            pin_to_gpio = self._pin_to_gpio_rev1
        elif GPIO.RPI_REVISION == 2:
            pin_to_gpio = self._pin_to_gpio_rev2
        else:
            pin_to_gpio = self._pin_to_gpio_rev3

        return pin_to_gpio[pin] 
Example #3
Source File: __init__.py    From OctoPrint-PSUControl with GNU Affero General Public License v3.0 5 votes vote down vote up
def _gpio_bcm_to_board(self, pin):
        if GPIO.RPI_REVISION == 1:
            pin_to_gpio = self._pin_to_gpio_rev1
        elif GPIO.RPI_REVISION == 2:
            pin_to_gpio = self._pin_to_gpio_rev2
        else:
            pin_to_gpio = self._pin_to_gpio_rev3

        return pin_to_gpio.index(pin) 
Example #4
Source File: stm32control.py    From arminarm with GNU General Public License v2.0 5 votes vote down vote up
def setup():
	print "GPIO version: " + str(GPIO.VERSION)
	print "Pi revision " + str(GPIO.RPI_REVISION)