Implementing G-code procedures in the firmware
I have a question I couldn't the answer to with the search function. The thing is that the printer I have to control needs some special procedures for homing, changing the toolheads, calibrating extruders, calibrating the HBP and more.
For example the procedure for homing is as follows:
G28 Y ; Home Y BEFORE X, this is very important
G1 Y-3.0 ; This is needed for the X to be homed, because the magnet that is detected by the hall sensor is on the Y gantry
G28 X ; Home X
G28 Z ; Home Z
G1 Y-10.0 F2400 ; Move to the fysical zero position
G92 X0 Y0 Z0 ; Set the zero position of the printer to the current position
Of course, the printer has to execute all of this code when the user presses "Home all" in simplify3D, or any other gcode sender for that matter. This might be possible by editing some of the definitions in configuration.h (although I doubt it) but it would be way easier if I could kind of "hook" this code to the G28 (home all) command. This is because I have to implement more procedures and digging into the firmware to implement all of them would be really cumbersome while I already have the gcodes corresponding to the procedures.
So my real question is:
Can I replace a command the arduino receives by a series of other commands?