Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
358 views
in Technique[技术] by (71.8m points)

Temp sensor slows down my GUI python program (Python3, raspberry pi)

I have main program with GUI which redraws vectors.

In this gui program iam fast reading some data and draw them fluently on the canvas.

Problem i, when i calling temperature sensor, becasue he has delay about 1s and every time i read this, my GUI program gets stuck 1s for reading temp sensor data.

How can i solve this problem.

GUI.py

#MAKEING SOME GUI STAFF
from temperature import temp
while True:
     print(temp.temperatures())

">>>The temperature is 25 celsius"
#waiting about 1s and stucking GUI.py
">>>The temperature is 25,1 celsius"
#and over and over again .....

temperature.py

from w1thermsensor import W1ThermSensor
sensor = W1ThermSensor()

class temp(): 
    def temperatures():
        try:
            temperature = sensor.get_temperature()
            print("The temperature is %s celsius" % temperature)
            return(temperature)
        except:
            print("error")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...