当前位置: 首页>>代码示例>>Python>>正文


Python Adafruit_GPIO.Platform类代码示例

本文整理汇总了Python中Adafruit_GPIO.Platform的典型用法代码示例。如果您正苦于以下问题:Python Platform类的具体用法?Python Platform怎么用?Python Platform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Platform类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_revision_1

	def test_revision_1(self):
		with patch('__builtin__.open') as mock_open:
			handle = mock_open.return_value.__enter__.return_value
			handle.__iter__.return_value = iter(['Revision : 0002'])
			rev = Platform.pi_revision()
			self.assertEquals(rev, 1)
		with patch('__builtin__.open') as mock_open:
			handle = mock_open.return_value.__enter__.return_value
			handle.__iter__.return_value = iter(['Revision : 0003'])
			rev = Platform.pi_revision()
			self.assertEquals(rev, 1)
开发者ID:andysmithfal,项目名称:Adafruit_Python_GPIO,代码行数:11,代码来源:test_Platform.py

示例2: get_platform_pwm

def get_platform_pwm(**keywords):
    """Attempt to return a PWM instance for the platform which the code is being
    executed on.  Currently supports only the Raspberry Pi using the RPi.GPIO
    library and Beaglebone Black using the Adafruit_BBIO library.  Will throw an
    exception if a PWM instance can't be created for the current platform.  The
    returned PWM object has the same interface as the RPi_PWM_Adapter and
    BBIO_PWM_Adapter classes.
    """
    plat = Platform.platform_detect()
    if plat == Platform.RASPBERRY_PI:
        import RPi.GPIO
        return RPi_PWM_Adapter(RPi.GPIO, **keywords)
    elif plat == Platform.BEAGLEBONE_BLACK:
        import Adafruit_BBIO.PWM
        return BBIO_PWM_Adapter(Adafruit_BBIO.PWM, **keywords)
    elif plat == Platform.CHIP:
        if "pwmtype" in keywords.keys():
            if keywords["pwmtype"] == "pwm":
                import CHIP_IO.PWM
                return CHIP_PWM_Adapter(CHIP_IO.PWM)
            elif keywords["pwmtype"] == "softpwm":
                import CHIP_IO.SOFTPWM
                return CHIP_PWM_Adapter(CHIP_IO.SOFTPWM)
        else:
            raise ValueError('For CHIP, you need to specify pwmtype in argument with value pwm or softpwm: get_platform_pwm(pwmtype="pwm") or get_platform_type(pwmtype="softpwm")')
    elif plat == Platform.UNKNOWN:
        raise RuntimeError('Could not determine platform.')
开发者ID:xtacocorex,项目名称:Adafruit_Python_GPIO,代码行数:27,代码来源:PWM.py

示例3: __init__

	def __init__(self, dc, spi, rst=None, gpio=None, width=ILI9341_TFTWIDTH,
		height=ILI9341_TFTHEIGHT):
		"""Create an instance of the display using SPI communication.  Must
		provide the GPIO pin number for the D/C pin and the SPI driver.  Can
		optionally provide the GPIO pin number for the reset pin as the rst
		parameter.
		"""
		self._dc = dc
		self._rst = rst
		self._spi = spi
		self._gpio = gpio
		self.width = width
		self.height = height
		if self._gpio is None:
			self._gpio = GPIO.get_platform_gpio()
		# Set DC as output.
		self._gpio.setup(dc, GPIO.OUT)
		# Setup reset as output (if provided).
		if rst is not None:
			self._gpio.setup(rst, GPIO.OUT)
		# Set SPI to mode 0, MSB first.
		spi.set_mode(0)
		spi.set_bit_order(SPI.MSBFIRST)
	
                # Clock nerfed for the Minnowboard	
                if(Platform.platform_detect() == 3):
                    spi.set_clock_hz(1000000)
                else:
                    spi.set_clock_hz(64000000)
		
                # Create an image buffer.
		self.buffer = Image.new('RGB', (width, height))
开发者ID:steelee,项目名称:Adafruit_Python_ILI9341,代码行数:32,代码来源:ILI9341.py

示例4: get_platform_gpio

def get_platform_gpio(**keywords):
    """Attempt to return a GPIO instance for the platform which the code is being
    executed on.  Currently supports only the Raspberry Pi using the RPi.GPIO
    library and Beaglebone Black using the Adafruit_BBIO library.  Will throw an
    exception if a GPIO instance can't be created for the current platform.  The
    returned GPIO object is an instance of BaseGPIO.
    """

    print "GPIO.py get_platform_gpio()"




    plat = Platform.platform_detect()
    if plat == Platform.RASPBERRY_PI:
        import RPi.GPIO
        return RPiGPIOAdapter(RPi.GPIO, **keywords)
    #elif plat == Platform.BEAGLEBONE_BLACK:
        #import Adafruit_BBIO.GPIO
        #return AdafruitBBIOAdapter(Adafruit_BBIO.GPIO, **keywords)
    #elif plat == Platform.MINNOWBOARD:
        #import mraa
        #return AdafruitMinnowAdapter(mraa, **keywords)
    elif plat == Platform.UNKNOWN:
        raise RuntimeError('Could not determine platform.')
开发者ID:atmelino,项目名称:bananapi,代码行数:25,代码来源:GPIO.py

示例5: get_default_bus

def get_default_bus():
    """Return the default bus number based on the device platform.  For a
    Raspberry Pi either bus 0 or 1 (based on the Pi revision) will be returned.
    For a Beaglebone Black the first user accessible bus, 1, will be returned.
    """
    plat = Platform.platform_detect()
    if plat == Platform.RASPBERRY_PI:
        if Platform.pi_revision() == 1:
            # Revision 1 Pi uses I2C bus 0.
            return 0
        else:
            # Revision 2 Pi uses I2C bus 1.
            return 1
    elif plat == Platform.BEAGLEBONE_BLACK:
        # Beaglebone Black has multiple I2C buses, default to 1 (P9_19 and P9_20).
        return 1
    else:
        raise RuntimeError('Could not determine default I2C bus for platform.')
开发者ID:AntonisVafeas,项目名称:Adafruit_Python_GPIO,代码行数:18,代码来源:I2C.py

示例6: get_default_bus

def get_default_bus():
    """Return the default bus number based on the device platform.  For a
    Raspberry Pi either bus 0 or 1 (based on the Pi revision) will be returned.
    For a Beaglebone Black the first user accessible bus, 1, will be returned.
    """
    plat = Platform.platform_detect()
    if plat == Platform.RASPBERRY_PI:
        if Platform.pi_revision() == 1:
            # Revision 1 Pi uses I2C bus 0.
            return 0
        else:
            # Revision 2 Pi uses I2C bus 1.
            return 1
    elif plat == Platform.BEAGLEBONE_BLACK:
        # Beaglebone Black has multiple I2C buses, default to 1 (P9_19 and P9_20).
        return 1
    elif plat == Platform.CHIP:
        # CHIP has 2 user accessible I2C busses, default to 2 (U1425 and U14_26)
        # The 4.4 Kernel CHIPs remove i2c-1 for the ability to set with a dtb overlay
        # and therefore isn't accessible without one
        return 2
    else:
        raise RuntimeError("Could not determine default I2C bus for platform.")
开发者ID:xtacocorex,项目名称:Adafruit_Python_GPIO,代码行数:23,代码来源:I2C.py

示例7: require_repeated_start

def require_repeated_start():
    """Enable repeated start conditions for I2C register reads.  This is the
    normal behavior for I2C, however on some platforms like the Raspberry Pi
    there are bugs which disable repeated starts unless explicitly enabled with
    this function.  See this thread for more details:
      http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=15840
    """
    plat = Platform.platform_detect()
    if plat == Platform.RASPBERRY_PI:
        # On the Raspberry Pi there is a bug where register reads don't send a
        # repeated start condition like the kernel smbus I2C driver functions
        # define.  As a workaround this bit in the BCM2708 driver sysfs tree can
        # be changed to enable I2C repeated starts.
        subprocess.check_call('chmod 666 /sys/module/i2c_bcm2708/parameters/combined', shell=True)
        subprocess.check_call('echo -n 1 > /sys/module/i2c_bcm2708/parameters/combined', shell=True)
开发者ID:AntonisVafeas,项目名称:Adafruit_Python_GPIO,代码行数:15,代码来源:I2C.py

示例8: get_platform_pwm

def get_platform_pwm(**keywords):
    """Attempt to return a PWM instance for the platform which the code is being
    executed on.  Currently supports only the Raspberry Pi using the RPi.GPIO
    library and Beaglebone Black using the Adafruit_BBIO library.  Will throw an
    exception if a PWM instance can't be created for the current platform.  The
    returned PWM object has the same interface as the RPi_PWM_Adapter and
    BBIO_PWM_Adapter classes.
    """
    plat = Platform.platform_detect()
    if plat == Platform.RASPBERRY_PI:
        import RPi.GPIO
        return RPi_PWM_Adapter(RPi.GPIO, **keywords)
    elif plat == Platform.BEAGLEBONE_BLACK:
        import Adafruit_BBIO.PWM
        return BBIO_PWM_Adapter(Adafruit_BBIO.PWM, **keywords)
    elif plat == Platform.UNKNOWN:
        raise RuntimeError('Could not determine platform.')
开发者ID:11zombie11,项目名称:Adafruit,代码行数:17,代码来源:PWM.py

示例9: get_platform_gpio

def get_platform_gpio(**keywords):
	"""Attempt to return a GPIO instance for the platform which the code is being
	executed on.  Currently supports only the Raspberry Pi using the RPi.GPIO
	library and Beaglebone Black using the Adafruit_BBIO library.  Will throw an
	exception if a GPIO instance can't be created for the current platform.  The
	returned GPIO object is an instance of BaseGPIO.
	"""
	plat = Platform.platform_detect()
	if plat == Platform.RASPBERRY_PI:
		try:
			from sysfs.gpio import GPIOController
			return LinuxSysFSAdapter(GPIOController(), **keywords)
		except:
			import RPi.GPIO
			return RPiGPIOAdapter(RPi.GPIO, **keywords)
		
	elif plat == Platform.BEAGLEBONE_BLACK:
		import Adafruit_BBIO.GPIO
		return AdafruitBBIOAdapter(Adafruit_BBIO.GPIO, **keywords)
	elif plat == Platform.UNKNOWN:
		raise RuntimeError('Could not determine platform.')
开发者ID:xspager,项目名称:Adafruit_Python_GPIO,代码行数:21,代码来源:GPIO.py

示例10: test_unknown

 def test_unknown(self):
     result = Platform.platform_detect()
     self.assertEquals(result, Platform.UNKNOWN)
开发者ID:11zombie11,项目名称:Adafruit,代码行数:3,代码来源:test_Platform.py

示例11: test_beaglebone_black

 def test_beaglebone_black(self):
     result = Platform.platform_detect()
     self.assertEquals(result, Platform.BEAGLEBONE_BLACK)
开发者ID:11zombie11,项目名称:Adafruit,代码行数:3,代码来源:test_Platform.py

示例12: test_raspberry_pi

	def test_raspberry_pi(self):
		result = Platform.platform_detect()
		self.assertEquals(result, Platform.RASPBERRY_PI)
开发者ID:andysmithfal,项目名称:Adafruit_Python_GPIO,代码行数:3,代码来源:test_Platform.py

示例13: test_revision_2

 def test_revision_2(self):
     with patch("__builtin__.open") as mock_open:
         handle = mock_open.return_value.__enter__.return_value
         handle.__iter__.return_value = iter(["Revision : 000e"])
         rev = Platform.pi_revision()
         self.assertEquals(rev, 2)
开发者ID:kenpi2b,项目名称:RaspberryPi-WeatherPiArduino,代码行数:6,代码来源:test_Platform.py


注:本文中的Adafruit_GPIO.Platform类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。