Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IFNDEF more code that is releated to Filament Autoload #1

Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Firmware/Filament_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#ifdef FILAMENT_SENSOR
FSensorBlockRunout::FSensorBlockRunout() {
fsensor.setRunoutEnabled(false); //suppress filament runouts while loading filament.
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
fsensor.setAutoLoadEnabled(false); //suppress filament autoloads while loading filament.
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
#if (FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
fsensor.setJamDetectionEnabled(false); //suppress filament jam detection while loading filament.
#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
Expand Down Expand Up @@ -50,12 +52,14 @@ void Filament_sensor::setEnabled(bool enabled) {
}
}

#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
void Filament_sensor::setAutoLoadEnabled(bool state, bool updateEEPROM) {
autoLoadEnabled = state;
if (updateEEPROM) {
eeprom_update_byte_notify((uint8_t *)EEPROM_FSENS_AUTOLOAD_ENABLED, state);
}
}
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY

void Filament_sensor::setRunoutEnabled(bool state, bool updateEEPROM) {
runoutEnabled = state;
Expand Down
2 changes: 2 additions & 0 deletions Firmware/Filament_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ class Filament_sensor {

static void setEnabled(bool enabled);

#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
void setAutoLoadEnabled(bool state, bool updateEEPROM = false);
bool getAutoLoadEnabled() const { return autoLoadEnabled; }
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
Comment on lines +49 to +52
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the correct approach, you're disabling too much. These functions are not just used for the Autoload menu item. It's used by triggerFilamentInserted() too for normal autoload functionality.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually these shouldn't be used when autoload is disabled. There in the 3rd commit I removed even more code and tested it with MK404

  • MK3S
  • MK3S + MMU
  • MK2.5S


void setRunoutEnabled(bool state, bool updateEEPROM = false);
bool getRunoutEnabled() const { return runoutEnabled; }
Expand Down
4 changes: 4 additions & 0 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,9 @@ void debug_printer_states()
printf_P(PSTR("DBG:fsensor.getFilamentPresent() = %d\n"), (int)fsensor.getFilamentPresent());
printf_P(PSTR("DBG:MMU CUTTER ENABLED = %d\n"), (int)eeprom_read_byte((uint8_t*)EEPROM_MMU_CUTTER_ENABLED));
printf_P(PSTR("DBG:fsensor.isEnabled() = %d\n"), (int)fsensor.isEnabled());
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
printf_P(PSTR("DBG:fsensor.getAutoLoadEnabled() = %d\n"), (int)fsensor.getAutoLoadEnabled());
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
printf_P(PSTR("DBG:custom_message_type = %d\n"), (int)custom_message_type);
printf_P(PSTR("DBG:uvlo_auto_recovery_ready = %d\n"), (int)uvlo_auto_recovery_ready);
SERIAL_ECHOLN("");
Expand Down Expand Up @@ -769,7 +771,9 @@ static void factory_reset(char level)

#ifdef FILAMENT_SENSOR
fsensor.setEnabled(true);
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
fsensor.setAutoLoadEnabled(true, true);
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
fsensor.setRunoutEnabled(true, true);
#if (FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
fsensor.setJamDetectionEnabled(true, true);
Expand Down
2 changes: 2 additions & 0 deletions Firmware/Prusa_farm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,9 @@ void farm_mode_init() {
#ifdef FILAMENT_SENSOR
//to be converted to Filament_sensor.h...
//disabled filament autoload (PFW360)
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
fsensor.setAutoLoadEnabled(false);
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
#endif //FILAMENT_SENSOR
// ~ FanCheck -> on
eeprom_update_byte_notify((uint8_t*)EEPROM_FAN_CHECK_ENABLED, true);
Expand Down
2 changes: 1 addition & 1 deletion Firmware/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ extern const char MSG_NOT_LOADED [] PROGMEM_I1 = ISTR("Filament not loaded"); //
extern const char MSG_NOT_COLOR [] PROGMEM_I1 = ISTR("Color not correct"); ////MSG_NOT_COLOR c=19
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
extern const char MSG_AUTOLOADING_ENABLED [] PROGMEM_I1 = ISTR("Autoloading filament is active, just press the knob and insert filament..."); ////MSG_AUTOLOADING_ENABLED c=20 r=4
#endif //REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
extern const char MSG_FILAMENT_USED [] PROGMEM_I1 = ISTR("Filament used"); ////MSG_FILAMENT_USED c=19
extern const char MSG_PRINT_TIME [] PROGMEM_I1 = ISTR("Print time"); ////MSG_PRINT_TIME c=19
extern const char MSG_TOTAL_FILAMENT [] PROGMEM_I1 = ISTR("Total filament"); ////MSG_TOTAL_FILAMENT c=19
Expand Down
2 changes: 1 addition & 1 deletion Firmware/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ extern const char MSG_NOT_LOADED [];
extern const char MSG_NOT_COLOR [];
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
extern const char MSG_AUTOLOADING_ENABLED [];
#endif //REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
extern const char MSG_FILAMENT_USED [];
extern const char MSG_PRINT_TIME [];
extern const char MSG_TOTAL_FILAMENT [];
Expand Down
29 changes: 18 additions & 11 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2145,9 +2145,9 @@ void lcd_wait_interact(const char* filament_name) {
lcd_print(filament_name);
lcd_set_cursor(0, 2);
}
#ifdef FILAMENT_SENSOR
#if defined FILAMENT_SENSOR && !defined(REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY)
if (!fsensor.getAutoLoadEnabled())
#endif //FILAMENT_SENSOR
#endif //FILAMENT_SENSOR AND NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
{
lcd_puts_P(_T(MSG_PRESS));
}
Expand Down Expand Up @@ -4024,9 +4024,11 @@ static void lcd_fsensor_runout_set() {
fsensor.setRunoutEnabled(!fsensor.getRunoutEnabled(), true);
}

#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
static void lcd_fsensor_autoload_set() {
fsensor.setAutoLoadEnabled(!fsensor.getAutoLoadEnabled(), true);
}
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY

#if FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125
static void lcd_fsensor_jam_detection_set() {
Expand Down Expand Up @@ -4066,7 +4068,9 @@ static void lcd_fsensor_settings_menu() {
}
else {
MENU_ITEM_TOGGLE_P(_T(MSG_FSENSOR_RUNOUT), fsensor.getRunoutEnabled() ? _T(MSG_ON) : _T(MSG_OFF), lcd_fsensor_runout_set);
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
MENU_ITEM_TOGGLE_P(_T(MSG_FSENSOR_AUTOLOAD), fsensor.getAutoLoadEnabled() ? _T(MSG_ON) : _T(MSG_OFF), lcd_fsensor_autoload_set);
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
#if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
MENU_ITEM_TOGGLE_P(_T(MSG_FSENSOR_JAM_DETECTION), fsensor.getJamDetectionEnabled() ? _T(MSG_ON) : _T(MSG_OFF), lcd_fsensor_jam_detection_set);
#endif //defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
Expand Down Expand Up @@ -5318,19 +5322,22 @@ 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()) {
MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), lcd_unLoadFilament);
}
// if (!fsensor.getAutoLoadEnabled()) {
// MENU_ITEM_SUBMENU_P(_T(MSG_LOAD_FILAMENT), lcd_LoadFilament);
// }
3d-gussner marked this conversation as resolved.
Show resolved Hide resolved
if (!fsensor.getFilamentPresent()) {
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
else {
if (fsensor.getAutoLoadEnabled()) {
MENU_ITEM_SUBMENU_P(_T(MSG_AUTOLOAD_FILAMENT), lcd_menu_AutoLoadFilament);
}
} else {
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
MENU_ITEM_SUBMENU_P(_T(MSG_LOAD_FILAMENT), lcd_LoadFilament);
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
}
#endif //NOT REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
} else {
MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), lcd_unLoadFilament);
}
#endif //REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
} else {
#endif //FILAMENT_SENSOR
MENU_ITEM_SUBMENU_P(_T(MSG_LOAD_FILAMENT), lcd_LoadFilament);
Expand Down