Skip to content

Commit

Permalink
IFNDEF more code that is releated to Filament Autoload
Browse files Browse the repository at this point in the history
  • Loading branch information
3d-gussner committed Dec 23, 2024
1 parent 8e2a94d commit 2b38f12
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
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

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 //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
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);
// }
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

0 comments on commit 2b38f12

Please sign in to comment.