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

feat: add macro prompt dialog #1630

Merged
merged 19 commits into from
Dec 3, 2023

Conversation

meteyou
Copy link
Member

@meteyou meteyou commented Oct 28, 2023

Signed-off-by: Stefan Dej meteyou@gmail.com

Description

This PR will add a function to Mainsail, to generate prompts via gcode/macros.

Related Tickets & Documents

fixes #1625

Mobile & Desktop Screenshots/Recordings

image

image

[optional] Are there any post-deployment tasks we need to perform?

  • Merge the docs PR for this feature

Signed-off-by: Stefan Dej <meteyou@gmail.com>
Signed-off-by: Stefan Dej <meteyou@gmail.com>
Signed-off-by: Stefan Dej <meteyou@gmail.com>
Signed-off-by: Stefan Dej <meteyou@gmail.com>
…romptActionButton

Signed-off-by: Stefan Dej <meteyou@gmail.com>
Signed-off-by: Stefan Dej <meteyou@gmail.com>
Signed-off-by: Stefan Dej <meteyou@gmail.com>
Signed-off-by: Stefan Dej <meteyou@gmail.com>
Signed-off-by: Stefan Dej <meteyou@gmail.com>
Signed-off-by: Stefan Dej <meteyou@gmail.com>
Signed-off-by: Stefan Dej <meteyou@gmail.com>
Signed-off-by: Stefan Dej <meteyou@gmail.com>
Signed-off-by: Stefan Dej <meteyou@gmail.com>
Signed-off-by: Stefan Dej <meteyou@gmail.com>
Signed-off-by: Stefan Dej <meteyou@gmail.com>
@meteyou meteyou marked this pull request as ready for review October 29, 2023 14:16
@meteyou meteyou requested review from dw-0 and rackrick October 29, 2023 14:17
@meteyou meteyou changed the title feat: add action command prompt dialog feat: add macro prompt dialog Oct 29, 2023
@ulope
Copy link

ulope commented Oct 30, 2023

Awesome!
That was really quick!

The implementation does seem to deviate a bit from the octoprint "spec" though.

Octoprint "protocol":

  • Commands:
    • begin <title>
    • (choice|button) <text> - those are just aliases of each other
    • show
    • end
  • Response: M876 S<index-of-choice> (the G-code used is configurable).

While in this PR it looks like (as far as I could infer from the code):

  • Commands:
    • begin <title>
    • button <text>[[|<command>]|<color>] - no choice here
    • button_group_start
    • button_group_end
    • text
    • show
    • close - vs. end above
  • Response: <command> (or the text??, not sure about the code here)

I like the extensions since they allow richer interactions, but I think the basic protocol should remain compatible with the one from octoprint.

@Phil1988
Copy link

Very nice!
This will level up the user experience and make the interface even more usable.
Cant wait to have this integrated 👍

@meteyou
Copy link
Member Author

meteyou commented Oct 30, 2023

@ulope both are not compatible. so you have to write your macros complete different, that you can use this in klipper, because klipper has no "wait for an user input" function and the prompt_end command don't definite the "end" of the declaration. so the "close" command is really a "close" of the prompt.

I already wrote the docs for this feature. maybe it will be clearer with that:
screencapture-docs-mainsail-xyz-changes-WqGAJH0GaI5torSkb3GO-overview-features-macro-prompts-2023-10-30-21_38_46

@ulope
Copy link

ulope commented Oct 31, 2023

@ulope both are not compatible. so you have to write your macros complete different, that you can use this in klipper, because klipper has no "wait for an user input" function and

Well you don't have to.
Take a look at the M600 macro I linked in the original issue. Even on klipper it's possible to write macros that use the a singe response dispatch gcode.

But it's probably right that the way you implemented it is much easier to use for Klipper users...

the prompt_end command don't definite the "end" of the declaration. so the "close" command is really a "close" of the prompt.

So is end:

prompt_end
Tells OctoPrint that the dialog should now be closed (e.g. the user made the choice on the printer directly instead of through OctoPrint). Will be ignored if no dialog is defined yet.

Signed-off-by: Stefan Dej <meteyou@gmail.com>
@zellneralex
Copy link
Member

@ulope: I prepared for our testing a flow that contains M600 and filament runout. Doing that gets pretty “ugly” fast.
That was one reason why we deceived to simplify the process for most user flows.

alao the use of Octoprint and moonraker/mainsail is nothing that is done in parallel so that there is in my opinion no need to be 100% compatible to the octoprint version.

@zellneralex
Copy link
Member

choice/button: we believe the word button is the better here and why having 2 cmds that do exactly the same
end/close:
in the octo world end really close the dialog box and ends the waiting (gcode streamer)
in the Moonraker/mainsail world this really only closes the box, if you do net set a PAUSE in the macro calling the box the print would continue.

@ulope
Copy link

ulope commented Nov 2, 2023

@ulope: I prepared for our testing a flow that contains M600 and filament runout. Doing that gets pretty “ugly” fast. That was one reason why we deceived to simplify the process for most user flows.

alao the use of Octoprint and moonraker/mainsail is nothing that is done in parallel so that there is in my opinion no need to be 100% compatible to the octoprint version.

Yeah, I've been working on a PR that adds support for prompts to KlipperScreen and after using it a bit I agree that the model you came up with will lead to much simpler and easier to write macros.

My only concern regarding compatibility is that people may want to switch from / to octoprint and then would have to re-work their macros.
But that may not be as big of a concern in practice...

@zellneralex
Copy link
Member

My only concern regarding compatibility is that people may want to switch from / to octoprint and then would have to re-work their macros. But that may not be as big of a concern in practice...

In my opinion that will not be an issue. They need to rework there Octoprint command flow anyhow. Look at the M600 example
that [gcode_macro M876] must be always added and developed going from Octoprint to moonraker/mainsail

I hope you using the same command we do to give the user a possibility to see and do the same regardless what UI he uses in that moment.

@ulope
Copy link

ulope commented Nov 2, 2023

I hope you using the same command we do to give the user a possibility to see and do the same regardless what UI he uses in that moment.

Yes, that was my initial concern to have alignment across all implementations, but as I said above, I've come around to your point of view in the meantime.

@meteyou
Copy link
Member Author

meteyou commented Nov 3, 2023

@ulope plus post your discord name, or write me a pn. I will add you to a channel.

@ulope
Copy link

ulope commented Nov 4, 2023

@ulope plus post your discord name, or write me a pn. I will add you to a channel.

Cool, my username is @ulope_

@Zeanon
Copy link

Zeanon commented Nov 4, 2023

@ulope both are not compatible. so you have to write your macros complete different, that you can use this in klipper, because klipper has no "wait for an user input" function and the prompt_end command don't definite the "end" of the declaration. so the "close" command is really a "close" of the prompt.

I already wrote the docs for this feature. maybe it will be clearer with that: screencapture-docs-mainsail-xyz-changes-WqGAJH0GaI5torSkb3GO-overview-features-macro-prompts-2023-10-30-21_38_46

You can actually create pseudo asynchronity in klipper by having a starting macro which sets everything up, then activates a delayed gcode that calls itself while checking a variable, then you have a macro which sets that variable and then the delayed gcode reads it and continues.
I know it's convoluted and not the easiest way but it works

@meteyou
Copy link
Member Author

meteyou commented Nov 4, 2023

@ulope plus post your discord name, or write me a pn. I will add you to a channel.

Cool, my username is @ulope_

sry. i cannot find this user on the Mainsail discord....

@ulope
Copy link

ulope commented Nov 6, 2023

sry. i cannot find this user on the Mainsail discord....

I’m definitely there. Sent you a PN on discord.

Signed-off-by: Stefan Dej <meteyou@gmail.com>
is could be possible, that klipper is busy and dont execute the close command fast enough

Signed-off-by: Stefan Dej <meteyou@gmail.com>
@meteyou meteyou merged commit 07d4eb4 into mainsail-crew:develop Dec 3, 2023
9 checks passed
@meteyou meteyou deleted the feat/action-command-prompt branch December 3, 2023 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for action command prompts
6 participants