本文整理汇总了Python中pyb.delay函数的典型用法代码示例。如果您正苦于以下问题:Python delay函数的具体用法?Python delay怎么用?Python delay使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delay函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calibrate
def calibrate():
with open("calibration.txt", "r") as f:
data = f.read()
while True:
print(clear_screen, end="")
print(data, end="")
pyb.delay(200)
示例2: testline
def testline( display ) :
print('testing line')
displaysize = display.size()
start = (int(displaysize[0] / 2), int(displaysize[1] / 2))
px = 0
py = 0
def draw(x, y) :
display.line(start, (x, y), randcolor())
for x in range(displaysize[0]) :
draw(px, py)
px += 1
for y in range(displaysize[1]) :
draw(px, py)
py += 1
for x in range(displaysize[0]) :
draw(px, py)
px -= 1
for y in range(displaysize[1]) :
draw(px, py)
py -= 1
pyb.delay(2000)
示例3: test
def test():
mpu9150 = MPU9150("X")
testfunc(mpu9150)
print()
pyb.delay(250)
print("Repeating")
testfunc(mpu9150)
示例4: flash
def flash(): # routine to flash blue LED when beat detected
b_LED.on()
pyb.delay(30)
b_LED.off()
示例5: loop
def loop():
global mstat,lmstat,mx,lmx,my,lmy,maxX,maxY
#get a reading from the mouse */
mouseWrite(0xeb) # /* give me data! */
mouseRead() # /* ignore ack */
mstat = mouseRead()
mx = mouseRead()
my = mouseRead()
if((mstat != lmstat) or
(mx !=lmx) or
(my != lmy)):
#/* send the data back up */
#//Serial.print(mstat, BIN);
print('X=',str(mx),'\tY=',str(my) + interpretStatByte(mstat))
lmstat = mstat
lmx = mx
lmy = my
#maxX = max(mx,maxX);
#maxY = max(my,maxY);
"""
Serial.print("maxX: ");
Serial.print(maxX,DEC);
Serial.print("\tmaxY: ");
Serial.println(maxY,DEC);
"""
pyb.delay(20)
示例6: clear_tastes
def clear_tastes(tastes = ['Y1', 'Y2', 'Y3', 'Y4'], duration = 10000):
for i in tastes:
pyb.Pin(i, pyb.Pin.OUT_PP).high()
pyb.delay(duration)
for i in tastes:
pyb.Pin(i, pyb.Pin.OUT_PP).low()
print('The purge is complete. This has been the most sucessful purge yet.')
示例7: uart_hash
def uart_hash():
# initialize UART(6) to output TX on Pin Y1
uart = UART(6)
while True:
uart.init(9600, bits=8, parity = 0, stop = 2)
uart.writechar(ord('#')) # letter '#'
pyb.delay(5) # delay by 5ms
示例8: mainLoop
def mainLoop(self):
while True:
if polling:
self.pollPollables()
self.processQ()
# put a sleep comand here to save energy
pyb.delay(self.mainLoopDelay)
示例9: wait_for_connection
def wait_for_connection():
print( "wifi.py: wait_for_connection()" )
global _state
while not nic().is_connected():
nic().update()
pyb.delay(100)
_state = NICState.CONNECTED
示例10: test_6
def test_6(self):
t0 = pyb.Timer(0)
t0.init(freq=1000)
t0.counter(0)
pyb.delay(100)
t0.deinit()
self.assertGT(t0.counter(), 8, "timer counter")
示例11: run
def run(cName='X7',dName='X8'):
p = PS2a.PS2(cName,dName)
mInit(p)
#setup local loop variabls
lmStat = 'y'
mStat = 'n'
lmx = '1'
mx = '0'
lmy = '1'
my = '0'
outputTemplate = 'X=%d\tY=%d\t%s'
while True:
p.write(0XEB) # poll
print('Write POLL')
p.read() # ignore the ACK
mstat = p.read() # status byte
mx = p.read() # delta-x byte
my = p.read() # delta-y byte
if mstat != lmstat or mx != lmx or my != lmy:
print (outputTemplate%(mx,my,interpretStat(mstat)))
lmstat = mstat
lmx = mx
lmy =my
pyb.delay(20)
示例12: _communicate
def _communicate(self, request, number_of_bytes_to_read):
_checkInt(number_of_bytes_to_read)
# Sleep to make sure 3.5 character times have passed
minimum_silent_period = _calculate_minimum_silent_period(self.serial.get_baudrate())
pyb.delay(minimum_silent_period)
# Write request
self.serial.write(request)
# Read response
answer = bytearray()
timeOutRead = 200
while True:
if self.serial.any():
answer = self.serial.read(number_of_bytes_to_read)
break
else:
pyb.delay(10)
timeOutRead-=1
if timeOutRead<=0:
break
#_________
if len(answer) == 0:
raise Exception('No communication with the instrument (no answer)')
return answer
示例13: lcd_fun
def lcd_fun():
# Main program block
lcd = HD44780()
# Pins 0-5 as above
lcd.PINS = ['Y1','Y2','Y3','Y4','Y5','Y6']
# Initialise display
lcd.init()
# Use it
lcd.set_line(0) # First line
lcd.set_string("ABCDEFGHIJKLMNOP") # Send a string
lcd.set_line(1) # Second line
lcd.set_string("1234567890123456") # Again
pyb.delay(3000) # 3 second delay
# Send some more
lcd.set_line(0)
lcd.set_string("*micropython-lcd")
lcd.set_line(1)
lcd.set_string("github.com/wjdp")
pyb.delay(3000)
# Done
lcd.clear()
示例14: brake
def brake( self ) :
""" Brake the motor by sending power both directions. """
self._forward.high()
self._backward.high()
self._speedControl.pulse_width_percent = 100
delay(1000)
self.speed = 0
示例15: hal_write_command
def hal_write_command(self, cmd):
"""Writes a command to the LCD."""
self.i2c.mem_write(cmd, self.i2c_addr, self.LCD_DDRAM)
if cmd <= 3:
# The home and clear commands require a worst
# case delay of 4.1 msec
delay(5)