2018-10-27 20:15:46 +02:00
/**
* Marlin 3 D Printer Firmware
* Copyright ( C ) 2016 MarlinFirmware [ https : //github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl .
* Copyright ( C ) 2011 Camiel Gubbels / Erik van der Zalm
*
* 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/>.
*
*/
//
// Main Menu
//
# include "../../inc/MarlinConfigPre.h"
# if HAS_LCD_MENU
# include "menu.h"
# include "../../module/temperature.h"
2019-01-12 03:42:11 +01:00
# include "../../gcode/queue.h"
# include "../../module/printcounter.h"
2019-01-15 15:58:54 +01:00
# include "../../module/stepper.h"
2018-10-27 20:15:46 +02:00
2019-01-12 03:42:11 +01:00
# if ENABLED(POWER_LOSS_RECOVERY)
# include "../../feature/power_loss_recovery.h"
# endif
2018-10-27 20:15:46 +02:00
2019-01-28 05:43:13 +01:00
# if ENABLED(SDSUPPORT)
# include "../../sd/cardreader.h"
# endif
2019-01-12 03:42:11 +01:00
void lcd_pause ( ) {
2018-11-27 21:40:40 +01:00
# if ENABLED(POWER_LOSS_RECOVERY)
2019-01-12 03:42:11 +01:00
if ( recovery . enabled ) recovery . save ( true , false ) ;
2018-11-27 21:40:40 +01:00
# endif
2019-01-12 03:42:11 +01:00
# if ENABLED(PARK_HEAD_ON_PAUSE)
2019-01-28 06:10:25 +01:00
lcd_advanced_pause_show_message ( ADVANCED_PAUSE_MESSAGE_INIT , ADVANCED_PAUSE_MODE_PAUSE_PRINT ) ; // Show message immediately to let user know about pause in progress
enqueue_and_echo_commands_P ( PSTR ( " M25 P \n M24 " ) ) ;
2019-01-12 03:42:11 +01:00
# elif ENABLED(SDSUPPORT)
2018-11-29 02:28:31 +01:00
enqueue_and_echo_commands_P ( PSTR ( " M25 " ) ) ;
2019-01-12 03:42:11 +01:00
# elif defined(ACTION_ON_PAUSE)
2019-01-28 05:43:13 +01:00
host_action_pause ( ) ;
2019-01-12 03:42:11 +01:00
# endif
2019-01-15 15:58:54 +01:00
planner . synchronize ( ) ;
2019-01-12 03:42:11 +01:00
}
2018-10-27 20:15:46 +02:00
2019-01-12 03:42:11 +01:00
void lcd_resume ( ) {
# if ENABLED(SDSUPPORT)
if ( card . isPaused ( ) ) enqueue_and_echo_commands_P ( PSTR ( " M24 " ) ) ;
2019-01-31 04:08:36 +01:00
# endif
# ifdef ACTION_ON_RESUME
2019-01-28 05:43:13 +01:00
host_action_resume ( ) ;
2019-01-12 03:42:11 +01:00
# endif
}
2019-01-28 05:43:13 +01:00
void lcd_stop ( ) {
# if ENABLED(SDSUPPORT)
2018-10-27 20:15:46 +02:00
wait_for_heatup = wait_for_user = false ;
2018-11-17 05:39:16 +01:00
card . flag . abort_sd_printing = true ;
2019-01-28 05:43:13 +01:00
# endif
# ifdef ACTION_ON_CANCEL
host_action_cancel ( ) ;
# endif
ui . set_status_P ( PSTR ( MSG_PRINT_ABORTED ) , - 1 ) ;
ui . return_to_status ( ) ;
}
2018-12-27 18:36:39 +01:00
2019-01-28 05:43:13 +01:00
void menu_abort_confirm ( ) {
START_MENU ( ) ;
MENU_BACK ( MSG_MAIN ) ;
MENU_ITEM ( function , MSG_STOP_PRINT , lcd_stop ) ;
END_MENU ( ) ;
}
2018-10-27 20:15:46 +02:00
2019-02-01 02:10:52 +01:00
# if ENABLED(PRUSA_MMU2)
2019-02-07 00:38:46 +01:00
# include "../../lcd/menu/menu_mmu2.h"
2019-02-01 02:10:52 +01:00
# endif
2018-10-27 20:15:46 +02:00
void menu_tune ( ) ;
2018-10-27 23:45:37 +02:00
void menu_motion ( ) ;
2018-10-27 20:15:46 +02:00
void menu_temperature ( ) ;
void menu_configuration ( ) ;
2018-10-28 09:05:17 +01:00
void menu_user ( ) ;
2018-10-27 20:15:46 +02:00
void menu_temp_e0_filament_change ( ) ;
void menu_change_filament ( ) ;
void menu_info ( ) ;
void menu_led ( ) ;
void menu_main ( ) {
START_MENU ( ) ;
MENU_BACK ( MSG_WATCH ) ;
2019-02-04 13:11:17 +01:00
const bool busy = printer_busy ( )
2019-02-03 00:08:44 +01:00
# if ENABLED(SDSUPPORT)
2019-02-04 13:11:17 +01:00
, card_detected = card . isDetected ( )
, card_open = card_detected & & card . isFileOpen ( )
2019-02-03 00:08:44 +01:00
# endif
;
2019-01-12 03:42:11 +01:00
if ( busy ) {
MENU_ITEM ( function , MSG_PAUSE_PRINT , lcd_pause ) ;
2019-01-28 05:43:13 +01:00
# if ENABLED(SDSUPPORT) || defined(ACTION_ON_CANCEL)
MENU_ITEM ( submenu , MSG_STOP_PRINT , menu_abort_confirm ) ;
2019-01-12 03:42:11 +01:00
# endif
2019-01-15 15:58:54 +01:00
MENU_ITEM ( submenu , MSG_TUNE , menu_tune ) ;
}
else {
2019-01-21 06:24:53 +01:00
# if !HAS_ENCODER_WHEEL && ENABLED(SDSUPPORT)
//
// Autostart
//
# if ENABLED(MENU_ADDAUTOSTART)
if ( ! busy ) MENU_ITEM ( function , MSG_AUTOSTART , card . beginautostart ) ;
# endif
2019-02-03 00:08:44 +01:00
if ( card_detected ) {
if ( ! card_open ) {
2019-01-21 06:24:53 +01:00
MENU_ITEM ( submenu , MSG_CARD_MENU , menu_sdcard ) ;
# if !PIN_EXISTS(SD_DETECT)
MENU_ITEM ( gcode , MSG_CHANGE_SDCARD , PSTR ( " M21 " ) ) ; // SD-card changed by user
# endif
}
}
else {
# if !PIN_EXISTS(SD_DETECT)
MENU_ITEM ( gcode , MSG_INIT_SDCARD , PSTR ( " M21 " ) ) ; // Manually init SD-card
# endif
MENU_ITEM ( function , MSG_NO_CARD , NULL ) ;
}
# endif // !HAS_ENCODER_WHEEL && SDSUPPORT
2019-02-04 10:02:44 +01:00
# if ENABLED(SDSUPPORT) || defined(ACTION_ON_RESUME)
# if ENABLED(SDSUPPORT)
if ( card . isFileOpen ( ) & & card . isPaused ( ) )
# endif
MENU_ITEM ( function , MSG_RESUME_PRINT , lcd_resume ) ;
# endif
2019-01-23 22:48:56 +01:00
2018-10-27 23:45:37 +02:00
MENU_ITEM ( submenu , MSG_MOTION , menu_motion ) ;
2018-10-27 20:15:46 +02:00
MENU_ITEM ( submenu , MSG_TEMPERATURE , menu_temperature ) ;
2019-02-01 02:10:52 +01:00
# if ENABLED(MMU2_MENUS)
MENU_ITEM ( submenu , MSG_MMU2_MENU , menu_mmu2 ) ;
# endif
2018-10-27 20:15:46 +02:00
}
MENU_ITEM ( submenu , MSG_CONFIGURATION , menu_configuration ) ;
# if ENABLED(CUSTOM_USER_MENUS)
2018-10-28 09:05:17 +01:00
MENU_ITEM ( submenu , MSG_USER_MENU , menu_user ) ;
2018-10-27 20:15:46 +02:00
# endif
# if ENABLED(ADVANCED_PAUSE_FEATURE)
# if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES)
if ( thermalManager . targetHotEnoughToExtrude ( active_extruder ) )
MENU_ITEM ( gcode , MSG_FILAMENTCHANGE , PSTR ( " M600 B0 " ) ) ;
else
MENU_ITEM ( submenu , MSG_FILAMENTCHANGE , menu_temp_e0_filament_change ) ;
# else
MENU_ITEM ( submenu , MSG_FILAMENTCHANGE , menu_change_filament ) ;
# endif
# endif
# if ENABLED(LCD_INFO_MENU)
MENU_ITEM ( submenu , MSG_INFO_MENU , menu_info ) ;
# endif
# if ENABLED(LED_CONTROL_MENU)
MENU_ITEM ( submenu , MSG_LED_CONTROL , menu_led ) ;
# endif
//
// Switch power on/off
//
# if HAS_POWER_SWITCH
if ( powersupply_on )
MENU_ITEM ( gcode , MSG_SWITCH_PS_OFF , PSTR ( " M81 " ) ) ;
else
MENU_ITEM ( gcode , MSG_SWITCH_PS_ON , PSTR ( " M80 " ) ) ;
# endif
2019-01-21 06:24:53 +01:00
# if HAS_ENCODER_WHEEL && ENABLED(SDSUPPORT)
2019-01-14 00:59:32 +01:00
//
// Autostart
//
# if ENABLED(MENU_ADDAUTOSTART)
2019-01-21 06:24:53 +01:00
if ( ! busy ) MENU_ITEM ( function , MSG_AUTOSTART , card . beginautostart ) ;
2019-01-14 00:59:32 +01:00
# endif
2018-10-27 20:15:46 +02:00
2019-02-03 00:08:44 +01:00
if ( card_detected ) {
if ( ! card_open ) {
2019-01-21 06:24:53 +01:00
MENU_ITEM ( submenu , MSG_CARD_MENU , menu_sdcard ) ;
# if !PIN_EXISTS(SD_DETECT)
MENU_ITEM ( gcode , MSG_CHANGE_SDCARD , PSTR ( " M21 " ) ) ; // SD-card changed by user
# endif
2019-01-15 15:58:54 +01:00
}
2019-01-12 03:42:11 +01:00
}
else {
# if !PIN_EXISTS(SD_DETECT)
2019-01-14 00:59:32 +01:00
MENU_ITEM ( gcode , MSG_INIT_SDCARD , PSTR ( " M21 " ) ) ; // Manually init SD-card
2019-01-12 03:42:11 +01:00
# endif
2019-01-14 00:59:32 +01:00
MENU_ITEM ( function , MSG_NO_CARD , NULL ) ;
2019-01-12 03:42:11 +01:00
}
2019-01-21 06:24:53 +01:00
# endif // HAS_ENCODER_WHEEL && SDSUPPORT
2019-01-14 00:59:32 +01:00
2018-10-27 20:15:46 +02:00
END_MENU ( ) ;
}
# endif // HAS_LCD_MENU