Single nozzle filament change (#11994)

This commit is contained in:
InsanityAutomation
2018-10-07 18:06:14 -04:00
committed by Scott Lahteine
parent bfcf570d68
commit 74cd6cb4fc
94 changed files with 1267 additions and 38 deletions

View File

@ -0,0 +1,63 @@
/**
* 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 "../../inc/MarlinConfigPre.h"
#if ENABLED(SINGLENOZZLE)
#include "../gcode.h"
#include "../../module/tool_change.h"
#if NUM_SERIAL > 1
#include "../../gcode/queue.h"
#endif
void M217_report(const bool eeprom=false) {
#if NUM_SERIAL > 1
const int16_t port = command_queue_port[cmd_queue_index_r];
#endif
serialprintPGM_P(port, eeprom ? PSTR(" M217") : PSTR("Singlenozzle:"));
SERIAL_ECHOPAIR_P(port, " S", singlenozzle_swap_length);
SERIAL_ECHOPAIR_P(port, " P", singlenozzle_prime_speed);
SERIAL_ECHOLNPAIR_P(port, " R", singlenozzle_retract_speed);
}
/**
* M217 - Set SINGLENOZZLE toolchange parameters
*
* S[mm] Swap length
* P[mm/s] Prime speed
* R[mm/s] Retract speed
*/
void GcodeSuite::M217() {
bool report = true;
if (parser.seenval('S')) { report = false; const float v = parser.value_float(); singlenozzle_swap_length = constrain(v, 0, 500); }
if (parser.seenval('P')) { report = false; const int16_t v = parser.value_int(); singlenozzle_prime_speed = constrain(v, 10, 5400); }
if (parser.seenval('R')) { report = false; const int16_t v = parser.value_int(); singlenozzle_retract_speed = constrain(v, 10, 5400); }
if (report) M217_report();
}
#endif // SINGLENOZZLE

View File

@ -487,6 +487,10 @@ void GcodeSuite::process_parsed_command(
case 211: M211(); break; // M211: Enable, Disable, and/or Report software endstops
#if ENABLED(SINGLENOZZLE)
case 217: M217(); break; // M217: Set filament swap parameters
#endif
#if HOTENDS > 1
case 218: M218(); break; // M218: Set a tool offset
#endif

View File

@ -165,6 +165,7 @@
* M209 - Turn Automatic Retract Detection on/off: S<0|1> (For slicers that don't support G10/11). (Requires FWRETRACT_AUTORETRACT)
Every normal extrude-only move will be classified as retract depending on the direction.
* M211 - Enable, Disable, and/or Report software endstops: S<0|1> (Requires MIN_SOFTWARE_ENDSTOPS or MAX_SOFTWARE_ENDSTOPS)
* M217 - Set filament swap parameters: "M217 S<length> P<feedrate> R<feedrate>". (Requires SINGLENOZZLE)
* M218 - Set/get a tool offset: "M218 T<index> X<offset> Y<offset>". (Requires 2 or more extruders)
* M220 - Set Feedrate Percentage: "M220 S<percent>" (i.e., "FR" on the LCD)
* M221 - Set Flow Percentage: "M221 S<percent>"
@ -617,6 +618,10 @@ private:
static void M211();
#if ENABLED(SINGLENOZZLE)
static void M217();
#endif
#if HOTENDS > 1
static void M218();
#endif

View File

@ -35,6 +35,10 @@
#include "../../feature/leds/leds.h"
#endif
#if ENABLED(SINGLENOZZLE)
#include "../../module/tool_change.h"
#endif
/**
* M104: Set hot end temperature
*/
@ -44,12 +48,12 @@ void GcodeSuite::M104() {
const uint8_t e = target_extruder;
#if ENABLED(SINGLENOZZLE)
if (e != active_extruder) return;
#endif
if (parser.seenval('S')) {
const int16_t temp = parser.value_celsius();
#if ENABLED(SINGLENOZZLE)
singlenozzle_temp[e] = temp;
if (e != active_extruder) return;
#endif
thermalManager.setTargetHotend(temp, e);
#if ENABLED(DUAL_X_CARRIAGE)
@ -85,14 +89,14 @@ void GcodeSuite::M109() {
if (get_target_extruder_from_command()) return;
if (DEBUGGING(DRYRUN)) return;
#if ENABLED(SINGLENOZZLE)
if (target_extruder != active_extruder) return;
#endif
const bool no_wait_for_cooling = parser.seenval('S'),
set_temp = no_wait_for_cooling || parser.seenval('R');
if (set_temp) {
const int16_t temp = parser.value_celsius();
#if ENABLED(SINGLENOZZLE)
singlenozzle_temp[target_extruder] = temp;
if (target_extruder != active_extruder) return;
#endif
thermalManager.setTargetHotend(temp, target_extruder);
#if ENABLED(DUAL_X_CARRIAGE)
@ -115,13 +119,8 @@ void GcodeSuite::M109() {
#endif
#if ENABLED(ULTRA_LCD)
const bool heating = thermalManager.isHeatingHotend(target_extruder);
if (heating || !no_wait_for_cooling)
#if HOTENDS > 1
lcd_status_printf_P(0, heating ? PSTR("E%i " MSG_HEATING) : PSTR("E%i " MSG_COOLING), target_extruder + 1);
#else
lcd_setstatusPGM(heating ? PSTR("E " MSG_HEATING) : PSTR("E " MSG_COOLING));
#endif
if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling)
thermalManager.set_heating_message(target_extruder);
#endif
}

View File

@ -27,6 +27,11 @@
#include "../gcode.h"
#include "../../Marlin.h" // for fan_speed — should move those to Planner
#if ENABLED(SINGLENOZZLE)
#include "../../module/motion.h"
#include "../../module/tool_change.h"
#endif
/**
* M106: Set Fan Speed
*
@ -42,6 +47,15 @@
*/
void GcodeSuite::M106() {
const uint8_t p = parser.byteval('P');
const uint16_t s = parser.ushortval('S', 255);
#if ENABLED(SINGLENOZZLE)
if (p != active_extruder) {
if (p < EXTRUDERS) singlenozzle_fan_speed[p] = MIN(s, 255U);
return;
}
#endif
if (p < FAN_COUNT) {
#if ENABLED(EXTRA_FAN_SPEED)
const int16_t t = parser.intval('T');
@ -55,14 +69,12 @@ void GcodeSuite::M106() {
fan_speed[p] = new_fan_speed[p];
break;
default:
new_fan_speed[p] = MIN(t, 255);
new_fan_speed[p] = MIN(t, 255U);
break;
}
return;
}
#endif // EXTRA_FAN_SPEED
const uint16_t s = parser.ushortval('S', 255);
fan_speed[p] = MIN(s, 255U);
}
}
@ -72,6 +84,13 @@ void GcodeSuite::M106() {
*/
void GcodeSuite::M107() {
const uint16_t p = parser.ushortval('P');
#if ENABLED(SINGLENOZZLE)
if (p != active_extruder) {
if (p < EXTRUDERS) singlenozzle_fan_speed[p] = 0;
return;
}
#endif
if (p < FAN_COUNT) fan_speed[p] = 0;
}