2017-09-06 06:28:31 -05:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 08:00:57 -06:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-06 06:28:31 -05:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-27 23:57:50 -05:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-06 06:28:31 -05:00
|
|
|
*
|
|
|
|
* 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
|
2020-07-22 22:20:14 -05:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2017-09-06 06:28:31 -05:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-01-30 03:24:43 -06:00
|
|
|
/**
|
2020-03-13 16:29:29 -05:00
|
|
|
* gcode/temp/M104_M109.cpp
|
2020-01-30 03:24:43 -06:00
|
|
|
*
|
|
|
|
* Hotend target temperature control
|
|
|
|
*/
|
|
|
|
|
2019-09-10 02:20:49 -05:00
|
|
|
#include "../../inc/MarlinConfigPre.h"
|
|
|
|
|
|
|
|
#if EXTRUDERS
|
|
|
|
|
2017-09-07 22:33:16 -05:00
|
|
|
#include "../gcode.h"
|
|
|
|
#include "../../module/temperature.h"
|
2017-09-23 18:09:14 -05:00
|
|
|
#include "../../module/motion.h"
|
2017-09-07 22:33:16 -05:00
|
|
|
#include "../../module/planner.h"
|
|
|
|
#include "../../lcd/ultralcd.h"
|
2019-10-24 15:35:40 -05:00
|
|
|
|
2020-01-02 19:01:38 -06:00
|
|
|
#include "../../MarlinCore.h" // for startOrResumeJob, etc.
|
2017-09-07 22:33:16 -05:00
|
|
|
|
|
|
|
#if ENABLED(PRINTJOB_TIMER_AUTOSTART)
|
|
|
|
#include "../../module/printcounter.h"
|
2019-10-24 15:35:40 -05:00
|
|
|
#if ENABLED(CANCEL_OBJECTS)
|
|
|
|
#include "../../feature/cancel_object.h"
|
|
|
|
#endif
|
2017-09-07 22:33:16 -05:00
|
|
|
#endif
|
|
|
|
|
2018-10-07 17:06:14 -05:00
|
|
|
#if ENABLED(SINGLENOZZLE)
|
|
|
|
#include "../../module/tool_change.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-23 18:09:14 -05:00
|
|
|
/**
|
2020-07-09 03:11:57 -05:00
|
|
|
* M104: Set Hotend Temperature target and return immediately
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* I<preset> : Material Preset index (if material presets are defined)
|
|
|
|
* T<index> : Tool index. If omitted, applies to the active tool
|
|
|
|
* S<target> : The target temperature in current units
|
2017-09-23 18:09:14 -05:00
|
|
|
*/
|
|
|
|
void GcodeSuite::M104() {
|
2018-11-14 17:33:04 -06:00
|
|
|
|
2017-09-23 18:09:14 -05:00
|
|
|
if (DEBUGGING(DRYRUN)) return;
|
|
|
|
|
2018-11-14 17:33:04 -06:00
|
|
|
#if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
|
2018-11-17 06:55:25 -06:00
|
|
|
constexpr int8_t target_extruder = 0;
|
2018-11-14 17:33:04 -06:00
|
|
|
#else
|
2018-11-17 06:55:25 -06:00
|
|
|
const int8_t target_extruder = get_target_extruder_from_command();
|
|
|
|
if (target_extruder < 0) return;
|
2018-11-14 17:33:04 -06:00
|
|
|
#endif
|
2017-09-23 18:09:14 -05:00
|
|
|
|
2020-07-09 03:11:57 -05:00
|
|
|
bool got_temp = false;
|
|
|
|
int16_t temp = 0;
|
|
|
|
|
|
|
|
// Accept 'I' if temperature presets are defined
|
|
|
|
#if PREHEAT_COUNT
|
|
|
|
got_temp = parser.seenval('I');
|
|
|
|
if (got_temp) {
|
|
|
|
const uint8_t index = parser.value_byte();
|
|
|
|
temp = ui.material_preset[_MIN(index, PREHEAT_COUNT - 1)].hotend_temp;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// If no 'I' get the temperature from 'S'
|
|
|
|
if (!got_temp) {
|
|
|
|
got_temp = parser.seenval('S');
|
|
|
|
if (got_temp) temp = parser.value_celsius();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (got_temp) {
|
2020-04-28 00:21:23 -05:00
|
|
|
#if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
|
2018-11-17 06:55:25 -06:00
|
|
|
singlenozzle_temp[target_extruder] = temp;
|
|
|
|
if (target_extruder != active_extruder) return;
|
2018-10-07 17:06:14 -05:00
|
|
|
#endif
|
2018-11-17 06:55:25 -06:00
|
|
|
thermalManager.setTargetHotend(temp, target_extruder);
|
2017-09-23 18:09:14 -05:00
|
|
|
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
2020-10-16 16:59:55 -05:00
|
|
|
if (idex_is_duplicating() && target_extruder == 0)
|
2017-09-23 18:09:14 -05:00
|
|
|
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.
|
2020-01-30 03:24:43 -06:00
|
|
|
* Hotends use EXTRUDE_MINTEMP / 2 to allow nozzles to be put into hot standby
|
|
|
|
* mode, for instance in a dual extruder setup, without affecting the running
|
|
|
|
* print timer.
|
2017-09-23 18:09:14 -05:00
|
|
|
*/
|
2020-01-30 03:24:43 -06:00
|
|
|
thermalManager.check_timer_autostart(false, true);
|
2017-09-23 18:09:14 -05:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(AUTOTEMP, planner.autotemp_M104_M109());
|
2017-09-23 18:09:14 -05:00
|
|
|
}
|
|
|
|
|
2017-09-06 06:28:31 -05:00
|
|
|
/**
|
2020-07-09 03:11:57 -05:00
|
|
|
* M109: Set Hotend Temperature target and wait
|
|
|
|
*
|
|
|
|
* Parameters
|
|
|
|
* I<preset> : Material Preset index (if material presets are defined)
|
|
|
|
* T<index> : Tool index. If omitted, applies to the active tool
|
|
|
|
* S<target> : The target temperature in current units. Wait for heating only.
|
|
|
|
* R<target> : The target temperature in current units. Wait for heating and cooling.
|
2020-01-30 03:24:43 -06:00
|
|
|
*
|
2020-07-09 03:11:57 -05:00
|
|
|
* With AUTOTEMP...
|
|
|
|
* F<factor> : Autotemp Scaling Factor. Set non-zero to enable Auto-temp.
|
|
|
|
* S<min> : Minimum temperature, in current units.
|
|
|
|
* B<max> : Maximum temperature, in current units.
|
|
|
|
*
|
|
|
|
* Examples
|
|
|
|
* M109 S100 : Set target to 100°. Wait until the hotend is at or above 100°.
|
|
|
|
* M109 R150 : Set target to 150°. Wait until the hotend gets close to 150°.
|
|
|
|
*
|
|
|
|
* With PRINTJOB_TIMER_AUTOSTART turning on heaters will start the print job timer
|
|
|
|
* (used by printingIsActive, etc.) and turning off heaters will stop the timer.
|
2017-09-06 06:28:31 -05:00
|
|
|
*/
|
2017-09-07 22:33:16 -05:00
|
|
|
void GcodeSuite::M109() {
|
2017-09-06 06:28:31 -05:00
|
|
|
|
|
|
|
if (DEBUGGING(DRYRUN)) return;
|
|
|
|
|
2018-11-14 17:33:04 -06:00
|
|
|
#if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
|
|
|
|
constexpr int8_t target_extruder = 0;
|
|
|
|
#else
|
|
|
|
const int8_t target_extruder = get_target_extruder_from_command();
|
|
|
|
if (target_extruder < 0) return;
|
|
|
|
#endif
|
|
|
|
|
2020-07-09 03:11:57 -05:00
|
|
|
bool got_temp = false;
|
|
|
|
int16_t temp = 0;
|
|
|
|
|
|
|
|
// Accept 'I' if temperature presets are defined
|
|
|
|
#if PREHEAT_COUNT
|
|
|
|
got_temp = parser.seenval('I');
|
|
|
|
if (got_temp) {
|
|
|
|
const uint8_t index = parser.value_byte();
|
|
|
|
temp = ui.material_preset[_MIN(index, PREHEAT_COUNT - 1)].hotend_temp;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Get the temperature from 'S' or 'R'
|
|
|
|
bool no_wait_for_cooling = false;
|
|
|
|
if (!got_temp) {
|
|
|
|
no_wait_for_cooling = parser.seenval('S');
|
|
|
|
got_temp = no_wait_for_cooling || parser.seenval('R');
|
|
|
|
if (got_temp) temp = int16_t(parser.value_celsius());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (got_temp) {
|
2020-04-28 00:21:23 -05:00
|
|
|
#if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
|
2018-10-07 17:06:14 -05:00
|
|
|
singlenozzle_temp[target_extruder] = temp;
|
|
|
|
if (target_extruder != active_extruder) return;
|
|
|
|
#endif
|
2017-09-06 06:28:31 -05:00
|
|
|
thermalManager.setTargetHotend(temp, target_extruder);
|
|
|
|
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
2020-10-16 16:59:55 -05:00
|
|
|
if (idex_is_duplicating() && target_extruder == 0)
|
2017-09-06 06:28:31 -05:00
|
|
|
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.
|
|
|
|
*/
|
2020-01-30 03:24:43 -06:00
|
|
|
thermalManager.check_timer_autostart(true, true);
|
2017-09-06 06:28:31 -05:00
|
|
|
#endif
|
|
|
|
|
2019-07-17 03:12:39 -05:00
|
|
|
#if HAS_DISPLAY
|
2018-10-07 17:06:14 -05:00
|
|
|
if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling)
|
|
|
|
thermalManager.set_heating_message(target_extruder);
|
2018-02-04 00:39:01 -06:00
|
|
|
#endif
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(AUTOTEMP, planner.autotemp_M104_M109());
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2020-07-09 03:11:57 -05:00
|
|
|
if (got_temp)
|
2018-09-29 02:10:51 -05:00
|
|
|
(void)thermalManager.wait_for_hotend(target_extruder, no_wait_for_cooling);
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
2019-09-10 02:20:49 -05:00
|
|
|
|
|
|
|
#endif // EXTRUDERS
|