Welcome Guest! To enable all features please Login or Register.
Go to last post Go to first unread
#1 Posted : Thursday, February 22, 2018 10:57:46 PM(UTC)

Rank: Member

Groups: Registered
Joined: 3/20/2017(UTC)
Posts: 10

Thanks: 1 times
Custom nodes in Embrio are meant to be very powerful tool for convenient programming and for filling missing functionality of basic Embrio library. I would gladly switch from writing code in Arduino editor to Embrio because of its visualization convenience, but at the moment I can't because of lack of information.
Here is what I am talking about:
1. To understand how to write code for nodes I must understand how it works, how it is imlemented in that model of programming that I am used to in Arduino editor. Some "underhood" explanation would be very useful. For example in Docs in "Editing nodes definition" you explain update conditions under drop-down menu:
Declarations: Here you can write variables and functions that can be used from any code in the node.
Out of this I make an assumption that if I check "touches physical pin" then code written in Declarations is placed in Arduino editor before "Setup" section where I usually do my declarations. So I try to make my own sensor read node:

And compiler returns me an error: "_value" was not declared in the scope of "Every update". But wait a minute, docs told me that in "Declarations" I can write variables and functions that can be used from any code in the node. It brings confusion. My assumption was wrong?
At this point I realize I dont understand how it really works and documentation doesn't give me an answer. What happened with my variable, why it became undeclared?
Encapsulation paragraph in "Custom Arduino Node Notes" gives a glimpse on this telling that nodes don't have global variables, but doesn't explain implementation.
Conclusion: Needed more detailed explanation what happens to code placed in all sections of custom node. Is it converted to something else? Is variable name changed during compiling?

2. Reference.
As Embrio has its own functions and syntax of accessing inputs, outputs, triggers and so on it could be good idea to make a reference list of all of it. Now I have to gather that info through all articles in Docs anf if I forget something I need to look through it all again to recover. Syntax and Functions should be gathered in one place.

These are difficulties I encountered trying to start working with Embrio. Maybe I am not the only one. Hope this feedback will help to make your product better. I really enjoy it but it needs to be explained a bit better to understand it's concepts.

Thank you.
#2 Posted : Friday, February 23, 2018 5:12:24 AM(UTC)

Rank: Administration

Groups: Administrators
Joined: 12/11/2014(UTC)
Posts: 661

Thanks: 1 times
Was thanked: 36 time(s) in 33 post(s)
You should be able to access _value the way you posted, I suspect the problem is that you wrote Input_In_Min instead of Input_In.Min. Does it work if you change it? Further evidence that I need better documentation (and maybe more code validators on the nodes to catch stuff like that). I agree with you on that, I will do another pass through.

Embrio does a lot of transforming of code when it compiles. The generated code isn't very readable, so I have it hidden, but you are right there are times when I need to look at the generated code to debug when I am working on new nodes. I am thinking that instead of showing the full generated program, I can show just how each function was translated which would help with debugging.

For an example of the kind of transformation that happens, say you have a node with an Every Update code implementation that accesses an internal variable that you defined in the declarations section, as well as an input and output on the node. If you have multiple copies of that node in a project, we don't want to copy the entire code implementation, so Embrio creates a function called something like YourNode_EveryUpdate. It takes as parameters a reference to the internal variable and the input and output variables. Each instance of the node has a global variable for the internal variable, and global variables for the inputs and outputs. When the node is processed, it calls the global YourNode_EveryUdpate function and passes its copies of the global variables.

Ideally that would all work well all the time and you wouldn't have any need to see the generated code, but sometimes it is still useful. Especially when the generated code distorts your code enough that the captured compile error doesn't make sense any more. I think a "view generated code for node" view would be helpful here, one that shows a very stripped down generated Arduino program with just the functions and global variables used for one node. I'll put that on my list.

In the mean time I will do more on the documentation, I always lag a bit behind on that.
#3 Posted : Friday, April 01, 2022 2:09:49 AM(UTC)

Rank: Member

Groups: Registered
Joined: 5/5/2021(UTC)
Posts: 11

Hi, what a great sharing!
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.