|
@@ -123,17 +123,12 @@ void fsensor_stop_and_save_print(void)
|
|
|
stop_and_save_print_to_ram(0, 0);
|
|
|
}
|
|
|
|
|
|
-void fsensor_restore_print_and_continue_IR(void)
|
|
|
+void fsensor_restore_print_and_continue(void)
|
|
|
{
|
|
|
+ printf_P(PSTR("fsensor_restore_print_and_continue\n"));
|
|
|
fsensor_watch_runout = true;
|
|
|
fsensor_err_cnt = 0;
|
|
|
fsensor_m600_enqueued = false;
|
|
|
-}
|
|
|
-
|
|
|
-void fsensor_restore_print_and_continue(void)
|
|
|
-{
|
|
|
- printf_P(PSTR("fsensor_restore_print_and_continue\n"));
|
|
|
- fsensor_restore_print_and_continue_IR();
|
|
|
restore_print_from_ram_and_continue(0);
|
|
|
}
|
|
|
|
|
@@ -527,6 +522,47 @@ void fsensor_st_block_chunk(block_t* bl, int cnt)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+inline T fsensor_clamp_z(float current_z){
|
|
|
+ T z( current_z );
|
|
|
+ if(z < T(25)){
|
|
|
+
|
|
|
+ z = T(25);
|
|
|
+ }
|
|
|
+ return z + T(FILAMENTCHANGE_ZADD);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void fsensor_enque_M600(){
|
|
|
+ printf_P(PSTR("fsensor_update - M600\n"));
|
|
|
+ eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1);
|
|
|
+ eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1);
|
|
|
+ enquecommand_front_P(PSTR("PRUSA fsensor_recover"));
|
|
|
+ fsensor_m600_enqueued = true;
|
|
|
+ enquecommand_front_P((PSTR("M600")));
|
|
|
+#define xstr(a) str(a)
|
|
|
+#define str(a) #a
|
|
|
+ static const char gcodeMove[] PROGMEM =
|
|
|
+ "G1 X" xstr(FILAMENTCHANGE_XPOS)
|
|
|
+ " Y" xstr(FILAMENTCHANGE_YPOS)
|
|
|
+ " Z%u";
|
|
|
+#undef str
|
|
|
+#undef xstr
|
|
|
+ char buf[32];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ static_assert(Z_MAX_POS < (255 - FILAMENTCHANGE_ZADD), "Z-range too high, change fsensor_clamp_z<uint8_t> to <uint16_t>");
|
|
|
+ sprintf_P(buf, gcodeMove, fsensor_clamp_z<uint8_t>(current_position[Z_AXIS]) );
|
|
|
+ enquecommand_front(buf, false);
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -535,7 +571,7 @@ void fsensor_st_block_chunk(block_t* bl, int cnt)
|
|
|
void fsensor_update(void)
|
|
|
{
|
|
|
#ifdef PAT9125
|
|
|
- if (fsensor_enabled && fsensor_watch_runout && (fsensor_err_cnt > FSENSOR_ERR_MAX))
|
|
|
+ if (fsensor_enabled && fsensor_watch_runout && (fsensor_err_cnt > FSENSOR_ERR_MAX) && ( ! fsensor_m600_enqueued) )
|
|
|
{
|
|
|
bool autoload_enabled_tmp = fsensor_autoload_enabled;
|
|
|
fsensor_autoload_enabled = false;
|
|
@@ -575,11 +611,7 @@ void fsensor_update(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- printf_P(PSTR("fsensor_update - M600\n"));
|
|
|
- eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1);
|
|
|
- eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1);
|
|
|
- enquecommand_front_P(PSTR("PRUSA fsensor_recover"));
|
|
|
- enquecommand_front_P((PSTR("M600")));
|
|
|
+ fsensor_enque_M600();
|
|
|
fsensor_watch_runout = false;
|
|
|
}
|
|
|
fsensor_autoload_enabled = autoload_enabled_tmp;
|
|
@@ -587,14 +619,9 @@ void fsensor_update(void)
|
|
|
}
|
|
|
#else
|
|
|
if ((digitalRead(IR_SENSOR_PIN) == 1) && CHECK_FSENSOR && fsensor_enabled && ir_sensor_detected && ( ! fsensor_m600_enqueued) )
|
|
|
- {
|
|
|
-
|
|
|
- printf_P(PSTR("fsensor_update - M600\n"));
|
|
|
- eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1);
|
|
|
- eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1);
|
|
|
- enquecommand_front_P(PSTR("PRUSA fsensor_recover_IR"));
|
|
|
- fsensor_m600_enqueued = true;
|
|
|
- enquecommand_front_P((PSTR("M600")));
|
|
|
+ {
|
|
|
+ fsensor_stop_and_save_print();
|
|
|
+ fsensor_enque_M600();
|
|
|
}
|
|
|
#endif
|
|
|
}
|