0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-01-10 11:47:53 +00:00
MarlinFirmware/Marlin/src/gcode/feature/powerloss/M1000.cpp

88 lines
2.3 KiB
C++
Raw Normal View History

2018-11-17 02:47:07 +00:00
/**
* Marlin 3D Printer Firmware
2020-02-03 14:00:57 +00:00
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
2018-11-17 02:47:07 +00:00
*
* Based on Sprinter and grbl.
2019-06-28 04:57:50 +00:00
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
2018-11-17 02:47:07 +00: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-23 03:20:14 +00:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2018-11-17 02:47:07 +00:00
*
*/
#include "../../../inc/MarlinConfig.h"
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../../gcode.h"
2020-03-13 21:29:29 +00:00
#include "../../../feature/powerloss.h"
2018-11-17 02:47:07 +00:00
#include "../../../module/motion.h"
#include "../../../lcd/ultralcd.h"
2020-01-04 03:00:44 +00:00
#if ENABLED(EXTENSIBLE_UI)
2020-03-13 21:29:29 +00:00
#include "../../../lcd/extui/ui_api.h"
2020-01-04 03:00:44 +00:00
#endif
2018-11-17 02:47:07 +00:00
2019-04-06 01:02:46 +00:00
#define DEBUG_OUT ENABLED(DEBUG_POWER_LOSS_RECOVERY)
#include "../../../core/debug_out.h"
2018-11-17 02:47:07 +00:00
2019-04-06 01:02:46 +00:00
void menu_job_recovery();
2018-11-17 02:47:07 +00:00
2019-04-06 01:02:46 +00:00
inline void plr_error(PGM_P const prefix) {
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
DEBUG_ECHO_START();
2018-11-17 02:47:07 +00:00
serialprintPGM(prefix);
2020-06-01 22:02:49 +00:00
DEBUG_ECHOLNPGM(" Job Recovery Data");
2019-04-06 01:02:46 +00:00
#else
UNUSED(prefix);
#endif
}
2018-11-17 02:47:07 +00:00
2020-01-14 02:52:24 +00:00
#if HAS_LCD_MENU
void lcd_power_loss_recovery_cancel();
#endif
2018-11-17 02:47:07 +00:00
/**
* M1000: Resume from power-loss (undocumented)
* - With 'S' go to the Resume/Cancel menu
* - With no parameters, run recovery commands
*/
void GcodeSuite::M1000() {
if (recovery.valid()) {
if (parser.seen('S')) {
#if HAS_LCD_MENU
ui.goto_screen(menu_job_recovery);
#elif ENABLED(EXTENSIBLE_UI)
ExtUI::onPowerLossResume();
#else
SERIAL_ECHO_MSG("Resume requires LCD.");
#endif
}
2020-01-14 02:52:24 +00:00
else if (parser.seen('C')) {
#if HAS_LCD_MENU
lcd_power_loss_recovery_cancel();
#else
recovery.cancel();
#endif
2020-04-22 21:35:03 +00:00
TERN_(EXTENSIBLE_UI, ExtUI::onPrintTimerStopped());
2020-01-14 02:52:24 +00:00
}
2018-11-17 02:47:07 +00:00
else
recovery.resume();
}
2019-04-06 01:02:46 +00:00
else
plr_error(recovery.info.valid_head ? PSTR("No") : PSTR("Invalid"));
2018-11-17 02:47:07 +00:00
}
#endif // POWER_LOSS_RECOVERY