Skip to content

Commit 77263ac

Browse files
committed
first release
0 parents  commit 77263ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4875
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 EDBC-REPO-NPM
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
# uNode++
3+
4+
**uNode++** is an innovative open source project that aims to make it easier to create applications in **C++**. This project introduces a high-level abstraction layer that allows developers to write **C++** code in a way that is similar to how they would write code in **NodeJS**. With **uNode++**, developers can leverage the advantages of the **C++** language while benefiting from the ease of use and flexibility that **NodeJS** offers. This unique combination of features makes **uNode++** a powerful tool for creating high-performance and scalable applications. Additionally, since it is an open source project, anyone can contribute and improve **uNode++** to fit their specific needs.
5+
6+
- **uNode++:** compatible with embed devices [here](https://github.com/EDBCREPO/uNODEPP)
7+
- **Node++:** compatible with PC and esp32 [here](https://github.com/EDBCREPO/NODEPP)
8+
9+
## Key Features
10+
11+
- Allows writing C++ code as if writing in NodeJS
12+
- Adds a high-level abstraction layer to simplify C++ application development
13+
- Includes an event loop that can handle multiple events and tasks on a single thread of execution
14+
- Supports coroutines, which allows running multiple tasks concurrently on a single thread
15+
- Open source project, meaning anyone can contribute and improve it
16+
- Compatible with several embeded platforms like PIC's and Arduino
17+
18+
## Usage
19+
20+
To use **uNode++**, simply include the `node++.h` header file in your project and start writing **C++** code as if you were writing in **NodeJS**. Here's a simple example:
21+
22+
```cpp
23+
#include <node++.h>
24+
25+
using namespace nodepp;
26+
27+
void _Ready() {
28+
console::log("Hello, World!");
29+
}
30+
```
31+
32+
Example - [here](https://github.com/EDBCREPO/uNODE/tree/main/examples)
33+
34+
## Contribution
35+
36+
If you want to contribute to **uNode++**, you are welcome to do so! You can contribute in several ways:
37+
38+
- Improving the documentation
39+
- Reporting bugs and issues
40+
- Adding new features or improving existing ones
41+
- Writing tests and ensuring compatibility with different platforms
42+
- Before submitting a pull request, make sure to read the contribution guidelines.
43+
44+
## License
45+
46+
**uNode++** is distributed under the MIT License. See the LICENSE file for more details.

examples/Coroutines.ino

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <node++.h>
2+
3+
using namespace nodepp;
4+
5+
void _Ready() { console::start(9600);
6+
7+
process::loop::add([=](){ static int itr = 10;
8+
_Start
9+
10+
while( itr --> 0 ){
11+
console::done(" Process 1:",itr); _Yield(1);
12+
}
13+
14+
_End
15+
});
16+
17+
process::loop::add([=](){ static int itr = 10;
18+
_Start
19+
20+
while( itr --> 0 ){
21+
console::error("Process 2:",itr); _Yield(1);
22+
}
23+
24+
_End
25+
});
26+
27+
}

examples/advancedBlikingLed.ino

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <node++/node++.h>
2+
#include <node++/timer.h>
3+
4+
using namespace nodepp;
5+
6+
void _Ready() {
7+
console::start(9600);
8+
9+
queue_t<int> q ({ 13, 12, 11, 10 });
10+
q.map([]( int pin ){ IO::mode( pin, OUTPUT ); });
11+
12+
timer::interval([=](){
13+
static auto p = q; p.next();
14+
15+
array_t<int> mode ({ p.get()->data,
16+
IO::digital::read(p.get()->data)
17+
});
18+
19+
IO::digital::write( mode[0], !mode[1] );
20+
21+
}, 100 );
22+
23+
}

examples/analogBlinkingLed.ino

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <node++.h>
2+
#include <node++/timer.h>
3+
4+
using namespace nodepp;
5+
6+
ulong frq = 1000;
7+
array_t<int> INP ({ 14 });
8+
array_t<int> OUT ({ 13, 12 });
9+
10+
void _Ready() {
11+
12+
for( auto x : OUT ) pinMode( x, OUTPUT );
13+
for( auto x : INP ) pinMode( x, INPUT );
14+
15+
timer::interval([](){
16+
frq = digitalRead( INP[0] );
17+
},1);
18+
19+
timer::interval([](){
20+
static bool b = 0; b=!b;
21+
digitalWrite( OUT[0], b );
22+
}, &frq );
23+
24+
timer::interval([](){
25+
static bool b = 0; b=!b;
26+
digitalWrite( OUT[1], b );
27+
},500);
28+
29+
}

examples/blikingLed.ino

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#define led LED_BUILTIN
2+
3+
#include <node++.h>
4+
#include <node++/timer.h>
5+
6+
using namespace nodepp;
7+
8+
void _Ready() {
9+
pinMode( led, OUTPUT );
10+
11+
timer::interval([](){
12+
static bool b = 0; b=!b;
13+
digitalWrite( led, b );
14+
},1000);
15+
16+
}

examples/counters.ino

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <node++.h>
2+
#include <node++/timer.h>
3+
4+
using namespace nodepp;
5+
6+
void _Ready() { console::start(9600);
7+
8+
timer::add([](){
9+
static int i = 0; i++;
10+
console::log("interval every: 1 second - ",i," seconds");
11+
return ( i >= 10 ) ? -1 : 1;
12+
}, 1000 );
13+
14+
}

examples/event.ino

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <node++.h>
2+
#include <node++/event.h>
3+
#include <node++/timer.h>
4+
5+
using namespace nodepp;
6+
7+
event_t<> ev;
8+
9+
void _Ready() {
10+
console::start(9600);
11+
12+
timer::timeout([=](){ ev.emit(); },1000);
13+
14+
ev.on([](){ console::log("hello world"); });
15+
16+
console::log("before event");
17+
18+
}

examples/generator.ino

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <node++.h>
2+
3+
using namespace nodepp;
4+
5+
_Generator( process_1 ) {
6+
int counter = 100;
7+
_Emit(int)
8+
9+
while( counter-->0 ){
10+
console::done(" :>",counter);
11+
_Return( counter );
12+
}
13+
14+
_Stop
15+
};
16+
17+
_Generator( process_2 ) {
18+
int counter = 100;
19+
_Emit(int)
20+
21+
while( counter-->0 ){
22+
console::error(":>",counter);
23+
_Return( counter );
24+
}
25+
26+
_Stop
27+
};
28+
29+
void _Ready() {
30+
console::start(9600);
31+
process_1 A; process_2 B;
32+
while( A()>0 && B()>0 ){}
33+
}

examples/helloWorld.ino

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <node++.h>
2+
#include <node++/timer.h>
3+
4+
using namespace nodepp;
5+
6+
void _Ready() {
7+
console::start(9600);
8+
9+
timer::interval([](){
10+
console::log("hello world");
11+
}, 100 );
12+
13+
}

0 commit comments

Comments
 (0)