user1354033
user1354033

Reputation: 213

Plotting real-time on Raspberry Pi with python and wxWidget

I'm trying to plot some data coming from the sensor on banana pi. For simplicity of development I use python and wxWidget. To plot the data I use matplotlib library. It's doing ok on my laptop, but when I launch it on banana pi, the plot is drawn very slow.

def on_redraw_timer(self, event):
    print datetime.datetime.now()
    self.data.append(getCurrentValue())
    self.draw_plot()

This code is executed every 100 ms and this is what it outputs

2016-03-06 10:51:47.530607
2016-03-06 10:51:47.880988
2016-03-06 10:51:48.211054
2016-03-06 10:51:48.538298
2016-03-06 10:51:48.864935
2016-03-06 10:51:49.190108
2016-03-06 10:51:49.514287
2016-03-06 10:51:49.851634
2016-03-06 10:51:50.178744
2016-03-06 10:51:50.503762

So it takes 300 ms to draw the plot. Which is unacceptable. Is it possible to fasten the drawing speed? Or should I use some other libraries?

Thank you!

Upvotes: 1

Views: 1305

Answers (1)

jhoepken
jhoepken

Reputation: 1858

I think that there is no real way of speeding things up on the banana pi. Keep in mind that you are using a tiny CPU with a very limited amount of RAM for the same application you usually use your laptop for. I'm not saying that you cannot run a GUI on the banana pi or use matplotlib, but the 100ms replot frequency is a little bit tough, as you have already experienced on your own. Especially since you run an operating system (linux, I guess) with a window manager that takes it's toll on the RAM and CPU as well.

As a suggestion, could you use your existing python script to extract the data and use gnuplot to display it? This could work at that frequency. There is even a gnuplot python interface, but this will most likely not solve your 300ms plot delay problem.

Upvotes: 1

Related Questions