-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NodeJS demo example ?! #49
Comments
Thanks for sharing your demo! How did you find about the AVR8js project? |
searching for Arduíno emulator. |
It'd probably take a few weeks of work. I think a more promising approach would be to call NodeJS (or another JavaScript runtime) from Java. You can probably even use the bare V8 JavaScript engine from Java, I'm pretty sure there are bindings available, and I think the simulator should run there pretty smoothly. I have recently tried to run it on deno, which is also based on V8, and it worked flawlessly (I hope to get that demo to YouTube at some point). So basically you found it on Google? I'm wondering how visible the project is for people who are looking for an Arduino emulator. |
Yes i'm running using graavm and j2v8. public class J2V8 {
public static void main(String[] args) throws IOException {
Path path = Paths.get("/media/ricardo/Dados/TEMP/testes-java/avr8js_demo_vanilla/run-v8.js");
NodeJS node = NodeJS.createNodeJS();
node.exec(path.toFile());
while (node.isRunning()) {
node.handleMessage();
}
}
} i need remove async / await to work |
It was actually a video on youtube .. I am making a number of improvements to the Arduino IDE, and one of the things I wanted to integrate was an emulator. Now i'm building a HMI / Interface builder... To make easy create visualizations and experiments.. |
That's super-cool Ricardo! I think that @LironHazan and @vitaliy-bobrov would love to see what you are doing here with the guitar effects :) I'm not experienced with J2V8, which V8 version does it use? Perhaps @benjamingr can give you some pointers if you get stuck on figuring out the performance issues... |
In fact, it runs at about the same speed as the browser ... on nodejs much faster ... I was impressed. |
|
Which speeds did you observe on Node vs the browser? There can be many factors which affect the speed of execution. For example, transpiling the code down to ES5 can slow down execution by adding extra code... |
simple benckmark J2V8 (attached code / avr8js_demo_vanilla/run-v8.js):Program running... NodeJS: v13.12.0
Time: Blink finished in 1 ms graalvm
Program running... package javascript.j2v8;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import com.eclipsesource.v8.NodeJS;
import com.eclipsesource.v8.V8;
public class J2V8 {
public static void main(String[] args) throws IOException {
Path path = Paths.get("/media/ricardo/Dados/TEMP/testes-java/avr8js_demo_vanilla/run-v8.js");
NodeJS node = NodeJS.createNodeJS();
node.exec(path.toFile());
while (node.isRunning()) {
node.handleMessage();
}
}
} PS: J2V8 need remove async / await .. only.. |
Running on: browserbundle.js:2522 Fetch finished loading: GET "http://localhost:3000/blink.hex". |
What if you remove the "TaskScheduler" and make |
Could you do this ? |
For comparison purposes I decided to share with you the results I obtained using |
Interesting! I have sent you a PR which disables timer1/2, I wonder how it compares with your previous measurements |
Improved Now
But dont respect to delay() like java version.. void loop() {
digitalWrite(LED_BUILTIN, HIGH);
Serial.println("V1");
delay(100);
digitalWrite(LED_BUILTIN, LOW);
Serial.println("V0");
delay(100);
} |
Timer 0 is used for delay. Timer 1/2 shouldn't make any difference with regards to We may be able to improve timer speed once #38 (and other related improvements) will be implemented |
I achieved the promising result using SIMAVR, which is easier to integrate without suffering from performance problem, and more portable. my Arduino IDE |
Very nice work @ricardojlrufino :-) I see that you also added auto complete and other useful features to the Arduino IDE, that's awesome! What are your next plans? Yes, it seems that SIMAVR is a better tool for the job. AVR8js was built with the web browser/Node.js environment in mind. There's an ongoing experiment for using Web Assembly (#35), but it might take some time. |
Create a more robust development environment (with file explorer) (https://github.com/ricardojlrufino/JExplorerTree) and improved layout (see in video: https://youtu.be/58tEhkvaeOk) Then I will re-implement the Autocomplete, as it was made for version 1.5.x, the version that was integrated into to official beta version (and stopped), didn’t stay with usability and poor performance, because includes other tools . I'm looking for collaborators, if only to test the improvements |
That looks awesome Ricardo! |
First, congratulations on the project.
I ended up not finding a pure nodejs version of the examples. and created the repository:
https://github.com/ricardojlrufino/avr8js_demo_node
I am thinking of some way of integrating with an application made in JAVA, a plugin for arduino IDE.
Java supports JavaScript code execution, but I believe it will be slow.
My first attempt was this and it got really slow: using: graalvm / graaljs
oracle/graaljs#296
The text was updated successfully, but these errors were encountered: