Code Monkey home page Code Monkey logo

gpio's Introduction

plebgpio

plebgpio provides a high level API for GPIO operation of LEDs and buttons.  It can be run from Bash (Unix shell) or NodeJS. 

Key features: 
• The interface is higher level; for example one may write a color to an LED. 
• Operation does not require root privileges

WIP

This is not commplete.  'plebgpio' C code is fine but the Javascript code is not.

It was developed for Ubuntu Linux but may run on other distributions 

Concepts

No sudo

While root privilege is required to install 'plebgpio', it is not required to invoke it. 

Stateless binary program

Normal operation is done by invoking a compiled program ('plebgpio') from the shell or from NodeJS.  Parameters tell 'plebgpio' what to do.  The program iself holds no state.  Instead, the calling utility hands in parameters representing a command, and the current state.  The program executes the command and hands back a new state. 

So a series of shell calls would look like this.

export GPIO="";export GPIO=$(plebgpio initialize 1);
export GPIO=$(plebgpio write led1 $GPIO red)

The shell variable GPIO holds the state information.

Built-in structure

plebgpio is controlled with reference to LEDs and BTNs, not pins.  The mapping from one to another is coded into the program iself.  In fact, there are eight mappings available.  The actual mapping is selected with the initialize command.

//        ~  ~  ~   LED-0   ~  ~  ~       ~  ~  ~   LED-1   ~  ~  ~       ~  ~  ~   LED-2   ~  ~  ~     BTN-0   BTN-1   BTN-2  empty
//        R       G       B       W       R       G       B       W       R       G       B       W
    {     17 ,    27 ,    22 ,    22 ,    25 ,     8 ,     7 ,     7 ,    11 ,     9 ,    10 ,    10 ,    17 ,     4 ,     0 ,     0  },
    {      0 ,     0 ,     0 ,     0 ,     1 ,     1 ,     1 ,     0 ,     1 ,     1 ,     1 ,     0 ,     1 ,     0 ,     0 ,     0  },
//        0       1       2       3       4       5       6       7       8       9      10      11      12      13      14      15      16      

The first row gives pin numbers and the second row are bits to say what pins are available to plebgpio.

gpio's People

Contributors

briantbutton avatar

Watchers

 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.