|
| 1 | +/** |
| 2 | + * Marlin 3D Printer Firmware |
| 3 | + * Copyright (c) 2022 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 | +#include "../../inc/MarlinConfig.h" |
| 23 | + |
| 24 | +#if HAS_GCODE_M255 |
| 25 | + |
| 26 | +#include "../gcode.h" |
| 27 | +#include "../../lcd/marlinui.h" |
| 28 | + |
| 29 | +/** |
| 30 | + * M255: Set the LCD sleep timeout (in minutes) |
| 31 | + * S<minutes> - Period of inactivity required for display / backlight sleep |
| 32 | + */ |
| 33 | +void GcodeSuite::M255() { |
| 34 | + if (parser.seenval('S')) { |
| 35 | + #if HAS_DISPLAY_SLEEP |
| 36 | + const int m = parser.value_int(); |
| 37 | + ui.sleep_timeout_minutes = constrain(m, SLEEP_TIMEOUT_MIN, SLEEP_TIMEOUT_MAX); |
| 38 | + #else |
| 39 | + const int s = parser.value_int() * 60; |
| 40 | + ui.lcd_backlight_timeout = constrain(s, LCD_BKL_TIMEOUT_MIN, LCD_BKL_TIMEOUT_MAX); |
| 41 | + #endif |
| 42 | + } |
| 43 | + else |
| 44 | + M255_report(); |
| 45 | +} |
| 46 | + |
| 47 | +void GcodeSuite::M255_report(const bool forReplay/*=true*/) { |
| 48 | + report_heading_etc(forReplay, F(STR_DISPLAY_SLEEP)); |
| 49 | + SERIAL_ECHOLNPGM(" M255 S", |
| 50 | + #if HAS_DISPLAY_SLEEP |
| 51 | + ui.sleep_timeout_minutes, " ; (minutes)" |
| 52 | + #else |
| 53 | + ui.lcd_backlight_timeout, " ; (seconds)" |
| 54 | + #endif |
| 55 | + ); |
| 56 | +} |
| 57 | + |
| 58 | +#endif // HAS_GCODE_M255 |
0 commit comments