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


Python time.sleep_us方法代码示例

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


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

示例1: _send_pulse_and_wait

# 需要导入模块: import time [as 别名]
# 或者: from time import sleep_us [as 别名]
def _send_pulse_and_wait(self):
        """
        Send the pulse to trigger and listen on echo pin.
        We use the method `machine.time_pulse_us()` to get the microseconds until the echo is received.
        """
        self.trigger.value(0) # Stabilize the sensor
        time.sleep_us(5)
        self.trigger.value(1)
        # Send a 10us pulse.
        time.sleep_us(10)
        self.trigger.value(0)
        try:
            pulse_time = machine.time_pulse_us(self.echo, 1, self.echo_timeout_us)
            return pulse_time
        except OSError as ex:
            if ex.args[0] == 110: # 110 = ETIMEDOUT
                raise OSError('Out of range')
            raise ex 
开发者ID:rsc1975,项目名称:micropython-hcsr04,代码行数:20,代码来源:hcsr04.py

示例2: readVoRaw

# 需要导入模块: import time [as 别名]
# 或者: from time import sleep_us [as 别名]
def readVoRaw(self, samplingTime, deltaTime):
        # Turn on ILED
        self.sharpLEDPin.value(0)

        # Wait 0.28ms 
        time.sleep_us(samplingTime)

        VoRaw = self.sharpVoPin.read()

        # Wait 0.04ms
        time.sleep_us(deltaTime)

        # Turn off ILED
        self.sharpLEDPin.value(1)

        return VoRaw 
开发者ID:IBM-Developer-Korea,项目名称:developer-badge-2018-apps,代码行数:18,代码来源:gp2y1014au.py

示例3: _pulse

# 需要导入模块: import time [as 别名]
# 或者: from time import sleep_us [as 别名]
def _pulse(self) -> int:
        """
        Send a pulse and wait for the echo pin using machine.time_pulse_us() to measure us.
        :return: int
        """
        tr = self._tr
        tr.value(0)
        time.sleep_us(5)
        tr.value(1)
        time.sleep_us(10)
        tr.value(0)
        try:
            return machine.time_pulse_us(self._ec, 1, self._to)
        except OSError as e:
            if e.args[0] == 100:  # TIMEOUT
                raise OSError("Object too far")
            raise e 
开发者ID:kevinkk525,项目名称:pysmartnode,代码行数:19,代码来源:hcsr04.py

示例4: readValue

# 需要导入模块: import time [as 别名]
# 或者: from time import sleep_us [as 别名]
def readValue():
    global Voc, Vos, idx

    VoRaw = dust_sensor.readRawVo(220, 40) # adjusted 280 -> 220

    # Compute the output voltage in Volts.
    Vo = VoRaw / 4095.0 * 5.0

    # Exponential Moving Average
    # https://www.investopedia.com/terms/e/ema.asp
    # EMA(t) = Value(t)*k + EMA(y) * (1-k)
    # k = 2 / (N+1)
    # k = 0.005 where N = 399
    Vos = Vo * 0.005 + Vos * 0.995
        
    # print('{}, {}, {}, {}'.format(idx, VoRaw, Vo*1000.0, Vos*1000.0))

    density = (Vos - 0.6) / 0.5 * 100.0
    if density < 0:
      density = 0

    print('{}, {}, {}'.format(Vo*1000.0, Vos*1000.0, density*10))
    
    status_box.text(density+'ug/m3')

    idx += 1

    #time.sleep_us(10000 - 320)
    time.sleep_us(4000) 
开发者ID:IBM-Developer-Korea,项目名称:developer-badge-2018-apps,代码行数:31,代码来源:dust_firmware_avg.py

示例5: readValue

# 需要导入模块: import time [as 别名]
# 或者: from time import sleep_us [as 别名]
def readValue():
    global Voc, Vos, idx

    # Turn on ILED
    sharpLEDPin.value(0)

    # Wait 0.28 ms 
    time.sleep_us(280)

    VoRaw = sharpVoPin.read()

    # Wait 0.04 ms
    #time.sleep_us(40)

    # Turn off ILED
    sharpLEDPin.value(1)

    # Compute the output voltage in Volts.
    Vo = VoRaw / 4095.0 * 3.3

    # Exponential Moving Average
    # https://www.investopedia.com/terms/e/ema.asp
    # EMA(t) = Value(t)*k + EMA(y) * (1-k)
    # k = 2 / (N+1)
    # k = 0.005 where N = 399
    Vos = Vo * 0.005 + Vos * 0.995
    dV = Vos - Voc
    if dV < 0:
        dV = 0
        Voc = Vo

    # Convert to Dust Density in units of ug/m3.
    dustDensity = dV / K * 100.0
    
    print('VoRaw={}, Vo={} mV, Density={} ug/m3'.format(VoRaw, Vo*1000.0, dustDensity))

    idx += 1

    time.sleep_us(10000 - 320) 
开发者ID:IBM-Developer-Korea,项目名称:developer-badge-2018-apps,代码行数:41,代码来源:dust_average.py

示例6: readValue

# 需要导入模块: import time [as 别名]
# 或者: from time import sleep_us [as 别名]
def readValue():
    global Voc

    # Turn on ILED
    sharpLEDPin.value(0)

    # Wait 0.28 ms 
    # time.sleep_us(280) # Actually, it took 0.4 ms.
    time.sleep_us(196) # It was measured about value of 0.28 ms

    VoRaw = sharpVoPin.read()

    # Wait 0.04 ms
    #time.sleep_us(40)

    # Turn off ILED
    sharpLEDPin.value(1)

    # Compute the output voltage in Volts.
    Vo = VoRaw / 4095.0 * 5.0

    # Convert to Dust Density in units of ug/m3.
    dV = Vo - Voc
    if dV < 0:
        dV = 0
        Voc = Vo
    
    dustDensity = dV / K * 100.0
    
    print('VoRaw={}, Vo={} mV, Density={} ug/m3'.format(VoRaw, Vo*1000.0, dustDensity))

    #time.sleep_us(10000 - 320)
    time.sleep_us(4000) 
开发者ID:IBM-Developer-Korea,项目名称:developer-badge-2018-apps,代码行数:35,代码来源:dust_firmware.py

示例7: readValue

# 需要导入模块: import time [as 别名]
# 或者: from time import sleep_us [as 别名]
def readValue():
    global Voc

    # Turn on ILED
    sharpLEDPin.value(0)

    # Wait 0.28 ms 
    time.sleep_us(280)

    VoRaw = sharpVoPin.read()

    # Wait 0.04 ms
    #time.sleep_us(40)

    # Turn off ILED
    sharpLEDPin.value(1)

    # Compute the output voltage in Volts.
    Vo = VoRaw / 4095.0 * 3.3

    # Convert to Dust Density in units of ug/m3.
    dV = Vo - Voc
    if dV < 0:
        dV = 0
        Voc = Vo

    # Convert to Dust Density in units of ug/m3.
    dustDensity = dV / K * 100.0
    
    print('VoRaw={}, Vo={} mV, Density={} ug/m3'.format(VoRaw, Vo*1000.0, dustDensity))

    time.sleep_us(10000 - 320) 
开发者ID:IBM-Developer-Korea,项目名称:developer-badge-2018-apps,代码行数:34,代码来源:dust.py

示例8: freq

# 需要导入模块: import time [as 别名]
# 或者: from time 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
        time.sleep_us(5)
        self._write(0x00, old_mode | 0xa1) # Mode 1, autoincrement on 
开发者ID:1zlab,项目名称:1ZLAB_PyEspCar,代码行数:12,代码来源:pca9685.py

示例9: sleep_us

# 需要导入模块: import time [as 别名]
# 或者: from time import sleep_us [as 别名]
def sleep_us(self, useconds):
        try:
            time.sleep_us(useconds)
        except AttributeError:
            machine.udelay(useconds) 
开发者ID:Python-IoT,项目名称:Smart-IoT-Planting-System,代码行数:7,代码来源:upcd8544.py

示例10: reset

# 需要导入模块: import time [as 别名]
# 或者: from time import sleep_us [as 别名]
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 
开发者ID:Python-IoT,项目名称:Smart-IoT-Planting-System,代码行数:15,代码来源:upcd8544.py

示例11: _send_pulse_and_wait

# 需要导入模块: import time [as 别名]
# 或者: from time import sleep_us [as 别名]
def _send_pulse_and_wait(self):
        """
        Send the pulse to trigger and listen on echo pin.
        We use the method `machine.time_pulse_us()` to get the microseconds until the echo is received.
        """
        self.trigger.value(0) # Stabilize the sensor
        time.sleep_us(5)
        self.trigger.value(1)
        # Send a 10us pulse.
        time.sleep_us(10)
        self.trigger.value(0)
        try:
            if (uname().sysname == 'WiPy'):
                pulse_list = pulses_get(self.echo, self.echo_timeout_us)
                if(len(pulse_list) == 0):
                    pulse_time = -1
                else:
                    pulse_time = pulse_list[0][1]
            else:
                pulse_time = time_pulse_us(self.echo, 1, self.echo_timeout_us)

            return pulse_time
        except OSError as ex:
            if ex.args[0] == 110: # 110 = ETIMEDOUT
                raise OSError('Out of range')
            raise ex 
开发者ID:lemariva,项目名称:uPySensors,代码行数:28,代码来源:hcsr04.py

示例12: _reset

# 需要导入模块: import time [as 别名]
# 或者: from time import sleep_us [as 别名]
def _reset( self ) :
    '''Reset the device.'''
    self.dc(0)
    self.reset(1)
    time.sleep_us(500)
    self.reset(0)
    time.sleep_us(500)
    self.reset(1)
    time.sleep_us(500) 
开发者ID:lemariva,项目名称:uPySensors,代码行数:11,代码来源:ST7735.py

示例13: write_clk

# 需要导入模块: import time [as 别名]
# 或者: from time import sleep_us [as 别名]
def write_clk(self):
        self.clk.value(0)
        time.sleep_us(20)
        self.clk.value(1)
        time.sleep_us(20) 
开发者ID:sipeed,项目名称:MaixPy_scripts,代码行数:7,代码来源:RGB_LED.py

示例14: readValue

# 需要导入模块: import time [as 别名]
# 或者: from time import sleep_us [as 别名]
def readValue():
    global Voc, Vos, idx

    # Turn on ILED
    sharpLEDPin.value(0)

    # Wait 0.28 ms 
    # time.sleep_us(280) # Actually, it took 0.4 ms.
    time.sleep_us(196) # It was measured about value of 0.28 ms

    VoRaw = sharpVoPin.read()

    # Wait 0.04 ms
    #time.sleep_us(40)

    # Turn off ILED
    sharpLEDPin.value(1)

    # Compute the output voltage in Volts.
    Vo = VoRaw / 4095.0 * 3.3

    # Exponential Moving Average
    # https://www.investopedia.com/terms/e/ema.asp
    # EMA(t) = Value(t)*k + EMA(y) * (1-k)
    # k = 2 / (N+1)
    # k = 0.005 where N = 399
    Vos = Vo * 0.005 + Vos * 0.995
    dV = Vos - Voc
    if dV < 0:
        dV = 0

    # Convert to Dust Density in units of ug/m3.
    dustDensity = dV / K * 100.0
    
    #print('VoRaw={}, Vo={} mV, Density={} ug/m3'.format(VoRaw, Vo*1000.0, dustDensity))
    
    print('{}, {}, {}'.format(idx, Vo*1000.0, Vos*1000.0))

    status_box.text(str(dustDensity)+'ug/m3')

    idx += 1

    #time.sleep_us(10000 - 320)
    time.sleep_us(4000) 
开发者ID:IBM-Developer-Korea,项目名称:developer-badge-2018-apps,代码行数:46,代码来源:dust_average copy.py


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