Pingo package documentation on pcDuino 3
Pingo provides a uniform API to program devices like the Raspberry Pi, BeagleBone Black, pcDuino etc. just like the Python DBAPI provides an uniform API for database programming in Python.
The API is object-oriented but easy to use: a board is an instance of a Board subclass. Every board has a dictionary called pins which lists all GPIO pins on the board. Each pin is an instance of a Pin subclass with attributes that you can inspect to learn about its capabilities.
The name Pingo is a tribute to Garoa Hacker Clube, where the project started (the words pingo and garoa are related in Portuguese). To our English-speaking friends we like to say that it means “pin, go!” – the main purpose of this package.
Basicly, there are two ways of installing Pingo:
- from Python Pip
- from Github (recommended)
Installing from PyPI
To install Pingo from PyPI (Python Package Index), first, make sure you have pip installed in your machine. On Linux machines, this usually means you have the python-pip package installed. You can check if you have pip in your machine by typing the following text on a shell prompt:
$ pip --version pip 1.0 from /usr/lib/python2.7/dist-packages (python 2.7)
If the output is similar from the one above, you can install Pingo by simple typing pip install pingo as root on you terminal. That’s it!
Installing from Github
Since Pingo is currently in alpha state and under heavy develpment, installing Pingo from Github may be a good idea. Besides that, it will be easy for you to contribute to the project, if you wish. See the Contributing section on the left menu.
To install Pingo from Github, you must have Git installed. Presuming you already have that, just type:
$ git clone https://github.com/garoa/pingo.git
After that, get into the pingo directory and setup Python to use your brand new directory as a library:
$ sudo python setup.py develop
Done! You are ready to program using Pingo!
To use pingo, the first step is to instatiate a concrete Board. Each Pingo driver is a concrete board, for example, pingo.rpi.RaspberryPi and pingo.arduino.ArduinoFirmata are two such boards.
Pingo can automatically detect the board in most common cases. If it is running on a supported board, pingo.detect.MyBoard() returns an proper board instance. If Pingo is running on an unsupported machine (eg. a PC running GNU/Linux), it will try to find a remote Arduino using the Firmata protocol via USB and – if succesfull – will return a pingo.arduino.ArduinoFirmata instance.
Once you have a board instance, its possible to access its pins through the board.pins dict.
import time import pingo board = pingo.detect.MyBoard() #instead pingo.pcduino.PcDuino() led = board.pins led.mode = pingo.OUT while True: led.toggle() time.sleep(.1)
pingo.pcduino.PcDuino() a pcDuino of driver that is extend the pingo.board.Board interface class.
The following table lists the drivers currently planned or under development.
Types of drivers
- Pingo and user code run on the board itself, using the Python interpreter installed in it.
- Pingo and user code run on host computer connected to board, controlling the board remotely. Useful for boards that are unable to run Python, like the Arduino UNO.
- Pingo and user code run on host computer emulating a dummy board in software. Useful for testing base classes from board.py and for teaching and demonstration.
Status of drivers
- level 0
- Digital I/O: get/set high/low status of digital pins (no PWM support).
- level 1
- Analog input: read values from analog pins.
- level 2
- PWM output: set variable value for digital pins with PWM capability.
- Some Python experiments have been done with the board. See the experiments/ directory for code that may be helpful to start a new driver for a board.
- Nothing has been done. Great opportunity for you to contribute with experiments and/or start a new driver.