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


Python utime.sleep_ms方法代码示例

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


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

示例1: clock

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def clock(x):
    print('Clock test.')
    refresh(ssd, True)  # Clear any prior image
    lbl = Label(wri, 5, 85, 'Clock')
    dial = Dial(wri, 5, 5, height = 75, ticks = 12, bdcolor=None, label=50)  # Border in fg color
    hrs = Pointer(dial)
    mins = Pointer(dial)
    hrs.value(0 + 0.7j, RED)
    mins.value(0 + 0.9j, YELLOW)
    dm = cmath.rect(1, -cmath.pi/30)  # Rotate by 1 minute (CW)
    dh = cmath.rect(1, -cmath.pi/1800)  # Rotate hours by 1 minute
    for n in range(x):
        refresh(ssd)
        utime.sleep_ms(200)
        mins.value(mins.value() * dm, YELLOW)
        hrs.value(hrs.value() * dh, RED)
        dial.text('ticks: {}'.format(n))
    lbl.value('Done') 
开发者ID:peterhinch,项目名称:micropython-nano-gui,代码行数:20,代码来源:color15.py

示例2: __init__

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def __init__(self, spi, pincs, pindc, pinrs, height=64, width=96):
        self.spi = spi
        self.rate = 6660000  # Data sheet: 150ns min clock period
        self.pincs = pincs
        self.pindc = pindc  # 1 = data 0 = cmd
        self.height = height  # Required by Writer class
        self.width = width
        # Save color mode for use by writer_gui (blit)
        self.mode = framebuf.GS8  # Use 8bit greyscale for 8 bit color.
        gc.collect()
        self.buffer = bytearray(self.height * self.width)
        super().__init__(self.buffer, self.width, self.height, self.mode)
        pinrs(0)  # Pulse the reset line
        utime.sleep_ms(1)
        pinrs(1)
        utime.sleep_ms(1)
        self._write(b'\xae\xa0\x32\xa1\x00\xa2\x00\xa4\xa8\x3f\xad\x8e\xb0'\
        b'\x0b\xb1\x31\xb3\xf0\x8a\x64\x8b\x78\x8c\x64\xbb\x3a\xbe\x3e\x87'\
        b'\x06\x81\x91\x82\x50\x83\x7d\xaf', 0)
        gc.collect()
        self.show() 
开发者ID:peterhinch,项目名称:micropython-nano-gui,代码行数:23,代码来源:ssd1331.py

示例3: __init__

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def __init__(self, spi, pincs, pindc, pinrs, height=64, width=96):
        self.spi = spi
        self.rate = 6660000  # Data sheet: 150ns min clock period
        self.pincs = pincs
        self.pindc = pindc  # 1 = data 0 = cmd
        self.height = height  # Required by Writer class
        self.width = width
        # Save color mode for use by writer_gui (blit)
        self.mode = framebuf.RGB565
        gc.collect()
        self.buffer = bytearray(self.height * self.width * 2)
        super().__init__(self.buffer, self.width, self.height, self.mode)
        pinrs(0)  # Pulse the reset line
        utime.sleep_ms(1)
        pinrs(1)
        utime.sleep_ms(1)
        self._write(b'\xae\xa0\x72\xa1\x00\xa2\x00\xa4\xa8\x3f\xad\x8e\xb0'\
        b'\x0b\xb1\x31\xb3\xf0\x8a\x64\x8b\x78\x8c\x64\xbb\x3a\xbe\x3e\x87'\
        b'\x06\x81\x91\x82\x50\x83\x7d\xaf', 0)
        gc.collect()
        self.show() 
开发者ID:peterhinch,项目名称:micropython-nano-gui,代码行数:23,代码来源:ssd1331_16bit.py

示例4: main

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def main():
    print('alevel test is running.')
    CWriter.set_textpos(ssd, 0, 0)  # In case previous tests have altered it
    wri = CWriter(ssd, arial10, GREEN, BLACK, verbose=False)
    wri.set_clip(True, True, False)
    acc = pyb.Accel()
    dial = Dial(wri, 5, 5, height = 75, ticks = 12, bdcolor=None,
                label='Tilt Pyboard', style = Dial.COMPASS, pip=YELLOW)  # Border in fg color
    ptr = Pointer(dial)
    scale = 1/40
    while True:
        x, y, z = acc.filtered_xyz()
        # Depending on relative alignment of display and Pyboard this line may
        # need changing: swap x and y or change signs so arrow points in direction
        # board is tilted.
        ptr.value(-y*scale + 1j*x*scale, YELLOW)
        refresh(ssd)
        utime.sleep_ms(200) 
开发者ID:peterhinch,项目名称:micropython-nano-gui,代码行数:20,代码来源:alevel.py

示例5: rt_rect

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def rt_rect():
    print('Simulate realtime data acquisition of discontinuous data.')
    refresh(ssd, True)  # Clear any prior image
    g = CartesianGraph(wri, 2, 2, fgcolor=WHITE, gridcolor=LIGHTGREEN)
    curve = Curve(g, RED)
    x = -1
    for _ in range(40):
        y = 0.1/x if abs(x) > 0.05 else None  # Discontinuity
        curve.point(x, y)
        utime.sleep_ms(100)
        refresh(ssd)
        x += 0.05
    g.clear()
    curve = Curve(g, YELLOW)
    x = -1
    for _ in range(40):
        y = -0.1/x if abs(x) > 0.05 else None  # Discontinuity
        curve.point(x, y)
        utime.sleep_ms(100)
        refresh(ssd)
        x += 0.05 
开发者ID:peterhinch,项目名称:micropython-nano-gui,代码行数:23,代码来源:fpt.py

示例6: run_forever

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def run_forever(self):
        assert len(self.intervals)>0
        while True:
            output_things = self._get_tasks()
            start_ts = utime.ticks_ms()
            for pub in output_things:
                pub._observe()
                if not pub.__connections__:
                    self._remove_task(pub)
            if len(self.intervals)==0:
                break
            end_ts = utime.ticks_ms()
            if end_ts > start_ts:
                self._advance_time(int(round((end_ts-start_ts)/10)))
            sleep = self._get_next_sleep_interval()
            utime.sleep_ms(sleep*10)
            now = utime.ticks_ms()
            self._advance_time(int(round((now-end_ts)/10)) if now>=end_ts else sleep) 
开发者ID:mpi-sws-rse,项目名称:thingflow-python,代码行数:20,代码来源:thingflow.py

示例7: go_forward

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def go_forward(self, speed_percent=None, delay_ms=None):
        '''
        小车前进
        '''
        if speed_percent is None:
            speed_percent = self.speed_percent
        else:
            speed_percent = float(speed_percent)
        if delay_ms is not None:
            delay_ms = int(delay_ms)

        self.left_motor.speed_percent = speed_percent
        self.right_motor.speed_percent = speed_percent

        if delay_ms is not None:
            delay_ms = int(float(delay_ms))
            utime.sleep_ms(delay_ms)
            self.stop() 
开发者ID:1zlab,项目名称:1ZLAB_PyEspCar,代码行数:20,代码来源:car.py

示例8: go_backward

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def go_backward(self, speed_percent=None, delay_ms=None):
        '''
        小车后退
        '''
        if speed_percent is None:
            speed_percent = self.speed_percent
        else:
            speed_percent = float(speed_percent)
        if delay_ms is not None:
            delay_ms = int(delay_ms)

        self.left_motor.speed_percent = -1*speed_percent
        self.right_motor.speed_percent = -1*speed_percent

        if delay_ms is not None:
            delay_ms = int(float(delay_ms))
            utime.sleep_ms(delay_ms)
            self.stop() 
开发者ID:1zlab,项目名称:1ZLAB_PyEspCar,代码行数:20,代码来源:car.py

示例9: turn_left

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def turn_left(self, speed_percent=None, delay_ms=None):
        '''
        小车左转
        '''
        if speed_percent is None:
            speed_percent = self.speed_percent
        else:
            speed_percent = float(speed_percent)            

        self.left_motor.speed_percent = -1* speed_percent
        self.right_motor.speed_percent = speed_percent

        if delay_ms is not None:
            delay_ms = int(float(delay_ms))
            utime.sleep_ms(delay_ms)
            self.stop() 
开发者ID:1zlab,项目名称:1ZLAB_PyEspCar,代码行数:18,代码来源:car.py

示例10: turn_right

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def turn_right(self, speed_percent=None, delay_ms=None):
        '''
        小车右转
        '''
        if speed_percent is None:
            speed_percent = self.speed_percent
        else:
            speed_percent = float(speed_percent)
        
        self.left_motor.speed_percent = speed_percent
        self.right_motor.speed_percent = -1* speed_percent
        
        if delay_ms is not None:
            delay_ms = int(float(delay_ms))
            utime.sleep_ms(delay_ms)
            self.stop() 
开发者ID:1zlab,项目名称:1ZLAB_PyEspCar,代码行数:18,代码来源:car.py

示例11: test

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def test(use_priority=True):
    global after, after_ms, loop, lp_version
    processing_delay = 2  # Processing time in low priority task (ms)
    if use_priority and not lp_version:
        print('To test priority mechanism you must use fast_io version of uasyncio.')
    else:
        ntasks = max(num_coros) + 10 #4
        if use_priority:
            loop = asyncio.get_event_loop(ntasks, ntasks, 0, ntasks)
            after = asyncio.after
            after_ms = asyncio.after_ms
        else:
            lp_version = False
            after = asyncio.sleep
            after_ms = asyncio.sleep_ms
            loop = asyncio.get_event_loop(ntasks, ntasks)
        s = 'Testing latency of priority task with coros blocking for {}ms.'
        print(s.format(processing_delay))
        if lp_version:
            print('Using priority mechanism.')
        else:
            print('Not using priority mechanism.')
        loop.create_task(run_test(processing_delay))
        loop.run_until_complete(report()) 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:26,代码来源:latency.py

示例12: _gauge

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def _gauge(self):
        now = utime.ticks_ms()
        if utime.ticks_diff(now, self._last_read_ts) > self._new_read_ms:
            self._last_read_ts = now
            r = self._t_os + (self._p_os << 3) + (1 << 6)
            self._write(BMX280_REGISTER_CONTROL, r)
            utime.sleep_ms(100)  # TODO calc sleep
            if self._chip_id == 0x58:
                d = self._read(BMX280_REGISTER_DATA, 6)  # read all data at once (as by spec)
                self._p_raw = (d[0] << 12) + (d[1] << 4) + (d[2] >> 4)
                self._t_raw = (d[3] << 12) + (d[4] << 4) + (d[5] >> 4)
            else:
                d = self._read(BMX280_REGISTER_DATA, 8)  # read all data at once (as by spec)
                self._p_raw = (d[0] << 12) + (d[1] << 4) + (d[2] >> 4)
                self._t_raw = (d[3] << 12) + (d[4] << 4) + (d[5] >> 4)
                self._h_raw = (d[6] << 8) + d[7]

            self._t_fine = 0
            self._t = 0
            self._h = 0
            self._p = 0 
开发者ID:lemariva,项目名称:uPySensors,代码行数:23,代码来源:bmx280.py

示例13: irq_handler

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def irq_handler(self, irq_pin):
        '''
        外部中断的相应函数
        '''
        # 如果当前正在处理中断,则忽略
        if not self.flag:
            return
        # 添加软件滤波
        utime.sleep_ms(50)
        if self.pin.value() == self.BUTTON_PRESS:
            # 判断当前按键状态是不是按下,如果是,则执行回调函数
            if self.flag and self.callback is not None:
                self.flag = False
                # 执行回调函数
                self.callback(self.pin)
                self.flag = True 
开发者ID:1zlab,项目名称:1ZLAB_MicroPython_ESP32_Tutorial,代码行数:18,代码来源:button.py

示例14: connect

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def connect(self, timeout=_CONNECT_TIMEOUT):
        end_time = time.time() + timeout
        while not self.connected():
            if self._state == self.DISCONNECTED:
                try:
                    self._get_socket()
                    self._authenticate()
                    self._set_heartbeat()
                    self._last_rcv_time = ticks_ms()
                    self.log('Registered events: {}\n'.format(list(self._events.keys())))
                    self.call_handler(self._CONNECT)
                    return True
                except BlynkError as b_err:
                    self.disconnect(b_err)
                    sleep_ms(self.TASK_PERIOD_RES)
                except RedirectError as r_err:
                    self.disconnect()
                    self.server = r_err.server
                    self.port = r_err.port
                    sleep_ms(self.TASK_PERIOD_RES)
            if time.time() >= end_time:
                return False 
开发者ID:blynkkk,项目名称:lib-python,代码行数:24,代码来源:blynklib_mp.py

示例15: wait

# 需要导入模块: import utime [as 别名]
# 或者: from utime import sleep_ms [as 别名]
def wait(self, delay):
        # Default wait implementation, to be overriden in subclasses
        # with IO scheduling
        if __debug__ and DEBUG:
            log.debug("Sleeping for: %s", delay)
        time.sleep_ms(delay) 
开发者ID:lemariva,项目名称:uPyCam,代码行数:8,代码来源:core.py


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