• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

M291, non-blocking with a timer?

Scheduled Pinned Locked Moved
Gcode meta commands
2
4
240
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    mikeabuilder
    last edited by 15 Mar 2023, 23:19

    I'm trying to write a macro this will execute one code path if a user responds to a message and execute a different code path if the user does not respond. The idea is to have a series of things the printer will do at power-on ( heat bed, home, level bed, create mesh), but that there will be occasions when the user wants to skip one or more of these steps.

    I think it might not be possible at all, but I thought I'd ask here. I've been looking at M291 and I can implement two code paths if I use a blocking mode like S=3 or S=4, but it requires the user to make a choice at each step. I want to give the user an amount of time and if they don;t respond, continue.

    One thought is that I could use a non-blocking message like S=1 if I put it in a delay loop and checked on every iteration whether the user has selected the "Close" button. Is this possible with 3.5?

    undefined 1 Reply Last reply 16 Mar 2023, 12:32 Reply Quote 0
    • undefined
      chrishamm administrators @mikeabuilder
      last edited by 16 Mar 2023, 12:32

      @mikeabuilder Something like this?

      var now = state.time
      M291 S2 T5 P"Confirm or ignore"
      if state.time - var.now >= 5
      echo "Prompt ignored"
      else
      echo "Prompt confirmed"

      Duet software engineer

      1 Reply Last reply Reply Quote 0
      • undefined
        mikeabuilder
        last edited by 16 Mar 2023, 15:57

        @chrishamm - This is precisely what I'm looking for - a solution, and better than the one I was contemplating.

        One question about the solution, though. I noticed a different behavior in RRF3.5 (works) vs RRF3.4 (did not work). In the gcode dictionary, M291 with S=2 is described as blocking, and the T parameter is supposed to be ignored for S=2 or S=3. For the code above to work, I think the T parameter is not being ignored. Is this a change in RRF 3.5?

        undefined 1 Reply Last reply 17 Mar 2023, 09:30 Reply Quote 0
        • undefined
          chrishamm administrators @mikeabuilder
          last edited by 17 Mar 2023, 09:30

          @mikeabuilder Yes, I think it is a change from 3.5. The messagebox implementation is different from 3.4 because of the new types that are now supported but TBH I wasn't aware that T was supposed to be ignored before for S=2 and S=3. I'll check the docs again.

          Duet software engineer

          1 Reply Last reply Reply Quote 0
          • undefined kerfun referenced this topic 23 Mar 2024, 00:34
          4 out of 4
          • First post
            4/4
            Last post
          Unless otherwise noted, all forum content is licensed under CC-BY-SA