• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python time.sleep_ms函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_SHT_temperature

 def get_SHT_temperature(self):
  self._bus.writeto(self._address,TRI_T_MEASURE_NO_HOLD)
  sleep_ms(150)
  origin_data=self._bus.readfrom(self._address,2)
  origin_value=unp('>h',origin_data)[0]
  value=-46.85+175.72*(origin_value/65536)
  return value
开发者ID:radiumray,项目名称:mdxly,代码行数:7,代码来源:sht20.py


示例2: blink_all_timed

    def blink_all_timed(self, color, blink_duration, brightness=1):
        """ Blink the entire stand at 2Hz for blink_duration, turns off afterwards
        
        Arguments:
            color : can be 'red', 'green', 'blue', 
                    or a tuple of (r,g,b) where r, g, and b are between 0 and 255
            blink_duration : duration to blink for in seconds
            brightness : between 0 and 1, 0 is off, 1 is full brightness
        """
        start_time = time.ticks_ms()
        
        run_time = time.ticks_diff(time.ticks_ms(), start_time) 
        
        while run_time/1000 < blink_duration:
            if run_time % 500 < 250: 
                self.turn_all_to_color(color, brightness)
            else:
                self.turn_all_off()
            
            time.sleep_ms(1)
            run_time = time.ticks_diff(time.ticks_ms(), start_time) 

        # Ensure that all are off 
        self.turn_all_off()
        
开发者ID:DocVaughan,项目名称:CRAWLAB-Code-Snippets,代码行数:24,代码来源:main.py


示例3: main

def main():
    # Executed on boot
    global switchPin
    global switchstate
    global lightstate
    switchPin = machine.Pin(13, machine.Pin.IN, machine.Pin.PULL_UP)
    cm.setAP(False)   # We don't want AP in work mode by default
    savedData = boot.readSession()
    lightstate = int(savedData[1])
    switchstate = int(savedData[2])
    triac.activate(lightstate)
    print("Bulb reinitialised")
    attemptConnect()

    # Main program
    while(MainLoop):
        global compareTime
        time.sleep_ms(checkFrequency)
        if time.ticks_diff(time.ticks_ms(), compareTime) > reconnAttemptInterval:
            attemptConnect()
            print("Done MQTT connect")
            compareTime = time.ticks_ms()
        if not emergencyMode:
            checkInputChange(0)
            if cm.mqttActive:
                mqtt.check_msg()
        else:
            checkInputChange(1)
开发者ID:DanijelMi,项目名称:Micropython_MQTT_8266bulb,代码行数:28,代码来源:workMode.py


示例4: __init__

    def __init__(self, i2c_bus):

        # create i2c obect
        _bmp_addr = self._bmp_addr
        self._bmp_i2c = i2c_bus
        self._bmp_i2c.start()
        self.chip_id = self._bmp_i2c.readfrom_mem(_bmp_addr, 0xD0, 2)
        # read calibration data from EEPROM
        self._AC1 = unp('>h', self._bmp_i2c.readfrom_mem(_bmp_addr, 0xAA, 2))[0]
        self._AC2 = unp('>h', self._bmp_i2c.readfrom_mem(_bmp_addr, 0xAC, 2))[0]
        self._AC3 = unp('>h', self._bmp_i2c.readfrom_mem(_bmp_addr, 0xAE, 2))[0]
        self._AC4 = unp('>H', self._bmp_i2c.readfrom_mem(_bmp_addr, 0xB0, 2))[0]
        self._AC5 = unp('>H', self._bmp_i2c.readfrom_mem(_bmp_addr, 0xB2, 2))[0]
        self._AC6 = unp('>H', self._bmp_i2c.readfrom_mem(_bmp_addr, 0xB4, 2))[0]
        self._B1 = unp('>h', self._bmp_i2c.readfrom_mem(_bmp_addr, 0xB6, 2))[0]
        self._B2 = unp('>h', self._bmp_i2c.readfrom_mem(_bmp_addr, 0xB8, 2))[0]
        self._MB = unp('>h', self._bmp_i2c.readfrom_mem(_bmp_addr, 0xBA, 2))[0]
        self._MC = unp('>h', self._bmp_i2c.readfrom_mem(_bmp_addr, 0xBC, 2))[0]
        self._MD = unp('>h', self._bmp_i2c.readfrom_mem(_bmp_addr, 0xBE, 2))[0]

        # settings to be adjusted by user
        self.oversample_setting = 3
        self.baseline = 101325.0

        # output raw
        self.UT_raw = None
        self.B5_raw = None
        self.MSB_raw = None
        self.LSB_raw = None
        self.XLSB_raw = None
        self.gauge = self.makegauge() # Generator instance
        for _ in range(128):
            next(self.gauge)
            time.sleep_ms(1)
开发者ID:micropython-IMU,项目名称:micropython-bmp180,代码行数:34,代码来源:bmp180.py


示例5: activity

 def activity(self):
     if not self.debounced:
         time.sleep_ms(self.act_dur)
         self.debounced = True
     if self.int_pin():
         return True
     return False
开发者ID:osisoft,项目名称:OMF-Samples,代码行数:7,代码来源:LIS2HH12.py


示例6: playmusic

def playmusic():
    for i in range(0, len(musiclist), 1):
        display.show(str(musiclist[i]))
        music.pitch(round(round(tonelist[musiclist[i]])), PWM(Pin(27)))
        time.sleep_ms(round(500 * rhythmlist[i]))
        music.stop(PWM(Pin(27)))
        time.sleep_ms(10)
开发者ID:radiumray,项目名称:mdxly,代码行数:7,代码来源:mixly.py


示例7: diagnostic

def diagnostic():

    n = np.n
    print("Count = ", n)

    cycle(3, 1000)
    cycle(10, 100)
    cycle(10, 50)
    cycle(10, 30)

    for j in range(0, 40):
        for i in range(0, n):
            r = 10
            if uos.urandom(1) <= b'\x30':
                r = 255

            np[(i-1) % n] = (0, 0, 0)
            np[i] = (r, 10, 10)
            np.write()

            time.sleep_ms(30)

    for j in range(255, 0, -5):
        for i in range(0, n):
            np[i] = (j, 0, 0)
            np.write()
            time.sleep_ms(10)
开发者ID:mampersat,项目名称:minions,代码行数:27,代码来源:main.py


示例8: cycle

def cycle(iterations, speed):
    for i in range(0, iterations):
        for i in range(0, np.n):
            np[(i-1) % np.n] = (0, 0, 0)
            np[i] = (10, 10, 10)
            np.write()
            time.sleep_ms(speed)
开发者ID:mampersat,项目名称:minions,代码行数:7,代码来源:main.py


示例9: get_SHT_relative_humidity

 def get_SHT_relative_humidity(self):
  self._bus.writeto(self._address,TRI_RH_MEASURE_NO_HOLD)
  sleep_ms(150)
  origin_data=self._bus.readfrom(self._address,2)
  origin_value=unp('>H',origin_data)[0]
  value=-6+125*(origin_value/65536)
  return value
开发者ID:radiumray,项目名称:mdxly,代码行数:7,代码来源:sht20.py


示例10: rainbow_cycle

def rainbow_cycle(wait):
  for j in range(255):
    for i in range(n):
      rc_index = (i * 256 // n) + j
      np[i] = wheel(rc_index & 255)
    np.write()
    time.sleep_ms(wait)
开发者ID:RuiSantosdotme,项目名称:Random-Nerd-Tutorials,代码行数:7,代码来源:esp32_esp8266_ws2812b.py


示例11: readAltitude

def readAltitude():
    toggleOneShot()         # Toggle the OST bit causing the sensor to immediately take another reading

    # Wait for PDR bit, indicates we have new data
    counter = 0
    while( (IIC_Read(STATUS) & 0x02) == 0):
        counter = counter + 1
        if(counter > 600):
            # Error out after max of 512ms for a read
            return(-1)
        time.sleep_ms(1)

    # Read pressure registers
    data = bytearray(3)
    counter = 0
    nBytes = 0
    while True:
        nBytes = i2c.readfrom_mem_into(MPL3115Address, OUT_P_MSB, data)
        if nBytes == 3:
            break
        counter = counter + 1
        if(counter > 500):
            # Error out after max of 512ms for a read
            return(0x00)
        time.sleep_ms(1)            # wait 1msec

    msb = data[0]
    csb = data[1]
    lsb = data[2]

    value = (msb << 16) | (csb << 8) | lsb
    value = value >> 4
    Height = float(value) / 16.0
    return(Height)
开发者ID:AndersonJV,项目名称:IoT_ICTP_Workshop,代码行数:34,代码来源:main.py


示例12: cylon

def cylon(*, start=0, end=0, colors=(b'\xff\x22\x33\x40',), sleep_ms=250,
          verbose=False):
  """All this has happened before and all this will happen again."""
  assert len(colors) in (1,2), 'only 1 or 2 colors allowed'
  end = _default_num_leds(end)
  byte_end = end*4
  byte_start = start*4
  direction = 4
  pos = byte_start
  led_data = bytearray(led_off*end)
  while True:
    led_data[pos:pos+4] = colors[0]
    if len(colors) > 1:
      led_data[byte_end-pos-4:byte_end-pos] = colors[1]
    test(led_data, num_leds=end, rotate=0)
    if verbose:
      print('LED #', pos//4)
    time.sleep_ms(sleep_ms)
    led_data[pos:pos+4] = led_off
    if len(colors) > 1:
      led_data[byte_end-pos-4:byte_end-pos] = led_off
    pos += direction
    if pos >= byte_end or pos < byte_start:
      direction = -direction
      pos += direction*2  # Undo and go back.
开发者ID:gpshead,项目名称:life_circle,代码行数:25,代码来源:apa102.py


示例13: test_main

def test_main():
    """Test function for verifying basic functionality."""
    print("Running test_main")
    i2c = I2C(scl=Pin(5), sda=Pin(4), freq=400000)
    lcd = I2cLcd(i2c, DEFAULT_I2C_ADDR, 2, 16)
    lcd.putstr("It Works!\nSecond Line")
    sleep_ms(3000)
    lcd.clear()
    count = 0
    while True:
        lcd.move_to(0, 0)
        lcd.putstr("%7d" % (ticks_ms() // 1000))
        sleep_ms(1000)
        count += 1
        if count % 10 == 3:
            print("Turning backlight off")
            lcd.backlight_off()
        if count % 10 == 4:
            print("Turning backlight on")
            lcd.backlight_on()
        if count % 10 == 5:
            print("Turning display off")
            lcd.display_off()
        if count % 10 == 6:
            print("Turning display on")
            lcd.display_on()
        if count % 10 == 7:
            print("Turning display & backlight off")
            lcd.backlight_off()
            lcd.display_off()
        if count % 10 == 8:
            print("Turning display & backlight on")
            lcd.backlight_on()
            lcd.display_on()
开发者ID:dhylands,项目名称:python_lcd,代码行数:34,代码来源:esp8266_i2c_lcd_test.py


示例14: knight_rider

def knight_rider(loop=100, delay=50):
    """ Show Knight Rider animation
    loop = number of loops
    delay = sleep time between steps
    based on sin function
    """
    periods = 16

    # syncrhonize the two cos waves
    # this math is based on measurements vs. understanding what's going on
    np_div = np.n / 3.3

    t = 0
    for i in range(0, loop):
        t += 1
        for p in range(0, np.n):

            # this controls speed - higher is faster
            f = t * 3.2

            v1 = math.cos(f / periods + p/np_div) - 0.7
            v1 = max(0, v1)

            v2 = math.cos(-f / periods + p/np_div) - 0.7
            v2 = max(0, v2)

            b = int(v1 * 50) + int(v2 * 50)

            np[p] = (b, 0, 0)

        np.write()
        time.sleep_ms(delay)
开发者ID:mampersat,项目名称:minions,代码行数:32,代码来源:main.py


示例15: _raw_temp_humi

 def _raw_temp_humi(self, temp_acc=RES_14_BIT, humi_acc=RES_14_BIT):
     """
     Initiate a temperature and humidity sensor reading in one operation. 
     This safes time (and thereby energy). Accuracy for both sensors can 
     be specified. Same valid accuracy values apply to both seonsors.
     """
     if not temp_acc in (RES_11_BIT, RES_14_BIT):
         raise ValueError('Temperature measure accuracy invalid!')
     if not temp_acc in (RES_8_BIT, RES_11_BIT, RES_14_BIT):
         raise ValueError('Humidity measure accuracy invalid!')
     config = C_MODE_BOTH
     if temp_acc == RES_11_BIT:
         config = config | C_TEMP_11BIT
     elif temp_acc == RES_14_BIT:
         config = config | C_TEMP_14BIT
     if humi_acc == RES_8_BIT:
         config = config | C_HUMI_8BIT
     elif humi_acc == RES_11_BIT:
         config = config | C_HUMI_11BIT
     elif humi_acc == RES_14_BIT:
         config = config | C_HUMI_14BIT
     self._config(config)
     self._send(R_TEMP)
     sleep_ms(20)
     raw = self._recv(4)
     return (raw[1] + (raw[0] << 8), raw[3] + (raw[2] << 8))
开发者ID:PeteBoucher,项目名称:micropython-hdc1008,代码行数:26,代码来源:hdc1008.py


示例16: cycle

def cycle(r, g, b, wait):
  for i in range(n):
    for j in range(n):
      np[j] = (0, 0, 0)
    np[i % n] = (r, g, b)
    np.write()
    time.sleep_ms(wait)
开发者ID:RuiSantosdotme,项目名称:Random-Nerd-Tutorials,代码行数:7,代码来源:esp32_esp8266_ws2812b.py


示例17: test

def test(t):
    publish("test 1.3")
    for i in range(0, lights, 3):
        np[i] = (100,100,100)
        np[(i-3) % lights] = (0,0,0)
        np.write()
        time.sleep_ms(100)
开发者ID:mampersat,项目名称:minions,代码行数:7,代码来源:main.py


示例18: connectWiFi

 def connectWiFi(self,ssid,passwd):
  self.sta.active(True)
  self.sta.connect(ssid,passwd)
  while(self.sta.ifconfig()[0]=='0.0.0.0'):
   sleep_ms(200)
   print('Connecting to network...')
  print('WiFi Connection Successful,Network Config:%s'%str(self.sta.ifconfig()))
开发者ID:radiumray,项目名称:mdxly,代码行数:7,代码来源:mpython.py


示例19: bin_walk_2

def bin_walk_2():
    """ Display incrementing binary digit
    Only make neopixel changes that are necessary - faster
    16 lights = 00:03:17
    39 lights ~ 100 years
    """
    b = 0
    while True:
        # find the first OFF bit
        # probably a better way to do this with log() etc
        t = 0
        while (b & pow(2, t)):
            t += 1

        # is this the last bit on the strip
        if (t == np.n):
            b = 0
            time.sleep(1)
        else:
            np[t] = (5, 5, 5)
            # np[t] = (uos.urandom(1)[0], uos.urandom(1)[0], uos.urandom(1)[0])

        for i in range(0, t):
            np[i] = (0, 0, 0)
        np.write()

        b += 1

        # time.sleep_ms(168750) # 8 bits = 6 hours
        time.sleep_ms(14063)  # 8 bits = 30min
开发者ID:mampersat,项目名称:minions,代码行数:30,代码来源:main.py


示例20: __init__

    def __init__(self, i2c=None, sda='P22', scl='P21'):
        if i2c is not None:
            self.i2c = i2c
        else:
            self.i2c = I2C(0, mode=I2C.MASTER, pins=(sda, scl))

        self.sda = sda
        self.scl = scl
        self.clk_cal_factor = 1
        self.reg = bytearray(6)
        self.wake_int = False

        try:
            self.read_fw_version()
        except Exception:
            time.sleep_ms(2)
        try:
            # init the ADC for the battery measurements
            self.poke_memory(ANSELC_ADDR, 1 << 2)
            self.poke_memory(ADCON0_ADDR, (0x06 << _ADCON0_CHS_POSN) | _ADCON0_ADON_MASK)
            self.poke_memory(ADCON1_ADDR, (0x06 << _ADCON1_ADCS_POSN))
            # enable the pull-up on RA3
            self.poke_memory(WPUA_ADDR, (1 << 3))
            # make RC5 an input
            self.set_bits_in_memory(TRISC_ADDR, 1 << 5)
            # set RC6 and RC7 as outputs and enable power to the sensors and the GPS
            self.mask_bits_in_memory(TRISC_ADDR, ~(1 << 6))
            self.mask_bits_in_memory(TRISC_ADDR, ~(1 << 7))

            if self.read_fw_version() < 6:
                raise ValueError('Pytrack firmware out of date')

        except Exception:
            raise Exception('Pytrack board not detected')
开发者ID:H-LK,项目名称:pycom-libraries,代码行数:34,代码来源:pytrack.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python time.split函数代码示例发布时间:2022-05-27
下一篇:
Python time.sleep函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap