本文整理汇总了Python中pyb.delay函数的典型用法代码示例。如果您正苦于以下问题:Python delay函数的具体用法?Python delay怎么用?Python delay使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delay函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:stoggi,项目名称:microslides,代码行数:7,代码来源:main.py
示例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)
开发者ID:rolandvs,项目名称:GuyCarverMicroPythonCode,代码行数:26,代码来源:tft.py
示例3: test
def test():
mpu9150 = MPU9150("X")
testfunc(mpu9150)
print()
pyb.delay(250)
print("Repeating")
testfunc(mpu9150)
开发者ID:johannes-otto,项目名称:micropython-mpu9x50,代码行数:7,代码来源:magtest.py
示例4: flash
def flash(): # routine to flash blue LED when beat detected
b_LED.on()
pyb.delay(30)
b_LED.off()
开发者ID:Kurtizl,项目名称:Balancing-Robot,代码行数:7,代码来源:milestone3.py
示例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)
开发者ID:P3PO,项目名称:ArduGuitar,代码行数:27,代码来源:psmouse.py
示例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.')
开发者ID:wachutka,项目名称:Blech_Lab,代码行数:7,代码来源:blech_video.py
示例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
开发者ID:old-blighty,项目名称:de1-electonics-group-project,代码行数:7,代码来源:full.py
示例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)
开发者ID:gratefulfrog,项目名称:ArduGuitar,代码行数:7,代码来源:appT.py
示例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
开发者ID:prehensile,项目名称:Mk3-Firmware,代码行数:7,代码来源:wifi.py
示例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")
开发者ID:martinribelotta,项目名称:micropython,代码行数:7,代码来源:TestTimers.py
示例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)
开发者ID:P3PO,项目名称:ArduGuitar,代码行数:29,代码来源:ps2m.py
示例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
开发者ID:ernesto-g,项目名称:micropython,代码行数:29,代码来源:ModBus.py
示例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()
开发者ID:ffilipus,项目名称:micropython-lcd,代码行数:28,代码来源:example.py
示例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
开发者ID:rolandvs,项目名称:GuyCarverMicroPythonCode,代码行数:7,代码来源:L298N.py
示例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)
开发者ID:dhylands,项目名称:python_lcd,代码行数:7,代码来源:pyb_i2c_grove_rgb_lcd.py
示例16: cycleAll
def cycleAll():
vals = [0 for i in range(nbShiftRegs)]
for i in range(nbShiftRegs):
for j in range(8):
vals[i] |= 1<<j
testSPI(vals)
delay(100)
开发者ID:P3PO,项目名称:ArduGuitar,代码行数:7,代码来源:HMItest.py
示例17: main_client
def main_client(addr):
nic = network.WIZNET5K(pyb.SPI(2), pyb.Pin.board.Y5, pyb.Pin.board.Y4)
nic.ifconfig((SENSOR_IP, SENSOR_MASK, SENSOR_GATEWAY, SENSOR_DNS))
# print(nic.ifconfig())
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
count = 0
try:
s.connect(addr)
except:
pass
data = {
'serial_no':'1234567890',
'ip':SENSOR_IP,
'op':gOperator['OP_REGISTER'],
'type':gSensorType['TEMPERATURE']
}
DHT22.init()
while True:
pyb.delay(100)
hum, tem = measure()
print('%d hum:%f, tem:%f' % (count,hum, tem))
data['value'] = {'hum':hum, 'tem':tem}
count += 1
try:
send(s, 'post', '/test_pymagic', data)
print(s.recv(4096))
except:
pass
pyb.delay(1000)
开发者ID:kamijawa,项目名称:pymagic,代码行数:30,代码来源:main.py
示例18: __init__
def __init__(self, pinout, height=32, external_vcc=True, i2c_devid=DEVID):
self.external_vcc = external_vcc
self.height = 32 if height == 32 else 64
self.pages = int(self.height / 8)
self.columns = 128
# Infer interface type from entries in pinout{}
if "dc" in pinout:
# SPI
rate = 1 * 1024 * 1024
self.spi = pyb.SPI(2, pyb.SPI.MASTER, baudrate=rate, polarity=1, phase=0) # SCK: Y6: MOSI: Y8
self.dc = pyb.Pin(pinout["dc"], pyb.Pin.OUT_PP, pyb.Pin.PULL_DOWN)
self.cs = pyb.Pin(pinout["cs"], pyb.Pin.OUT_PP, pyb.Pin.PULL_DOWN)
self.offset = 0
self.cs.high()
pyb.delay(100)
self.cs.low()
else:
# Infer bus number from pin
if pinout["sda"] == "X9":
self.i2c = pyb.I2C(1)
else:
self.i2c = pyb.I2C(2)
self.i2c.init(pyb.I2C.MASTER, baudrate=400000) # 400kHz
self.devid = i2c_devid
# used to reserve an extra byte in the image buffer AND as a way to
# infer the interface type
self.offset = 1
# I2C command buffer
self.cbuffer = bytearray(2)
self.cbuffer[0] = CTL_CMD
开发者ID:JonHylands,项目名称:ssd1106,代码行数:31,代码来源:ssd1106.py
示例19: init_uart
def init_uart(self, uart_bus, baud_rate, update_rate):
self.uart = pyb.UART(uart_bus, baud_rate, read_buf_len=1000)
pyb.delay(50)
# get RMC and GGA sentences at 1 hz
if update_rate == 1:
self.send_command(PMTK_SET_NMEA_OUTPUT_RMCGGA)
self.send_command(PMTK_SET_NMEA_UPDATE_1HZ)
self.send_command(PMTK_API_SET_FIX_CTL_1HZ)
elif update_rate == 5:
# get RMC and GGA sentences at 5 hz
self.send_command(PMTK_SET_NMEA_OUTPUT_RMCGGA)
self.send_command(PMTK_SET_NMEA_UPDATE_5HZ)
self.send_command(PMTK_API_SET_FIX_CTL_5HZ)
elif update_rate == 10:
if baud_rate == 9600: # send less data if using slower baud rate
self.send_command(PMTK_SET_NMEA_OUTPUT_RMCONLY)
elif baud_rate == 57600:
self.send_command(PMTK_SET_NMEA_OUTPUT_RMCGGA)
else:
raise ValueError("Invalid baud rate:", baud_rate)
self.send_command(PMTK_SET_NMEA_UPDATE_10HZ)
# fix can't update at 10 hz
self.send_command(PMTK_API_SET_FIX_CTL_5HZ)
else:
raise ValueError("Invalid update rate:", update_rate)
开发者ID:Woz4tetra,项目名称:Atlas,代码行数:28,代码来源:adafruit_gps.py
示例20: ultrasound
def ultrasound():
Trigger = Pin('X3', Pin.OUT_PP)
Echo = Pin('X4',Pin.IN)
# Create a microseconds counter.
micros = pyb.Timer(2, prescaler=83, period=0x3fffffff)
micros.counter(0)
start = 0
end = 0
# Send a 20usec pulse every 10ms
while True:
Trigger.high()
pyb.udelay(20)
Trigger.low()
# Wait until pulse starts
while Echo.value() == 0: # do nothing
start = micros.counter() # mark time at rising edge
# Wait until pulse goes low
while Echo.value() == 1: # do nothing
end = micros.counter() # mark time at falling edge
# Duration echo pulse = end - start
# Divide this by 2 to take account of round-trip
# Speed of sound in air is 340 m/s or 29 us/cm
# Distance in cm = (pulse_width)*0.5/29
distance = int(((end - start) / 2) / 29)
print('Distance: ', distance, ' cm')
pyb.delay(500)
开发者ID:old-blighty,项目名称:de1-electonics-group-project,代码行数:32,代码来源:full.py
注:本文中的pyb.delay函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论