Marlin 2.0 (compatible with both 8-bits and 32-bits control boards) has this feature in already Quotemarlin #define EVENT_GCODE_SD_STOP "G28XY"