Initial split-up of G-code handlers by category
This commit is contained in:
46
Marlin/src/gcode/config/M200.h
Normal file
46
Marlin/src/gcode/config/M200.h
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M200: Set filament diameter and set E axis units to cubic units
|
||||
*
|
||||
* T<extruder> - Optional extruder number. Current extruder if omitted.
|
||||
* D<linear> - Diameter of the filament. Use "D0" to switch back to linear units on the E axis.
|
||||
*/
|
||||
void gcode_M200() {
|
||||
|
||||
if (get_target_extruder_from_command(200)) return;
|
||||
|
||||
if (parser.seen('D')) {
|
||||
// setting any extruder filament size disables volumetric on the assumption that
|
||||
// slicers either generate in extruder values as cubic mm or as as filament feeds
|
||||
// for all extruders
|
||||
volumetric_enabled = (parser.value_linear_units() != 0.0);
|
||||
if (volumetric_enabled) {
|
||||
filament_size[target_extruder] = parser.value_linear_units();
|
||||
// make sure all extruders have some sane value for the filament size
|
||||
for (uint8_t i = 0; i < COUNT(filament_size); i++)
|
||||
if (! filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
|
||||
}
|
||||
}
|
||||
calculate_volumetric_multipliers();
|
||||
}
|
40
Marlin/src/gcode/config/M201.h
Normal file
40
Marlin/src/gcode/config/M201.h
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
|
||||
*
|
||||
* With multiple extruders use T to specify which one.
|
||||
*/
|
||||
void gcode_M201() {
|
||||
|
||||
GET_TARGET_EXTRUDER(201);
|
||||
|
||||
LOOP_XYZE(i) {
|
||||
if (parser.seen(axis_codes[i])) {
|
||||
const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
|
||||
planner.max_acceleration_mm_per_s2[a] = parser.value_axis_units((AxisEnum)a);
|
||||
}
|
||||
}
|
||||
// steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
|
||||
planner.reset_acceleration_rates();
|
||||
}
|
37
Marlin/src/gcode/config/M203.h
Normal file
37
Marlin/src/gcode/config/M203.h
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M203: Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in units/sec
|
||||
*
|
||||
* With multiple extruders use T to specify which one.
|
||||
*/
|
||||
void gcode_M203() {
|
||||
|
||||
GET_TARGET_EXTRUDER(203);
|
||||
|
||||
LOOP_XYZE(i)
|
||||
if (parser.seen(axis_codes[i])) {
|
||||
const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
|
||||
planner.max_feedrate_mm_s[a] = parser.value_axis_units((AxisEnum)a);
|
||||
}
|
||||
}
|
49
Marlin/src/gcode/config/M204.h
Normal file
49
Marlin/src/gcode/config/M204.h
Normal file
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M204: Set Accelerations in units/sec^2 (M204 P1200 R3000 T3000)
|
||||
*
|
||||
* P = Printing moves
|
||||
* R = Retract only (no X, Y, Z) moves
|
||||
* T = Travel (non printing) moves
|
||||
*
|
||||
* Also sets minimum segment time in ms (B20000) to prevent buffer under-runs and M20 minimum feedrate
|
||||
*/
|
||||
void gcode_M204() {
|
||||
if (parser.seen('S')) { // Kept for legacy compatibility. Should NOT BE USED for new developments.
|
||||
planner.travel_acceleration = planner.acceleration = parser.value_linear_units();
|
||||
SERIAL_ECHOLNPAIR("Setting Print and Travel Acceleration: ", planner.acceleration);
|
||||
}
|
||||
if (parser.seen('P')) {
|
||||
planner.acceleration = parser.value_linear_units();
|
||||
SERIAL_ECHOLNPAIR("Setting Print Acceleration: ", planner.acceleration);
|
||||
}
|
||||
if (parser.seen('R')) {
|
||||
planner.retract_acceleration = parser.value_linear_units();
|
||||
SERIAL_ECHOLNPAIR("Setting Retract Acceleration: ", planner.retract_acceleration);
|
||||
}
|
||||
if (parser.seen('T')) {
|
||||
planner.travel_acceleration = parser.value_linear_units();
|
||||
SERIAL_ECHOLNPAIR("Setting Travel Acceleration: ", planner.travel_acceleration);
|
||||
}
|
||||
}
|
42
Marlin/src/gcode/config/M205.h
Normal file
42
Marlin/src/gcode/config/M205.h
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M205: Set Advanced Settings
|
||||
*
|
||||
* S = Min Feed Rate (units/s)
|
||||
* T = Min Travel Feed Rate (units/s)
|
||||
* B = Min Segment Time (µs)
|
||||
* X = Max X Jerk (units/sec^2)
|
||||
* Y = Max Y Jerk (units/sec^2)
|
||||
* Z = Max Z Jerk (units/sec^2)
|
||||
* E = Max E Jerk (units/sec^2)
|
||||
*/
|
||||
void gcode_M205() {
|
||||
if (parser.seen('S')) planner.min_feedrate_mm_s = parser.value_linear_units();
|
||||
if (parser.seen('T')) planner.min_travel_feedrate_mm_s = parser.value_linear_units();
|
||||
if (parser.seen('B')) planner.min_segment_time = parser.value_millis();
|
||||
if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units();
|
||||
if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units();
|
||||
if (parser.seen('Z')) planner.max_jerk[Z_AXIS] = parser.value_linear_units();
|
||||
if (parser.seen('E')) planner.max_jerk[E_AXIS] = parser.value_linear_units();
|
||||
}
|
54
Marlin/src/gcode/config/M218.h
Normal file
54
Marlin/src/gcode/config/M218.h
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M218 - set hotend offset (in linear units)
|
||||
*
|
||||
* T<tool>
|
||||
* X<xoffset>
|
||||
* Y<yoffset>
|
||||
* Z<zoffset> - Available with DUAL_X_CARRIAGE and SWITCHING_NOZZLE
|
||||
*/
|
||||
void gcode_M218() {
|
||||
if (get_target_extruder_from_command(218) || target_extruder == 0) return;
|
||||
|
||||
if (parser.seenval('X')) hotend_offset[X_AXIS][target_extruder] = parser.value_linear_units();
|
||||
if (parser.seenval('Y')) hotend_offset[Y_AXIS][target_extruder] = parser.value_linear_units();
|
||||
|
||||
#if ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_NOZZLE) || ENABLED(PARKING_EXTRUDER)
|
||||
if (parser.seenval('Z')) hotend_offset[Z_AXIS][target_extruder] = parser.value_linear_units();
|
||||
#endif
|
||||
|
||||
SERIAL_ECHO_START();
|
||||
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
|
||||
HOTEND_LOOP() {
|
||||
SERIAL_CHAR(' ');
|
||||
SERIAL_ECHO(hotend_offset[X_AXIS][e]);
|
||||
SERIAL_CHAR(',');
|
||||
SERIAL_ECHO(hotend_offset[Y_AXIS][e]);
|
||||
#if ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_NOZZLE) || ENABLED(PARKING_EXTRUDER)
|
||||
SERIAL_CHAR(',');
|
||||
SERIAL_ECHO(hotend_offset[Z_AXIS][e]);
|
||||
#endif
|
||||
}
|
||||
SERIAL_EOL();
|
||||
}
|
28
Marlin/src/gcode/config/M220.h
Normal file
28
Marlin/src/gcode/config/M220.h
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M220: Set speed percentage factor, aka "Feed Rate" (M220 S95)
|
||||
*/
|
||||
void gcode_M220() {
|
||||
if (parser.seenval('S')) feedrate_percentage = parser.value_int();
|
||||
}
|
30
Marlin/src/gcode/config/M221.h
Normal file
30
Marlin/src/gcode/config/M221.h
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M221: Set extrusion percentage (M221 T0 S95)
|
||||
*/
|
||||
void gcode_M221() {
|
||||
if (get_target_extruder_from_command(221)) return;
|
||||
if (parser.seenval('S'))
|
||||
flow_percentage[target_extruder] = parser.value_int();
|
||||
}
|
69
Marlin/src/gcode/config/M301.h
Normal file
69
Marlin/src/gcode/config/M301.h
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M301: Set PID parameters P I D (and optionally C, L)
|
||||
*
|
||||
* P[float] Kp term
|
||||
* I[float] Ki term (unscaled)
|
||||
* D[float] Kd term (unscaled)
|
||||
*
|
||||
* With PID_EXTRUSION_SCALING:
|
||||
*
|
||||
* C[float] Kc term
|
||||
* L[float] LPQ length
|
||||
*/
|
||||
void gcode_M301() {
|
||||
|
||||
// multi-extruder PID patch: M301 updates or prints a single extruder's PID values
|
||||
// default behaviour (omitting E parameter) is to update for extruder 0 only
|
||||
const uint8_t e = parser.byteval('E'); // extruder being updated
|
||||
|
||||
if (e < HOTENDS) { // catch bad input value
|
||||
if (parser.seen('P')) PID_PARAM(Kp, e) = parser.value_float();
|
||||
if (parser.seen('I')) PID_PARAM(Ki, e) = scalePID_i(parser.value_float());
|
||||
if (parser.seen('D')) PID_PARAM(Kd, e) = scalePID_d(parser.value_float());
|
||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||
if (parser.seen('C')) PID_PARAM(Kc, e) = parser.value_float();
|
||||
if (parser.seen('L')) lpq_len = parser.value_float();
|
||||
NOMORE(lpq_len, LPQ_MAX_LEN);
|
||||
#endif
|
||||
|
||||
thermalManager.updatePID();
|
||||
SERIAL_ECHO_START();
|
||||
#if ENABLED(PID_PARAMS_PER_HOTEND)
|
||||
SERIAL_ECHOPAIR(" e:", e); // specify extruder in serial output
|
||||
#endif // PID_PARAMS_PER_HOTEND
|
||||
SERIAL_ECHOPAIR(" p:", PID_PARAM(Kp, e));
|
||||
SERIAL_ECHOPAIR(" i:", unscalePID_i(PID_PARAM(Ki, e)));
|
||||
SERIAL_ECHOPAIR(" d:", unscalePID_d(PID_PARAM(Kd, e)));
|
||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||
//Kc does not have scaling applied above, or in resetting defaults
|
||||
SERIAL_ECHOPAIR(" c:", PID_PARAM(Kc, e));
|
||||
#endif
|
||||
SERIAL_EOL();
|
||||
}
|
||||
else {
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ERRORLN(MSG_INVALID_EXTRUDER);
|
||||
}
|
||||
}
|
54
Marlin/src/gcode/config/M302.h
Normal file
54
Marlin/src/gcode/config/M302.h
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M302: Allow cold extrudes, or set the minimum extrude temperature
|
||||
*
|
||||
* S<temperature> sets the minimum extrude temperature
|
||||
* P<bool> enables (1) or disables (0) cold extrusion
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* M302 ; report current cold extrusion state
|
||||
* M302 P0 ; enable cold extrusion checking
|
||||
* M302 P1 ; disables cold extrusion checking
|
||||
* M302 S0 ; always allow extrusion (disables checking)
|
||||
* M302 S170 ; only allow extrusion above 170
|
||||
* M302 S170 P1 ; set min extrude temp to 170 but leave disabled
|
||||
*/
|
||||
void gcode_M302() {
|
||||
const bool seen_S = parser.seen('S');
|
||||
if (seen_S) {
|
||||
thermalManager.extrude_min_temp = parser.value_celsius();
|
||||
thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0);
|
||||
}
|
||||
|
||||
if (parser.seen('P'))
|
||||
thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0) || parser.value_bool();
|
||||
else if (!seen_S) {
|
||||
// Report current state
|
||||
SERIAL_ECHO_START();
|
||||
SERIAL_ECHOPAIR("Cold extrudes are ", (thermalManager.allow_cold_extrude ? "en" : "dis"));
|
||||
SERIAL_ECHOPAIR("abled (min temp ", thermalManager.extrude_min_temp);
|
||||
SERIAL_ECHOLNPGM("C)");
|
||||
}
|
||||
}
|
34
Marlin/src/gcode/config/M304.h
Normal file
34
Marlin/src/gcode/config/M304.h
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
void gcode_M304() {
|
||||
if (parser.seen('P')) thermalManager.bedKp = parser.value_float();
|
||||
if (parser.seen('I')) thermalManager.bedKi = scalePID_i(parser.value_float());
|
||||
if (parser.seen('D')) thermalManager.bedKd = scalePID_d(parser.value_float());
|
||||
|
||||
thermalManager.updatePID();
|
||||
|
||||
SERIAL_ECHO_START();
|
||||
SERIAL_ECHOPAIR(" p:", thermalManager.bedKp);
|
||||
SERIAL_ECHOPAIR(" i:", unscalePID_i(thermalManager.bedKi));
|
||||
SERIAL_ECHOLNPAIR(" d:", unscalePID_d(thermalManager.bedKd));
|
||||
}
|
311
Marlin/src/gcode/config/M43.h
Normal file
311
Marlin/src/gcode/config/M43.h
Normal file
@ -0,0 +1,311 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../pins/pinsDebug.h"
|
||||
|
||||
inline void toggle_pins() {
|
||||
const bool I_flag = parser.boolval('I');
|
||||
const int repeat = parser.intval('R', 1),
|
||||
start = parser.intval('S'),
|
||||
end = parser.intval('E', NUM_DIGITAL_PINS - 1),
|
||||
wait = parser.intval('W', 500);
|
||||
|
||||
for (uint8_t pin = start; pin <= end; pin++) {
|
||||
//report_pin_state_extended(pin, I_flag, false);
|
||||
if (!VALID_PIN(pin)) continue;
|
||||
if (!I_flag && pin_is_protected(pin)) {
|
||||
report_pin_state_extended(pin, I_flag, true, "Untouched ");
|
||||
SERIAL_EOL();
|
||||
}
|
||||
else {
|
||||
report_pin_state_extended(pin, I_flag, true, "Pulsing ");
|
||||
#if AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
|
||||
if (pin == TEENSY_E2) {
|
||||
SET_OUTPUT(TEENSY_E2);
|
||||
for (int16_t j = 0; j < repeat; j++) {
|
||||
WRITE(TEENSY_E2, LOW); safe_delay(wait);
|
||||
WRITE(TEENSY_E2, HIGH); safe_delay(wait);
|
||||
WRITE(TEENSY_E2, LOW); safe_delay(wait);
|
||||
}
|
||||
}
|
||||
else if (pin == TEENSY_E3) {
|
||||
SET_OUTPUT(TEENSY_E3);
|
||||
for (int16_t j = 0; j < repeat; j++) {
|
||||
WRITE(TEENSY_E3, LOW); safe_delay(wait);
|
||||
WRITE(TEENSY_E3, HIGH); safe_delay(wait);
|
||||
WRITE(TEENSY_E3, LOW); safe_delay(wait);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
pinMode(pin, OUTPUT);
|
||||
for (int16_t j = 0; j < repeat; j++) {
|
||||
digitalWrite(pin, 0); safe_delay(wait);
|
||||
digitalWrite(pin, 1); safe_delay(wait);
|
||||
digitalWrite(pin, 0); safe_delay(wait);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
SERIAL_EOL();
|
||||
}
|
||||
SERIAL_ECHOLNPGM("Done.");
|
||||
|
||||
} // toggle_pins
|
||||
|
||||
inline void servo_probe_test() {
|
||||
#if !(NUM_SERVOS > 0 && HAS_SERVO_0)
|
||||
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ERRORLNPGM("SERVO not setup");
|
||||
|
||||
#elif !HAS_Z_SERVO_ENDSTOP
|
||||
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ERRORLNPGM("Z_ENDSTOP_SERVO_NR not setup");
|
||||
|
||||
#else // HAS_Z_SERVO_ENDSTOP
|
||||
|
||||
const uint8_t probe_index = parser.byteval('P', Z_ENDSTOP_SERVO_NR);
|
||||
|
||||
SERIAL_PROTOCOLLNPGM("Servo probe test");
|
||||
SERIAL_PROTOCOLLNPAIR(". using index: ", probe_index);
|
||||
SERIAL_PROTOCOLLNPAIR(". deploy angle: ", z_servo_angle[0]);
|
||||
SERIAL_PROTOCOLLNPAIR(". stow angle: ", z_servo_angle[1]);
|
||||
|
||||
bool probe_inverting;
|
||||
|
||||
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
|
||||
|
||||
#define PROBE_TEST_PIN Z_MIN_PIN
|
||||
|
||||
SERIAL_PROTOCOLLNPAIR(". probe uses Z_MIN pin: ", PROBE_TEST_PIN);
|
||||
SERIAL_PROTOCOLLNPGM(". uses Z_MIN_ENDSTOP_INVERTING (ignores Z_MIN_PROBE_ENDSTOP_INVERTING)");
|
||||
SERIAL_PROTOCOLPGM(". Z_MIN_ENDSTOP_INVERTING: ");
|
||||
|
||||
#if Z_MIN_ENDSTOP_INVERTING
|
||||
SERIAL_PROTOCOLLNPGM("true");
|
||||
#else
|
||||
SERIAL_PROTOCOLLNPGM("false");
|
||||
#endif
|
||||
|
||||
probe_inverting = Z_MIN_ENDSTOP_INVERTING;
|
||||
|
||||
#elif ENABLED(Z_MIN_PROBE_ENDSTOP)
|
||||
|
||||
#define PROBE_TEST_PIN Z_MIN_PROBE_PIN
|
||||
SERIAL_PROTOCOLLNPAIR(". probe uses Z_MIN_PROBE_PIN: ", PROBE_TEST_PIN);
|
||||
SERIAL_PROTOCOLLNPGM(". uses Z_MIN_PROBE_ENDSTOP_INVERTING (ignores Z_MIN_ENDSTOP_INVERTING)");
|
||||
SERIAL_PROTOCOLPGM(". Z_MIN_PROBE_ENDSTOP_INVERTING: ");
|
||||
|
||||
#if Z_MIN_PROBE_ENDSTOP_INVERTING
|
||||
SERIAL_PROTOCOLLNPGM("true");
|
||||
#else
|
||||
SERIAL_PROTOCOLLNPGM("false");
|
||||
#endif
|
||||
|
||||
probe_inverting = Z_MIN_PROBE_ENDSTOP_INVERTING;
|
||||
|
||||
#endif
|
||||
|
||||
SERIAL_PROTOCOLLNPGM(". deploy & stow 4 times");
|
||||
SET_INPUT_PULLUP(PROBE_TEST_PIN);
|
||||
bool deploy_state, stow_state;
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
MOVE_SERVO(probe_index, z_servo_angle[0]); //deploy
|
||||
safe_delay(500);
|
||||
deploy_state = READ(PROBE_TEST_PIN);
|
||||
MOVE_SERVO(probe_index, z_servo_angle[1]); //stow
|
||||
safe_delay(500);
|
||||
stow_state = READ(PROBE_TEST_PIN);
|
||||
}
|
||||
if (probe_inverting != deploy_state) SERIAL_PROTOCOLLNPGM("WARNING - INVERTING setting probably backwards");
|
||||
|
||||
refresh_cmd_timeout();
|
||||
|
||||
if (deploy_state != stow_state) {
|
||||
SERIAL_PROTOCOLLNPGM("BLTouch clone detected");
|
||||
if (deploy_state) {
|
||||
SERIAL_PROTOCOLLNPGM(". DEPLOYED state: HIGH (logic 1)");
|
||||
SERIAL_PROTOCOLLNPGM(". STOWED (triggered) state: LOW (logic 0)");
|
||||
}
|
||||
else {
|
||||
SERIAL_PROTOCOLLNPGM(". DEPLOYED state: LOW (logic 0)");
|
||||
SERIAL_PROTOCOLLNPGM(". STOWED (triggered) state: HIGH (logic 1)");
|
||||
}
|
||||
#if ENABLED(BLTOUCH)
|
||||
SERIAL_PROTOCOLLNPGM("ERROR: BLTOUCH enabled - set this device up as a Z Servo Probe with inverting as true.");
|
||||
#endif
|
||||
|
||||
}
|
||||
else { // measure active signal length
|
||||
MOVE_SERVO(probe_index, z_servo_angle[0]); // deploy
|
||||
safe_delay(500);
|
||||
SERIAL_PROTOCOLLNPGM("please trigger probe");
|
||||
uint16_t probe_counter = 0;
|
||||
|
||||
// Allow 30 seconds max for operator to trigger probe
|
||||
for (uint16_t j = 0; j < 500 * 30 && probe_counter == 0 ; j++) {
|
||||
|
||||
safe_delay(2);
|
||||
|
||||
if (0 == j % (500 * 1)) // keep cmd_timeout happy
|
||||
refresh_cmd_timeout();
|
||||
|
||||
if (deploy_state != READ(PROBE_TEST_PIN)) { // probe triggered
|
||||
|
||||
for (probe_counter = 1; probe_counter < 50 && deploy_state != READ(PROBE_TEST_PIN); ++probe_counter)
|
||||
safe_delay(2);
|
||||
|
||||
if (probe_counter == 50)
|
||||
SERIAL_PROTOCOLLNPGM("Z Servo Probe detected"); // >= 100mS active time
|
||||
else if (probe_counter >= 2)
|
||||
SERIAL_PROTOCOLLNPAIR("BLTouch compatible probe detected - pulse width (+/- 4mS): ", probe_counter * 2); // allow 4 - 100mS pulse
|
||||
else
|
||||
SERIAL_PROTOCOLLNPGM("noise detected - please re-run test"); // less than 2mS pulse
|
||||
|
||||
MOVE_SERVO(probe_index, z_servo_angle[1]); //stow
|
||||
|
||||
} // pulse detected
|
||||
|
||||
} // for loop waiting for trigger
|
||||
|
||||
if (probe_counter == 0) SERIAL_PROTOCOLLNPGM("trigger not detected");
|
||||
|
||||
} // measure active signal length
|
||||
|
||||
#endif
|
||||
|
||||
} // servo_probe_test
|
||||
|
||||
/**
|
||||
* M43: Pin debug - report pin state, watch pins, toggle pins and servo probe test/report
|
||||
*
|
||||
* M43 - report name and state of pin(s)
|
||||
* P<pin> Pin to read or watch. If omitted, reads all pins.
|
||||
* I Flag to ignore Marlin's pin protection.
|
||||
*
|
||||
* M43 W - Watch pins -reporting changes- until reset, click, or M108.
|
||||
* P<pin> Pin to read or watch. If omitted, read/watch all pins.
|
||||
* I Flag to ignore Marlin's pin protection.
|
||||
*
|
||||
* M43 E<bool> - Enable / disable background endstop monitoring
|
||||
* - Machine continues to operate
|
||||
* - Reports changes to endstops
|
||||
* - Toggles LED_PIN when an endstop changes
|
||||
* - Can not reliably catch the 5mS pulse from BLTouch type probes
|
||||
*
|
||||
* M43 T - Toggle pin(s) and report which pin is being toggled
|
||||
* S<pin> - Start Pin number. If not given, will default to 0
|
||||
* L<pin> - End Pin number. If not given, will default to last pin defined for this board
|
||||
* I<bool> - Flag to ignore Marlin's pin protection. Use with caution!!!!
|
||||
* R - Repeat pulses on each pin this number of times before continueing to next pin
|
||||
* W - Wait time (in miliseconds) between pulses. If not given will default to 500
|
||||
*
|
||||
* M43 S - Servo probe test
|
||||
* P<index> - Probe index (optional - defaults to 0
|
||||
*/
|
||||
void gcode_M43() {
|
||||
|
||||
if (parser.seen('T')) { // must be first or else its "S" and "E" parameters will execute endstop or servo test
|
||||
toggle_pins();
|
||||
return;
|
||||
}
|
||||
|
||||
// Enable or disable endstop monitoring
|
||||
if (parser.seen('E')) {
|
||||
endstop_monitor_flag = parser.value_bool();
|
||||
SERIAL_PROTOCOLPGM("endstop monitor ");
|
||||
serialprintPGM(endstop_monitor_flag ? PSTR("en") : PSTR("dis"));
|
||||
SERIAL_PROTOCOLLNPGM("abled");
|
||||
return;
|
||||
}
|
||||
|
||||
if (parser.seen('S')) {
|
||||
servo_probe_test();
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the range of pins to test or watch
|
||||
const uint8_t first_pin = parser.byteval('P'),
|
||||
last_pin = parser.seenval('P') ? first_pin : NUM_DIGITAL_PINS - 1;
|
||||
|
||||
if (first_pin > last_pin) return;
|
||||
|
||||
const bool ignore_protection = parser.boolval('I');
|
||||
|
||||
// Watch until click, M108, or reset
|
||||
if (parser.boolval('W')) {
|
||||
SERIAL_PROTOCOLLNPGM("Watching pins");
|
||||
uint8_t pin_state[last_pin - first_pin + 1];
|
||||
for (int8_t pin = first_pin; pin <= last_pin; pin++) {
|
||||
if (!VALID_PIN(pin)) continue;
|
||||
if (pin_is_protected(pin) && !ignore_protection) continue;
|
||||
pinMode(pin, INPUT_PULLUP);
|
||||
delay(1);
|
||||
/*
|
||||
if (IS_ANALOG(pin))
|
||||
pin_state[pin - first_pin] = analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)); // int16_t pin_state[...]
|
||||
else
|
||||
//*/
|
||||
pin_state[pin - first_pin] = digitalRead(pin);
|
||||
}
|
||||
|
||||
#if HAS_RESUME_CONTINUE
|
||||
wait_for_user = true;
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
for (int8_t pin = first_pin; pin <= last_pin; pin++) {
|
||||
if (!VALID_PIN(pin)) continue;
|
||||
if (pin_is_protected(pin) && !ignore_protection) continue;
|
||||
const byte val =
|
||||
/*
|
||||
IS_ANALOG(pin)
|
||||
? analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)) : // int16_t val
|
||||
:
|
||||
//*/
|
||||
digitalRead(pin);
|
||||
if (val != pin_state[pin - first_pin]) {
|
||||
report_pin_state_extended(pin, ignore_protection, false);
|
||||
pin_state[pin - first_pin] = val;
|
||||
}
|
||||
}
|
||||
|
||||
#if HAS_RESUME_CONTINUE
|
||||
if (!wait_for_user) {
|
||||
KEEPALIVE_STATE(IN_HANDLER);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
safe_delay(200);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Report current state of selected pin(s)
|
||||
for (uint8_t pin = first_pin; pin <= last_pin; pin++)
|
||||
if (VALID_PIN(pin)) report_pin_state_extended(pin, ignore_protection, true);
|
||||
}
|
28
Marlin/src/gcode/config/M540.h
Normal file
28
Marlin/src/gcode/config/M540.h
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M540: Set whether SD card print should abort on endstop hit (M540 S<0|1>)
|
||||
*/
|
||||
void gcode_M540() {
|
||||
if (parser.seen('S')) stepper.abort_on_endstop_hit = parser.value_bool();
|
||||
}
|
51
Marlin/src/gcode/config/M92.h
Normal file
51
Marlin/src/gcode/config/M92.h
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M92: Set axis steps-per-unit for one or more axes, X, Y, Z, and E.
|
||||
* (Follows the same syntax as G92)
|
||||
*
|
||||
* With multiple extruders use T to specify which one.
|
||||
*/
|
||||
void gcode_M92() {
|
||||
|
||||
GET_TARGET_EXTRUDER(92);
|
||||
|
||||
LOOP_XYZE(i) {
|
||||
if (parser.seen(axis_codes[i])) {
|
||||
if (i == E_AXIS) {
|
||||
const float value = parser.value_per_axis_unit((AxisEnum)(E_AXIS + TARGET_EXTRUDER));
|
||||
if (value < 20.0) {
|
||||
float factor = planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab.
|
||||
planner.max_jerk[E_AXIS] *= factor;
|
||||
planner.max_feedrate_mm_s[E_AXIS + TARGET_EXTRUDER] *= factor;
|
||||
planner.max_acceleration_steps_per_s2[E_AXIS + TARGET_EXTRUDER] *= factor;
|
||||
}
|
||||
planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] = value;
|
||||
}
|
||||
else {
|
||||
planner.axis_steps_per_mm[i] = parser.value_per_axis_unit((AxisEnum)i);
|
||||
}
|
||||
}
|
||||
}
|
||||
planner.refresh_positioning();
|
||||
}
|
Reference in New Issue
Block a user