picandies
Posts: 186
Joined: Wed Nov 26, 2014 5:13 pm

Where's the pigpio tutorial?

Mon Nov 19, 2018 8:39 am

For the pigpio library, is there a solid tutorial (article, or step-by-step format) for getting things generally set up & working?

I opened some of the code snips, but that's not so much an explanation & very few comments are within. The pigrpio site itself seems to have a vast array of commands & their descriptions (a bit overwhelming). Looking for intro to "pigpio tutorial101", hello world type of article, which usually includes things to watch out for/gotchas.

User avatar
joan
Posts: 14097
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Where's the pigpio tutorial?

Mon Nov 19, 2018 8:59 am

I am not aware of any such tutorial.

The abyz.me.uk site documentation is intended for reasonably experienced programmers who will normally be familiar with API style documentation.

I'm afraid it is a few years since I started programming and have little memory of, or feel for, common pitfalls any more.

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: Where's the pigpio tutorial?

Mon Nov 19, 2018 12:35 pm

Not familiar with pigpio, though if you are writing stuff to do GPIO have you tryed using WiringPi instead? WiringPi is well supported, can be used from C, C++, FreeBASIC, Pascal, Assembly, or just about any other compiled programming language (and some interpreted for that).

There are a lot of good resources on WiringPi in many places.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

incognitum
Posts: 300
Joined: Tue Oct 30, 2018 3:34 pm

Re: Where's the pigpio tutorial?

Mon Nov 19, 2018 12:54 pm

You do not state which programming language you plan to use it with.
If Python, you can also start by using it indirectly through the more beginner friendly gpiozero abstraction.

https://gpiozero.readthedocs.io/en/stab ... _gpio.html

picandies
Posts: 186
Joined: Wed Nov 26, 2014 5:13 pm

Re: Where's the pigpio tutorial?

Mon Nov 19, 2018 5:52 pm

Yes everything is in Python. Not sure I follow you, is GPIOzero the same as pigpio, except in python? If they are not the same, what does one have to do with the other? Why use gpiozero instead of pigpio? what are the advantages/disadvantages? Is there a timing penalty?

User avatar
joan
Posts: 14097
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Where's the pigpio tutorial?

Mon Nov 19, 2018 7:09 pm

You can think of gpiozero as a front end to various GPIO library back ends, in programming terms you can call it a wrapper around several GPIO libraries.

gpiozero provides a "proper" Python abstraction around the likes of RPi.GPIO, pigpio, RPIO.GPIO etc.

gpiozero has extensive tutorials and provides many useful methods for handling all sorts of devices which may be connected to the Pi GPIO.

incognitum
Posts: 300
Joined: Tue Oct 30, 2018 3:34 pm

Re: Where's the pigpio tutorial?

Mon Nov 19, 2018 7:40 pm

Main advantage is that it is more high-level.

Want to keep blinking a LED attached to GPIO 17 while doing other stuff?

Code: Select all

from gpiozero import LED

led = LED(17)
led.blink()
Want to do the same with the pigpio Python bindings?
You will have to write your own code that starts a thread, and executes a loop among the lines of:

Code: Select all

pi = pigpio.pi()
pi.set_mode(17, pigpio.OUTPUT)

while True:
   pi.write(17,1)
   time.sleep(1)
   pi.write(17,0)
   time.sleep(1)
Any form of abstraction will come with a performance penalty.
Blinking a led isn't that time critical though :-)

Return to “General discussion”