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


Python utime.ticks_add方法代码示例

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


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

示例1: multi_fields

# 需要导入模块: import utime [as 别名]
# 或者: from utime import ticks_add [as 别名]
def multi_fields(t):
    print('Dynamic labels.')
    refresh(ssd, True)  # Clear any prior image
    nfields = []
    dy = wri.height + 6
    y = 2
    col = 15
    width = wri.stringlen('99.99')
    for txt in ('X:', 'Y:', 'Z:'):
        Label(wri, y, 0, txt)  # Use wri default colors
        nfields.append(Label(wri, y, col, width, bdcolor=None))  # Specify a border, color TBD
        y += dy

    end = utime.ticks_add(utime.ticks_ms(), t * 1000)
    while utime.ticks_diff(end, utime.ticks_ms()) > 0:
        for field in nfields:
            value = int.from_bytes(uos.urandom(3),'little')/167772
            overrange =  None if value < 70 else YELLOW if value < 90 else RED
            field.value('{:5.2f}'.format(value), fgcolor = overrange, bdcolor = overrange)
        refresh(ssd)
        utime.sleep(1)
    Label(wri, 0, 64, ' OK ', True, fgcolor = RED)
    refresh(ssd)
    utime.sleep(1) 
开发者ID:peterhinch,项目名称:micropython-nano-gui,代码行数:26,代码来源:color15.py

示例2: multi_fields

# 需要导入模块: import utime [as 别名]
# 或者: from utime import ticks_add [as 别名]
def multi_fields(t):
    print('multi_fields')
    refresh(ssd, True)  # Clear any prior image
    nfields = []
    dy = wri.height + 6
    y = 2
    col = 15
    width = wri.stringlen('99.99')
    for txt in ('X:', 'Y:', 'Z:'):
        Label(wri, y, 0, txt)  # Use wri default colors
        nfields.append(Label(wri, y, col, width, bdcolor=None))  # Specify a border, color TBD
        y += dy

    end = utime.ticks_add(utime.ticks_ms(), t * 1000)
    while utime.ticks_diff(end, utime.ticks_ms()) > 0:
        for field in nfields:
            value = int.from_bytes(uos.urandom(3),'little')/167772
            overrange =  None if value < 70 else YELLOW if value < 90 else RED
            field.value('{:5.2f}'.format(value), fgcolor = overrange, bdcolor = overrange)
        refresh(ssd)
        utime.sleep(1)
    Label(wri, 0, 64, ' OK ', True, fgcolor = RED)
    refresh(ssd)
    utime.sleep(1) 
开发者ID:peterhinch,项目名称:micropython-nano-gui,代码行数:26,代码来源:color96.py

示例3: call_later

# 需要导入模块: import utime [as 别名]
# 或者: from utime import ticks_add [as 别名]
def call_later(self, delay, callback, *args):
        self.call_at_(time.ticks_add(self.time(), int(delay * 1000)), callback, args) 
开发者ID:lemariva,项目名称:uPyCam,代码行数:4,代码来源:core.py

示例4: call_later_ms

# 需要导入模块: import utime [as 别名]
# 或者: from utime import ticks_add [as 别名]
def call_later_ms(self, delay, callback, *args):
        if not delay:
            return self.call_soon(callback, *args)
        self.call_at_(time.ticks_add(self.time(), delay), callback, args) 
开发者ID:lemariva,项目名称:uPyCam,代码行数:6,代码来源:core.py

示例5: trigger

# 需要导入模块: import utime [as 别名]
# 或者: from utime import ticks_add [as 别名]
def trigger(self, duration=0):  # Update end time
        self._running = True
        if duration <= 0:
            duration = self.duration
        tn = time.ticks_add(time.ticks_ms(), duration)  # new end time
        self.verbose and self._tstop is not None and self._tstop > tn \
            and print("Warning: can't reduce Delay_ms time.")
        # Start killer if can allocate and killer is not running
        sk = self.can_alloc and self._tstop is None
        # The following indicates ._killer is running: it will be
        # started either here or in ._run
        self._tstop = tn
        if sk:  # ._killer stops the delay when its period has elapsed
            asyncio.create_task(self._killer()) 
开发者ID:peterhinch,项目名称:micropython-samples,代码行数:16,代码来源:delay_ms.py

示例6: __call__

# 需要导入模块: import utime [as 别名]
# 或者: from utime import ticks_add [as 别名]
def __call__(self, ms):
        self.end = utime.ticks_add(utime.ticks_ms(), ms)
        return self 
开发者ID:peterhinch,项目名称:micropython-samples,代码行数:5,代码来源:ms_timer.py

示例7: trigger

# 需要导入模块: import utime [as 别名]
# 或者: from utime import ticks_add [as 别名]
def trigger(self, duration=0):  # Update end time
        if duration <= 0:
            duration = self.duration
        if self.can_alloc and self.tstop is None:  # No killer task is running
            self.tstop = time.ticks_add(time.ticks_ms(), duration)
            # Start a task which stops the delay after its period has elapsed
            self.loop.create_task(self.killer())
        self.tstop = time.ticks_add(time.ticks_ms(), duration) 
开发者ID:peterhinch,项目名称:micropython-samples,代码行数:10,代码来源:aswitch.py

示例8: trigger

# 需要导入模块: import utime [as 别名]
# 或者: from utime import ticks_add [as 别名]
def trigger(self, duration=0):  # Update end time
        now = ticks_ms()
        if duration <= 0:  # Use default set by constructor
            duration = self._duration
        self._retrn = None
        is_running = self()
        tstop = self._tstop  # Current stop time
        # Retriggering normally just updates ._tstop for ._timer
        self._tstop = ticks_add(now, duration)
        # Identify special case where we are bringing the end time forward
        can = is_running and duration < ticks_diff(tstop, now)
        if not is_running or can:
            schedule(self._do_trig, can) 
开发者ID:peterhinch,项目名称:micropython-tft-gui,代码行数:15,代码来源:delay_ms.py

示例9: ticks_add

# 需要导入模块: import utime [as 别名]
# 或者: from utime import ticks_add [as 别名]
def ticks_add(a, b):
        return (a + b) % _PERIOD 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:4,代码来源:rtc_time.py

示例10: trigger

# 需要导入模块: import utime [as 别名]
# 或者: from utime import ticks_add [as 别名]
def trigger(self, duration=0):  # Update end time
        self._running = True
        if duration <= 0:
            duration = self.duration
        tn = time.ticks_add(time.ticks_ms(), duration)  # new end time
        self.verbose and self._tstop is not None and self._tstop > tn \
            and print("Warning: can't reduce Delay_ms time.")
        # Start killer if can allocate and killer is not running
        sk = self.can_alloc and self._tstop is None
        # The following indicates ._killer is running: it will be
        # started either here or in ._run
        self._tstop = tn
        if sk:  # ._killer stops the delay when its period has elapsed
            self.loop.create_task(self._killer()) 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:16,代码来源:aswitch.py

示例11: call_after_ms

# 需要导入模块: import utime [as 别名]
# 或者: from utime import ticks_add [as 别名]
def call_after_ms(self, delay, callback, *args):
        self.call_at_lp_(time.ticks_add(self.time(), delay), callback, *args) 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:4,代码来源:core.py

示例12: call_after

# 需要导入模块: import utime [as 别名]
# 或者: from utime import ticks_add [as 别名]
def call_after(self, delay, callback, *args):
        self.call_at_lp_(time.ticks_add(self.time(), int(delay * 1000)), callback, *args) 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:4,代码来源:core.py


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