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


Python Pin.OPEN_DRAIN属性代码示例

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


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

示例1: __init__

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OPEN_DRAIN [as 别名]
def __init__(self, name, pin,
                 rising=False, falling=False,
                 pullup=True, on_change=None, report_change=True):
        if pullup:
            pin.init(Pin.IN, Pin.PULL_UP)
        else:
            pin.init(Pin.IN, Pin.OPEN_DRAIN)
        if rising and falling:
            trigger = Pin.IRQ_RISING | Pin.IRQ_FALLING
        elif not rising and falling:
            trigger = Pin.IRQ_FALLING
        else:  # also if both all false
            trigger = Pin.IRQ_RISING
        pin.irq(trigger=trigger, handler=self._cb)
        self.counter = 0
        self.report_counter = 0
        self.triggered = False
        Device.__init__(self, name, pin, on_change=on_change,
                        report_change=report_change)
        self.getters[""] = self.value 
开发者ID:ulno,项目名称:ulnoiot-upy,代码行数:22,代码来源:trigger.py

示例2: digital_write

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OPEN_DRAIN [as 别名]
def digital_write(self, payload):
        """
        Write to a digital gpio pin
        :param payload:
        :return:
        """
        pin = payload['pin']
        mode = Pin.OUT
        if 'drain' in payload:
            if not payload['drain']:
                mode = Pin.OPEN_DRAIN
        pin_object = Pin(pin, mode)
        pwm = PWM(pin_object)
        pwm.deinit()
        Pin(pin, mode, value=payload['value'])
        self.input_pin_objects[pin] = None 
开发者ID:MrYsLab,项目名称:python_banyan,代码行数:18,代码来源:esp_8266Full.py

示例3: __init__

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OPEN_DRAIN [as 别名]
def __init__(self, gnd, sck, data, vcc):
        self.gnd = gnd
        self.sck = sck
        self.data = data
        self.vcc = vcc

        self.gnd.mode(Pin.OUT)
        self.vcc.mode(Pin.OUT)
        self.sck.mode(Pin.OUT)
        self.data.mode(Pin.OPEN_DRAIN)

        self.gnd.pull(Pin.PULL_DOWN)
        self.vcc.pull(Pin.PULL_UP)
        self.sck.pull(Pin.PULL_DOWN)
        self.data.pull(None)

        self.sleep() 
开发者ID:ayoy,项目名称:upython-aq-monitor,代码行数:19,代码来源:sht1x.py

示例4: test

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OPEN_DRAIN [as 别名]
def test():
    dout = Pin(Pin.board.Y5, Pin.OUT_PP, value = 0)   # Define pins
    ckout = Pin(Pin.board.Y6, Pin.OUT_PP, value = 0)  # Don't assert clock until data is set
    din = Pin(Pin.board.Y7, Pin.IN)
    ckin = Pin(Pin.board.Y8, Pin.IN)
    reset = Pin(Pin.board.Y4, Pin.OPEN_DRAIN)
    sig_reset = Signal(reset, invert = True)

    channel = SynCom(False, ckin, ckout, din, dout, sig_reset, 10000)

    loop = asyncio.get_event_loop()
    loop.create_task(heartbeat())
    loop.create_task(channel.start(initiator_task))
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        pass
    finally:
        ckout.value(0) 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:21,代码来源:sr_init.py

示例5: __init__

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OPEN_DRAIN [as 别名]
def __init__(self, trigger_pin, echo_pin, echo_timeout_us=500*2*30):
        """
        trigger_pin: Output pin to send pulses
        echo_pin: Readonly pin to measure the distance. The pin should be protected with 1k resistor
        echo_timeout_us: Timeout in microseconds to listen to echo pin.
        By default is based in sensor limit range (4m)
        """
        self.echo_timeout_us = echo_timeout_us
        # Init trigger pin (out)
        self.trigger = Pin(trigger_pin, mode=Pin.OUT)
        self.trigger.value(0)
        # Init echo pin (in)
        if (uname().sysname == 'WiPy'):
            self.echo = Pin(echo_pin, mode=Pin.OPEN_DRAIN)
        else:
            self.echo = Pin(echo_pin, mode=Pin.IN) 
开发者ID:lemariva,项目名称:uPySensors,代码行数:18,代码来源:hcsr04.py

示例6: __init__

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OPEN_DRAIN [as 别名]
def __init__(self, scl, sda):
        """Initiate the HUT21D

        Args:
            scl (int): Pin id where the sdl pin is connected to
            sda (int): Pin id where the sda pin is connected to
        """
        self.i2c = I2C(scl=Pin(scl, Pin.OPEN_DRAIN, Pin.PULL_UP), sda=Pin(sda, Pin.OPEN_DRAIN, Pin.PULL_UP), freq=100000) 
开发者ID:IBM-Developer-Korea,项目名称:developer-badge-2018-apps,代码行数:10,代码来源:htu21d.py

示例7: set_mode_digital_output

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OPEN_DRAIN [as 别名]
def set_mode_digital_output(self, payload):
        """
        Set pin as a digtal output
        :param payload:
        :return:
        """
        pin = payload['pin']
        mode = Pin.OUT
        if 'drain' in payload:
            if not payload['drain']:
                mode = Pin.OPEN_DRAIN
        Pin(pin, mode, value=payload['value']) 
开发者ID:MrYsLab,项目名称:python_banyan,代码行数:14,代码来源:esp_8266Full.py

示例8: digital_write

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OPEN_DRAIN [as 别名]
def digital_write(self,payload):
  pin=payload['pin']
  mode=Pin.OUT
  if 'drain' in payload:
   if not payload['drain']:
    mode=Pin.OPEN_DRAIN
  pin_object=Pin(pin,mode)
  pwm=PWM(pin_object)
  pwm.deinit()
  Pin(pin,mode,value=payload['value'])
  self.input_pin_objects[pin]=None 
开发者ID:MrYsLab,项目名称:python_banyan,代码行数:13,代码来源:esp_8266.py

示例9: set_mode_digital_output

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OPEN_DRAIN [as 别名]
def set_mode_digital_output(self,payload):
  pin=payload['pin']
  mode=Pin.OUT
  if 'drain' in payload:
   if not payload['drain']:
    mode=Pin.OPEN_DRAIN
  Pin(pin,mode,value=payload['value']) 
开发者ID:MrYsLab,项目名称:python_banyan,代码行数:9,代码来源:esp_8266.py

示例10: __init__

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OPEN_DRAIN [as 别名]
def __init__(self, name, trigger_pin, echo_pin,
                 echo_timeout_us=30000, precision=10,
                 on_change=None, report_change=True,
                 filter=None):
        # trigger_pin: Output pin to send pulses
        # echo_pin: Readonly pin to measure the distance.
        #           The pin should be protected with 1k resistor
        # echo_timeout_us: Timeout in microseconds to listen to echo pin.
        # By default is based in sensor limit range (4m)
        self.current_value = 0
        self._last_measured = 0
        if type(trigger_pin) is not Pin:
            trigger_pin = Pin(trigger_pin)
        self.trigger_pin = trigger_pin
        if type(echo_pin) is not Pin:
            echo_pin = Pin(trigger_pin)
        self.echo_pin = echo_pin
        self.precision = precision
        trigger_pin.init(Pin.OUT)
        trigger_pin.off()
        echo_pin.init(Pin.IN)
        echo_pin.init(Pin.OPEN_DRAIN)
        self.echo_timeout_us = echo_timeout_us
        self.distance = -10000
        Device.__init__(self, name, (trigger_pin, echo_pin),
                        on_change=on_change,
                        report_change=report_change,
                        filter=filter) 
开发者ID:ulno,项目名称:ulnoiot-upy,代码行数:30,代码来源:hcsr04.py

示例11: drive_mode

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OPEN_DRAIN [as 别名]
def drive_mode(self, mod):
        self.__drive_mode = mod
        if mod is DriveMode.OPEN_DRAIN:
            self._pin.init(mode=Pin.OPEN_DRAIN)
        elif mod is DriveMode.PUSH_PULL:
            self._pin.init(mode=Pin.OUT) 
开发者ID:adafruit,项目名称:Adafruit_Blinka,代码行数:8,代码来源:digitalio.py


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