I'm trying to write a script for a LCD device called the uLCD32-pt and the issue is that you are required to connect to it with a baudrate of 9600 and in order to get a higher baud rate you have to connect to it, send a change baudrate command, then send the new commands at the newly set baudrate. My lcd display is going super slow when drawing pixels and I know its because of the baudrate so is their any way to change the baudrate after connecting to a device? Here is my code so far?
import serial
import time
#Connect to uLCD32-pt with autobaud
ser = serial.Serial(
port='/dev/ttyUSB0',
baudrate=9600,
timeout=1,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS
)
ser.write("U")
while(True):
#15 x white pixels
ser.write(chr(0x0050)+chr(0x0000)+chr(0x0001)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#1
ser.write(chr(0x0050)+chr(0x0000)+chr(0x0002)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#2
ser.write(chr(0x0050)+chr(0x0000)+chr(0x0003)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#3
ser.write(chr(0x0050)+chr(0x0000)+chr(0x0004)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#4
ser.write(chr(0x0050)+chr(0x0000)+chr(0x0005)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#5
ser.write(chr(0x0050)+chr(0x0000)+chr(0x0006)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#6
ser.write(chr(0x0050)+chr(0x0000)+chr(0x0007)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#7
ser.write(chr(0x0050)+chr(0x0000)+chr(0x0008)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#8
ser.write(chr(0x0050)+chr(0x0000)+chr(0x0009)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#9
ser.write(chr(0x0050)+chr(0x0000)+chr(0x000A)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#10
ser.write(chr(0x0050)+chr(0x0000)+chr(0x000B)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#11
ser.write(chr(0x0050)+chr(0x0000)+chr(0x000C)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#12
ser.write(chr(0x0050)+chr(0x0000)+chr(0x000D)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#13
ser.write(chr(0x0050)+chr(0x0000)+chr(0x000E)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#14
ser.write(chr(0x0050)+chr(0x0000)+chr(0x000F)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#15
ser.write(chr(0x0050)+chr(0x0000)+chr(0x0010)+chr(0x0000)+chr(0x000A)+chr(0x00FF)+chr(0x00FF))#16
In the documentation, the description of the baud rate property says:
Read or write current baud rate setting.
So I expect this line to work:
ser.baudrate = 115200
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With