本文整理汇总了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)
示例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)
示例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)
示例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)
示例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())
示例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
示例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)
示例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)
示例9: ticks_add
# 需要导入模块: import utime [as 别名]
# 或者: from utime import ticks_add [as 别名]
def ticks_add(a, b):
return (a + b) % _PERIOD
示例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())
示例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)
示例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)