Basic Information:
Printer Model: A8 & Custom Printer
MCU / Printerboard: A8, and Octopus
klippy.log
Fill out above information and in all cases attach your klippy.log
file (use zip to compress it, if too big). Pasting your printer.cfg
is not needed
Be sure to check our “Knowledge Base” Category first. Most relevant items, e.g. error messages, are covered there
Describe your issue:
…
klippy.log (82.4 KB)
I think I am seeing a bug with gcode_buttons. Or, at the very least, unexpected behaviour. (I am using the buttons to fire MQTT messages, and/or via moonraker, but am just using M118 messages in this example for simplicity.
Taking the following simple gcode_button example (pin ommited for brevity)
[gcode_button test_button]
press_gcode: M118 Button Pressed
release_gcode: M118 Button Released
This works as expected when the printer is idle, or moving (e.g G0 X100 F100), i.e I can toggle the pin High and Low, and the appropriate Gcode will be displated with the button is pushed or released.
However: If I run a “G4 P10000” for example, and then push (and release) the button while, while the “Delay” is running, what happens is:
-
Nothing happens while the G4 timer is running - no “Button Pressed” message is displayed.
-
As soon as the timer is finished, we get a “Button Pressed” message, BUT no “Button Released”. This, Klipper is no longer in the correct state - it thinks the button is “pushed down still”, but it is not.
-
If, now that the timer has finished, I now push down (and hold) the button, again nothing happens, the press_gcode is not called. I believe this is because Klipper incorrectly thinks the button is already pushed, as it never registered the earlier “Release…”. Thus, the appropriate “Button Push” actions never occur…
So, there seem to be three problems here:
-
If you push a button while a G4 delay is running, the “Button Pushed” method is not fired until after the G4 actually finishes. (Perhaps this is by design?) If a pin goes high/low during a G4, isn’t it reasonable for those actions to run immediately? For example, lets say the button is an Emergency Stop button…
-
Additionally, Klipper now thinks the button is still in the “Pushed” state, but in reality it has long since been released. But the release_gcode is never actually called at all… so expected functionality never occurs - i.e IF a G4 is running, then Klipper never calls the appropriate commands once the button/pin changes state to “Released”…
-
Additionally, if a person (or electronic sensor) now “pushes this button”, after the G4 has finished, then the press_gcode is never fired, as Klipper thinks the button is already pushed down…
Issue 3 is especially bad - because it means the physical button will not have any action IF it is pushed AFTER it was pushed during a G4 command…
If one pushes a button, and there is no G4 or any other commands running, then one would of course assume the press_gcode actions should occur…
AFAIK this is a bug in klipper, and easily reproducible - simply create a gcode_button linked to a physical button, and push it while running a G4 command.
Can anyone please advise how to proceed from here? Or confirm this is a bug?
Thankyou.