How do I get the lcd.write ("blah blah") to refresh every ex amount of time as im using a varible


#1

Title says it all how can I refresh every 0.5 seconds so the varibles update. Thanks


#2

You’ll need to post some code for context. Right now the question is a little bit “how long is a piece of string.”


#3

I am wanting to display the time on my Display O Tron hat and when I run it only stays on the same time eg 14:44:44 and dosent refresh same with CPU temps how do I get it to refresh every 0.5 seconds. I have tried "while True: lcd.write (timenow) and it just writes the time all over the screen all 3 rows and dosent refresh and im just wanting to know a way to get it to refresh. Thanks


#4

Sounds like you were on the right track. Try adding an lcd.clear() before your lcd.write(timenow)


#5

And to be clear it won’t flicker or anything also do you know how to format the lines like LCD.write(“Temp”, temperature,“Pres:”, pressure "\n etc. Because when I use the comma to separate like in print it says unexpected more than one argument also can’t figure out how to do new line


#6

You should use .format() like, for example:

line = "Temp: {temp}, Pres: {pres}\n".format(temp=temperature, pres=pressure)
LCD.write(line)

See: https://pyformat.info