Skip to content
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

[FR]: Add scripting support to commands #610

Open
git-rz opened this issue Apr 25, 2023 · 1 comment
Open

[FR]: Add scripting support to commands #610

git-rz opened this issue Apr 25, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@git-rz
Copy link

git-rz commented Apr 25, 2023

While using the bed visualizer commands / macros, I wish to press a button and see terminal output in a popup. (M92, M420, many more..)

I should be able to extract info from the output, either for display, or for reuse in subsequent commands.

Command syntax should allow for calculations.

Estep calibration, for instance, would be one use case that combines these ideas:

M92 T%(tool_param)s E{{ multiplier_param * ( $( M92 ).split(/ E[0-9.]+/)[ tool_param +1]) }}
{{ popup("Set new esteps for T$tool _param: $( M92 ).split(/ E[0-9.]+/)[ tool_param +1]) ") }}

Apologies for the syntax of the example above. I've mashed together the %.(...)s from this plugin, {{ from mustache, $() from shell, .split() from any number of modern languages.. I'm not asking for this exact syntax.

If there were an API to create a new button, then we can have buttons to add buttons. Use cases include:

  • Create a new button to restore a mesh (already logged as another issue here)
  • Create a button to restore nozzle offsets for dual extruders.
  • probably more

This is at least five feature requests in one, so I can split this out if there is interest.

  • simple calculations using params as inputs (probably super simple) (I'd be happy just to have this)
  • display outputs
  • parse outputs
  • generalized scripting
  • api (within the generalized scripting system) for adding more command buttons
@jneilliii jneilliii added the enhancement New feature or request label Apr 25, 2023
@git-rz
Copy link
Author

git-rz commented Apr 25, 2023

A revised example, where the entire command is in the script block, and where the $() is removed..

{{
  const initialEsteps = terminalSend("M92").split(/ E[0-9.]+/)[TOOL_PARAM +1]
  const newEsteps = initialEsteps * MULTIPLIER_PARAM
  terminalSend("M92 T${TOOL_PARAM} E${newEsteps}")
  if (yesNoPopup("Tool ${TOOL_PARAM} esteps set to ${newEsteps}. M500?")) {
    terminalSend("M500")
  }
}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants