當前位置: 首頁>>代碼示例>>Python>>正文


Python Pin.IRQ_FALLING屬性代碼示例

本文整理匯總了Python中machine.Pin.IRQ_FALLING屬性的典型用法代碼示例。如果您正苦於以下問題:Python Pin.IRQ_FALLING屬性的具體用法?Python Pin.IRQ_FALLING怎麽用?Python Pin.IRQ_FALLING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在machine.Pin的用法示例。


在下文中一共展示了Pin.IRQ_FALLING屬性的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import IRQ_FALLING [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: __init__

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import IRQ_FALLING [as 別名]
def __init__(self,button_idx, callback=None):
        # 按鍵字典
        # 數據結構: (GPIO編號,按鍵抬起的電平, 按鍵按下的電平)
        button_list = [(39, False, True)]

        if button_idx < 0 or button_idx >= len(button_list):
            print("ERROR: Wrong Button Index")
            print("Valid Button Index: {} - {}".format(0, len(button_list)-1))
            return None

        gpio_id, self.BUTTON_RELEASE, self.BUTTON_PRESS, = button_list[button_idx]
        # 按鍵
        self.pin = Pin(gpio_id, Pin.IN)
        # 回調函數
        self.callback = callback
        # 設置外部中斷
        if self.BUTTON_PRESS == True:
            self.pin.irq(trigger=Pin.IRQ_RISING, handler=self.irq_handler)
        else:
            self.pin.irq(trigger=Pin.IRQ_FALLING, handler=self.irq_handler)
        
        # 標誌位 當前是否可以相應按鍵中斷
        self.flag = True 
開發者ID:1zlab,項目名稱:1ZLAB_PyEspCar,代碼行數:25,代碼來源:button.py

示例3: __init__

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import IRQ_FALLING [as 別名]
def __init__(self, pin, callback, extended, *args):  # Optional args for callback
        self._ev_start = Event()
        self._callback = callback
        self._extended = extended
        self._addr = 0
        self.block_time = 80 if extended else 73  # Allow for some tx tolerance (?)
        self._args = args
        self._times = array('i',  (0 for _ in range(_EDGECOUNT + 1)))  # +1 for overrun
        if platform == 'pyboard':
            ExtInt(pin, ExtInt.IRQ_RISING_FALLING, Pin.PULL_NONE, self._cb_pin)
        else:  # PR5962 ESP8266 hard IRQ's not supported
            pin.irq(handler = self._cb_pin, trigger = (Pin.IRQ_FALLING | Pin.IRQ_RISING))
        #elif ESP32:
            #pin.irq(handler = self._cb_pin, trigger = (Pin.IRQ_FALLING | Pin.IRQ_RISING))
        #else:
            #pin.irq(handler = self._cb_pin, trigger = (Pin.IRQ_FALLING | Pin.IRQ_RISING), hard = True)
        self._edge = 0
        self._ev_start.clear()
        loop = asyncio.get_event_loop()
        loop.create_task(self._run()) 
開發者ID:peterhinch,項目名稱:micropython-async,代碼行數:22,代碼來源:aremote.py

示例4: set_callbacks

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import IRQ_FALLING [as 別名]
def set_callbacks(self, callback=None):
        mode = Pin.IRQ_RISING | Pin.IRQ_FALLING
        self.irq_clk = self.pin_clk.irq(trigger=mode, handler=callback)
        self.irq_dt = self.pin_dt.irq(trigger=mode, handler=callback) 
開發者ID:SpotlightKid,項目名稱:micropython-stm-lib,代碼行數:6,代碼來源:encoder.py

示例5: __init__

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import IRQ_FALLING [as 別名]
def __init__(self, port):
        self.tx = PWM(port[0], freq=38000, duty=0, timer=1)
        self.rx = Pin(port[1], Pin.IN)
        self.rx.init(Pin.IN)
        self.rx.irq(handler=self._irq_cb, trigger=Pin.IRQ_FALLING)
        self.rx_value = 0
        self.times = 0
        self.status = 0
        self.tx_en = 0
        self.duty = 0
        self.time_num = peripheral.get_timer()
        if self.time_num == None:
            raise unit.Unit('ir application time fail')
        self.timer = Timer(self.time_num)
        self.timer.init(period=50, mode=self.timer.PERIODIC, callback=self._update) 
開發者ID:m5stack,項目名稱:UIFlow-Code,代碼行數:17,代碼來源:_ir.py

示例6: set_mode_digital_input

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import IRQ_FALLING [as 別名]
def set_mode_digital_input(self, payload):
        """
        Set a pin as a digital input with pull_up and
        enable interrupts for a change on either edge.
        :param payload:
        :return:
        """
        pin = payload['pin']
        pin_in = Pin(pin, Pin.IN, Pin.PULL_UP)
        pin_in.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING, handler=self.digital_input_callback)
        self.input_pin_objects[pin] = pin_in 
開發者ID:MrYsLab,項目名稱:python_banyan,代碼行數:13,代碼來源:esp_8266Full.py

示例7: __init__

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import IRQ_FALLING [as 別名]
def __init__(self, pin_x, pin_y, reverse, scale):
        self.reverse = reverse
        self.scale = scale
        self.forward = True
        self.pin_x = pin_x
        self.pin_y = pin_y
        self._pos = 0
        self.x_interrupt = pin_x.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING, handler=self.x_callback)
        self.y_interrupt = pin_y.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING, handler=self.y_callback) 
開發者ID:peterhinch,項目名稱:micropython-samples,代碼行數:11,代碼來源:encoder_portable.py

示例8: __init__

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import IRQ_FALLING [as 別名]
def __init__(self, gpio_id, callback=None):
        # 按鍵
        self.pin = Pin(gpio_id, Pin.IN)
        # 回調函數
        self.callback = callback
        # 設置外部中斷
        self.pin.irq(trigger=Pin.IRQ_FALLING, handler=self.irq_handler)
        # 標誌位 是否處理完成中斷
        self.flag = False 
開發者ID:1zlab,項目名稱:1ZLAB_PyEspCar,代碼行數:11,代碼來源:user_button.py

示例9: __init__

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import IRQ_FALLING [as 別名]
def __init__(self, pin, callback=None, trigger=Pin.IRQ_FALLING | Pin.IRQ_RISING):
        self._register = bytearray([0b11111111])
        self._user_callback = callback
        self._current_state = False
        self._previous_state = False
        self._pin = pin
        self._pin.init(self._pin.IN, trigger=trigger, handler=self._callback) 
開發者ID:tuupola,項目名稱:micropython-m5stack,代碼行數:9,代碼來源:input.py

示例10: __init__

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import IRQ_FALLING [as 別名]
def __init__(self, callback=None, trigger=Pin.IRQ_FALLING | Pin.IRQ_RISING):
        pin = Pin(BUTTON_A_PIN, Pin.IN)
        DigitalInput.__init__(self, pin, callback=callback, trigger=trigger) 
開發者ID:tuupola,項目名稱:micropython-m5stack,代碼行數:5,代碼來源:m5stack.py

示例11: init_pins

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import IRQ_FALLING [as 別名]
def init_pins(self):
        self.pin_irq = Pin(self.irq_pin, Pin.IN, Pin.PULL_UP)
        self.pin_irq.irq(handler=self.isr, trigger=Pin.IRQ_FALLING) 
開發者ID:larsks,項目名稱:py-mpu6050,代碼行數:5,代碼來源:mpuserver.py

示例12: __init__

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import IRQ_FALLING [as 別名]
def __init__(self, uart, rx_pin, rx_irq=None, frame_irq=None, CHR_TMO=3, FRAME_TMO=100):
        self._rxpin = rx_pin
        self._rxirq = rx_irq
        self._frameirq = frame_irq
        self._CHR_TMO = CHR_TMO
        self._FRAME_TMO = FRAME_TMO
        self._rxpin.init(Pin.IN)
        self._rxpin.irq(trigger = Pin.IRQ_FALLING, handler = self._RXPIN_IRQ)
        self._TMRX = Timer(-1)
        self._TMRX_sta = 0
        self._mode = Timer.ONE_SHOT if sys.platform == 'pyboard' else Timer.PERIODIC
        self.uart = uart 
開發者ID:micropython-Chinese-Community,項目名稱:mpy-lib,代碼行數:14,代碼來源:irqUART.py

示例13: __init__

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import IRQ_FALLING [as 別名]
def __init__(self, pin, callback, extended, *args):  # Optional args for callback
        self._ev_start = Message()
        self._callback = callback
        self._extended = extended
        self._addr = 0
        self.block_time = 80 if extended else 73  # Allow for some tx tolerance (?)
        self._args = args
        self._times = array('i',  (0 for _ in range(_EDGECOUNT + 1)))  # +1 for overrun
        if platform == 'pyboard':
            ExtInt(pin, ExtInt.IRQ_RISING_FALLING, Pin.PULL_NONE, self._cb_pin)
        else:  # PR5962 ESP8266 hard IRQ's not supported
            pin.irq(handler = self._cb_pin, trigger = (Pin.IRQ_FALLING | Pin.IRQ_RISING))
        self._edge = 0
        self._ev_start.clear()
        asyncio.create_task(self._run()) 
開發者ID:peterhinch,項目名稱:micropython-async,代碼行數:17,代碼來源:aremote.py


注:本文中的machine.Pin.IRQ_FALLING屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。