Skip to content

NodeppOfficial/nodepp-arduino

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Nodepp-Arduino

The DOOM of Async Frameworks: Write Once, Build Everywhere, Process Everything.

Platform MIT License

Nodepp is a groundbreaking C++ framework that bridges the gap between the language's raw performance and the developer-friendly abstractions of Node.js. By providing a high-level, asynchronous API, Nodepp empowers you to write C++ with a familiar syntaxβ€”enabling seamless development across cloud servers, desktop apps, and microcontrollers.

At its core, Nodepp features a 100% asynchronous architecture powered by an internal Event Loop. This allows for massive concurrency and scalable task management with minimal code complexity, effectively bringing the "Write Once, Run Everywhere" philosophy to the world of high-performance C++.

πŸ”—: Nodepp The MOST Powerful Framework for Asynchronous Programming in C++

πŸ’‘ Featured Project: Asynchronous Enigma Machine

To showcase Nodepp for Arduino efficiency on "bare metal" hardware, we implemented a fully functional Enigma Machine on an Arduino Nano.

ezgif-7f4dec232396a556.mp4

Try it now: Enigma Machine Simulation

Features

  • πŸ“Œ: Lightweight: Minimal dependencies, making it ideal for IoT and embedded systems.
  • πŸ“Œ: Cross-Platform: Write once, run on Linux, Windows, Mac, Android, WASM and Arduino/ESP32.
  • πŸ“Œ: Memory Efficient: Custom ptr_t, queue_t, array_t and string_t primitives provide SSO (Small Stack Optimization) and zero-copy slicing.
  • πŸ“Œ: Scalability: Build applications that can handle large workloads and grow with your needs.
  • πŸ“Œ: Open-source: Contribute to the project's development and customize it to your specific requirements.

Batteries Included

  • πŸ“Œ: UTF Support: Comprehensive manipulation for UTF8, UTF16, and UTF32.
  • πŸ“Œ: Built-in JSON & RegExp: Full parsing and text processing engines.
  • πŸ“Œ: I/O Multiplexing: Support for Poll, Epoll, Kqueue, and WSAPoll.
  • πŸ“Œ: Reactive Programming: Built-in Events and Observers system.

Examples

Hello world

#include <nodepp.h>

using namespace nodepp;

void onMain() {
    console::enable(9600);
    console::log("Hello World!");
}

Coroutines

#include <nodepp.h>

using namespace nodepp;

void onMain() {

    ptr_t<uchar> IO ({ 2, 3, 4, 5 });
    for( auto x: IO ){ pinMode( x, OUTPUT ); }

    process::add( coroutine::add( COROUTINE(){
        static uchar pin = 0;
    coBegin

        while( true ){
            digitalWrite( pin, LOW );
            pin = ( pin + 1 ) % IO.size();
            digitalWrite( pin, HIGH );
        coDelay( 300 ); }

    coFinish
    }));

}

Events

#include <nodepp.h>
#include <nodepp/event.h>

using namespace nodepp;

event_t<> ev;

void onMain(){

    pinMode( 13, OUTPUT );

    ev.on([](){
        static bool b=0; b=!b;
        digitalWrite( 13, b );
    });

    ev.emit();

}

Timer

#include <nodepp.h>
#include <nodepp/timer.h>

using namespace nodepp;

void onMain(){

    pinMode( 13, OUTPUT );    

    timer::interval([=](){
        static bool b=0; b=!b;
        digitalWrite( 13, b );
    }, 1000 );

}

Promises

#include <nodepp.h>
#include <nodepp/promise.h>

using namespace nodepp;

void onMain(){ Serial.begin( 9600 );

    promise_t<int,except_t>([=]( res_t<int> res, rej_t<except_t> rej ){
        res( 10 );
    })

    .then([=]( int res ){ console::log( res ); })

    .fail([=]( except_t err ){ console::log( err.what() ); })

}

More Examples here

Learn By Projects

3 channel Asynchronous Led Chaser

IMAGE

LCD 16x2 Async Task

IMAGE

Event-Driven Button

IMAGE

Dining Philosophers

IMAGE

Asynchronous measurement

IMAGE

Asynchronous Traffic Light

IMAGE

3 Channel Asynchronous Counter

IMAGE

Enigma Machine

IMAGE

Nodepp Supports Other Platforms Too

Contribution

If you want to contribute to Nodepp, you are welcome to do so! You can contribute in several ways:

  • β˜• Buying me a Coffee
  • πŸ“’ Reporting bugs and issues
  • πŸ“ Improving the documentation
  • πŸ“Œ Adding new features or improving existing ones
  • πŸ§ͺ Writing tests and ensuring compatibility with different platforms
  • πŸ” Before submitting a pull request, make sure to read the contribution guidelines.

ko-fi

License

Nodepp-arduino is distributed under the MIT License. See the LICENSE file for more details.

Sponsor this project

Packages

No packages published

Contributors 2

  •  
  •  

Languages