Merge pull request #3564 from wavexx/fil_loading_state
Filament loading state fixes
This commit is contained in:
commit
ce141a2fa1
|
|
@ -278,7 +278,6 @@ extern uint32_t start_pause_print; // milliseconds
|
|||
extern ShortTimer usb_timer;
|
||||
extern bool processing_tcode;
|
||||
extern bool homing_flag;
|
||||
extern bool loading_flag;
|
||||
extern uint32_t total_filament_used; // mm/100 or 10um
|
||||
|
||||
/// @brief Save print statistics to EEPROM
|
||||
|
|
|
|||
|
|
@ -179,7 +179,6 @@ bool mesh_bed_leveling_flag = false;
|
|||
|
||||
uint32_t total_filament_used;
|
||||
HeatingStatus heating_status;
|
||||
bool loading_flag = false;
|
||||
int fan_edge_counter[2];
|
||||
int fan_speed[2];
|
||||
|
||||
|
|
@ -513,9 +512,8 @@ bool __attribute__((noinline)) printJobOngoing() {
|
|||
bool __attribute__((noinline)) printer_active() {
|
||||
return printJobOngoing()
|
||||
|| isPrintPaused
|
||||
|| (custom_message_type == CustomMsg::TempCal)
|
||||
|| saved_printing
|
||||
|| (lcd_commands_type == LcdCommands::Layer1Cal)
|
||||
|| (lcd_commands_type != LcdCommands::Idle)
|
||||
|| MMU2::mmu2.MMU_PRINT_SAVED()
|
||||
|| homing_flag
|
||||
|| mesh_bed_leveling_flag;
|
||||
|
|
@ -3581,13 +3579,12 @@ void gcode_M701(float fastLoadLength, uint8_t mmuSlotIndex){
|
|||
|
||||
Sound_MakeCustom(50, 500, false);
|
||||
|
||||
if (!farm_mode && loading_flag) {
|
||||
if (!farm_mode && (eFilamentAction != FilamentAction::None)) {
|
||||
lcd_load_filament_color_check();
|
||||
}
|
||||
lcd_update_enable(true);
|
||||
lcd_update(2);
|
||||
lcd_setstatuspgm(MSG_WELCOME);
|
||||
loading_flag = false;
|
||||
custom_message_type = CustomMsg::Status;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ void prusa_statistics(uint8_t _message) {
|
|||
else if (isPrintPaused) {
|
||||
prusa_statistics_case0(14);
|
||||
}
|
||||
else if (IS_SD_PRINTING || loading_flag) {
|
||||
else if (IS_SD_PRINTING || (eFilamentAction != FilamentAction::None)) {
|
||||
prusa_statistics_case0(4);
|
||||
}
|
||||
else {
|
||||
|
|
@ -270,7 +270,7 @@ void prusa_statistics(uint8_t _message) {
|
|||
status_number = 3;
|
||||
farm_timer = 1;
|
||||
|
||||
if (IS_SD_PRINTING || loading_flag) {
|
||||
if (IS_SD_PRINTING || (eFilamentAction != FilamentAction::None)) {
|
||||
SERIAL_ECHO('{');
|
||||
prusa_stat_printerstatus(4);
|
||||
prusa_stat_farm_number();
|
||||
|
|
@ -374,7 +374,7 @@ void prusa_statistics_update_from_status_screen() {
|
|||
switch (farm_timer) {
|
||||
case 8:
|
||||
prusa_statistics(21);
|
||||
if(loading_flag)
|
||||
if(eFilamentAction != FilamentAction::None)
|
||||
prusa_statistics(22);
|
||||
break;
|
||||
case 5:
|
||||
|
|
|
|||
|
|
@ -1796,10 +1796,10 @@ switch(eFilamentAction)
|
|||
switch(eFilamentAction)
|
||||
{
|
||||
case FilamentAction::AutoLoad:
|
||||
eFilamentAction=FilamentAction::None; // i.e. non-autoLoad
|
||||
// loading no longer cancellable
|
||||
eFilamentAction = FilamentAction::Load;
|
||||
// FALLTHRU
|
||||
case FilamentAction::Load:
|
||||
loading_flag=true;
|
||||
enquecommand_P(MSG_M701); // load filament
|
||||
break;
|
||||
case FilamentAction::UnLoad:
|
||||
|
|
@ -1818,6 +1818,17 @@ switch(eFilamentAction)
|
|||
}
|
||||
}
|
||||
|
||||
void mFilamentBack()
|
||||
{
|
||||
if (eFilamentAction == FilamentAction::AutoLoad ||
|
||||
eFilamentAction == FilamentAction::Preheat ||
|
||||
eFilamentAction == FilamentAction::Lay1Cal)
|
||||
{
|
||||
// filament action has been cancelled
|
||||
eFilamentAction = FilamentAction::None;
|
||||
}
|
||||
}
|
||||
|
||||
void mFilamentItem(uint16_t nTemp, uint16_t nTempBed)
|
||||
{
|
||||
uint8_t nLevel;
|
||||
|
|
@ -1860,14 +1871,16 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed)
|
|||
{
|
||||
nLevel = bFilamentPreheatState ? 1 : 2;
|
||||
menu_back(nLevel);
|
||||
if ((eFilamentAction == FilamentAction::Load) || (eFilamentAction == FilamentAction::AutoLoad))
|
||||
{
|
||||
loading_flag = true;
|
||||
enquecommand_P(MSG_M701); // load filament
|
||||
if (eFilamentAction == FilamentAction::AutoLoad) eFilamentAction = FilamentAction::None; // i.e. non-autoLoad
|
||||
|
||||
if (eFilamentAction == FilamentAction::AutoLoad) {
|
||||
// loading no longer cancellable
|
||||
eFilamentAction = FilamentAction::Load;
|
||||
}
|
||||
if (eFilamentAction == FilamentAction::UnLoad)
|
||||
enquecommand_P(MSG_M702); // unload filament
|
||||
|
||||
if (eFilamentAction == FilamentAction::Load)
|
||||
enquecommand_P(MSG_M701); // load filament
|
||||
else if (eFilamentAction == FilamentAction::UnLoad)
|
||||
enquecommand_P(MSG_M702); // unload filament
|
||||
}
|
||||
break;
|
||||
case FilamentAction::MmuLoad:
|
||||
|
|
@ -1968,7 +1981,7 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed)
|
|||
menu_back();
|
||||
}
|
||||
menu_back();
|
||||
if (eFilamentAction == FilamentAction::AutoLoad) eFilamentAction = FilamentAction::None; // i.e. non-autoLoad
|
||||
mFilamentBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2044,16 +2057,6 @@ static void mFilamentItem_PVB()
|
|||
mFilamentItem(PVB_PREHEAT_HOTEND_TEMP, PVB_PREHEAT_HPB_TEMP);
|
||||
}
|
||||
|
||||
void mFilamentBack()
|
||||
{
|
||||
if (eFilamentAction == FilamentAction::AutoLoad ||
|
||||
eFilamentAction == FilamentAction::Preheat ||
|
||||
eFilamentAction == FilamentAction::Lay1Cal)
|
||||
{
|
||||
eFilamentAction = FilamentAction::None; // i.e. non-autoLoad
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_generic_preheat_menu()
|
||||
{
|
||||
MENU_BEGIN();
|
||||
|
|
@ -3678,13 +3681,14 @@ static void lcd_wizard_load() {
|
|||
// NOTE: a full screen message showing which filament is being inserted
|
||||
// is performed by M701. For this reason MSG_LOADING_FILAMENT is not
|
||||
// used here when a MMU is used.
|
||||
eFilamentAction = FilamentAction::MmuLoad;
|
||||
} else {
|
||||
lcd_show_fullscreen_message_and_wait_P(
|
||||
_i("Please insert filament into the extruder, then press the knob to load it.")); ////MSG_WIZARD_LOAD_FILAMENT c=20 r=6
|
||||
lcd_update_enable(false);
|
||||
lcd_clear();
|
||||
lcd_puts_at_P(0, 2, _T(MSG_LOADING_FILAMENT));
|
||||
loading_flag = true;
|
||||
eFilamentAction = FilamentAction::Load;
|
||||
}
|
||||
|
||||
// When MMU is disabled P parameter is ignored
|
||||
|
|
@ -5179,9 +5183,9 @@ static void lcd_main_menu()
|
|||
}
|
||||
#endif
|
||||
#ifdef SDSUPPORT //!@todo SDSUPPORT undefined creates several issues in source code
|
||||
if (card.cardOK || lcd_commands_type == LcdCommands::Layer1Cal) {
|
||||
if (card.cardOK || lcd_commands_type != LcdCommands::Idle) {
|
||||
if (!card.isFileOpen()) {
|
||||
if (!usb_timer.running() && (lcd_commands_type != LcdCommands::Layer1Cal)) {
|
||||
if (!usb_timer.running() && (lcd_commands_type == LcdCommands::Idle)) {
|
||||
bMain=true; // flag ('fake parameter') for 'lcd_sdcard_menu()' function
|
||||
MENU_ITEM_SUBMENU_P(_T(MSG_CARD_MENU), lcd_sdcard_menu);
|
||||
}
|
||||
|
|
@ -5198,7 +5202,7 @@ static void lcd_main_menu()
|
|||
}
|
||||
#endif //SDSUPPORT
|
||||
|
||||
if(!isPrintPaused && !printJobOngoing() && (lcd_commands_type != LcdCommands::Layer1Cal)) {
|
||||
if(!isPrintPaused && !printJobOngoing() && (lcd_commands_type == LcdCommands::Idle)) {
|
||||
if (!farm_mode) {
|
||||
const int8_t sheet = eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet));
|
||||
const int8_t nextSheet = eeprom_next_initialized_sheet(sheet);
|
||||
|
|
@ -5208,7 +5212,7 @@ static void lcd_main_menu()
|
|||
}
|
||||
}
|
||||
|
||||
if ( ! ( printJobOngoing() || (lcd_commands_type == LcdCommands::Layer1Cal || Stopped) ) ) {
|
||||
if ( ! ( printJobOngoing() || (lcd_commands_type != LcdCommands::Idle) || (eFilamentAction != FilamentAction::None) || Stopped ) ) {
|
||||
if (MMU2::mmu2.Enabled()) {
|
||||
if(!MMU2::mmu2.FindaDetectsFilament() && !fsensor.getFilamentPresent()) {
|
||||
// The MMU 'Load filament' state machine will reject the command if any
|
||||
|
|
@ -5239,7 +5243,7 @@ static void lcd_main_menu()
|
|||
if(!isPrintPaused) MENU_ITEM_SUBMENU_P(_T(MSG_CALIBRATION), lcd_calibration_menu);
|
||||
}
|
||||
|
||||
if (!usb_timer.running() && (lcd_commands_type != LcdCommands::Layer1Cal)) {
|
||||
if (!usb_timer.running() && (lcd_commands_type == LcdCommands::Idle)) {
|
||||
MENU_ITEM_SUBMENU_P(_i("Statistics"), lcd_menu_statistics);////MSG_STATISTICS c=18
|
||||
}
|
||||
|
||||
|
|
@ -6913,7 +6917,8 @@ static bool check_file(const char* filename) {
|
|||
|
||||
static void menu_action_sdfile(const char* filename)
|
||||
{
|
||||
loading_flag = false;
|
||||
if(eFilamentAction != FilamentAction::None) return;
|
||||
|
||||
char cmd[30];
|
||||
char* c;
|
||||
bool result = true;
|
||||
|
|
|
|||
|
|
@ -175,17 +175,17 @@ void lcd_hw_setup_menu(void); // NOT static due to using ins
|
|||
|
||||
enum class FilamentAction : uint_least8_t
|
||||
{
|
||||
None, //!< 'none' state is used as flag for (filament) autoLoad (i.e. opposite for 'autoLoad' state)
|
||||
None, // no filament action is taking place
|
||||
Load,
|
||||
AutoLoad,
|
||||
AutoLoad, // triggered by insertion, cancellable until it transitions to Load
|
||||
UnLoad,
|
||||
MmuLoad,
|
||||
MmuUnLoad,
|
||||
MmuEject,
|
||||
MmuCut,
|
||||
MmuLoadingTest,
|
||||
Preheat,
|
||||
Lay1Cal,
|
||||
Preheat, // triggered by preheat (cancellable)
|
||||
Lay1Cal, // triggered by 1st layer calibration (cancellable)
|
||||
};
|
||||
|
||||
extern FilamentAction eFilamentAction;
|
||||
|
|
|
|||
Loading…
Reference in New Issue