|
| 1 | +/** |
| 2 | + * Marlin 3D Printer Firmware |
| 3 | + * Copyright (c) 2021 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(SERVO_DETACH_GCODE) |
| 26 | + |
| 27 | +#include "../gcode.h" |
| 28 | +#include "../../module/servo.h" |
| 29 | + |
| 30 | +/** |
| 31 | + * M282: Detach Servo. P<index> |
| 32 | + */ |
| 33 | +void GcodeSuite::M282() { |
| 34 | + |
| 35 | + if (!parser.seen('P')) return; |
| 36 | + |
| 37 | + const int servo_index = parser.value_int(); |
| 38 | + if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) |
| 39 | + DETACH_SERVO(servo_index); |
| 40 | + else |
| 41 | + SERIAL_ECHO_MSG("Servo ", servo_index, " out of range"); |
| 42 | + |
| 43 | +} |
| 44 | + |
| 45 | +#endif // SERVO_DETACH_GCODE |
0 commit comments