Python time 模块,sleep_us() 实例源码

我们从Python开源项目中,提取了以下43个代码示例,用于说明如何使用time.sleep_us()

项目:pycom-libraries    作者:pycom    | 项目源码 | 文件源码
def reset(self):
        """
        Perform the onewire reset function.
        Returns True if a device asserted a presence pulse, False otherwise.
        """
        sleep_us = time.sleep_us
        disable_irq = machine.disable_irq
        enable_irq = machine.enable_irq
        pin = self.pin

        pin(0)
        sleep_us(480)
        i = disable_irq()
        pin(1)
        sleep_us(60)
        status = not pin()
        enable_irq(i)
        sleep_us(420)
        return status
项目:pycom-libraries    作者:pycom    | 项目源码 | 文件源码
def reset(self):
        """
        Perform the onewire reset function.
        Returns True if a device asserted a presence pulse, False otherwise.
        """
        sleep_us = time.sleep_us
        disable_irq = machine.disable_irq
        enable_irq = machine.enable_irq
        pin = self.pin

        pin(0)
        sleep_us(480)
        i = disable_irq()
        pin(1)
        sleep_us(60)
        status = not pin()
        enable_irq(i)
        sleep_us(420)
        return status
项目:wipy-ussd1306    作者:mbirth    | 项目源码 | 文件源码
def reset(self):
        """ issue reset impulse to reset the display """
        self.rst.value(0)  # RST on
        self.sleep_us(100) # reset impulse has to be >100 ns and <100 ms
        self.rst.value(1)  # RST off
        # Defaults after reset:
#        1. Display is OFF
#        2. 128 x 64 Display Mode
#        3. Normal segment and display data column address and row address mapping (SEG0 mapped to
#                address 00h and COM0 mapped to address 00h)
#        4. Shift register data clear in serial interface
#        5. Display start line is set at display RAM address 0
#        6. Column address counter is set at 0
#        7. Normal scan direction of the COM outputs
#        8. Contrast control register is set at 7Fh
#        9. Normal display mode (Equivalent to A4h command) 
        self.power      = self.POWER_DOWN
        self.addressing = self.ADDRESSING_HORIZ
        self.display_mode = self.DISPLAY_NORMAL
项目:LoPy    作者:FablabLannion    | 项目源码 | 文件源码
def reset(self):
        """
        Perform the onewire reset function.
        Returns True if a device asserted a presence pulse, False otherwise.
        """
        sleep_us = time.sleep_us
        disable_irq = machine.disable_irq
        enable_irq = machine.enable_irq
        pin = self.pin

        pin(0)
        sleep_us(480)
        i = disable_irq()
        pin(1)
        sleep_us(60)
        status = not pin()
        enable_irq(i)
        sleep_us(420)
        return status
项目:pycom-libraries    作者:pycom    | 项目源码 | 文件源码
def read_bit(self):
        sleep_us = time.sleep_us
        enable_irq = machine.enable_irq
        pin = self.pin

        pin(1) # half of the devices don't match CRC without this line
        i = machine.disable_irq()
        pin(0)
        sleep_us(1)
        pin(1)
        sleep_us(1)
        value = pin()
        enable_irq(i)
        sleep_us(40)
        return value
项目:pycom-libraries    作者:pycom    | 项目源码 | 文件源码
def write_bit(self, value):
        sleep_us = time.sleep_us
        pin = self.pin

        i = machine.disable_irq()
        pin(0)
        sleep_us(1)
        pin(value)
        sleep_us(60)
        pin(1)
        sleep_us(1)
        machine.enable_irq(i)
项目:pycom-libraries    作者:pycom    | 项目源码 | 文件源码
def _wait(self):
        count = 0
        time.sleep_us(10)
        while self.i2c.readfrom(I2C_SLAVE_ADDR, 1)[0] != 0xFF:
            time.sleep_us(100)
            count += 1
            if (count > 500):  # timeout after 50ms
                raise Exception('Board timeout')
项目:pycom-libraries    作者:pycom    | 项目源码 | 文件源码
def read_battery_voltage(self):
        self.set_bits_in_memory(ADCON0_ADDR, _ADCON0_GO_nDONE_MASK)
        time.sleep_us(50)
        while self.peek_memory(ADCON0_ADDR) & _ADCON0_GO_nDONE_MASK:
            time.sleep_us(100)
        adc_val = (self.peek_memory(ADRESH_ADDR) << 2) + (self.peek_memory(ADRESL_ADDR) >> 6)
        return (((adc_val * 3.3 * 280) / 1023) / 180) + 0.01    # add 10mV to compensate for the drop in the FET
项目:pycom-libraries    作者:pycom    | 项目源码 | 文件源码
def read_bit(self):
        sleep_us = time.sleep_us
        enable_irq = machine.enable_irq
        pin = self.pin

        pin(1) # half of the devices don't match CRC without this line
        i = machine.disable_irq()
        pin(0)
        sleep_us(1)
        pin(1)
        sleep_us(1)
        value = pin()
        enable_irq(i)
        sleep_us(40)
        return value
项目:pycom-libraries    作者:pycom    | 项目源码 | 文件源码
def write_bit(self, value):
        sleep_us = time.sleep_us
        pin = self.pin

        i = machine.disable_irq()
        pin(0)
        sleep_us(1)
        pin(value)
        sleep_us(60)
        pin(1)
        sleep_us(1)
        machine.enable_irq(i)
项目:pycom-libraries    作者:pycom    | 项目源码 | 文件源码
def read_bit(self):
        sleep_us = time.sleep_us
        enable_irq = machine.enable_irq
        pin = self.pin

        pin(1) # half of the devices don't match CRC without this line
        i = machine.disable_irq()
        pin(0)
        sleep_us(1)
        pin(1)
        sleep_us(1)
        value = pin()
        enable_irq(i)
        sleep_us(40)
        return value
项目:pycom-libraries    作者:pycom    | 项目源码 | 文件源码
def write_bit(self, value):
        sleep_us = time.sleep_us
        pin = self.pin

        i = machine.disable_irq()
        pin(0)
        sleep_us(1)
        pin(value)
        sleep_us(60)
        pin(1)
        sleep_us(1)
        machine.enable_irq(i)
项目:Smart-IoT-Planting-System    作者:Python-IoT    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:Smart-IoT-Planting-System    作者:Python-IoT    | 项目源码 | 文件源码
def reset(self):
        """ issue reset impulse to reset the display """
        self.rst.value(0)  # RST on
        self.sleep_us(100) # reset impulse has to be >100 ns and <100 ms
        self.rst.value(1)  # RST off
        # Defaults after reset:
        self.power      = self.POWER_DOWN
        self.addressing = self.ADDRESSING_HORIZ
        self.instr      = self.INSTR_BASIC
        self.display_mode = self.DISPLAY_BLANK
        self.temp_coeff = self.TEMP_COEFF_0
        self.bias       = self.BIAS_1_11
        self.voltage    = 3060
项目:wipy-ussd1306    作者:mbirth    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def reset(self):
        """ issue reset impulse to reset the display """
        self.rst.value(0)  # RST on
        self.sleep_us(100) # reset impulse has to be >100 ns and <100 ms
        self.rst.value(1)  # RST off
        # Defaults after reset:
        self.power      = self.POWER_DOWN
        self.addressing = self.ADDRESSING_HORIZ
        self.instr      = self.INSTR_BASIC
        self.display_mode = self.DISPLAY_BLANK
        self.temp_coeff = self.TEMP_COEFF_0
        self.bias       = self.BIAS_1_11
        self.voltage    = 3060
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def reset(self):
        """ issue reset impulse to reset the display """
        self.rst.value(0)  # RST on
        self.sleep_us(100) # reset impulse has to be >100 ns and <100 ms
        self.rst.value(1)  # RST off
        # Defaults after reset:
        self.power      = self.POWER_DOWN
        self.addressing = self.ADDRESSING_HORIZ
        self.instr      = self.INSTR_BASIC
        self.display_mode = self.DISPLAY_BLANK
        self.temp_coeff = self.TEMP_COEFF_0
        self.bias       = self.BIAS_1_11
        self.voltage    = 3060
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def reset(self):
        """ issue reset impulse to reset the display """
        self.rst.value(0)  # RST on
        self.sleep_us(100) # reset impulse has to be >100 ns and <100 ms
        self.rst.value(1)  # RST off
        # Defaults after reset:
        self.power      = self.POWER_DOWN
        self.addressing = self.ADDRESSING_HORIZ
        self.instr      = self.INSTR_BASIC
        self.display_mode = self.DISPLAY_BLANK
        self.temp_coeff = self.TEMP_COEFF_0
        self.bias       = self.BIAS_1_11
        self.voltage    = 3060
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def reset(self):
        """ issue reset impulse to reset the display """
        self.rst.value(0)  # RST on
        self.sleep_us(100) # reset impulse has to be >100 ns and <100 ms
        self.rst.value(1)  # RST off
        # Defaults after reset:
        self.power      = self.POWER_DOWN
        self.addressing = self.ADDRESSING_HORIZ
        self.instr      = self.INSTR_BASIC
        self.display_mode = self.DISPLAY_BLANK
        self.temp_coeff = self.TEMP_COEFF_0
        self.bias       = self.BIAS_1_11
        self.voltage    = 3060
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def reset(self):
        """ issue reset impulse to reset the display """
        self.rst.value(0)  # RST on
        self.sleep_us(100) # reset impulse has to be >100 ns and <100 ms
        self.rst.value(1)  # RST off
        # Defaults after reset:
        self.power      = self.POWER_DOWN
        self.addressing = self.ADDRESSING_HORIZ
        self.instr      = self.INSTR_BASIC
        self.display_mode = self.DISPLAY_BLANK
        self.temp_coeff = self.TEMP_COEFF_0
        self.bias       = self.BIAS_1_11
        self.voltage    = 3060
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def reset(self):
        """ issue reset impulse to reset the display """
        self.rst.value(0)  # RST on
        self.sleep_us(100) # reset impulse has to be >100 ns and <100 ms
        self.rst.value(1)  # RST off
        # Defaults after reset:
        self.power      = self.POWER_DOWN
        self.addressing = self.ADDRESSING_HORIZ
        self.instr      = self.INSTR_BASIC
        self.display_mode = self.DISPLAY_BLANK
        self.temp_coeff = self.TEMP_COEFF_0
        self.bias       = self.BIAS_1_11
        self.voltage    = 3060
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def reset(self):
        """ issue reset impulse to reset the display """
        self.rst.value(0)  # RST on
        self.sleep_us(100) # reset impulse has to be >100 ns and <100 ms
        self.rst.value(1)  # RST off
        # Defaults after reset:
        self.power      = self.POWER_DOWN
        self.addressing = self.ADDRESSING_HORIZ
        self.instr      = self.INSTR_BASIC
        self.display_mode = self.DISPLAY_BLANK
        self.temp_coeff = self.TEMP_COEFF_0
        self.bias       = self.BIAS_1_11
        self.voltage    = 3060
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:developmentBoard    作者:TPYBoard    | 项目源码 | 文件源码
def reset(self):
        """ issue reset impulse to reset the display """
        self.rst.value(0)  # RST on
        self.sleep_us(100) # reset impulse has to be >100 ns and <100 ms
        self.rst.value(1)  # RST off
        # Defaults after reset:
        self.power      = self.POWER_DOWN
        self.addressing = self.ADDRESSING_HORIZ
        self.instr      = self.INSTR_BASIC
        self.display_mode = self.DISPLAY_BLANK
        self.temp_coeff = self.TEMP_COEFF_0
        self.bias       = self.BIAS_1_11
        self.voltage    = 3060
项目:esp8266-upy    作者:mchobby    | 项目源码 | 文件源码
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
        self.i2c.writeto_mem(self.address, BME280_REGISTER_CONTROL_HUM,
                             self._l1_barray)
        self._l1_barray[0] = self._mode << 5 | self._mode << 2 | 1
        self.i2c.writeto_mem(self.address, BME280_REGISTER_CONTROL,
                             self._l1_barray)

        sleep_time = 1250 + 2300 * (1 << self._mode)
        sleep_time = sleep_time + 2300 * (1 << self._mode) + 575
        sleep_time = sleep_time + 2300 * (1 << self._mode) + 575
        time.sleep_us(sleep_time)  # Wait the required time

        # burst readout from 0xF7 to 0xFE, recommended by datasheet
        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
        # humidity(0xFD): (msb << 8) | lsb
        raw_hum = (readout[6] << 8) | readout[7]

        result[0] = raw_temp
        result[1] = raw_press
        result[2] = raw_hum
项目:micropython-adafruit-pca9685    作者:adafruit    | 项目源码 | 文件源码
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
        time.sleep_us(5)
        self._write(0x00, old_mode | 0xa1) # Mode 1, autoincrement on
项目:pydx_upython    作者:gizm00    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:pydx_upython    作者:gizm00    | 项目源码 | 文件源码
def reset(self):
        """ issue reset impulse to reset the display """
        self.rst.value(0)  # RST on
        self.sleep_us(100) # reset impulse has to be >100 ns and <100 ms
        self.rst.value(1)  # RST off
        # Defaults after reset:
        self.power      = self.POWER_DOWN
        self.addressing = self.ADDRESSING_HORIZ
        self.instr      = self.INSTR_BASIC
        self.display_mode = self.DISPLAY_BLANK
        self.temp_coeff = self.TEMP_COEFF_0
        self.bias       = self.BIAS_1_11
        self.voltage    = 3060
项目:pydx_upython    作者:gizm00    | 项目源码 | 文件源码
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds)
项目:pydx_upython    作者:gizm00    | 项目源码 | 文件源码
def reset(self):
        """ issue reset impulse to reset the display """
        self.rst.value(0)  # RST on
        self.sleep_us(100) # reset impulse has to be >100 ns and <100 ms
        self.rst.value(1)  # RST off
        # Defaults after reset:
        self.power      = self.POWER_DOWN
        self.addressing = self.ADDRESSING_HORIZ
        self.instr      = self.INSTR_BASIC
        self.display_mode = self.DISPLAY_BLANK
        self.temp_coeff = self.TEMP_COEFF_0
        self.bias       = self.BIAS_1_11
        self.voltage    = 3060
项目:esp    作者:mhoffma    | 项目源码 | 文件源码
def ping0(self):
        self.trig.high()
        time.sleep_us(10)
        self.trig.low()
        d= machine.time_pulse_us(self.echo,1)
        return d
项目:LoPy    作者:FablabLannion    | 项目源码 | 文件源码
def read_bit(self):
        sleep_us = time.sleep_us
        enable_irq = machine.enable_irq
        pin = self.pin

        pin(1) # half of the devices don't match CRC without this line
        i = machine.disable_irq()
        pin(0)
        sleep_us(1)
        pin(1)
        sleep_us(1)
        value = pin()
        enable_irq(i)
        sleep_us(40)
        return value
项目:LoPy    作者:FablabLannion    | 项目源码 | 文件源码
def write_bit(self, value):
        sleep_us = time.sleep_us
        pin = self.pin

        i = machine.disable_irq()
        pin(0)
        sleep_us(1)
        pin(value)
        sleep_us(60)
        pin(1)
        sleep_us(1)
        machine.enable_irq(i)