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


Python machine.disable_irq方法代码示例

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


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

示例1: _callback

# 需要导入模块: import machine [as 别名]
# 或者: from machine import disable_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 disable_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: power_down

# 需要导入模块: import machine [as 别名]
# 或者: from machine import disable_irq [as 别名]
def power_down(self):
        """When PD_SCK pin changes from low to high and stays at
        high for longer than 60µs, HX711 enters power down mode.


        """
        log.info('HX711 power down')
        state = disable_irq()
        self.pSCK.value(False)
        self.pSCK.value(True)
        utime.sleep_us(80)
        enable_irq(state)

        # Hold level to HIGH, even during deep sleep.
        # https://community.hiveeyes.org/t/strom-sparen-beim-einsatz-der-micropython-firmware-im-batteriebetrieb/2055/72
        if self.platform_info.vendor == self.platform_info.MICROPYTHON.Pycom:
            self.pSCK.hold(True) 
开发者ID:hiveeyes,项目名称:terkin-datalogger,代码行数:19,代码来源:hx711.py

示例4: disable_irq

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

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

示例5: acquire_out_buffer

# 需要导入模块: import machine [as 别名]
# 或者: from machine import disable_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

示例6: get_ms

# 需要导入模块: import machine [as 别名]
# 或者: from machine import disable_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 disable_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

示例8: read

# 需要导入模块: import machine [as 别名]
# 或者: from machine import disable_irq [as 别名]
def read(self):
        """This chip has a non-standard serial protocol.
        
        Serial Interface
        ----------------
        Pin PD_SCK and DOUT are used for data retrieval, input selection,
        gain selection and power down controls.
        
        When output data is not ready for retrieval, digital output pin DOUT
        is high. Serial clock input PD_SCK should be low. When DOUT goes to
        low, it indicates data is ready for retrieval.
        
        By applying 25~27 positive clock pulses at the PD_SCK pin, data is
        shifted out from the DOUT output pin. Each PD_SCK pulse shifts out
        one bit, starting with the MSB bit first, until all 24 bits are
        shifted out. The 25th pulse at PD_SCK input will pull DOUT pin back
        to high.


        """

        # Initialize the hardware once.
        # Otherwise, croak with ``DeviceNotFound('HX711 not available')``.
        if not self.initialize():

            # Wait for the device becoming ready.
            self.wait_ready()

        # Shift in data, gain & channel info.
        result = 0
        for j in range(24 + self.GAIN):
            state = disable_irq()
            self.pSCK(True)
            self.pSCK(False)
            enable_irq(state)
            result = (result << 1) | self.pOUT()

        # Shift back the extra bits.
        result >>= self.GAIN

        # Check sign.
        if result > 0x7fffff:
            result -= 0x1000000

        return result 
开发者ID:hiveeyes,项目名称:terkin-datalogger,代码行数:47,代码来源:hx711.py


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