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


Python pyb.millis方法代码示例

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


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

示例1: play

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import millis [as 别名]
def play(self, pattern, kit=None):
        # channel volume
        self.midiout.control_change(10, self.volume, ch=self.channel)
        self.activate_drumkit(kit)
        # give MIDI instrument some time to load drumkit
        delay(200)

        try:
            while True:
                last_tick = millis()
                pattern.playstep(self.midiout, self.channel)
                timetowait = max(0, self.mpt - (millis() - last_tick))
                if timetowait > 0:
                    delay(int(timetowait))
        finally:
            # all sound off
            self.midiout.control_change(120, 0, ch=self.channel) 
开发者ID:SpotlightKid,项目名称:micropython-stm-lib,代码行数:19,代码来源:drumseq.py

示例2: performanceTest

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import millis [as 别名]
def performanceTest():
	d = 10000
	print("start. Wait for %d milis" % d)
	millis = pyb.millis
	endTime = millis() + d
	count = 0
	while millis() < endTime:
		count += 1
	print("Count: ", count) 
开发者ID:martinribelotta,项目名称:uPyIDE,代码行数:11,代码来源:Main_perf.py

示例3: get_pid

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import millis [as 别名]
def get_pid(self, error, scaler):
        tnow = millis()
        dt = tnow - self._last_t
        output = 0
        if self._last_t == 0 or dt > 1000:
            dt = 0
            self.reset_I()
        self._last_t = tnow
        delta_time = float(dt) / float(1000)
        output += error * self._kp
        if abs(self._kd) > 0 and dt > 0:
            if isnan(self._last_derivative):
                derivative = 0
                self._last_derivative = 0
            else:
                derivative = (error - self._last_error) / delta_time
            derivative = self._last_derivative + \
                                     ((delta_time / (self._RC + delta_time)) * \
                                        (derivative - self._last_derivative))
            self._last_error = error
            self._last_derivative = derivative
            output += self._kd * derivative
        output *= scaler
        if abs(self._ki) > 0 and dt > 0:
            self._integrator += (error * self._ki) * scaler * delta_time
            if self._integrator < -self._imax: self._integrator = -self._imax
            elif self._integrator > self._imax: self._integrator = self._imax
            output += self._integrator
        return output 
开发者ID:SingTown,项目名称:OpenMV-Pan-Tilt,代码行数:31,代码来源:pid.py

示例4: frame_data_repeat

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import millis [as 别名]
def frame_data_repeat(self, stage, use_old):
        self.asm_data[0] = addressof(self.image)
        self.asm_data[1] = addressof(self.image_old) if use_old else 0
        start = pyb.millis()
        count = 0
        while True:
            self.frame_data(stage)
            count +=1
            if pyb.elapsed_millis(start) > self.factored_stage_time:
                break
        if self.verbose:
            print('frame_data_repeat count = {}'.format(count)) 
开发者ID:peterhinch,项目名称:micropython-epaper,代码行数:14,代码来源:epdpart.py

示例5: frame_fixed_repeat

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import millis [as 别名]
def frame_fixed_repeat(self, fixed_value, stage):
        start = pyb.millis()
        count = 0
        while True:
            self.frame_fixed(fixed_value, stage)
            count +=1
            if pyb.elapsed_millis(start) > self.factored_stage_time:
                break
        if self.verbose:
            print('frame_fixed_repeat count = {}'.format(count)) 
开发者ID:peterhinch,项目名称:micropython-epaper,代码行数:12,代码来源:epdpart.py

示例6: _frame_fixed_timed

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import millis [as 别名]
def _frame_fixed_timed(self, fixed_value, stage_time):
        t_start = pyb.millis()
        t_elapsed = -1
        while t_elapsed < stage_time: 
            for line in range(LINES_PER_DISPLAY -1, -1, -1): 
                self._line_fixed(line, fixed_value, set_voltage_limit = False)
            t_elapsed = pyb.elapsed_millis(t_start) 
开发者ID:peterhinch,项目名称:micropython-epaper,代码行数:9,代码来源:epd.py

示例7: blink_millis

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import millis [as 别名]
def blink_millis():
    start = pyb.millis()
    led.on()
    while pyb.elapsed_millis(start) < 100:
        pass
    led.off()
    while pyb.elapsed_millis(start) < 200:
        pass
    led.on()
    while pyb.elapsed_millis(start) < 300:
        pass
    led.off()
    while pyb.elapsed_millis(start) < 1000:
        pass 
开发者ID:dhylands,项目名称:upy-examples,代码行数:16,代码来源:elapsed.py

示例8: sk

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import millis [as 别名]
def sk():
  count = 0
  millis = pyb.millis
  print('start')
  kon = millis() + 1000
  while millis() < kon:
    count += 1
  print('normal', count) 
开发者ID:dhylands,项目名称:upy-examples,代码行数:10,代码来源:counter_perf.py

示例9: skn

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import millis [as 别名]
def skn():
  count = 0
  millis = pyb.millis
  print('start')
  kon = millis() + 1000
  while millis() < kon:
    count += 1
  print("native", count) 
开发者ID:dhylands,项目名称:upy-examples,代码行数:10,代码来源:counter_perf.py

示例10: get_pid

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import millis [as 别名]
def get_pid(self, error, scaler):
    tnow = millis()
    dt = tnow - self._last_t
    output = 0
    if self._last_t == 0 or dt > 1000:
      dt = 0
      self.reset_I()
    self._last_t = tnow
    delta_time = float(dt) / float(1000)
    output += error * self._kp
    if abs(self._kd) > 0 and dt > 0:
      if isnan(self._last_derivative):
        derivative = 0
        self._last_derivative = 0
      else:
        derivative = (error - self._last_error) / delta_time
      derivative = self._last_derivative + \
                   ((delta_time / (self._RC + delta_time)) * \
                    (derivative - self._last_derivative))
      self._last_error = error
      self._last_derivative = derivative
      output += self._kd * derivative
    output *= scaler
    if abs(self._ki) > 0 and dt > 0:
      self._integrator += (error * self._ki) * scaler * delta_time
      if self._integrator < -self._imax: self._integrator = -self._imax
      elif self._integrator > self._imax: self._integrator = self._imax
      output += self._integrator
    return output 
开发者ID:wagnerc4,项目名称:flight_controller,代码行数:31,代码来源:pid.py


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