2019-02-01 02:10:52 +01:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 15:00:57 +01:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2019-02-01 02:10:52 +01:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2019-02-01 02:10:52 +01: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
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
#if HAS_LCD_MENU && ENABLED(MMU2_MENUS)
|
|
|
|
|
2019-02-07 00:38:46 +01:00
|
|
|
#include "../../feature/prusa_MMU2/mmu2.h"
|
|
|
|
#include "menu_mmu2.h"
|
|
|
|
#include "menu.h"
|
2019-02-01 02:10:52 +01:00
|
|
|
|
|
|
|
uint8_t currentTool;
|
|
|
|
bool mmuMenuWait;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Load Filament
|
|
|
|
//
|
|
|
|
|
2019-04-09 00:56:40 +02:00
|
|
|
void _mmu2_load_filamentToNozzle(uint8_t index) {
|
2019-02-01 02:10:52 +01:00
|
|
|
ui.reset_status();
|
|
|
|
ui.return_to_status();
|
2019-10-10 02:46:10 +02:00
|
|
|
ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
|
2019-04-09 00:56:40 +02:00
|
|
|
if (mmu2.load_filament_to_nozzle(index)) ui.reset_status();
|
2019-02-01 02:10:52 +01:00
|
|
|
}
|
|
|
|
|
2019-10-08 02:44:33 +02:00
|
|
|
inline void action_mmu2_load_filament_to_nozzle(const uint8_t tool) {
|
2019-04-09 00:56:40 +02:00
|
|
|
_mmu2_load_filamentToNozzle(tool);
|
2019-02-01 02:10:52 +01:00
|
|
|
ui.return_to_status();
|
|
|
|
}
|
|
|
|
|
2019-04-09 00:56:40 +02:00
|
|
|
void _mmu2_load_filament(uint8_t index) {
|
2019-02-01 02:10:52 +01:00
|
|
|
ui.return_to_status();
|
2019-10-10 02:46:10 +02:00
|
|
|
ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
|
2019-04-09 00:56:40 +02:00
|
|
|
mmu2.load_filament(index);
|
2019-02-01 02:10:52 +01:00
|
|
|
ui.reset_status();
|
|
|
|
}
|
2019-04-09 00:56:40 +02:00
|
|
|
void action_mmu2_load_all() {
|
2019-02-01 02:10:52 +01:00
|
|
|
for (uint8_t i = 0; i < EXTRUDERS; i++)
|
2019-04-09 00:56:40 +02:00
|
|
|
_mmu2_load_filament(i);
|
2019-02-01 02:10:52 +01:00
|
|
|
ui.return_to_status();
|
|
|
|
}
|
|
|
|
|
2019-04-09 00:56:40 +02:00
|
|
|
void menu_mmu2_load_filament() {
|
2019-02-01 02:10:52 +01:00
|
|
|
START_MENU();
|
2019-10-03 12:38:30 +02:00
|
|
|
BACK_ITEM(MSG_MMU2_MENU);
|
|
|
|
ACTION_ITEM(MSG_MMU2_ALL, action_mmu2_load_all);
|
2019-11-26 09:15:31 +01:00
|
|
|
LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ _mmu2_load_filament(MenuItemBase::itemIndex); });
|
2019-02-01 02:10:52 +01:00
|
|
|
END_MENU();
|
|
|
|
}
|
|
|
|
|
2019-04-09 00:56:40 +02:00
|
|
|
void menu_mmu2_load_to_nozzle() {
|
2019-02-01 02:10:52 +01:00
|
|
|
START_MENU();
|
2019-10-03 12:38:30 +02:00
|
|
|
BACK_ITEM(MSG_MMU2_MENU);
|
2019-11-26 09:15:31 +01:00
|
|
|
LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_load_filament_to_nozzle(MenuItemBase::itemIndex); });
|
2019-02-01 02:10:52 +01:00
|
|
|
END_MENU();
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Eject Filament
|
|
|
|
//
|
|
|
|
|
2019-04-09 00:56:40 +02:00
|
|
|
void _mmu2_eject_filament(uint8_t index) {
|
2019-02-01 02:10:52 +01:00
|
|
|
ui.reset_status();
|
|
|
|
ui.return_to_status();
|
2019-10-10 02:46:10 +02:00
|
|
|
ui.status_printf_P(0, GET_TEXT(MSG_MMU2_EJECTING_FILAMENT), int(index + 1));
|
2019-04-09 00:56:40 +02:00
|
|
|
if (mmu2.eject_filament(index, true)) ui.reset_status();
|
2019-02-01 02:10:52 +01:00
|
|
|
}
|
|
|
|
|
2019-04-09 00:56:40 +02:00
|
|
|
void action_mmu2_unload_filament() {
|
2019-02-01 02:10:52 +01:00
|
|
|
ui.reset_status();
|
|
|
|
ui.return_to_status();
|
|
|
|
LCD_MESSAGEPGM(MSG_MMU2_UNLOADING_FILAMENT);
|
|
|
|
idle();
|
|
|
|
if (mmu2.unload()) ui.reset_status();
|
|
|
|
}
|
|
|
|
|
2019-04-09 00:56:40 +02:00
|
|
|
void menu_mmu2_eject_filament() {
|
2019-02-01 02:10:52 +01:00
|
|
|
START_MENU();
|
2019-10-03 12:38:30 +02:00
|
|
|
BACK_ITEM(MSG_MMU2_MENU);
|
2019-11-26 09:15:31 +01:00
|
|
|
LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ _mmu2_eject_filament(MenuItemBase::itemIndex); });
|
2019-02-01 02:10:52 +01:00
|
|
|
END_MENU();
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// MMU2 Menu
|
|
|
|
//
|
|
|
|
|
|
|
|
void action_mmu2_reset() {
|
|
|
|
mmu2.init();
|
|
|
|
ui.reset_status();
|
|
|
|
}
|
|
|
|
|
|
|
|
void menu_mmu2() {
|
|
|
|
START_MENU();
|
2019-10-03 12:38:30 +02:00
|
|
|
BACK_ITEM(MSG_MAIN);
|
|
|
|
SUBMENU(MSG_MMU2_LOAD_FILAMENT, menu_mmu2_load_filament);
|
|
|
|
SUBMENU(MSG_MMU2_LOAD_TO_NOZZLE, menu_mmu2_load_to_nozzle);
|
|
|
|
SUBMENU(MSG_MMU2_EJECT_FILAMENT, menu_mmu2_eject_filament);
|
|
|
|
ACTION_ITEM(MSG_MMU2_UNLOAD_FILAMENT, action_mmu2_unload_filament);
|
|
|
|
ACTION_ITEM(MSG_MMU2_RESET, action_mmu2_reset);
|
2019-02-01 02:10:52 +01:00
|
|
|
END_MENU();
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// T* Choose Filament
|
|
|
|
//
|
|
|
|
|
|
|
|
inline void action_mmu2_choose(const uint8_t tool) {
|
|
|
|
currentTool = tool;
|
|
|
|
mmuMenuWait = false;
|
|
|
|
}
|
|
|
|
|
2019-04-09 00:56:40 +02:00
|
|
|
void menu_mmu2_choose_filament() {
|
2019-02-01 02:10:52 +01:00
|
|
|
START_MENU();
|
|
|
|
#if LCD_HEIGHT > 2
|
2019-09-27 10:06:23 +02:00
|
|
|
STATIC_ITEM(MSG_MMU2_CHOOSE_FILAMENT_HEADER, SS_CENTER|SS_INVERT);
|
2019-02-01 02:10:52 +01:00
|
|
|
#endif
|
2019-11-26 09:15:31 +01:00
|
|
|
LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_choose(MenuItemBase::itemIndex); });
|
2019-02-01 02:10:52 +01:00
|
|
|
END_MENU();
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// MMU2 Filament Runout
|
|
|
|
//
|
|
|
|
|
2019-03-14 08:26:07 +01:00
|
|
|
void menu_mmu2_pause() {
|
2019-04-09 00:56:40 +02:00
|
|
|
currentTool = mmu2.get_current_tool();
|
2019-02-01 02:10:52 +01:00
|
|
|
START_MENU();
|
|
|
|
#if LCD_HEIGHT > 2
|
2019-10-10 02:46:10 +02:00
|
|
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, SS_CENTER|SS_INVERT);
|
2019-02-01 02:10:52 +01:00
|
|
|
#endif
|
2019-11-02 06:05:05 +01:00
|
|
|
ACTION_ITEM(MSG_MMU2_RESUME, []{ mmuMenuWait = false; });
|
|
|
|
ACTION_ITEM(MSG_MMU2_UNLOAD_FILAMENT, []{ mmu2.unload(); });
|
|
|
|
ACTION_ITEM(MSG_MMU2_LOAD_FILAMENT, []{ mmu2.load_filament(currentTool); });
|
|
|
|
ACTION_ITEM(MSG_MMU2_LOAD_TO_NOZZLE, []{ mmu2.load_filament_to_nozzle(currentTool); });
|
2019-02-01 02:10:52 +01:00
|
|
|
END_MENU();
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu2_M600() {
|
2019-03-23 22:30:43 +01:00
|
|
|
ui.defer_status_screen();
|
2019-03-14 08:26:07 +01:00
|
|
|
ui.goto_screen(menu_mmu2_pause);
|
2019-02-01 02:10:52 +01:00
|
|
|
mmuMenuWait = true;
|
|
|
|
while (mmuMenuWait) idle();
|
|
|
|
}
|
|
|
|
|
2019-04-09 00:56:40 +02:00
|
|
|
uint8_t mmu2_choose_filament() {
|
2019-03-23 22:30:43 +01:00
|
|
|
ui.defer_status_screen();
|
2019-04-09 00:56:40 +02:00
|
|
|
ui.goto_screen(menu_mmu2_choose_filament);
|
2019-02-01 02:10:52 +01:00
|
|
|
mmuMenuWait = true;
|
|
|
|
while (mmuMenuWait) idle();
|
|
|
|
ui.return_to_status();
|
|
|
|
return currentTool;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // HAS_LCD_MENU && ENABLED(PRUSA_MMU2_MENUS)
|