<p>Can someone show me how to add Lines to Marlin 1.1.8 ?
I want to change the M400 command.
In a kind like that:</p>
<pre><code>M400 () { move Z + 5 if not Z MAX; Home X; printbed on MAX LENGHT}.
</code></pre>
<p>This coud be ported to pause and abort.</p>

CC BY-SA 4.0
2020-10-30T09:30:35.703Z
That should be doable, but what you want is not possible if the printer hasn't been homed yet. The printer should be homed first, else Z is unknown. Note that it not smart to let known commands do something different than default. I think in version 1.1.8, the printer will not go over the limits, so no need to check for Z max. Programmatically, you need to send (`G28`), `G91`, `G1 Z5 F1000`, `G90`, `G1 X0 Ymax` where Ymax needs to receive the max set in the firmware first.
0scar
CC BY-SA 4.0
2020-10-30T10:54:03.997Z
M400 is the final command print finished so all axes are homed long before.
But i dont know how to add lines of code to this function.
I tried but nothing worked :(
maf
CC BY-SA 4.0
2020-10-30T11:29:52.410Z
Not necessarily, motors can be disabled, there is no guarantee the printer is homed. Maybe in your case yes, but if you override a command, you should make it generic. Maybe you could add to the question why you want to do this, this seems exactly something for an end G-code script?
0scar
CC BY-SA 4.0
2020-10-30T12:06:13.410Z
The End Gcode is befor M400 method of marlin so FW will execude commands after the End Gcode from slicer so i need help to add lines of code to the method of m400 in marlin firmeware
maf
<marlin>
Marlin inline void gcode_M400()
maf
# Marlin inline void gcode_M400()

(Asked by: username_0 on 2020-10-26)

Can someone show me how to add Lines to Marlin 1.1.8 ?
I want to change the M400 command.
In a kind like that:
M400 () { move Z + 5 if not Z MAX; Home X; printbed on MAX LENGHT}.

This coud be ported to pause and abort.

**Tags:** marlin
> **Comments:**
> **username_1**: That should be doable, but what you want is not possible if the printer hasn't been homed yet. The printer should be homed first, else Z is unknown. Note that it not smart to let known commands do something different than default. I think in version 1.1.8, the printer will not go over the limits, so no need to check for Z max. Programmatically, you need to send (`G28`), `G91`, `G1 Z5 F1000`, `G90`, `G1 X0 Ymax` where Ymax needs to receive the max set in the firmware first.  
> **username_0**: M400 is the final command print finished so all axes are homed long before. But i dont know how to add lines of code to this function. I tried but nothing worked :(  
> **username_1**: Not necessarily, motors can be disabled, there is no guarantee the printer is homed. Maybe in your case yes, but if you override a command, you should make it generic. Maybe you could add to the question why you want to do this, this seems exactly something for an end G-code script?  
> **username_0**: The End Gcode is befor M400 method of marlin so FW will execude commands after the End Gcode from slicer so i need help to add lines of code to the method of m400 in marlin firmeware  

---

## 0 answers

