Giter VIP home page Giter VIP logo

pi-crust's Introduction

Pi Crust

A collection of wrappers to make working with the Raspberry Pi GPIO interface more efficient.

To install, clone or download the repository and run python setup.py install.

Raspi Parallel GPIO

This class provides a parallel output on an array of pins, as well as an array of parallel input. The pins for both sides are stored in arrays and can be changed and even made the same, if your hardware setup makes that a safe thing to do. When the Rx function is called, the class fills its data slot "register" with the boolean values of the pins defined as input, which can then be read as an array. The Rx function does not take any arguments. The Tx function transmits or sends data over the pins defined as output in parallel. No clock is used as it isn't necessary in this case.

The Tx function takes an integer as an argument, which is then converted into an array of boolean values (binary) and the pins of output are set accordingly. If the resulting binary number does not fit in the array of pins, the number is output from least significant to most significant bit until the output is full, and the error field of the class is set to true. No warnings or failures are produced by over-filling the output other than that. The class does not accept a size, as it relies on the length of the array of pins it has at its disposal for output.

Usage:

The parallel class gives each input and output its own pin, so keep that in mind while building hardware that you're using this with.

from pi_crust import ParallelIO
gpioInterface = ParallelIO( )

Sending/Receiving:
gpioInterface.Rx() # Retrieve the state of the array of input pins
gpioInterface.Tx( integer ) # Send data over the array of output pins

Alternatively, a command line utility is provided for "on the fly" usage:

$ picrust-parallel <integer to send>

Raspi Bus GPIO

This class provides a bus interface to output (for now, it still reads input in parallel). The Rx function functions identical to the one in the Raspi Binary GPIO. The Tx function is called the same way although it does operate differently. Rather than iterating through an array of output and outputting on each pin, it iterates through the array of output and outputs it to one pin, cycles the clock on another pin so the value is read in (if using something like a shift register), then iterates to the next value. The class can be initialized with a size as well, so that the class will be aware of when to stop sending data.
The size defaults to 8 bits.

The class is initialized in a different way than the parallel one. It requires one argument, the pin to output data on. For a clock, it defaults to pin 23, although that can be set via an argument as well. The clock is somewhat makeshift and the implementation of that will likely change in the future.

This implementation uses fewer pins, so may be the better choice depending what you happen to be doing. Be aware that it is also subject to heavier changes, since it was mainly hacked together.

Usage:

The bus class uses two pins (per instance of the class) to provide a data output and a clock signal. For building hardware that requires a ton of outputs, this is probably the best class to use. If used with a mux, controlling multiple groups of hardware individually would be possible using only a few more pins to control mux output (probably best done in parallel, using an instance of the parallel wrapper in addition to this one.)

from pi_crust import BusIO
gpioInterface = BusIO( output pin, clock pin, output size )

Defaults:
gpioInterface = BusIO( output pin )

Sending/Receiving:
gpioInterface.Rx() # Retrieve data from the array of input pins
gpioInterface.Tx( integer ) # Send data over the output pin

Alternatively, a command line utility is provided for "on the fly" usage:

$ picrust-bus <integer to send> <pin to send over>

LICENSE

Licensed under the BSD license. See LICENSE for full license text.

Though not required by the license terms, please consider contributing, providing feedback, or simply dropping a line to say that this software was useful to you.

thenaterhood/pi-crust (c) 2012-2013 Nate Levesque (TheNaterhood), www.thenaterhood.com

pi-crust's People

Contributors

thenaterhood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.