當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。