My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

gcode.h 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /**
  24. * gcode.h - Temporary container for all gcode handlers
  25. */
  26. /**
  27. * -----------------
  28. * G-Codes in Marlin
  29. * -----------------
  30. *
  31. * Helpful G-code references:
  32. * - http://marlinfw.org/meta/gcode
  33. * - https://reprap.org/wiki/G-code
  34. * - http://linuxcnc.org/docs/html/gcode.html
  35. *
  36. * Help to document Marlin's G-codes online:
  37. * - https://github.com/MarlinFirmware/MarlinDocumentation
  38. *
  39. * -----------------
  40. *
  41. * "G" Codes
  42. *
  43. * G0 -> G1
  44. * G1 - Coordinated Movement X Y Z E
  45. * G2 - CW ARC
  46. * G3 - CCW ARC
  47. * G4 - Dwell S<seconds> or P<milliseconds>
  48. * G5 - Cubic B-spline with XYZE destination and IJPQ offsets
  49. * G10 - Retract filament according to settings of M207 (Requires FWRETRACT)
  50. * G11 - Retract recover filament according to settings of M208 (Requires FWRETRACT)
  51. * G12 - Clean tool (Requires NOZZLE_CLEAN_FEATURE)
  52. * G17 - Select Plane XY (Requires CNC_WORKSPACE_PLANES)
  53. * G18 - Select Plane ZX (Requires CNC_WORKSPACE_PLANES)
  54. * G19 - Select Plane YZ (Requires CNC_WORKSPACE_PLANES)
  55. * G20 - Set input units to inches (Requires INCH_MODE_SUPPORT)
  56. * G21 - Set input units to millimeters (Requires INCH_MODE_SUPPORT)
  57. * G26 - Mesh Validation Pattern (Requires G26_MESH_VALIDATION)
  58. * G27 - Park Nozzle (Requires NOZZLE_PARK_FEATURE)
  59. * G28 - Home one or more axes
  60. * G29 - Start or continue the bed leveling probe procedure (Requires bed leveling)
  61. * G30 - Single Z probe, probes bed at X Y location (defaults to current XY location)
  62. * G31 - Dock sled (Z_PROBE_SLED only)
  63. * G32 - Undock sled (Z_PROBE_SLED only)
  64. * G33 - Delta Auto-Calibration (Requires DELTA_AUTO_CALIBRATION)
  65. * G34 - Z Stepper automatic alignment using probe: I<iterations> T<accuracy> A<amplification> (Requires Z_STEPPER_AUTO_ALIGN)
  66. * G38 - Probe in any direction using the Z_MIN_PROBE (Requires G38_PROBE_TARGET)
  67. * G42 - Coordinated move to a mesh point (Requires MESH_BED_LEVELING, AUTO_BED_LEVELING_BLINEAR, or AUTO_BED_LEVELING_UBL)
  68. * G80 - Cancel current motion mode (Requires GCODE_MOTION_MODES)
  69. * G90 - Use Absolute Coordinates
  70. * G91 - Use Relative Coordinates
  71. * G92 - Set current position to coordinates given
  72. *
  73. * "M" Codes
  74. *
  75. * M0 - Unconditional stop - Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled)
  76. * M1 -> M0
  77. * M3 - Turn ON Laser | Spindle (clockwise), set Power | Speed. (Requires SPINDLE_FEATURE or LASER_FEATURE)
  78. * M4 - Turn ON Laser | Spindle (counter-clockwise), set Power | Speed. (Requires SPINDLE_FEATURE or LASER_FEATURE)
  79. * M5 - Turn OFF Laser | Spindle. (Requires SPINDLE_FEATURE or LASER_FEATURE)
  80. * M7 - Turn mist coolant ON. (Requires COOLANT_CONTROL)
  81. * M8 - Turn flood coolant ON. (Requires COOLANT_CONTROL)
  82. * M9 - Turn coolant OFF. (Requires COOLANT_CONTROL)
  83. * M12 - Set up closed loop control system. (Requires EXTERNAL_CLOSED_LOOP_CONTROLLER)
  84. * M16 - Expected printer check. (Requires EXPECTED_PRINTER_CHECK)
  85. * M17 - Enable/Power all stepper motors
  86. * M18 - Disable all stepper motors; same as M84
  87. * M20 - List SD card. (Requires SDSUPPORT)
  88. * M21 - Init SD card. (Requires SDSUPPORT)
  89. * M22 - Release SD card. (Requires SDSUPPORT)
  90. * M23 - Select SD file: "M23 /path/file.gco". (Requires SDSUPPORT)
  91. * M24 - Start/resume SD print. (Requires SDSUPPORT)
  92. * M25 - Pause SD print. (Requires SDSUPPORT)
  93. * M26 - Set SD position in bytes: "M26 S12345". (Requires SDSUPPORT)
  94. * M27 - Report SD print status. (Requires SDSUPPORT)
  95. * OR, with 'S<seconds>' set the SD status auto-report interval. (Requires AUTO_REPORT_SD_STATUS)
  96. * OR, with 'C' get the current filename.
  97. * M28 - Start SD write: "M28 /path/file.gco". (Requires SDSUPPORT)
  98. * M29 - Stop SD write. (Requires SDSUPPORT)
  99. * M30 - Delete file from SD: "M30 /path/file.gco"
  100. * M31 - Report time since last M109 or SD card start to serial.
  101. * M32 - Select file and start SD print: "M32 [S<bytepos>] !/path/file.gco#". (Requires SDSUPPORT)
  102. * Use P to run other files as sub-programs: "M32 P !filename#"
  103. * The '#' is necessary when calling from within sd files, as it stops buffer prereading
  104. * M33 - Get the longname version of a path. (Requires LONG_FILENAME_HOST_SUPPORT)
  105. * M34 - Set SD Card sorting options. (Requires SDCARD_SORT_ALPHA)
  106. * M42 - Change pin status via gcode: M42 P<pin> S<value>. LED pin assumed if P is omitted.
  107. * M43 - Display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
  108. * M48 - Measure Z Probe repeatability: M48 P<points> X<pos> Y<pos> V<level> E<engage> L<legs> S<chizoid>. (Requires Z_MIN_PROBE_REPEATABILITY_TEST)
  109. * M73 - Set the progress percentage. (Requires LCD_SET_PROGRESS_MANUALLY)
  110. * M75 - Start the print job timer.
  111. * M76 - Pause the print job timer.
  112. * M77 - Stop the print job timer.
  113. * M78 - Show statistical information about the print jobs. (Requires PRINTCOUNTER)
  114. * M80 - Turn on Power Supply. (Requires PSU_CONTROL)
  115. * M81 - Turn off Power Supply. (Requires PSU_CONTROL)
  116. * M82 - Set E codes absolute (default).
  117. * M83 - Set E codes relative while in Absolute (G90) mode.
  118. * M84 - Disable steppers until next move, or use S<seconds> to specify an idle
  119. * duration after which steppers should turn off. S0 disables the timeout.
  120. * M85 - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
  121. * M92 - Set planner.settings.axis_steps_per_mm for one or more axes.
  122. * M100 - Watch Free Memory (for debugging) (Requires M100_FREE_MEMORY_WATCHER)
  123. * M104 - Set extruder target temp.
  124. * M105 - Report current temperatures.
  125. * M106 - Set print fan speed.
  126. * M107 - Print fan off.
  127. * M108 - Break out of heating loops (M109, M190, M303). With no controller, breaks out of M0/M1. (Requires EMERGENCY_PARSER)
  128. * M109 - S<temp> Wait for extruder current temp to reach target temp. ** Wait only when heating! **
  129. * R<temp> Wait for extruder current temp to reach target temp. ** Wait for heating or cooling. **
  130. * If AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F
  131. * M110 - Set the current line number. (Used by host printing)
  132. * M111 - Set debug flags: "M111 S<flagbits>". See flag bits defined in enum.h.
  133. * M112 - Full Shutdown.
  134. * M113 - Get or set the timeout interval for Host Keepalive "busy" messages. (Requires HOST_KEEPALIVE_FEATURE)
  135. * M114 - Report current position.
  136. * M115 - Report capabilities. (Extended capabilities requires EXTENDED_CAPABILITIES_REPORT)
  137. * M117 - Display a message on the controller screen. (Requires an LCD)
  138. * M118 - Display a message in the host console.
  139. * M119 - Report endstops status.
  140. * M120 - Enable endstops detection.
  141. * M121 - Disable endstops detection.
  142. * M122 - Debug stepper (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470)
  143. * M125 - Save current position and move to filament change position. (Requires PARK_HEAD_ON_PAUSE)
  144. * M126 - Solenoid Air Valve Open. (Requires BARICUDA)
  145. * M127 - Solenoid Air Valve Closed. (Requires BARICUDA)
  146. * M128 - EtoP Open. (Requires BARICUDA)
  147. * M129 - EtoP Closed. (Requires BARICUDA)
  148. * M140 - Set bed target temp. S<temp>
  149. * M141 - Set heated chamber target temp. S<temp> (Requires a chamber heater)
  150. * M145 - Set heatup values for materials on the LCD. H<hotend> B<bed> F<fan speed> for S<material> (0=PLA, 1=ABS)
  151. * M149 - Set temperature units. (Requires TEMPERATURE_UNITS_SUPPORT)
  152. * M150 - Set Status LED Color as R<red> U<green> B<blue> P<bright>. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED, PCA9533, or PCA9632).
  153. * M155 - Auto-report temperatures with interval of S<seconds>. (Requires AUTO_REPORT_TEMPERATURES)
  154. * M163 - Set a single proportion for a mixing extruder. (Requires MIXING_EXTRUDER)
  155. * M164 - Commit the mix and save to a virtual tool (current, or as specified by 'S'). (Requires MIXING_EXTRUDER)
  156. * M165 - Set the mix for the mixing extruder (and current virtual tool) with parameters ABCDHI. (Requires MIXING_EXTRUDER and DIRECT_MIXING_IN_G1)
  157. * M166 - Set the Gradient Mix for the mixing extruder. (Requires GRADIENT_MIX)
  158. * M190 - S<temp> Wait for bed current temp to reach target temp. ** Wait only when heating! **
  159. * R<temp> Wait for bed current temp to reach target temp. ** Wait for heating or cooling. **
  160. * M200 - Set filament diameter, D<diameter>, setting E axis units to cubic. (Use S0 to revert to linear units.)
  161. * M201 - Set max acceleration in units/s^2 for print moves: "M201 X<accel> Y<accel> Z<accel> E<accel>"
  162. * M202 - Set max acceleration in units/s^2 for travel moves: "M202 X<accel> Y<accel> Z<accel> E<accel>" ** UNUSED IN MARLIN! **
  163. * M203 - Set maximum feedrate: "M203 X<fr> Y<fr> Z<fr> E<fr>" in units/sec.
  164. * M204 - Set default acceleration in units/sec^2: P<printing> R<extruder_only> T<travel>
  165. * M205 - Set advanced settings. Current units apply:
  166. S<print> T<travel> minimum speeds
  167. B<minimum segment time>
  168. X<max X jerk>, Y<max Y jerk>, Z<max Z jerk>, E<max E jerk>
  169. * M206 - Set additional homing offset. (Disabled by NO_WORKSPACE_OFFSETS or DELTA)
  170. * M207 - Set Retract Length: S<length>, Feedrate: F<units/min>, and Z lift: Z<distance>. (Requires FWRETRACT)
  171. * M208 - Set Recover (unretract) Additional (!) Length: S<length> and Feedrate: F<units/min>. (Requires FWRETRACT)
  172. * M209 - Turn Automatic Retract Detection on/off: S<0|1> (For slicers that don't support G10/11). (Requires FWRETRACT_AUTORETRACT)
  173. Every normal extrude-only move will be classified as retract depending on the direction.
  174. * M211 - Enable, Disable, and/or Report software endstops: S<0|1> (Requires MIN_SOFTWARE_ENDSTOPS or MAX_SOFTWARE_ENDSTOPS)
  175. * M217 - Set filament swap parameters: "M217 S<length> P<feedrate> R<feedrate>". (Requires SINGLENOZZLE)
  176. * M218 - Set/get a tool offset: "M218 T<index> X<offset> Y<offset>". (Requires 2 or more extruders)
  177. * M220 - Set Feedrate Percentage: "M220 S<percent>" (i.e., "FR" on the LCD)
  178. * Use "M220 B" to back up the Feedrate Percentage and "M220 R" to restore it. (Requires PRUSA_MMU2)
  179. * M221 - Set Flow Percentage: "M221 S<percent>"
  180. * M226 - Wait until a pin is in a given state: "M226 P<pin> S<state>"
  181. * M240 - Trigger a camera to take a photograph. (Requires PHOTO_GCODE)
  182. * M250 - Set LCD contrast: "M250 C<contrast>" (0-63). (Requires LCD support)
  183. * M260 - i2c Send Data (Requires EXPERIMENTAL_I2CBUS)
  184. * M261 - i2c Request Data (Requires EXPERIMENTAL_I2CBUS)
  185. * M280 - Set servo position absolute: "M280 P<index> S<angle|µs>". (Requires servos)
  186. * M281 - Set servo min|max position: "M281 P<index> L<min> U<max>". (Requires EDITABLE_SERVO_ANGLES)
  187. * M290 - Babystepping (Requires BABYSTEPPING)
  188. * M300 - Play beep sound S<frequency Hz> P<duration ms>
  189. * M301 - Set PID parameters P I and D. (Requires PIDTEMP)
  190. * M302 - Allow cold extrudes, or set the minimum extrude S<temperature>. (Requires PREVENT_COLD_EXTRUSION)
  191. * M303 - PID relay autotune S<temperature> sets the target temperature. Default 150C. (Requires PIDTEMP)
  192. * M304 - Set bed PID parameters P I and D. (Requires PIDTEMPBED)
  193. * M305 - Set user thermistor parameters R T and P. (Requires TEMP_SENSOR_x 1000)
  194. * M350 - Set microstepping mode. (Requires digital microstepping pins.)
  195. * M351 - Toggle MS1 MS2 pins directly. (Requires digital microstepping pins.)
  196. * M355 - Set Case Light on/off and set brightness. (Requires CASE_LIGHT_PIN)
  197. * M380 - Activate solenoid on active extruder. (Requires EXT_SOLENOID)
  198. * M381 - Disable all solenoids. (Requires EXT_SOLENOID)
  199. * M400 - Finish all moves.
  200. * M401 - Deploy and activate Z probe. (Requires a probe)
  201. * M402 - Deactivate and stow Z probe. (Requires a probe)
  202. * M403 - Set filament type for PRUSA MMU2
  203. * M404 - Display or set the Nominal Filament Width: "W<diameter>". (Requires FILAMENT_WIDTH_SENSOR)
  204. * M405 - Enable Filament Sensor flow control. "M405 D<delay_cm>". (Requires FILAMENT_WIDTH_SENSOR)
  205. * M406 - Disable Filament Sensor flow control. (Requires FILAMENT_WIDTH_SENSOR)
  206. * M407 - Display measured filament diameter in millimeters. (Requires FILAMENT_WIDTH_SENSOR)
  207. * M410 - Quickstop. Abort all planned moves.
  208. * M412 - Enable / Disable Filament Runout Detection. (Requires FILAMENT_RUNOUT_SENSOR)
  209. * M413 - Enable / Disable Power-Loss Recovery. (Requires POWER_LOSS_RECOVERY)
  210. * M420 - Enable/Disable Leveling (with current values) S1=enable S0=disable (Requires MESH_BED_LEVELING or ABL)
  211. * M421 - Set a single Z coordinate in the Mesh Leveling grid. X<units> Y<units> Z<units> (Requires MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, or AUTO_BED_LEVELING_UBL)
  212. * M422 - Set Z Stepper automatic alignment position using probe. X<units> Y<units> A<axis> (Requires Z_STEPPER_AUTO_ALIGN)
  213. * M425 - Enable/Disable and tune backlash correction. (Requires BACKLASH_COMPENSATION and BACKLASH_GCODE)
  214. * M428 - Set the home_offset based on the current_position. Nearest edge applies. (Disabled by NO_WORKSPACE_OFFSETS or DELTA)
  215. * M486 - Identify and cancel objects. (Requires CANCEL_OBJECTS)
  216. * M500 - Store parameters in EEPROM. (Requires EEPROM_SETTINGS)
  217. * M501 - Restore parameters from EEPROM. (Requires EEPROM_SETTINGS)
  218. * M502 - Revert to the default "factory settings". ** Does not write them to EEPROM! **
  219. * M503 - Print the current settings (in memory): "M503 S<verbose>". S0 specifies compact output.
  220. * M504 - Validate EEPROM contents. (Requires EEPROM_SETTINGS)
  221. * M524 - Abort the current SD print job started with M24. (Requires SDSUPPORT)
  222. * M540 - Enable/disable SD card abort on endstop hit: "M540 S<state>". (Requires SD_ABORT_ON_ENDSTOP_HIT)
  223. * M569 - Enable stealthChop on an axis. (Requires at least one _DRIVER_TYPE to be TMC2130/2160/2208/2209/5130/5160)
  224. * M600 - Pause for filament change: "M600 X<pos> Y<pos> Z<raise> E<first_retract> L<later_retract>". (Requires ADVANCED_PAUSE_FEATURE)
  225. * M603 - Configure filament change: "M603 T<tool> U<unload_length> L<load_length>". (Requires ADVANCED_PAUSE_FEATURE)
  226. * M605 - Set Dual X-Carriage movement mode: "M605 S<mode> [X<x_offset>] [R<temp_offset>]". (Requires DUAL_X_CARRIAGE)
  227. * M665 - Set delta configurations: "M665 H<delta height> L<diagonal rod> R<delta radius> S<segments/s> B<calibration radius> X<Alpha angle trim> Y<Beta angle trim> Z<Gamma angle trim> (Requires DELTA)
  228. * M666 - Set/get offsets for delta (Requires DELTA) or dual endstops (Requires [XYZ]_DUAL_ENDSTOPS).
  229. * M701 - Load filament (Requires FILAMENT_LOAD_UNLOAD_GCODES)
  230. * M702 - Unload filament (Requires FILAMENT_LOAD_UNLOAD_GCODES)
  231. * M810-M819 - Define/execute a G-code macro (Requires GCODE_MACROS)
  232. * M851 - Set Z probe's XYZ offsets in current units. (Negative values: X=left, Y=front, Z=below)
  233. * M852 - Set skew factors: "M852 [I<xy>] [J<xz>] [K<yz>]". (Requires SKEW_CORRECTION_GCODE, and SKEW_CORRECTION_FOR_Z for IJ)
  234. * M860 - Report the position of position encoder modules.
  235. * M861 - Report the status of position encoder modules.
  236. * M862 - Perform an axis continuity test for position encoder modules.
  237. * M863 - Perform steps-per-mm calibration for position encoder modules.
  238. * M864 - Change position encoder module I2C address.
  239. * M865 - Check position encoder module firmware version.
  240. * M866 - Report or reset position encoder module error count.
  241. * M867 - Enable/disable or toggle error correction for position encoder modules.
  242. * M868 - Report or set position encoder module error correction threshold.
  243. * M869 - Report position encoder module error.
  244. * M876 - Handle Prompt Response. (Requires HOST_PROMPT_SUPPORT and not EMERGENCY_PARSER)
  245. * M900 - Get or Set Linear Advance K-factor. (Requires LIN_ADVANCE)
  246. * M906 - Set or get motor current in milliamps using axis codes X, Y, Z, E. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470)
  247. * M907 - Set digital trimpot motor current using axis codes. (Requires a board with digital trimpots)
  248. * M908 - Control digital trimpot directly. (Requires DAC_STEPPER_CURRENT or DIGIPOTSS_PIN)
  249. * M909 - Print digipot/DAC current value. (Requires DAC_STEPPER_CURRENT)
  250. * M910 - Commit digipot/DAC value to external EEPROM via I2C. (Requires DAC_STEPPER_CURRENT)
  251. * M911 - Report stepper driver overtemperature pre-warn condition. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660)
  252. * M912 - Clear stepper driver overtemperature pre-warn condition flag. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660)
  253. * M913 - Set HYBRID_THRESHOLD speed. (Requires HYBRID_THRESHOLD)
  254. * M914 - Set StallGuard sensitivity. (Requires SENSORLESS_HOMING or SENSORLESS_PROBING)
  255. * M916 - L6470 tuning: Increase KVAL_HOLD until thermal warning. (Requires at least one _DRIVER_TYPE L6470)
  256. * M917 - L6470 tuning: Find minimum current thresholds. (Requires at least one _DRIVER_TYPE L6470)
  257. * M918 - L6470 tuning: Increase speed until max or error. (Requires at least one _DRIVER_TYPE L6470)
  258. * M951 - Set Magnetic Parking Extruder parameters. (Requires MAGNETIC_PARKING_EXTRUDER)
  259. * M7219 - Control Max7219 Matrix LEDs. (Requires MAX7219_GCODE)
  260. *
  261. * M360 - SCARA calibration: Move to cal-position ThetaA (0 deg calibration)
  262. * M361 - SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree)
  263. * M362 - SCARA calibration: Move to cal-position PsiA (0 deg calibration)
  264. * M363 - SCARA calibration: Move to cal-position PsiB (90 deg calibration - steps per degree)
  265. * M364 - SCARA calibration: Move to cal-position PSIC (90 deg to Theta calibration position)
  266. *
  267. * ************ Custom codes - This can change to suit future G-code regulations
  268. * G425 - Calibrate using a conductive object. (Requires CALIBRATION_GCODE)
  269. * M928 - Start SD logging: "M928 filename.gco". Stop with M29. (Requires SDSUPPORT)
  270. * M997 - Perform in-application firmware update
  271. * M999 - Restart after being stopped by error
  272. *
  273. * "T" Codes
  274. *
  275. * T0-T3 - Select an extruder (tool) by index: "T<n> F<units/min>"
  276. *
  277. */
  278. #include "../inc/MarlinConfig.h"
  279. #include "parser.h"
  280. #if ENABLED(I2C_POSITION_ENCODERS)
  281. #include "../feature/I2CPositionEncoder.h"
  282. #endif
  283. enum AxisRelative : uint8_t { REL_X, REL_Y, REL_Z, REL_E, E_MODE_ABS, E_MODE_REL };
  284. class GcodeSuite {
  285. public:
  286. static uint8_t axis_relative;
  287. static inline bool axis_is_relative(const AxisEnum a) {
  288. if (a == E_AXIS) {
  289. if (TEST(axis_relative, E_MODE_REL)) return true;
  290. if (TEST(axis_relative, E_MODE_ABS)) return false;
  291. }
  292. return TEST(axis_relative, a);
  293. }
  294. static inline void set_relative_mode(const bool rel) {
  295. axis_relative = rel ? _BV(REL_X) | _BV(REL_Y) | _BV(REL_Z) | _BV(REL_E) : 0;
  296. }
  297. static inline void set_e_relative() {
  298. CBI(axis_relative, E_MODE_ABS);
  299. SBI(axis_relative, E_MODE_REL);
  300. }
  301. static inline void set_e_absolute() {
  302. CBI(axis_relative, E_MODE_REL);
  303. SBI(axis_relative, E_MODE_ABS);
  304. }
  305. #if ENABLED(CNC_WORKSPACE_PLANES)
  306. /**
  307. * Workspace planes only apply to G2/G3 moves
  308. * (and "canned cycles" - not a current feature)
  309. */
  310. enum WorkspacePlane : char { PLANE_XY, PLANE_ZX, PLANE_YZ };
  311. static WorkspacePlane workspace_plane;
  312. #endif
  313. #define MAX_COORDINATE_SYSTEMS 9
  314. #if ENABLED(CNC_COORDINATE_SYSTEMS)
  315. static int8_t active_coordinate_system;
  316. static xyz_pos_t coordinate_system[MAX_COORDINATE_SYSTEMS];
  317. static bool select_coordinate_system(const int8_t _new);
  318. #endif
  319. static millis_t previous_move_ms;
  320. FORCE_INLINE static void reset_stepper_timeout() { previous_move_ms = millis(); }
  321. static int8_t get_target_extruder_from_command();
  322. static int8_t get_target_e_stepper_from_command();
  323. static void get_destination_from_command();
  324. static void process_parsed_command(const bool no_ok=false);
  325. static void process_next_command();
  326. // Execute G-code in-place, preserving current G-code parameters
  327. static void process_subcommands_now_P(PGM_P pgcode);
  328. static void process_subcommands_now(char * gcode);
  329. static inline void home_all_axes() {
  330. extern const char G28_STR[];
  331. process_subcommands_now_P(G28_STR);
  332. }
  333. #if ENABLED(HOST_KEEPALIVE_FEATURE)
  334. /**
  335. * States for managing Marlin and host communication
  336. * Marlin sends messages if blocked or busy
  337. */
  338. enum MarlinBusyState : char {
  339. NOT_BUSY, // Not in a handler
  340. IN_HANDLER, // Processing a GCode
  341. IN_PROCESS, // Known to be blocking command input (as in G29)
  342. PAUSED_FOR_USER, // Blocking pending any input
  343. PAUSED_FOR_INPUT // Blocking pending text input (concept)
  344. };
  345. static MarlinBusyState busy_state;
  346. static uint8_t host_keepalive_interval;
  347. static void host_keepalive();
  348. #define KEEPALIVE_STATE(N) REMEMBER(_KA_, gcode.busy_state, gcode.N)
  349. #else
  350. #define KEEPALIVE_STATE(N) NOOP
  351. #endif
  352. static void dwell(millis_t time);
  353. private:
  354. static void G0_G1(
  355. #if IS_SCARA || defined(G0_FEEDRATE)
  356. const bool fast_move=false
  357. #endif
  358. );
  359. #if ENABLED(ARC_SUPPORT)
  360. static void G2_G3(const bool clockwise);
  361. #endif
  362. static void G4();
  363. #if ENABLED(BEZIER_CURVE_SUPPORT)
  364. static void G5();
  365. #endif
  366. #if ENABLED(FWRETRACT)
  367. static void G10();
  368. static void G11();
  369. #endif
  370. #if ENABLED(NOZZLE_CLEAN_FEATURE)
  371. static void G12();
  372. #endif
  373. #if ENABLED(CNC_WORKSPACE_PLANES)
  374. static void G17();
  375. static void G18();
  376. static void G19();
  377. #endif
  378. #if ENABLED(INCH_MODE_SUPPORT)
  379. static void G20();
  380. static void G21();
  381. #endif
  382. #if ENABLED(G26_MESH_VALIDATION)
  383. static void G26();
  384. #endif
  385. #if ENABLED(NOZZLE_PARK_FEATURE)
  386. static void G27();
  387. #endif
  388. static void G28(const bool always_home_all);
  389. #if HAS_LEVELING
  390. #if ENABLED(G29_RETRY_AND_RECOVER)
  391. static void G29_with_retry();
  392. #define G29_TYPE bool
  393. #else
  394. #define G29_TYPE void
  395. #endif
  396. static G29_TYPE G29();
  397. #endif
  398. #if HAS_BED_PROBE
  399. static void G30();
  400. #if ENABLED(Z_PROBE_SLED)
  401. static void G31();
  402. static void G32();
  403. #endif
  404. #endif
  405. #if ENABLED(DELTA_AUTO_CALIBRATION)
  406. static void G33();
  407. #endif
  408. #if ENABLED(Z_STEPPER_AUTO_ALIGN)
  409. static void G34();
  410. static void M422();
  411. #endif
  412. #if ENABLED(G38_PROBE_TARGET)
  413. static void G38(const int8_t subcode);
  414. #endif
  415. #if HAS_MESH
  416. static void G42();
  417. #endif
  418. #if ENABLED(CNC_COORDINATE_SYSTEMS)
  419. static void G53();
  420. static void G54();
  421. static void G55();
  422. static void G56();
  423. static void G57();
  424. static void G58();
  425. static void G59();
  426. #endif
  427. #if ENABLED(GCODE_MOTION_MODES)
  428. static void G80();
  429. #endif
  430. static void G92();
  431. #if ENABLED(CALIBRATION_GCODE)
  432. static void G425();
  433. #endif
  434. #if HAS_RESUME_CONTINUE
  435. static void M0_M1();
  436. #endif
  437. #if HAS_CUTTER
  438. static void M3_M4(const bool is_M4);
  439. static void M5();
  440. #endif
  441. #if ENABLED(COOLANT_CONTROL)
  442. #if ENABLED(COOLANT_MIST)
  443. static void M7();
  444. #endif
  445. #if ENABLED(COOLANT_FLOOD)
  446. static void M8();
  447. #endif
  448. static void M9();
  449. #endif
  450. #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
  451. static void M12();
  452. #endif
  453. #if ENABLED(EXPECTED_PRINTER_CHECK)
  454. static void M16();
  455. #endif
  456. static void M17();
  457. static void M18_M84();
  458. #if ENABLED(SDSUPPORT)
  459. static void M20();
  460. static void M21();
  461. static void M22();
  462. static void M23();
  463. static void M24();
  464. static void M25();
  465. static void M26();
  466. static void M27();
  467. static void M28();
  468. static void M29();
  469. static void M30();
  470. #endif
  471. static void M31();
  472. #if ENABLED(SDSUPPORT)
  473. static void M32();
  474. #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
  475. static void M33();
  476. #endif
  477. #if BOTH(SDCARD_SORT_ALPHA, SDSORT_GCODE)
  478. static void M34();
  479. #endif
  480. #endif
  481. static void M42();
  482. #if ENABLED(PINS_DEBUGGING)
  483. static void M43();
  484. #endif
  485. #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
  486. static void M48();
  487. #endif
  488. #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
  489. static void M73();
  490. #endif
  491. static void M75();
  492. static void M76();
  493. static void M77();
  494. #if ENABLED(PRINTCOUNTER)
  495. static void M78();
  496. #endif
  497. #if ENABLED(PSU_CONTROL)
  498. static void M80();
  499. #endif
  500. static void M81();
  501. static void M82();
  502. static void M83();
  503. static void M85();
  504. static void M92();
  505. #if ENABLED(M100_FREE_MEMORY_WATCHER)
  506. static void M100();
  507. #endif
  508. #if EXTRUDERS
  509. static void M104();
  510. static void M109();
  511. #endif
  512. static void M105();
  513. #if FAN_COUNT > 0
  514. static void M106();
  515. static void M107();
  516. #endif
  517. #if DISABLED(EMERGENCY_PARSER)
  518. static void M108();
  519. static void M112();
  520. static void M410();
  521. #if ENABLED(HOST_PROMPT_SUPPORT)
  522. static void M876();
  523. #endif
  524. #endif
  525. static void M110();
  526. static void M111();
  527. #if ENABLED(HOST_KEEPALIVE_FEATURE)
  528. static void M113();
  529. #endif
  530. static void M114();
  531. static void M115();
  532. static void M117();
  533. static void M118();
  534. static void M119();
  535. static void M120();
  536. static void M121();
  537. #if ENABLED(PARK_HEAD_ON_PAUSE)
  538. static void M125();
  539. #endif
  540. #if ENABLED(BARICUDA)
  541. #if HAS_HEATER_1
  542. static void M126();
  543. static void M127();
  544. #endif
  545. #if HAS_HEATER_2
  546. static void M128();
  547. static void M129();
  548. #endif
  549. #endif
  550. #if HAS_HEATED_BED
  551. static void M140();
  552. static void M190();
  553. #endif
  554. #if HAS_HEATED_CHAMBER
  555. static void M141();
  556. static void M191();
  557. #endif
  558. #if HOTENDS && HAS_LCD_MENU
  559. static void M145();
  560. #endif
  561. #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
  562. static void M149();
  563. #endif
  564. #if HAS_COLOR_LEDS
  565. static void M150();
  566. #endif
  567. #if ENABLED(AUTO_REPORT_TEMPERATURES) && HAS_TEMP_SENSOR
  568. static void M155();
  569. #endif
  570. #if ENABLED(MIXING_EXTRUDER)
  571. static void M163();
  572. static void M164();
  573. #if ENABLED(DIRECT_MIXING_IN_G1)
  574. static void M165();
  575. #endif
  576. #if ENABLED(GRADIENT_MIX)
  577. static void M166();
  578. #endif
  579. #endif
  580. static void M200();
  581. static void M201();
  582. #if 0
  583. static void M202(); // Not used for Sprinter/grbl gen6
  584. #endif
  585. static void M203();
  586. static void M204();
  587. static void M205();
  588. #if HAS_M206_COMMAND
  589. static void M206();
  590. #endif
  591. #if ENABLED(FWRETRACT)
  592. static void M207();
  593. static void M208();
  594. #if ENABLED(FWRETRACT_AUTORETRACT)
  595. static void M209();
  596. #endif
  597. #endif
  598. static void M211();
  599. #if EXTRUDERS > 1
  600. static void M217();
  601. #endif
  602. #if HAS_HOTEND_OFFSET
  603. static void M218();
  604. #endif
  605. static void M220();
  606. #if EXTRUDERS
  607. static void M221();
  608. #endif
  609. static void M226();
  610. #if ENABLED(PHOTO_GCODE)
  611. static void M240();
  612. #endif
  613. #if HAS_LCD_CONTRAST
  614. static void M250();
  615. #endif
  616. #if ENABLED(EXPERIMENTAL_I2CBUS)
  617. static void M260();
  618. static void M261();
  619. #endif
  620. #if HAS_SERVOS
  621. static void M280();
  622. #if ENABLED(EDITABLE_SERVO_ANGLES)
  623. static void M281();
  624. #endif
  625. #endif
  626. #if ENABLED(BABYSTEPPING)
  627. static void M290();
  628. #endif
  629. #if HAS_BUZZER
  630. static void M300();
  631. #endif
  632. #if ENABLED(PIDTEMP)
  633. static void M301();
  634. #endif
  635. #if ENABLED(PREVENT_COLD_EXTRUSION)
  636. static void M302();
  637. #endif
  638. #if HAS_PID_HEATING
  639. static void M303();
  640. #endif
  641. #if ENABLED(PIDTEMPBED)
  642. static void M304();
  643. #endif
  644. #if HAS_USER_THERMISTORS
  645. static void M305();
  646. #endif
  647. #if HAS_MICROSTEPS
  648. static void M350();
  649. static void M351();
  650. #endif
  651. #if HAS_CASE_LIGHT
  652. static void M355();
  653. #endif
  654. #if ENABLED(MORGAN_SCARA)
  655. static bool M360();
  656. static bool M361();
  657. static bool M362();
  658. static bool M363();
  659. static bool M364();
  660. #endif
  661. #if EITHER(EXT_SOLENOID, MANUAL_SOLENOID_CONTROL)
  662. static void M380();
  663. static void M381();
  664. #endif
  665. static void M400();
  666. #if HAS_BED_PROBE
  667. static void M401();
  668. static void M402();
  669. #endif
  670. #if ENABLED(PRUSA_MMU2)
  671. static void M403();
  672. #endif
  673. #if ENABLED(FILAMENT_WIDTH_SENSOR)
  674. static void M404();
  675. static void M405();
  676. static void M406();
  677. static void M407();
  678. #endif
  679. #if HAS_FILAMENT_SENSOR
  680. static void M412();
  681. #endif
  682. #if HAS_LEVELING
  683. static void M420();
  684. static void M421();
  685. #endif
  686. #if ENABLED(BACKLASH_GCODE)
  687. static void M425();
  688. #endif
  689. #if HAS_M206_COMMAND
  690. static void M428();
  691. #endif
  692. #if ENABLED(CANCEL_OBJECTS)
  693. static void M486();
  694. #endif
  695. static void M500();
  696. static void M501();
  697. static void M502();
  698. #if DISABLED(DISABLE_M503)
  699. static void M503();
  700. #endif
  701. #if ENABLED(EEPROM_SETTINGS)
  702. static void M504();
  703. #endif
  704. #if ENABLED(SDSUPPORT)
  705. static void M524();
  706. #endif
  707. #if ENABLED(SD_ABORT_ON_ENDSTOP_HIT)
  708. static void M540();
  709. #endif
  710. #if ENABLED(BAUD_RATE_GCODE)
  711. static void M575();
  712. #endif
  713. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  714. static void M600();
  715. static void M603();
  716. #endif
  717. #if HAS_DUPLICATION_MODE
  718. static void M605();
  719. #endif
  720. #if IS_KINEMATIC
  721. static void M665();
  722. #endif
  723. #if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS
  724. static void M666();
  725. #endif
  726. #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  727. static void M701();
  728. static void M702();
  729. #endif
  730. #if ENABLED(GCODE_MACROS)
  731. static void M810_819();
  732. #endif
  733. #if HAS_BED_PROBE
  734. static void M851();
  735. #endif
  736. #if ENABLED(SKEW_CORRECTION_GCODE)
  737. static void M852();
  738. #endif
  739. #if ENABLED(I2C_POSITION_ENCODERS)
  740. FORCE_INLINE static void M860() { I2CPEM.M860(); }
  741. FORCE_INLINE static void M861() { I2CPEM.M861(); }
  742. FORCE_INLINE static void M862() { I2CPEM.M862(); }
  743. FORCE_INLINE static void M863() { I2CPEM.M863(); }
  744. FORCE_INLINE static void M864() { I2CPEM.M864(); }
  745. FORCE_INLINE static void M865() { I2CPEM.M865(); }
  746. FORCE_INLINE static void M866() { I2CPEM.M866(); }
  747. FORCE_INLINE static void M867() { I2CPEM.M867(); }
  748. FORCE_INLINE static void M868() { I2CPEM.M868(); }
  749. FORCE_INLINE static void M869() { I2CPEM.M869(); }
  750. #endif
  751. #if ENABLED(LIN_ADVANCE)
  752. static void M900();
  753. #endif
  754. #if HAS_TRINAMIC
  755. static void M122();
  756. static void M906();
  757. #if HAS_STEALTHCHOP
  758. static void M569();
  759. #endif
  760. #if ENABLED(MONITOR_DRIVER_STATUS)
  761. static void M911();
  762. static void M912();
  763. #endif
  764. #if ENABLED(HYBRID_THRESHOLD)
  765. static void M913();
  766. #endif
  767. #if USE_SENSORLESS
  768. static void M914();
  769. #endif
  770. #endif
  771. #if HAS_L64XX
  772. static void M122();
  773. static void M906();
  774. static void M916();
  775. static void M917();
  776. static void M918();
  777. #endif
  778. #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM || EITHER(DIGIPOT_I2C, DAC_STEPPER_CURRENT)
  779. static void M907();
  780. #if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT)
  781. static void M908();
  782. #if ENABLED(DAC_STEPPER_CURRENT)
  783. static void M909();
  784. static void M910();
  785. #endif
  786. #endif
  787. #endif
  788. #if ENABLED(SDSUPPORT)
  789. static void M928();
  790. #endif
  791. #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
  792. static void M951();
  793. #endif
  794. #if ENABLED(PLATFORM_M997_SUPPORT)
  795. static void M997();
  796. #endif
  797. static void M999();
  798. #if ENABLED(POWER_LOSS_RECOVERY)
  799. static void M413();
  800. static void M1000();
  801. #endif
  802. #if ENABLED(MAX7219_GCODE)
  803. static void M7219();
  804. #endif
  805. static void T(const uint8_t tool_index);
  806. };
  807. extern GcodeSuite gcode;