Giter Club home page Giter Club logo

piplates's Introduction

Pi Plates library

A library to interact with Pi-Plates from Java.

Pi-Plates are a family of stackable and interchangeable add-on circuit boards that allow you to interact with the outside world using your Raspberry Pi (http://www.pi-plates.com)

Requirements

Since this code uses the Pi4J library to control GPIO pins and the SPI bus, which interacts directly with the SoC's registers, your code must run as root for now.

For the same reason you cannot just run it on your development PC. Pi4J uses the native WiringPi library (http://wiringpi.com/) which is compiled for ARM and will not run on x86 processors.

I recommend creating a script to build your code locally, transfer it to your Raspberry Pi and start a JVM with remote debugging enabled. Most IDEs will give you the exact parameters to use on your JVM.

Usage

The library implements two classes that act as interfaces to the two types of Pi-Plates currently supported:

  • com.nahuellofeudo.piplates.daqcplate.DAQCPlate
  • com.nahuellofeudo.piplates.relayplate.RELAYPlate

You interact with a plate by creating an instance of the corresponding class and passing the plate's address to the constructor. For example, to interact with a DAQC-Plate configured on address 2, you would do:

// Initialize plate interface
DAQCPlate daqcPlate = new DAQCPlate(2);

// Interact with the plate
double hardwareVersion = daqcPlate.getHWRev();
double softwareVersion = daqcPlate.getFWRev();
int analogValue = daqcPlate.getADC(adcChannel);

The code includes synchronization primitives to avoid SPI bus collisions if multiple threads try to communicate at the same time, even with different plates.

The interfaces themselves are modeled following the same patterns as Pi-Plates' own Python library, although some methods and parameters have been renamed to follow Java naming conventions.

All methods include Javadocs with short descriptions of what they do and how to use them.

Installation

The library is published as a Maven dependency on Maven Central. Just include the following dependency in your POM.XML:

<dependency>
    <groupId>com.nahuellofeudo</groupId>
    <artifactId>piplates</artifactId>
    <version>0.1.1</version>
</dependency>

Known bugs and limitations

Only DAQCPlate and RELAYPlate are supported, as those are the only ones I personally have. If you want support for MOTORplate feel free to send me one :-)

The library is SLOW. I haven't optimized the communication with the different plates yet, so there are many delays that may be longer than necessary or not necessary at all. All communication is synchronized, though, so you can call all methods concurrently and they will execute one at a time and in order.

This is the first public release of this code, so expect the interfaces to change slightly in future releases.

License

The code is licensed under the GPL license (https://www.gnu.org/licenses/gpl.txt)

piplates's People

Contributors

nahuellofeudo avatar

Watchers

WallyWare 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.