iiot2k / gpiox

Raspberry Pi gpiox node.js and C++ library
Apache License 2.0
5 stars 2 forks source link

@iiot2k/gpiox

platform

Raspberry Pi gpiox library


Thanks for the coffee !! 😁

Installation

npm install @iiot2k/gpiox

or add in your package.json:

"dependencies": {
    "@iiot2k/gpiox": "latest"
},

View on npmπŸ“Œ
View on GitHubπŸ“Œ
Report any issues hereπŸ“Œ

Detail

Functions

Node.js API

Node.js API functions are explained in document API.md
Node.js examples are on examples folder.

// node.js example turns output pin 20 on and after 3000ms off
"use strict";

const gpiox = require("@iiot2k/gpiox");

gpiox.init_gpio(20, gpiox.GPIO_MODE_OUTPUT, 1);

setTimeout(() => {
    gpiox.set_gpio(20, 0);
    gpiox.deinit_gpio(20);
}, 3000);

C++ API

This library uses C++ addon modules as interface to hardware.
Therefore, there is also a C++ interface to the drivers.
Unfortunately the C++ addon modules are not open source.
I provide the C++ static link libraries.
But if you are interested in the sources, I can send them to you.
Please send me an email with your name to iiot2k@gmail.com
I can only provide limited support for the C++ addon modules sources.

I have shown some C++ examples in the cpp directory and on GitHubπŸ“Œ
The C++ API functions are described in the header file gpiox_lib.h

// C++ example turns output on and after 3000ms off

#include <stdio.h>

#include "gpiox_lib.h"

void timeout_callback()
{
    gpiox::set_gpio(20, 0);
    gpiox::deinit_gpio(20);
}

int main()
{
    gpiox::init_gpio(20, gpiox::GPIO_MODE_OUTPUT, 1);
    gpiox::set_timeout(timeout_callback, 3000);

    return 0;
}