msharma
Posts: 8
Joined: Tue Jun 28, 2016 9:59 am

Choosing a language

Tue Jun 28, 2016 2:23 pm

Hello.

I am currently planning to write a program which not only uses SPI and the GPIO but needs to have a graphical user interface. As far as I'm aware, the best tools for using SPI and GPIO are the wiringPi libraries. However, the graphical tools for C++, again as far as I'm aware, are not as good as those for python, and I am struggling to find well supported and documented python SPI libraries.

Furthermore, I am planning to use the camera module, and hence a good API for the camera would also be incredibly beneficial.

An option is having a C++ script running in the background and maybe saving info to a file which is being read by a python GUI which will act as I/O. However, this would raise issues with regards to writing and reading to a file at the same time.

I was wondering whether anybody could offer me any suggestions, especially regarding which APIs to used and anything I could use to synchronise timings between two different scripts.

Thanks

MarcScott
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 81
Joined: Sat Aug 08, 2015 11:30 am

Re: Choosing a language

Wed Jun 29, 2016 7:04 am

As often with these types of questions, you'll get opinions rather than answers.

For my two-pence worth, I'd recommend Python3. Excellent GPIO (have you tried gpiozero https://gpiozero.readthedocs.io/en/v1.2.0/ support and the PiCamera library is excellent and well documented https://picamera.readthedocs.io/en/release-1.11/

With regards to SPI, spidev seems popular, although I would have to agree the documentation isn't great

User avatar
ben_nuttall
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 231
Joined: Sun Aug 19, 2012 11:19 am
Location: Cambridge, UK
Contact: Website

Re: Choosing a language

Fri Jul 01, 2016 7:49 pm

GPIO Zero supports the SPI protocol and a few SPI devices too.

As for user interfaces, you could use PyGame Zero or just PyGame. There are others in Python, such as tkinker and qt...

If you want to use C++, there's a great C library called pigpio which is installed by default in Raspbian too. Documentation here: http://abyz.co.uk/rpi/pigpio/
Community Manager - Raspberry Pi Foundation
Author of GPIO Zero and creator of piwheels

User avatar
DougieLawson
Posts: 36554
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Choosing a language

Fri Jul 01, 2016 8:07 pm

ben_nuttall wrote:GPIO Zero supports the SPI protocol and a few SPI devices too.
Does it support two MCP3008s on a single RPi? If so do I daisy chain them on one SPI chip select or have one on /dev/spidev0.0 and the other on /dev/spidev0.1?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

timrowledge
Posts: 1289
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: Choosing a language

Fri Jul 01, 2016 10:26 pm

I'd use Squeak Smalltalk. Talk to wiringPi or pigpio easily - pigpio is included in the Raspbian distort now to support Scratch, which is written in Squeak. I've got support for i2c & api & 1wire devices as well as general gpio driving. Oh, and the camera module. Obviously, Squeak has good GUI support since Smalltalk is the system in which the entire concept was pretty much invented. Pretty good sound support too. Runs very nicely on a Pi2/3, decently on a 0.

The Squeak vm is (obviously) included in Raspbian and so you only need to download the image/changes/sources trio of files to get going.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

Return to “Beginners”