Prusa MINI Firmware overview
GcodeSuite Class Reference

#include <gcode.h>

Collaboration diagram for GcodeSuite:

Static Public Member Functions

static bool axis_is_relative (const AxisEnum a)
 
static void set_relative_mode (const bool rel)
 
static void set_e_relative ()
 
static void set_e_absolute ()
 
static FORCE_INLINE void reset_stepper_timeout ()
 
static int8_t get_target_extruder_from_command ()
 
static int8_t get_target_e_stepper_from_command ()
 
static void get_destination_from_command ()
 
static void process_parsed_command (const bool no_ok=false)
 
static void process_next_command ()
 
static void process_subcommands_now_P (PGM_P pgcode)
 
static void process_subcommands_now (char *gcode)
 
static void home_all_axes ()
 
static void dwell (millis_t time)
 

Static Public Attributes

static uint8_t axis_relative
 
static millis_t previous_move_ms
 

Member Function Documentation

◆ axis_is_relative()

static bool GcodeSuite::axis_is_relative ( const AxisEnum  a)
static
294  {
295  if (a == E_AXIS) {
296  if (TEST(axis_relative, E_MODE_REL)) return true;
297  if (TEST(axis_relative, E_MODE_ABS)) return false;
298  }
299  return TEST(axis_relative, a);
300  }
Here is the caller graph for this function:

◆ set_relative_mode()

static void GcodeSuite::set_relative_mode ( const bool  rel)
static
301  {
302  axis_relative = rel ? _BV(REL_X) | _BV(REL_Y) | _BV(REL_Z) | _BV(REL_E) : 0;
303  }
Here is the caller graph for this function:

◆ set_e_relative()

static void GcodeSuite::set_e_relative ( )
static
304  {
307  }

◆ set_e_absolute()

static void GcodeSuite::set_e_absolute ( )
static
308  {
311  }

◆ reset_stepper_timeout()

static FORCE_INLINE void GcodeSuite::reset_stepper_timeout ( )
static
330 { previous_move_ms = millis(); }
Here is the call graph for this function:

◆ get_target_extruder_from_command()

int8_t GcodeSuite::get_target_extruder_from_command ( )
static

Get the target extruder from the T parameter or the active_extruder Return -1 if the T parameter is out of range

79  {
80  if (parser.seenval('T')) {
81  const int8_t e = parser.value_byte();
82  if (e < EXTRUDERS) return e;
84  SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum);
85  SERIAL_ECHOLNPAIR(" " MSG_INVALID_EXTRUDER " ", int(e));
86  return -1;
87  }
88  return active_extruder;
89 }

◆ get_target_e_stepper_from_command()

int8_t GcodeSuite::get_target_e_stepper_from_command ( )
static

Get the target e stepper from the T parameter Return -1 if the T parameter is out of range or unspecified

95  {
96  const int8_t e = parser.intval('T', -1);
97  if (WITHIN(e, 0, E_STEPPERS - 1)) return e;
98 
100  SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum);
101  if (e == -1)
103  else
104  SERIAL_ECHOLNPAIR(" " MSG_INVALID_E_STEPPER " ", int(e));
105  return -1;
106 }

◆ get_destination_from_command()

void GcodeSuite::get_destination_from_command ( )
static

Set XYZE destination and feedrate from the current GCode command

  • Set destination from included axis codes
  • Set to current for missing axis codes
  • Set the feedrate, if included
115  {
116  xyze_bool_t seen = { false, false, false, false };
117  LOOP_XYZE(i) {
118  if ( (seen[i] = parser.seenval(axis_codes[i])) ) {
119  const float v = parser.value_axis_units((AxisEnum)i);
121  }
122  else
124  }
125 
126  #if ENABLED(POWER_LOSS_RECOVERY) && !PIN_EXISTS(POWER_LOSS)
127  // Only update power loss recovery on moves with E
128  if (recovery.enabled && IS_SD_PRINTING() && seen.e && (seen.x || seen.y))
129  recovery.save();
130  #endif
131 
132  if (parser.linearval('F') > 0)
133  feedrate_mm_s = parser.value_feedrate();
134 
135  #if ENABLED(PRINTCOUNTER)
136  if (!DEBUGGING(DRYRUN))
137  print_job_timer.incFilamentUsed(destination.e - current_position.e);
138  #endif
139 
140  // Get ABCDHI mixing factors
141  #if BOTH(MIXING_EXTRUDER, DIRECT_MIXING_IN_G1)
142  M165();
143  #endif
144 }
Here is the call graph for this function:

◆ process_parsed_command()

void GcodeSuite::process_parsed_command ( const bool  no_ok = false)
static

When G29_RETRY_AND_RECOVER is enabled, call G29() in a loop with recovery and retry handling. Process the parsed command and dispatch it to its handler

195  {
196  KEEPALIVE_STATE(IN_HANDLER);
197 
198  // Handle a known G, M, or T
199  switch (parser.command_letter) {
200  case 'G': switch (parser.codenum) {
201 
202  case 0: case 1: G0_G1( // G0: Fast Move, G1: Linear Move
203  #if IS_SCARA || defined(G0_FEEDRATE)
204  parser.codenum == 0
205  #endif
206  );
207  break;
208 
209  #if ENABLED(ARC_SUPPORT) && DISABLED(SCARA)
210  case 2: case 3: G2_G3(parser.codenum == 2); break; // G2: CW ARC, G3: CCW ARC
211  #endif
212 
213  case 4: G4(); break; // G4: Dwell
214 
215  #if ENABLED(BEZIER_CURVE_SUPPORT)
216  case 5: G5(); break; // G5: Cubic B_spline
217  #endif
218 
219  #if ENABLED(FWRETRACT)
220  case 10: G10(); break; // G10: Retract / Swap Retract
221  case 11: G11(); break; // G11: Recover / Swap Recover
222  #endif
223 
224  #if ENABLED(NOZZLE_CLEAN_FEATURE)
225  case 12: G12(); break; // G12: Nozzle Clean
226  #endif
227 
228  #if ENABLED(CNC_WORKSPACE_PLANES)
229  case 17: G17(); break; // G17: Select Plane XY
230  case 18: G18(); break; // G18: Select Plane ZX
231  case 19: G19(); break; // G19: Select Plane YZ
232  #endif
233 
234  #if ENABLED(INCH_MODE_SUPPORT)
235  case 20: G20(); break; // G20: Inch Mode
236  case 21: G21(); break; // G21: MM Mode
237  #else
238  case 21: NOOP; break; // No error on unknown G21
239  #endif
240 
241  #if ENABLED(G26_MESH_VALIDATION)
242  case 26: G26(); break; // G26: Mesh Validation Pattern generation
243  #endif
244 
245  #if ENABLED(NOZZLE_PARK_FEATURE)
246  case 27: G27(); break; // G27: Nozzle Park
247  #endif
248 
249  case 28: G28(false); break; // G28: Home all axes, one at a time
250 
251  #if HAS_LEVELING
252  case 29: // G29: Bed leveling calibration
253  #if ENABLED(G29_RETRY_AND_RECOVER)
254  G29_with_retry();
255  #else
256  G29();
257  #endif
258  break;
259  #endif // HAS_LEVELING
260 
261  #if HAS_BED_PROBE
262  case 30: G30(); break; // G30: Single Z probe
263  #if ENABLED(Z_PROBE_SLED)
264  case 31: G31(); break; // G31: dock the sled
265  case 32: G32(); break; // G32: undock the sled
266  #endif
267  #endif
268 
269  #if ENABLED(DELTA_AUTO_CALIBRATION)
270  case 33: G33(); break; // G33: Delta Auto-Calibration
271  #endif
272 
273  #if ENABLED(Z_STEPPER_AUTO_ALIGN)
274  case 34: G34(); break; // G34: Z Stepper automatic alignment using probe
275  #endif
276 
277  #if ENABLED(G38_PROBE_TARGET)
278  case 38: // G38.2, G38.3: Probe towards target
279  if (WITHIN(parser.subcode, 2,
280  #if ENABLED(G38_PROBE_AWAY)
281  5
282  #else
283  3
284  #endif
285  )) G38(parser.subcode); // G38.4, G38.5: Probe away from target
286  break;
287  #endif
288 
289  #if ENABLED(CNC_COORDINATE_SYSTEMS)
290  case 53: G53(); break;
291  case 54: G54(); break;
292  case 55: G55(); break;
293  case 56: G56(); break;
294  case 57: G57(); break;
295  case 58: G58(); break;
296  case 59: G59(); break;
297  #endif
298 
299  #if ENABLED(GCODE_MOTION_MODES)
300  case 80: G80(); break; // G80: Reset the current motion mode
301  #endif
302 
303  case 90: set_relative_mode(false); break; // G90: Absolute Mode
304  case 91: set_relative_mode(true); break; // G91: Relative Mode
305 
306  case 92: G92(); break; // G92: Set current axis position(s)
307 
308  #if HAS_MESH
309  case 42: G42(); break; // G42: Coordinated move to a mesh point
310  #endif
311 
312  #if ENABLED(CALIBRATION_GCODE)
313  case 425: G425(); break; // G425: Perform calibration with calibration cube
314  #endif
315 
316  #if ENABLED(DEBUG_GCODE_PARSER)
317  case 800: parser.debug(); break; // G800: GCode Parser Test for G
318  #endif
319 
320  default: parser.unknown_command_error(); break;
321  }
322  break;
323 
324  case 'M': switch (parser.codenum) {
325  #if HAS_RESUME_CONTINUE
326  case 0: // M0: Unconditional stop - Wait for user button press on LCD
327  case 1: M0_M1(); break; // M1: Conditional stop - Wait for user button press on LCD
328  #endif
329 
330  #if HAS_CUTTER
331  case 3: M3_M4(false); break; // M3: Turn ON Laser | Spindle (clockwise), set Power | Speed
332  case 4: M3_M4(true ); break; // M4: Turn ON Laser | Spindle (counter-clockwise), set Power | Speed
333  case 5: M5(); break; // M5: Turn OFF Laser | Spindle
334  #endif
335 
336  #if ENABLED(COOLANT_CONTROL)
337  #if ENABLED(COOLANT_MIST)
338  case 7: M7(); break; // M7: Mist coolant ON
339  #endif
340  #if ENABLED(COOLANT_FLOOD)
341  case 8: M8(); break; // M8: Flood coolant ON
342  #endif
343  case 9: M9(); break; // M9: Coolant OFF
344  #endif
345 
346  #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
347  case 12: M12(); break; // M12: Synchronize and optionally force a CLC set
348  #endif
349 
350  #if ENABLED(EXPECTED_PRINTER_CHECK)
351  case 16: M16(); break; // M16: Expected printer check
352  #endif
353 
354  case 17: M17(); break; // M17: Enable all stepper motors
355 
356  #if ENABLED(SDSUPPORT)
357  case 20: M20(); break; // M20: List SD card
358  case 21: M21(); break; // M21: Init SD card
359  case 22: M22(); break; // M22: Release SD card
360  case 23: M23(); break; // M23: Select file
361  case 24: M24(); break; // M24: Start SD print
362  case 25: M25(); break; // M25: Pause SD print
363  case 26: M26(); break; // M26: Set SD index
364  case 27: M27(); break; // M27: Get SD status
365  case 28: M28(); break; // M28: Start SD write
366  case 29: M29(); break; // M29: Stop SD write
367  case 30: M30(); break; // M30 <filename> Delete File
368  case 32: M32(); break; // M32: Select file and start SD print
369 
370  #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
371  case 33: M33(); break; // M33: Get the long full path to a file or folder
372  #endif
373 
374  #if BOTH(SDCARD_SORT_ALPHA, SDSORT_GCODE)
375  case 34: M34(); break; // M34: Set SD card sorting options
376  #endif
377 
378  case 928: M928(); break; // M928: Start SD write
379  #endif // SDSUPPORT
380 
381  case 31: M31(); break; // M31: Report time since the start of SD print or last M109
382  case 42: M42(); break; // M42: Change pin state
383 
384  #if ENABLED(PINS_DEBUGGING)
385  case 43: M43(); break; // M43: Read pin state
386  #endif
387 
388  #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
389  case 48: M48(); break; // M48: Z probe repeatability test
390  #endif
391 
392  #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
393  case 73: M73(); break; // M73: Set progress percentage (for display on LCD)
394  #endif
395 
396  #if ENABLED(M73_PRUSA)
397  case 73: M73_PE(); break; // M73 PrusaEdition
398  #endif
399 
400  case 75: M75(); break; // M75: Start print timer
401  case 76: M76(); break; // M76: Pause print timer
402  case 77: M77(); break; // M77: Stop print timer
403 
404  #if ENABLED(PRINTCOUNTER)
405  case 78: M78(); break; // M78: Show print statistics
406  #endif
407 
408  #if ENABLED(M100_FREE_MEMORY_WATCHER)
409  case 100: M100(); break; // M100: Free Memory Report
410  #endif
411 
412  #if EXTRUDERS
413  case 104: M104(); break; // M104: Set hot end temperature
414  case 109: M109(); break; // M109: Wait for hotend temperature to reach target
415  #endif
416 
417  case 105: M105(); return; // M105: Report Temperatures (and say "ok")
418 
419  #if FAN_COUNT > 0
420  case 106: M106(); break; // M106: Fan On
421  case 107: M107(); break; // M107: Fan Off
422  #endif
423 
424  case 110: M110(); break; // M110: Set Current Line Number
425  case 111: M111(); break; // M111: Set debug level
426 
427  #if DISABLED(EMERGENCY_PARSER)
428  case 108: M108(); break; // M108: Cancel Waiting
429  case 112: M112(); break; // M112: Full Shutdown
430  case 410: M410(); break; // M410: Quickstop - Abort all the planned moves.
431  #if ENABLED(HOST_PROMPT_SUPPORT)
432  case 876: M876(); break; // M876: Handle Host prompt responses
433  #endif
434  #else
435  case 108: case 112: case 410:
436  #if ENABLED(HOST_PROMPT_SUPPORT)
437  case 876:
438  #endif
439  break;
440  #endif
441 
442  #if ENABLED(HOST_KEEPALIVE_FEATURE)
443  case 113: M113(); break; // M113: Set Host Keepalive interval
444  #endif
445 
446  #if HAS_HEATED_BED
447  case 140: M140(); break; // M140: Set bed temperature
448  case 190: M190(); break; // M190: Wait for bed temperature to reach target
449  #endif
450 
451  #if HAS_HEATED_CHAMBER
452  case 141: M141(); break; // M141: Set chamber temperature
453  case 191: M191(); break; // M191: Wait for chamber temperature to reach target
454  #endif
455 
456  #if ENABLED(AUTO_REPORT_TEMPERATURES) && HAS_TEMP_SENSOR
457  case 155: M155(); break; // M155: Set temperature auto-report interval
458  #endif
459 
460  #if ENABLED(PARK_HEAD_ON_PAUSE)
461  case 125: M125(); break; // M125: Store current position and move to filament change position
462  #endif
463 
464  #if ENABLED(BARICUDA)
465  // PWM for HEATER_1_PIN
466  #if HAS_HEATER_1
467  case 126: M126(); break; // M126: valve open
468  case 127: M127(); break; // M127: valve closed
469  #endif
470 
471  // PWM for HEATER_2_PIN
472  #if HAS_HEATER_2
473  case 128: M128(); break; // M128: valve open
474  case 129: M129(); break; // M129: valve closed
475  #endif
476  #endif // BARICUDA
477 
478  #if HAS_POWER_SWITCH
479  case 80: M80(); break; // M80: Turn on Power Supply
480  #endif
481  case 81: M81(); break; // M81: Turn off Power, including Power Supply, if possible
482 
483  case 82: M82(); break; // M82: Set E axis normal mode (same as other axes)
484  case 83: M83(); break; // M83: Set E axis relative mode
485  case 18: case 84: M18_M84(); break; // M18/M84: Disable Steppers / Set Timeout
486  case 85: M85(); break; // M85: Set inactivity stepper shutdown timeout
487  case 86: M86(); break; // M86: Set Safety Timer expiration time
488  case 92: M92(); break; // M92: Set the steps-per-unit for one or more axes
489  case 114: M114(); break; // M114: Report current position
490  case 115: M115(); break; // M115: Report capabilities
491  case 117: M117(); break; // M117: Set LCD message text, if possible
492  case 118: M118(); break; // M118: Display a message in the host console
493  case 119: M119(); break; // M119: Report endstop states
494  case 120: M120(); break; // M120: Enable endstops
495  case 121: M121(); break; // M121: Disable endstops
496 
497  #if HOTENDS && HAS_LCD_MENU
498  case 145: M145(); break; // M145: Set material heatup parameters
499  #endif
500 
501  #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
502  case 149: M149(); break; // M149: Set temperature units
503  #endif
504 
505  #if HAS_COLOR_LEDS
506  case 150: M150(); break; // M150: Set Status LED Color
507  #endif
508 
509  #if ENABLED(MIXING_EXTRUDER)
510  case 163: M163(); break; // M163: Set a component weight for mixing extruder
511  case 164: M164(); break; // M164: Save current mix as a virtual extruder
512  #if ENABLED(DIRECT_MIXING_IN_G1)
513  case 165: M165(); break; // M165: Set multiple mix weights
514  #endif
515  #if ENABLED(GRADIENT_MIX)
516  case 166: M166(); break; // M166: Set Gradient Mix
517  #endif
518  #endif
519 
520  #if DISABLED(NO_VOLUMETRICS)
521  case 200: M200(); break; // M200: Set filament diameter, E to cubic units
522  #endif
523 
524  case 201: M201(); break; // M201: Set max acceleration for print moves (units/s^2)
525 
526  #if 0
527  case 202: M202(); break; // M202: Not used for Sprinter/grbl gen6
528  #endif
529 
530  case 203: M203(); break; // M203: Set max feedrate (units/sec)
531  case 204: M204(); break; // M204: Set acceleration
532  case 205: M205(); break; // M205: Set advanced settings
533 
534  #if HAS_M206_COMMAND
535  case 206: M206(); break; // M206: Set home offsets
536  #endif
537 
538  #if ENABLED(DELTA)
539  case 665: M665(); break; // M665: Set delta configurations
540  #endif
541 
542  #if ANY(DELTA, X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS, Z_DUAL_ENDSTOPS)
543  case 666: M666(); break; // M666: Set delta or dual endstop adjustment
544  #endif
545 
546  #if ENABLED(FWRETRACT)
547  case 207: M207(); break; // M207: Set Retract Length, Feedrate, and Z lift
548  case 208: M208(); break; // M208: Set Recover (unretract) Additional Length and Feedrate
549  #if ENABLED(FWRETRACT_AUTORETRACT)
550  case 209:
551  if (MIN_AUTORETRACT <= MAX_AUTORETRACT) M209(); // M209: Turn Automatic Retract Detection on/off
552  break;
553  #endif
554  #endif
555 
556  #if HAS_SOFTWARE_ENDSTOPS
557  case 211: M211(); break; // M211: Enable, Disable, and/or Report software endstops
558  #endif
559 
560  #if EXTRUDERS > 1
561  case 217: M217(); break; // M217: Set filament swap parameters
562  #endif
563 
564  #if HAS_HOTEND_OFFSET
565  case 218: M218(); break; // M218: Set a tool offset
566  #endif
567 
568  case 220: M220(); break; // M220: Set Feedrate Percentage: S<percent> ("FR" on your LCD)
569 
570  #if EXTRUDERS
571  case 221: M221(); break; // M221: Set Flow Percentage
572  #endif
573 
574  case 226: M226(); break; // M226: Wait until a pin reaches a state
575 
576  #if HAS_SERVOS
577  case 280: M280(); break; // M280: Set servo position absolute
578  #if ENABLED(EDITABLE_SERVO_ANGLES)
579  case 281: M281(); break; // M281: Set servo angles
580  #endif
581  #endif
582 
583  #if ENABLED(BABYSTEPPING)
584  case 290: M290(); break; // M290: Babystepping
585  #endif
586 
587  #if HAS_BUZZER
588  case 300: M300(); break; // M300: Play beep tone
589  #endif
590 
591  #if ENABLED(PIDTEMP)
592  case 301: M301(); break; // M301: Set hotend PID parameters
593  #endif
594 
595  #if ENABLED(PIDTEMPBED)
596  case 304: M304(); break; // M304: Set bed PID parameters
597  #endif
598 
599  #if ENABLED(PHOTO_GCODE)
600  case 240: M240(); break; // M240: Trigger a camera
601  #endif
602 
603  #if HAS_LCD_CONTRAST
604  case 250: M250(); break; // M250: Set LCD contrast
605  #endif
606 
607  #if ENABLED(EXPERIMENTAL_I2CBUS)
608  case 260: M260(); break; // M260: Send data to an i2c slave
609  case 261: M261(); break; // M261: Request data from an i2c slave
610  #endif
611 
612  #if ENABLED(PREVENT_COLD_EXTRUSION)
613  case 302: M302(); break; // M302: Allow cold extrudes (set the minimum extrude temperature)
614  #endif
615 
616  #if HAS_PID_HEATING
617  case 303: M303(); break; // M303: PID autotune
618  #endif
619 
620  #if HAS_USER_THERMISTORS
621  case 305: M305(); break; // M305: Set user thermistor parameters
622  #endif
623 
624  #if ENABLED(MORGAN_SCARA)
625  case 360: if (M360()) return; break; // M360: SCARA Theta pos1
626  case 361: if (M361()) return; break; // M361: SCARA Theta pos2
627  case 362: if (M362()) return; break; // M362: SCARA Psi pos1
628  case 363: if (M363()) return; break; // M363: SCARA Psi pos2
629  case 364: if (M364()) return; break; // M364: SCARA Psi pos3 (90 deg to Theta)
630  #endif
631 
632  #if EITHER(EXT_SOLENOID, MANUAL_SOLENOID_CONTROL)
633  case 380: M380(); break; // M380: Activate solenoid on active (or specified) extruder
634  case 381: M381(); break; // M381: Disable all solenoids or, if MANUAL_SOLENOID_CONTROL, active (or specified) solenoid
635  #endif
636 
637  case 400: M400(); break; // M400: Finish all moves
638 
639  #if HAS_BED_PROBE
640  case 401: M401(); break; // M401: Deploy probe
641  case 402: M402(); break; // M402: Stow probe
642  #endif
643 
644  #if ENABLED(PRUSA_MMU2)
645  case 403: M403(); break;
646  #endif
647 
648  #if ENABLED(FILAMENT_WIDTH_SENSOR)
649  case 404: M404(); break; // M404: Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width
650  case 405: M405(); break; // M405: Turn on filament sensor for control
651  case 406: M406(); break; // M406: Turn off filament sensor for control
652  case 407: M407(); break; // M407: Display measured filament diameter
653  #endif
654 
655  #if HAS_FILAMENT_SENSOR
656  case 412: M412(); break; // M412: Enable/Disable filament runout detection
657  #endif
658 
659  #if HAS_LEVELING
660  case 420: M420(); break; // M420: Enable/Disable Bed Leveling
661  #endif
662 
663  #if HAS_MESH
664  case 421: M421(); break; // M421: Set a Mesh Bed Leveling Z coordinate
665  #endif
666 
667  #if ENABLED(BACKLASH_GCODE)
668  case 425: M425(); break; // M425: Tune backlash compensation
669  #endif
670 
671  #if HAS_M206_COMMAND
672  case 428: M428(); break; // M428: Apply current_position to home_offset
673  #endif
674 
675  case 500: M500(); break; // M500: Store settings in EEPROM
676  case 501: M501(); break; // M501: Read settings from EEPROM
677  case 502: M502(); break; // M502: Revert to default settings
678  #if DISABLED(DISABLE_M503)
679  case 503: M503(); break; // M503: print settings currently in memory
680  #endif
681  #if ENABLED(EEPROM_SETTINGS)
682  case 504: M504(); break; // M504: Validate EEPROM contents
683  #endif
684 
685  #if ENABLED(SDSUPPORT)
686  case 524: M524(); break; // M524: Abort the current SD print job
687  #endif
688 
689  #if ENABLED(SD_ABORT_ON_ENDSTOP_HIT)
690  case 540: M540(); break; // M540: Set abort on endstop hit for SD printing
691  #endif
692 
693  #if ENABLED(BAUD_RATE_GCODE)
694  case 575: M575(); break; // M575: Set serial baudrate
695  #endif
696 
697  #if HAS_BED_PROBE
698  case 851: M851(); break; // M851: Set Z Probe Z Offset
699  #endif
700 
701  #if ENABLED(SKEW_CORRECTION_GCODE)
702  case 852: M852(); break; // M852: Set Skew factors
703  #endif
704 
705  #if ENABLED(ADVANCED_PAUSE_FEATURE)
706  case 600: M600(); break; // M600: Pause for Filament Change
707  case 603: M603(); break; // M603: Configure Filament Change
708  #endif
709 
710  #if HAS_DUPLICATION_MODE
711  case 605: M605(); break; // M605: Set Dual X Carriage movement mode
712  #endif
713 
714  #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
715  case 701: M701(); break; // M701: Load Filament
716  case 702: M702(); break; // M702: Unload Filament
717  #endif
718 
719  #if ENABLED(MAX7219_GCODE)
720  case 7219: M7219(); break; // M7219: Set LEDs, columns, and rows
721  #endif
722 
723  #if ENABLED(GCODE_MACROS)
724  case 810: case 811: case 812: case 813: case 814:
725  case 815: case 816: case 817: case 818: case 819:
726  M810_819(); break; // M810-M819: Define/execute G-code macro
727  #endif
728 
729  #if ENABLED(LIN_ADVANCE)
730  case 900: M900(); break; // M900: Set advance K factor.
731  #endif
732 
733  #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM || EITHER(DIGIPOT_I2C, DAC_STEPPER_CURRENT)
734  case 907: M907(); break; // M907: Set digital trimpot motor current using axis codes.
735  #if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT)
736  case 908: M908(); break; // M908: Control digital trimpot directly.
737  #if ENABLED(DAC_STEPPER_CURRENT)
738  case 909: M909(); break; // M909: Print digipot/DAC current value
739  case 910: M910(); break; // M910: Commit digipot/DAC value to external EEPROM
740  #endif
741  #endif
742  #endif
743 
744  #if HAS_TRINAMIC
745  case 122: M122(); break; // M122: Report driver configuration and status
746  case 906: M906(); break; // M906: Set motor current in milliamps using axis codes X, Y, Z, E
747  #if HAS_STEALTHCHOP
748  case 569: M569(); break; // M569: Enable stealthChop on an axis.
749  #endif
750  #if ENABLED(MONITOR_DRIVER_STATUS)
751  case 911: M911(); break; // M911: Report TMC2130 prewarn triggered flags
752  case 912: M912(); break; // M912: Clear TMC2130 prewarn triggered flags
753  #endif
754  #if ENABLED(HYBRID_THRESHOLD)
755  case 913: M913(); break; // M913: Set HYBRID_THRESHOLD speed.
756  #endif
757  #if USE_SENSORLESS
758  case 914: M914(); break; // M914: Set StallGuard sensitivity.
759  #endif
760  #endif
761 
762  #if HAS_DRIVER(L6470)
763  case 122: M122(); break; // M122: Report status
764  case 906: M906(); break; // M906: Set or get motor drive level
765  case 916: M916(); break; // M916: L6470 tuning: Increase drive level until thermal warning
766  case 917: M917(); break; // M917: L6470 tuning: Find minimum current thresholds
767  case 918: M918(); break; // M918: L6470 tuning: Increase speed until max or error
768  #endif
769 
770  #if HAS_MICROSTEPS
771  case 350: M350(); break; // M350: Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
772  case 351: M351(); break; // M351: Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low.
773  #endif
774 
775  #if HAS_CASE_LIGHT
776  case 355: M355(); break; // M355: Set case light brightness
777  #endif
778 
779  #if ENABLED(DEBUG_GCODE_PARSER)
780  case 800: parser.debug(); break; // M800: GCode Parser Test for M
781  #endif
782 
783  #if ENABLED(I2C_POSITION_ENCODERS)
784  case 860: M860(); break; // M860: Report encoder module position
785  case 861: M861(); break; // M861: Report encoder module status
786  case 862: M862(); break; // M862: Perform axis test
787  case 863: M863(); break; // M863: Calibrate steps/mm
788  case 864: M864(); break; // M864: Change module address
789  case 865: M865(); break; // M865: Check module firmware version
790  case 866: M866(); break; // M866: Report axis error count
791  case 867: M867(); break; // M867: Toggle error correction
792  case 868: M868(); break; // M868: Set error correction threshold
793  case 869: M869(); break; // M869: Report axis error
794  #endif
795 
796  #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
797  case 951: M951(); break; // M951: Set Magnetic Parking Extruder parameters
798  #endif
799 
800  #if ENABLED(Z_STEPPER_AUTO_ALIGN)
801  case 422: M422(); break; // M422: Set Z Stepper automatic alignment position using probe
802  #endif
803 
804  #if ENABLED(PLATFORM_M997_SUPPORT)
805  case 997: M997(); break; // M997: Perform in-application firmware update
806  #endif
807 
808  case 999: M999(); break; // M999: Restart after being Stopped
809 
810  #if ENABLED(POWER_LOSS_RECOVERY)
811  case 413: M413(); break; // M413: Enable/disable/query Power-Loss Recovery
812  case 1000: M1000(); break; // M1000: Resume from power-loss
813  #endif
814 
815  default: parser.unknown_command_error(); break;
816  }
817  break;
818 
819  case 'T': T(parser.codenum); break; // Tn: Tool Change
820 
821  default: parser.unknown_command_error();
822  }
823 
824  if (!no_ok) queue.ok_to_send();
825 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_next_command()

void GcodeSuite::process_next_command ( )
static

Process a single command and dispatch it to its handler This is called from the main loop()

831  {
832  char * const current_command = queue.command_buffer[queue.index_r];
833 
835 
836  #if ENABLED(POWER_LOSS_RECOVERY)
838  #endif
839 
840  if (DEBUGGING(ECHO)) {
842  SERIAL_ECHOLN(current_command);
843  #if ENABLED(M100_FREE_MEMORY_DUMPER)
844  SERIAL_ECHOPAIR("slot:", queue.index_r);
845  M100_dump_routine(PSTR(" Command Queue:"), queue.command_buffer, queue.command_buffer + sizeof(queue.command_buffer));
846  #endif
847  }
848 
849  // Parse the next command in the queue
850  parser.parse(current_command);
852 }
Here is the call graph for this function:

◆ process_subcommands_now_P()

void GcodeSuite::process_subcommands_now_P ( PGM_P  pgcode)
static

Run a series of commands, bypassing the command queue to allow G-code "macros" to be called from within other G-code handlers.

859  {
860  char * const saved_cmd = parser.command_ptr; // Save the parser state
861  for (;;) {
862  PGM_P const delim = strchr_P(pgcode, '\n'); // Get address of next newline
863  const size_t len = delim ? delim - pgcode : strlen_P(pgcode); // Get the command length
864  char cmd[len + 1]; // Allocate a stack buffer
865  strncpy_P(cmd, pgcode, len); // Copy the command to the stack
866  cmd[len] = '\0'; // End with a nul
867  parser.parse(cmd); // Parse the command
868  process_parsed_command(true); // Process it
869  if (!delim) break; // Last command?
870  pgcode = delim + 1; // Get the next command
871  }
872  parser.parse(saved_cmd); // Restore the parser state
873 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_subcommands_now()

void GcodeSuite::process_subcommands_now ( char *  gcode)
static
875  {
876  char * const saved_cmd = parser.command_ptr; // Save the parser state
877  for (;;) {
878  char * const delim = strchr(gcode, '\n'); // Get address of next newline
879  if (delim) *delim = '\0'; // Replace with nul
880  parser.parse(gcode); // Parse the current command
881  process_parsed_command(true); // Process it
882  if (!delim) break; // Last command?
883  gcode = delim + 1; // Get the next command
884  }
885  parser.parse(saved_cmd); // Restore the parser state
886 }
Here is the call graph for this function:

◆ home_all_axes()

static void GcodeSuite::home_all_axes ( )
static
343 { process_subcommands_now_P(PSTR("G28")); }
Here is the call graph for this function:

◆ dwell()

void GcodeSuite::dwell ( millis_t  time)
static

Dwell waits immediately. It does not synchronize. Use M400 instead of G4

149  {
150  time += millis();
151  while (PENDING(millis(), time)) idle();
152 }
Here is the call graph for this function:

Member Data Documentation

◆ axis_relative

uint8_t GcodeSuite::axis_relative
static
Initial value:
= (
(ar_init.x ? _BV(REL_X) : 0)
| (ar_init.y ? _BV(REL_Y) : 0)
| (ar_init.z ? _BV(REL_Z) : 0)
| (ar_init.e ? _BV(REL_E) : 0)
)

◆ previous_move_ms

millis_t GcodeSuite::previous_move_ms
static
WITHIN
#define WITHIN(N, L, H)
Definition: macros.h:195
PENDING
#define PENDING(NOW, SOON)
Definition: millis_t.h:28
SERIAL_CHAR
#define SERIAL_CHAR(x)
Definition: serial.h:69
REL_Y
Definition: gcode.h:287
PORT_REDIRECT
#define PORT_REDIRECT(p)
Definition: serial.h:66
pbuf::len
u16_t len
Definition: pbuf.h:159
XYZEval
Definition: types.h:101
SERIAL_ECHO
#define SERIAL_ECHO(x)
Definition: serial.h:70
GcodeSuite::process_subcommands_now_P
static void process_subcommands_now_P(PGM_P pgcode)
Definition: gcode.cpp:859
GcodeSuite::process_parsed_command
static void process_parsed_command(const bool no_ok=false)
Definition: gcode.cpp:195
strchr_P
const char * strchr_P(const char *s, int c)
Definition: Marduino.h:57
GCodeQueue::ok_to_send
static void ok_to_send()
Definition: queue.cpp:242
queue
GCodeQueue queue
Definition: queue.cpp:28
IS_SD_PRINTING
#define IS_SD_PRINTING()
Definition: cardreader.h:295
REL_X
Definition: gcode.h:287
print_job_timer
Stopwatch print_job_timer
Definition: printcounter.cpp:63
SERIAL_ECHOPAIR
#define SERIAL_ECHOPAIR(V...)
Definition: serial.h:114
E_MODE_ABS
Definition: gcode.h:287
PGM_P
#define PGM_P
Definition: pgmspace.h:30
XYZEval::e
T e
Definition: types.h:383
i
uint8_t i
Definition: screen_test_graph.c:72
GcodeSuite::previous_move_ms
static millis_t previous_move_ms
Definition: gcode.h:329
AxisEnum
AxisEnum
Definition: types.h:36
destination
xyze_pos_t destination
Definition: motion.cpp:110
millis
uint32_t millis(void)
Definition: wiring_time.c:29
PrintJobRecovery::queue_index_r
static uint8_t queue_index_r
Queue index of the active command.
Definition: power_loss_recovery.h:113
recovery
PrintJobRecovery recovery
SERIAL_ECHO_START
#define SERIAL_ECHO_START()
Definition: serial.h:179
SERIAL_ECHOLN
#define SERIAL_ECHOLN(x)
Definition: serial.h:72
KEEPALIVE_STATE
#define KEEPALIVE_STATE(N)
Definition: gcode.h:365
strlen_P
#define strlen_P(s)
Definition: pgmspace.h:61
E_MODE_REL
Definition: gcode.h:287
MSG_INVALID_E_STEPPER
#define MSG_INVALID_E_STEPPER
Definition: language.h:168
GCodeQueue::command_buffer
static char command_buffer[BUFSIZE][MAX_CMD_SIZE]
Definition: queue.h:54
PSTR
#define PSTR(str)
Definition: pgmspace.h:31
current_position
xyze_pos_t current_position
Definition: motion.cpp:102
ar_init
static constexpr xyze_bool_t ar_init
Definition: gcode.cpp:53
LOGICAL_TO_NATIVE
#define LOGICAL_TO_NATIVE(POS, AXIS)
Definition: motion.h:270
GCodeQueue::index_r
static uint8_t index_r
Definition: queue.h:51
gcode
GcodeSuite gcode
Definition: gcode.cpp:29
GcodeSuite::axis_is_relative
static bool axis_is_relative(const AxisEnum a)
Definition: gcode.h:294
XYZEval::x
T x
Definition: types.h:383
feedrate_mm_s
feedRate_t feedrate_mm_s
Definition: motion.cpp:138
SERIAL_ECHOLNPAIR
#define SERIAL_ECHOLNPAIR(V...)
Definition: serial.h:144
createSpeedLookupTable.a
list a
Definition: createSpeedLookupTable.py:29
REL_Z
Definition: gcode.h:287
GcodeSuite::set_relative_mode
static void set_relative_mode(const bool rel)
Definition: gcode.h:301
_BV
#define _BV(bit)
Definition: wiring_constants.h:99
E_STEPPERS
#define E_STEPPERS
Definition: Conditionals_LCD.h:429
IS_SCARA
#define IS_SCARA
Definition: Conditionals_LCD.h:544
CBI
#define CBI(A, B)
Definition: macros.h:89
PrintJobRecovery::save
static void save(const bool force=false, const bool save_queue=true)
EXTRUDERS
#define EXTRUDERS
Definition: Configuration_A3ides_2209_MINI.h:148
DEBUGGING
#define DEBUGGING(F)
Definition: serial.h:47
strncpy_P
#define strncpy_P(a, b, n)
Definition: pgmspace.h:66
TEST
#define TEST(n, b)
Definition: macros.h:81
GcodeSuite::axis_relative
static uint8_t axis_relative
Definition: gcode.h:292
NOOP
#define NOOP
Definition: macros.h:258
E_AXIS
Definition: types.h:40
SBI
#define SBI(A, B)
Definition: macros.h:85
axis_codes
const xyze_char_t axis_codes
Definition: types.h:486
REL_E
Definition: gcode.h:287
SERIAL_ECHOLNPGM
#define SERIAL_ECHOLNPGM(S)
Definition: serial.h:174
LOOP_XYZE
#define LOOP_XYZE(VAR)
Definition: types.h:61
idle
void idle()
Definition: Marlin.cpp:629
MSG_E_STEPPER_NOT_SPECIFIED
#define MSG_E_STEPPER_NOT_SPECIFIED
Definition: language.h:169
PrintJobRecovery::enabled
static bool enabled
Definition: power_loss_recovery.h:138
MSG_INVALID_EXTRUDER
#define MSG_INVALID_EXTRUDER
Definition: language.h:167
active_extruder
constexpr uint8_t active_extruder
Definition: motion.h:107
ENABLED
#define ENABLED(V...)
Definition: macros.h:177
XYZEval::y
T y
Definition: types.h:383
createSpeedLookupTable.parser
parser
Definition: createSpeedLookupTable.py:14