Initial split-up of G-code handlers by category
This commit is contained in:
63
Marlin/src/gcode/temperature/M104.h
Normal file
63
Marlin/src/gcode/temperature/M104.h
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M104: Set hot end temperature
|
||||
*/
|
||||
void gcode_M104() {
|
||||
if (get_target_extruder_from_command(104)) return;
|
||||
if (DEBUGGING(DRYRUN)) return;
|
||||
|
||||
#if ENABLED(SINGLENOZZLE)
|
||||
if (target_extruder != active_extruder) return;
|
||||
#endif
|
||||
|
||||
if (parser.seenval('S')) {
|
||||
const int16_t temp = parser.value_celsius();
|
||||
thermalManager.setTargetHotend(temp, target_extruder);
|
||||
|
||||
#if ENABLED(DUAL_X_CARRIAGE)
|
||||
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
|
||||
thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1);
|
||||
#endif
|
||||
|
||||
#if ENABLED(PRINTJOB_TIMER_AUTOSTART)
|
||||
/**
|
||||
* Stop the timer at the end of print. Start is managed by 'heat and wait' M109.
|
||||
* We use half EXTRUDE_MINTEMP here to allow nozzles to be put into hot
|
||||
* standby mode, for instance in a dual extruder setup, without affecting
|
||||
* the running print timer.
|
||||
*/
|
||||
if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) {
|
||||
print_job_timer.stop();
|
||||
LCD_MESSAGEPGM(WELCOME_MSG);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (parser.value_celsius() > thermalManager.degHotend(target_extruder))
|
||||
lcd_status_printf_P(0, PSTR("E%i %s"), target_extruder + 1, MSG_HEATING);
|
||||
}
|
||||
|
||||
#if ENABLED(AUTOTEMP)
|
||||
planner.autotemp_M104_M109();
|
||||
#endif
|
||||
}
|
38
Marlin/src/gcode/temperature/M105.h
Normal file
38
Marlin/src/gcode/temperature/M105.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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M105: Read hot end and bed temperature
|
||||
*/
|
||||
void gcode_M105() {
|
||||
if (get_target_extruder_from_command(105)) return;
|
||||
|
||||
#if HAS_TEMP_HOTEND || HAS_TEMP_BED
|
||||
SERIAL_PROTOCOLPGM(MSG_OK);
|
||||
print_heaterstates();
|
||||
#else // !HAS_TEMP_HOTEND && !HAS_TEMP_BED
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS);
|
||||
#endif
|
||||
|
||||
SERIAL_EOL();
|
||||
}
|
34
Marlin/src/gcode/temperature/M106.h
Normal file
34
Marlin/src/gcode/temperature/M106.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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M106: Set Fan Speed
|
||||
*
|
||||
* S<int> Speed between 0-255
|
||||
* P<index> Fan index, if more than one fan
|
||||
*/
|
||||
void gcode_M106() {
|
||||
uint16_t s = parser.ushortval('S', 255);
|
||||
NOMORE(s, 255);
|
||||
const uint8_t p = parser.byteval('P', 0);
|
||||
if (p < FAN_COUNT) fanSpeeds[p] = s;
|
||||
}
|
29
Marlin/src/gcode/temperature/M107.h
Normal file
29
Marlin/src/gcode/temperature/M107.h
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M107: Fan Off
|
||||
*/
|
||||
void gcode_M107() {
|
||||
const uint16_t p = parser.ushortval('P');
|
||||
if (p < FAN_COUNT) fanSpeeds[p] = 0;
|
||||
}
|
185
Marlin/src/gcode/temperature/M109.h
Normal file
185
Marlin/src/gcode/temperature/M109.h
Normal file
@ -0,0 +1,185 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M109: Sxxx Wait for extruder(s) to reach temperature. Waits only when heating.
|
||||
* Rxxx Wait for extruder(s) to reach temperature. Waits when heating and cooling.
|
||||
*/
|
||||
|
||||
#ifndef MIN_COOLING_SLOPE_DEG
|
||||
#define MIN_COOLING_SLOPE_DEG 1.50
|
||||
#endif
|
||||
#ifndef MIN_COOLING_SLOPE_TIME
|
||||
#define MIN_COOLING_SLOPE_TIME 60
|
||||
#endif
|
||||
|
||||
void gcode_M109() {
|
||||
|
||||
if (get_target_extruder_from_command(109)) return;
|
||||
if (DEBUGGING(DRYRUN)) return;
|
||||
|
||||
#if ENABLED(SINGLENOZZLE)
|
||||
if (target_extruder != active_extruder) return;
|
||||
#endif
|
||||
|
||||
const bool no_wait_for_cooling = parser.seenval('S');
|
||||
if (no_wait_for_cooling || parser.seenval('R')) {
|
||||
const int16_t temp = parser.value_celsius();
|
||||
thermalManager.setTargetHotend(temp, target_extruder);
|
||||
|
||||
#if ENABLED(DUAL_X_CARRIAGE)
|
||||
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
|
||||
thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1);
|
||||
#endif
|
||||
|
||||
#if ENABLED(PRINTJOB_TIMER_AUTOSTART)
|
||||
/**
|
||||
* Use half EXTRUDE_MINTEMP to allow nozzles to be put into hot
|
||||
* standby mode, (e.g., in a dual extruder setup) without affecting
|
||||
* the running print timer.
|
||||
*/
|
||||
if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) {
|
||||
print_job_timer.stop();
|
||||
LCD_MESSAGEPGM(WELCOME_MSG);
|
||||
}
|
||||
else
|
||||
print_job_timer.start();
|
||||
#endif
|
||||
|
||||
if (thermalManager.isHeatingHotend(target_extruder)) lcd_status_printf_P(0, PSTR("E%i %s"), target_extruder + 1, MSG_HEATING);
|
||||
}
|
||||
else return;
|
||||
|
||||
#if ENABLED(AUTOTEMP)
|
||||
planner.autotemp_M104_M109();
|
||||
#endif
|
||||
|
||||
#if TEMP_RESIDENCY_TIME > 0
|
||||
millis_t residency_start_ms = 0;
|
||||
// Loop until the temperature has stabilized
|
||||
#define TEMP_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_RESIDENCY_TIME) * 1000UL))
|
||||
#else
|
||||
// Loop until the temperature is very close target
|
||||
#define TEMP_CONDITIONS (wants_to_cool ? thermalManager.isCoolingHotend(target_extruder) : thermalManager.isHeatingHotend(target_extruder))
|
||||
#endif
|
||||
|
||||
float target_temp = -1.0, old_temp = 9999.0;
|
||||
bool wants_to_cool = false;
|
||||
wait_for_heatup = true;
|
||||
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
|
||||
|
||||
#if DISABLED(BUSY_WHILE_HEATING)
|
||||
KEEPALIVE_STATE(NOT_BUSY);
|
||||
#endif
|
||||
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
const float start_temp = thermalManager.degHotend(target_extruder);
|
||||
uint8_t old_blue = 0;
|
||||
#endif
|
||||
|
||||
do {
|
||||
// Target temperature might be changed during the loop
|
||||
if (target_temp != thermalManager.degTargetHotend(target_extruder)) {
|
||||
wants_to_cool = thermalManager.isCoolingHotend(target_extruder);
|
||||
target_temp = thermalManager.degTargetHotend(target_extruder);
|
||||
|
||||
// Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
|
||||
if (no_wait_for_cooling && wants_to_cool) break;
|
||||
}
|
||||
|
||||
now = millis();
|
||||
if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
|
||||
next_temp_ms = now + 1000UL;
|
||||
print_heaterstates();
|
||||
#if TEMP_RESIDENCY_TIME > 0
|
||||
SERIAL_PROTOCOLPGM(" W:");
|
||||
if (residency_start_ms)
|
||||
SERIAL_PROTOCOL(long((((TEMP_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL));
|
||||
else
|
||||
SERIAL_PROTOCOLCHAR('?');
|
||||
#endif
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
||||
idle();
|
||||
refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
|
||||
|
||||
const float temp = thermalManager.degHotend(target_extruder);
|
||||
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
// Gradually change LED strip from violet to red as nozzle heats up
|
||||
if (!wants_to_cool) {
|
||||
const uint8_t blue = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 255, 0);
|
||||
if (blue != old_blue) {
|
||||
old_blue = blue;
|
||||
set_led_color(255, 0, blue
|
||||
#if ENABLED(NEOPIXEL_RGBW_LED)
|
||||
, 0, true
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TEMP_RESIDENCY_TIME > 0
|
||||
|
||||
const float temp_diff = FABS(target_temp - temp);
|
||||
|
||||
if (!residency_start_ms) {
|
||||
// Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
|
||||
if (temp_diff < TEMP_WINDOW) residency_start_ms = now;
|
||||
}
|
||||
else if (temp_diff > TEMP_HYSTERESIS) {
|
||||
// Restart the timer whenever the temperature falls outside the hysteresis.
|
||||
residency_start_ms = now;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Prevent a wait-forever situation if R is misused i.e. M109 R0
|
||||
if (wants_to_cool) {
|
||||
// break after MIN_COOLING_SLOPE_TIME seconds
|
||||
// if the temperature did not drop at least MIN_COOLING_SLOPE_DEG
|
||||
if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
|
||||
if (old_temp - temp < MIN_COOLING_SLOPE_DEG) break;
|
||||
next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME;
|
||||
old_temp = temp;
|
||||
}
|
||||
}
|
||||
|
||||
} while (wait_for_heatup && TEMP_CONDITIONS);
|
||||
|
||||
if (wait_for_heatup) {
|
||||
LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
#if ENABLED(RGBW_LED) || ENABLED(NEOPIXEL_RGBW_LED)
|
||||
set_led_color(0, 0, 0, 255); // Turn on the WHITE LED
|
||||
#else
|
||||
set_led_color(255, 255, 255); // Set LEDs All On
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#if DISABLED(BUSY_WHILE_HEATING)
|
||||
KEEPALIVE_STATE(IN_HANDLER);
|
||||
#endif
|
||||
}
|
29
Marlin/src/gcode/temperature/M140.h
Normal file
29
Marlin/src/gcode/temperature/M140.h
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M140: Set bed temperature
|
||||
*/
|
||||
void gcode_M140() {
|
||||
if (DEBUGGING(DRYRUN)) return;
|
||||
if (parser.seenval('S')) thermalManager.setTargetBed(parser.value_celsius());
|
||||
}
|
32
Marlin/src/gcode/temperature/M155.h
Normal file
32
Marlin/src/gcode/temperature/M155.h
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M155: Set temperature auto-report interval. M155 S<seconds>
|
||||
*/
|
||||
void gcode_M155() {
|
||||
if (parser.seenval('S')) {
|
||||
auto_report_temp_interval = parser.value_byte();
|
||||
NOMORE(auto_report_temp_interval, 60);
|
||||
next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval;
|
||||
}
|
||||
}
|
149
Marlin/src/gcode/temperature/M190.h
Normal file
149
Marlin/src/gcode/temperature/M190.h
Normal file
@ -0,0 +1,149 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MIN_COOLING_SLOPE_DEG_BED
|
||||
#define MIN_COOLING_SLOPE_DEG_BED 1.50
|
||||
#endif
|
||||
#ifndef MIN_COOLING_SLOPE_TIME_BED
|
||||
#define MIN_COOLING_SLOPE_TIME_BED 60
|
||||
#endif
|
||||
|
||||
/**
|
||||
* M190: Sxxx Wait for bed current temp to reach target temp. Waits only when heating
|
||||
* Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
|
||||
*/
|
||||
void gcode_M190() {
|
||||
if (DEBUGGING(DRYRUN)) return;
|
||||
|
||||
LCD_MESSAGEPGM(MSG_BED_HEATING);
|
||||
const bool no_wait_for_cooling = parser.seenval('S');
|
||||
if (no_wait_for_cooling || parser.seenval('R')) {
|
||||
thermalManager.setTargetBed(parser.value_celsius());
|
||||
#if ENABLED(PRINTJOB_TIMER_AUTOSTART)
|
||||
if (parser.value_celsius() > BED_MINTEMP)
|
||||
print_job_timer.start();
|
||||
#endif
|
||||
}
|
||||
else return;
|
||||
|
||||
#if TEMP_BED_RESIDENCY_TIME > 0
|
||||
millis_t residency_start_ms = 0;
|
||||
// Loop until the temperature has stabilized
|
||||
#define TEMP_BED_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_BED_RESIDENCY_TIME) * 1000UL))
|
||||
#else
|
||||
// Loop until the temperature is very close target
|
||||
#define TEMP_BED_CONDITIONS (wants_to_cool ? thermalManager.isCoolingBed() : thermalManager.isHeatingBed())
|
||||
#endif
|
||||
|
||||
float target_temp = -1.0, old_temp = 9999.0;
|
||||
bool wants_to_cool = false;
|
||||
wait_for_heatup = true;
|
||||
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
|
||||
|
||||
#if DISABLED(BUSY_WHILE_HEATING)
|
||||
KEEPALIVE_STATE(NOT_BUSY);
|
||||
#endif
|
||||
|
||||
target_extruder = active_extruder; // for print_heaterstates
|
||||
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
const float start_temp = thermalManager.degBed();
|
||||
uint8_t old_red = 255;
|
||||
#endif
|
||||
|
||||
do {
|
||||
// Target temperature might be changed during the loop
|
||||
if (target_temp != thermalManager.degTargetBed()) {
|
||||
wants_to_cool = thermalManager.isCoolingBed();
|
||||
target_temp = thermalManager.degTargetBed();
|
||||
|
||||
// Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
|
||||
if (no_wait_for_cooling && wants_to_cool) break;
|
||||
}
|
||||
|
||||
now = millis();
|
||||
if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
|
||||
next_temp_ms = now + 1000UL;
|
||||
print_heaterstates();
|
||||
#if TEMP_BED_RESIDENCY_TIME > 0
|
||||
SERIAL_PROTOCOLPGM(" W:");
|
||||
if (residency_start_ms)
|
||||
SERIAL_PROTOCOL(long((((TEMP_BED_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL));
|
||||
else
|
||||
SERIAL_PROTOCOLCHAR('?');
|
||||
#endif
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
||||
idle();
|
||||
refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
|
||||
|
||||
const float temp = thermalManager.degBed();
|
||||
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
// Gradually change LED strip from blue to violet as bed heats up
|
||||
if (!wants_to_cool) {
|
||||
const uint8_t red = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 0, 255);
|
||||
if (red != old_red) {
|
||||
old_red = red;
|
||||
set_led_color(red, 0, 255
|
||||
#if ENABLED(NEOPIXEL_RGBW_LED)
|
||||
, 0, true
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TEMP_BED_RESIDENCY_TIME > 0
|
||||
|
||||
const float temp_diff = FABS(target_temp - temp);
|
||||
|
||||
if (!residency_start_ms) {
|
||||
// Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
|
||||
if (temp_diff < TEMP_BED_WINDOW) residency_start_ms = now;
|
||||
}
|
||||
else if (temp_diff > TEMP_BED_HYSTERESIS) {
|
||||
// Restart the timer whenever the temperature falls outside the hysteresis.
|
||||
residency_start_ms = now;
|
||||
}
|
||||
|
||||
#endif // TEMP_BED_RESIDENCY_TIME > 0
|
||||
|
||||
// Prevent a wait-forever situation if R is misused i.e. M190 R0
|
||||
if (wants_to_cool) {
|
||||
// Break after MIN_COOLING_SLOPE_TIME_BED seconds
|
||||
// if the temperature did not drop at least MIN_COOLING_SLOPE_DEG_BED
|
||||
if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
|
||||
if (old_temp - temp < MIN_COOLING_SLOPE_DEG_BED) break;
|
||||
next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME_BED;
|
||||
old_temp = temp;
|
||||
}
|
||||
}
|
||||
|
||||
} while (wait_for_heatup && TEMP_BED_CONDITIONS);
|
||||
|
||||
if (wait_for_heatup) LCD_MESSAGEPGM(MSG_BED_DONE);
|
||||
#if DISABLED(BUSY_WHILE_HEATING)
|
||||
KEEPALIVE_STATE(IN_HANDLER);
|
||||
#endif
|
||||
}
|
54
Marlin/src/gcode/temperature/M303.h
Normal file
54
Marlin/src/gcode/temperature/M303.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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M303: PID relay autotune
|
||||
*
|
||||
* S<temperature> sets the target temperature. (default 150C)
|
||||
* E<extruder> (-1 for the bed) (default 0)
|
||||
* C<cycles>
|
||||
* U<bool> with a non-zero value will apply the result to current settings
|
||||
*/
|
||||
void gcode_M303() {
|
||||
#if HAS_PID_HEATING
|
||||
const int e = parser.intval('E'), c = parser.intval('C', 5);
|
||||
const bool u = parser.boolval('U');
|
||||
|
||||
int16_t temp = parser.celsiusval('S', e < 0 ? 70 : 150);
|
||||
|
||||
if (WITHIN(e, 0, HOTENDS - 1))
|
||||
target_extruder = e;
|
||||
|
||||
#if DISABLED(BUSY_WHILE_HEATING)
|
||||
KEEPALIVE_STATE(NOT_BUSY);
|
||||
#endif
|
||||
|
||||
thermalManager.PID_autotune(temp, e, c, u);
|
||||
|
||||
#if DISABLED(BUSY_WHILE_HEATING)
|
||||
KEEPALIVE_STATE(IN_HANDLER);
|
||||
#endif
|
||||
#else
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ERRORLNPGM(MSG_ERR_M303_DISABLED);
|
||||
#endif
|
||||
}
|
Reference in New Issue
Block a user