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


Python pyb.udelay方法代码示例

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


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

示例1: main

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import udelay [as 别名]
def main():
    global var1, var2
    var1, var2 = 0, 0
    t2 = pyb.Timer(2, freq = 995, callback = update)
    t4 = pyb.Timer(4, freq = 1000, callback = update)
    for x in range(1000000):
        with mutex:             # critical section start
            a = var1
            pyb.udelay(200)
            b = var2
            result = a == b     # critical section end
        if not result:
            print('Fail after {} iterations'.format(x))
            break
        pyb.delay(1)
        if x % 1000 == 0:
            print(x)
    t2.deinit()
    t4.deinit()
    print(var1, var2) 
开发者ID:peterhinch,项目名称:micropython-samples,代码行数:22,代码来源:mutex_test.py

示例2: loop

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import udelay [as 别名]
def loop(midiin):
    while True:
        midiin.poll()
        pyb.udelay(50) 
开发者ID:SpotlightKid,项目名称:micropython-stm-lib,代码行数:6,代码来源:printmidiin.py

示例3: _usleep

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import udelay [as 别名]
def _usleep(self, us):
        """Delay by (sleep) us microseconds."""
        # Wrapped as a method for portability
        pyb.udelay(us) 
开发者ID:SpotlightKid,项目名称:micropython-stm-lib,代码行数:6,代码来源:hd44780.py

示例4: update

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import udelay [as 别名]
def update(t):                  # Interrupt handler may not be able to acquire the lock
    global var1, var2           # if main loop has it
    if mutex.test():            # critical section start
        var1 += 1
        pyb.udelay(200)
        var2 += 1
        mutex.release()         # critical section end 
开发者ID:peterhinch,项目名称:micropython-samples,代码行数:9,代码来源:mutex_test.py

示例5: sleep_us

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

示例6: distance_in_cm

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import udelay [as 别名]
def distance_in_cm(self):
        start = 0
        end = 0

        # Create a microseconds counter.
        micros = pyb.Timer(2, prescaler=83, period=0x3fffffff)
        micros.counter(0)

        # Send a 10us pulse.
        self.trigger.high()
        pyb.udelay(10)
        self.trigger.low()

        # Wait 'till whe pulse starts.
        while self.echo.value() == 0:
            start = micros.counter()

        # Wait 'till the pulse is gone.
        while self.echo.value() == 1:
            end = micros.counter()

        # Deinit the microseconds counter
        micros.deinit()

        # Calc the duration of the recieved pulse, divide the result by
        # 2 (round-trip) and divide it by 29 (the speed of sound is
        # 340 m/s and that is 29 us/cm).
        dist_in_cm = ((end - start) / 2) / 29

        return dist_in_cm 
开发者ID:mithru,项目名称:MicroPython-Examples,代码行数:32,代码来源:ultrasonic.py

示例7: info

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import udelay [as 别名]
def info(self):
        self.pinCS.low()
        pyb.udelay(1000)                        # FLASH wake up delay
        self.spi.send(FLASH_RDID)
        manufacturer = self.spi.send_recv(FLASH_NOP)[0]
        id_high = self.spi.send_recv(FLASH_NOP)[0]
        id_low = self.spi.send_recv(FLASH_NOP)[0]
        self.pinCS.high()
        return manufacturer, id_high << 8 | id_low 
开发者ID:peterhinch,项目名称:micropython-epaper,代码行数:11,代码来源:flash.py


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