Merge pull request #3564 from wavexx/fil_loading_state

Filament loading state fixes
This commit is contained in:
3d-gussner 2023-07-26 16:38:29 +02:00 committed by GitHub
commit ce141a2fa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 40 deletions

View File

@ -278,7 +278,6 @@ extern uint32_t start_pause_print; // milliseconds
extern ShortTimer usb_timer; extern ShortTimer usb_timer;
extern bool processing_tcode; extern bool processing_tcode;
extern bool homing_flag; extern bool homing_flag;
extern bool loading_flag;
extern uint32_t total_filament_used; // mm/100 or 10um extern uint32_t total_filament_used; // mm/100 or 10um
/// @brief Save print statistics to EEPROM /// @brief Save print statistics to EEPROM

View File

@ -179,7 +179,6 @@ bool mesh_bed_leveling_flag = false;
uint32_t total_filament_used; uint32_t total_filament_used;
HeatingStatus heating_status; HeatingStatus heating_status;
bool loading_flag = false;
int fan_edge_counter[2]; int fan_edge_counter[2];
int fan_speed[2]; int fan_speed[2];
@ -513,9 +512,8 @@ bool __attribute__((noinline)) printJobOngoing() {
bool __attribute__((noinline)) printer_active() { bool __attribute__((noinline)) printer_active() {
return printJobOngoing() return printJobOngoing()
|| isPrintPaused || isPrintPaused
|| (custom_message_type == CustomMsg::TempCal)
|| saved_printing || saved_printing
|| (lcd_commands_type == LcdCommands::Layer1Cal) || (lcd_commands_type != LcdCommands::Idle)
|| MMU2::mmu2.MMU_PRINT_SAVED() || MMU2::mmu2.MMU_PRINT_SAVED()
|| homing_flag || homing_flag
|| mesh_bed_leveling_flag; || mesh_bed_leveling_flag;
@ -3581,13 +3579,12 @@ void gcode_M701(float fastLoadLength, uint8_t mmuSlotIndex){
Sound_MakeCustom(50, 500, false); Sound_MakeCustom(50, 500, false);
if (!farm_mode && loading_flag) { if (!farm_mode && (eFilamentAction != FilamentAction::None)) {
lcd_load_filament_color_check(); lcd_load_filament_color_check();
} }
lcd_update_enable(true); lcd_update_enable(true);
lcd_update(2); lcd_update(2);
lcd_setstatuspgm(MSG_WELCOME); lcd_setstatuspgm(MSG_WELCOME);
loading_flag = false;
custom_message_type = CustomMsg::Status; custom_message_type = CustomMsg::Status;
} }

View File

@ -242,7 +242,7 @@ void prusa_statistics(uint8_t _message) {
else if (isPrintPaused) { else if (isPrintPaused) {
prusa_statistics_case0(14); prusa_statistics_case0(14);
} }
else if (IS_SD_PRINTING || loading_flag) { else if (IS_SD_PRINTING || (eFilamentAction != FilamentAction::None)) {
prusa_statistics_case0(4); prusa_statistics_case0(4);
} }
else { else {
@ -270,7 +270,7 @@ void prusa_statistics(uint8_t _message) {
status_number = 3; status_number = 3;
farm_timer = 1; farm_timer = 1;
if (IS_SD_PRINTING || loading_flag) { if (IS_SD_PRINTING || (eFilamentAction != FilamentAction::None)) {
SERIAL_ECHO('{'); SERIAL_ECHO('{');
prusa_stat_printerstatus(4); prusa_stat_printerstatus(4);
prusa_stat_farm_number(); prusa_stat_farm_number();
@ -374,7 +374,7 @@ void prusa_statistics_update_from_status_screen() {
switch (farm_timer) { switch (farm_timer) {
case 8: case 8:
prusa_statistics(21); prusa_statistics(21);
if(loading_flag) if(eFilamentAction != FilamentAction::None)
prusa_statistics(22); prusa_statistics(22);
break; break;
case 5: case 5:

View File

@ -1796,10 +1796,10 @@ switch(eFilamentAction)
switch(eFilamentAction) switch(eFilamentAction)
{ {
case FilamentAction::AutoLoad: case FilamentAction::AutoLoad:
eFilamentAction=FilamentAction::None; // i.e. non-autoLoad // loading no longer cancellable
eFilamentAction = FilamentAction::Load;
// FALLTHRU // FALLTHRU
case FilamentAction::Load: case FilamentAction::Load:
loading_flag=true;
enquecommand_P(MSG_M701); // load filament enquecommand_P(MSG_M701); // load filament
break; break;
case FilamentAction::UnLoad: 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) void mFilamentItem(uint16_t nTemp, uint16_t nTempBed)
{ {
uint8_t nLevel; uint8_t nLevel;
@ -1860,14 +1871,16 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed)
{ {
nLevel = bFilamentPreheatState ? 1 : 2; nLevel = bFilamentPreheatState ? 1 : 2;
menu_back(nLevel); menu_back(nLevel);
if ((eFilamentAction == FilamentAction::Load) || (eFilamentAction == FilamentAction::AutoLoad))
{ if (eFilamentAction == FilamentAction::AutoLoad) {
loading_flag = true; // loading no longer cancellable
enquecommand_P(MSG_M701); // load filament eFilamentAction = FilamentAction::Load;
if (eFilamentAction == FilamentAction::AutoLoad) eFilamentAction = FilamentAction::None; // i.e. non-autoLoad
} }
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; break;
case FilamentAction::MmuLoad: case FilamentAction::MmuLoad:
@ -1968,7 +1981,7 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed)
menu_back(); menu_back();
} }
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); 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() void lcd_generic_preheat_menu()
{ {
MENU_BEGIN(); MENU_BEGIN();
@ -3678,13 +3681,14 @@ static void lcd_wizard_load() {
// NOTE: a full screen message showing which filament is being inserted // NOTE: a full screen message showing which filament is being inserted
// is performed by M701. For this reason MSG_LOADING_FILAMENT is not // is performed by M701. For this reason MSG_LOADING_FILAMENT is not
// used here when a MMU is used. // used here when a MMU is used.
eFilamentAction = FilamentAction::MmuLoad;
} else { } else {
lcd_show_fullscreen_message_and_wait_P( 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 _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_update_enable(false);
lcd_clear(); lcd_clear();
lcd_puts_at_P(0, 2, _T(MSG_LOADING_FILAMENT)); lcd_puts_at_P(0, 2, _T(MSG_LOADING_FILAMENT));
loading_flag = true; eFilamentAction = FilamentAction::Load;
} }
// When MMU is disabled P parameter is ignored // When MMU is disabled P parameter is ignored
@ -5179,9 +5183,9 @@ static void lcd_main_menu()
} }
#endif #endif
#ifdef SDSUPPORT //!@todo SDSUPPORT undefined creates several issues in source code #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 (!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 bMain=true; // flag ('fake parameter') for 'lcd_sdcard_menu()' function
MENU_ITEM_SUBMENU_P(_T(MSG_CARD_MENU), lcd_sdcard_menu); MENU_ITEM_SUBMENU_P(_T(MSG_CARD_MENU), lcd_sdcard_menu);
} }
@ -5198,7 +5202,7 @@ static void lcd_main_menu()
} }
#endif //SDSUPPORT #endif //SDSUPPORT
if(!isPrintPaused && !printJobOngoing() && (lcd_commands_type != LcdCommands::Layer1Cal)) { if(!isPrintPaused && !printJobOngoing() && (lcd_commands_type == LcdCommands::Idle)) {
if (!farm_mode) { if (!farm_mode) {
const int8_t sheet = eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)); const int8_t sheet = eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet));
const int8_t nextSheet = eeprom_next_initialized_sheet(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.Enabled()) {
if(!MMU2::mmu2.FindaDetectsFilament() && !fsensor.getFilamentPresent()) { if(!MMU2::mmu2.FindaDetectsFilament() && !fsensor.getFilamentPresent()) {
// The MMU 'Load filament' state machine will reject the command if any // 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(!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 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) static void menu_action_sdfile(const char* filename)
{ {
loading_flag = false; if(eFilamentAction != FilamentAction::None) return;
char cmd[30]; char cmd[30];
char* c; char* c;
bool result = true; bool result = true;

View File

@ -175,17 +175,17 @@ void lcd_hw_setup_menu(void); // NOT static due to using ins
enum class FilamentAction : uint_least8_t 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, Load,
AutoLoad, AutoLoad, // triggered by insertion, cancellable until it transitions to Load
UnLoad, UnLoad,
MmuLoad, MmuLoad,
MmuUnLoad, MmuUnLoad,
MmuEject, MmuEject,
MmuCut, MmuCut,
MmuLoadingTest, MmuLoadingTest,
Preheat, Preheat, // triggered by preheat (cancellable)
Lay1Cal, Lay1Cal, // triggered by 1st layer calibration (cancellable)
}; };
extern FilamentAction eFilamentAction; extern FilamentAction eFilamentAction;