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


Python GPIO.IN属性代码示例

本文整理汇总了Python中Adafruit_BBIO.GPIO.IN属性的典型用法代码示例。如果您正苦于以下问题:Python GPIO.IN属性的具体用法?Python GPIO.IN怎么用?Python GPIO.IN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在Adafruit_BBIO.GPIO的用法示例。


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

示例1: init

# 需要导入模块: from Adafruit_BBIO import GPIO [as 别名]
# 或者: from Adafruit_BBIO.GPIO import IN [as 别名]
def init(self, mode=IN, pull=None):
        """Initialize the Pin"""
        if mode is not None:
            if mode == self.IN:
                self._mode = self.IN
                GPIO.setup(self.id, GPIO.IN)
            elif mode == self.OUT:
                self._mode = self.OUT
                GPIO.setup(self.id, GPIO.OUT)
            else:
                raise RuntimeError("Invalid mode for pin: %s" % self.id)
        if pull is not None:
            if self._mode != self.IN:
                raise RuntimeError("Cannot set pull resistor on output")
            if pull == self.PULL_UP:
                GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_UP)
            elif pull == self.PULL_DOWN:
                GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
            else:
                raise RuntimeError("Invalid pull for pin: %s" % self.id) 
开发者ID:adafruit,项目名称:Adafruit_Blinka,代码行数:22,代码来源:pin.py

示例2: __init__

# 需要导入模块: from Adafruit_BBIO import GPIO [as 别名]
# 或者: from Adafruit_BBIO.GPIO import IN [as 别名]
def __init__(self, port, callback):
        self.port = port
        self.callback = callback

        GPIO.setup(self.port, GPIO.IN)

        print "DETECT EVENTS:", self.port

        # GPIO.RISING, GPIO.FALLING, GPIO.BOTH
        GPIO.remove_event_detect(self.port)
        GPIO.add_event_detect(self.port, GPIO.RISING, callback=self.check_rising, bouncetime=300)
        #GPIO.add_event_detect(self.port, GPIO.BOTH, callback=self.check_rising)
        #GPIO.add_event_detect(self.port, GPIO.FALLING, callback=self.check_falling)
        #GPIO.add_event_detect(self.port, GPIO.FALLING, self.check_falling) 
开发者ID:daq-tools,项目名称:kotori,代码行数:16,代码来源:gpio.py

示例3: __init__

# 需要导入模块: from Adafruit_BBIO import GPIO [as 别名]
# 或者: from Adafruit_BBIO.GPIO import IN [as 别名]
def __init__(self, bus=0, device=0, speed=1000000, pin_rst=def_pin_rst,
            pin_ce=0, pin_irq=def_pin_irq, pin_mode = def_pin_mode):
        self.pin_rst = pin_rst
        self.pin_ce = pin_ce
        self.pin_irq = pin_irq

        self.spi = SPIClass()
        self.spi.open(bus, device)
        if board == RASPBERRY:
            self.spi.max_speed_hz = speed
        else:
            self.spi.mode = 0
            self.spi.msh = speed

        if pin_mode is not None:
            GPIO.setmode(pin_mode)
        if pin_rst != 0:
            GPIO.setup(pin_rst, GPIO.OUT)
            GPIO.output(pin_rst, 1)
        GPIO.setup(pin_irq, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GPIO.add_event_detect(pin_irq, GPIO.FALLING,
                callback=self.irq_callback)
        if pin_ce != 0:
            GPIO.setup(pin_ce, GPIO.OUT)
            GPIO.output(pin_ce, 1)
        self.init() 
开发者ID:ondryaso,项目名称:pi-rc522,代码行数:28,代码来源:rfid.py

示例4: __init__

# 需要导入模块: from Adafruit_BBIO import GPIO [as 别名]
# 或者: from Adafruit_BBIO.GPIO import IN [as 别名]
def __init__(self):
        global GPIO
        try:
            import Adafruit_BBIO.GPIO as GPIO
        except ImportError:
            raise ImportError(self._import_error_msg)

        super(BeagleBoneBlack, self).__init__()

        self.PIN_MODES = {
            pingo.IN: GPIO.IN,
            pingo.OUT: GPIO.OUT,
        }

        self.PIN_STATES = {
            pingo.HIGH: GPIO.HIGH,
            pingo.LOW: GPIO.LOW,
        }

        gpio_pins = [pingo.DigitalPin(self, location, gpio_id)
                     for location, gpio_id in self.PINS.items()]
        ground_pins = [pingo.GroundPin(self, location)
                       for location in self.GND_PINS]
        vcc_pins = [pingo.VccPin(self, location, voltage)
                    for location, voltage in self.VCC_PINS.items()]

        self._add_pins(gpio_pins + ground_pins + vcc_pins) 
开发者ID:pingo-io,项目名称:pingo-py,代码行数:29,代码来源:bbb.py


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