Advanced Functionality Questions
-
Hi folks,
I'm exploring some ideas for an advanced 3D Printer project, am very excited for the new variables and conditional logic functionality which should make things a lot easier, and would appreciate some feedback on these things:
Adding controls to DWC:
If we wanted to have a new button, we could make it in HTML, bind it to JS function, and have that use sendGCode to trigger a respective Macro for that button.As an example:
Button1
could triggersendGCode("M98 P"button1script.g"");
I'm sure there is some specific syntax needed to deal with the quotes inside quotes, but does this make sense?Getting data back from the Duet board to DWC to update elements with info. This is where it gets more interesting...
As best as I can tell, things like temperatures, tools, etc... are in DWC aslastStatusResponse
, and the UI elements are updated using that. I haven't looked at how this is done on the firmware side yet, so please forgive any oversights and point me to any relevant code that would put me on the right track.I would prefer not to have to modify the RRF firmware in order to add functionality that sends data back to DWC. It would be much more preferable if Macros could have the ability to send data back, either directly, or through the model behind lastStatusResponse.
The way I could see this happening:
-
Execute a command in config.g for "add this new field to the board's status object".
-
In a Macro, a command can be used to update the value of that field with new data.
EDIT: Does what I am describing here relate to the new RRF3.1 Object Model? Is that what will be getting sent back to DWC for the status of heater/ selected tool/ etc? If so, would you allow for custom keys to be added to the object, whose values can be updated via gCode, as described above?
Would love to hear your thoughts on this.
Thanks,
Ray -
-
@raykholo said in Advanced Functionality Questions:
If we wanted to have a new button, we could make it in HTML, bind it to JS function, and have that use sendGCode to trigger a respective Macro for that button.
are you aware that if you create a macro it becomes a button in the ui?
-
@raykholo said in Advanced Functionality Questions:
If we wanted to have a new button, we could make it in HTML, bind it to JS function, and have that use sendGCode to trigger a respective Macro [or G or M code] for that button.
With the addition above, this is fundamentally how DWC works internally. So I'm not sure what you are saying/asking.
Getting data back from the Duet board to DWC to update elements with info.
Old HTTPS or new Websocket, the actual communication is one of two things: DWC sends a "command" and a callback is triggered when that "responds", the callback parsing a JSON object and updating the GUI... or DWC periodically 'polls' a query that results in a JSON object (again, via callback) and the GUI is updated from fields in that object.
So, again, not sure what you are asking.
Perhaps... you are asking "Does the new conditional/variables stuff include having macros take arguments and return results?" I'm investigating that same question myself.
-
Yes, I was using the button send as the simple example of "yes, this should be straightforward to replicate". I just checked how a defined macro button works, and it does indeed send an M98 command with its name "Test1" so that's fine.
rr_gcode?gcode=M98%20P%220%3A%2Fmacros%2FTest%201%22
I was thinking about making other UI elements (dropdowns, sliders, etc...), where it would have to be written into HTML. So yeah, M98 seems to be the proper way to do this.
Perhaps... you are asking "Does the new conditional/variables stuff include having macros take arguments and return results?" I'm investigating that same question myself.
For getting data back, yes, I would like Macros to be able to return data that the DWC can use to update custom UI elements (show values in text field, change a slider position, all the things that already happen with temps and so on).
Right now, I only see an
echo
command that writes a message to console: https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands#Section_Echo_commandI do not know that the webpage would be able to parse console messages to see if it finds data to update the UI. A real way to return data would be preferable.
I'm not sure if the data might need to persist somewhere for things to work well, which is why I brought up sticking it in the object model/ lastStatusResponse JSON object.
-
@raykholo said in Advanced Functionality Questions:
I would prefer not to have to modify the RRF firmware in order to add functionality that sends data back to DWC
With the Duet3 you can have programable functionality on the Raspberry PI, without having to modify the RRF firmware. My guess that this is one of the reasons it was done this way, to enable OEMs to customize their user experience.
BTW, 'RRF firmware' is redundant. Just like 'ATM machine'.
-
@raykholo said in Advanced Functionality Questions:
For getting data back, yes, I would like Macros to be able to return data
I had a separate conversation with Dave in another thread on this forum. Macro arguments and return values are planned.