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


Python utime.sleep_us方法代码示例

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


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

示例1: power_down

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

示例2: read_raw_data

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_us [as 别名]
def read_raw_data(self, result):
        """ Reads the raw (uncompensated) data from the sensor.

            Args:
                result: array of length 3 or alike where the result will be
                stored, in temperature, pressure, humidity order
            Returns:
                None
        """

        self._l1_barray[0] = self._mode_temperature << 5 | self._mode_pressure << 2 | BMP280_POWER_MODE_FORCED
        self.i2c.writeto_mem(self.address, BMP280_REGISTER_CONTROL, self._l1_barray)

        time.sleep_us(self.compute_delay_time())  # Wait the required time

        # burst readout from 0xF7 to 0xFC, recommended by datasheet
        # we read the 6 bytes (3 bytes each)
        self.i2c.readfrom_mem_into(self.address, 0xF7, self._l8_barray)
        readout = self._l8_barray
        # pressure(0xF7): ((msb << 16) | (lsb << 8) | xlsb) >> 4
        raw_press = ((readout[0] << 16) | (readout[1] << 8) | readout[2]) >> 4
        # temperature(0xFA): ((msb << 16) | (lsb << 8) | xlsb) >> 4
        raw_temp = ((readout[3] << 16) | (readout[4] << 8) | readout[5]) >> 4

        result[0] = raw_temp
        result[1] = raw_press 
开发者ID:m5stack,项目名称:UIFlow-Code,代码行数:28,代码来源:bmp280.py

示例3: test

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_us [as 别名]
def test():
    utime.sleep_us(10000)

# @time_acc_function
# applied to a function causes it to print the number of times it was called
# with the accumulated time used. 
开发者ID:peterhinch,项目名称:micropython-samples,代码行数:8,代码来源:timed_func.py

示例4: __noop

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_us [as 别名]
def __noop(self):
        utime.sleep_us(self.CLOCK_TIME_US) 
开发者ID:ayoy,项目名称:upython-aq-monitor,代码行数:4,代码来源:sht1x.py

示例5: freq

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_us [as 别名]
def freq(self, freq=None):
        if freq is None:
            return int(25000000.0 / 4096 / (self._read(0xfe) - 0.5))
        prescale = int(25000000.0 / 4096.0 / freq + 0.5)
        old_mode = self._read(0x00) # Mode 1
        self._write(0x00, (old_mode & 0x7F) | 0x10) # Mode 1, sleep
        self._write(0xfe, prescale) # Prescale
        self._write(0x00, old_mode) # Mode 1
        utime.sleep_us(5)
        self._write(0x00, old_mode | 0xa1) # Mode 1, autoincrement on 
开发者ID:openmv,项目名称:openmv-projects,代码行数:12,代码来源:pca9685.py

示例6: reset

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_us [as 别名]
def reset(self):
        """
        Reset BlueNRG-MS module
        """
        self._rst_pin.off()
        utime.sleep_us(5)
        self._rst_pin.on()
        utime.sleep_us(5) 
开发者ID:dmazzella,项目名称:uble,代码行数:10,代码来源:bluenrg_ms.py

示例7: read

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_us [as 别名]
def read(self, size=HCI_READ_PACKET_SIZE, retry=5):
        """
        Read packet from BlueNRG-MS module
        """
        result = None
        while retry:
            with CSContext(self._nss_pin):
                # Exchange header
                self._spi_bus.write_readinto(
                    _READ_HEADER_MASTER,
                    self._rw_header_slave
                )
                rx_read_bytes = (
                    self._rw_header_slave[4] << 8
                ) | self._rw_header_slave[3]
                if self._rw_header_slave[0] == 0x02 and rx_read_bytes > 0:
                    # SPI is ready
                    # avoid to read more data that size of the buffer
                    if rx_read_bytes > size:
                        rx_read_bytes = size
                    data = b'\xFF' * rx_read_bytes
                    result = bytearray(rx_read_bytes)
                    self._spi_bus.write_readinto(data, result)
                    break
                else:
                    utime.sleep_us(50)
            retry -= 1

        # Add a small delay to give time to the BlueNRG to set the IRQ pin low
        # to avoid a useless SPI read at the end of the transaction
        utime.sleep_us(150)
        return result 
开发者ID:dmazzella,项目名称:uble,代码行数:34,代码来源:bluenrg_ms.py

示例8: lcd_nybble

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_us [as 别名]
def lcd_nybble(self, bits):  # send the LS 4 bits
        for pin in self.datapins:
            pin.value(bits & 0x01)
            bits >>= 1
        time.sleep_us(LCD.E_DELAY)  # 50μs
        self.LCD_E.value(True)  # Toggle the enable pin
        time.sleep_us(LCD.E_PULSE)
        self.LCD_E.value(False)
        if self.initialising:
            time.sleep_ms(5)
        else:
            time.sleep_us(LCD.E_DELAY)  # 50μs 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:14,代码来源:alcd.py

示例9: lcd_nybble

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_us [as 别名]
def lcd_nybble(self, bits):                 # send the LS 4 bits
        for pin in self.datapins:
            pin.value(bits & 0x01)
            bits >>= 1
        time.sleep_us(LCD.E_DELAY)  # 50μs
        self.LCD_E.value(True)                  # Toggle the enable pin
        time.sleep_us(LCD.E_PULSE)
        self.LCD_E.value(False)
        if self.initialising:
            time.sleep_ms(5)
        else:
            time.sleep_us(LCD.E_DELAY)  # 50μs 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:14,代码来源:alcd.py

示例10: wake

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_us [as 别名]
def wake(self):
        """Wake the INA219 from power down mode."""
        configuration = self._read_configuration()
        self._configuration_register(configuration | 0x0007)
        # 40us delay to recover from powerdown (p14 of spec)
        utime.sleep_us(40) 
开发者ID:chrisb2,项目名称:pyb_ina219,代码行数:8,代码来源:ina219.py

示例11: power_up

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_us [as 别名]
def power_up(self):
        """When PD_SCK Input is low, chip is in normal working mode."""

        # Unfreeze pin hold when coming from 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(False)

        log.info('HX711 power up')
        self.pSCK.value(False)
        #utime.sleep_us(80)

        #self.initialize() 
开发者ID:hiveeyes,项目名称:terkin-datalogger,代码行数:15,代码来源:hx711.py

示例12: _handler

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_us [as 别名]
def _handler(self, _, sn=bytearray(2), txnull=bytearray(2)):
        addr = Responder.addr
        self.rem.irq(handler=None)
        utime.sleep_us(_DELAY)  # Ensure Initiator has set up to write.
        self.i2c.readfrom_into(addr, sn)
        self.own(1)
        self.waitfor(0)
        self.own(0)
        n = sn[0] + ((sn[1] & 0x7f) << 8)  # no of bytes to receive
        if n > self.rxbufsize:
            raise ValueError('Receive data too large for buffer.')
        self.cantx = not bool(sn[1] & 0x80)  # Can Initiator accept a payload?
        if n:
            self.waitfor(1)
            utime.sleep_us(_DELAY)
            mv = memoryview(self.rx_mv[0: n])  # allocates
            self.i2c.readfrom_into(addr, mv)
            self.own(1)
            self.waitfor(0)
            self.own(0)
            self._handle_rxd(mv)

        self.own(1)  # Request to send
        self.waitfor(1)
        utime.sleep_us(_DELAY)
        dtx = self.txbyt != b'' and self.cantx  # Data to send
        siz = self.txsiz if dtx else txnull
        if self.rxbyt:
            siz[1] |= 0x80  # Hold off Initiator TX
        else:
            siz[1] &= 0x7f
        self.i2c.writeto(addr, siz)  # Was getting ENODEV occasionally on Pyboard
        self.own(0)
        self.waitfor(0)
        if dtx:
            self.own(1)
            self.waitfor(1)
            utime.sleep_us(_DELAY)
            self.i2c.writeto(addr, self.txbyt)
            self.own(0)
            self.waitfor(0)
            self._txdone()  # Invalidate source
        self.rem.irq(handler=self._handler, trigger=machine.Pin.IRQ_RISING) 
开发者ID:peterhinch,项目名称:micropython-iot,代码行数:45,代码来源:asi2c.py

示例13: write

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_us [as 别名]
def write(self, header, param, retry=5):
        """
        Write packet to BlueNRG-MS module
        """
        result = None
        while retry:
            with CSContext(self._nss_pin):
                # Exchange header
                self._spi_bus.write_readinto(
                    _WRITE_HEADER_MASTER,
                    self._rw_header_slave
                )
                rx_write_bytes = self._rw_header_slave[1]
                rx_read_bytes = (
                    self._rw_header_slave[4] << 8
                ) | self._rw_header_slave[3]
                if self._rw_header_slave[0] == 0x02 and (
                        rx_write_bytes > 0 or rx_read_bytes > 0):
                    # SPI is ready
                    if header:
                        # avoid to write more data that size of the buffer
                        if rx_write_bytes >= len(header):
                            result = bytearray(len(header))
                            self._spi_bus.write_readinto(header, result)
                            if param:
                                rx_write_bytes -= len(header)
                                # avoid to read more data that size of the
                                # buffer
                                if len(param) > rx_write_bytes:
                                    tx_bytes = rx_write_bytes
                                else:
                                    tx_bytes = len(param)
                                result = bytearray(tx_bytes)
                                self._spi_bus.write_readinto(param, result)
                                break
                            else:
                                break
                        else:
                            break
                    else:
                        break
                else:
                    utime.sleep_us(50)
            retry -= 1

        return result 
开发者ID:dmazzella,项目名称:uble,代码行数:48,代码来源:bluenrg_ms.py

示例14: _handler

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_us [as 别名]
def _handler(self, _, sn=bytearray(2), txnull=bytearray(2)):
        addr = Responder.addr
        self.rem.irq(handler=None, trigger=machine.Pin.IRQ_RISING)
        utime.sleep_us(_DELAY)  # Ensure Initiator has set up to write.
        self.i2c.readfrom_into(addr, sn)
        self.own(1)
        self.waitfor(0)
        self.own(0)
        n = sn[0] + ((sn[1] & 0x7f) << 8)  # no of bytes to receive
        if n > self.rxbufsize:
            raise ValueError('Receive data too large for buffer.')
        self.cantx = not bool(sn[1] & 0x80)  # Can Initiator accept a payload?
        if n:
            self.waitfor(1)
            utime.sleep_us(_DELAY)
            mv = memoryview(self.rx_mv[0: n])  # allocates
            self.i2c.readfrom_into(addr, mv)
            self.own(1)
            self.waitfor(0)
            self.own(0)
            self._handle_rxd(mv)

        self.own(1)  # Request to send
        self.waitfor(1)
        utime.sleep_us(_DELAY)
        dtx = self.txbyt != b'' and self.cantx  # Data to send
        siz = self.txsiz if dtx else txnull
        if self.rxbyt:
            siz[1] |= 0x80  # Hold off Initiator TX
        else:
            siz[1] &= 0x7f
        self.i2c.writeto(addr, siz)  # Was getting ENODEV occasionally on Pyboard
        self.own(0)
        self.waitfor(0)
        if dtx:
            self.own(1)
            self.waitfor(1)
            utime.sleep_us(_DELAY)
            self.i2c.writeto(addr, self.txbyt)
            self.own(0)
            self.waitfor(0)
            self._txdone()  # Invalidate source
        self.rem.irq(handler=self._handler, trigger=machine.Pin.IRQ_RISING) 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:45,代码来源:asi2c.py


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