Skip to content

Commit

Permalink
More to exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
3d-gussner committed Dec 30, 2024
1 parent 427eac9 commit e97409a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 12 deletions.
18 changes: 14 additions & 4 deletions Firmware/Filament_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ void Filament_sensor::settings_init_common() {
state = enabled ? State::initializing : State::disabled;
}

#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
autoLoadEnabled = eeprom_read_byte((uint8_t *)EEPROM_FSENS_AUTOLOAD_ENABLED);
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
runoutEnabled = eeprom_read_byte((uint8_t *)EEPROM_FSENS_RUNOUT_ENABLED);
sensorActionOnError = (SensorActionOnError)eeprom_read_byte((uint8_t *)EEPROM_FSENSOR_ACTION_NA);
if (sensorActionOnError == SensorActionOnError::_Undef) {
Expand All @@ -100,19 +102,22 @@ bool Filament_sensor::checkFilamentEvents() {
if (oldFilamentPresent != newFilamentPresent) {
oldFilamentPresent = newFilamentPresent;
eventBlankingTimer.start();
if (newFilamentPresent) { // filament insertion
if (!newFilamentPresent) { // filament removed
// puts_P(PSTR("filament removed"));
triggerFilamentRemoved();
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
} else { // filament removal
// puts_P(PSTR("filament inserted"));
triggerFilamentInserted();
postponedLoadEvent = true;
} else { // filament removal
// puts_P(PSTR("filament removed"));
triggerFilamentRemoved();
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
}
return true;
}
return false;
}

#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
void Filament_sensor::triggerFilamentInserted() {
if (autoLoadEnabled
&& (eFilamentAction == FilamentAction::None)
Expand All @@ -127,6 +132,7 @@ void Filament_sensor::triggerFilamentInserted() {
menu_submenu(lcd_AutoLoadFilament, true);
}
}
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY

void Filament_sensor::triggerFilamentRemoved() {
// SERIAL_ECHOLNPGM("triggerFilamentRemoved");
Expand Down Expand Up @@ -155,7 +161,9 @@ void Filament_sensor::filRunout() {
// SERIAL_ECHOLNPGM("filRunout");
sendHostNotification_P(MSG_FILAMENT_RUNOUT_DETECTED);
runoutEnabled = false;
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
autoLoadEnabled = false;
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
stop_and_save_print_to_ram(0, 0);
restore_print_from_ram_and_continue(0);
eeprom_increment_byte((uint8_t *)EEPROM_FERROR_COUNT);
Expand Down Expand Up @@ -459,7 +467,9 @@ void PAT9125_sensor::resetStepCount() {

void PAT9125_sensor::filJam() {
runoutEnabled = false;
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
autoLoadEnabled = false;
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
jamDetection = false;
stop_and_save_print_to_ram(0, 0);
restore_print_from_ram_and_continue(0);
Expand Down
4 changes: 4 additions & 0 deletions Firmware/Filament_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ class Filament_sensor {

bool checkFilamentEvents();

#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
void triggerFilamentInserted();
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY

void triggerFilamentRemoved();

Expand All @@ -77,7 +79,9 @@ class Filament_sensor {
void triggerError();

State state;
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
bool autoLoadEnabled;
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
bool runoutEnabled;
bool oldFilamentPresent; //for creating filament presence switching events.
bool postponedLoadEvent; //this event lasts exactly one update cycle. It is long enough to be able to do polling for load event.
Expand Down
25 changes: 19 additions & 6 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,9 @@ bool shouldPreheatOnlyNozzle() {

switch(eFilamentAction) {
case FilamentAction::Load:
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
case FilamentAction::AutoLoad:
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
case FilamentAction::UnLoad:
case FilamentAction::MmuLoad:
case FilamentAction::MmuUnLoad:
Expand Down Expand Up @@ -1804,7 +1806,9 @@ static void mFilamentPrompt() {
lcd_set_cursor(0,2);
switch(eFilamentAction) {
case FilamentAction::Load:
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
case FilamentAction::AutoLoad:
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
case FilamentAction::MmuLoad:
case FilamentAction::MmuLoadingTest:
lcd_puts_P(_T(MSG_TO_LOAD_FIL));
Expand All @@ -1824,15 +1828,21 @@ static void mFilamentPrompt() {
if(lcd_clicked()
#ifdef FILAMENT_SENSOR
/// @todo leptun - add this as a specific retest item
|| (((eFilamentAction == FilamentAction::Load) || (eFilamentAction == FilamentAction::AutoLoad)) && fsensor.getFilamentLoadEvent())
|| (((eFilamentAction == FilamentAction::Load)
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
|| (eFilamentAction == FilamentAction::AutoLoad)
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
) && fsensor.getFilamentLoadEvent())
#endif //FILAMENT_SENSOR
) {
menu_back(bFilamentPreheatState ? 2 : 3);
switch(eFilamentAction) {
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
case FilamentAction::AutoLoad:
// loading no longer cancellable
eFilamentAction = FilamentAction::Load;
[[fallthrough]];
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
case FilamentAction::Load:
enquecommand_P(MSG_M701); // load filament
break;
Expand Down Expand Up @@ -1901,17 +1911,20 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed)
switch (eFilamentAction)
{
case FilamentAction::Load:
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
case FilamentAction::AutoLoad:
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
case FilamentAction::UnLoad:
if (bFilamentWaitingFlag) menu_submenu(mFilamentPrompt, true);
else
{
mFilamentResetMenuStack();
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
if (eFilamentAction == FilamentAction::AutoLoad) {
// loading no longer cancellable
eFilamentAction = FilamentAction::Load;
}

#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
if (eFilamentAction == FilamentAction::Load)
enquecommand_P(MSG_M701); // load filament
else if (eFilamentAction == FilamentAction::UnLoad)
Expand Down Expand Up @@ -1983,7 +1996,9 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed)
switch (eFilamentAction)
{
case FilamentAction::Load:
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
case FilamentAction::AutoLoad:
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
case FilamentAction::MmuLoad:
case FilamentAction::MmuLoadingTest:
lcd_puts_P(_T(MSG_PREHEATING_TO_LOAD));
Expand Down Expand Up @@ -2308,10 +2323,11 @@ static void lcd_LoadFilament()
preheat_or_continue(FilamentAction::Load);
}

#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
void lcd_AutoLoadFilament() {
preheat_or_continue(FilamentAction::AutoLoad);
}

#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY

//! @brief Show filament used a print time
//!
Expand Down Expand Up @@ -5322,9 +5338,6 @@ static void lcd_main_menu()
} else {
#ifdef FILAMENT_SENSOR
if (fsensor.isEnabled()) {
// if (!fsensor.getAutoLoadEnabled()) {
// MENU_ITEM_SUBMENU_P(_T(MSG_LOAD_FILAMENT), lcd_LoadFilament);
// }
if (!fsensor.getFilamentPresent()) {
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
if (fsensor.getAutoLoadEnabled()) {
Expand Down
5 changes: 4 additions & 1 deletion Firmware/ultralcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ enum class FilamentAction : uint_least8_t
{
None, // no filament action is taking place
Load,
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
AutoLoad, // triggered by insertion, cancellable until it transitions to Load
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
UnLoad,
MmuLoad,
MmuUnLoad,
Expand All @@ -197,8 +199,9 @@ extern FilamentAction eFilamentAction;
void mFilamentItem(uint16_t nTemp,uint16_t nTempBed);
void lcd_generic_preheat_menu();
void unload_filament(float unloadLength);
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
void lcd_AutoLoadFilament();

#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY

void lcd_wait_for_heater();
void lcd_wait_for_cool_down();
Expand Down
2 changes: 1 addition & 1 deletion Firmware/variants/MK3S.h
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,6 @@
*------------------------------------*/

//Uncomment to remove the "AutoLoad filament" LCD menu entry if autoload is enabled.
//#define REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
#define REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY

#endif //__CONFIGURATION_PRUSA_H

0 comments on commit e97409a

Please sign in to comment.