Gcode button, odd behaviour, interaction with macro. Bug?

Basic Information:

Printer Model: Voron 2.4, Pi4a,
MCU / Printerboard: Spider 1.1
klippy.log

klippy.log (1.4 MB)

I’m seeing odd behavior from a G-Code button, that seems to depend on some aspects of the macro, potentially simply the length?

So,

  1. pressing the button will trigger the macro and the macro will complete.
  2. then on pressing the button again nothing will happen, unless there is a release g code specified, in which case the release g code will play when the button is pushed a second time
  3. Then after pushing the button a third time the macro will play through and the cycle will start again.

After debugging it appears that it’s potentially even simply the length of the macro that will produce this odd behavior. I will include two versions of a very similar macro the first does not create the issue the second does.

Pull-up, or inversion don’t appear to have anything to do with the issue. Neither does the board pin, i’ve tried different pins. Also commenting out release_gcode entirely has no effect. It also doesn’t seem to matter if the button is triggering a macro or the code directly.

Is this potentially a bug? None of this occurs triggering the macro from the Mainsail interface.


[gcode_button F_PURGE_BUTTON]
pin:^!PA3
press_gcode:
FIL_PURGE

release_gcode:
M117 Released

[gcode_macro FIL_PURGE]    (Button works as expected)
gcode:

  {% if printer.extruder.temperature > 50.0|int %}     ; Nozzle temp based 
  {% set varix = (range(0, 25) | random) + 35 %}       ; x = to random between 35-55

 STATUS_HEATING
 M204 S7000 
 G91                                   ; relative for lift 
 G1 Z3.00                               ; Raise before move Purge XY
 G90                                         ; Absolute for move 
 G1 F24000  X{varix} Y359.3        ; Move to Purge XY
 G1  Z8					          ; Move to Purge Z
 M117 Filament down

 G1  Z5.75					           ; Move to Purge Z
 G1  F8000 X75 Y359.3			       ; Move to Purge Z	

 G0 X125   F14000                                ; Wipe back
 G0 X75    F14000                                 ; Wipe forth

    {% else %}
 M117 Too Cold! 209C                   
         {% endif %}
[gcode_macro FIL_PURGE]    (Button exhibits behaviour described above)
gcode:

  {% if printer.extruder.temperature > 50.0|int %}     ; Nozzle temp based 
  {% set varix = (range(0, 25) | random) + 35 %}       ; x = to random between 35-55

 STATUS_HEATING
 M204 S7000 
 G91                                   ; relative for lift 
 G1 Z3.00                               ; Raise before move Purge XY
 G90                                         ; Absolute for move 
 G1 F24000  X{varix} Y359.3        ; Move to Purge XY
 G1  Z8					          ; Move to Purge Z
 M117 Filament down

 G1  Z5.75					           ; Move to Purge Z
 G1  F8000 X75 Y359.3			       ; Move to Purge Z	

 G0 X125   F14000                                ; Wipe back
 G0 X75    F14000                                 ; Wipe forth
 G0 X125   F14000                                ; Wipe back
 G0 X75    F14000                                 ; Wipe forth
 G0 X125   F14000                                ; Wipe back
 G0 X75    F14000                                 ; Wipe forth
 G0 X125   F14000                                ; Wipe back
 G0 X75    F14000                                 ; Wipe forth
 G0 X125   F14000                                ; Wipe back
 G0 X75    F14000                                 ; Wipe forth
    
   {% else %}
 M117 Too Cold! 209C                   
         {% endif %}

Over 5000 lines of printer.cfg? All written yourself?
2000 lines of these are just bed meshes :roll_eyes:

Can’t imagine someone will dig through all of this.

Have you tried tossing an ‘M400’ in there after all the ‘G0’ commands?

No I haven’t. It should go after the series of wipe (back and forth) moves?

That’s where I’d try it first. If that doesn’t change anything, try moving it around or even adding additional ones. It may have no effect but it’s an easy thing to try.

If I put an M400 at the end of the wipe series the button stops working completely after the first press. It even stops working when triggered from Mainsail interface rather than the button. Maybe this is indicative of why this odd behaviour is happening?

But other than that it didn’t solve the issue. If i move it around and even try it in a few places I can see the macro pausing before it carries on. But the odd button behaviour described in the first post persists.

Hmmm, that’s interesting. What if you put it in the press_gcode: section instead of the macro itself? Or even the release_gcode: section for that matter?

Ahh, interesting…Ill try it out.

Same behaviour. But good idea for a test, for sure. Not sure what to conclude from this though.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.