Merge pull request #1078 from mkbel/auto_deplete_2

Auto deplete 2
This commit is contained in:
PavelSindler 2018-08-28 11:10:04 +02:00 committed by GitHub
commit 7a88fc9ef7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 181 additions and 100 deletions

View file

@ -3124,6 +3124,8 @@ void gcode_M600(bool automatic, float x_position, float y_position, float z_shif
if(!automatic) M600_check_state(); if(!automatic) M600_check_state();
lcd_update_enable(true);
//Not let's go back to print //Not let's go back to print
fanSpeed = fanSpeedBckp; fanSpeed = fanSpeedBckp;
@ -8881,7 +8883,6 @@ void M600_check_state()
// Everything good // Everything good
default: default:
lcd_change_success(); lcd_change_success();
lcd_update_enable(true);
break; break;
} }
} }

View file

@ -144,6 +144,7 @@
// Sound Mode // Sound Mode
//#define EEPROM_SOUND_MODE (EEPROM_EXTRUDEMULTIPLY-1) // uint8 //#define EEPROM_SOUND_MODE (EEPROM_EXTRUDEMULTIPLY-1) // uint8
#define EEPROM_SOUND_MODE (EEPROM_UVLO_TINY_Z_MICROSTEPS-1) // uint8 #define EEPROM_SOUND_MODE (EEPROM_UVLO_TINY_Z_MICROSTEPS-1) // uint8
#define EEPROM_AUTO_DEPLETE (EEPROM_SOUND_MODE-1) //bool
// !!!!! // !!!!!
// !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!! // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!!

View file

@ -12,7 +12,6 @@
#include "ultralcd.h" #include "ultralcd.h"
#include "sound.h" #include "sound.h"
#define CHECK_FINDA ((IS_SD_PRINTING || is_usb_printing) && (mcode_in_progress != 600) && !saved_printing && e_active()) #define CHECK_FINDA ((IS_SD_PRINTING || is_usb_printing) && (mcode_in_progress != 600) && !saved_printing && e_active())
#define MMU_TODELAY 100 #define MMU_TODELAY 100
@ -187,7 +186,7 @@ void mmu_loop(void)
} }
mmu_cmd = 0; mmu_cmd = 0;
} }
else if ((mmu_last_response + 800) < millis()) //request every 800ms else if ((mmu_last_response + 300) < millis()) //request every 300ms
{ {
puts_P(PSTR("MMU <= 'P0'")); puts_P(PSTR("MMU <= 'P0'"));
mmu_puts_P(PSTR("P0\n")); //send 'read finda' request mmu_puts_P(PSTR("P0\n")); //send 'read finda' request
@ -203,7 +202,8 @@ void mmu_loop(void)
if (!mmu_finda && CHECK_FINDA && fsensor_enabled) { if (!mmu_finda && CHECK_FINDA && fsensor_enabled) {
fsensor_stop_and_save_print(); fsensor_stop_and_save_print();
enquecommand_front_P(PSTR("FSENSOR_RECOVER")); //then recover enquecommand_front_P(PSTR("FSENSOR_RECOVER")); //then recover
enquecommand_front_P(PSTR("M600")); //save print and run M600 command if (lcd_autoDeplete) enquecommand_front_P(PSTR("M600 AUTO")); //save print and run M600 command
else enquecommand_front_P(PSTR("M600")); //save print and run M600 command
} }
mmu_state = 1; mmu_state = 1;
if (mmu_cmd == 0) if (mmu_cmd == 0)
@ -448,6 +448,7 @@ void mmu_M600_load_filament(bool automatic)
bool response = false; bool response = false;
bool yes = false; bool yes = false;
tmp_extruder = mmu_extruder;
if (!automatic) { if (!automatic) {
mmu_M600_wait_and_beep(); mmu_M600_wait_and_beep();
#ifdef MMU_M600_SWITCH_EXTRUDER #ifdef MMU_M600_SWITCH_EXTRUDER
@ -478,6 +479,7 @@ void mmu_M600_load_filament(bool automatic)
mmu_load_to_nozzle(); mmu_load_to_nozzle();
st_synchronize(); st_synchronize();
current_position[E_AXIS]+= FILAMENTCHANGE_FINALFEED ; current_position[E_AXIS]+= FILAMENTCHANGE_FINALFEED ;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2, active_extruder); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2, active_extruder);

View file

@ -88,6 +88,7 @@ unsigned long display_time; //just timer for showing pid finished message on lcd
float pid_temp = DEFAULT_PID_TEMP; float pid_temp = DEFAULT_PID_TEMP;
static bool forceMenuExpire = false; static bool forceMenuExpire = false;
bool lcd_autoDeplete;
static float manual_feedrate[] = MANUAL_FEEDRATE; static float manual_feedrate[] = MANUAL_FEEDRATE;
@ -4513,6 +4514,159 @@ void lcd_settings_linearity_correction_menu(void)
} }
#endif // TMC2130 #endif // TMC2130
#ifdef FILAMENT_SENSOR
#define SETTINGS_FILAMENT_SENSOR \
do\
{\
if (FSensorStateMenu == 0)\
{\
if (fsensor_not_responding)\
{\
/* Filament sensor not working*/\
MENU_ITEM_FUNCTION_P(_i("Fil. sensor [N/A]"), lcd_fsensor_state_set);/*////MSG_FSENSOR_NA c=0 r=0*/\
MENU_ITEM_SUBMENU_P(_T(MSG_FSENS_AUTOLOAD_NA), lcd_fsensor_fail);\
}\
else\
{\
/* Filament sensor turned off, working, no problems*/\
MENU_ITEM_FUNCTION_P(_T(MSG_FSENSOR_OFF), lcd_fsensor_state_set);\
if (mmu_enabled == false)if (mmu_enabled == false)\
{\
MENU_ITEM_SUBMENU_P(_T(MSG_FSENS_AUTOLOAD_NA), lcd_filament_autoload_info);\
}\
}\
}\
else\
{\
/* Filament sensor turned on, working, no problems*/\
MENU_ITEM_FUNCTION_P(_T(MSG_FSENSOR_ON), lcd_fsensor_state_set);\
if (mmu_enabled == false)\
{\
if (fsensor_autoload_enabled)\
MENU_ITEM_FUNCTION_P(_i("F. autoload [on]"), lcd_set_filament_autoload);/*////MSG_FSENS_AUTOLOAD_ON c=17 r=1*/\
else\
MENU_ITEM_FUNCTION_P(_i("F. autoload [off]"), lcd_set_filament_autoload);/*////MSG_FSENS_AUTOLOAD_OFF c=17 r=1*/\
}\
}\
}\
while(0)
#else //FILAMENT_SENSOR
#define SETTINGS_FILAMENT_SENSOR do{}while(0)
#endif //FILAMENT_SENSOR
#ifdef TMC2130
#define SETTINGS_SILENT_MODE \
do\
{\
if(!farm_mode)\
{\
if (SilentModeMenu == SILENT_MODE_NORMAL)\
{\
MENU_ITEM_FUNCTION_P(_T(MSG_STEALTH_MODE_OFF), lcd_silent_mode_set);\
}\
else MENU_ITEM_FUNCTION_P(_T(MSG_STEALTH_MODE_ON), lcd_silent_mode_set);\
if (SilentModeMenu == SILENT_MODE_NORMAL)\
{\
if (CrashDetectMenu == 0)\
{\
MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_OFF), lcd_crash_mode_set);\
}\
else MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_ON), lcd_crash_mode_set);\
}\
else MENU_ITEM_SUBMENU_P(_T(MSG_CRASHDETECT_NA), lcd_crash_mode_info);\
}\
}\
while (0)
#else //TMC2130
#define SETTINGS_SILENT_MODE \
do\
{\
if(!farm_mode)\
{\
switch (SilentModeMenu)\
{\
case SILENT_MODE_POWER:\
MENU_ITEM_FUNCTION_P(_T(MSG_SILENT_MODE_OFF), lcd_silent_mode_set);\
break;\
case SILENT_MODE_SILENT:\
MENU_ITEM_FUNCTION_P(_T(MSG_SILENT_MODE_ON), lcd_silent_mode_set);\
break;\
case SILENT_MODE_AUTO:\
MENU_ITEM_FUNCTION_P(_T(MSG_AUTO_MODE_ON), lcd_silent_mode_set);\
break;\
default:\
MENU_ITEM_FUNCTION_P(_T(MSG_SILENT_MODE_OFF), lcd_silent_mode_set);\
break; /* (probably) not needed*/\
}\
}\
}\
while (0)
#endif //TMC2130
#ifdef SDCARD_SORT_ALPHA
#define SETTINGS_SD \
do\
{\
if (card.ToshibaFlashAir_isEnabled())\
MENU_ITEM_FUNCTION_P(_i("SD card [flshAir]"), lcd_toshiba_flash_air_compatibility_toggle);/*////MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_ON c=19 r=1*/\
else\
MENU_ITEM_FUNCTION_P(_i("SD card [normal]"), lcd_toshiba_flash_air_compatibility_toggle);/*////MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF c=19 r=1*/\
\
if (!farm_mode)\
{\
uint8_t sdSort;\
EEPROM_read(EEPROM_SD_SORT, (uint8_t*)&sdSort, sizeof(sdSort));\
switch (sdSort)\
{\
case SD_SORT_TIME: MENU_ITEM_FUNCTION_P(_i("Sort: [time]"), lcd_sort_type_set); break;/*////MSG_SORT_TIME c=17 r=1*/\
case SD_SORT_ALPHA: MENU_ITEM_FUNCTION_P(_i("Sort: [alphabet]"), lcd_sort_type_set); break;/*////MSG_SORT_ALPHA c=17 r=1*/\
default: MENU_ITEM_FUNCTION_P(_i("Sort: [none]"), lcd_sort_type_set);/*////MSG_SORT_NONE c=17 r=1*/\
}\
}\
}\
while (0)
#else // SDCARD_SORT_ALPHA
#define SETTINGS_SD \
do\
{\
if (card.ToshibaFlashAir_isEnabled())\
MENU_ITEM_FUNCTION_P(_i("SD card [flshAir]"), lcd_toshiba_flash_air_compatibility_toggle);/*////MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_ON c=19 r=1*/\
else\
MENU_ITEM_FUNCTION_P(_i("SD card [normal]"), lcd_toshiba_flash_air_compatibility_toggle);/*////MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF c=19 r=1*/\
}\
while (0)
#endif // SDCARD_SORT_ALPHA
#define SETTINGS_SOUND \
do\
{\
switch(eSoundMode)\
{\
case e_SOUND_MODE_LOUD:\
MENU_ITEM_FUNCTION_P(_i(MSG_SOUND_MODE_LOUD),lcd_sound_state_set);\
break;\
case e_SOUND_MODE_ONCE:\
MENU_ITEM_FUNCTION_P(_i(MSG_SOUND_MODE_ONCE),lcd_sound_state_set);\
break;\
case e_SOUND_MODE_SILENT:\
MENU_ITEM_FUNCTION_P(_i(MSG_SOUND_MODE_SILENT),lcd_sound_state_set);\
break;\
case e_SOUND_MODE_MUTE:\
MENU_ITEM_FUNCTION_P(_i(MSG_SOUND_MODE_MUTE),lcd_sound_state_set);\
break;\
default:\
MENU_ITEM_FUNCTION_P(_i(MSG_SOUND_MODE_LOUD),lcd_sound_state_set);\
}\
}\
while (0)
static void auto_deplete_switch()
{
lcd_autoDeplete = !lcd_autoDeplete;
eeprom_update_byte((unsigned char *)EEPROM_AUTO_DEPLETE, lcd_autoDeplete);
}
static void lcd_settings_menu() static void lcd_settings_menu()
{ {
EEPROM_read(EEPROM_SILENT, (uint8_t*)&SilentModeMenu, sizeof(SilentModeMenu)); EEPROM_read(EEPROM_SILENT, (uint8_t*)&SilentModeMenu, sizeof(SilentModeMenu));
@ -4525,72 +4679,24 @@ static void lcd_settings_menu()
if (!isPrintPaused) if (!isPrintPaused)
MENU_ITEM_GCODE_P(_i("Disable steppers"), PSTR("M84"));////MSG_DISABLE_STEPPERS c=0 r=0 MENU_ITEM_GCODE_P(_i("Disable steppers"), PSTR("M84"));////MSG_DISABLE_STEPPERS c=0 r=0
#ifndef TMC2130 SETTINGS_FILAMENT_SENSOR;
if (!farm_mode)
{ //dont show in menu if we are in farm mode
switch (SilentModeMenu)
{
case SILENT_MODE_POWER: MENU_ITEM_FUNCTION_P(_T(MSG_SILENT_MODE_OFF), lcd_silent_mode_set); break;
case SILENT_MODE_SILENT: MENU_ITEM_FUNCTION_P(_T(MSG_SILENT_MODE_ON), lcd_silent_mode_set); break;
case SILENT_MODE_AUTO: MENU_ITEM_FUNCTION_P(_T(MSG_AUTO_MODE_ON), lcd_silent_mode_set); break;
default: MENU_ITEM_FUNCTION_P(_T(MSG_SILENT_MODE_OFF), lcd_silent_mode_set); break; // (probably) not needed
}
}
#endif //TMC2130
#ifdef FILAMENT_SENSOR if (mmu_enabled)
if (FSensorStateMenu == 0)
{ {
if (fsensor_not_responding) if (lcd_autoDeplete) MENU_ITEM_FUNCTION_P(_i("Auto deplete [on]"), auto_deplete_switch);
{ else MENU_ITEM_FUNCTION_P(_i("Auto deplete[off]"), auto_deplete_switch);
// Filament sensor not working
MENU_ITEM_FUNCTION_P(_i("Fil. sensor [N/A]"), lcd_fsensor_state_set);////MSG_FSENSOR_NA c=0 r=0
MENU_ITEM_SUBMENU_P(_T(MSG_FSENS_AUTOLOAD_NA), lcd_fsensor_fail);
} }
else
{
// Filament sensor turned off, working, no problems
MENU_ITEM_FUNCTION_P(_T(MSG_FSENSOR_OFF), lcd_fsensor_state_set);
if (mmu_enabled == false)
{
MENU_ITEM_SUBMENU_P(_T(MSG_FSENS_AUTOLOAD_NA), lcd_filament_autoload_info);
}
}
}
else
{
// Filament sensor turned on, working, no problems
MENU_ITEM_FUNCTION_P(_T(MSG_FSENSOR_ON), lcd_fsensor_state_set);
if (mmu_enabled == false)
{
if (fsensor_autoload_enabled)
MENU_ITEM_FUNCTION_P(_i("F. autoload [on]"), lcd_set_filament_autoload);////MSG_FSENS_AUTOLOAD_ON c=17 r=1
else
MENU_ITEM_FUNCTION_P(_i("F. autoload [off]"), lcd_set_filament_autoload);////MSG_FSENS_AUTOLOAD_OFF c=17 r=1
}
}
#endif //FILAMENT_SENSOR
if (fans_check_enabled == true) if (fans_check_enabled == true)
MENU_ITEM_FUNCTION_P(_i("Fans check [on]"), lcd_set_fan_check);////MSG_FANS_CHECK_ON c=17 r=1 MENU_ITEM_FUNCTION_P(_i("Fans check [on]"), lcd_set_fan_check);////MSG_FANS_CHECK_ON c=17 r=1
else else
MENU_ITEM_FUNCTION_P(_i("Fans check [off]"), lcd_set_fan_check);////MSG_FANS_CHECK_OFF c=17 r=1 MENU_ITEM_FUNCTION_P(_i("Fans check [off]"), lcd_set_fan_check);////MSG_FANS_CHECK_OFF c=17 r=1
#ifdef TMC2130 SETTINGS_SILENT_MODE;
if(!farm_mode)
{
if (SilentModeMenu == SILENT_MODE_NORMAL) { MENU_ITEM_FUNCTION_P(_T(MSG_STEALTH_MODE_OFF), lcd_silent_mode_set); }
else MENU_ITEM_FUNCTION_P(_T(MSG_STEALTH_MODE_ON), lcd_silent_mode_set);
if (SilentModeMenu == SILENT_MODE_NORMAL)
{
if (CrashDetectMenu == 0) { MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_OFF), lcd_crash_mode_set); }
else MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_ON), lcd_crash_mode_set);
}
else MENU_ITEM_SUBMENU_P(_T(MSG_CRASHDETECT_NA), lcd_crash_mode_info);
}
#if defined (TMC2130) && defined (LINEARITY_CORRECTION)
MENU_ITEM_SUBMENU_P(_i("Lin. correction"), lcd_settings_linearity_correction_menu); MENU_ITEM_SUBMENU_P(_i("Lin. correction"), lcd_settings_linearity_correction_menu);
#endif //TMC2130 #endif //LINEARITY_CORRECTION && TMC2130
if (temp_cal_active == false) if (temp_cal_active == false)
MENU_ITEM_FUNCTION_P(_i("Temp. cal. [off]"), lcd_temp_calibration_set);////MSG_TEMP_CALIBRATION_OFF c=20 r=1 MENU_ITEM_FUNCTION_P(_i("Temp. cal. [off]"), lcd_temp_calibration_set);////MSG_TEMP_CALIBRATION_OFF c=20 r=1
@ -4611,45 +4717,9 @@ static void lcd_settings_menu()
MENU_ITEM_SUBMENU_P(_i("Select language"), lcd_language_menu);////MSG_LANGUAGE_SELECT c=0 r=0 MENU_ITEM_SUBMENU_P(_i("Select language"), lcd_language_menu);////MSG_LANGUAGE_SELECT c=0 r=0
#endif //(LANG_MODE != 0) #endif //(LANG_MODE != 0)
if (card.ToshibaFlashAir_isEnabled()) SETTINGS_SD;
MENU_ITEM_FUNCTION_P(_i("SD card [flshAir]"), lcd_toshiba_flash_air_compatibility_toggle);////MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_ON c=19 r=1 SETTINGS_SOUND;
else
MENU_ITEM_FUNCTION_P(_i("SD card [normal]"), lcd_toshiba_flash_air_compatibility_toggle);////MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF c=19 r=1
#ifdef SDCARD_SORT_ALPHA
if (!farm_mode)
{
uint8_t sdSort;
EEPROM_read(EEPROM_SD_SORT, (uint8_t*)&sdSort, sizeof(sdSort));
switch (sdSort)
{
case SD_SORT_TIME: MENU_ITEM_FUNCTION_P(_i("Sort: [time]"), lcd_sort_type_set); break;////MSG_SORT_TIME c=17 r=1
case SD_SORT_ALPHA: MENU_ITEM_FUNCTION_P(_i("Sort: [alphabet]"), lcd_sort_type_set); break;////MSG_SORT_ALPHA c=17 r=1
default: MENU_ITEM_FUNCTION_P(_i("Sort: [none]"), lcd_sort_type_set);////MSG_SORT_NONE c=17 r=1
}
}
#endif // SDCARD_SORT_ALPHA
//-//
switch(eSoundMode)
{
case e_SOUND_MODE_LOUD:
MENU_ITEM_FUNCTION_P(_i(MSG_SOUND_MODE_LOUD),lcd_sound_state_set);
break;
case e_SOUND_MODE_ONCE:
MENU_ITEM_FUNCTION_P(_i(MSG_SOUND_MODE_ONCE),lcd_sound_state_set);
break;
case e_SOUND_MODE_SILENT:
MENU_ITEM_FUNCTION_P(_i(MSG_SOUND_MODE_SILENT),lcd_sound_state_set);
break;
case e_SOUND_MODE_MUTE:
MENU_ITEM_FUNCTION_P(_i(MSG_SOUND_MODE_MUTE),lcd_sound_state_set);
break;
default:
MENU_ITEM_FUNCTION_P(_i(MSG_SOUND_MODE_LOUD),lcd_sound_state_set);
}
//-//
if (farm_mode) if (farm_mode)
{ {
MENU_ITEM_SUBMENU_P(PSTR("Farm number"), lcd_farm_no); MENU_ITEM_SUBMENU_P(PSTR("Farm number"), lcd_farm_no);
@ -7000,6 +7070,12 @@ void menu_action_sddirectory(const char* filename, char* longFilename)
void ultralcd_init() void ultralcd_init()
{ {
{
uint8_t autoDepleteRaw = eeprom_read_byte(reinterpret_cast<uint8_t*>(EEPROM_AUTO_DEPLETE));
if (0xff == autoDepleteRaw) lcd_autoDeplete = false;
else lcd_autoDeplete = autoDepleteRaw;
}
lcd_init(); lcd_init();
lcd_refresh(); lcd_refresh();
lcd_longpress_func = menu_lcd_longpress_func; lcd_longpress_func = menu_lcd_longpress_func;

View file

@ -112,6 +112,7 @@ extern int8_t SilentModeMenu;
extern bool cancel_heatup; extern bool cancel_heatup;
extern bool isPrintPaused; extern bool isPrintPaused;
extern bool lcd_autoDeplete;
void lcd_ignore_click(bool b=true); void lcd_ignore_click(bool b=true);