jdrexmo
Posts: 2
Joined: Sun Nov 08, 2015 2:45 am

Direction needed: simple graphics code

Mon Nov 09, 2015 2:31 am

Sorry if cross-posting is a faux pas here, but I need help with this as soon as possible and I thought maybe I asked in the wrong forum the first time.

I have a Raspberry Pi 2 with a no-touch HDMI backpack. I want to program some fairly simple graphics based on SPI input values. I have found sample code in Python for reading my analog values via MCP3008 and SPI. I'm trying to draw some bell curves on a graph according to those analog values (two values determine coordinates of a point, third value determines width of the curve beneath that point) in more or less real time (I'll be polling the MCP3008 inputs, but would like to instantly redraw when changes are detected). I do not need, or want, a GUI.

Can anyone give me a little direction how to code some basic drawing? In a way that can work with those analog input values?

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Direction needed: simple graphics code

Mon Nov 09, 2015 7:44 am

I think the fixation on "needing no GUI" is a bit misguided. Nothing stops you from configuring X to start a single app in fullscreen mode.

That said , have a look into Matplotlib and Numpy.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: Direction needed: simple graphics code

Tue Nov 10, 2015 3:09 pm

Or even gnuplot (gnuplot-x) ...one hacky way to to avoid 'GUI' (X Window system/desktop) could be to output your data to a file (or pipe), use gnuplot to render an image file and use fbi to display the image - depending on refresh rate requirements obviously...

Such a pity that (apparently) no-one has made anything like this in Python: http://mindchunk.blogspot.no/2012/09/op ... ry-pi.html

Maybe pygame modified to work with framebuffer: https://learn.adafruit.com/pi-video-out ... ramebuffer
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

Return to “Python”