本文整理汇总了Python中pyb.UART.writechar方法的典型用法代码示例。如果您正苦于以下问题:Python UART.writechar方法的具体用法?Python UART.writechar怎么用?Python UART.writechar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyb.UART
的用法示例。
在下文中一共展示了UART.writechar方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: uart_hash
# 需要导入模块: from pyb import UART [as 别名]
# 或者: from pyb.UART import writechar [as 别名]
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
示例2: uart_hashtag
# 需要导入模块: from pyb import UART [as 别名]
# 或者: from pyb.UART import writechar [as 别名]
def uart_hashtag():
the_word = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
# initialize X5 as trigger output
uart = UART(6)
uart.init(9600, bits=8, parity = None, stop = 2)
while True:
# initialize UART(6) to output TX on Pin Y1
for i in range(36):
uart.writechar(ord(the_word[i]))
uart.writechar(13)
uart.writechar(10)
pyb.delay(1000)
示例3: JYMCU
# 需要导入模块: from pyb import UART [as 别名]
# 或者: from pyb.UART import writechar [as 别名]
class JYMCU(object):
"""JY-MCU Bluetooth serial device driver. This is simply a light UART wrapper
with addition AT command methods to customize the device."""
def __init__( self, uart, baudrate ):
""" uart = uart #1-6, baudrate must match what is set on the JY-MCU.
Needs to be a #1-C. """
self._uart = UART(uart, baudrate)
def __del__( self ) : self._uart.deinit()
def any( self ) : return self._uart.any()
def write( self, astring ) : return self._uart.write(astring)
def writechar( self, achar ) : self._uart.writechar(achar)
def read( self, num = None ) : return self._uart.read(num)
def readline( self ) : return self._uart.readline()
def readchar( self ) : return self._uart.readchar()
def readall( self ) : return self._uart.readall()
def readinto( self, buf, count = None ) : return self._uart.readinto(buf, count)
def _cmd( self, cmd ) :
""" Send AT command, wait a bit then return result string. """
self._uart.write("AT+" + cmd)
udelay(500)
return self.readline()
def baudrate( self, rate ) :
""" Set the baud rate. Needs to be #1-C. """
return self._cmd("BAUD" + str(rate))
def name( self, name ) :
""" Set the name to show up on the connecting device. """
return self._cmd("NAME" + name)
def pin( self, pin ) :
""" Set the given 4 digit numeric pin. """
return self._cmd("PIN" + str(pin))
def version( self ) : return self._cmd("VERSION")
def setrepl( self ) : repl_uart(self._uart)
示例4: ord
# 需要导入模块: from pyb import UART [as 别名]
# 或者: from pyb.UART import writechar [as 别名]
elif command[2] == ord('6'): # DOWN PRESSED
print('Decreasing speed...')
(speedL,speedR) = speed(mode='dec',speedL=speedL,speedR=speedR)
print(speedL,speedR,vardirection)
if isRecording == True:
record(['speedDown',speedL,speedR])
elif command[2] == ord('7'): #LEFT PRESSED
print('Turning left...')
(speedL,speedR) = turn(turnDirection='l',speedL=speedL,speedR=speedR)
print(speedL,speedR,vardirection)
if isRecording == True:
record(['turnL',speedL,speedR])
elif command[2] == ord('8'): # RIGHT PRESSED
print('Turning right...')
(speedL,speedR) = turn(turnDirection='r',speedL=speedL,speedR=speedR)
print(speedL,speedR,vardirection)
if isRecording == True:
record(['turnR',speedL,speedR])
else: # writing to the robot with UART
message = 'command not understood'
print(message)
print(command)
for i in range(22):
uart.writechar(ord(message[i]))
uart.writechar(13)
uart.writechar(10)
示例5: UART
# 需要导入模块: from pyb import UART [as 别名]
# 或者: from pyb.UART import writechar [as 别名]
from pyb import UART
uart = UART(1)
uart = UART(1, 9600)
uart = UART(1, 9600, bits=8, parity=None, stop=1)
print(uart)
uart.init(2400)
print(uart)
print(uart.any())
print(uart.write('123'))
print(uart.write(b'abcd'))
print(uart.writechar(1))
# make sure this method exists
uart.sendbreak()
示例6: UART
# 需要导入模块: from pyb import UART [as 别名]
# 或者: from pyb.UART import writechar [as 别名]
#_________________________________________________
# Task 6: Function to generate UART sequence for '#' on Y1
# initialize UART(6) to output TX on Pin Y1
import pyb
from pyb import Pin, Timer, UART
print('Task 6: Using UART to send "#"')
uart = UART(6)
while True:
uart.init(9600, bits=8, parity = 0, stop = 2)
uart.writechar(ord('#'))
pyb.delay(5)