Browse Source

preHeat @ filament management

another funcionality II
MRprusa3d 5 years ago
parent
commit
a54c68b874
4 changed files with 111 additions and 51 deletions
  1. 1 18
      Firmware/menu.cpp
  2. 47 13
      Firmware/mmu.cpp
  3. 2 0
      Firmware/mmu.h
  4. 61 20
      Firmware/ultralcd.cpp

+ 1 - 18
Firmware/menu.cpp

@@ -16,7 +16,7 @@
 
 extern int32_t lcd_encoder;
 
-#define MENU_DEPTH_MAX       4
+#define MENU_DEPTH_MAX       6
 
 static menu_record_t menu_stack[MENU_DEPTH_MAX];
 
@@ -85,7 +85,6 @@ void menu_end(void)
 	}
 }
 
-//-//
 void menu_back(uint8_t nLevel)
 {
      menu_depth = ((menu_depth > nLevel) ? (menu_depth - nLevel) : 0);
@@ -97,17 +96,6 @@ void menu_back(void)
 menu_back(1);
 }
 
-/*
-void menu_back(void)
-{
-	if (menu_depth > 0)
-	{
-		menu_depth--;		
-		menu_goto(menu_stack[menu_depth].menu, menu_stack[menu_depth].position, true, true);
-	}
-}
-*/
-
 static void menu_back_no_reset(void)
 {
 	if (menu_depth > 0)
@@ -394,8 +382,3 @@ template uint8_t menu_item_edit_P<int16_t*>(const char* str, int16_t *pval, int1
 template uint8_t menu_item_edit_P<uint8_t*>(const char* str, uint8_t *pval, int16_t min_val, int16_t max_val);
 
 #undef _menu_data
-
-
-
-
-

+ 47 - 13
Firmware/mmu.cpp

@@ -1022,6 +1022,28 @@ void mmu_filament_ramming()
     }
 }
 
+//-//
+void extr_unload_()
+{
+//if(bFilamentAction)
+if(0)
+	{
+     bFilamentAction=false;
+     extr_unload();
+     }
+else	{
+     eFilamentAction=e_FILAMENT_ACTION_mmuUnLoad;
+     bFilamentFirstRun=false;
+     if(target_temperature[0]>=EXTRUDE_MINTEMP)
+          {
+          bFilamentPreheatState=true;
+          mFilamentItem(target_temperature[0],target_temperature_bed);
+          }
+//     else menu_submenu(mFilamentMenu);
+     else mFilamentMenu();
+	}
+}
+
 void extr_unload()
 { //unload just current filament for multimaterial printers
 #ifdef SNMM
@@ -1030,11 +1052,8 @@ void extr_unload()
 	uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
 #endif
 
-//-//	if (degHotend0() > EXTRUDE_MINTEMP)
-//if(current_temperature[0]>(target_temperature[0]*0.95))
-if(bFilamentAction)
+	if (degHotend0() > EXTRUDE_MINTEMP)
 	{
-bFilamentAction=false;
 #ifndef SNMM
 		st_synchronize();
 		
@@ -1108,13 +1127,7 @@ bFilamentAction=false;
 	}
 	else
 	{
-          eFilamentAction=e_FILAMENT_ACTION_mmuUnLoad;
-          bFilamentFirstRun=false;
-          if(target_temperature[0]>=EXTRUDE_MINTEMP) {
-               bFilamentPreheatState=true;
-               mFilamentItem(target_temperature[0],target_temperature_bed);
-          }
-          else menu_submenu(mFilamentMenu);
+		show_preheat_nozzle_warning();
 	}
 	//lcd_return_to_status();
 }
@@ -1172,51 +1185,71 @@ void extr_adj_4()
 
 void mmu_load_to_nozzle_0() 
 {
+//-//
+     menu_back();
 	lcd_mmu_load_to_nozzle(0);
 }
 
 void mmu_load_to_nozzle_1() 
 {
+//-//
+     menu_back();
 	lcd_mmu_load_to_nozzle(1);
 }
 
 void mmu_load_to_nozzle_2() 
 {
+//-//
+     menu_back();
 	lcd_mmu_load_to_nozzle(2);
 }
 
 void mmu_load_to_nozzle_3() 
 {
+//-//
+     menu_back();
 	lcd_mmu_load_to_nozzle(3);
 }
 
 void mmu_load_to_nozzle_4() 
 {
+//-//
+     menu_back();
 	lcd_mmu_load_to_nozzle(4);
 }
 
 void mmu_eject_fil_0()
 {
+//-//
+     menu_back();
 	mmu_eject_filament(0, true);
 }
 
 void mmu_eject_fil_1()
 {
+//-//
+     menu_back();
 	mmu_eject_filament(1, true);
 }
 
 void mmu_eject_fil_2()
 {
+//-//
+     menu_back();
 	mmu_eject_filament(2, true);
 }
 
 void mmu_eject_fil_3()
 {
+//-//
+     menu_back();
 	mmu_eject_filament(3, true);
 }
 
 void mmu_eject_fil_4()
 {
+//-//
+     menu_back();
 	mmu_eject_filament(4, true);
 }
 
@@ -1344,7 +1377,7 @@ void mmu_show_warning()
 void lcd_mmu_load_to_nozzle(uint8_t filament_nr)
 {
 //-//
-bFilamentAction=false;
+bFilamentAction=false;                            // NOT in "mmu_load_to_nozzle_menu()"
   if (degHotend0() > EXTRUDE_MINTEMP)
   {
 	tmp_extruder = filament_nr;
@@ -1377,7 +1410,8 @@ bFilamentAction=false;
 void mmu_eject_filament(uint8_t filament, bool recover)
 {
 //-//
-bFilamentAction=false;
+bFilamentAction=false;                            // NOT in "mmu_fil_eject_menu()"
+return;
 	if (filament < 5) 
 	{
 

+ 2 - 0
Firmware/mmu.h

@@ -101,6 +101,8 @@ extern int get_ext_nr();
 extern void display_loading();
 extern void extr_adj(int extruder);
 extern void extr_unload();
+//-//
+extern void extr_unload_();
 extern void extr_adj_0();
 extern void extr_adj_1();
 extern void extr_adj_2();

+ 61 - 20
Firmware/ultralcd.cpp

@@ -2310,6 +2310,8 @@ bool bFilamentAction=false;
 
 static void mFilamentPrompt()
 {
+uint8_t nLevel;
+
 lcd_set_cursor(0,0);
 lcdui_print_temp(LCD_STR_THERMOMETER[0],(int)degHotend(0),(int)degTargetHotend(0));
 lcd_set_cursor(0,2);
@@ -2332,14 +2334,13 @@ switch(eFilamentAction)
      }
 if(lcd_clicked())
      {
-//./     menu_back();
-//./     menu_back();
-menu_back(2);
+     nLevel=2;
      if(!bFilamentPreheatState)
           {
-          menu_back();
-//-//          setTargetHotend0(0.0);
+          nLevel++;
+//          setTargetHotend0(0.0);                  // uncoment if return to base state is required
           }
+     menu_back(nLevel);
      switch(eFilamentAction)
           {
           case e_FILAMENT_ACTION_Load:
@@ -2350,20 +2351,27 @@ menu_back(2);
           case e_FILAMENT_ACTION_unLoad:
                enquecommand_P(PSTR("M702"));      // unload filament
                break;
+/*
           case e_FILAMENT_ACTION_mmuLoad:
-  MYSERIAL.println("mFilamentPrompt - mmuLoad");
-bFilamentAction=true;
+//./  MYSERIAL.println("mFilamentPrompt - mmuLoad");
+               bFilamentAction=true;
                menu_submenu(mmu_load_to_nozzle_menu);
                break;
+*/
+/*
           case e_FILAMENT_ACTION_mmuUnLoad:
-bFilamentAction=true;
+//./  MYSERIAL.println("mFilamentPrompt - mmuUnLoad");
+               bFilamentAction=true;
                extr_unload();
                break;
+*/
+/*
           case e_FILAMENT_ACTION_mmuEject:
   MYSERIAL.println("mFilamentPrompt - mmuEject");
-bFilamentAction=true;
-               menu_submenu(mmu_fil_eject_menu);
+               bFilamentAction=true;
+//               menu_submenu(mmu_fil_eject_menu);
                break;
+*/
           }
      if(eFilamentAction==e_FILAMENT_ACTION_autoLoad)
           eFilamentAction=e_FILAMENT_ACTION_none; // i.e. non-autoLoad
@@ -2373,6 +2381,8 @@ bFilamentAction=true;
 void mFilamentItem(uint16_t nTemp,uint16_t nTempBed)
 {
 static int nTargetOld,nTargetBedOld;
+uint8_t nLevel;
+static bool bBeep=false;
 
 //if(bPreheatState)                                 // not necessary
      nTargetOld=target_temperature[0];
@@ -2416,12 +2426,47 @@ if(lcd_clicked())
      if(eFilamentAction==e_FILAMENT_ACTION_autoLoad)
           eFilamentAction=e_FILAMENT_ACTION_none; // i.e. non-autoLoad
      }
-//./else if(!isHeatingHotend0())
-else if(current_temperature[0]>(target_temperature[0]*0.95))
+else {
+     if(current_temperature[0]>(target_temperature[0]*0.95))
           {
-          menu_submenu(mFilamentPrompt);
-          Sound_MakeSound(e_SOUND_TYPE_StandardPrompt);
+          switch(eFilamentAction)
+               {
+               case e_FILAMENT_ACTION_Load:
+               case e_FILAMENT_ACTION_autoLoad:
+               case e_FILAMENT_ACTION_unLoad:
+                    menu_submenu(mFilamentPrompt);
+                    break;
+               case e_FILAMENT_ACTION_mmuLoad:
+                    nLevel=1;
+                    if(!bFilamentPreheatState)
+                         nLevel++;
+                    bFilamentAction=true;
+                    menu_back(nLevel);
+                    menu_submenu(mmu_load_to_nozzle_menu);
+                    break;
+               case e_FILAMENT_ACTION_mmuUnLoad:
+                    nLevel=1;
+                    if(!bFilamentPreheatState)
+                         nLevel++;
+                    bFilamentAction=true;
+                    menu_back(nLevel);
+                    extr_unload();
+                    break;
+               case e_FILAMENT_ACTION_mmuEject:
+                    nLevel=1;
+                    if(!bFilamentPreheatState)
+                         nLevel++;
+                    bFilamentAction=true;
+                    menu_back(nLevel);
+                    menu_submenu(mmu_fil_eject_menu);
+                    break;
+               }
+          if(bBeep)
+               Sound_MakeSound(e_SOUND_TYPE_StandardPrompt);
+          bBeep=false;
           }
+     else bBeep=true;
+     }
 }
 
 static void mFilamentItem_PLA()
@@ -5643,10 +5688,8 @@ static void fil_load_menu()
 static void mmu_load_to_nozzle_menu()
 {
 //-//if (degHotend0() > EXTRUDE_MINTEMP)
-//if(current_temperature[0]>(target_temperature[0]*0.95))
 if(bFilamentAction)
 {
-//../bFilamentAction=false;
 	MENU_BEGIN();
 	MENU_ITEM_BACK_P(_T(MSG_MAIN));
 	MENU_ITEM_FUNCTION_P(_i("Load filament 1"), mmu_load_to_nozzle_0);
@@ -5671,10 +5714,8 @@ else {
 static void mmu_fil_eject_menu()
 {
 //-//if (degHotend0() > EXTRUDE_MINTEMP)
-//if(current_temperature[0]>(target_temperature[0]*0.95))
 if(bFilamentAction)
 {
-//../bFilamentAction=false;
 	MENU_BEGIN();
 	MENU_ITEM_BACK_P(_T(MSG_MAIN));
 	MENU_ITEM_FUNCTION_P(_i("Eject filament 1"), mmu_eject_fil_0);
@@ -5685,7 +5726,6 @@ if(bFilamentAction)
 	MENU_END();
 }
 else {
-  MYSERIAL.println("   eject - else");
      eFilamentAction=e_FILAMENT_ACTION_mmuEject;
      bFilamentFirstRun=false;
      if(target_temperature[0]>=EXTRUDE_MINTEMP)
@@ -6166,7 +6206,8 @@ static void lcd_main_menu()
 		MENU_ITEM_SUBMENU_P(_T(MSG_LOAD_FILAMENT), fil_load_menu);
 		MENU_ITEM_SUBMENU_P(_i("Load to nozzle"), mmu_load_to_nozzle_menu);
 //-//          MENU_ITEM_FUNCTION_P(_T(MSG_UNLOAD_FILAMENT), extr_unload);
-          MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), extr_unload);
+//bFilamentFirstRun=true;
+          MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), extr_unload_);
 		MENU_ITEM_SUBMENU_P(_i("Eject filament"), mmu_fil_eject_menu);
 	}
 	else