|
| 1 | +/** |
| 2 | + * Marlin 3D Printer Firmware |
| 3 | + * Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] |
| 4 | + * |
| 5 | + * Based on Sprinter and grbl. |
| 6 | + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
| 7 | + * |
| 8 | + * This program is free software: you can redistribute it and/or modify |
| 9 | + * it under the terms of the GNU General Public License as published by |
| 10 | + * the Free Software Foundation, either version 3 of the License, or |
| 11 | + * (at your option) any later version. |
| 12 | + * |
| 13 | + * This program is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * GNU General Public License for more details. |
| 17 | + * |
| 18 | + * You should have received a copy of the GNU General Public License |
| 19 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 20 | + * |
| 21 | + */ |
| 22 | + |
| 23 | +/** |
| 24 | + * gcode/temp/M86-M87.cpp |
| 25 | + * |
| 26 | + * Hotend Idle Timeout |
| 27 | + */ |
| 28 | + |
| 29 | +#include "../../inc/MarlinConfigPre.h" |
| 30 | + |
| 31 | +#if ENABLED(HOTEND_IDLE_TIMEOUT) |
| 32 | + |
| 33 | +#include "../gcode.h" |
| 34 | +#include "../../feature/hotend_idle.h" |
| 35 | + |
| 36 | +void GcodeSuite::M86_report(const bool forReplay/*=true*/) { |
| 37 | + hotend_idle_settings_t &c = hotend_idle.cfg; |
| 38 | + report_heading(forReplay, F("Hotend Idle Timeout")); |
| 39 | + SERIAL_ECHOLNPGM(" M86" |
| 40 | + #if HAS_HEATED_BED |
| 41 | + " B", c.bed_target, |
| 42 | + #endif |
| 43 | + " E", c.nozzle_target, |
| 44 | + " S", c.timeout, |
| 45 | + " T", c.trigger |
| 46 | + ); |
| 47 | +} |
| 48 | + |
| 49 | +/** |
| 50 | + * M86: Set / Report Hotend Idle Timeout |
| 51 | + * |
| 52 | + * Parameters |
| 53 | + * S<seconds> : Idle timeout. Set to 0 to disable. |
| 54 | + * E<temp> : Extruder idle temperature to set on timeout |
| 55 | + * B<temp> : Bed idle temperature to set on timeout |
| 56 | + * T<temp> : Minimum extruder temperature to consider for timeout (> idle temperature) |
| 57 | + */ |
| 58 | +void GcodeSuite::M86() { |
| 59 | + if (!parser.seen_any()) return M86_report(); |
| 60 | + hotend_idle_settings_t &c = hotend_idle.cfg; |
| 61 | + if (parser.seenval('S')) c.timeout = parser.value_ushort(); |
| 62 | + if (parser.seenval('T')) c.trigger = parser.value_celsius(); |
| 63 | + if (parser.seenval('E')) c.nozzle_target = parser.value_celsius(); |
| 64 | + #if HAS_HEATED_BED |
| 65 | + if (parser.seenval('B')) c.bed_target = parser.value_celsius(); |
| 66 | + #endif |
| 67 | + const celsius_t min_trigger = c.nozzle_target + TEMP_HYSTERESIS; |
| 68 | + if (c.trigger <= min_trigger) |
| 69 | + SERIAL_ECHOLNPGM("?Idle Timeout (T) trigger temperature should be over ", min_trigger, "C."); |
| 70 | +} |
| 71 | + |
| 72 | +/** |
| 73 | + * M86: Cancel Hotend Idle Timeout (by setting the timeout period to 0) |
| 74 | + */ |
| 75 | +void GcodeSuite::M87() { |
| 76 | + hotend_idle.cfg.timeout = 0; |
| 77 | +} |
| 78 | + |
| 79 | +#endif // HOTEND_IDLE_TIMEOUT |
0 commit comments