Initial split-up of G-code handlers by category
This commit is contained in:
52
Marlin/src/gcode/feature/advance/M900.h
Normal file
52
Marlin/src/gcode/feature/advance/M900.h
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M900: Set and/or Get advance K factor and WH/D ratio
|
||||
*
|
||||
* K<factor> Set advance K factor
|
||||
* R<ratio> Set ratio directly (overrides WH/D)
|
||||
* W<width> H<height> D<diam> Set ratio from WH/D
|
||||
*/
|
||||
void gcode_M900() {
|
||||
stepper.synchronize();
|
||||
|
||||
const float newK = parser.floatval('K', -1);
|
||||
if (newK >= 0) planner.extruder_advance_k = newK;
|
||||
|
||||
float newR = parser.floatval('R', -1);
|
||||
if (newR < 0) {
|
||||
const float newD = parser.floatval('D', -1),
|
||||
newW = parser.floatval('W', -1),
|
||||
newH = parser.floatval('H', -1);
|
||||
if (newD >= 0 && newW >= 0 && newH >= 0)
|
||||
newR = newD ? (newW * newH) / (sq(newD * 0.5) * M_PI) : 0;
|
||||
}
|
||||
if (newR >= 0) planner.advance_ed_ratio = newR;
|
||||
|
||||
SERIAL_ECHO_START();
|
||||
SERIAL_ECHOPAIR("Advance K=", planner.extruder_advance_k);
|
||||
SERIAL_ECHOPGM(" E/D=");
|
||||
const float ratio = planner.advance_ed_ratio;
|
||||
if (ratio) SERIAL_ECHO(ratio); else SERIAL_ECHOPGM("Auto");
|
||||
SERIAL_EOL();
|
||||
}
|
30
Marlin/src/gcode/feature/baricuda/M126.h
Normal file
30
Marlin/src/gcode/feature/baricuda/M126.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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M126: Heater 1 valve open
|
||||
*/
|
||||
void gcode_M126() {
|
||||
|
||||
baricuda_valve_pressure = parser.byteval('S', 255);
|
||||
|
||||
}
|
30
Marlin/src/gcode/feature/baricuda/M127.h
Normal file
30
Marlin/src/gcode/feature/baricuda/M127.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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M127: Heater 1 valve close
|
||||
*/
|
||||
void gcode_M127() {
|
||||
|
||||
baricuda_valve_pressure = 0;
|
||||
|
||||
}
|
30
Marlin/src/gcode/feature/baricuda/M128.h
Normal file
30
Marlin/src/gcode/feature/baricuda/M128.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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M128: Heater 2 valve open
|
||||
*/
|
||||
void gcode_M128() {
|
||||
|
||||
baricuda_e_to_p_pressure = parser.byteval('S', 255);
|
||||
|
||||
}
|
30
Marlin/src/gcode/feature/baricuda/M129.h
Normal file
30
Marlin/src/gcode/feature/baricuda/M129.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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M129: Heater 2 valve close
|
||||
*/
|
||||
void gcode_M129() {
|
||||
|
||||
baricuda_e_to_p_pressure = 0;
|
||||
|
||||
}
|
53
Marlin/src/gcode/feature/camera/M240.h
Normal file
53
Marlin/src/gcode/feature/camera/M240.h
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M240: Trigger a camera by emulating a Canon RC-1
|
||||
* See http://www.doc-diy.net/photo/rc-1_hacked/
|
||||
*/
|
||||
void gcode_M240() {
|
||||
#ifdef CHDK
|
||||
|
||||
OUT_WRITE(CHDK, HIGH);
|
||||
chdkHigh = millis();
|
||||
chdkActive = true;
|
||||
|
||||
#elif HAS_PHOTOGRAPH
|
||||
|
||||
const uint8_t NUM_PULSES = 16;
|
||||
const float PULSE_LENGTH = 0.01524;
|
||||
for (int i = 0; i < NUM_PULSES; i++) {
|
||||
WRITE(PHOTOGRAPH_PIN, HIGH);
|
||||
_delay_ms(PULSE_LENGTH);
|
||||
WRITE(PHOTOGRAPH_PIN, LOW);
|
||||
_delay_ms(PULSE_LENGTH);
|
||||
}
|
||||
delay(7.33);
|
||||
for (int i = 0; i < NUM_PULSES; i++) {
|
||||
WRITE(PHOTOGRAPH_PIN, HIGH);
|
||||
_delay_ms(PULSE_LENGTH);
|
||||
WRITE(PHOTOGRAPH_PIN, LOW);
|
||||
_delay_ms(PULSE_LENGTH);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
77
Marlin/src/gcode/feature/caselight/M355.h
Normal file
77
Marlin/src/gcode/feature/caselight/M355.h
Normal file
@ -0,0 +1,77 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#if HAS_CASE_LIGHT
|
||||
|
||||
#ifndef INVERT_CASE_LIGHT
|
||||
#define INVERT_CASE_LIGHT false
|
||||
#endif
|
||||
int case_light_brightness; // LCD routine wants INT
|
||||
bool case_light_on;
|
||||
|
||||
void update_case_light() {
|
||||
pinMode(CASE_LIGHT_PIN, OUTPUT); // digitalWrite doesn't set the port mode
|
||||
uint8_t case_light_bright = (uint8_t)case_light_brightness;
|
||||
if (case_light_on) {
|
||||
if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) {
|
||||
analogWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? 255 - case_light_brightness : case_light_brightness );
|
||||
}
|
||||
else WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? LOW : HIGH);
|
||||
}
|
||||
else WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? HIGH : LOW);
|
||||
}
|
||||
|
||||
#endif // HAS_CASE_LIGHT
|
||||
|
||||
/**
|
||||
* M355: Turn case light on/off and set brightness
|
||||
*
|
||||
* P<byte> Set case light brightness (PWM pin required - ignored otherwise)
|
||||
*
|
||||
* S<bool> Set case light on/off
|
||||
*
|
||||
* When S turns on the light on a PWM pin then the current brightness level is used/restored
|
||||
*
|
||||
* M355 P200 S0 turns off the light & sets the brightness level
|
||||
* M355 S1 turns on the light with a brightness of 200 (assuming a PWM pin)
|
||||
*/
|
||||
void gcode_M355() {
|
||||
#if HAS_CASE_LIGHT
|
||||
uint8_t args = 0;
|
||||
if (parser.seenval('P')) ++args, case_light_brightness = parser.value_byte();
|
||||
if (parser.seenval('S')) ++args, case_light_on = parser.value_bool();
|
||||
if (args) update_case_light();
|
||||
|
||||
// always report case light status
|
||||
SERIAL_ECHO_START();
|
||||
if (!case_light_on) {
|
||||
SERIAL_ECHOLN("Case light: off");
|
||||
}
|
||||
else {
|
||||
if (!USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) SERIAL_ECHOLN("Case light: on");
|
||||
else SERIAL_ECHOLNPAIR("Case light: ", case_light_brightness);
|
||||
}
|
||||
#else
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ERRORLNPGM(MSG_ERR_M355_NONE);
|
||||
#endif
|
||||
}
|
36
Marlin/src/gcode/feature/clean/G12.h
Normal file
36
Marlin/src/gcode/feature/clean/G12.h
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* G12: Clean the nozzle
|
||||
*/
|
||||
void gcode_G12() {
|
||||
// Don't allow nozzle cleaning without homing first
|
||||
if (axis_unhomed_error()) return;
|
||||
|
||||
const uint8_t pattern = parser.ushortval('P', 0),
|
||||
strokes = parser.ushortval('S', NOZZLE_CLEAN_STROKES),
|
||||
objects = parser.ushortval('T', NOZZLE_CLEAN_TRIANGLES);
|
||||
const float radius = parser.floatval('R', NOZZLE_CLEAN_CIRCLE_RADIUS);
|
||||
|
||||
Nozzle::clean(pattern, strokes, radius, objects);
|
||||
}
|
61
Marlin/src/gcode/feature/digipot/M907.h
Normal file
61
Marlin/src/gcode/feature/digipot/M907.h
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M907: Set digital trimpot motor current using axis codes X, Y, Z, E, B, S
|
||||
*/
|
||||
void gcode_M907() {
|
||||
#if HAS_DIGIPOTSS
|
||||
|
||||
LOOP_XYZE(i) if (parser.seen(axis_codes[i])) stepper.digipot_current(i, parser.value_int());
|
||||
if (parser.seen('B')) stepper.digipot_current(4, parser.value_int());
|
||||
if (parser.seen('S')) for (uint8_t i = 0; i <= 4; i++) stepper.digipot_current(i, parser.value_int());
|
||||
|
||||
#elif HAS_MOTOR_CURRENT_PWM
|
||||
|
||||
#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
|
||||
if (parser.seen('X')) stepper.digipot_current(0, parser.value_int());
|
||||
#endif
|
||||
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
|
||||
if (parser.seen('Z')) stepper.digipot_current(1, parser.value_int());
|
||||
#endif
|
||||
#if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
|
||||
if (parser.seen('E')) stepper.digipot_current(2, parser.value_int());
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(DIGIPOT_I2C)
|
||||
// this one uses actual amps in floating point
|
||||
LOOP_XYZE(i) if (parser.seen(axis_codes[i])) digipot_i2c_set_current(i, parser.value_float());
|
||||
// for each additional extruder (named B,C,D,E..., channels 4,5,6,7...)
|
||||
for (uint8_t i = NUM_AXIS; i < DIGIPOT_I2C_NUM_CHANNELS; i++) if (parser.seen('B' + i - (NUM_AXIS))) digipot_i2c_set_current(i, parser.value_float());
|
||||
#endif
|
||||
|
||||
#if ENABLED(DAC_STEPPER_CURRENT)
|
||||
if (parser.seen('S')) {
|
||||
const float dac_percent = parser.value_float();
|
||||
for (uint8_t i = 0; i <= 4; i++) dac_current_percent(i, dac_percent);
|
||||
}
|
||||
LOOP_XYZE(i) if (parser.seen(axis_codes[i])) dac_current_percent(i, parser.value_float());
|
||||
#endif
|
||||
}
|
39
Marlin/src/gcode/feature/digipot/M908.h
Normal file
39
Marlin/src/gcode/feature/digipot/M908.h
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M908: Control digital trimpot directly (M908 P<pin> S<current>)
|
||||
*/
|
||||
void gcode_M908() {
|
||||
#if HAS_DIGIPOTSS
|
||||
stepper.digitalPotWrite(
|
||||
parser.intval('P'),
|
||||
parser.intval('S')
|
||||
);
|
||||
#endif
|
||||
#ifdef DAC_STEPPER_CURRENT
|
||||
dac_current_raw(
|
||||
parser.byteval('P', -1),
|
||||
parser.ushortval('S', 0)
|
||||
);
|
||||
#endif
|
||||
}
|
27
Marlin/src/gcode/feature/digipot/M909.h
Normal file
27
Marlin/src/gcode/feature/digipot/M909.h
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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_M909() {
|
||||
|
||||
dac_print_values();
|
||||
|
||||
}
|
27
Marlin/src/gcode/feature/digipot/M910.h
Normal file
27
Marlin/src/gcode/feature/digipot/M910.h
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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_M910() {
|
||||
|
||||
dac_commit_eeprom();
|
||||
|
||||
}
|
41
Marlin/src/gcode/feature/fwretract/G10_G11.h
Normal file
41
Marlin/src/gcode/feature/fwretract/G10_G11.h
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* G10 - Retract filament according to settings of M207
|
||||
*/
|
||||
void gcode_G10() {
|
||||
#if EXTRUDERS > 1
|
||||
const bool rs = parser.boolval('S');
|
||||
retracted_swap[active_extruder] = rs; // Use 'S' for swap, default to false
|
||||
#endif
|
||||
retract(true
|
||||
#if EXTRUDERS > 1
|
||||
, rs
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* G11 - Recover filament according to settings of M208
|
||||
*/
|
||||
void gcode_G11() { retract(false); }
|
36
Marlin/src/gcode/feature/fwretract/M207.h
Normal file
36
Marlin/src/gcode/feature/fwretract/M207.h
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M207: Set firmware retraction values
|
||||
*
|
||||
* S[+units] retract_length
|
||||
* W[+units] swap_retract_length (multi-extruder)
|
||||
* F[units/min] retract_feedrate_mm_s
|
||||
* Z[units] retract_zlift
|
||||
*/
|
||||
void gcode_M207() {
|
||||
if (parser.seen('S')) retract_length = parser.value_axis_units(E_AXIS);
|
||||
if (parser.seen('F')) retract_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
|
||||
if (parser.seen('Z')) retract_zlift = parser.value_linear_units();
|
||||
if (parser.seen('W')) swap_retract_length = parser.value_axis_units(E_AXIS);
|
||||
}
|
36
Marlin/src/gcode/feature/fwretract/M208.h
Normal file
36
Marlin/src/gcode/feature/fwretract/M208.h
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M208: Set firmware un-retraction values
|
||||
*
|
||||
* S[+units] retract_recover_length (in addition to M207 S*)
|
||||
* W[+units] swap_retract_recover_length (multi-extruder)
|
||||
* F[units/min] retract_recover_feedrate_mm_s
|
||||
* R[units/min] swap_retract_recover_feedrate_mm_s
|
||||
*/
|
||||
void gcode_M208() {
|
||||
if (parser.seen('S')) retract_recover_length = parser.value_axis_units(E_AXIS);
|
||||
if (parser.seen('F')) retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
|
||||
if (parser.seen('R')) swap_retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
|
||||
if (parser.seen('W')) swap_retract_recover_length = parser.value_axis_units(E_AXIS);
|
||||
}
|
35
Marlin/src/gcode/feature/fwretract/M209.h
Normal file
35
Marlin/src/gcode/feature/fwretract/M209.h
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M209: Enable automatic retract (M209 S1)
|
||||
* For slicers that don't support G10/11, reversed extrude-only
|
||||
* moves will be classified as retraction.
|
||||
*/
|
||||
void gcode_M209() {
|
||||
if (MIN_AUTORETRACT <= MAX_AUTORETRACT) {
|
||||
if (parser.seen('S')) {
|
||||
autoretract_enabled = parser.value_bool();
|
||||
for (uint8_t i = 0; i < EXTRUDERS; i++) retracted[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
70
Marlin/src/gcode/feature/i2c/M260_M261.h
Normal file
70
Marlin/src/gcode/feature/i2c/M260_M261.h
Normal file
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M260: Send data to a I2C slave device
|
||||
*
|
||||
* This is a PoC, the formating and arguments for the GCODE will
|
||||
* change to be more compatible, the current proposal is:
|
||||
*
|
||||
* M260 A<slave device address base 10> ; Sets the I2C slave address the data will be sent to
|
||||
*
|
||||
* M260 B<byte-1 value in base 10>
|
||||
* M260 B<byte-2 value in base 10>
|
||||
* M260 B<byte-3 value in base 10>
|
||||
*
|
||||
* M260 S1 ; Send the buffered data and reset the buffer
|
||||
* M260 R1 ; Reset the buffer without sending data
|
||||
*
|
||||
*/
|
||||
void gcode_M260() {
|
||||
// Set the target address
|
||||
if (parser.seen('A')) i2c.address(parser.value_byte());
|
||||
|
||||
// Add a new byte to the buffer
|
||||
if (parser.seen('B')) i2c.addbyte(parser.value_byte());
|
||||
|
||||
// Flush the buffer to the bus
|
||||
if (parser.seen('S')) i2c.send();
|
||||
|
||||
// Reset and rewind the buffer
|
||||
else if (parser.seen('R')) i2c.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* M261: Request X bytes from I2C slave device
|
||||
*
|
||||
* Usage: M261 A<slave device address base 10> B<number of bytes>
|
||||
*/
|
||||
void gcode_M261() {
|
||||
if (parser.seen('A')) i2c.address(parser.value_byte());
|
||||
|
||||
uint8_t bytes = parser.byteval('B', 1);
|
||||
|
||||
if (i2c.addr && bytes && bytes <= TWIBUS_BUFFER_SIZE) {
|
||||
i2c.relay(bytes);
|
||||
}
|
||||
else {
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ERRORLN("Bad i2c request");
|
||||
}
|
||||
}
|
46
Marlin/src/gcode/feature/leds/M150.h
Normal file
46
Marlin/src/gcode/feature/leds/M150.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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M150: Set Status LED Color - Use R-U-B-W for R-G-B-W
|
||||
*
|
||||
* Always sets all 3 or 4 components. If a component is left out, set to 0.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* M150 R255 ; Turn LED red
|
||||
* M150 R255 U127 ; Turn LED orange (PWM only)
|
||||
* M150 ; Turn LED off
|
||||
* M150 R U B ; Turn LED white
|
||||
* M150 W ; Turn LED white using a white LED
|
||||
*
|
||||
*/
|
||||
void gcode_M150() {
|
||||
set_led_color(
|
||||
parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : 0,
|
||||
parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : 0,
|
||||
parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : 0
|
||||
#if ENABLED(RGBW_LED) || ENABLED(NEOPIXEL_RGBW_LED)
|
||||
, parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : 0
|
||||
#endif
|
||||
);
|
||||
}
|
38
Marlin/src/gcode/feature/mixing/M163.h
Normal file
38
Marlin/src/gcode/feature/mixing/M163.h
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M163: Set a single mix factor for a mixing extruder
|
||||
* This is called "weight" by some systems.
|
||||
*
|
||||
* S[index] The channel index to set
|
||||
* P[float] The mix value
|
||||
*
|
||||
*/
|
||||
void gcode_M163() {
|
||||
const int mix_index = parser.intval('S');
|
||||
if (mix_index < MIXING_STEPPERS) {
|
||||
float mix_value = parser.floatval('P');
|
||||
NOLESS(mix_value, 0.0);
|
||||
mixing_factor[mix_index] = RECIPROCAL(mix_value);
|
||||
}
|
||||
}
|
36
Marlin/src/gcode/feature/mixing/M164.h
Normal file
36
Marlin/src/gcode/feature/mixing/M164.h
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M164: Store the current mix factors as a virtual tool.
|
||||
*
|
||||
* S[index] The virtual tool to store
|
||||
*
|
||||
*/
|
||||
void gcode_M164() {
|
||||
const int tool_index = parser.intval('S');
|
||||
if (tool_index < MIXING_VIRTUAL_TOOLS) {
|
||||
normalize_mix();
|
||||
for (uint8_t i = 0; i < MIXING_STEPPERS; i++)
|
||||
mixing_virtual_tool_mix[tool_index][i] = mixing_factor[i];
|
||||
}
|
||||
}
|
36
Marlin/src/gcode/feature/mixing/M165.h
Normal file
36
Marlin/src/gcode/feature/mixing/M165.h
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M165: Set multiple mix factors for a mixing extruder.
|
||||
* Factors that are left out will be set to 0.
|
||||
* All factors together must add up to 1.0.
|
||||
*
|
||||
* A[factor] Mix factor for extruder stepper 1
|
||||
* B[factor] Mix factor for extruder stepper 2
|
||||
* C[factor] Mix factor for extruder stepper 3
|
||||
* D[factor] Mix factor for extruder stepper 4
|
||||
* H[factor] Mix factor for extruder stepper 5
|
||||
* I[factor] Mix factor for extruder stepper 6
|
||||
*
|
||||
*/
|
||||
void gcode_M165() { gcode_get_mix(); }
|
30
Marlin/src/gcode/feature/pause/G27.h
Normal file
30
Marlin/src/gcode/feature/pause/G27.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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* G27: Park the nozzle
|
||||
*/
|
||||
void gcode_G27() {
|
||||
// Don't allow nozzle parking without homing first
|
||||
if (axis_unhomed_error()) return;
|
||||
Nozzle::park(parser.ushortval('P'));
|
||||
}
|
89
Marlin/src/gcode/feature/pause/M125.h
Normal file
89
Marlin/src/gcode/feature/pause/M125.h
Normal file
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* 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 "common.h"
|
||||
|
||||
/**
|
||||
* M125: Store current position and move to filament change position.
|
||||
* Called on pause (by M25) to prevent material leaking onto the
|
||||
* object. On resume (M24) the head will be moved back and the
|
||||
* print will resume.
|
||||
*
|
||||
* If Marlin is compiled without SD Card support, M125 can be
|
||||
* used directly to pause the print and move to park position,
|
||||
* resuming with a button click or M108.
|
||||
*
|
||||
* L = override retract length
|
||||
* X = override X
|
||||
* Y = override Y
|
||||
* Z = override Z raise
|
||||
*/
|
||||
void gcode_M125() {
|
||||
|
||||
// Initial retract before move to filament change position
|
||||
const float retract = parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0
|
||||
#ifdef PAUSE_PARK_RETRACT_LENGTH
|
||||
- (PAUSE_PARK_RETRACT_LENGTH)
|
||||
#endif
|
||||
;
|
||||
|
||||
// Lift Z axis
|
||||
const float z_lift = parser.linearval('Z')
|
||||
#ifdef PAUSE_PARK_Z_ADD
|
||||
+ PAUSE_PARK_Z_ADD
|
||||
#endif
|
||||
;
|
||||
|
||||
// Move XY axes to filament change position or given position
|
||||
const float x_pos = parser.linearval('X')
|
||||
#ifdef PAUSE_PARK_X_POS
|
||||
+ PAUSE_PARK_X_POS
|
||||
#endif
|
||||
#if HOTENDS > 1 && DISABLED(DUAL_X_CARRIAGE)
|
||||
+ (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0)
|
||||
#endif
|
||||
;
|
||||
const float y_pos = parser.linearval('Y')
|
||||
#ifdef PAUSE_PARK_Y_POS
|
||||
+ PAUSE_PARK_Y_POS
|
||||
#endif
|
||||
#if HOTENDS > 1 && DISABLED(DUAL_X_CARRIAGE)
|
||||
+ (active_extruder ? hotend_offset[Y_AXIS][active_extruder] : 0)
|
||||
#endif
|
||||
;
|
||||
|
||||
#if DISABLED(SDSUPPORT)
|
||||
const bool job_running = print_job_timer.isRunning();
|
||||
#endif
|
||||
|
||||
if (pause_print(retract, z_lift, x_pos, y_pos)) {
|
||||
#if DISABLED(SDSUPPORT)
|
||||
// Wait for lcd click or M108
|
||||
wait_for_filament_reload();
|
||||
|
||||
// Return to print position and continue
|
||||
resume_print();
|
||||
|
||||
if (job_running) print_job_timer.start();
|
||||
#endif
|
||||
}
|
||||
}
|
103
Marlin/src/gcode/feature/pause/M600.h
Normal file
103
Marlin/src/gcode/feature/pause/M600.h
Normal file
@ -0,0 +1,103 @@
|
||||
/**
|
||||
* 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 "common.h"
|
||||
|
||||
/**
|
||||
* M600: Pause for filament change
|
||||
*
|
||||
* E[distance] - Retract the filament this far (negative value)
|
||||
* Z[distance] - Move the Z axis by this distance
|
||||
* X[position] - Move to this X position, with Y
|
||||
* Y[position] - Move to this Y position, with X
|
||||
* U[distance] - Retract distance for removal (negative value) (manual reload)
|
||||
* L[distance] - Extrude distance for insertion (positive value) (manual reload)
|
||||
* B[count] - Number of times to beep, -1 for indefinite (if equipped with a buzzer)
|
||||
*
|
||||
* Default values are used for omitted arguments.
|
||||
*
|
||||
*/
|
||||
void gcode_M600() {
|
||||
|
||||
#if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
|
||||
// Don't allow filament change without homing first
|
||||
if (axis_unhomed_error()) home_all_axes();
|
||||
#endif
|
||||
|
||||
// Initial retract before move to filament change position
|
||||
const float retract = parser.seen('E') ? parser.value_axis_units(E_AXIS) : 0
|
||||
#ifdef PAUSE_PARK_RETRACT_LENGTH
|
||||
- (PAUSE_PARK_RETRACT_LENGTH)
|
||||
#endif
|
||||
;
|
||||
|
||||
// Lift Z axis
|
||||
const float z_lift = parser.linearval('Z', 0
|
||||
#ifdef PAUSE_PARK_Z_ADD
|
||||
+ PAUSE_PARK_Z_ADD
|
||||
#endif
|
||||
);
|
||||
|
||||
// Move XY axes to filament exchange position
|
||||
const float x_pos = parser.linearval('X', 0
|
||||
#ifdef PAUSE_PARK_X_POS
|
||||
+ PAUSE_PARK_X_POS
|
||||
#endif
|
||||
);
|
||||
const float y_pos = parser.linearval('Y', 0
|
||||
#ifdef PAUSE_PARK_Y_POS
|
||||
+ PAUSE_PARK_Y_POS
|
||||
#endif
|
||||
);
|
||||
|
||||
// Unload filament
|
||||
const float unload_length = parser.seen('U') ? parser.value_axis_units(E_AXIS) : 0
|
||||
#if defined(FILAMENT_CHANGE_UNLOAD_LENGTH) && FILAMENT_CHANGE_UNLOAD_LENGTH > 0
|
||||
- (FILAMENT_CHANGE_UNLOAD_LENGTH)
|
||||
#endif
|
||||
;
|
||||
|
||||
// Load filament
|
||||
const float load_length = parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0
|
||||
#ifdef FILAMENT_CHANGE_LOAD_LENGTH
|
||||
+ FILAMENT_CHANGE_LOAD_LENGTH
|
||||
#endif
|
||||
;
|
||||
|
||||
const int beep_count = parser.intval('B',
|
||||
#ifdef FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS
|
||||
FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS
|
||||
#else
|
||||
-1
|
||||
#endif
|
||||
);
|
||||
|
||||
const bool job_running = print_job_timer.isRunning();
|
||||
|
||||
if (pause_print(retract, z_lift, x_pos, y_pos, unload_length, beep_count, true)) {
|
||||
wait_for_filament_reload(beep_count);
|
||||
resume_print(load_length, ADVANCED_PAUSE_EXTRUDE_LENGTH, beep_count);
|
||||
}
|
||||
|
||||
// Resume the print job timer if it was running
|
||||
if (job_running) print_job_timer.start();
|
||||
}
|
335
Marlin/src/gcode/feature/pause/common.h
Normal file
335
Marlin/src/gcode/feature/pause/common.h
Normal file
@ -0,0 +1,335 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* feature/pause/common.h - Merge this with its G-codes in the refactor
|
||||
*/
|
||||
|
||||
#ifndef PAUSE_COMMON_H
|
||||
#define PAUSE_COMMON_H
|
||||
|
||||
#if IS_KINEMATIC
|
||||
#define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder)
|
||||
#else
|
||||
#define RUNPLAN(RATE_MM_S) line_to_destination(RATE_MM_S)
|
||||
#endif
|
||||
|
||||
static float resume_position[XYZE];
|
||||
static bool move_away_flag = false;
|
||||
#if ENABLED(SDSUPPORT)
|
||||
static bool sd_print_paused = false;
|
||||
#endif
|
||||
|
||||
static void filament_change_beep(const int8_t max_beep_count, const bool init=false) {
|
||||
static millis_t next_buzz = 0;
|
||||
static int8_t runout_beep = 0;
|
||||
|
||||
if (init) next_buzz = runout_beep = 0;
|
||||
|
||||
const millis_t ms = millis();
|
||||
if (ELAPSED(ms, next_buzz)) {
|
||||
if (max_beep_count < 0 || runout_beep < max_beep_count + 5) { // Only beep as long as we're supposed to
|
||||
next_buzz = ms + ((max_beep_count < 0 || runout_beep < max_beep_count) ? 2500 : 400);
|
||||
BUZZ(300, 2000);
|
||||
runout_beep++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ensure_safe_temperature() {
|
||||
bool heaters_heating = true;
|
||||
|
||||
wait_for_heatup = true; // M108 will clear this
|
||||
while (wait_for_heatup && heaters_heating) {
|
||||
idle();
|
||||
heaters_heating = false;
|
||||
HOTEND_LOOP() {
|
||||
if (thermalManager.degTargetHotend(e) && abs(thermalManager.degHotend(e) - thermalManager.degTargetHotend(e)) > TEMP_HYSTERESIS) {
|
||||
heaters_heating = true;
|
||||
#if ENABLED(ULTIPANEL)
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool pause_print(const float &retract, const float &z_lift, const float &x_pos, const float &y_pos,
|
||||
const float &unload_length = 0 , const int8_t max_beep_count = 0, const bool show_lcd = false
|
||||
) {
|
||||
if (move_away_flag) return false; // already paused
|
||||
|
||||
if (!DEBUGGING(DRYRUN) && (unload_length != 0 || retract != 0)) {
|
||||
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
||||
if (!thermalManager.allow_cold_extrude &&
|
||||
thermalManager.degTargetHotend(active_extruder) < thermalManager.extrude_min_temp) {
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ERRORLNPGM(MSG_TOO_COLD_FOR_M600);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
ensure_safe_temperature(); // wait for extruder to heat up before unloading
|
||||
}
|
||||
|
||||
// Indicate that the printer is paused
|
||||
move_away_flag = true;
|
||||
|
||||
// Pause the print job and timer
|
||||
#if ENABLED(SDSUPPORT)
|
||||
if (IS_SD_PRINTING) {
|
||||
card.pauseSDPrint();
|
||||
sd_print_paused = true;
|
||||
}
|
||||
#endif
|
||||
print_job_timer.pause();
|
||||
|
||||
// Show initial message and wait for synchronize steppers
|
||||
if (show_lcd) {
|
||||
#if ENABLED(ULTIPANEL)
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Save current position
|
||||
stepper.synchronize();
|
||||
COPY(resume_position, current_position);
|
||||
|
||||
if (retract) {
|
||||
// Initial retract before move to filament change position
|
||||
set_destination_to_current();
|
||||
destination[E_AXIS] += retract;
|
||||
RUNPLAN(PAUSE_PARK_RETRACT_FEEDRATE);
|
||||
stepper.synchronize();
|
||||
}
|
||||
|
||||
// Lift Z axis
|
||||
if (z_lift > 0)
|
||||
do_blocking_move_to_z(current_position[Z_AXIS] + z_lift, PAUSE_PARK_Z_FEEDRATE);
|
||||
|
||||
// Move XY axes to filament exchange position
|
||||
do_blocking_move_to_xy(x_pos, y_pos, PAUSE_PARK_XY_FEEDRATE);
|
||||
|
||||
if (unload_length != 0) {
|
||||
if (show_lcd) {
|
||||
#if ENABLED(ULTIPANEL)
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_UNLOAD);
|
||||
idle();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Unload filament
|
||||
set_destination_to_current();
|
||||
destination[E_AXIS] += unload_length;
|
||||
RUNPLAN(FILAMENT_CHANGE_UNLOAD_FEEDRATE);
|
||||
stepper.synchronize();
|
||||
}
|
||||
|
||||
if (show_lcd) {
|
||||
#if ENABLED(ULTIPANEL)
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INSERT);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if HAS_BUZZER
|
||||
filament_change_beep(max_beep_count, true);
|
||||
#endif
|
||||
|
||||
idle();
|
||||
|
||||
// Disable extruders steppers for manual filament changing (only on boards that have separate ENABLE_PINS)
|
||||
#if E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN
|
||||
disable_e_steppers();
|
||||
safe_delay(100);
|
||||
#endif
|
||||
|
||||
// Start the heater idle timers
|
||||
const millis_t nozzle_timeout = (millis_t)(PAUSE_PARK_NOZZLE_TIMEOUT) * 1000UL;
|
||||
|
||||
HOTEND_LOOP()
|
||||
thermalManager.start_heater_idle_timer(e, nozzle_timeout);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void wait_for_filament_reload(const int8_t max_beep_count = 0) {
|
||||
bool nozzle_timed_out = false;
|
||||
|
||||
// Wait for filament insert by user and press button
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
wait_for_user = true; // LCD click or M108 will clear this
|
||||
while (wait_for_user) {
|
||||
#if HAS_BUZZER
|
||||
filament_change_beep(max_beep_count);
|
||||
#endif
|
||||
|
||||
// If the nozzle has timed out, wait for the user to press the button to re-heat the nozzle, then
|
||||
// re-heat the nozzle, re-show the insert screen, restart the idle timers, and start over
|
||||
if (!nozzle_timed_out)
|
||||
HOTEND_LOOP()
|
||||
nozzle_timed_out |= thermalManager.is_heater_idle(e);
|
||||
|
||||
if (nozzle_timed_out) {
|
||||
#if ENABLED(ULTIPANEL)
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_CLICK_TO_HEAT_NOZZLE);
|
||||
#endif
|
||||
|
||||
// Wait for LCD click or M108
|
||||
while (wait_for_user) idle(true);
|
||||
|
||||
// Re-enable the heaters if they timed out
|
||||
HOTEND_LOOP() thermalManager.reset_heater_idle_timer(e);
|
||||
|
||||
// Wait for the heaters to reach the target temperatures
|
||||
ensure_safe_temperature();
|
||||
|
||||
#if ENABLED(ULTIPANEL)
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INSERT);
|
||||
#endif
|
||||
|
||||
// Start the heater idle timers
|
||||
const millis_t nozzle_timeout = (millis_t)(PAUSE_PARK_NOZZLE_TIMEOUT) * 1000UL;
|
||||
|
||||
HOTEND_LOOP()
|
||||
thermalManager.start_heater_idle_timer(e, nozzle_timeout);
|
||||
|
||||
wait_for_user = true; /* Wait for user to load filament */
|
||||
nozzle_timed_out = false;
|
||||
|
||||
#if HAS_BUZZER
|
||||
filament_change_beep(max_beep_count, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
idle(true);
|
||||
}
|
||||
KEEPALIVE_STATE(IN_HANDLER);
|
||||
}
|
||||
|
||||
static void resume_print(const float &load_length = 0, const float &initial_extrude_length = 0, const int8_t max_beep_count = 0) {
|
||||
bool nozzle_timed_out = false;
|
||||
|
||||
if (!move_away_flag) return;
|
||||
|
||||
// Re-enable the heaters if they timed out
|
||||
HOTEND_LOOP() {
|
||||
nozzle_timed_out |= thermalManager.is_heater_idle(e);
|
||||
thermalManager.reset_heater_idle_timer(e);
|
||||
}
|
||||
|
||||
if (nozzle_timed_out) ensure_safe_temperature();
|
||||
|
||||
#if HAS_BUZZER
|
||||
filament_change_beep(max_beep_count, true);
|
||||
#endif
|
||||
|
||||
if (load_length != 0) {
|
||||
#if ENABLED(ULTIPANEL)
|
||||
// Show "insert filament"
|
||||
if (nozzle_timed_out)
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INSERT);
|
||||
#endif
|
||||
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
wait_for_user = true; // LCD click or M108 will clear this
|
||||
while (wait_for_user && nozzle_timed_out) {
|
||||
#if HAS_BUZZER
|
||||
filament_change_beep(max_beep_count);
|
||||
#endif
|
||||
idle(true);
|
||||
}
|
||||
KEEPALIVE_STATE(IN_HANDLER);
|
||||
|
||||
#if ENABLED(ULTIPANEL)
|
||||
// Show "load" message
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_LOAD);
|
||||
#endif
|
||||
|
||||
// Load filament
|
||||
destination[E_AXIS] += load_length;
|
||||
RUNPLAN(FILAMENT_CHANGE_LOAD_FEEDRATE);
|
||||
stepper.synchronize();
|
||||
}
|
||||
|
||||
#if ENABLED(ULTIPANEL) && ADVANCED_PAUSE_EXTRUDE_LENGTH > 0
|
||||
|
||||
float extrude_length = initial_extrude_length;
|
||||
|
||||
do {
|
||||
if (extrude_length > 0) {
|
||||
// "Wait for filament extrude"
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_EXTRUDE);
|
||||
|
||||
// Extrude filament to get into hotend
|
||||
destination[E_AXIS] += extrude_length;
|
||||
RUNPLAN(ADVANCED_PAUSE_EXTRUDE_FEEDRATE);
|
||||
stepper.synchronize();
|
||||
}
|
||||
|
||||
// Show "Extrude More" / "Resume" menu and wait for reply
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
wait_for_user = false;
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_OPTION);
|
||||
while (advanced_pause_menu_response == ADVANCED_PAUSE_RESPONSE_WAIT_FOR) idle(true);
|
||||
KEEPALIVE_STATE(IN_HANDLER);
|
||||
|
||||
extrude_length = ADVANCED_PAUSE_EXTRUDE_LENGTH;
|
||||
|
||||
// Keep looping if "Extrude More" was selected
|
||||
} while (advanced_pause_menu_response == ADVANCED_PAUSE_RESPONSE_EXTRUDE_MORE);
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(ULTIPANEL)
|
||||
// "Wait for print to resume"
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_RESUME);
|
||||
#endif
|
||||
|
||||
// Set extruder to saved position
|
||||
destination[E_AXIS] = current_position[E_AXIS] = resume_position[E_AXIS];
|
||||
planner.set_e_position_mm(current_position[E_AXIS]);
|
||||
|
||||
// Move XY to starting position, then Z
|
||||
do_blocking_move_to_xy(resume_position[X_AXIS], resume_position[Y_AXIS], PAUSE_PARK_XY_FEEDRATE);
|
||||
do_blocking_move_to_z(resume_position[Z_AXIS], PAUSE_PARK_Z_FEEDRATE);
|
||||
|
||||
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
|
||||
filament_ran_out = false;
|
||||
#endif
|
||||
|
||||
#if ENABLED(ULTIPANEL)
|
||||
// Show status screen
|
||||
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
|
||||
#endif
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
if (sd_print_paused) {
|
||||
card.startFileprint();
|
||||
sd_print_paused = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
move_away_flag = false;
|
||||
}
|
||||
|
||||
#endif // PAUSE_COMMON_H
|
50
Marlin/src/gcode/feature/snmm/M702.h
Normal file
50
Marlin/src/gcode/feature/snmm/M702.h
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
inline void select_multiplexed_stepper(const uint8_t e) {
|
||||
stepper.synchronize();
|
||||
disable_e_steppers();
|
||||
WRITE(E_MUX0_PIN, TEST(e, 0) ? HIGH : LOW);
|
||||
WRITE(E_MUX1_PIN, TEST(e, 1) ? HIGH : LOW);
|
||||
WRITE(E_MUX2_PIN, TEST(e, 2) ? HIGH : LOW);
|
||||
safe_delay(100);
|
||||
}
|
||||
|
||||
/**
|
||||
* M702: Unload all extruders
|
||||
*/
|
||||
void gcode_M702() {
|
||||
for (uint8_t s = 0; s < E_STEPPERS; s++) {
|
||||
select_multiplexed_stepper(e);
|
||||
// TODO: standard unload filament function
|
||||
// MK2 firmware behavior:
|
||||
// - Make sure temperature is high enough
|
||||
// - Raise Z to at least 15 to make room
|
||||
// - Extrude 1cm of filament in 1 second
|
||||
// - Under 230C quickly purge ~12mm, over 230C purge ~10mm
|
||||
// - Change E max feedrate to 80, eject the filament from the tube. Sync.
|
||||
// - Restore E max feedrate to 50
|
||||
}
|
||||
// Go back to the last active extruder
|
||||
select_multiplexed_stepper(active_extruder);
|
||||
disable_e_steppers();
|
||||
}
|
65
Marlin/src/gcode/feature/trinamic/M906.h
Normal file
65
Marlin/src/gcode/feature/trinamic/M906.h
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
static void tmc2130_get_current(TMC2130Stepper &st, const char name) {
|
||||
SERIAL_CHAR(name);
|
||||
SERIAL_ECHOPGM(" axis driver current: ");
|
||||
SERIAL_ECHOLN(st.getCurrent());
|
||||
}
|
||||
static void tmc2130_set_current(TMC2130Stepper &st, const char name, const int mA) {
|
||||
st.setCurrent(mA, R_SENSE, HOLD_MULTIPLIER);
|
||||
tmc2130_get_current(st, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* M906: Set motor current in milliamps using axis codes X, Y, Z, E
|
||||
* Report driver currents when no axis specified
|
||||
*
|
||||
* S1: Enable automatic current control
|
||||
* S0: Disable
|
||||
*/
|
||||
void gcode_M906() {
|
||||
uint16_t values[XYZE];
|
||||
LOOP_XYZE(i)
|
||||
values[i] = parser.intval(axis_codes[i]);
|
||||
|
||||
#if ENABLED(X_IS_TMC2130)
|
||||
if (values[X_AXIS]) tmc2130_set_current(stepperX, 'X', values[X_AXIS]);
|
||||
else tmc2130_get_current(stepperX, 'X');
|
||||
#endif
|
||||
#if ENABLED(Y_IS_TMC2130)
|
||||
if (values[Y_AXIS]) tmc2130_set_current(stepperY, 'Y', values[Y_AXIS]);
|
||||
else tmc2130_get_current(stepperY, 'Y');
|
||||
#endif
|
||||
#if ENABLED(Z_IS_TMC2130)
|
||||
if (values[Z_AXIS]) tmc2130_set_current(stepperZ, 'Z', values[Z_AXIS]);
|
||||
else tmc2130_get_current(stepperZ, 'Z');
|
||||
#endif
|
||||
#if ENABLED(E0_IS_TMC2130)
|
||||
if (values[E_AXIS]) tmc2130_set_current(stepperE0, 'E', values[E_AXIS]);
|
||||
else tmc2130_get_current(stepperE0, 'E');
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTOMATIC_CURRENT_CONTROL)
|
||||
if (parser.seen('S')) auto_current_control = parser.value_bool();
|
||||
#endif
|
||||
}
|
49
Marlin/src/gcode/feature/trinamic/M911.h
Normal file
49
Marlin/src/gcode/feature/trinamic/M911.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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
static void tmc2130_report_otpw(TMC2130Stepper &st, const char name) {
|
||||
SERIAL_CHAR(name);
|
||||
SERIAL_ECHOPGM(" axis temperature prewarn triggered: ");
|
||||
serialprintPGM(st.getOTPW() ? PSTR("true") : PSTR("false"));
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
||||
/**
|
||||
* M911: Report TMC2130 stepper driver overtemperature pre-warn flag
|
||||
* The flag is held by the library and persist until manually cleared by M912
|
||||
*/
|
||||
void gcode_M911() {
|
||||
const bool reportX = parser.seen('X'), reportY = parser.seen('Y'), reportZ = parser.seen('Z'), reportE = parser.seen('E'),
|
||||
reportAll = (!reportX && !reportY && !reportZ && !reportE) || (reportX && reportY && reportZ && reportE);
|
||||
#if ENABLED(X_IS_TMC2130)
|
||||
if (reportX || reportAll) tmc2130_report_otpw(stepperX, 'X');
|
||||
#endif
|
||||
#if ENABLED(Y_IS_TMC2130)
|
||||
if (reportY || reportAll) tmc2130_report_otpw(stepperY, 'Y');
|
||||
#endif
|
||||
#if ENABLED(Z_IS_TMC2130)
|
||||
if (reportZ || reportAll) tmc2130_report_otpw(stepperZ, 'Z');
|
||||
#endif
|
||||
#if ENABLED(E0_IS_TMC2130)
|
||||
if (reportE || reportAll) tmc2130_report_otpw(stepperE0, 'E');
|
||||
#endif
|
||||
}
|
47
Marlin/src/gcode/feature/trinamic/M912.h
Normal file
47
Marlin/src/gcode/feature/trinamic/M912.h
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
static void tmc2130_clear_otpw(TMC2130Stepper &st, const char name) {
|
||||
st.clear_otpw();
|
||||
SERIAL_CHAR(name);
|
||||
SERIAL_ECHOLNPGM(" prewarn flag cleared");
|
||||
}
|
||||
|
||||
/**
|
||||
* M912: Clear TMC2130 stepper driver overtemperature pre-warn flag held by the library
|
||||
*/
|
||||
void gcode_M912() {
|
||||
const bool clearX = parser.seen('X'), clearY = parser.seen('Y'), clearZ = parser.seen('Z'), clearE = parser.seen('E'),
|
||||
clearAll = (!clearX && !clearY && !clearZ && !clearE) || (clearX && clearY && clearZ && clearE);
|
||||
#if ENABLED(X_IS_TMC2130)
|
||||
if (clearX || clearAll) tmc2130_clear_otpw(stepperX, 'X');
|
||||
#endif
|
||||
#if ENABLED(Y_IS_TMC2130)
|
||||
if (clearY || clearAll) tmc2130_clear_otpw(stepperY, 'Y');
|
||||
#endif
|
||||
#if ENABLED(Z_IS_TMC2130)
|
||||
if (clearZ || clearAll) tmc2130_clear_otpw(stepperZ, 'Z');
|
||||
#endif
|
||||
#if ENABLED(E0_IS_TMC2130)
|
||||
if (clearE || clearAll) tmc2130_clear_otpw(stepperE0, 'E');
|
||||
#endif
|
||||
}
|
57
Marlin/src/gcode/feature/trinamic/M913.h
Normal file
57
Marlin/src/gcode/feature/trinamic/M913.h
Normal file
@ -0,0 +1,57 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
static void tmc2130_get_pwmthrs(TMC2130Stepper &st, const char name, const uint16_t spmm) {
|
||||
SERIAL_CHAR(name);
|
||||
SERIAL_ECHOPGM(" stealthChop max speed set to ");
|
||||
SERIAL_ECHOLN(12650000UL * st.microsteps() / (256 * st.stealth_max_speed() * spmm));
|
||||
}
|
||||
static void tmc2130_set_pwmthrs(TMC2130Stepper &st, const char name, const int32_t thrs, const uint32_t spmm) {
|
||||
st.stealth_max_speed(12650000UL * st.microsteps() / (256 * thrs * spmm));
|
||||
tmc2130_get_pwmthrs(st, name, spmm);
|
||||
}
|
||||
|
||||
/**
|
||||
* M913: Set HYBRID_THRESHOLD speed.
|
||||
*/
|
||||
void gcode_M913() {
|
||||
uint16_t values[XYZE];
|
||||
LOOP_XYZE(i)
|
||||
values[i] = parser.intval(axis_codes[i]);
|
||||
|
||||
#if ENABLED(X_IS_TMC2130)
|
||||
if (values[X_AXIS]) tmc2130_set_pwmthrs(stepperX, 'X', values[X_AXIS], planner.axis_steps_per_mm[X_AXIS]);
|
||||
else tmc2130_get_pwmthrs(stepperX, 'X', planner.axis_steps_per_mm[X_AXIS]);
|
||||
#endif
|
||||
#if ENABLED(Y_IS_TMC2130)
|
||||
if (values[Y_AXIS]) tmc2130_set_pwmthrs(stepperY, 'Y', values[Y_AXIS], planner.axis_steps_per_mm[Y_AXIS]);
|
||||
else tmc2130_get_pwmthrs(stepperY, 'Y', planner.axis_steps_per_mm[Y_AXIS]);
|
||||
#endif
|
||||
#if ENABLED(Z_IS_TMC2130)
|
||||
if (values[Z_AXIS]) tmc2130_set_pwmthrs(stepperZ, 'Z', values[Z_AXIS], planner.axis_steps_per_mm[Z_AXIS]);
|
||||
else tmc2130_get_pwmthrs(stepperZ, 'Z', planner.axis_steps_per_mm[Z_AXIS]);
|
||||
#endif
|
||||
#if ENABLED(E0_IS_TMC2130)
|
||||
if (values[E_AXIS]) tmc2130_set_pwmthrs(stepperE0, 'E', values[E_AXIS], planner.axis_steps_per_mm[E_AXIS]);
|
||||
else tmc2130_get_pwmthrs(stepperE0, 'E', planner.axis_steps_per_mm[E_AXIS]);
|
||||
#endif
|
||||
}
|
45
Marlin/src/gcode/feature/trinamic/M914.h
Normal file
45
Marlin/src/gcode/feature/trinamic/M914.h
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
static void tmc2130_get_sgt(TMC2130Stepper &st, const char name) {
|
||||
SERIAL_CHAR(name);
|
||||
SERIAL_ECHOPGM(" driver homing sensitivity set to ");
|
||||
SERIAL_ECHOLN(st.sgt());
|
||||
}
|
||||
static void tmc2130_set_sgt(TMC2130Stepper &st, const char name, const int8_t sgt_val) {
|
||||
st.sgt(sgt_val);
|
||||
tmc2130_get_sgt(st, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* M914: Set SENSORLESS_HOMING sensitivity.
|
||||
*/
|
||||
void gcode_M914() {
|
||||
#if ENABLED(X_IS_TMC2130)
|
||||
if (parser.seen(axis_codes[X_AXIS])) tmc2130_set_sgt(stepperX, 'X', parser.value_int());
|
||||
else tmc2130_get_sgt(stepperX, 'X');
|
||||
#endif
|
||||
#if ENABLED(Y_IS_TMC2130)
|
||||
if (parser.seen(axis_codes[Y_AXIS])) tmc2130_set_sgt(stepperY, 'Y', parser.value_int());
|
||||
else tmc2130_get_sgt(stepperY, 'Y');
|
||||
#endif
|
||||
}
|
Reference in New Issue
Block a user