Reuse FSensor runout blocking impl. throughout the whole FW
This commit is contained in:
parent
eed816d9de
commit
0e75a03c8c
|
|
@ -11,13 +11,29 @@
|
||||||
#include "ultralcd.h"
|
#include "ultralcd.h"
|
||||||
|
|
||||||
#ifdef FILAMENT_SENSOR
|
#ifdef FILAMENT_SENSOR
|
||||||
#if FILAMENT_SENSOR_TYPE == FSENSOR_IR
|
FSensorBlockRunout::FSensorBlockRunout() {
|
||||||
|
fsensor.setRunoutEnabled(false); //suppress filament runouts while loading filament.
|
||||||
|
fsensor.setAutoLoadEnabled(false); //suppress filament autoloads while loading filament.
|
||||||
|
#if (FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
|
||||||
|
fsensor.setJamDetectionEnabled(false); //suppress filament jam detection while loading filament.
|
||||||
|
#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
|
||||||
|
}
|
||||||
|
|
||||||
|
FSensorBlockRunout::~FSensorBlockRunout() {
|
||||||
|
fsensor.settings_init(); // restore filament runout state.
|
||||||
|
}
|
||||||
|
|
||||||
|
# if FILAMENT_SENSOR_TYPE == FSENSOR_IR
|
||||||
IR_sensor fsensor;
|
IR_sensor fsensor;
|
||||||
#elif FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG
|
# elif FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG
|
||||||
IR_sensor_analog fsensor;
|
IR_sensor_analog fsensor;
|
||||||
#elif FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125
|
# elif FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125
|
||||||
PAT9125_sensor fsensor;
|
PAT9125_sensor fsensor;
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
|
#else // FILAMENT_SENSOR
|
||||||
|
FSensorBlockRunout::FSensorBlockRunout() { }
|
||||||
|
FSensorBlockRunout::~FSensorBlockRunout() { }
|
||||||
#endif // FILAMENT_SENSOR
|
#endif // FILAMENT_SENSOR
|
||||||
|
|
||||||
void Filament_sensor::setEnabled(bool enabled) {
|
void Filament_sensor::setEnabled(bool enabled) {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,15 @@
|
||||||
#define FSENSOR_IR_ANALOG 2
|
#define FSENSOR_IR_ANALOG 2
|
||||||
#define FSENSOR_PAT9125 3
|
#define FSENSOR_PAT9125 3
|
||||||
|
|
||||||
|
/// Can be used to block printer's filament sensor handling - to avoid errorneous injecting of M600
|
||||||
|
/// while doing a toolchange with the MMU
|
||||||
|
/// In case of "no filament sensor" these methods default to an empty implementation
|
||||||
|
class FSensorBlockRunout {
|
||||||
|
public:
|
||||||
|
FSensorBlockRunout();
|
||||||
|
~FSensorBlockRunout();
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef FILAMENT_SENSOR
|
#ifdef FILAMENT_SENSOR
|
||||||
class Filament_sensor {
|
class Filament_sensor {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -3573,84 +3573,76 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float
|
||||||
else
|
else
|
||||||
unload_filament(true); // unload filament for single material (used also in M702)
|
unload_filament(true); // unload filament for single material (used also in M702)
|
||||||
st_synchronize(); // finish moves
|
st_synchronize(); // finish moves
|
||||||
|
{
|
||||||
|
FSensorBlockRunout fsBlockRunout;
|
||||||
|
|
||||||
#ifdef FILAMENT_SENSOR
|
if (!MMU2::mmu2.Enabled()) {
|
||||||
fsensor.setRunoutEnabled(false); //suppress filament runouts while loading filament.
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||||
fsensor.setAutoLoadEnabled(false); //suppress filament autoloads while loading filament.
|
lcd_change_fil_state =
|
||||||
#if (FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
|
lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Was filament unload successful?"), false, LCD_LEFT_BUTTON_CHOICE); ////MSG_UNLOAD_SUCCESSFUL c=20 r=2
|
||||||
fsensor.setJamDetectionEnabled(false); //suppress filament jam detection while loading filament.
|
if (lcd_change_fil_state == LCD_MIDDLE_BUTTON_CHOICE) {
|
||||||
#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!MMU2::mmu2.Enabled()) {
|
|
||||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
|
||||||
lcd_change_fil_state =
|
|
||||||
lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Was filament unload successful?"), false, LCD_LEFT_BUTTON_CHOICE); ////MSG_UNLOAD_SUCCESSFUL c=20 r=2
|
|
||||||
if (lcd_change_fil_state == LCD_MIDDLE_BUTTON_CHOICE) {
|
|
||||||
lcd_clear();
|
|
||||||
lcd_puts_at_P(0, 2, _T(MSG_PLEASE_WAIT));
|
|
||||||
current_position[X_AXIS] -= 100;
|
|
||||||
plan_buffer_line_curposXYZE(FILAMENTCHANGE_XYFEED);
|
|
||||||
st_synchronize();
|
|
||||||
lcd_show_fullscreen_message_and_wait_P(_i("Please open idler and remove filament manually.")); ////MSG_CHECK_IDLER c=20 r=5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MMU2::mmu2.Enabled()) {
|
|
||||||
if (!automatic) {
|
|
||||||
if (saved_printing){
|
|
||||||
// if M600 was invoked by filament senzor (FINDA) eject filament so user can easily remove it
|
|
||||||
MMU2::mmu2.eject_filament(MMU2::mmu2.get_current_tool(), false);
|
|
||||||
}
|
|
||||||
mmu_M600_wait_and_beep();
|
|
||||||
if (saved_printing) {
|
|
||||||
lcd_clear();
|
lcd_clear();
|
||||||
lcd_puts_at_P(0, 2, _T(MSG_PLEASE_WAIT));
|
lcd_puts_at_P(0, 2, _T(MSG_PLEASE_WAIT));
|
||||||
//@@TODO mmu_command(MmuCmd::R0);
|
current_position[X_AXIS] -= 100;
|
||||||
// manage_response(false, false);
|
plan_buffer_line_curposXYZE(FILAMENTCHANGE_XYFEED);
|
||||||
|
st_synchronize();
|
||||||
|
lcd_show_fullscreen_message_and_wait_P(_i("Please open idler and remove filament manually.")); ////MSG_CHECK_IDLER c=20 r=5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mmu_M600_load_filament(automatic, HotendTempBckp);
|
|
||||||
} else
|
|
||||||
M600_load_filament();
|
|
||||||
|
|
||||||
if (!automatic)
|
if (MMU2::mmu2.Enabled()) {
|
||||||
M600_check_state(HotendTempBckp);
|
if (!automatic) {
|
||||||
|
if (saved_printing){
|
||||||
|
// if M600 was invoked by filament senzor (FINDA) eject filament so user can easily remove it
|
||||||
|
MMU2::mmu2.eject_filament(MMU2::mmu2.get_current_tool(), false);
|
||||||
|
}
|
||||||
|
mmu_M600_wait_and_beep();
|
||||||
|
if (saved_printing) {
|
||||||
|
lcd_clear();
|
||||||
|
lcd_puts_at_P(0, 2, _T(MSG_PLEASE_WAIT));
|
||||||
|
//@@TODO mmu_command(MmuCmd::R0);
|
||||||
|
// manage_response(false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mmu_M600_load_filament(automatic, HotendTempBckp);
|
||||||
|
} else
|
||||||
|
M600_load_filament();
|
||||||
|
|
||||||
lcd_update_enable(true);
|
if (!automatic)
|
||||||
|
M600_check_state(HotendTempBckp);
|
||||||
|
|
||||||
// Not let's go back to print
|
lcd_update_enable(true);
|
||||||
fanSpeed = fanSpeedBckp;
|
|
||||||
|
// Not let's go back to print
|
||||||
|
fanSpeed = fanSpeedBckp;
|
||||||
|
|
||||||
|
// Feed a little of filament to stabilize pressure
|
||||||
|
if (!automatic) {
|
||||||
|
current_position[E_AXIS] += FILAMENTCHANGE_RECFEED;
|
||||||
|
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EXFEED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move XY back
|
||||||
|
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_XYFEED, active_extruder);
|
||||||
|
st_synchronize();
|
||||||
|
// Move Z back
|
||||||
|
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_ZFEED, active_extruder);
|
||||||
|
st_synchronize();
|
||||||
|
|
||||||
|
// Set E position to original
|
||||||
|
plan_set_e_position(lastpos[E_AXIS]);
|
||||||
|
|
||||||
|
memcpy(current_position, lastpos, sizeof(lastpos));
|
||||||
|
set_destination_to_current();
|
||||||
|
|
||||||
|
// Recover feed rate
|
||||||
|
feedmultiply = feedmultiplyBckp;
|
||||||
|
char cmd[9];
|
||||||
|
sprintf_P(cmd, PSTR("M220 S%i"), feedmultiplyBckp);
|
||||||
|
enquecommand(cmd);
|
||||||
|
|
||||||
// Feed a little of filament to stabilize pressure
|
|
||||||
if (!automatic) {
|
|
||||||
current_position[E_AXIS] += FILAMENTCHANGE_RECFEED;
|
|
||||||
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EXFEED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move XY back
|
|
||||||
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_XYFEED, active_extruder);
|
|
||||||
st_synchronize();
|
|
||||||
// Move Z back
|
|
||||||
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_ZFEED, active_extruder);
|
|
||||||
st_synchronize();
|
|
||||||
|
|
||||||
// Set E position to original
|
|
||||||
plan_set_e_position(lastpos[E_AXIS]);
|
|
||||||
|
|
||||||
memcpy(current_position, lastpos, sizeof(lastpos));
|
|
||||||
set_destination_to_current();
|
|
||||||
|
|
||||||
// Recover feed rate
|
|
||||||
feedmultiply = feedmultiplyBckp;
|
|
||||||
char cmd[9];
|
|
||||||
sprintf_P(cmd, PSTR("M220 S%i"), feedmultiplyBckp);
|
|
||||||
enquecommand(cmd);
|
|
||||||
|
|
||||||
#ifdef FILAMENT_SENSOR
|
|
||||||
fsensor.settings_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
lcd_setstatuspgm(MSG_WELCOME);
|
lcd_setstatuspgm(MSG_WELCOME);
|
||||||
custom_message_type = CustomMsg::Status;
|
custom_message_type = CustomMsg::Status;
|
||||||
}
|
}
|
||||||
|
|
@ -3658,16 +3650,9 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float
|
||||||
void gcode_M701(uint8_t mmuSlotIndex){
|
void gcode_M701(uint8_t mmuSlotIndex){
|
||||||
printf_P(PSTR("gcode_M701 begin\n"));
|
printf_P(PSTR("gcode_M701 begin\n"));
|
||||||
|
|
||||||
#ifdef FILAMENT_SENSOR
|
FSensorBlockRunout fsBlockRunout;
|
||||||
fsensor.setRunoutEnabled(false); // suppress filament runouts while loading filament.
|
|
||||||
fsensor.setAutoLoadEnabled(false); // suppress filament autoloads while loading filament.
|
|
||||||
#if (FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
|
|
||||||
fsensor.setJamDetectionEnabled(false); // suppress filament jam detection while loading filament.
|
|
||||||
#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
prusa_statistics(22);
|
prusa_statistics(22);
|
||||||
}
|
|
||||||
|
|
||||||
if (MMU2::mmu2.Enabled() && mmuSlotIndex < MMU_FILAMENT_COUNT) {
|
if (MMU2::mmu2.Enabled() && mmuSlotIndex < MMU_FILAMENT_COUNT) {
|
||||||
MMU2::mmu2.load_filament(mmuSlotIndex); // loads current extruder
|
MMU2::mmu2.load_filament(mmuSlotIndex); // loads current extruder
|
||||||
|
|
@ -3705,10 +3690,6 @@ void gcode_M701(uint8_t mmuSlotIndex){
|
||||||
}
|
}
|
||||||
|
|
||||||
eFilamentAction = FilamentAction::None;
|
eFilamentAction = FilamentAction::None;
|
||||||
|
|
||||||
#ifdef FILAMENT_SENSOR
|
|
||||||
fsensor.settings_init(); // restore filament runout state.
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Get serial number from 32U2 processor
|
* @brief Get serial number from 32U2 processor
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ bool MMU2::tool_change(uint8_t index) {
|
||||||
|
|
||||||
if (index != extruder) {
|
if (index != extruder) {
|
||||||
ReportingRAII rep(CommandInProgress::ToolChange);
|
ReportingRAII rep(CommandInProgress::ToolChange);
|
||||||
BlockRunoutRAII blockRunout;
|
FSensorBlockRunout blockRunout;
|
||||||
|
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
|
|
||||||
|
|
@ -227,7 +227,7 @@ bool MMU2::tool_change(char code, uint8_t slot) {
|
||||||
if( ! WaitForMMUReady())
|
if( ! WaitForMMUReady())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BlockRunoutRAII blockRunout;
|
FSensorBlockRunout blockRunout;
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case '?': {
|
case '?': {
|
||||||
|
|
@ -333,7 +333,7 @@ bool MMU2::load_filament_to_nozzle(uint8_t index) {
|
||||||
{
|
{
|
||||||
// used for MMU-menu operation "Load to Nozzle"
|
// used for MMU-menu operation "Load to Nozzle"
|
||||||
ReportingRAII rep(CommandInProgress::ToolChange);
|
ReportingRAII rep(CommandInProgress::ToolChange);
|
||||||
BlockRunoutRAII blockRunout;
|
FSensorBlockRunout blockRunout;
|
||||||
|
|
||||||
if( extruder != MMU2_NO_TOOL ){ // we already have some filament loaded - free it + shape its tip properly
|
if( extruder != MMU2_NO_TOOL ){ // we already have some filament loaded - free it + shape its tip properly
|
||||||
filament_ramming();
|
filament_ramming();
|
||||||
|
|
|
||||||
|
|
@ -7,21 +7,4 @@ FilamentState WhereIsFilament(){
|
||||||
return fsensor.getFilamentPresent() ? FilamentState::AT_FSENSOR : FilamentState::NOT_PRESENT;
|
return fsensor.getFilamentPresent() ? FilamentState::AT_FSENSOR : FilamentState::NOT_PRESENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BlockRunoutRAII::BlockRunoutRAII() {
|
|
||||||
#ifdef FILAMENT_SENSOR
|
|
||||||
fsensor.setRunoutEnabled(false); //suppress filament runouts while loading filament.
|
|
||||||
fsensor.setAutoLoadEnabled(false); //suppress filament autoloads while loading filament.
|
|
||||||
#if (FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
|
|
||||||
fsensor.setJamDetectionEnabled(false); //suppress filament jam detection while loading filament.
|
|
||||||
#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockRunoutRAII::~BlockRunoutRAII() {
|
|
||||||
#ifdef FILAMENT_SENSOR
|
|
||||||
fsensor.settings_init(); // restore filament runout state.
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace MMU2
|
} // namespace MMU2
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "Filament_sensor.h"
|
||||||
|
|
||||||
namespace MMU2 {
|
namespace MMU2 {
|
||||||
|
|
||||||
|
|
@ -13,12 +14,4 @@ enum class FilamentState : uint_fast8_t {
|
||||||
|
|
||||||
FilamentState WhereIsFilament();
|
FilamentState WhereIsFilament();
|
||||||
|
|
||||||
/// Can be used to block printer's filament sensor handling - to avoid errorneous injecting of M600
|
|
||||||
/// while doing a toolchange with the MMU
|
|
||||||
class BlockRunoutRAII {
|
|
||||||
public:
|
|
||||||
BlockRunoutRAII();
|
|
||||||
~BlockRunoutRAII();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace MMU2
|
} // namespace MMU2
|
||||||
|
|
|
||||||
|
|
@ -5196,14 +5196,7 @@ void unload_filament(bool automatic)
|
||||||
custom_message_type = CustomMsg::FilamentLoading;
|
custom_message_type = CustomMsg::FilamentLoading;
|
||||||
lcd_setstatuspgm(_T(MSG_UNLOADING_FILAMENT));
|
lcd_setstatuspgm(_T(MSG_UNLOADING_FILAMENT));
|
||||||
|
|
||||||
#ifdef FILAMENT_SENSOR
|
FSensorBlockRunout fsBlockRunout;
|
||||||
fsensor.setRunoutEnabled(false); //suppress filament runouts while loading filament.
|
|
||||||
fsensor.setAutoLoadEnabled(false); //suppress filament autoloads while loading filament.
|
|
||||||
#if (FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
|
|
||||||
fsensor.setJamDetectionEnabled(false); //suppress filament jam detection while loading filament.
|
|
||||||
#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
raise_z_above(automatic? MIN_Z_FOR_SWAP: MIN_Z_FOR_UNLOAD);
|
raise_z_above(automatic? MIN_Z_FOR_SWAP: MIN_Z_FOR_UNLOAD);
|
||||||
|
|
||||||
// extr_unload2();
|
// extr_unload2();
|
||||||
|
|
@ -5241,10 +5234,6 @@ void unload_filament(bool automatic)
|
||||||
custom_message_type = CustomMsg::Status;
|
custom_message_type = CustomMsg::Status;
|
||||||
|
|
||||||
eFilamentAction = FilamentAction::None;
|
eFilamentAction = FilamentAction::None;
|
||||||
|
|
||||||
#ifdef FILAMENT_SENSOR
|
|
||||||
fsensor.settings_init(); //restore filament runout state.
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "xflash.h"
|
#include "xflash.h"
|
||||||
|
|
@ -6209,8 +6198,7 @@ void printf_IRSensorAnalogBoardChange(){
|
||||||
static bool lcd_selftest_IRsensor(bool bStandalone)
|
static bool lcd_selftest_IRsensor(bool bStandalone)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
fsensor.setAutoLoadEnabled(false);
|
FSensorBlockRunout fsBlockRunout;
|
||||||
fsensor.setRunoutEnabled(false);
|
|
||||||
IR_sensor_analog::SensorRevision oldSensorRevision = fsensor.getSensorRevision();
|
IR_sensor_analog::SensorRevision oldSensorRevision = fsensor.getSensorRevision();
|
||||||
IR_sensor_analog::SensorRevision newSensorRevision;
|
IR_sensor_analog::SensorRevision newSensorRevision;
|
||||||
uint16_t volt_IR_int = fsensor.getVoltRaw();
|
uint16_t volt_IR_int = fsensor.getVoltRaw();
|
||||||
|
|
@ -6236,7 +6224,6 @@ static bool lcd_selftest_IRsensor(bool bStandalone)
|
||||||
}
|
}
|
||||||
ret = true;
|
ret = true;
|
||||||
exit:
|
exit:
|
||||||
fsensor.settings_init();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue