I’ll preface this saying that this is a very specific use case that applies only to the Sparkmaker LaserPro (that I know of). The LaserPro includes an autofocus sensor that can keep the laser head a constant distance from the material. The autofocus is activated using the following Gcode:
M206 S## ; Single point Autofocus. Moves Z down at the current position until it is the specifide distance (mm) away. For example, M206 S11 sets the focal distance to 11 mm. This only happens 1 time at time/position of code execution.
M207 S## ; this is realtime autofocusing. It constantly moves Z to maintain the set distance from the material. This is the code which pertains to the issue.
S0 disables the auto focusing.
Now the issue at hand is that in the current iteration of Lightburn, custom GCode commands can only be put at the very start or end. This means that if autofocus is enabled, the laser will move Z down at the home position, not over the material. This could cause several issues such as the machine trying to move down past the Z limit if the machine is propped up (which also seams to hang Lightburn) or if the head starts moves down, but is below the height of the material which causes it to run into the edge of the workpiece before it can move up.
The LaserPro software handles this by not issuing the autofocus command until the head is over the first point in the laser cut path. The head lowers, a short pause happens, then it starts lasering. This guarantees that the head is directly above the workpiece (assuming the user positioned/framed it correctly).
Is there a way to somehow incorporate this behavior into Lightburn? Have Gcode that gets sent right before the first laser fire command?
I know this is a niche case and specifically for this machine, but there may be some other useful cases of being able to execute code right before the laser starts firing (which should be over the material).