bonylu
Posts: 3
Joined: Thu Jul 04, 2013 3:59 am

How to display data from sensors

Thu Jul 04, 2013 10:05 am

Hi fellows,
I collect data from some sensors, such as ultrasonic, temperature, humidity, etc.
The python script of the sensor is a function, and returns a value per second.
----------------------------------------------------------------
def xxx
return xxx
----------------------------------------------------------------
I use pygame to create a window showing a live video, and wanna display the data on the video,
however,the process will wait the sensor to return value in each loop.
---------------------------------------------------------------
while
sensor1.data() <-----------wait 1 second
sensor2.data() <----------wait 1 second
display.text1
display.text2
...
updatewindow
-----------------------------------------------------------------
So the sensor collection delay will cause low fps.

Is there a good solution to eliminate the delay? subprocess?

Thanks in advance,
Bony

User avatar
Davespice
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 1612
Joined: Fri Oct 14, 2011 8:06 pm
Location: London, United Kingdom
Contact: Website Twitter

Re: How to display data from sensors

Thu Jul 04, 2013 3:59 pm

Yeah you can do multi threading in Python no problem;
Have a read of this; http://www.tutorialspoint.com/python/py ... eading.htm

bonylu
Posts: 3
Joined: Thu Jul 04, 2013 3:59 am

Re: How to display data from sensors

Fri Jul 05, 2013 9:15 am

Davespice wrote:Yeah you can do multi threading in Python no problem;
Have a read of this; http://www.tutorialspoint.com/python/py ... eading.htm
Thanks. I think it useful. :P
But the question is that, how can father progress get returning value from sub-processes? :?:


Bony

Return to “Python”

Who is online

Users browsing this forum: Douglas6 and 6 guests