|
| 1 | +/** |
| 2 | + * Marlin 3D Printer Firmware |
| 3 | + * Copyright (c) 2025 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 | +#include "../../inc/MarlinConfig.h" |
| 24 | + |
| 25 | +#if ENABLED(CONFIGURABLE_MACHINE_NAME) |
| 26 | + |
| 27 | +#include "../gcode.h" |
| 28 | +#include "../../MarlinCore.h" |
| 29 | +#include "../../lcd/marlinui.h" |
| 30 | + |
| 31 | +/** |
| 32 | + * M550: Set machine name |
| 33 | + * |
| 34 | + * Parameters: |
| 35 | + * P "<name>" Set the name using the 'P' parameter (RepRapFirmware) |
| 36 | + * "<name>" Set the name using the "string" parameter |
| 37 | + */ |
| 38 | +void GcodeSuite::M550() { |
| 39 | + bool did_set = true; |
| 40 | + |
| 41 | + if (parser.seenval('P')) |
| 42 | + machine_name = parser.value_string(); |
| 43 | + else if (TERN(GCODE_QUOTED_STRINGS, false, parser.seen('P'))) |
| 44 | + machine_name = parser.string_arg[0] == 'P' ? &parser.string_arg[1] : parser.string_arg; |
| 45 | + else if (parser.string_arg && parser.string_arg[0]) |
| 46 | + machine_name = parser.string_arg; |
| 47 | + else |
| 48 | + did_set = false; |
| 49 | + |
| 50 | + if (did_set) { |
| 51 | + machine_name.trim(); |
| 52 | + ui.reset_status(false); |
| 53 | + } |
| 54 | + else |
| 55 | + SERIAL_ECHOLNPGM("RepRap name: ", &machine_name); |
| 56 | + |
| 57 | +} |
| 58 | + |
| 59 | +#endif // CONFIGURABLE_MACHINE_NAME |
0 commit comments