Skip to content

Java library for controlling GPIO pins on Linux systems

License

Notifications You must be signed in to change notification settings

doordeck/simplegpio

Repository files navigation

SimpleGPIO

Build Status Coverage Status

A simple library for reading input and writing output to GPIO pins on Linux platforms using Sysfs.

Usage

SimpleGPIO is split into three components

  • simplegpio-core - Core components including a fallback input poller based on a naive pure Java implementation
  • simplegpio-module-libbulldog - An enhanced input poller using JNI and libbulldog; this version offers most stability and performance but least portability - the libbulldog library should be downloaded and named 'libbulldog-linux.so'
  • simplegpio-module-epoll - A performant and slightly more portable input poller based on calls to epoll using JNA

Example

    InputPollerFactory inputPollerFactory = InputPollerFactoryLocator.locate();
    PinFactory pinFactory = new PinFactory(inputPollerFactory);
    Pin pin = pinFactory.getPin(71); // P8_48 on a Beaglebone Black 
    DigitalInput in = pin.as(DigitalInput.class);
    in.addInterruptListener(new InterruptListener() {
              @Override
              public void interruptRequest(InterruptEventArgs args) {
                  System.out.println("Input! " + args.getEdge());
              }
          });

Building

SimpleGPIO uses maven.

mvn clean install

Credits

SimpleGPIO is based on a fork of silverspoon.io's libbulldog with JNA epoll support from jcommon-process.

License

SimpleGPIO is licensed under Apache License, Version 2.0.

About

Java library for controlling GPIO pins on Linux systems

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages