Followup fixes for singlenozzle, etc. (#17712)

This commit is contained in:
studiodyne 2020-04-28 07:21:23 +02:00 committed by GitHub
parent 4f003fc7a7
commit 89b17b5463
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 61 additions and 34 deletions

View file

@ -150,6 +150,13 @@
// For Cyclops or any "multi-extruder" that shares a single nozzle. // For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE //#define SINGLENOZZLE
// Save and restore temperature and fan speed on tool-change.
// Set standby for the unselected tool with M104/106/109 T...
#if ENABLED(SINGLENOZZLE)
//#define SINGLENOZZLE_STANDBY_TEMP
//#define SINGLENOZZLE_STANDBY_FAN
#endif
/** /**
* Průša MK2 Single Nozzle Multi-Material Multiplexer, and variants. * Průša MK2 Single Nozzle Multi-Material Multiplexer, and variants.
* *

View file

@ -1889,7 +1889,7 @@
// (May break filament if not retracted beforehand.) // (May break filament if not retracted beforehand.)
//#define TOOLCHANGE_FS_INIT_BEFORE_SWAP //#define TOOLCHANGE_FS_INIT_BEFORE_SWAP
// Prime on the first T command even if the same or no toolchange / swap // Prime on the first T0 (If other, TOOLCHANGE_FS_INIT_BEFORE_SWAP applied)
// Enable it (M217 V[0/1]) before printing, to avoid unwanted priming on host connect // Enable it (M217 V[0/1]) before printing, to avoid unwanted priming on host connect
//#define TOOLCHANGE_FS_PRIME_FIRST_USED //#define TOOLCHANGE_FS_PRIME_FIRST_USED

View file

@ -65,7 +65,7 @@ void GcodeSuite::M104() {
if (parser.seenval('S')) { if (parser.seenval('S')) {
const int16_t temp = parser.value_celsius(); const int16_t temp = parser.value_celsius();
#if ENABLED(SINGLENOZZLE) #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
singlenozzle_temp[target_extruder] = temp; singlenozzle_temp[target_extruder] = temp;
if (target_extruder != active_extruder) return; if (target_extruder != active_extruder) return;
#endif #endif
@ -111,7 +111,7 @@ void GcodeSuite::M109() {
set_temp = no_wait_for_cooling || parser.seenval('R'); set_temp = no_wait_for_cooling || parser.seenval('R');
if (set_temp) { if (set_temp) {
const int16_t temp = parser.value_celsius(); const int16_t temp = parser.value_celsius();
#if ENABLED(SINGLENOZZLE) #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
singlenozzle_temp[target_extruder] = temp; singlenozzle_temp[target_extruder] = temp;
if (target_extruder != active_extruder) return; if (target_extruder != active_extruder) return;
#endif #endif

View file

@ -168,8 +168,9 @@ void menu_temperature() {
EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); });
#endif #endif
#if ENABLED(SINGLENOZZLE) #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
EDIT_ITEM_FAST(uint16_3, MSG_NOZZLE_STANDBY, &singlenozzle_temp[active_extruder ? 0 : 1], 0, HEATER_0_MAXTEMP - HOTEND_OVERSHOOT); LOOP_S_L_N(e, 1, EXTRUDERS)
EDIT_ITEM_FAST_N(uint16_3, e, MSG_NOZZLE_STANDBY, &singlenozzle_temp[e], 0, thermalManager.heater_maxtemp[0] - HOTEND_OVERSHOOT);
#endif #endif
// //
@ -207,11 +208,11 @@ void menu_temperature() {
}; };
#endif #endif
#define SNFAN(N) (ENABLED(SINGLENOZZLE) && !HAS_FAN##N && EXTRUDERS > N) #define SNFAN(N) (ENABLED(SINGLENOZZLE_STANDBY_FAN) && !HAS_FAN##N && EXTRUDERS > N)
#if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7) #if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
auto singlenozzle_item = [&](const uint8_t f) { auto singlenozzle_item = [&](const uint8_t f) {
MENU_ITEM_IF(1) { MENU_ITEM_IF(1) {
editable.uint8 = thermalManager.fan_speed[f]; editable.uint8 = singlenozzle_fan_speed[f];
EDIT_ITEM_FAST_N(percent, f, MSG_STORED_FAN_N, &editable.uint8, 0, 255, on_fan_update); EDIT_ITEM_FAST_N(percent, f, MSG_STORED_FAN_N, &editable.uint8, 0, 255, on_fan_update);
} }
}; };

View file

@ -124,8 +124,9 @@ void menu_tune() {
EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); });
#endif #endif
#if ENABLED(SINGLENOZZLE) #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
EDIT_ITEM_FAST(uint16_3, MSG_NOZZLE_STANDBY, &singlenozzle_temp[active_extruder ? 0 : 1], 0, HEATER_0_MAXTEMP - HOTEND_OVERSHOOT); LOOP_S_L_N(e, 1, EXTRUDERS)
EDIT_ITEM_FAST_N(uint16_3, e, MSG_NOZZLE_STANDBY, &singlenozzle_temp[e], 0, thermalManager.heater_maxtemp[0] - HOTEND_OVERSHOOT);
#endif #endif
// //
@ -156,11 +157,11 @@ void menu_tune() {
}; };
#endif #endif
#define SNFAN(N) (ENABLED(SINGLENOZZLE) && !HAS_FAN##N && EXTRUDERS > N) #define SNFAN(N) (ENABLED(SINGLENOZZLE_STANDBY_FAN) && !HAS_FAN##N && EXTRUDERS > N)
#if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7) #if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
auto singlenozzle_item = [&](const uint8_t f) { auto singlenozzle_item = [&](const uint8_t f) {
MENU_ITEM_IF(1) { MENU_ITEM_IF(1) {
editable.uint8 = thermalManager.fan_speed[f]; editable.uint8 = singlenozzle_fan_speed[f];
EDIT_ITEM_FAST_N(percent, f, MSG_STORED_FAN_N, &editable.uint8, 0, 255, on_fan_update); EDIT_ITEM_FAST_N(percent, f, MSG_STORED_FAN_N, &editable.uint8, 0, 255, on_fan_update);
} }
}; };

View file

@ -2861,6 +2861,17 @@ void Planner::set_max_jerk(const AxisEnum axis, float targetValue) {
#if ENABLED(AUTOTEMP) #if ENABLED(AUTOTEMP)
void Planner::autotemp_update() {
#if ENABLED(AUTOTEMP_PROPORTIONAL)
const int16_t target = thermalManager.degTargetHotend(active_extruder);
autotemp_min = target + AUTOTEMP_MIN_P;
autotemp_max = target + AUTOTEMP_MAX_P;
#endif
autotemp_factor = TERN(AUTOTEMP_PROPORTIONAL, AUTOTEMP_FACTOR_P, 0);
autotemp_enabled = autotemp_factor != 0;
}
void Planner::autotemp_M104_M109() { void Planner::autotemp_M104_M109() {
#if ENABLED(AUTOTEMP_PROPORTIONAL) #if ENABLED(AUTOTEMP_PROPORTIONAL)

View file

@ -824,6 +824,7 @@ class Planner {
static bool autotemp_enabled; static bool autotemp_enabled;
static void getHighESpeed(); static void getHighESpeed();
static void autotemp_M104_M109(); static void autotemp_M104_M109();
static void autotemp_update();
#endif #endif
#if HAS_LINEAR_E_JERK #if HAS_LINEAR_E_JERK

View file

@ -193,7 +193,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
NOMORE(speed, 255U); NOMORE(speed, 255U);
#if ENABLED(SINGLENOZZLE) #if ENABLED(SINGLENOZZLE_STANDBY_FAN)
if (target != active_extruder) { if (target != active_extruder) {
if (target < EXTRUDERS) singlenozzle_fan_speed[target] = speed; if (target < EXTRUDERS) singlenozzle_fan_speed[target] = speed;
return; return;

View file

@ -47,11 +47,12 @@
bool toolchange_extruder_ready[EXTRUDERS]; bool toolchange_extruder_ready[EXTRUDERS];
#endif #endif
#if ENABLED(SINGLENOZZLE) #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
uint16_t singlenozzle_temp[EXTRUDERS]; uint16_t singlenozzle_temp[EXTRUDERS];
#if HAS_FAN #endif
uint8_t singlenozzle_fan_speed[EXTRUDERS];
#endif #if BOTH(HAS_FAN, SINGLENOZZLE_STANDBY_FAN)
uint8_t singlenozzle_fan_speed[EXTRUDERS];
#endif #endif
#if ENABLED(MAGNETIC_PARKING_EXTRUDER) || defined(EVENT_GCODE_AFTER_TOOLCHANGE) || (ENABLED(PARKING_EXTRUDER) && PARKING_EXTRUDER_SOLENOIDS_DELAY > 0) #if ENABLED(MAGNETIC_PARKING_EXTRUDER) || defined(EVENT_GCODE_AFTER_TOOLCHANGE) || (ENABLED(PARKING_EXTRUDER) && PARKING_EXTRUDER_SOLENOIDS_DELAY > 0)
@ -822,7 +823,7 @@ void tool_change_prime() {
#if TOOLCHANGE_FS_FAN >= 0 && HAS_FAN #if TOOLCHANGE_FS_FAN >= 0 && HAS_FAN
const int16_t fansp = thermalManager.fan_speed[TOOLCHANGE_FS_FAN]; const int16_t fansp = thermalManager.fan_speed[TOOLCHANGE_FS_FAN];
thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = toolchange_settings.fan_speed; thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = toolchange_settings.fan_speed;
safe_delay(toolchange_settings.fan_time * 1000); gcode.dwell(toolchange_settings.fan_time * 1000);
thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = fansp; thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = fansp;
#endif #endif
@ -934,7 +935,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
// Z raise before retraction // Z raise before retraction
#if ENABLED(TOOLCHANGE_ZRAISE_BEFORE_RETRACT) && DISABLED(SWITCHING_NOZZLE) #if ENABLED(TOOLCHANGE_ZRAISE_BEFORE_RETRACT) && DISABLED(SWITCHING_NOZZLE)
if (can_move_away && TERN1(toolchange_settings.enable_park)) { if (can_move_away && TERN1(TOOLCHANGE_PARK, toolchange_settings.enable_park)) {
// Do a small lift to avoid the workpiece in the move back (below) // Do a small lift to avoid the workpiece in the move back (below)
current_position.z += toolchange_settings.z_raise; current_position.z += toolchange_settings.z_raise;
#if HAS_SOFTWARE_ENDSTOPS #if HAS_SOFTWARE_ENDSTOPS
@ -956,8 +957,12 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
SERIAL_ECHO_MSG(STR_ERR_HOTEND_TOO_COLD); SERIAL_ECHO_MSG(STR_ERR_HOTEND_TOO_COLD);
if (ENABLED(SINGLENOZZLE)) { active_extruder = new_tool; return; } if (ENABLED(SINGLENOZZLE)) { active_extruder = new_tool; return; }
} }
else else {
unscaled_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed)); // If first new tool, toolchange without unloading the old not initialized 'Just prime/init the new'
if (first_tool_is_primed)
unscaled_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed));
first_tool_is_primed = true; // The first new tool will be primed by toolchanging
}
} }
#endif #endif
@ -1059,15 +1064,16 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
const bool should_move = safe_to_move && !no_move && IsRunning(); const bool should_move = safe_to_move && !no_move && IsRunning();
if (should_move) { if (should_move) {
#if ENABLED(SINGLENOZZLE) #if BOTH(HAS_FAN, SINGLENOZZLE_STANDBY_FAN)
#if HAS_FAN singlenozzle_fan_speed[old_tool] = thermalManager.fan_speed[0];
singlenozzle_fan_speed[old_tool] = thermalManager.fan_speed[0]; thermalManager.fan_speed[0] = singlenozzle_fan_speed[new_tool];
thermalManager.fan_speed[0] = singlenozzle_fan_speed[new_tool]; #endif
#endif
#if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
singlenozzle_temp[old_tool] = thermalManager.temp_hotend[0].target; singlenozzle_temp[old_tool] = thermalManager.temp_hotend[0].target;
if (singlenozzle_temp[new_tool] && singlenozzle_temp[new_tool] != singlenozzle_temp[old_tool]) { if (singlenozzle_temp[new_tool] && singlenozzle_temp[new_tool] != singlenozzle_temp[old_tool]) {
thermalManager.setTargetHotend(singlenozzle_temp[new_tool], 0); thermalManager.setTargetHotend(singlenozzle_temp[new_tool], 0);
TERN_(AUTOTEMP, planner.autotemp_update());
TERN_(HAS_DISPLAY, thermalManager.set_heating_message(0)); TERN_(HAS_DISPLAY, thermalManager.set_heating_message(0));
(void)thermalManager.wait_for_hotend(0, false); // Wait for heating or cooling (void)thermalManager.wait_for_hotend(0, false); // Wait for heating or cooling
} }
@ -1101,7 +1107,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
#if TOOLCHANGE_FS_FAN >= 0 && HAS_FAN #if TOOLCHANGE_FS_FAN >= 0 && HAS_FAN
const int16_t fansp = thermalManager.fan_speed[TOOLCHANGE_FS_FAN]; const int16_t fansp = thermalManager.fan_speed[TOOLCHANGE_FS_FAN];
thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = toolchange_settings.fan_speed; thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = toolchange_settings.fan_speed;
safe_delay(toolchange_settings.fan_time * 1000); gcode.dwell(toolchange_settings.fan_time * 1000);
thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = fansp; thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = fansp;
#endif #endif
} }
@ -1245,10 +1251,9 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
// Migrate the temperature to the new hotend // Migrate the temperature to the new hotend
#if HAS_MULTI_HOTEND #if HAS_MULTI_HOTEND
thermalManager.setTargetHotend(thermalManager.degTargetHotend(active_extruder), migration_extruder); thermalManager.setTargetHotend(thermalManager.temp_hotend[active_extruder].target, migration_extruder);
#if HAS_DISPLAY TERN_(AUTOTEMP, planner.autotemp_update());
thermalManager.set_heating_message(0); TERN_(HAS_DISPLAY, thermalManager.set_heating_message(0));
#endif
thermalManager.wait_for_hotend(active_extruder); thermalManager.wait_for_hotend(active_extruder);
#endif #endif

View file

@ -108,11 +108,12 @@
#endif #endif
#if ENABLED(SINGLENOZZLE) #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
extern uint16_t singlenozzle_temp[EXTRUDERS]; extern uint16_t singlenozzle_temp[EXTRUDERS];
#if HAS_FAN #endif
extern uint8_t singlenozzle_fan_speed[EXTRUDERS];
#endif #if BOTH(HAS_FAN, SINGLENOZZLE_STANDBY_FAN)
extern uint8_t singlenozzle_fan_speed[EXTRUDERS];
#endif #endif
TERN_(ELECTROMAGNETIC_SWITCHING_TOOLHEAD, void est_init()); TERN_(ELECTROMAGNETIC_SWITCHING_TOOLHEAD, void est_init());