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


Python machine.enable_irq方法代码示例

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


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

示例1: _callback

# 需要导入模块: import machine [as 别名]
# 或者: from machine import enable_irq [as 别名]
def _callback(self, pin):
        irq_state = machine.disable_irq()

        while True:
            self._register[0] <<= 1
            self._register[0] |= pin.value()

            #print("{:08b}".format(self._register[0]))
            # All bits set, button has been released for 8 loops
            if self._register[0] is 0b11111111:
                self._current_state = False
                break

            # All bits unset, button has been pressed for 8 loops
            if self._register[0] is 0b00000000:
                self._current_state = True
                break

        # Handle edge case of two consequent rising interrupts
        if self._current_state is not self._previous_state:
            self._previous_state = self._current_state
            self._user_callback(self._pin, self._current_state)

        machine.enable_irq(irq_state) 
开发者ID:tuupola,项目名称:micropython-m5stack,代码行数:26,代码来源:input.py

示例2: get_t_split

# 需要导入模块: import machine [as 别名]
# 或者: from machine import enable_irq [as 别名]
def get_t_split(self):
        state = machine.disable_irq()
        t = self.t_ms
        acquired = self.acquired
        machine.enable_irq(state)
        isecs, ims = divmod(t, 1000)  # Get integer secs and ms
        x, secs = divmod(isecs, 60)
        hrs, mins = divmod(x, 60)
        dt = utime.ticks_diff(utime.ticks_us(), acquired)  # μs to time now
        ds, us = divmod(dt, 1000000)
        # If dt > 1e6 can add to secs without risk of rollover: see above.
        self._time[0] = hrs
        self._time[1] = mins
        self._time[2] = secs + ds
        self._time[3] = us + ims*1000
        return self._time 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:18,代码来源:as_tGPS.py

示例3: enable_irq

# 需要导入模块: import machine [as 别名]
# 或者: from machine import enable_irq [as 别名]
def enable_irq(self, **kwargs):
        """
        Enable interrupt requests.

        :param kwargs: Parameters to pass to :meth:`platypush.plugins.esp.EspPlugin.execute`.
        """
        code = '''
import machine
machine.enable_irq()
'''
        return self.execute(code, **kwargs).output 
开发者ID:BlackLight,项目名称:platypush,代码行数:13,代码来源:__init__.py

示例4: acquire_out_buffer

# 需要导入模块: import machine [as 别名]
# 或者: from machine import enable_irq [as 别名]
def acquire_out_buffer(self):
        while self.out_buffer_lock == True:
            time.sleep_ms(1)  # Wait for release
        self.irqstate = machine.disable_irq()
        if self.out_buffer_lock == True:  # TODO: check if this locking is enough
            machine.enable_irq(self.irqstate)
            return False
        self.out_buffer_lock = True
        return True 
开发者ID:ulno,项目名称:ulnoiot-upy,代码行数:11,代码来源:unetrepl.py

示例5: release_out_buffer

# 需要导入模块: import machine [as 别名]
# 或者: from machine import enable_irq [as 别名]
def release_out_buffer(self):
        self.out_buffer_lock = False
        machine.enable_irq(self.irqstate) 
开发者ID:ulno,项目名称:ulnoiot-upy,代码行数:5,代码来源:unetrepl.py

示例6: get_ms

# 需要导入模块: import machine [as 别名]
# 或者: from machine import enable_irq [as 别名]
def get_ms(self):
        state = machine.disable_irq()
        t = self.t_ms
        acquired = self.acquired
        machine.enable_irq(state)
        return t + utime.ticks_diff(utime.ticks_us(), acquired) // 1000

    # Return accurate GPS time of day (hrs: int, mins: int, secs: int, μs: int)
    # The ISR can skip an update of .secs if a day rollover would occur. Next
    # RMC handles this, so if updates are at 1s intervals the subsequent ISR
    # will see hms = 0, 0, 1 and a value of .acquired > 1000000.
    # Even at the slowest update rate of 10s this can't overflow into minutes. 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:14,代码来源:as_tGPS.py

示例7: monkeypatch_machine

# 需要导入模块: import machine [as 别名]
# 或者: from machine import enable_irq [as 别名]
def monkeypatch_machine():

    from mock import Mock

    import uuid
    import machine

    # Some primitives.
    machine.enable_irq = Mock()
    machine.disable_irq = Mock()
    machine.unique_id = lambda: str(uuid.uuid4().fields[-1])[:5].encode()
    machine.freq = Mock(return_value=42000000)
    machine.idle = Mock()

    # Reset cause and wake reason.
    machine.PWRON_RESET = 0
    machine.HARD_RESET = 1
    machine.WDT_RESET = 2
    machine.DEEPSLEEP_RESET = 3
    machine.SOFT_RESET = 4
    machine.BROWN_OUT_RESET = 5

    machine.PWRON_WAKE = 0
    machine.GPIO_WAKE = 1
    machine.RTC_WAKE = 2
    machine.ULP_WAKE = 3

    machine.reset_cause = Mock(return_value=0)
    machine.wake_reason = wake_reason 
开发者ID:hiveeyes,项目名称:terkin-datalogger,代码行数:31,代码来源:compat.py


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