5

Is there documentation for RPi.GPIO? I have searched the web and can't find anything.

I know I can use pydoc or help() but this produces the following:-

wait_for_edge(...)
    Wait for an edge.  Returns the channel number or None on timeout.
    channel      - either board pin number or BCM number depending on which mode is set.
    edge         - RISING, FALLING or BOTH
    [bouncetime] - time allowed between calls to allow for switchbounce
    [timeout]    - timeout in ms

This is OK, in as far as it goes, but doesn't really explain. I assume the function blocks until the interrupt, but this is not stated. What are the limits/defaults for timeout?

I have the following code, which I start on boot. Pressing the button successfully shuts down, but I have noticed it also seems to shut down at other times.

I could add some code to verify the button push, or some circuitry to make it more robust, but though I would check the documentation first.

while True:
    # set an interrupt on a falling edge and wait for it to happen
    GPIO.wait_for_edge(INT, GPIO.FALLING)

    subprocess.call(['poweroff'], shell=True, \
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)

Edit 2016-01-03


I downloaded the source from SourceForge, which made things somewhat clearer, but the timeout parameter seems to be missing in action.

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • 1
    Have you tried here: http://raspi.tv/2013/rpi-gpio-basics-7-rpi-gpio-cheat-sheet-and-pointers-to-rpi-gpio-advanced-tutorials – Patrick Cook Jan 01 '16 at 10:15
  • 1
    it's common knowledge that you can always find the documentation on the source code and examples. Authors use seldescripted names: usually 'wait' means that :) – fcm Jan 01 '16 at 23:15

2 Answers2

9

The official documentation is http://sourceforge.net/p/raspberry-gpio-python/wiki/Examples/

It doesn't seem to have a traditional API style of documentation.

joan
  • 71,024
  • 5
  • 73
  • 106
  • 4
    This answers my question - with "No". I have tried teaching myself python many times over the last 2 years. I like the philosophy and the language itself (apart from classes - which are bizarre). When I want to develop something using a library I get lost in the woeful documentation, and take the easy path and use c or c++, with well documented libraries. – Milliways Jan 02 '16 at 02:40
  • 1
    I can grasp a language tg – fcm Jan 02 '16 at 03:17
  • 1
    @Milliways My pigpio Python module has, perhaps, more traditional documentation. Python classes are pretty much the same (in my opinion) with the Arduino class wrappers for motors/servos etc., i.e. pretty similar to C++ classes. – joan Jan 02 '16 at 10:07
3

I have finally found a Python library with documentation gpiozero

I recommend this to anyone attempting to manipulate GPIO with Python.

Just to clarify I also highly recommend the pigpio Python module which has more functionality.

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • This is not an answer to the posted question. gpiozero is a completely different software library – user3728501 Jul 21 '21 at 10:52
  • @user3728501 gpiozero is actually a wrapper for RPi.GPIO (although it can use other pin factories) – Milliways Jul 21 '21 at 11:22
  • Point still stands. It's not the same thing, and doesn't have the same use cases. OP specifically stated asking for documentation for RPI.GPIO, not gpiozero, which is completely different. – user3728501 Jul 21 '21 at 11:25
  • 1
    @user3728501 You seem to have failed to notice that I was the author of the original Question (more than 5 years ago). My additional Answer (while not detracting from the Answer I accepted) is intended to help any new uses who may read this. Even though I have since written an enhanced version of RPI.GPIO I still recommend gpiozero to any new users. It has exactly the same functionality - just better documented and easier to use. – Milliways Jul 21 '21 at 11:32
  • So you answered your own question with an answer which wasn't relevant to the question? – user3728501 Jul 21 '21 at 12:00
  • It would seem the original "desire" was to get a GPIO library with documentation since the OP "finally found" something, only the OP can comment on that. Since gpiozero wraps RPi.GPIO, I would debate that it is a "completely different software library". Consider that readers finding this question would likely find this answer, given by the OP, to be valuable. – user3481644 Jan 31 '23 at 16:36