Skip to content

Commit

Permalink
🔧 CONFIGURE_FILAMENT_CHANGE - Optional M603 (MarlinFirmware#26613)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
  • Loading branch information
2 people authored and chrisheib committed Jan 6, 2024
1 parent 0c2e1af commit 84886b7
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2055,7 +2055,7 @@
/**
* Enable detailed logging of G28, G29, M48, etc.
* Turn on with the command 'M111 S32'.
* NOTE: Requires a lot of PROGMEM!
* NOTE: Requires a lot of flash!
*/
//#define DEBUG_LEVELING_FEATURE

Expand Down Expand Up @@ -2344,7 +2344,7 @@
*/
#define EEPROM_SETTINGS // Persistent storage with M500 and M501
//#define DISABLE_M503 // Saves ~2700 bytes of flash. Disable for release!
#define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save PROGMEM.
#define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save flash.
#define EEPROM_BOOT_SILENT // Keep M503 quiet and only give errors during first load
#if ENABLED(EEPROM_SETTINGS)
//#define EEPROM_AUTO_INIT // Init EEPROM automatically on any errors.
Expand Down
3 changes: 2 additions & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@
#define CALIBRATION_NOZZLE_TIP_HEIGHT 1.0 // mm
#define CALIBRATION_NOZZLE_OUTER_DIAMETER 2.0 // mm

// Uncomment to enable reporting (required for "G425 V", but consumes PROGMEM).
// Uncomment to enable reporting (required for "G425 V", but consumes flash).
//#define CALIBRATION_REPORTING

// The true location and dimension the cube/bolt/washer on the bed.
Expand Down Expand Up @@ -2929,6 +2929,7 @@
//#define FILAMENT_LOAD_UNLOAD_GCODES // Add M701/M702 Load/Unload G-codes, plus Load/Unload in the LCD Prepare menu.
//#define FILAMENT_UNLOAD_ALL_EXTRUDERS // Allow M702 to unload all extruders above a minimum target temp (as set by M302)
#define CONFIGURE_FILAMENT_CHANGE // Add M603 G-code and menu items. Requires ~1.3K bytes of flash.
#endif

// @section tmc_smart
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/max7219.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

#if ENABLED(MAX7219_DEBUG)

#define MAX7219_ERRORS // Disable to save 406 bytes of Program Memory
#define MAX7219_ERRORS // Requires ~400 bytes of flash

#include "max7219.h"

Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ static xyze_pos_t resume_position;
PauseMode pause_mode = PAUSE_MODE_PAUSE_PRINT;
#endif

fil_change_settings_t fc_settings[EXTRUDERS];
#if ENABLED(CONFIGURE_FILAMENT_CHANGE)
fil_change_settings_t fc_settings[EXTRUDERS];
#endif

#if HAS_MEDIA
#include "../sd/cardreader.h"
Expand Down
19 changes: 14 additions & 5 deletions Marlin/src/feature/pause.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
* This may be combined with related G-codes if features are consolidated.
*/

typedef struct {
float unload_length, load_length;
} fil_change_settings_t;

#include "../inc/MarlinConfigPre.h"

#if ENABLED(ADVANCED_PAUSE_FEATURE)
Expand Down Expand Up @@ -69,7 +65,20 @@ enum PauseMessage : char {
extern PauseMode pause_mode;
#endif

extern fil_change_settings_t fc_settings[EXTRUDERS];
typedef struct FilamentChangeSettings {
#if ENABLED(CONFIGURE_FILAMENT_CHANGE)
float load_length, unload_length;
#else
static constexpr float load_length = FILAMENT_CHANGE_FAST_LOAD_LENGTH,
unload_length = FILAMENT_CHANGE_UNLOAD_LENGTH;
#endif
} fil_change_settings_t;

#if ENABLED(CONFIGURE_FILAMENT_CHANGE)
extern fil_change_settings_t fc_settings[EXTRUDERS];
#else
constexpr fil_change_settings_t fc_settings[EXTRUDERS];
#endif

extern uint8_t did_pause_print;

Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/gcode/feature/pause/M603.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
*
*/

#include "../../../inc/MarlinConfig.h"
#include "../../../inc/MarlinConfigPre.h"

#if ENABLED(ADVANCED_PAUSE_FEATURE)
#if ENABLED(CONFIGURE_FILAMENT_CHANGE)

#include "../../gcode.h"
#include "../../../feature/pause.h"
Expand Down Expand Up @@ -80,4 +80,4 @@ void GcodeSuite::M603_report(const bool forReplay/*=true*/) {
#endif
}

#endif // ADVANCED_PAUSE_FEATURE
#endif // CONFIGURE_FILAMENT_CHANGE
4 changes: 3 additions & 1 deletion Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,9 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {

#if ENABLED(ADVANCED_PAUSE_FEATURE)
case 600: M600(); break; // M600: Pause for Filament Change
case 603: M603(); break; // M603: Configure Filament Change
#if ENABLED(CONFIGURE_FILAMENT_CHANGE)
case 603: M603(); break; // M603: Configure Filament Change
#endif
#endif

#if HAS_DUPLICATION_MODE
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/e3v2/jyersui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2910,7 +2910,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
break;
#endif

#if ENABLED(ADVANCED_PAUSE_FEATURE)
#if ENABLED(CONFIGURE_FILAMENT_CHANGE)
case ADVANCED_LOAD:
if (draw) {
drawMenuItem(row, ICON_WriteEEPROM, F("Load Length"));
Expand All @@ -2927,7 +2927,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
else
modifyValue(fc_settings[0].unload_length, 0, EXTRUDE_MAXLENGTH, 1);
break;
#endif // ADVANCED_PAUSE_FEATURE
#endif // CONFIGURE_FILAMENT_CHANGE

#if ENABLED(PREVENT_COLD_EXTRUSION)
case ADVANCED_COLD_EXTRUDE:
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3302,7 +3302,7 @@ void drawFilSetMenu() {
#if ENABLED(PREVENT_COLD_EXTRUSION)
EDIT_ITEM(ICON_ExtrudeMinT, MSG_EXTRUDER_MIN_TEMP, onDrawPIntMenu, setExtMinT, &hmiData.extMinT);
#endif
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#if ENABLED(CONFIGURE_FILAMENT_CHANGE)
EDIT_ITEM(ICON_FilLoad, MSG_FILAMENT_LOAD, onDrawPFloatMenu, setFilLoad, &fc_settings[0].load_length);
EDIT_ITEM(ICON_FilUnload, MSG_FILAMENT_UNLOAD, onDrawPFloatMenu, setFilUnload, &fc_settings[0].unload_length);
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/nextion/nextion_tft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ void NextionTFT::panelInfo(uint8_t req) {
SEND_PRINT_INFO("t8", getFilamentUsed_str);
break;

case 28: // Filament laod/unload
case 28: // Filament load/unload
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#define SEND_PAUSE_INFO(A, B) SEND_VALasTXT(A, fc_settings[getActiveTool()].B)
#else
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void menu_backlash();
}
#endif

#if ENABLED(ADVANCED_PAUSE_FEATURE)
#if ENABLED(CONFIGURE_FILAMENT_CHANGE)
constexpr float extrude_maxlength = TERN(PREVENT_LENGTHY_EXTRUDE, EXTRUDE_MAXLENGTH, 999);

EDIT_ITEM_FAST(float4, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength);
Expand Down
18 changes: 6 additions & 12 deletions Marlin/src/module/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/

// Change EEPROM version if the structure changes
#define EEPROM_VERSION "V89"
#define EEPROM_VERSION "V90"
#define EEPROM_OFFSET 100

// Check the integrity of data offsets.
Expand Down Expand Up @@ -508,7 +508,7 @@ typedef struct SettingsDataStruct {
//
// ADVANCED_PAUSE_FEATURE
//
#if HAS_EXTRUDERS
#if ENABLED(CONFIGURE_FILAMENT_CHANGE)
fil_change_settings_t fc_settings[EXTRUDERS]; // M603 T U L
#endif

Expand Down Expand Up @@ -1551,11 +1551,8 @@ void MarlinSettings::postprocess() {
//
// Advanced Pause filament load & unload lengths
//
#if HAS_EXTRUDERS
#if ENABLED(CONFIGURE_FILAMENT_CHANGE)
{
#if DISABLED(ADVANCED_PAUSE_FEATURE)
const fil_change_settings_t fc_settings[EXTRUDERS] = { 0, 0 };
#endif
_FIELD_TEST(fc_settings);
EEPROM_WRITE(fc_settings);
}
Expand Down Expand Up @@ -2626,11 +2623,8 @@ void MarlinSettings::postprocess() {
//
// Advanced Pause filament load & unload lengths
//
#if HAS_EXTRUDERS
#if ENABLED(CONFIGURE_FILAMENT_CHANGE)
{
#if DISABLED(ADVANCED_PAUSE_FEATURE)
fil_change_settings_t fc_settings[EXTRUDERS];
#endif
_FIELD_TEST(fc_settings);
EEPROM_READ(fc_settings);
}
Expand Down Expand Up @@ -3549,7 +3543,7 @@ void MarlinSettings::reset() {
//
// Advanced Pause filament load & unload lengths
//
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#if ENABLED(CONFIGURE_FILAMENT_CHANGE)
EXTRUDER_LOOP() {
fc_settings[e].unload_length = FILAMENT_CHANGE_UNLOAD_LENGTH;
fc_settings[e].load_length = FILAMENT_CHANGE_FAST_LOAD_LENGTH;
Expand Down Expand Up @@ -3924,7 +3918,7 @@ void MarlinSettings::reset() {
//
// Advanced Pause filament load & unload lengths
//
TERN_(ADVANCED_PAUSE_FEATURE, gcode.M603_report(forReplay));
TERN_(CONFIGURE_FILAMENT_CHANGE, gcode.M603_report(forReplay));

//
// Tool-changing Parameters
Expand Down
1 change: 1 addition & 0 deletions buildroot/tests/BIGTREE_GTR_V1_0
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_
opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER BLTOUCH NEOPIXEL_LED Z_SAFE_HOMING NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE \
FILAMENT_RUNOUT_SENSOR FIL_RUNOUT4_PULLUP FIL_RUNOUT8_PULLUP FILAMENT_CHANGE_RESUME_ON_INSERT PAUSE_REHEAT_FAST_RESUME \
LCD_BED_TRAMMING BED_TRAMMING_USE_PROBE
opt_disable CONFIGURE_FILAMENT_CHANGE
exec_test $1 $2 "BigTreeTech GTR | 8 Extruders | Auto-Fan | Mixed TMC Drivers | Runout Sensors w/ distinct states" "$3"

restore_configs
Expand Down
3 changes: 2 additions & 1 deletion ini/features.ini
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ MIXING_EXTRUDER = build_src_filter=+<src/feature/mixing.c
HAS_PRUSA_MMU1 = build_src_filter=+<src/feature/mmu/mmu.cpp>
HAS_PRUSA_MMU2 = build_src_filter=+<src/feature/mmu/mmu2.cpp> +<src/gcode/feature/prusa_MMU2>
PASSWORD_FEATURE = build_src_filter=+<src/feature/password> +<src/gcode/feature/password>
ADVANCED_PAUSE_FEATURE = build_src_filter=+<src/feature/pause.cpp> +<src/gcode/feature/pause/M600.cpp> +<src/gcode/feature/pause/M603.cpp>
ADVANCED_PAUSE_FEATURE = build_src_filter=+<src/feature/pause.cpp> +<src/gcode/feature/pause/M600.cpp>
CONFIGURE_FILAMENT_CHANGE = build_src_filter=+<src/gcode/feature/pause/M603.cpp>
PSU_CONTROL = build_src_filter=+<src/feature/power.cpp>
HAS_POWER_MONITOR = build_src_filter=+<src/feature/power_monitor.cpp> +<src/gcode/feature/power_monitor>
POWER_LOSS_RECOVERY = build_src_filter=+<src/feature/powerloss.cpp> +<src/gcode/feature/powerloss>
Expand Down

0 comments on commit 84886b7

Please sign in to comment.