Reuse FSensor runout blocking impl. throughout the whole FW
This commit is contained in:
parent
eed816d9de
commit
0e75a03c8c
|
|
@ -11,6 +11,18 @@
|
||||||
#include "ultralcd.h"
|
#include "ultralcd.h"
|
||||||
|
|
||||||
#ifdef FILAMENT_SENSOR
|
#ifdef FILAMENT_SENSOR
|
||||||
|
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
|
# 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
|
||||||
|
|
@ -18,6 +30,10 @@ 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,14 +3573,8 @@ 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
|
||||||
|
{
|
||||||
#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
|
|
||||||
|
|
||||||
if (!MMU2::mmu2.Enabled()) {
|
if (!MMU2::mmu2.Enabled()) {
|
||||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||||
|
|
@ -3647,9 +3641,7 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float
|
||||||
sprintf_P(cmd, PSTR("M220 S%i"), feedmultiplyBckp);
|
sprintf_P(cmd, PSTR("M220 S%i"), feedmultiplyBckp);
|
||||||
enquecommand(cmd);
|
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