http server loop while running LED scrolling loop #11053
-
So I'm pretty new to Python/micropython and am having an issue. I'm trying to take the string from my http request and have it printed to my LED screen. I want the http server to keep running but I also want the screen to keep scrolling my text. My current code is only running the LED screen once. Any help is appreciated. signage = ""
print("after signage set")
def wwwsvr():
cl, addr = s.accept()
print('client connected from', addr)
request = cl.recv(1024)
print("request:")
print(request)
request = str(request)
start = '='
stop = 'HTTP'
global signage
signage = str(request[request.find(start)+1 : request.find(stop)-1])
response = html
cl.send(resp)
cl.send(response)
cl.close()
print("Inside wwwsvr")
print(signage)
return str(signage)
def ledmsg(mytext):
#global signage
#Get the message length
length = len(mytext)
#Calculate number of columns of the message
column = (length * 8)
#Clear the display.
display.fill(0)
display.show()
#sleep for one one seconds
time.sleep(1)
for x in range(32, -column, -1):
#Clear the display
display.fill(0)
# Write the scrolling text in to frame buffer
display.text(str(mytext.replace('+', " ")) ,x,0,1)
#Show the display
display.show()
#Set the Scrolling speed. Here it is 50mS.
time.sleep(0.05)
print("inside ledmsg")
print(signage)
while True:
try:
wwwsvr()
ledmsg(signage)
except OSError as e:
cl.close()
print('connection closed')
print("outside functions") |
Beta Was this translation helpful? Give feedback.
Answered by
manwichmakesameal
Mar 21, 2023
Replies: 1 comment
-
Well, to answer myself: it's threading dummy. Use threading to fix this. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
manwichmakesameal
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, to answer myself: it's threading dummy. Use threading to fix this.