Переглянути джерело

finda filament runout: initial version

PavelSindler 5 роки тому
батько
коміт
ceb49d1262
5 змінених файлів з 34 додано та 3 видалено
  1. 3 0
      Firmware/Marlin.h
  2. 3 1
      Firmware/Marlin_main.cpp
  3. 10 1
      Firmware/mmu.cpp
  4. 17 0
      Firmware/planner.cpp
  5. 1 1
      Firmware/planner.h

+ 3 - 0
Firmware/Marlin.h

@@ -359,6 +359,9 @@ extern uint8_t print_percent_done_normal;
 extern uint32_t print_time_remaining_normal;
 extern uint8_t print_percent_done_silent;
 extern uint32_t print_time_remaining_silent;
+extern uint16_t mcode_in_progress;
+extern uint16_t gcode_in_progress;
+
 #define PRINT_TIME_REMAINING_INIT 0xffffffff
 #define PRINT_PERCENT_DONE_INIT   0xff
 #define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CUSTOM_MSG_TYPE_TEMCAL) || saved_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL) || card.paused || mmu_print_saved)

+ 3 - 1
Firmware/Marlin_main.cpp

@@ -3408,7 +3408,9 @@ void process_commands()
 	}
 #endif //BACKLASH_Y
 #endif //TMC2130
-
+	else if (code_seen("FSENSOR_RECOVER")) {
+		fsensor_restore_print_and_continue();
+  }
   else if(code_seen("PRUSA")){
 		if (code_seen("Ping")) {  //PRUSA Ping
 			if (farm_mode) {

+ 10 - 1
Firmware/mmu.cpp

@@ -7,6 +7,8 @@
 #include "uart2.h"
 #include "temperature.h"
 #include "Configuration_prusa.h"
+#include "fsensor.h"
+#include "cardreader.h"
 
 
 extern const char* lcd_display_message_fullscreen_P(const char *msg);
@@ -16,6 +18,7 @@ extern void lcd_return_to_status();
 extern void lcd_wait_for_heater();
 extern char choose_extruder_menu();
 
+#define CHECK_FINDA ((IS_SD_PRINTING || is_usb_printing) && (mcode_in_progress != 600) && !saved_printing && e_active())
 
 #define MMU_TODELAY 100
 #define MMU_TIMEOUT 10
@@ -182,7 +185,7 @@ void mmu_loop(void)
 			}
 			mmu_cmd = 0;
 		}
-		else if ((mmu_last_response + 1000) < millis()) //request every 1s
+		else if ((mmu_last_response + 800) < millis()) //request every 800ms
 		{
 			puts_P(PSTR("MMU <= 'P0'"));
 		    mmu_puts_P(PSTR("P0\n")); //send 'read finda' request
@@ -194,6 +197,12 @@ void mmu_loop(void)
 		{
 			fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer
 			printf_P(PSTR("MMU => '%dok'\n"), mmu_finda);
+			//printf_P(PSTR("Eact: %d\n"), int(e_active()));
+			if (!mmu_finda && CHECK_FINDA) {
+				fsensor_stop_and_save_print();
+				enquecommand_front_P(PSTR("FSENSOR_RECOVER")); //then recover
+				enquecommand_front_P(PSTR("M600")); //save print and run M600 command
+			}
 			mmu_state = 1;
 			if (mmu_cmd == 0)
 				mmu_ready = true;

+ 17 - 0
Firmware/planner.cpp

@@ -494,6 +494,23 @@ void getHighESpeed()
 }
 #endif
 
+bool e_active()
+{
+	unsigned char e_active = 0;
+	block_t *block;
+  if(block_buffer_tail != block_buffer_head)
+  {
+    uint8_t block_index = block_buffer_tail;
+    while(block_index != block_buffer_head)
+    {
+      block = &block_buffer[block_index];
+      if(block->steps_e.wide != 0) e_active++;
+      block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
+    }
+  }
+  return (e_active > 0) ? true : false ;
+}
+
 void check_axes_activity()
 {
   unsigned char x_active = 0;

+ 1 - 1
Firmware/planner.h

@@ -154,7 +154,7 @@ void plan_set_position(float x, float y, float z, const float &e);
 void plan_set_z_position(const float &z);
 void plan_set_e_position(const float &e);
 
-
+extern bool e_active();
 
 void check_axes_activity();