GPIO control libraries for C++, Python3, Node.js, Node-red

Post Reply
User avatar
tony.hong
Posts: 83
Joined: Tue Jun 04, 2019 1:49 pm
languages_spoken: korean
ODROIDs: All
Location: korea
Has thanked: 22 times
Been thanked: 28 times
Contact:

GPIO control libraries for C++, Python3, Node.js, Node-red

Unread post by tony.hong » Tue Jan 28, 2020 2:41 pm

GPIO control libraries for C++, Python3, Node.js, Node-red

The goals
  • Allows users to write code in a language they are familiar with
  • Allows users to easily change another language. APIs are very similar. So they can easily change it.
  • Allows users to control GPIO using diagrams. It supports Node-red.
  • Supports C++, Python3, Node.js, Rust, Go, Node-red, Arduino, Scratch, Etc.
  • Supports All Odroid boards.
  • Supports happy coding for a lot of users, for a lot of IoT projects. LoLIoT =>LOT
There are no libraries above v1.0.0. Until v1.0.0, API may not be backward compatible even if the MAJOR version does not change.

C++, Python3, Node.js for Odroid-N2 support Digital I/O, Analog I, Uart, I2c, Spi.
Node-red for Odroid-N2 supports Digital I/O, Analog I.

Try it out and comment on any issue(bug, enhancement, question, etc).

Note that these libraries only use physical pin numbers.

See the installation guide below.

utility: https://github.com/loliot/lot
Odroid-N2(C++): https://github.com/loliot/lot-odroid-n2
Python3: https://github.com/loliot/python3-lot
Node.js: https://github.com/loliot/node-lot-gpio
Node-red: https://github.com/loliot/node-red-contrib-lot

Docs

You can create C ++ Docs using Doxygen.

Python3 Docs is very comfortable.

Code: Select all

>>> import lot
>>> help(lot)
>>> help(lot.Gpio)
>>> help(lot.Spi)
>>> help(lot.I2c)
>>> help(lot.Uart)
>>> help(lot.Gpio.toggle)
...
Blink Example

Ref: 'lot' spelling is L, O, T.

C++

Code: Select all

#include <lot/lot.h>
#include <lot/Gpio.h>

int main( void )
{
    lot::init_time();
    lot::Gpio led( 13 );
    led.mode( lot::DOUT );

    while( 1 )
    {
        led.toggle();
        lot::delay_ms( 200 );
    }
}
Python3

Code: Select all

import lot

lot.init_time()
led = lot.Gpio(13)
led.mode(lot.DOUT)

while True:
    led.toggle()
    lot.delay_ms(200)

Node.js

Code: Select all

const lot = require("lot-gpio");

const led = new lot.Gpio(13);
led.mode(lot.DOUT);

setInterval(() => {
    led.toggle();
}, 200);
Node-red
.
node-red-lot-blink.gif
node-red-lot-blink.gif (65.41 KiB) Viewed 934 times
These users thanked the author tony.hong for the post (total 2):
mad_ady (Tue Jan 28, 2020 2:58 pm) • joerg (Tue Jan 28, 2020 3:35 pm)

User avatar
mad_ady
Posts: 7561
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 394 times
Been thanked: 296 times
Contact:

Re: GPIO control libraries for C++, Python3, Node.js, Node-red

Unread post by mad_ady » Tue Jan 28, 2020 2:58 pm

Quite a big project you have here :)

joerg
Posts: 942
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Has thanked: 13 times
Been thanked: 39 times
Contact:

Re: GPIO control libraries for C++, Python3, Node.js, Node-red

Unread post by joerg » Tue Jan 28, 2020 3:44 pm

Very impressive!

User avatar
tony.hong
Posts: 83
Joined: Tue Jun 04, 2019 1:49 pm
languages_spoken: korean
ODROIDs: All
Location: korea
Has thanked: 22 times
Been thanked: 28 times
Contact:

Re: GPIO control libraries for C++, Python3, Node.js, Node-red

Unread post by tony.hong » Tue Jan 28, 2020 6:05 pm

I will be the god of GPIO 8-) :lol:

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: Tenaja and 1 guest