I was working on a few G-code mods for my X1C and noticed that this wasn’t documented as far as I can tell. @mowcius - Feel free to add to the OP if you wish.
Referencing the Checkboxes (e.g. Calibrate, Timelapse, Bed Leveling)
This is information from testing, so may not be 100% accurate, but it does seem to work.
You can query the checkbox status at time of print by wrapping your commands in with M622/M623 callouts after an M1002, example:
; Purposes of this is
; Check if Filament Calibration checkbox was set, if true, skip and use the new calibrated values.
M1002 judge_flag extrude_cali_flag
M622 J0 ; Meaning it's false, proceed in this block.
{if enable_pressure_advance[current_extruder]}
; If PA is enabled in the Filament Settings, use that K-Value.
; If not we proceed with whatever the printer has stored.
M400
M900 K{pressure_advance[current_extruder]} L1000 M10
{endif}
M623 ; End of the extrude_cali_flag check.
The above sample code queries the “Run Flow Calibration” checkbox, and if it was FALSE (unchecked) when printing occurred the section of the code will run. If the box was TRUE (checked), the printer will skip over the section between M622 and M623.
Breakdown:
- M1002 judge_flag extrude_cali_flag
- This seems to query the “Run Flow Calibration” checkbox status at time of print.
- M622 J0 ;
- This creates a conditional, with the result needing to be FALSE to run the command.
- M623 ;
- This closes the conditional code block (think of it like an {endif})
If you wanted to run the code-block on a TRUE status, you’d switch M622 J0 to M622 J1.
I haven’t tested for the other queries, but these also exist:
- M1002 judge_flag g29_before_print_flag (likely the bed-leveling checkbox)
- M1002 judge_last_extrude_cali_success (based on the result of the calibration pass)
Other Examples:
This was just a sample script I used for debugging, allowing me to watch the camera. Placed in the Machine G-Code start after the initialization portion before all of the heatbed/heater stuff.
M1002 judge_flag extrude_cali_flag
M622 J0
; judge_flag with J0, false? Then turn the fans to a known value and blink the light.
M960 S5 P0 ; Bambu Lab toolhead logo light off
G4 P5000
M960 S5 P1 ; Bambu Lab toolhead logo light on
G4 P1000
M960 S5 P0 ; Bambu Lab toolhead logo light off
G4 P1000
M960 S5 P1 ; Bambu Lab toolhead logo light on
G4 P1000
M960 S5 P0 ; Bambu Lab toolhead logo light off
G4 P1000
M960 S5 P1 ; Bambu Lab toolhead logo light on
M623
G4 P6000
M1002 judge_flag extrude_cali_flag
M622 J1
; judge_flag with J1, true? Then turn the fans to known values and turn the laser on.
M106 S15 ; turn part-cooling fan to 15% for verification
M106 P2 S44 ; turn aux fan to 44% for verification
M106 P3 S67 ; turn chamber fan to 67% for verification
M960 S1 P1 ; turn on laser
M960 S2 P1 ; turn on laser
M623
If the Flow Calibration was checked, it does the latter part (with the laser), otherwise it does the first part (with the toolhead light).