From 2d8aa0cea1251836b5504bc6c06dac344116e665 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 19 Oct 2020 00:25:51 -0500 Subject: [PATCH 01/58] Tweak a host prompt call --- Marlin/src/feature/host_actions.cpp | 12 ++++++++++-- Marlin/src/feature/host_actions.h | 1 + Marlin/src/feature/pause.cpp | 7 ++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index 3012639220..a8b2b51dfc 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -113,12 +113,20 @@ void host_action(PGM_P const pstr, const bool eol) { void host_action_prompt_button(PGM_P const pstr) { host_action_prompt_plus(PSTR("button"), pstr); } void host_action_prompt_end() { host_action_prompt(PSTR("end")); } void host_action_prompt_show() { host_action_prompt(PSTR("show")); } - void host_prompt_do(const PromptReason reason, PGM_P const pstr, PGM_P const btn1/*=nullptr*/, PGM_P const btn2/*=nullptr*/) { - host_action_prompt_begin(reason, pstr); + + void _host_prompt_show(PGM_P const btn1/*=nullptr*/, PGM_P const btn2/*=nullptr*/) { if (btn1) host_action_prompt_button(btn1); if (btn2) host_action_prompt_button(btn2); host_action_prompt_show(); } + void host_prompt_do(const PromptReason reason, PGM_P const pstr, PGM_P const btn1/*=nullptr*/, PGM_P const btn2/*=nullptr*/) { + host_action_prompt_begin(reason, pstr); + _host_prompt_show(btn1, btn2); + } + void host_prompt_do(const PromptReason reason, PGM_P const pstr, const char extra_char, PGM_P const btn1/*=nullptr*/, PGM_P const btn2/*=nullptr*/) { + host_action_prompt_begin(reason, pstr, extra_char); + _host_prompt_show(btn1, btn2); + } void filament_load_host_prompt() { const bool disable_to_continue = TERN0(HAS_FILAMENT_SENSOR, runout.filament_ran_out); diff --git a/Marlin/src/feature/host_actions.h b/Marlin/src/feature/host_actions.h index 09eeed23e2..065b59d755 100644 --- a/Marlin/src/feature/host_actions.h +++ b/Marlin/src/feature/host_actions.h @@ -71,6 +71,7 @@ void host_action(PGM_P const pstr, const bool eol=true); void host_action_prompt_end(); void host_action_prompt_show(); void host_prompt_do(const PromptReason reason, PGM_P const pstr, PGM_P const btn1=nullptr, PGM_P const btn2=nullptr); + void host_prompt_do(const PromptReason reason, PGM_P const pstr, const char extra_char, PGM_P const btn1=nullptr, PGM_P const btn2=nullptr); inline void host_prompt_open(const PromptReason reason, PGM_P const pstr, PGM_P const btn1=nullptr, PGM_P const btn2=nullptr) { if (host_prompt_reason == PROMPT_NOT_DEFINED) host_prompt_do(reason, pstr, btn1, btn2); } diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 6f970d1a4c..0e544b15c7 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -199,17 +199,18 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l first_impatient_beep(max_beep_count); KEEPALIVE_STATE(PAUSED_FOR_USER); + #if ENABLED(HOST_PROMPT_SUPPORT) const char tool = '0' #if NUM_RUNOUT_SENSORS > 1 + active_extruder #endif ; - host_action_prompt_begin(PROMPT_USER_CONTINUE, PSTR("Load Filament T"), tool); - host_action_prompt_button(CONTINUE_STR); - host_action_prompt_show(); + host_action_prompt_do(PROMPT_USER_CONTINUE, PSTR("Load Filament T"), tool, CONTINUE_STR); #endif + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Load Filament"))); + while (wait_for_user) { impatient_beep(max_beep_count); idle_no_sleep(); From 0216e032be439dbf26a48acb7aee3228419cc869 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 19 Oct 2020 04:34:03 -0500 Subject: [PATCH 02/58] Host prompt followup --- Marlin/src/feature/pause.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 0e544b15c7..0a3609b3a1 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -206,7 +206,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l + active_extruder #endif ; - host_action_prompt_do(PROMPT_USER_CONTINUE, PSTR("Load Filament T"), tool, CONTINUE_STR); + host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Load Filament T"), tool, CONTINUE_STR); #endif TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Load Filament"))); From 40de56b58bcf218e91e213480c7b8d202c349c72 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Mon, 15 Jun 2020 11:52:54 -0400 Subject: [PATCH 03/58] Bump to head, fix compile errors --- Marlin/Configuration.h | 427 +++++++++++++++++++++++++++---------- Marlin/Configuration_adv.h | 263 +++++++++++++---------- Marlin/Version.h | 12 +- Marlin/_Bootscreen.h | 93 ++++++++ Marlin/_Statusscreen.h | 74 +++++++ 5 files changed, 636 insertions(+), 233 deletions(-) create mode 100644 Marlin/_Bootscreen.h create mode 100644 Marlin/_Statusscreen.h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 5ec41c596b..aa41f715c2 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1,3 +1,48 @@ + // If you have a trex 3, stock is this option plus 2208 on all axis. None in spreadcycle. +#define TREX3 + +// If you have a trex 3 that was upgraded from a 2+ with the kit, modifies home position and offsets. +//#define TREX3_UPGRADE + +//Stock 2+ X is a 4988, all options off defaults to this +//#define X_2208 +//#define X_Spreadcycle +//#define X_S109 + +// Y all options off defaults to 2+ 8825 / 3 2208 +//#define Y_2208 // Highly recommended as large prints with high mass can cause layer shifts with stealthchop at high speed +//#define Y_Spreadcycle +//#define Y_4988 // Some machines shipped with 4988 drivers across the board. Set this if you arent sure what you have and all the drivers look identical +//#define Y_S109 + +//Stock 2+ Z is a 8825, all options off defaults to this +//#define Z_2208 // NOT Recommended! Dual stepper current draw is above the recommended limit for this driver +//#define Z_4988 // Some machines shipped with 4988 drivers across the board. Set this if you arent sure what you have and all the drivers look identical +//#define Z_Spreadcycle +//#define Z_S109 + +//Stock 2+ Z is a 4988, all options off defaults to this +//#define E_2208 // Not Recommended! Stealthchop mode faults with linear advance +//#define E_Spreadcycle +//#define E_S109 + +#define BedAC + +#define tallVersion + +//#define ABL_Bilinear +/* + * Enables a filament sensor plugged into the laser pin. Disables the laser + */ +//#define FilamentSensor // Standard older TM3D runout sensor +//#define lerdgeFilSensor // Newer inverted logic TM3D Runout Sensor +//#define filamentEncoder + +//#define autoCalibrationKit + + +//////////////////////////////////DO not edit below here unless you know what youre doing! ////////////////////////////////// + /** * Marlin 3D Printer Firmware * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] @@ -21,6 +66,23 @@ */ #pragma once +// The TREX2+ upgraded to the 3 enables most of the same options, simplify here +#if ENABLED(TREX3_UPGRADE) + #define TREX3 +#endif + +#if ENABLED(TREX3) + #if DISABLED(X_S109) + #define X_2208 + #endif + #if DISABLED(Y_S109) + #define Y_2208 + #endif + #define Z_2208 + #define E_2208 + #define FilamentSensor +#endif + /** * Configuration.h * @@ -70,8 +132,8 @@ // @section info // Author info of this build printed to the host during boot and M115 -#define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. -//#define CUSTOM_VERSION_FILE Version.h // Path from the root directory (no quotes) +#define STRING_CONFIG_H_AUTHOR "Tinymachines3D" // Who made the changes. +#define CUSTOM_VERSION_FILE Version.h // Path from the root directory (no quotes) /** * *** VENDORS PLEASE READ *** @@ -88,10 +150,10 @@ #define SHOW_BOOTSCREEN // Show the bitmap in Marlin/_Bootscreen.h on startup. -//#define SHOW_CUSTOM_BOOTSCREEN +#define SHOW_CUSTOM_BOOTSCREEN // Show the bitmap in Marlin/_Statusscreen.h on the status screen. -//#define CUSTOM_STATUS_SCREEN_IMAGE +#define CUSTOM_STATUS_SCREEN_IMAGE // @section machine @@ -128,11 +190,22 @@ // Choose the name from boards.h that matches your setup #ifndef MOTHERBOARD - #define MOTHERBOARD BOARD_RAMPS_14_EFB +#if ENABLED(TREX3) + #define MOTHERBOARD BOARD_FORMBOT_TREX3 +#else + #define MOTHERBOARD BOARD_FORMBOT_TREX2PLUS +#endif #endif -// Name displayed in the LCD "Ready" message and Info menu -//#define CUSTOM_MACHINE_NAME "3D Printer" +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message +#if ENABLED(TREX3_UPGRADE) + #define CUSTOM_MACHINE_TIME "T-REX 3(u)" +#elif ENABLED(TREX3) + #define CUSTOM_MACHINE_NAME "T-REX 3" +#else + #define CUSTOM_MACHINE_NAME "T-REX 2+" +#endif // Printer's unique ID, used by some programs to differentiate between machines. // Choose your own or use a service like https://www.uuidgenerator.net/version4 @@ -142,7 +215,7 @@ // This defines the number of extruders // :[0, 1, 2, 3, 4, 5, 6, 7, 8] -#define EXTRUDERS 1 +#define EXTRUDERS 2 // Generally expected filament diameter (1.75, 2.85, 3.0, ...). Used for Volumetric, Filament Width Sensor, etc. #define DEFAULT_NOMINAL_FILAMENT_DIA 1.75 @@ -314,7 +387,12 @@ // Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing). // The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder). // For the other hotends it is their distance from the extruder 0 hotend. -//#define HOTEND_OFFSET_X { 0.0, 20.00 } // (mm) relative X-offset for each nozzle + #if ENABLED(TREX3) + #define HOTEND_OFFSET_X {0.0, 438.5} // (mm) relative X-offset for each nozzle + #else + #define HOTEND_OFFSET_X {0.0, 442.0} // (mm) relative X-offset for each nozzle + #endif + //#define HOTEND_OFFSET_Y { 0.0, 5.00 } // (mm) relative Y-offset for each nozzle //#define HOTEND_OFFSET_Z { 0.0, 0.00 } // (mm) relative Z-offset for each nozzle @@ -419,15 +497,24 @@ * 998 : Dummy Table that ALWAYS reads 25°C or the temperature defined below. * 999 : Dummy Table that ALWAYS reads 100°C or the temperature defined below. */ -#define TEMP_SENSOR_0 1 -#define TEMP_SENSOR_1 0 +#if ENABLED(TREX3) + #define TEMP_SENSOR_0 61 + #define TEMP_SENSOR_1 61 +#else + #define TEMP_SENSOR_0 1 + #define TEMP_SENSOR_1 1 +#endif #define TEMP_SENSOR_2 0 #define TEMP_SENSOR_3 0 #define TEMP_SENSOR_4 0 #define TEMP_SENSOR_5 0 #define TEMP_SENSOR_6 0 #define TEMP_SENSOR_7 0 -#define TEMP_SENSOR_BED 0 +#if(ENABLED(BedAC)) + #define TEMP_SENSOR_BED 11 +#else + #define TEMP_SENSOR_BED 0 +#endif #define TEMP_SENSOR_PROBE 0 #define TEMP_SENSOR_CHAMBER 0 @@ -446,11 +533,11 @@ //#define TEMP_SENSOR_1_AS_REDUNDANT #define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10 -#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109 +#define TEMP_RESIDENCY_TIME 3 // (seconds) Time to wait for hotend to "settle" in M109 #define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer #define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target -#define TEMP_BED_RESIDENCY_TIME 10 // (seconds) Time to wait for bed to "settle" in M190 +#define TEMP_BED_RESIDENCY_TIME 5 // (seconds) Time to wait for bed to "settle" in M190 #define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer #define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target @@ -469,8 +556,13 @@ // Above this temperature the heater will be switched off. // This can protect components from overheating, but NOT from shorts and failures. // (Use MINTEMP for thermistor short/failure protection.) -#define HEATER_0_MAXTEMP 275 -#define HEATER_1_MAXTEMP 275 +#if ENABLED(TREX3) + #define HEATER_0_MAXTEMP 350 + #define HEATER_1_MAXTEMP 350 +#else + #define HEATER_0_MAXTEMP 410 + #define HEATER_1_MAXTEMP 295 +#endif #define HEATER_2_MAXTEMP 275 #define HEATER_3_MAXTEMP 275 #define HEATER_4_MAXTEMP 275 @@ -491,22 +583,38 @@ #define PID_K1 0.95 // Smoothing factor within any PID loop #if ENABLED(PIDTEMP) - //#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM) - //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) - //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) + #define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM) + #define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) + #define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) // Set/get with gcode: M301 E[extruder number, 0-2] #if ENABLED(PID_PARAMS_PER_HOTEND) // Specify between 1 and HOTENDS values per array. // If fewer than EXTRUDER values are provided, the last element will be repeated. - #define DEFAULT_Kp_LIST { 22.20, 22.20 } - #define DEFAULT_Ki_LIST { 1.08, 1.08 } - #define DEFAULT_Kd_LIST { 114.00, 114.00 } + #if ENABLED(TREX3) + #define DEFAULT_Kp_LIST { 14.64, 14.64 } + #define DEFAULT_Ki_LIST { 1.08, 1.08 } + #define DEFAULT_Kd_LIST { 53.36, 53.36 } + #else + #define DEFAULT_Kp_LIST { 22.20, 22.20 } + #define DEFAULT_Ki_LIST { 1.08, 1.08 } + #define DEFAULT_Kd_LIST { 114.00, 114.00 } + #endif #else - #define DEFAULT_Kp 22.20 - #define DEFAULT_Ki 1.08 - #define DEFAULT_Kd 114.00 + #define DEFAULT_Kp 22.2 + #define DEFAULT_Ki 1.08 + #define DEFAULT_Kd 114 #endif + // MakerGear + //#define DEFAULT_Kp 7.0 + //#define DEFAULT_Ki 0.1 + //#define DEFAULT_Kd 12 + + // Mendel Parts V9 on 12V + //#define DEFAULT_Kp 63.0 + //#define DEFAULT_Ki 2.25 + //#define DEFAULT_Kd 440 + #endif // PIDTEMP //=========================================================================== @@ -625,10 +733,10 @@ // Almost all printers will be using one per axis. Probes will use one or more of the // extra connectors. Leave undefined any used for non-endstop and non-probe purposes. #define USE_XMIN_PLUG -#define USE_YMIN_PLUG +//#define USE_YMIN_PLUG #define USE_ZMIN_PLUG -//#define USE_XMAX_PLUG -//#define USE_YMAX_PLUG +#define USE_XMAX_PLUG +#define USE_YMAX_PLUG //#define USE_ZMAX_PLUG // Enable pullup for all endstops to prevent a floating state @@ -658,13 +766,13 @@ #endif // Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup). -#define X_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. -#define Y_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. -#define Z_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. -#define X_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. -#define Y_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. -#define Z_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. -#define Z_MIN_PROBE_ENDSTOP_INVERTING false // Set to true to invert the logic of the probe. +#define X_MIN_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. +#define Y_MIN_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop. +#define Z_MIN_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop. +#define X_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. +#define Y_MAX_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop. +#define Z_MAX_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop. +#define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the probe. /** * Stepper Drivers @@ -682,16 +790,38 @@ * TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE'] */ -#define X_DRIVER_TYPE A4988 -#define Y_DRIVER_TYPE A4988 -#define Z_DRIVER_TYPE A4988 -//#define X2_DRIVER_TYPE A4988 +#if ENABLED(X_2208) + #define X_DRIVER_TYPE TMC2208_STANDALONE + #define X2_DRIVER_TYPE TMC2208_STANDALONE +#else + #define X_DRIVER_TYPE A4988 + #define X2_DRIVER_TYPE A4988 +#endif +#if ENABLED(Y_2208) + #define Y_DRIVER_TYPE TMC2208_STANDALONE +#elif ENABLED(Y_4988) + #define Y_DRIVER_TYPE A4988 +#else + #define Y_DRIVER_TYPE DRV8825 +#endif +#if ENABLED(Z_2208) + #define Z_DRIVER_TYPE TMC2208_STANDALONE +#elif ENABLED(Z_4988) + #define Z_DRIVER_TYPE A4988 +#else + #define Z_DRIVER_TYPE DRV8825 +#endif //#define Y2_DRIVER_TYPE A4988 //#define Z2_DRIVER_TYPE A4988 //#define Z3_DRIVER_TYPE A4988 //#define Z4_DRIVER_TYPE A4988 -#define E0_DRIVER_TYPE A4988 -//#define E1_DRIVER_TYPE A4988 +#if ENABLED(E_2208) + #define E0_DRIVER_TYPE TMC2208_STANDALONE + #define E1_DRIVER_TYPE TMC2208_STANDALONE +#else + #define E0_DRIVER_TYPE DRV8825 + #define E1_DRIVER_TYPE DRV8825 +#endif //#define E2_DRIVER_TYPE A4988 //#define E3_DRIVER_TYPE A4988 //#define E4_DRIVER_TYPE A4988 @@ -745,18 +875,37 @@ * Override with M92 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 4000, 500 } + + +#if(ENABLED(Y_2208) || ENABLED(Y_4988) || ENABLED(Y_S109)) + #define Y_STEPSMM 80 +#else + #define Y_STEPSMM 160 +#endif + +#if(ENABLED(Z_2208) || ENABLED(Z_4988)) + #define Z_STEPSMM 800 +#else + #define Z_STEPSMM 1600 +#endif + +#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, Y_STEPSMM, Z_STEPSMM, 93 } /** * Default Max Feed Rate (mm/s) * Override with M203 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_MAX_FEEDRATE { 300, 300, 5, 25 } +#if ENABLED(Y_2208) && DISABLED(Y_Spreadcycle) + #define Y_MAXFEED 100 +#else + #define Y_MAXFEED 150 +#endif +#define DEFAULT_MAX_FEEDRATE { 200, Y_MAXFEED, 8, 75 } -//#define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2 +#define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2 #if ENABLED(LIMITED_MAX_FR_EDITING) - #define MAX_FEEDRATE_EDIT_VALUES { 600, 600, 10, 50 } // ...or, set your own edit limits + #define MAX_FEEDRATE_EDIT_VALUES { 300, 200, 15, 150 } // ...or, set your own edit limits #endif /** @@ -765,11 +914,11 @@ * Override with M201 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_MAX_ACCELERATION { 3000, 3000, 100, 10000 } +#define DEFAULT_MAX_ACCELERATION { 750, 500, 400, 3000 } -//#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2 +#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2 #if ENABLED(LIMITED_MAX_ACCEL_EDITING) - #define MAX_ACCEL_EDIT_VALUES { 6000, 6000, 200, 20000 } // ...or, set your own edit limits + #define MAX_ACCEL_EDIT_VALUES { 1500, 1500, 800, 5000 } // ...or, set your own edit limits #endif /** @@ -780,9 +929,9 @@ * M204 R Retract Acceleration * M204 T Travel Acceleration */ -#define DEFAULT_ACCELERATION 3000 // X, Y, Z and E acceleration for printing moves -#define DEFAULT_RETRACT_ACCELERATION 3000 // E acceleration for retracts -#define DEFAULT_TRAVEL_ACCELERATION 3000 // X, Y, Z acceleration for travel (non printing) moves +#define DEFAULT_ACCELERATION 500 // X, Y, Z and E acceleration for printing moves +#define DEFAULT_RETRACT_ACCELERATION 2000 // E acceleration for retracts +#define DEFAULT_TRAVEL_ACCELERATION 500 // X, Y, Z acceleration for travel (non printing) moves /** * Default Jerk limits (mm/s) @@ -792,10 +941,10 @@ * When changing speed and direction, if the difference is less than the * value set here, it may happen instantaneously. */ -//#define CLASSIC_JERK +#define CLASSIC_JERK #if ENABLED(CLASSIC_JERK) #define DEFAULT_XJERK 10.0 - #define DEFAULT_YJERK 10.0 + #define DEFAULT_YJERK 5.0 #define DEFAULT_ZJERK 0.3 //#define TRAVEL_EXTRA_XYJERK 0.0 // Additional jerk allowance for all travel moves @@ -829,7 +978,7 @@ * * See https://github.com/synthetos/TinyG/wiki/Jerk-Controlled-Motion-Explained */ -//#define S_CURVE_ACCELERATION +#define S_CURVE_ACCELERATION //=========================================================================== //============================= Z Probe Options ============================= @@ -903,7 +1052,7 @@ /** * The BLTouch probe uses a Hall effect sensor and emulates a servo. */ -//#define BLTOUCH +#define BLTOUCH /** * Pressure sensor with a BLTouch-like interface @@ -990,8 +1139,12 @@ * | [-] | * O-- FRONT --+ */ -#define NOZZLE_TO_PROBE_OFFSET { 10, 10, 0 } +#if ENABLED(TREX3) + #define NOZZLE_TO_PROBE_OFFSET { -3, 31, 0 } +#else + #define NOZZLE_TO_PROBE_OFFSET { -7, 29, 0 } +#endif // Most probes should stay away from the edges of the bed, but // with NOZZLE_AS_PROBE this can be negative for a wider probing area. #define PROBING_MARGIN 10 @@ -1014,7 +1167,7 @@ * A total of 2 does fast/slow probes with a weighted average. * A total of 3 or more adds more slow probes, taking the average. */ -//#define MULTIPLE_PROBING 2 +#define MULTIPLE_PROBING 2 //#define EXTRA_PROBING 1 /** @@ -1031,19 +1184,19 @@ * Example: `M851 Z-5` with a CLEARANCE of 4 => 9mm from bed to nozzle. * But: `M851 Z+1` with a CLEARANCE of 2 => 2mm from bed to nozzle. */ -#define Z_CLEARANCE_DEPLOY_PROBE 10 // Z Clearance for Deploy/Stow +#define Z_CLEARANCE_DEPLOY_PROBE 5 // Z Clearance for Deploy/Stow #define Z_CLEARANCE_BETWEEN_PROBES 5 // Z Clearance between probe points #define Z_CLEARANCE_MULTI_PROBE 5 // Z Clearance between multiple probes -//#define Z_AFTER_PROBING 5 // Z position after probing is done +#define Z_AFTER_PROBING 5 // Z position after probing is done -#define Z_PROBE_LOW_POINT -2 // Farthest distance below the trigger-point to go before stopping +#define Z_PROBE_LOW_POINT -3 // Farthest distance below the trigger-point to go before stopping // For M851 give a range for adjusting the Z probe offset -#define Z_PROBE_OFFSET_RANGE_MIN -20 -#define Z_PROBE_OFFSET_RANGE_MAX 20 +#define Z_PROBE_OFFSET_RANGE_MIN -9 +#define Z_PROBE_OFFSET_RANGE_MAX 9 // Enable the M48 repeatability test to test probe accuracy -//#define Z_MIN_PROBE_REPEATABILITY_TEST +#define Z_MIN_PROBE_REPEATABILITY_TEST // Before deploy/stow pause for user confirmation //#define PAUSE_BEFORE_DEPLOY_STOW @@ -1090,15 +1243,31 @@ // @section machine // Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. -#define INVERT_X_DIR false -#define INVERT_Y_DIR true -#define INVERT_Z_DIR false - +#if ENABLED(X_2208) + #define INVERT_X_DIR true +#else + #define INVERT_X_DIR false +#endif +#if ENABLED(Y_2208) + #define INVERT_Y_DIR true +#else + #define INVERT_Y_DIR false +#endif +#if ENABLED(Z_2208) + #define INVERT_Z_DIR false +#else + #define INVERT_Z_DIR true +#endif // @section extruder // For direct drive extruder v9 set to true, for geared extruder set to false. -#define INVERT_E0_DIR false -#define INVERT_E1_DIR false +#if ENABLED(E_2208) && DISABLED(TREX3) + #define INVERT_E0_DIR true + #define INVERT_E1_DIR false +#else + #define INVERT_E0_DIR false + #define INVERT_E1_DIR true +#endif #define INVERT_E2_DIR false #define INVERT_E3_DIR false #define INVERT_E4_DIR false @@ -1120,22 +1289,34 @@ // Direction of endstops when homing; 1=MAX, -1=MIN // :[-1,1] #define X_HOME_DIR -1 -#define Y_HOME_DIR -1 +#define Y_HOME_DIR 1 #define Z_HOME_DIR -1 // @section machine // The size of the print bed -#define X_BED_SIZE 200 -#define Y_BED_SIZE 200 +#define X_BED_SIZE 400 +#define Y_BED_SIZE 400 // Travel limits (mm) after homing, corresponding to endstop positions. -#define X_MIN_POS 0 -#define Y_MIN_POS 0 -#define Z_MIN_POS 0 -#define X_MAX_POS X_BED_SIZE -#define Y_MAX_POS Y_BED_SIZE -#define Z_MAX_POS 200 +#if DISABLED(TREX3) || ENABLED(TREX3_UPGRADE) + #define X_MIN_POS -42 + #define Y_MIN_POS 0 + #define Z_MIN_POS -3 + #define X_MAX_POS 450 + #define Y_MAX_POS Y_BED_SIZE +#else + #define X_MIN_POS -47 + #define Y_MIN_POS 0 + #define Z_MIN_POS -3 + #define X_MAX_POS 460 + #define Y_MAX_POS Y_BED_SIZE +#endif +#if(ENABLED(tallVersion)) + #define Z_MAX_POS 700 +#else + #define Z_MAX_POS 500 +#endif /** * Software Endstops @@ -1163,7 +1344,7 @@ #endif #if EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS) - //#define SOFT_ENDSTOPS_MENU_ITEM // Enable/Disable software endstops from the LCD + #define SOFT_ENDSTOPS_MENU_ITEM // Enable/Disable software endstops from the LCD #endif /** @@ -1173,13 +1354,23 @@ * RAMPS-based boards use SERVO3_PIN for the first runout sensor. * For other boards you may need to define FIL_RUNOUT_PIN, FIL_RUNOUT2_PIN, etc. */ -//#define FILAMENT_RUNOUT_SENSOR + #if ANY(FilamentSensor, filamentEncoder, lerdgeFilSensor) + #define FILAMENT_RUNOUT_SENSOR +#endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) - #define FIL_RUNOUT_ENABLED_DEFAULT true // Enable the sensor on startup. Override with M412 followed by M500. - #define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each. - #define FIL_RUNOUT_STATE LOW // Pin state indicating that filament is NOT present. - #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. - //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. + #define FIL_RUNOUT_ENABLED_DEFAULT true // Enable the sensor on startup. Override with M412 followed by M500. + #if ENABLED(TREX3) + #define NUM_RUNOUT_SENSORS 2 + #else + #define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each. + #endif + #if ENABLED(lerdgeFilSensor) || ENABLED(TREX3) + #define FIL_RUNOUT_STATE LOW // set to true to invert the logic of the sensor. + #else + #define FIL_RUNOUT_STATE HIGH // set to true to invert the logic of the sensor. + #endif + #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. + //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. // Set one or more commands to execute on filament runout. // (After 'M412 H' Marlin will ask the host to handle the process.) @@ -1188,13 +1379,19 @@ // After a runout is detected, continue printing this length of filament // before executing the runout script. Useful for a sensor at the end of // a feed tube. Requires 4 bytes SRAM per sensor, plus 4 bytes overhead. - //#define FILAMENT_RUNOUT_DISTANCE_MM 25 + #if ENABLED(filamentEncoder) + #define FILAMENT_RUNOUT_DISTANCE_MM 15 + #else + #define FILAMENT_RUNOUT_DISTANCE_MM 5 + #endif #ifdef FILAMENT_RUNOUT_DISTANCE_MM // Enable this option to use an encoder disc that toggles the runout pin // as the filament moves. (Be sure to set FILAMENT_RUNOUT_DISTANCE_MM // large enough to avoid false positives.) - //#define FILAMENT_MOTION_SENSOR + #if ENABLED(filamentEncoder) + #define FILAMENT_MOTION_SENSOR + #endif #endif #endif @@ -1238,15 +1435,18 @@ */ //#define AUTO_BED_LEVELING_3POINT //#define AUTO_BED_LEVELING_LINEAR -//#define AUTO_BED_LEVELING_BILINEAR -//#define AUTO_BED_LEVELING_UBL +#if ENABLED(ABL_Bilinear) + #define AUTO_BED_LEVELING_BILINEAR +#else + #define AUTO_BED_LEVELING_UBL +#endif //#define MESH_BED_LEVELING /** * Normally G28 leaves leveling disabled on completion. Enable * this option to have G28 restore the prior leveling state. */ -//#define RESTORE_LEVELING_AFTER_G28 +#define RESTORE_LEVELING_AFTER_G28 /** * Enable detailed logging of G28, G29, M48, etc. @@ -1270,7 +1470,7 @@ /** * Enable the G26 Mesh Validation Pattern tool. */ - //#define G26_MESH_VALIDATION + #define G26_MESH_VALIDATION #if ENABLED(G26_MESH_VALIDATION) #define MESH_TEST_NOZZLE_SIZE 0.4 // (mm) Diameter of primary nozzle. #define MESH_TEST_LAYER_HEIGHT 0.2 // (mm) Default layer height for the G26 Mesh Validation Tool. @@ -1285,7 +1485,7 @@ #if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR) // Set the number of grid points per dimension. - #define GRID_MAX_POINTS_X 3 + #define GRID_MAX_POINTS_X 11 #define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X // Probe along the Y axis, advancing X after each column @@ -1315,16 +1515,16 @@ //========================= Unified Bed Leveling ============================ //=========================================================================== - //#define MESH_EDIT_GFX_OVERLAY // Display a graphics overlay while editing the mesh + #define MESH_EDIT_GFX_OVERLAY // Display a graphics overlay while editing the mesh - #define MESH_INSET 1 // Set Mesh bounds as an inset region of the bed - #define GRID_MAX_POINTS_X 10 // Don't use more than 15 points per axis, implementation limited. + #define MESH_INSET 3 // Set Mesh bounds as an inset region of the bed + #define GRID_MAX_POINTS_X 15 // Don't use more than 15 points per axis, implementation limited. #define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X #define UBL_MESH_EDIT_MOVES_Z // Sophisticated users prefer no movement of nozzle #define UBL_SAVE_ACTIVE_ON_M500 // Save the currently active mesh in the current slot on M500 - //#define UBL_Z_RAISE_WHEN_OFF_MESH 2.5 // When the nozzle is off the mesh, this value is used + #define UBL_Z_RAISE_WHEN_OFF_MESH 0.0 // When the nozzle is off the mesh, this value is used // as the Z-Height correction value. #elif ENABLED(MESH_BED_LEVELING) @@ -1354,7 +1554,7 @@ #endif // Add a menu item to move between bed corners for manual bed adjustment -//#define LEVEL_BED_CORNERS +#define LEVEL_BED_CORNERS #if ENABLED(LEVEL_BED_CORNERS) #define LEVEL_CORNERS_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets @@ -1378,7 +1578,7 @@ // For DELTA this is the top-center of the Cartesian print volume. //#define MANUAL_X_HOME_POS 0 //#define MANUAL_Y_HOME_POS 0 -//#define MANUAL_Z_HOME_POS 0 +#define MANUAL_Z_HOME_POS 0 // Use "Z Safe Homing" to avoid homing with a Z probe outside the bed area. // @@ -1389,7 +1589,7 @@ // - Move the Z probe (or nozzle) to a defined XY point before Z Homing. // - Prevent Z homing when the Z probe is outside bed area. // -//#define Z_SAFE_HOMING +#define Z_SAFE_HOMING #if ENABLED(Z_SAFE_HOMING) #define Z_SAFE_HOMING_X_POINT X_CENTER // X point for Z homing @@ -1398,7 +1598,7 @@ // Homing speeds (mm/min) #define HOMING_FEEDRATE_XY (50*60) -#define HOMING_FEEDRATE_Z (4*60) +#define HOMING_FEEDRATE_Z (6*60) // Validate that endstops are triggered on homing moves #define VALIDATE_HOMING_ENDSTOPS @@ -1475,12 +1675,12 @@ * M501 - Read settings from EEPROM. (i.e., Throw away unsaved changes) * M502 - Revert settings to "factory" defaults. (Follow with M500 to init the EEPROM.) */ -//#define EEPROM_SETTINGS // Persistent storage with M500 and M501 +#define EEPROM_SETTINGS // Persistent storage with M500 and M501 //#define DISABLE_M503 // Saves ~2700 bytes of PROGMEM. Disable for release! #define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save PROGMEM. #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. + #define EEPROM_AUTO_INIT // Init EEPROM automatically on any errors. #endif // @@ -1527,11 +1727,11 @@ * P1 Raise the nozzle always to Z-park height. * P2 Raise the nozzle by Z-park amount, limited to Z_MAX_POS. */ -//#define NOZZLE_PARK_FEATURE +#define NOZZLE_PARK_FEATURE #if ENABLED(NOZZLE_PARK_FEATURE) // Specify a park position as { X, Y, Z_raise } - #define NOZZLE_PARK_POINT { (X_MIN_POS + 10), (Y_MAX_POS - 10), 20 } + #define NOZZLE_PARK_POINT { 150, (Y_MIN_POS + 10), 10 } //#define NOZZLE_PARK_X_ONLY // X move only is required to park //#define NOZZLE_PARK_Y_ONLY // Y move only is required to park #define NOZZLE_PARK_Z_RAISE_MIN 2 // (mm) Always raise Z by at least this distance @@ -1576,19 +1776,19 @@ * Caveats: The ending Z should be the same as starting Z. * Attention: EXPERIMENTAL. G-code arguments may change. */ -//#define NOZZLE_CLEAN_FEATURE +#define NOZZLE_CLEAN_FEATURE #if ENABLED(NOZZLE_CLEAN_FEATURE) // Default number of pattern repetitions - #define NOZZLE_CLEAN_STROKES 12 + #define NOZZLE_CLEAN_STROKES 4 // Default number of triangles #define NOZZLE_CLEAN_TRIANGLES 3 // Specify positions for each tool as { { X, Y, Z }, { X, Y, Z } } // Dual hotend system may use { { -20, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }, { 420, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }} - #define NOZZLE_CLEAN_START_POINT { { 30, 30, (Z_MIN_POS + 1) } } - #define NOZZLE_CLEAN_END_POINT { { 100, 60, (Z_MIN_POS + 1) } } + #define NOZZLE_CLEAN_START_POINT { { -20, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }, { 420, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }} + #define NOZZLE_CLEAN_END_POINT { { (-30), (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }, { (430), (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }} // Circular pattern radius #define NOZZLE_CLEAN_CIRCLE_RADIUS 6.5 @@ -1728,7 +1928,7 @@ * SD Card support is disabled by default. If your controller has an SD slot, * you must uncomment the following option or it won't work. */ -//#define SDSUPPORT +#define SDSUPPORT /** * SD CARD: SPI SPEED @@ -1808,7 +2008,7 @@ // // Add individual axis homing items (Home X, Home Y, and Home Z) to the LCD menu. // -//#define INDIVIDUAL_AXIS_HOMING_MENU +#define INDIVIDUAL_AXIS_HOMING_MENU // // SPEAKER/BUZZER @@ -1989,7 +2189,7 @@ // RepRapDiscount FULL GRAPHIC Smart Controller // https://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller // -//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER +#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER // // ReprapWorld Graphical LCD @@ -2359,8 +2559,9 @@ // Use software PWM to drive the fan, as for the heaters. This uses a very low frequency // which is not as annoying as with the hardware PWM. On the other hand, if this frequency // is too low, you should also increment SOFT_PWM_SCALE. -//#define FAN_SOFT_PWM - +#if ENABLED(TREX3) + #define FAN_SOFT_PWM +#endif // Incrementing this by 1 will double the software PWM frequency, // affecting heaters, and the fan if FAN_SOFT_PWM is enabled. // However, control resolution will be halved for each increment; diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 31661a582e..83e6403eba 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -186,12 +186,12 @@ * THERMAL_PROTECTION_HYSTERESIS and/or THERMAL_PROTECTION_PERIOD */ #if ENABLED(THERMAL_PROTECTION_HOTENDS) - #define THERMAL_PROTECTION_PERIOD 40 // Seconds - #define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius + #define THERMAL_PROTECTION_PERIOD 30 // Seconds + #define THERMAL_PROTECTION_HYSTERESIS 15 // Degrees Celsius - //#define ADAPTIVE_FAN_SLOWING // Slow part cooling fan if temperature drops + #define ADAPTIVE_FAN_SLOWING // Slow part cooling fan if temperature drops #if BOTH(ADAPTIVE_FAN_SLOWING, PIDTEMP) - //#define NO_FAN_SLOWING_IN_PID_TUNING // Don't slow fan speed during M303 + #define NO_FAN_SLOWING_IN_PID_TUNING // Don't slow fan speed during M303 #endif /** @@ -206,7 +206,7 @@ * and/or decrease WATCH_TEMP_INCREASE. WATCH_TEMP_INCREASE should not be set * below 2. */ - #define WATCH_TEMP_PERIOD 20 // Seconds + #define WATCH_TEMP_PERIOD 60 // Seconds #define WATCH_TEMP_INCREASE 2 // Degrees Celsius #endif @@ -214,28 +214,28 @@ * Thermal Protection parameters for the bed are just as above for hotends. */ #if ENABLED(THERMAL_PROTECTION_BED) - #define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds - #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius + #define THERMAL_PROTECTION_BED_PERIOD 80 // Seconds + #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius /** * As described above, except for the bed (M140/M190/M303). */ - #define WATCH_BED_TEMP_PERIOD 60 // Seconds - #define WATCH_BED_TEMP_INCREASE 2 // Degrees Celsius + #define WATCH_BED_TEMP_PERIOD 80 // Seconds + #define WATCH_BED_TEMP_INCREASE 2 // Degrees Celsius #endif /** * Thermal Protection parameters for the heated chamber. */ #if ENABLED(THERMAL_PROTECTION_CHAMBER) - #define THERMAL_PROTECTION_CHAMBER_PERIOD 20 // Seconds + #define THERMAL_PROTECTION_CHAMBER_PERIOD 20 // Seconds #define THERMAL_PROTECTION_CHAMBER_HYSTERESIS 2 // Degrees Celsius /** * Heated chamber watch settings (M141/M191). */ - #define WATCH_CHAMBER_TEMP_PERIOD 60 // Seconds - #define WATCH_CHAMBER_TEMP_INCREASE 2 // Degrees Celsius + #define WATCH_CHAMBER_TEMP_PERIOD 60 // Seconds + #define WATCH_CHAMBER_TEMP_INCREASE 2 // Degrees Celsius #endif #if ENABLED(PIDTEMP) @@ -413,7 +413,7 @@ // When first starting the main fan, run it at full speed for the // given number of milliseconds. This gets the fan spinning reliably // before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu) -//#define FAN_KICKSTART_TIME 100 +#define FAN_KICKSTART_TIME 100 // Some coolers may require a non-zero "off" state. //#define FAN_OFF_PWM 1 @@ -474,8 +474,14 @@ * Multiple extruders can be assigned to the same pin in which case * the fan will turn on when any selected extruder is above the threshold. */ -#define E0_AUTO_FAN_PIN -1 -#define E1_AUTO_FAN_PIN -1 +#if ENABLED(TREX3) + #define E0_AUTO_FAN_PIN 6 + #define E1_AUTO_FAN_PIN 45 +#else + #define E0_AUTO_FAN_PIN -1 + #define E1_AUTO_FAN_PIN -1 +#endif + #define E2_AUTO_FAN_PIN -1 #define E3_AUTO_FAN_PIN -1 #define E4_AUTO_FAN_PIN -1 @@ -503,16 +509,16 @@ /** * M355 Case Light on-off / brightness */ -//#define CASE_LIGHT_ENABLE +#define CASE_LIGHT_ENABLE #if ENABLED(CASE_LIGHT_ENABLE) //#define CASE_LIGHT_PIN 4 // Override the default pin if needed #define INVERT_CASE_LIGHT false // Set true if Case Light is ON when pin is LOW #define CASE_LIGHT_DEFAULT_ON true // Set default power-up state on - #define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // Set default power-up brightness (0-255, requires PWM pin) + #define CASE_LIGHT_DEFAULT_BRIGHTNESS 255 // Set default power-up brightness (0-255, requires PWM pin) //#define CASE_LIGHT_MAX_PWM 128 // Limit pwm - //#define CASE_LIGHT_MENU // Add Case Light options to the LCD menu - //#define CASE_LIGHT_NO_BRIGHTNESS // Disable brightness control. Enable for non-PWM lighting. - //#define CASE_LIGHT_USE_NEOPIXEL // Use NeoPixel LED as case light, requires NEOPIXEL_LED. + #define CASE_LIGHT_MENU // Add Case Light options to the LCD menu + #define CASE_LIGHT_NO_BRIGHTNESS // Disable brightness control. Enable for non-PWM lighting. + //#define CASE_LIGHT_USE_NEOPIXEL // Use Neopixel LED as case light, requires NEOPIXEL_LED. #if ENABLED(CASE_LIGHT_USE_NEOPIXEL) #define CASE_LIGHT_NEOPIXEL_COLOR { 255, 255, 255, 255 } // { Red, Green, Blue, White } #endif @@ -619,12 +625,16 @@ * Set the initial X offset and temperature differential with M605 S2 X[offs] R[deg] and * follow with M605 S3 to initiate mirrored movement. */ -//#define DUAL_X_CARRIAGE +#define DUAL_X_CARRIAGE #if ENABLED(DUAL_X_CARRIAGE) #define X1_MIN_POS X_MIN_POS // Set to X_MIN_POS #define X1_MAX_POS X_BED_SIZE // Set a maximum so the first X-carriage can't hit the parked second X-carriage - #define X2_MIN_POS 80 // Set a minimum to ensure the second X-carriage can't hit the parked first X-carriage - #define X2_MAX_POS 353 // Set this to the distance between toolheads when both heads are homed + #define X2_MIN_POS 0 // Set a minimum to ensure the second X-carriage can't hit the parked first X-carriage + #if DISABLED(TREX3) || ENABLED(TREX3_UPGRADE) + #define X2_MAX_POS 442 // Set this to the distance between toolheads when both heads are homed + #else + #define X2_MAX_POS 446 // Set this to the distance between toolheads when both heads are homed + #endif #define X2_HOME_DIR 1 // Set to 1. The second X-carriage always homes to the maximum endstop position #define X2_HOME_POS X2_MAX_POS // Default X2 home position. Set to X2_MAX_POS. // However: In this mode the HOTEND_OFFSET_X value for the second extruder provides a software @@ -636,8 +646,9 @@ #define DEFAULT_DUAL_X_CARRIAGE_MODE DXC_AUTO_PARK_MODE // Default x offset in duplication mode (typically set to half print bed width) - #define DEFAULT_DUPLICATION_X_OFFSET 100 -#endif + #define DEFAULT_DUPLICATION_X_OFFSET 200 + +#endif // DUAL_X_CARRIAGE // Activate a solenoid on the active extruder with M380. Disable all with M381. // Define SOL0_PIN, SOL1_PIN, etc., for each extruder that has a solenoid. @@ -658,7 +669,7 @@ //#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (mm) Backoff from endstops after homing -//#define QUICK_HOME // If G28 contains XY do a diagonal move first +#define QUICK_HOME // If G28 contains XY do a diagonal move first //#define HOME_Y_BEFORE_X // If G28 contains XY home Y before X //#define CODEPENDENT_XY_HOMING // If X/Y can't home without homing Y/X first @@ -724,7 +735,7 @@ * This feature was designed for Delta's with very fast Z moves however higher speed cartesians may function * If the machine cannot raise the probe fast enough after a trigger, it may enter a fault state. */ - //#define BLTOUCH_HS_MODE + #define BLTOUCH_HS_MODE // Safety: Enable voltage mode settings in the LCD menu. //#define BLTOUCH_LCD_VOLTAGE_MENU @@ -883,7 +894,7 @@ // Backlash Compensation // Adds extra movement to axes on direction-changes to account for backlash. // -//#define BACKLASH_COMPENSATION +#define BACKLASH_COMPENSATION #if ENABLED(BACKLASH_COMPENSATION) // Define values for backlash distance and correction. // If BACKLASH_GCODE is enabled these values are the defaults. @@ -895,7 +906,7 @@ //#define BACKLASH_SMOOTHING_MM 3 // (mm) // Add runtime configuration and tuning of backlash values (M425) - //#define BACKLASH_GCODE + #define BACKLASH_GCODE #if ENABLED(BACKLASH_GCODE) // Measure the Z backlash when probing (G29) and set with "M425 Z" @@ -925,7 +936,9 @@ * Note: HOTEND_OFFSET and CALIBRATION_OBJECT_CENTER must be set to within * ±5mm of true values for G425 to succeed. */ -//#define CALIBRATION_GCODE +#if ENABLED(autoCalibrationKit) + #define CALIBRATION_GCODE +#endif #if ENABLED(CALIBRATION_GCODE) //#define CALIBRATION_SCRIPT_PRE "M117 Starting Auto-Calibration\nT0\nG28\nG12\nM117 Calibrating..." @@ -945,8 +958,8 @@ //#define CALIBRATION_REPORTING // The true location and dimension the cube/bolt/washer on the bed. - #define CALIBRATION_OBJECT_CENTER { 264.0, -22.0, -2.0 } // mm - #define CALIBRATION_OBJECT_DIMENSIONS { 10.0, 10.0, 10.0 } // mm + #define CALIBRATION_OBJECT_CENTER { 264.0, 25.0, 12.5 } // mm + #define CALIBRATION_OBJECT_DIMENSIONS { 12.55, 12.55, 4.0 } // mm // Comment out any sides which are unreachable by the probe. For best // auto-calibration results, all sides must be reachable. @@ -957,12 +970,12 @@ // Probing at the exact top center only works if the center is flat. If // probing on a screwhead or hollow washer, probe near the edges. - //#define CALIBRATION_MEASURE_AT_TOP_EDGES + #define CALIBRATION_MEASURE_AT_TOP_EDGES // Define the pin to read during calibration #ifndef CALIBRATION_PIN - //#define CALIBRATION_PIN -1 // Define here to override the default pin - #define CALIBRATION_PIN_INVERTING false // Set to true to invert the custom pin + #define CALIBRATION_PIN 58 // Override in pins.h or set to -1 to use your Z endstop + #define CALIBRATION_PIN_INVERTING true // Set to true to invert the pin //#define CALIBRATION_PIN_PULLDOWN #define CALIBRATION_PIN_PULLUP #endif @@ -1082,7 +1095,7 @@ #endif // Include a page of printer information in the LCD Main Menu - //#define LCD_INFO_MENU + #define LCD_INFO_MENU #if ENABLED(LCD_INFO_MENU) //#define LCD_PRINTER_INFO_IS_BOOTSCREEN // Show bootscreen(s) instead of Printer Info pages #endif @@ -1119,22 +1132,22 @@ #endif // HAS_LCD_MENU // Scroll a longer status message into view -//#define STATUS_MESSAGE_SCROLLING +#define STATUS_MESSAGE_SCROLLING // On the Info Screen, display XY with one decimal place when possible -//#define LCD_DECIMAL_SMALL_XY +#define LCD_DECIMAL_SMALL_XY // The timeout (in ms) to return to the status screen from sub-menus -//#define LCD_TIMEOUT_TO_STATUS 15000 +#define LCD_TIMEOUT_TO_STATUS 15000 // Add an 'M73' G-code to set the current percentage -//#define LCD_SET_PROGRESS_MANUALLY +#define LCD_SET_PROGRESS_MANUALLY // Show the E position (filament used) during printing //#define LCD_SHOW_E_TOTAL #if ENABLED(SHOW_BOOTSCREEN) - #define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s) + #define BOOTSCREEN_TIMEOUT 2000 // (ms) Total Duration to display the boot screen(s) #endif #if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) @@ -1164,7 +1177,7 @@ // The standard SD detect circuit reads LOW when media is inserted and HIGH when empty. // Enable this option and set to HIGH if your SD cards are incorrectly detected. - //#define SD_DETECT_STATE HIGH + #define SD_DETECT_STATE HIGH //#define SDCARD_READONLY // Read-only SD card (to save over 2K of flash) @@ -1195,7 +1208,7 @@ * an option on the LCD screen to continue the print from the last-known * point in the file. */ - //#define POWER_LOSS_RECOVERY + #define POWER_LOSS_RECOVERY #if ENABLED(POWER_LOSS_RECOVERY) #define PLR_ENABLED_DEFAULT false // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500) //#define BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power loss @@ -1251,10 +1264,10 @@ #endif // This allows hosts to request long names for files and folders with M33 - //#define LONG_FILENAME_HOST_SUPPORT + #define LONG_FILENAME_HOST_SUPPORT // Enable this option to scroll long filenames in the SD card menu - //#define SCROLL_LONG_FILENAMES + #define SCROLL_LONG_FILENAMES // Leave the heaters on after Stop Print (not recommended!) //#define SD_ABORT_NO_COOLDOWN @@ -1276,7 +1289,7 @@ /** * Auto-report SdCard status with M27 S */ - //#define AUTO_REPORT_SD_STATUS + #define AUTO_REPORT_SD_STATUS /** * Support for USB thumb drives using an Arduino USB Host Shield or @@ -1421,7 +1434,7 @@ //#define STATUS_ALT_FAN_BITMAP // Use the alternative fan bitmap //#define STATUS_FAN_FRAMES 3 // :[0,1,2,3,4] Number of fan animation frames //#define STATUS_HEAT_PERCENT // Show heating in a progress bar - //#define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving 399 bytes of flash) + #define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving 399 bytes of flash) //#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~‭3260 (or ~940) bytes of PROGMEM. // Frivolous Game Options @@ -1603,21 +1616,22 @@ * * Warning: Does not respect endstops! */ -//#define BABYSTEPPING +#define BABYSTEPPING #if ENABLED(BABYSTEPPING) - //#define INTEGRATED_BABYSTEPPING // EXPERIMENTAL integration of babystepping into the Stepper ISR + #define INTEGRATED_BABYSTEPPING // EXPERIMENTAL integration of babystepping into the Stepper ISR //#define BABYSTEP_WITHOUT_HOMING //#define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement). //#define BABYSTEP_XY // Also enable X/Y Babystepping. Not supported on DELTA! #define BABYSTEP_INVERT_Z false // Change if Z babysteps should go the other way //#define BABYSTEP_MILLIMETER_UNITS // Specify BABYSTEP_MULTIPLICATOR_(XY|Z) in mm instead of micro-steps - #define BABYSTEP_MULTIPLICATOR_Z 1 // (steps or mm) Steps or millimeter distance for each Z babystep + #define BABYSTEP_MULTIPLICATOR_Z 20 // (steps or mm) Steps or millimeter distance for each Z babystep #define BABYSTEP_MULTIPLICATOR_XY 1 // (steps or mm) Steps or millimeter distance for each XY babystep - //#define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping. + #define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping. #if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING) #define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds. // Note: Extra time may be added to mitigate controller latency. + #define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement). //#define MOVE_Z_WHEN_IDLE // Jump to the move Z menu on doubleclick when printer is idle. #if ENABLED(MOVE_Z_WHEN_IDLE) #define MOVE_Z_IDLE_MULTIPLICATOR 1 // Multiply 1mm by this factor for the move step size. @@ -1626,10 +1640,10 @@ //#define BABYSTEP_DISPLAY_TOTAL // Display total babysteps since last G28 - //#define BABYSTEP_ZPROBE_OFFSET // Combine M851 Z and Babystepping + #define BABYSTEP_ZPROBE_OFFSET // Combine M851 Z and Babystepping #if ENABLED(BABYSTEP_ZPROBE_OFFSET) - //#define BABYSTEP_HOTEND_Z_OFFSET // For multiple hotends, babystep relative Z offsets - //#define BABYSTEP_ZPROBE_GFX_OVERLAY // Enable graphical overlay on Z-offset editor + #define BABYSTEP_HOTEND_Z_OFFSET // For multiple hotends, babystep relative Z offsets + #define BABYSTEP_ZPROBE_GFX_OVERLAY // Enable graphical overlay on Z-offset editor #endif #endif @@ -1650,10 +1664,12 @@ * * See https://marlinfw.org/docs/features/lin_advance.html for full instructions. */ -//#define LIN_ADVANCE +#if DISABLED(E_2208) || ENABLED(E_Spreadcycle) + #define LIN_ADVANCE +#endif #if ENABLED(LIN_ADVANCE) //#define EXTRA_LIN_ADVANCE_K // Enable for second linear advance constants - #define LIN_ADVANCE_K 0.22 // Unit: mm compression per 1mm/s extruder speed + #define LIN_ADVANCE_K 0.0 // Unit: mm compression per 1mm/s extruder speed //#define LA_DEBUG // If enabled, this will generate debug information output over USB. //#define EXPERIMENTAL_SCURVE // Enable this option to permit S-Curve Acceleration #endif @@ -1701,10 +1717,10 @@ #if EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL) // Override the mesh area if the automatic (max) area is too large - //#define MESH_MIN_X MESH_INSET - //#define MESH_MIN_Y MESH_INSET - //#define MESH_MAX_X X_BED_SIZE - (MESH_INSET) - //#define MESH_MAX_Y Y_BED_SIZE - (MESH_INSET) + #define MESH_MIN_X X_MIN_POS + MESH_INSET + #define MESH_MIN_Y Y_MIN_POS + MESH_INSET + #define MESH_MAX_X X_MAX_POS - MESH_INSET + #define MESH_MAX_Y Y_MAX_POS - MESH_INSET #endif /** @@ -1791,7 +1807,9 @@ // // G2/G3 Arc Support // -#define ARC_SUPPORT // Disable this feature to save ~3226 bytes +#if DISABLED(autoCalibrationKit) + #define ARC_SUPPORT // Disable this feature to save ~3226 bytes +#endif #if ENABLED(ARC_SUPPORT) #define MM_PER_ARC_SEGMENT 1 // (mm) Length (or minimum length) of each arc segment //#define ARC_SEGMENTS_PER_R 1 // Max segment length, MM_PER = Min @@ -1893,7 +1911,7 @@ #elif ENABLED(SDSUPPORT) #define BLOCK_BUFFER_SIZE 16 #else - #define BLOCK_BUFFER_SIZE 16 + #define BLOCK_BUFFER_SIZE 16 // maximize block buffer #endif // @section serial @@ -1944,7 +1962,7 @@ * Currently handles M108, M112, M410, M876 * NOTE: Not yet implemented for all platforms. */ -//#define EMERGENCY_PARSER +#define EMERGENCY_PARSER // Bad Serial-connections can miss a received command by sending an 'ok' // Therefore some clients abort after 30 seconds in a timeout. @@ -1953,7 +1971,7 @@ //#define NO_TIMEOUTS 1000 // Milliseconds // Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. -//#define ADVANCED_OK +#define ADVANCED_OK // Printrun may have trouble receiving long strings all at once. // This option inserts short delays between lines of serial output. @@ -1987,7 +2005,9 @@ * * Note that M207 / M208 / M209 settings are saved to EEPROM. */ -//#define FWRETRACT +#if ENABLED(ABL_Bilinear) + #define FWRETRACT +#endif #if ENABLED(FWRETRACT) #define FWRETRACT_AUTORETRACT // Override slicer retractions #if ENABLED(FWRETRACT_AUTORETRACT) @@ -2015,22 +2035,22 @@ // Z raise distance for tool-change, as needed for some extruders #define TOOLCHANGE_ZRAISE 2 // (mm) //#define TOOLCHANGE_ZRAISE_BEFORE_RETRACT // Apply raise before swap retraction (if enabled) - //#define TOOLCHANGE_NO_RETURN // Never return to previous position on tool-change + #define TOOLCHANGE_NO_RETURN // Never return to previous position on tool-change #if ENABLED(TOOLCHANGE_NO_RETURN) - //#define EVENT_GCODE_AFTER_TOOLCHANGE "G12X" // Extra G-code to run after tool-change + #define EVENT_GCODE_AFTER_TOOLCHANGE "G12X" // Extra G-code to run after tool-change #endif /** * Retract and prime filament on tool-change to reduce * ooze and stringing and to get cleaner transitions. */ - //#define TOOLCHANGE_FILAMENT_SWAP + #define TOOLCHANGE_FILAMENT_SWAP #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) // Load / Unload - #define TOOLCHANGE_FS_LENGTH 12 // (mm) Load / Unload length - #define TOOLCHANGE_FS_EXTRA_RESUME_LENGTH 0 // (mm) Extra length for better restart, fine tune by LCD/Gcode) - #define TOOLCHANGE_FS_RETRACT_SPEED (50*60) // (mm/min) (Unloading) - #define TOOLCHANGE_FS_UNRETRACT_SPEED (25*60) // (mm/min) (On SINGLENOZZLE or Bowden loading must be slowed down) + #define TOOLCHANGE_FS_LENGTH 4 // (mm) Load / Unload length + #define TOOLCHANGE_FS_EXTRA_RESUME_LENGTH 2 // (mm) Extra length for better restart, fine tune by LCD/Gcode) + #define TOOLCHANGE_FS_RETRACT_SPEED (50*60) // (mm/m) (Unloading) + #define TOOLCHANGE_FS_UNRETRACT_SPEED (25*60) // (mm/m) (On SINGLENOZZLE or Bowden loading must be slowed down) // Longer prime to clean out a SINGLENOZZLE #define TOOLCHANGE_FS_EXTRA_PRIME 0 // (mm) Extra priming length @@ -2087,49 +2107,49 @@ * Requires NOZZLE_PARK_FEATURE. * This feature is required for the default FILAMENT_RUNOUT_SCRIPT. */ -//#define ADVANCED_PAUSE_FEATURE +#define ADVANCED_PAUSE_FEATURE #if ENABLED(ADVANCED_PAUSE_FEATURE) #define PAUSE_PARK_RETRACT_FEEDRATE 60 // (mm/s) Initial retract feedrate. - #define PAUSE_PARK_RETRACT_LENGTH 2 // (mm) Initial retract. + #define PAUSE_PARK_RETRACT_LENGTH 4 // (mm) Initial retract. // This short retract is done immediately, before parking the nozzle. - #define FILAMENT_CHANGE_UNLOAD_FEEDRATE 10 // (mm/s) Unload filament feedrate. This can be pretty fast. + #define FILAMENT_CHANGE_UNLOAD_FEEDRATE 41 // (mm/s) Unload filament feedrate. This can be pretty fast. #define FILAMENT_CHANGE_UNLOAD_ACCEL 25 // (mm/s^2) Lower acceleration may allow a faster feedrate. - #define FILAMENT_CHANGE_UNLOAD_LENGTH 100 // (mm) The length of filament for a complete unload. + #define FILAMENT_CHANGE_UNLOAD_LENGTH 70 // (mm) The length of filament for a complete unload. // For Bowden, the full length of the tube and nozzle. // For direct drive, the full length of the nozzle. // Set to 0 for manual unloading. #define FILAMENT_CHANGE_SLOW_LOAD_FEEDRATE 6 // (mm/s) Slow move when starting load. #define FILAMENT_CHANGE_SLOW_LOAD_LENGTH 0 // (mm) Slow length, to allow time to insert material. // 0 to disable start loading and skip to fast load only - #define FILAMENT_CHANGE_FAST_LOAD_FEEDRATE 6 // (mm/s) Load filament feedrate. This can be pretty fast. + #define FILAMENT_CHANGE_FAST_LOAD_FEEDRATE 30 // (mm/s) Load filament feedrate. This can be pretty fast. #define FILAMENT_CHANGE_FAST_LOAD_ACCEL 25 // (mm/s^2) Lower acceleration may allow a faster feedrate. - #define FILAMENT_CHANGE_FAST_LOAD_LENGTH 0 // (mm) Load length of filament, from extruder gear to nozzle. + #define FILAMENT_CHANGE_FAST_LOAD_LENGTH 50 // (mm) Load length of filament, from extruder gear to nozzle. // For Bowden, the full length of the tube and nozzle. // For direct drive, the full length of the nozzle. //#define ADVANCED_PAUSE_CONTINUOUS_PURGE // Purge continuously up to the purge length until interrupted. #define ADVANCED_PAUSE_PURGE_FEEDRATE 3 // (mm/s) Extrude feedrate (after loading). Should be slower than load feedrate. - #define ADVANCED_PAUSE_PURGE_LENGTH 50 // (mm) Length to extrude after loading. + #define ADVANCED_PAUSE_PURGE_LENGTH 20 // (mm) Length to extrude after loading. // Set to 0 for manual extrusion. // Filament can be extruded repeatedly from the Filament Change menu // until extrusion is consistent, and to purge old filament. - #define ADVANCED_PAUSE_RESUME_PRIME 0 // (mm) Extra distance to prime nozzle after returning from park. - //#define ADVANCED_PAUSE_FANS_PAUSE // Turn off print-cooling fans while the machine is paused. + #define ADVANCED_PAUSE_RESUME_PRIME 2 // (mm) Extra distance to prime nozzle after returning from park. + #define ADVANCED_PAUSE_FANS_PAUSE // Turn off print-cooling fans while the machine is paused. // Filament Unload does a Retract, Delay, and Purge first: - #define FILAMENT_UNLOAD_PURGE_RETRACT 13 // (mm) Unload initial retract length. - #define FILAMENT_UNLOAD_PURGE_DELAY 5000 // (ms) Delay for the filament to cool after retract. + #define FILAMENT_UNLOAD_PURGE_RETRACT 4 // (mm) Unload initial retract length. + #define FILAMENT_UNLOAD_PURGE_DELAY 2000 // (ms) Delay for the filament to cool after retract. #define FILAMENT_UNLOAD_PURGE_LENGTH 8 // (mm) An unretract is done, then this length is purged. #define FILAMENT_UNLOAD_PURGE_FEEDRATE 25 // (mm/s) feedrate to purge before unload #define PAUSE_PARK_NOZZLE_TIMEOUT 45 // (seconds) Time limit before the nozzle is turned off for safety. - #define FILAMENT_CHANGE_ALERT_BEEPS 10 // Number of alert beeps to play when a response is needed. + #define FILAMENT_CHANGE_ALERT_BEEPS 1 // Number of alert beeps to play when a response is needed. #define PAUSE_PARK_NO_STEPPER_TIMEOUT // Enable for XYZ steppers to stay powered on during filament change. - //#define PARK_HEAD_ON_PAUSE // Park the nozzle during pause and filament change. - //#define HOME_BEFORE_FILAMENT_CHANGE // If needed, home before parking for filament change + #define PARK_HEAD_ON_PAUSE // Park the nozzle during pause and filament change. + #define HOME_BEFORE_FILAMENT_CHANGE // If needed, home before parking for filament change - //#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 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) #endif // @section tmc @@ -2932,13 +2952,18 @@ * See https://marlinfw.org/docs/configuration/laser_spindle.html for more config details. */ //#define SPINDLE_FEATURE -//#define LASER_FEATURE +#if ENABLED(TREX3) + #define LASER_FEATURE +#endif #if EITHER(SPINDLE_FEATURE, LASER_FEATURE) - #define SPINDLE_LASER_ACTIVE_STATE LOW // Set to "HIGH" if the on/off function is active HIGH - #define SPINDLE_LASER_PWM true // Set to "true" if your controller supports setting the speed/power - #define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower + //#define SHOW_CUTTER_ICON + #define SPINDLE_LASER_ACTIVE_HIGH true // Set to "true" if the on/off function is active HIGH + #define SPINDLE_LASER_PWM false // Set to "true" if your controller supports setting the speed/power + #define SPINDLE_LASER_PWM_INVERT true // Set to "true" if the speed/power goes up when you want it to go slower - #define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR and LPC) + #if ENABLED(SPINDLE_LASER_PWM) + //#define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR and LPC) + #endif /** * Speed / Power can be set ('M3 S') and displayed in terms of: @@ -2963,8 +2988,8 @@ #define SPINDLE_CHANGE_DIR_STOP // Enable if the spindle should stop before changing spin direction #define SPINDLE_INVERT_DIR false // Set to "true" if the spin direction is reversed - #define SPINDLE_LASER_POWERUP_DELAY 5000 // (ms) Delay to allow the spindle/laser to come up to speed/power - #define SPINDLE_LASER_POWERDOWN_DELAY 5000 // (ms) Delay to allow the spindle to stop + #define SPINDLE_LASER_POWERUP_DELAY 1 // (ms) Delay to allow the spindle/laser to come up to speed/power + #define SPINDLE_LASER_POWERDOWN_DELAY 1 // (ms) Delay to allow the spindle to stop /** * M3/M4 Power Equation @@ -3005,7 +3030,7 @@ * - Ramps the power up every N steps to approximate the speed trapezoid. * - Due to the limited power resolution this is only approximate. */ - #define LASER_POWER_INLINE_TRAPEZOID + //#define LASER_POWER_INLINE_TRAPEZOID /** * Continuously calculate the current power (nominal_power * current_rate / nominal_rate). @@ -3261,27 +3286,37 @@ /** * User-defined menu items that execute custom GCode */ -//#define CUSTOM_USER_MENUS +#define CUSTOM_USER_MENUS #if ENABLED(CUSTOM_USER_MENUS) - //#define CUSTOM_USER_MENU_TITLE "Custom Commands" - #define USER_SCRIPT_DONE "M117 User Script Done" + //#define USER_SCRIPT_DONE "M117 User Script Done" + #define CUSTOM_USER_MENU_TITLE "Setup" #define USER_SCRIPT_AUDIBLE_FEEDBACK - //#define USER_SCRIPT_RETURN // Return to status screen after a script + #define USER_SCRIPT_RETURN // Return to status screen after a script - #define USER_DESC_1 "Home & UBL Info" - #define USER_GCODE_1 "G28\nG29 W" + #if ENABLED(TREX3) + #define COMMFANNSPEED " " + #else + #define COMMFANNSPEED "M106 S128 \n" + #endif - #define USER_DESC_2 "Preheat for " PREHEAT_1_LABEL - #define USER_GCODE_2 "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) + #define USER_DESC_1 "Mesh Setup" + #define USER_DESC_3 "Prep for Z Adjust" + #if ENABLED(ABL_Bilinear) + #define USER_GCODE_1 "M502 \n M500 \n M501 \n M190 S75 \n G28 \n G29 \n M500 \n G28 \n M420 S1 \n " COMMFANNSPEED " M109 S225 \n G1 X100 Y 100 \n G1 Z0 \n M77 \n M117 Set Z Offset" + #define USER_GCODE_3 "M190 S75 \n " COMMFANNSPEED " M104 235 \n G28 \n M420 S1 \n G1 X100 Y 100 \n G1 Z0" + #else + #define USER_GCODE_1 "M502 \n M500 \n M501 \n M190 S75 \n G28 \n G29 P1 \n G29 S1 \n G29 S0 \n G29 F 10.0 \n G29 A \n M500 \n G28 \n G29 L1 \n " COMMFANNSPEED " M109 S225 \n G1 X150 Y 150 \n G1 Z0 \n M77 \n M117 Set Z Offset" + #define USER_GCODE_3 "M190 S75 \n " COMMFANNSPEED " M104 235 \n G28 \n G29 L1 \n G1 X100 Y 100 \n G1 Z0" + #endif - #define USER_DESC_3 "Preheat for " PREHEAT_2_LABEL - #define USER_GCODE_3 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) + #define USER_DESC_4 "Fill Mesh Points" + #define USER_GCODE_4 "G29 P3 \n G29 P3 \n G29 P3 \n G29 T" - #define USER_DESC_4 "Heat Bed/Home/Level" - #define USER_GCODE_4 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29" + #define USER_DESC_2 "PID Bed" + #define USER_GCODE_2 "M303 C4 S75 E-1 U \n M500 \n M117 PID Tune Done" - #define USER_DESC_5 "Home & Info" - #define USER_GCODE_5 "G28\nM503" + #define USER_DESC_5 "Run Mesh Validation" + #define USER_GCODE_5 "G26" #endif /** @@ -3298,10 +3333,10 @@ * Host Prompt Support enables Marlin to use the host for user prompts so * filament runout and other processes can be managed from the host side. */ -//#define HOST_ACTION_COMMANDS +#define HOST_ACTION_COMMANDS #if ENABLED(HOST_ACTION_COMMANDS) - //#define HOST_PROMPT_SUPPORT - //#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start + #define HOST_PROMPT_SUPPORT + #define HOST_START_MENU_ITEM // Add a menu item that tells the host to start #endif /** @@ -3309,7 +3344,7 @@ * * Implement M486 to allow Marlin to skip objects */ -//#define CANCEL_OBJECTS +#define CANCEL_OBJECTS /** * I2C position encoders for closed loop control. diff --git a/Marlin/Version.h b/Marlin/Version.h index fe0724fbfc..6bbf3a221d 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -28,25 +28,25 @@ /** * Marlin release version identifier */ -//#define SHORT_BUILD_VERSION "bugfix-2.0.x" +#define SHORT_BUILD_VERSION "2.0.5_TR25" /** * Verbose version identifier which should contain a reference to the location * from where the binary was downloaded or the source code was compiled. */ -//#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION +#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " TM3D" /** * The STRING_DISTRIBUTION_DATE represents when the binary file was built, * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2019-07-10" +#define STRING_DISTRIBUTION_DATE "2020-06-15" /** * Defines a generic printer name to be output to the LCD after booting Marlin. */ -//#define MACHINE_NAME "3D Printer" +#define MACHINE_NAME "TM3D Trex" /** * The SOURCE_CODE_URL is the location where users will find the Marlin Source @@ -54,7 +54,7 @@ * has a distinct Github fork— the Source Code URL should just be the main * Marlin repository. */ -//#define SOURCE_CODE_URL "https://github.com/MarlinFirmware/Marlin" +#define SOURCE_CODE_URL "https://github.com/InsanityAutomation/Marlin/tree/TM_Trex2+_2.0.x" /** * Default generic printer UUID. @@ -65,7 +65,7 @@ * The WEBSITE_URL is the location where users can get more information such as * documentation about a specific Marlin release. */ -//#define WEBSITE_URL "https://marlinfw.org" +#define WEBSITE_URL "tinymachines3d.com" /** * Set the vendor info the serial USB interface, if changable diff --git a/Marlin/_Bootscreen.h b/Marlin/_Bootscreen.h new file mode 100644 index 0000000000..d262102e47 --- /dev/null +++ b/Marlin/_Bootscreen.h @@ -0,0 +1,93 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Custom Bitmap for splashscreen + * + * You may use one of the following tools to generate the C++ bitmap array from + * a black and white image: + * + * - http://www.marlinfw.org/tools/u8glib/converter.html + * - http://www.digole.com/tools/PicturetoC_Hex_converter.php + */ + +#define CUSTOM_BOOTSCREEN_TIMEOUT 2500 +#define CUSTOM_BOOTSCREEN_BMPWIDTH 128 +#define CUSTOM_BOOTSCREEN_INVERTED + +const unsigned char custom_start_bmp[] PROGMEM = { + B11111101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111, + B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111, + B11111101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111, + B11111110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111, + B11111100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111, + B11111110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111, + B11111100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111, + B11111110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111, + B11111100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111, + B11111110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111, + B11111100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111, + B11111110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111, + B11111100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000000,B00000001,B11110000,B00111111, + B11111110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000000,B00000010,B00001000,B00011111, + B11111100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000000,B00000101,B00000100,B00111111, + B11111110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000000,B00001010,B00000010,B00011111, + B11111100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000000,B00010101,B00000001,B00111111, + B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000000,B00011000,B00000001,B00011111, + B11111100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000000,B00010100,B00000001,B00111111, + B11111110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000000,B00011000,B00000001,B00011111, + B11111100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B00010101,B00000001,B00111111, + B11111110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101010,B00001010,B00000010,B00011111, + B11111100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010001,B00000101,B00000100,B00111111, + B11111110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100001,B00000010,B10001000,B00011111, + B11111100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010001,B00000001,B11110000,B00111111, + B11111110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101010,B00000000,B00000000,B00011111, + B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00000000,B00000000,B00111111, + B11111110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111, + B11111100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111, + B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111111,B11111111,B11111111,B10011111, + B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010101,B01010101,B01010101,B10111111, + B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111, + B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000001,B00000100,B00010001,B10111111, + B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111, + B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111, + B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000001,B00000100,B00010001,B10111111, + B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111, + B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010101,B01010101,B01010101,B10111111, + B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111111,B11111111,B11111111,B10011111, + B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111, + B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111, + B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111, + B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111, + B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111, + B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111, + B11100000,B00101110,B11111011,B01111101,B11111011,B11111011,B11001111,B11000001,B11011111,B10111011,B00111110,B11000000,B11100001,B11111110,B00111100,B00011111, + B11111101,B11101110,B01111011,B00111001,B11111001,B11110011,B11001111,B10011110,B11011111,B10111011,B00111110,B11011111,B11011110,B11111100,B11011101,B11100111, + B11111101,B11101110,B00111011,B10111011,B11111001,B11101011,B11010111,B10111111,B01011111,B10111011,B01011110,B11011111,B11011110,B11111101,B11101101,B11110111, + B11111101,B11101110,B10111011,B11010011,B11111010,B11101011,B10110111,B00111111,B11011111,B10111011,B01001110,B11011111,B11011111,B11111111,B11001101,B11110011, + B11111101,B11101110,B11011011,B11000111,B11111010,B11101011,B10111011,B01111111,B11000000,B00111011,B01101110,B11000000,B11100011,B11111111,B00011101,B11110011, + B11111101,B11101110,B11001011,B11101111,B11111010,B11011011,B10111011,B01111111,B11011111,B10111011,B01100110,B11011111,B11111000,B11111111,B11001101,B11110011, + B11111101,B11101110,B11101011,B11101111,B11111011,B01011011,B00000011,B00111111,B01011111,B10111011,B01110110,B11011111,B11111110,B01111111,B11101101,B11110011, + B11111101,B11101110,B11110011,B11101111,B11111011,B01011011,B01111001,B10111110,B11011111,B10111011,B01111010,B11011111,B11011110,B01111101,B11101101,B11110111, + B11111101,B11101110,B11110011,B11101111,B11111011,B10111010,B11111101,B10011110,B11011111,B10111011,B01111100,B11011111,B11011110,B11111101,B11001101,B11100111, + B11111101,B11101110,B11111011,B11101111,B11111011,B10111010,B11111101,B11000001,B11011111,B10111011,B01111110,B11000000,B11100000,B11111110,B00011100,B00011111 +}; diff --git a/Marlin/_Statusscreen.h b/Marlin/_Statusscreen.h new file mode 100644 index 0000000000..d0450837ab --- /dev/null +++ b/Marlin/_Statusscreen.h @@ -0,0 +1,74 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Custom Status Screen bitmap + * + * Place this file in the root with your configuration files + * and enable CUSTOM_STATUS_SCREEN_IMAGE in Configuration.h. + * + * Use the Marlin Bitmap Converter to make your own: + * http://marlinfw.org/tools/u8glib/converter.html + */ + +// +// Status Screen Logo bitmap +// +#define STATUS_LOGO_Y 3 +#define STATUS_LOGO_WIDTH 24 + +const unsigned char status_logo_bmp[] PROGMEM = { + B11111111,B11111111,B11111111, + B10000000,B00000000,B00000001, + B10001110,B00000000,B11100001, + B10011111,B00000001,B11110001, + B10010011,B10000001,B00111001, + B10011111,B10000001,B11111001, + B10011111,B10000001,B11111001, + B10011111,B10111001,B11111001, + B10001111,B00101000,B11110001, + B10000000,B00111000,B00000001, + B10000000,B00000000,B00000001, + B10011111,B11111111,B11111001, + B10010001,B01110100,B10011001, + B10011011,B00000110,B10101001, + B10011011,B01010100,B10101001, + B10011011,B01010110,B10101001, + B10011011,B01010100,B10011001, + B10011111,B11111111,B11111001, + B11111111,B11111111,B11111111 +}; + +// +// Use default bitmaps +// +#define STATUS_HOTEND_ANIM +#define STATUS_BED_ANIM +#if HOTENDS < 2 + #define STATUS_LOGO_X 8 + #define STATUS_HEATERS_X 40 + #define STATUS_BED_X 72 +#else + #define STATUS_LOGO_X 0 + #define STATUS_HEATERS_X 32 + #define STATUS_BED_X 80 +#endif From 9eb4fc1cfd915e58203ae746630da97e74193264 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 20 Jun 2020 10:10:13 -0400 Subject: [PATCH 04/58] Update Configuration_adv.h --- Marlin/Configuration_adv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 83e6403eba..c35d4cc931 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3344,7 +3344,7 @@ * * Implement M486 to allow Marlin to skip objects */ -#define CANCEL_OBJECTS +//#define CANCEL_OBJECTS /** * I2C position encoders for closed loop control. From 62465cdf23e546d4d4f7ac940d8e48af2c36e65f Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 21 Jun 2020 10:07:20 -0400 Subject: [PATCH 05/58] Disable mesh validation pattern for UBL builds to fit --- Marlin/Configuration.h | 4 +++- Marlin/Version.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index aa41f715c2..97c4f4de77 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1470,7 +1470,9 @@ /** * Enable the G26 Mesh Validation Pattern tool. */ - #define G26_MESH_VALIDATION + #if ENABLED(ABL_Bilinear) + #define G26_MESH_VALIDATION + #endif #if ENABLED(G26_MESH_VALIDATION) #define MESH_TEST_NOZZLE_SIZE 0.4 // (mm) Diameter of primary nozzle. #define MESH_TEST_LAYER_HEIGHT 0.2 // (mm) Default layer height for the G26 Mesh Validation Tool. diff --git a/Marlin/Version.h b/Marlin/Version.h index 6bbf3a221d..bc61def27d 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -#define STRING_DISTRIBUTION_DATE "2020-06-15" +#define STRING_DISTRIBUTION_DATE "2020-06-21" /** * Defines a generic printer name to be output to the LCD after booting Marlin. From 23d024309e71c27a1431fe24ca1daffd5f68bb02 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Thu, 2 Jul 2020 15:52:47 -0400 Subject: [PATCH 06/58] Update runout.cpp --- Marlin/src/feature/runout.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 50e18e52ef..16eb928803 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -40,6 +40,7 @@ bool FilamentMonitorBase::enabled = true, #endif #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) + #define DEBUG_TOOLCHANGE_MIGRATION_FEATURE #include "../module/tool_change.h" #define DEBUG_OUT ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE) #include "../core/debug_out.h" From 8fe3650376cbe5f237308105b65e0188fba14d59 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Mon, 15 Jun 2020 11:52:54 -0400 Subject: [PATCH 07/58] Bump to head, fix compile errors --- Marlin/Configuration_adv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index c35d4cc931..83e6403eba 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3344,7 +3344,7 @@ * * Implement M486 to allow Marlin to skip objects */ -//#define CANCEL_OBJECTS +#define CANCEL_OBJECTS /** * I2C position encoders for closed loop control. From e4e9915d840b2d66dff718ef0e52790cc8d3bf67 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 20 Jun 2020 10:10:13 -0400 Subject: [PATCH 08/58] Update Configuration_adv.h --- Marlin/Configuration_adv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 83e6403eba..c35d4cc931 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3344,7 +3344,7 @@ * * Implement M486 to allow Marlin to skip objects */ -#define CANCEL_OBJECTS +//#define CANCEL_OBJECTS /** * I2C position encoders for closed loop control. From aa5a7f5c13bd6d31360c75d1d3ba233d1b33b87b Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 8 Aug 2020 12:14:26 -0400 Subject: [PATCH 09/58] Add SKR12Pro Support --- Marlin/Configuration.h | 132 +++++++++++++++++++++++-------------- Marlin/Configuration_adv.h | 67 ++++++++++++++----- 2 files changed, 130 insertions(+), 69 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 97c4f4de77..17be399234 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -41,6 +41,8 @@ //#define autoCalibrationKit +//#define SKR12Pro + //////////////////////////////////DO not edit below here unless you know what youre doing! ////////////////////////////////// /** @@ -165,14 +167,20 @@ * * :[-1, 0, 1, 2, 3, 4, 5, 6, 7] */ -#define SERIAL_PORT 0 +#if ENABLED(SKR12Pro) + #define SERIAL_PORT -1 +#else + #define SERIAL_PORT 0 +#endif /** * Select a secondary serial port on the board to use for communication with the host. * Currently Ethernet (-2) is only supported on Teensy 4.1 boards. * :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7] */ -//#define SERIAL_PORT_2 -1 +#if ENABLED(SKR12Pro) + #define SERIAL_PORT_2 1 +#endif /** * This setting determines the communication speed of the printer. @@ -190,11 +198,13 @@ // Choose the name from boards.h that matches your setup #ifndef MOTHERBOARD -#if ENABLED(TREX3) - #define MOTHERBOARD BOARD_FORMBOT_TREX3 -#else - #define MOTHERBOARD BOARD_FORMBOT_TREX2PLUS -#endif + #if ENABLED(SKR12Pro) + #define MOTHERBOARD BOARD_BTT_SKR_PRO_V1_2 + #elif ENABLED(TREX3) + #define MOTHERBOARD BOARD_FORMBOT_TREX3 + #else + #define MOTHERBOARD BOARD_FORMBOT_TREX2PLUS + #endif #endif // Optional custom name for your RepStrap or other custom machine @@ -634,7 +644,7 @@ * heater. If your configuration is significantly different than this and you don't understand * the issues involved, don't use bed PID until someone else verifies that your hardware works. */ -//#define PIDTEMPBED +#define PIDTEMPBED //#define BED_LIMIT_SWITCHING @@ -790,38 +800,58 @@ * TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE'] */ -#if ENABLED(X_2208) - #define X_DRIVER_TYPE TMC2208_STANDALONE - #define X2_DRIVER_TYPE TMC2208_STANDALONE + +#if ENABLED(SKR12Pro) + #if ENABLED(TMC2209Upgrade) + #define X_DRIVER_TYPE TMC2209 + #define X2_DRIVER_TYPE TMC2209 + #define Y_DRIVER_TYPE TMC2209 + #define Z_DRIVER_TYPE TMC2209 + #define E0_DRIVER_TYPE TMC2209 + #define E1_DRIVER_TYPE TMC2209 + #else + #define X_DRIVER_TYPE TMC2208 + #define X2_DRIVER_TYPE TMC2208 + #define Y_DRIVER_TYPE TMC2208 + #define Z_DRIVER_TYPE TMC2208 + #define E0_DRIVER_TYPE TMC2208 + #define E1_DRIVER_TYPE TMC2208 + #endif #else - #define X_DRIVER_TYPE A4988 - #define X2_DRIVER_TYPE A4988 -#endif -#if ENABLED(Y_2208) - #define Y_DRIVER_TYPE TMC2208_STANDALONE -#elif ENABLED(Y_4988) - #define Y_DRIVER_TYPE A4988 -#else - #define Y_DRIVER_TYPE DRV8825 -#endif -#if ENABLED(Z_2208) - #define Z_DRIVER_TYPE TMC2208_STANDALONE -#elif ENABLED(Z_4988) - #define Z_DRIVER_TYPE A4988 -#else - #define Z_DRIVER_TYPE DRV8825 -#endif -//#define Y2_DRIVER_TYPE A4988 -//#define Z2_DRIVER_TYPE A4988 -//#define Z3_DRIVER_TYPE A4988 -//#define Z4_DRIVER_TYPE A4988 -#if ENABLED(E_2208) - #define E0_DRIVER_TYPE TMC2208_STANDALONE - #define E1_DRIVER_TYPE TMC2208_STANDALONE -#else - #define E0_DRIVER_TYPE DRV8825 - #define E1_DRIVER_TYPE DRV8825 + #if ENABLED(X_2208) + #define X_DRIVER_TYPE TMC2208_STANDALONE + #define X2_DRIVER_TYPE TMC2208_STANDALONE + #else + #define X_DRIVER_TYPE A4988 + #define X2_DRIVER_TYPE A4988 + #endif + #if ENABLED(Y_2208) + #define Y_DRIVER_TYPE TMC2208_STANDALONE + #elif ENABLED(Y_4988) + #define Y_DRIVER_TYPE A4988 + #else + #define Y_DRIVER_TYPE DRV8825 + #endif + #if ENABLED(Z_2208) + #define Z_DRIVER_TYPE TMC2208_STANDALONE + #elif ENABLED(Z_4988) + #define Z_DRIVER_TYPE A4988 + #else + #define Z_DRIVER_TYPE DRV8825 + #endif + //#define Y2_DRIVER_TYPE A4988 + //#define Z2_DRIVER_TYPE A4988 + //#define Z3_DRIVER_TYPE A4988 + //#define Z4_DRIVER_TYPE A4988 + #if ENABLED(E_2208) + #define E0_DRIVER_TYPE TMC2208_STANDALONE + #define E1_DRIVER_TYPE TMC2208_STANDALONE + #else + #define E0_DRIVER_TYPE DRV8825 + #define E1_DRIVER_TYPE DRV8825 + #endif #endif + //#define E2_DRIVER_TYPE A4988 //#define E3_DRIVER_TYPE A4988 //#define E4_DRIVER_TYPE A4988 @@ -868,7 +898,7 @@ * following movement settings. If fewer factors are given than the * total number of extruders, the last value applies to the rest. */ -//#define DISTINCT_E_FACTORS +#define DISTINCT_E_FACTORS /** * Default Axis Steps Per Unit (steps/mm) @@ -889,7 +919,7 @@ #define Z_STEPSMM 1600 #endif -#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, Y_STEPSMM, Z_STEPSMM, 93 } +#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, Y_STEPSMM, Z_STEPSMM, 93, 93 } /** * Default Max Feed Rate (mm/s) @@ -901,7 +931,7 @@ #else #define Y_MAXFEED 150 #endif -#define DEFAULT_MAX_FEEDRATE { 200, Y_MAXFEED, 8, 75 } +#define DEFAULT_MAX_FEEDRATE { 200, Y_MAXFEED, 8, 75, 75 } #define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2 #if ENABLED(LIMITED_MAX_FR_EDITING) @@ -914,7 +944,7 @@ * Override with M201 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_MAX_ACCELERATION { 750, 500, 400, 3000 } +#define DEFAULT_MAX_ACCELERATION { 750, 500, 400, 3000, 3000 } #define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2 #if ENABLED(LIMITED_MAX_ACCEL_EDITING) @@ -951,7 +981,7 @@ //#define LIMITED_JERK_EDITING // Limit edit via M205 or LCD to DEFAULT_aJERK * 2 #if ENABLED(LIMITED_JERK_EDITING) - #define MAX_JERK_EDIT_VALUES { 20, 20, 0.6, 10 } // ...or, set your own edit limits + #define MAX_JERK_EDIT_VALUES { 20, 20, 0.6, 10, 10 } // ...or, set your own edit limits #endif #endif @@ -1243,17 +1273,17 @@ // @section machine // Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. -#if ENABLED(X_2208) +#if ANY(X_2208, SKR12Pro) #define INVERT_X_DIR true #else #define INVERT_X_DIR false #endif -#if ENABLED(Y_2208) +#if ANY(Y_2208, SKR12Pro) #define INVERT_Y_DIR true #else #define INVERT_Y_DIR false #endif -#if ENABLED(Z_2208) +#if ANY(Z_2208, SKR12Pro) #define INVERT_Z_DIR false #else #define INVERT_Z_DIR true @@ -1261,7 +1291,7 @@ // @section extruder // For direct drive extruder v9 set to true, for geared extruder set to false. -#if ENABLED(E_2208) && DISABLED(TREX3) +#if ANY(E_2208, SKR12Pro) && DISABLED(TREX3) #define INVERT_E0_DIR true #define INVERT_E1_DIR false #else @@ -1802,11 +1832,11 @@ // Move the nozzle to the initial position after cleaning #define NOZZLE_CLEAN_GOBACK - // For a purge/clean station that's always at the gantry height (thus no Z move) - //#define NOZZLE_CLEAN_NO_Z + // Enable for a purge/clean station that's always at the gantry height (thus no Z move) + #define NOZZLE_CLEAN_NO_Z // For a purge/clean station mounted on the X axis - //#define NOZZLE_CLEAN_NO_Y + #define NOZZLE_CLEAN_NO_Y // Explicit wipe G-code script applies to a G12 with no arguments. //#define WIPE_SEQUENCE_COMMANDS "G1 X-17 Y25 Z10 F4000\nG1 Z1\nM114\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 Z15\nM400\nG0 X-10.0 Y-9.0" @@ -2561,7 +2591,7 @@ // Use software PWM to drive the fan, as for the heaters. This uses a very low frequency // which is not as annoying as with the hardware PWM. On the other hand, if this frequency // is too low, you should also increment SOFT_PWM_SCALE. -#if ENABLED(TREX3) +#if ENABLED(TREX3) && DISABLED(SKR12Pro) #define FAN_SOFT_PWM #endif // Incrementing this by 1 will double the software PWM frequency, diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index c35d4cc931..eb1e33e1af 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -474,7 +474,10 @@ * Multiple extruders can be assigned to the same pin in which case * the fan will turn on when any selected extruder is above the threshold. */ -#if ENABLED(TREX3) +#if BOTH(SKR12Pro, TREX3) + #define E0_AUTO_FAN_PIN FAN2_PIN + #define E1_AUTO_FAN_PIN FAN2_PIN +#elif ENABLED(TREX3) #define E0_AUTO_FAN_PIN 6 #define E1_AUTO_FAN_PIN 45 #else @@ -511,7 +514,9 @@ */ #define CASE_LIGHT_ENABLE #if ENABLED(CASE_LIGHT_ENABLE) - //#define CASE_LIGHT_PIN 4 // Override the default pin if needed + #if ENABLED(SKR12Pro) + #define CASE_LIGHT_PIN HEATER_2_PIN // Override the default pin if needed + #endif #define INVERT_CASE_LIGHT false // Set true if Case Light is ON when pin is LOW #define CASE_LIGHT_DEFAULT_ON true // Set default power-up state on #define CASE_LIGHT_DEFAULT_BRIGHTNESS 255 // Set default power-up brightness (0-255, requires PWM pin) @@ -871,7 +876,11 @@ // Increase the slowdown divisor for larger buffer sizes. #define SLOWDOWN #if ENABLED(SLOWDOWN) - #define SLOWDOWN_DIVISOR 2 + #if ENABLED(SKR12Pro) + #define SLOWDOWN_DIVISOR 6 + #else + #define SLOWDOWN_DIVISOR 2 + #endif #endif /** @@ -955,7 +964,9 @@ #define CALIBRATION_NOZZLE_OUTER_DIAMETER 2.0 // mm // Uncomment to enable reporting (required for "G425 V", but consumes PROGMEM). - //#define CALIBRATION_REPORTING + #if ENABLED(SKR12Pro) + #define CALIBRATION_REPORTING + #endif // The true location and dimension the cube/bolt/washer on the bed. #define CALIBRATION_OBJECT_CENTER { 264.0, 25.0, 12.5 } // mm @@ -974,7 +985,11 @@ // Define the pin to read during calibration #ifndef CALIBRATION_PIN - #define CALIBRATION_PIN 58 // Override in pins.h or set to -1 to use your Z endstop + #if ENABLED(SKR12Pro) + #define CALIBRATION_PIN Z_MAX + #else + #define CALIBRATION_PIN 58 // Override in pins.h or set to -1 to use your Z endstop + #endif #define CALIBRATION_PIN_INVERTING true // Set to true to invert the pin //#define CALIBRATION_PIN_PULLDOWN #define CALIBRATION_PIN_PULLUP @@ -1351,7 +1366,9 @@ * * :[ 'LCD', 'ONBOARD', 'CUSTOM_CABLE' ] */ - //#define SDCARD_CONNECTION LCD + #if ENABLED(SKR12Pro) + #define SDCARD_CONNECTION ONBOARD + #endif #endif // SDSUPPORT @@ -1434,8 +1451,11 @@ //#define STATUS_ALT_FAN_BITMAP // Use the alternative fan bitmap //#define STATUS_FAN_FRAMES 3 // :[0,1,2,3,4] Number of fan animation frames //#define STATUS_HEAT_PERCENT // Show heating in a progress bar - #define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving 399 bytes of flash) - //#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~‭3260 (or ~940) bytes of PROGMEM. + #if DISABLED(SKR12Pro) + #define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving 399 bytes of flash) + #else + #define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~‭3260 (or ~940) bytes of PROGMEM. + #endif // Frivolous Game Options //#define MARLIN_BRICKOUT @@ -1665,7 +1685,7 @@ * See https://marlinfw.org/docs/features/lin_advance.html for full instructions. */ #if DISABLED(E_2208) || ENABLED(E_Spreadcycle) - #define LIN_ADVANCE + //#define LIN_ADVANCE #endif #if ENABLED(LIN_ADVANCE) //#define EXTRA_LIN_ADVANCE_K // Enable for second linear advance constants @@ -1807,7 +1827,7 @@ // // G2/G3 Arc Support // -#if DISABLED(autoCalibrationKit) +#if DISABLED(autoCalibrationKit, SKR12Pro) #define ARC_SUPPORT // Disable this feature to save ~3226 bytes #endif #if ENABLED(ARC_SUPPORT) @@ -1906,7 +1926,9 @@ // The number of linear moves that can be in the planner at once. // The value of BLOCK_BUFFER_SIZE must be a power of 2 (e.g. 8, 16, 32) -#if BOTH(SDSUPPORT, DIRECT_STEPPING) +#if ENABLED(SKR12Pro) + #define BLOCK_BUFFER_SIZE 64 +#elif BOTH(SDSUPPORT, DIRECT_STEPPING) #define BLOCK_BUFFER_SIZE 8 #elif ENABLED(SDSUPPORT) #define BLOCK_BUFFER_SIZE 16 @@ -1918,7 +1940,11 @@ // The ASCII buffer for serial input #define MAX_CMD_SIZE 96 -#define BUFSIZE 4 +#if ENABLED(SKR12Pro) + #define BUFSIZE 16 +#else + #define BUFSIZE 4 +#endif // Transmission to Host Buffer Size // To save 386 bytes of PROGMEM (and TX_BUFFER_SIZE+3 bytes of RAM) set to 0. @@ -2005,7 +2031,7 @@ * * Note that M207 / M208 / M209 settings are saved to EEPROM. */ -#if ENABLED(ABL_Bilinear) +#if ANY(ABL_Bilinear, SKR12Pro) #define FWRETRACT #endif #if ENABLED(FWRETRACT) @@ -2515,7 +2541,7 @@ * Define your own with: * { , , hysteresis_start[1..8] } */ - #define CHOPPER_TIMING CHOPPER_DEFAULT_12V // All axes (override below) + #define CHOPPER_TIMING CHOPPER_DEFAULT_24V // All axes (override below) //#define CHOPPER_TIMING_X CHOPPER_DEFAULT_12V // For X Axes (override below) //#define CHOPPER_TIMING_X2 CHOPPER_DEFAULT_12V //#define CHOPPER_TIMING_Y CHOPPER_DEFAULT_12V // For Y Axes (override below) @@ -2544,7 +2570,7 @@ * M912 - Clear stepper driver overtemperature pre-warn condition flag. * M122 - Report driver parameters (Requires TMC_DEBUG) */ - //#define MONITOR_DRIVER_STATUS + #define MONITOR_DRIVER_STATUS #if ENABLED(MONITOR_DRIVER_STATUS) #define CURRENT_STEP_DOWN 50 // [mA] @@ -2559,7 +2585,7 @@ * STEALTHCHOP_(XY|Z|E) must be enabled to use HYBRID_THRESHOLD. * M913 X/Y/Z/E to live tune the setting */ - //#define HYBRID_THRESHOLD + #define HYBRID_THRESHOLD #define X_HYBRID_THRESHOLD 100 // [mm/s] #define X2_HYBRID_THRESHOLD 100 @@ -2635,7 +2661,7 @@ * Beta feature! * Create a 50/50 square wave step pulse optimal for stepper drivers. */ - //#define SQUARE_WAVE_STEPPING + #define SQUARE_WAVE_STEPPING /** * Enable M122 debugging command for TMC stepper drivers. @@ -2965,6 +2991,9 @@ //#define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR and LPC) #endif + #if ENABLED(SKR12Pro) + #define SPINDLE_LASER_ENA_PIN PE4 + #endif /** * Speed / Power can be set ('M3 S') and displayed in terms of: * - PWM255 (S0 - S255) @@ -3344,7 +3373,9 @@ * * Implement M486 to allow Marlin to skip objects */ -//#define CANCEL_OBJECTS +#if ENABLED(SKR12Pro) + #define CANCEL_OBJECTS +#endif /** * I2C position encoders for closed loop control. From 2d160b84612378d8f332522580df05a645e368d5 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 20 Sep 2020 00:34:36 -0400 Subject: [PATCH 10/58] force set directions on all blocks in stepper isr --- Marlin/Configuration_adv.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index eb1e33e1af..140338df3a 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -186,7 +186,7 @@ * THERMAL_PROTECTION_HYSTERESIS and/or THERMAL_PROTECTION_PERIOD */ #if ENABLED(THERMAL_PROTECTION_HOTENDS) - #define THERMAL_PROTECTION_PERIOD 30 // Seconds + #define THERMAL_PROTECTION_PERIOD 60 // Seconds #define THERMAL_PROTECTION_HYSTERESIS 15 // Degrees Celsius #define ADAPTIVE_FAN_SLOWING // Slow part cooling fan if temperature drops @@ -214,13 +214,13 @@ * Thermal Protection parameters for the bed are just as above for hotends. */ #if ENABLED(THERMAL_PROTECTION_BED) - #define THERMAL_PROTECTION_BED_PERIOD 80 // Seconds + #define THERMAL_PROTECTION_BED_PERIOD 120 // Seconds #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius /** * As described above, except for the bed (M140/M190/M303). */ - #define WATCH_BED_TEMP_PERIOD 80 // Seconds + #define WATCH_BED_TEMP_PERIOD 120 // Seconds #define WATCH_BED_TEMP_INCREASE 2 // Degrees Celsius #endif @@ -2983,7 +2983,7 @@ #endif #if EITHER(SPINDLE_FEATURE, LASER_FEATURE) //#define SHOW_CUTTER_ICON - #define SPINDLE_LASER_ACTIVE_HIGH true // Set to "true" if the on/off function is active HIGH + #define SPINDLE_LASER_ACTIVE_STATE HIGH // Set to "true" if the on/off function is active HIGH #define SPINDLE_LASER_PWM false // Set to "true" if your controller supports setting the speed/power #define SPINDLE_LASER_PWM_INVERT true // Set to "true" if the speed/power goes up when you want it to go slower From 30162df320647814013c44eee08bc62e3e1db925 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 13 Nov 2020 18:47:34 -0600 Subject: [PATCH 11/58] Optimize M360 --- Marlin/src/gcode/host/M360.cpp | 73 ++++++++++++++++------------------ 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/Marlin/src/gcode/host/M360.cpp b/Marlin/src/gcode/host/M360.cpp index 9970dc4df9..201beeb0f9 100644 --- a/Marlin/src/gcode/host/M360.cpp +++ b/Marlin/src/gcode/host/M360.cpp @@ -28,16 +28,24 @@ #include "../../module/motion.h" #include "../../module/planner.h" -static void config_prefix(PGM_P const name, PGM_P const pref=nullptr) { +#if EXTRUDERS + #include "../../module/temperature.h" +#endif + +static void config_prefix(PGM_P const name, PGM_P const pref=nullptr, const int8_t ind=-1) { SERIAL_ECHOPGM("Config:"); if (pref) serialprintPGM(pref); + if (ind >= 0) { SERIAL_ECHO(int(ind)); SERIAL_CHAR(':'); } serialprintPGM(name); SERIAL_CHAR(':'); } -static void config_line(PGM_P const name, const float val, PGM_P const pref=nullptr) { - config_prefix(name, pref); +static void config_line(PGM_P const name, const float val, PGM_P const pref=nullptr, , const int8_t ind=-1) { + config_prefix(name, pref, ind); SERIAL_ECHOLN(val); } +static void config_line_e(const int8_t e, PGM_P const name, const float val) { + config_line(name, val, PSTR("Extr."), e + 1); +} /** * M360: Report Firmware configuration @@ -52,19 +60,19 @@ void GcodeSuite::M360() { // // Basics and Enabled items // - config_line(PSTR("Baudrate"), BAUDRATE); - config_line(PSTR("InputBuffer"), MAX_CMD_SIZE); - config_line(PSTR("PrintlineCache"), BUFSIZE); - config_line(PSTR("MixingExtruder"), ENABLED(MIXING_EXTRUDER)); - config_line(PSTR("SDCard"), ENABLED(SDSUPPORT)); - config_line(PSTR("Fan"), ENABLED(HAS_FAN)); - config_line(PSTR("LCD"), ENABLED(HAS_DISPLAY)); + config_line(PSTR("Baudrate"), BAUDRATE); + config_line(PSTR("InputBuffer"), MAX_CMD_SIZE); + config_line(PSTR("PrintlineCache"), BUFSIZE); + config_line(PSTR("MixingExtruder"), ENABLED(MIXING_EXTRUDER)); + config_line(PSTR("SDCard"), ENABLED(SDSUPPORT)); + config_line(PSTR("Fan"), ENABLED(HAS_FAN)); + config_line(PSTR("LCD"), ENABLED(HAS_DISPLAY)); config_line(PSTR("SoftwarePowerSwitch"), 1); config_line(PSTR("SupportLocalFilamentchange"), ENABLED(ADVANCED_PAUSE_FEATURE)); - config_line(PSTR("CaseLights"), ENABLED(CASE_LIGHT_ENABLE)); - config_line(PSTR("ZProbe"), ENABLED(HAS_BED_PROBE)); - config_line(PSTR("Autolevel"), ENABLED(HAS_LEVELING)); - config_line(PSTR("EEPROM"), ENABLED(EEPROM_SETTINGS)); + config_line(PSTR("CaseLights"), ENABLED(CASE_LIGHT_ENABLE)); + config_line(PSTR("ZProbe"), ENABLED(HAS_BED_PROBE)); + config_line(PSTR("Autolevel"), ENABLED(HAS_LEVELING)); + config_line(PSTR("EEPROM"), ENABLED(EEPROM_SETTINGS)); // // Homing Directions @@ -96,15 +104,15 @@ void GcodeSuite::M360() { PGMSTR(UNRET_STR, "RetractionUndo"); PGMSTR(SPEED_STR, "Speed"); // M10 Retract with swap (long) moves - config_line(PSTR("Length"), fwretract.settings.retract_length, RET_STR); - config_line(SPEED_STR, fwretract.settings.retract_feedrate_mm_s, RET_STR); - config_line(PSTR("ZLift"), fwretract.settings.retract_zraise, RET_STR); + config_line(PSTR("Length"), fwretract.settings.retract_length, RET_STR); + config_line(SPEED_STR, fwretract.settings.retract_feedrate_mm_s, RET_STR); + config_line(PSTR("ZLift"), fwretract.settings.retract_zraise, RET_STR); config_line(PSTR("LongLength"), fwretract.settings.swap_retract_length, RET_STR); // M11 Recover (undo) with swap (long) moves - config_line(SPEED_STR, fwretract.settings.retract_recover_feedrate_mm_s, UNRET_STR); - config_line(PSTR("ExtraLength"), fwretract.settings.retract_recover_extra, UNRET_STR); + config_line(SPEED_STR, fwretract.settings.retract_recover_feedrate_mm_s, UNRET_STR); + config_line(PSTR("ExtraLength"), fwretract.settings.retract_recover_extra, UNRET_STR); config_line(PSTR("ExtraLongLength"), fwretract.settings.swap_retract_recover_extra, UNRET_STR); - config_line(PSTR("LongSpeed"), fwretract.settings.swap_retract_recover_feedrate_mm_s, UNRET_STR); + config_line(PSTR("LongSpeed"), fwretract.settings.swap_retract_recover_feedrate_mm_s, UNRET_STR); #endif // @@ -165,24 +173,13 @@ void GcodeSuite::M360() { // config_line(PSTR("NumExtruder"), EXTRUDERS); #if EXTRUDERS - #define DIAM_VALUE(N) TERN(NO_VOLUMETRICS, DEFAULT_NOMINAL_FILAMENT_DIA, planner.filament_size[N]) - #if HAS_LINEAR_E_JERK - #define E_JERK_VAL(N) planner.max_e_jerk[E_INDEX_N(N)] - #elif HAS_CLASSIC_JERK - #define E_JERK_VAL(N) planner.max_jerk.e - #else - #define E_JERK_VAL(N) DEFAULT_EJERK - #endif - #define _EXTR_ITEM(N) do{ \ - PGMSTR(EXTR_STR, "Extr." STRINGIFY(INCREMENT(N)) ":"); \ - config_line(JERK_STR, E_JERK_VAL(N), EXTR_STR); \ - config_line(PSTR("MaxSpeed"), planner.settings.max_feedrate_mm_s[E_AXIS_N(N)], EXTR_STR); \ - config_line(PSTR("Acceleration"), planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(N)], EXTR_STR); \ - config_line(PSTR("Diameter"), DIAM_VALUE(N), EXTR_STR); \ - config_line(PSTR("MaxTemp"), (HEATER_##N##_MAXTEMP) - (HOTEND_OVERSHOOT), EXTR_STR); \ - }while(0) - - REPEAT(EXTRUDERS, _EXTR_ITEM); + LOOP_L_N(e, EXTRUDERS) { + config_line_e(e, TERN(HAS_LINEAR_E_JERK, planner.max_e_jerk[E_INDEX_N(e)], TERN(HAS_CLASSIC_JERK, planner.max_jerk.e, DEFAULT_EJERK)), E_JERK_VAL(e)); + config_line_e(e, PSTR("MaxSpeed"), planner.settings.max_feedrate_mm_s[E_AXIS_N(e)]); + config_line_e(e, PSTR("Acceleration"), planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(e)]); + config_line_e(e, PSTR("Diameter"), TERN(NO_VOLUMETRICS, DEFAULT_NOMINAL_FILAMENT_DIA, planner.filament_size[e])); + config_line_e(e, PSTR("MaxTemp"), thermalManager.heater_maxtemp[e]); + } #endif } From cd3bf4c766d31e8fa1b3522cc8e29d3cc28c73d9 Mon Sep 17 00:00:00 2001 From: Luu Lac <45380455+shitcreek@users.noreply.github.com> Date: Fri, 13 Nov 2020 18:48:59 -0600 Subject: [PATCH 12/58] Fix "autotune" LCD message (#20127) --- Marlin/src/gcode/temp/M303.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index c1bf9efd7f..52e34fc473 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -77,7 +77,7 @@ void GcodeSuite::M303() { KEEPALIVE_STATE(NOT_BUSY); #endif - ui.set_status(GET_TEXT(MSG_PID_AUTOTUNE)); + ui.set_status_P(GET_TEXT(MSG_PID_AUTOTUNE)); thermalManager.PID_autotune(temp, e, c, u); ui.reset_status(); } From dd345679d3abd0aaeb84d13570f8d58d8c0f0b5e Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 21 Nov 2020 15:16:47 -0500 Subject: [PATCH 13/58] Add display timings for new supplier --- Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR2.h | 12 ++++++++++++ Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR2.h b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR2.h index 843eadb432..1e836b37b8 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR2.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR2.h @@ -66,3 +66,15 @@ #if ENABLED(CASE_LIGHT_ENABLE) && PIN_EXISTS(CASE_LIGHT) && (CASE_LIGHT_PIN == SPINDLE_LASER_ENA_PIN || CASE_LIGHT_PIN == SPINDLE_LASER_PWM_PIN) #error "CASE_LIGHT_PIN conflicts with a Spindle / Laser pin." #endif + +#if HAS_MARLINUI_U8GLIB + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + #endif +#endif diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h index a97b0d2d12..b88726580b 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h @@ -173,3 +173,16 @@ #define BEEPER_PIN 37 #endif #endif + +#if HAS_MARLINUI_U8GLIB + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + #endif +#endif + From d6abfd25239bf6b9543c5951ca9628b48a8b6db3 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Fri, 1 Jan 2021 18:50:47 -0500 Subject: [PATCH 14/58] Fix move directly after G28X --- Marlin/src/MarlinCore.cpp | 1 + Marlin/src/module/motion.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 9a3de3f1ac..c1c2fe0615 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -660,6 +660,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { delayed_move_time = 0xFFFFFFFFUL; // force moves to be done destination = current_position; prepare_line_to_destination(); + planner.synchronize(); } #endif diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 9b6a0d913b..8caf472576 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1006,7 +1006,6 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { line_to_current_position(fr_zfast); } } - planner.synchronize(); // paranoia stepper.set_directions(); idex_set_parked(false); From 9b6037515ff012d587eaa5f0f64664eaaeaf5161 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 31 Jul 2021 14:47:58 -0400 Subject: [PATCH 15/58] Update Configuration.h --- Marlin/Configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 21012af892..0f7b5a2300 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -937,7 +937,7 @@ // Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup). #define X_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define Y_MIN_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop. -#define Z_MIN_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop. +#define Z_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define I_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define J_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define K_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. From 125e537dd175801423f734094aae21ab0c5c8a89 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Fri, 6 Aug 2021 13:10:05 -0400 Subject: [PATCH 16/58] Update Configuration.h --- Marlin/Configuration.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 8ca78d75b1..6a7c4fa100 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -151,10 +151,10 @@ #define SHOW_BOOTSCREEN // Show the bitmap in Marlin/_Bootscreen.h on startup. -#define SHOW_CUSTOM_BOOTSCREEN +//#define SHOW_CUSTOM_BOOTSCREEN // Show the bitmap in Marlin/_Statusscreen.h on the status screen. -#define CUSTOM_STATUS_SCREEN_IMAGE +//#define CUSTOM_STATUS_SCREEN_IMAGE // @section machine From 5b6317dd5bcfbe5b0f400066c7c6c3fdff9c1c29 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Fri, 6 Aug 2021 20:11:23 -0400 Subject: [PATCH 17/58] Update Configuration_adv.h --- Marlin/Configuration_adv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 70c21c4863..925fe0a46a 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1371,7 +1371,7 @@ // The standard SD detect circuit reads LOW when media is inserted and HIGH when empty. // Enable this option and set to HIGH if your SD cards are incorrectly detected. - #define SD_DETECT_STATE HIGH + //#define SD_DETECT_STATE HIGH //#define SD_IGNORE_AT_STARTUP // Don't mount the SD card when starting up //#define SDCARD_READONLY // Read-only SD card (to save over 2K of flash) From 4ddd6d27c1ac7761b773202e049f57af18304312 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 8 Aug 2021 14:29:24 -0400 Subject: [PATCH 18/58] trim ram --- Marlin/Configuration.h | 16 ++++++++-------- Marlin/Configuration_adv.h | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 6a7c4fa100..7cbdc0abce 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1104,7 +1104,7 @@ #endif #define DEFAULT_MAX_FEEDRATE { 200, Y_MAXFEED, 8, 75, 75 } -#define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2 +//#define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2 #if ENABLED(LIMITED_MAX_FR_EDITING) #define MAX_FEEDRATE_EDIT_VALUES { 300, 200, 15, 150 } // ...or, set your own edit limits #endif @@ -1117,7 +1117,7 @@ */ #define DEFAULT_MAX_ACCELERATION { 750, 500, 400, 3000, 3000 } -#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2 +//#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2 #if ENABLED(LIMITED_MAX_ACCEL_EDITING) #define MAX_ACCEL_EDIT_VALUES { 1500, 1500, 800, 5000 } // ...or, set your own edit limits #endif @@ -1361,7 +1361,7 @@ #define XY_PROBE_FEEDRATE (133*60) // Feedrate (mm/min) for the first approach when double-probing (MULTIPLE_PROBING == 2) -#define Z_PROBE_FEEDRATE_FAST (4*60) +#define Z_PROBE_FEEDRATE_FAST (10*60) // Feedrate (mm/min) for the "accurate" probe of each point #define Z_PROBE_FEEDRATE_SLOW (Z_PROBE_FEEDRATE_FAST / 2) @@ -1431,7 +1431,7 @@ #define Z_PROBE_OFFSET_RANGE_MAX 9 // Enable the M48 repeatability test to test probe accuracy -#define Z_MIN_PROBE_REPEATABILITY_TEST +//#define Z_MIN_PROBE_REPEATABILITY_TEST // Before deploy/stow pause for user confirmation //#define PAUSE_BEFORE_DEPLOY_STOW @@ -1791,9 +1791,9 @@ // Gradually reduce leveling correction until a set height is reached, // at which point movement will be level to the machine's XY plane. // The height can be set with M420 Z - #define ENABLE_LEVELING_FADE_HEIGHT + //#define ENABLE_LEVELING_FADE_HEIGHT #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - #define DEFAULT_LEVELING_FADE_HEIGHT 10.0 // (mm) Default fade height. + #define DEFAULT_LEVELING_FADE_HEIGHT 0.0 // (mm) Default fade height. #endif // For Cartesian machines, instead of dividing moves on mesh boundaries, @@ -1859,7 +1859,7 @@ #define GRID_MAX_POINTS_X 15 // Don't use more than 15 points per axis, implementation limited. #define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X - //#define UBL_HILBERT_CURVE // Use Hilbert distribution for less travel when probing multiple points + #define UBL_HILBERT_CURVE // Use Hilbert distribution for less travel when probing multiple points #define UBL_MESH_EDIT_MOVES_Z // Sophisticated users prefer no movement of nozzle #define UBL_SAVE_ACTIVE_ON_M500 // Save the currently active mesh in the current slot on M500 @@ -1896,7 +1896,7 @@ #endif // Add a menu item to move between bed corners for manual bed adjustment -#define LEVEL_BED_CORNERS +//#define LEVEL_BED_CORNERS #if ENABLED(LEVEL_BED_CORNERS) #define LEVEL_CORNERS_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 925fe0a46a..f97e0dea0f 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -472,9 +472,9 @@ * Hotend Idle Timeout * Prevent filament in the nozzle from charring and causing a critical jam. */ -//#define HOTEND_IDLE_TIMEOUT +#define HOTEND_IDLE_TIMEOUT #if ENABLED(HOTEND_IDLE_TIMEOUT) - #define HOTEND_IDLE_TIMEOUT_SEC (5*60) // (seconds) Time without extruder movement to trigger protection + #define HOTEND_IDLE_TIMEOUT_SEC (15*60) // (seconds) Time without extruder movement to trigger protection #define HOTEND_IDLE_MIN_TRIGGER 180 // (°C) Minimum temperature to enable hotend protection #define HOTEND_IDLE_NOZZLE_TARGET 0 // (°C) Safe temperature for the nozzle after timeout #define HOTEND_IDLE_BED_TARGET 0 // (°C) Safe temperature for the bed after timeout @@ -1045,7 +1045,7 @@ // Define values for backlash distance and correction. // If BACKLASH_GCODE is enabled these values are the defaults. #define BACKLASH_DISTANCE_MM { 0, 0, 0 } // (mm) One value for each linear axis - #define BACKLASH_CORRECTION 0.0 // 0.0 = no correction; 1.0 = full correction + #define BACKLASH_CORRECTION 0.5 // 0.0 = no correction; 1.0 = full correction // Add steps for motor direction changes on CORE kinematics //#define CORE_BACKLASH @@ -1059,7 +1059,7 @@ #if ENABLED(BACKLASH_GCODE) // Measure the Z backlash when probing (G29) and set with "M425 Z" - #define MEASURE_BACKLASH_WHEN_PROBING + //#define MEASURE_BACKLASH_WHEN_PROBING #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) // When measuring, the probe will move up to BACKLASH_MEASUREMENT_LIMIT @@ -1309,7 +1309,7 @@ #if HAS_DISPLAY // The timeout (in ms) to return to the status screen from sub-menus - #define LCD_TIMEOUT_TO_STATUS 15000 + //#define LCD_TIMEOUT_TO_STATUS 15000 #if ENABLED(SHOW_BOOTSCREEN) #define BOOTSCREEN_TIMEOUT 2000 // (ms) Total Duration to display the boot screen(s) @@ -1319,7 +1319,7 @@ #endif // Scroll a longer status message into view - #define STATUS_MESSAGE_SCROLLING + //#define STATUS_MESSAGE_SCROLLING // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY @@ -1410,7 +1410,7 @@ * an option on the LCD screen to continue the print from the last-known * point in the file. */ - #define POWER_LOSS_RECOVERY + //#define POWER_LOSS_RECOVERY #if ENABLED(POWER_LOSS_RECOVERY) #define PLR_ENABLED_DEFAULT false // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500) //#define BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power loss @@ -1501,7 +1501,7 @@ /** * Auto-report SdCard status with M27 S */ - #define AUTO_REPORT_SD_STATUS + //#define AUTO_REPORT_SD_STATUS /** * Support for USB thumb drives using an Arduino USB Host Shield or @@ -1895,7 +1895,7 @@ #if ENABLED(BABYSTEPPING) #define INTEGRATED_BABYSTEPPING // EXPERIMENTAL integration of babystepping into the Stepper ISR //#define BABYSTEP_WITHOUT_HOMING - //#define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement). + #define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement). //#define BABYSTEP_XY // Also enable X/Y Babystepping. Not supported on DELTA! #define BABYSTEP_INVERT_Z false // Change if Z babysteps should go the other way //#define BABYSTEP_MILLIMETER_UNITS // Specify BABYSTEP_MULTIPLICATOR_(XY|Z) in mm instead of micro-steps @@ -3361,7 +3361,7 @@ */ //#define SPINDLE_FEATURE #if ENABLED(TREX3) - #define LASER_FEATURE +// #define LASER_FEATURE #endif #if EITHER(SPINDLE_FEATURE, LASER_FEATURE) //#define SHOW_CUTTER_ICON From 8b10b829fdb15f6a65c90903ab93946832bdfee8 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 9 Oct 2021 11:58:45 -0400 Subject: [PATCH 19/58] Fix IDEX Mode Positioning --- Marlin/src/module/motion.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 1f13bd22ee..f5dd5d34c9 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1194,6 +1194,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { case DXC_DUPLICATION_MODE: if (active_extruder == 0) { // Restore planner to parked head (T1) X position + float x0_pos = current_position.x; xyze_pos_t pos_now = current_position; pos_now.x = inactive_extruder_x; planner.set_position_mm(pos_now); @@ -1201,7 +1202,9 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { // Keep the same X or add the duplication X offset xyze_pos_t new_pos = pos_now; if (dual_x_carriage_mode == DXC_DUPLICATION_MODE) - new_pos.x += duplicate_extruder_x_offset; + new_pos.x = x0_pos + duplicate_extruder_x_offset; + else + new_pos.x = _MIN(X_BED_SIZE - x0_pos, X_MAX_POS); // Move duplicate extruder into the correct position if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Set planner X", inactive_extruder_x, " ... Line to X", new_pos.x); From 32e8f9027192150f1f88a6d93cbe5e1b69580ab2 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 9 Oct 2021 11:58:54 -0400 Subject: [PATCH 20/58] Fix Delay definitions --- Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR2.h | 6 +++--- Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR2.h b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR2.h index 1e836b37b8..9de8c3ae87 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR2.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR2.h @@ -69,12 +69,12 @@ #if HAS_MARLINUI_U8GLIB #ifndef BOARD_ST7920_DELAY_1 - #define BOARD_ST7920_DELAY_1 DELAY_NS(125) + #define BOARD_ST7920_DELAY_1 125 #endif #ifndef BOARD_ST7920_DELAY_2 - #define BOARD_ST7920_DELAY_2 DELAY_NS(125) + #define BOARD_ST7920_DELAY_2 125 #endif #ifndef BOARD_ST7920_DELAY_3 - #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + #define BOARD_ST7920_DELAY_3 125 #endif #endif diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h index fe177cc2df..7127f69b57 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h @@ -100,9 +100,9 @@ #define E1_CS_PIN 44 #endif -#define E2_STEP_PIN 42 -#define E2_DIR_PIN 43 -#define E2_ENABLE_PIN 44 +#define X2_STEP_PIN 42 +#define X2_DIR_PIN 43 +#define X2_ENABLE_PIN 44 // // Temperature Sensors @@ -177,13 +177,13 @@ #if HAS_MARLINUI_U8GLIB #ifndef BOARD_ST7920_DELAY_1 - #define BOARD_ST7920_DELAY_1 DELAY_NS(125) + #define BOARD_ST7920_DELAY_1 125 #endif #ifndef BOARD_ST7920_DELAY_2 - #define BOARD_ST7920_DELAY_2 DELAY_NS(125) + #define BOARD_ST7920_DELAY_2 125 #endif #ifndef BOARD_ST7920_DELAY_3 - #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + #define BOARD_ST7920_DELAY_3 125 #endif #endif From 0cc6955ab72ea03663fa52b5a4f9ecddf40d6bba Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 9 Oct 2021 13:58:25 -0400 Subject: [PATCH 21/58] BLTouch High Speed EEPROM Control --- Marlin/Configuration_adv.h | 2 ++ Marlin/src/feature/bltouch.cpp | 3 ++- Marlin/src/feature/bltouch.h | 7 ++----- Marlin/src/gcode/bedlevel/G35.cpp | 3 ++- Marlin/src/gcode/calibrate/G34_M422.cpp | 2 +- Marlin/src/gcode/probe/M401_M402.cpp | 12 ++++++++++++ Marlin/src/lcd/language/language_en.h | 1 + Marlin/src/lcd/menu/menu_bed_corners.cpp | 15 ++++++++------- Marlin/src/lcd/menu/menu_configuration.cpp | 1 + Marlin/src/lcd/menu/menu_tramming.cpp | 3 ++- Marlin/src/module/motion.cpp | 9 +++++---- Marlin/src/module/probe.cpp | 19 +++++++++++-------- Marlin/src/module/settings.cpp | 22 ++++++++++++++++------ 13 files changed, 65 insertions(+), 34 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 8e1f673c87..0b01ec0d61 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -857,6 +857,8 @@ * Danger: Disable if your probe sometimes fails. Only suitable for stable well-adjusted systems. * This feature was designed for Deltabots with very fast Z moves; however, higher speed Cartesians * might be able to use it. If the machine can't raise Z fast enough the BLTouch may go into ALARM. + * + * This sets the default state. Can be changed through the SCD */ //#define BLTOUCH_HS_MODE diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index 49a10f62b1..fbe6012bbe 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -28,7 +28,8 @@ BLTouch bltouch; -bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain +bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain +bool BLTouch::bltouch_high_speed; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed #include "../module/servo.h" #include "../module/probe.h" diff --git a/Marlin/src/feature/bltouch.h b/Marlin/src/feature/bltouch.h index 9ecccb4256..7d9a0bb126 100644 --- a/Marlin/src/feature/bltouch.h +++ b/Marlin/src/feature/bltouch.h @@ -23,10 +23,6 @@ #include "../inc/MarlinConfigPre.h" -#if DISABLED(BLTOUCH_HS_MODE) - #define BLTOUCH_SLOW_MODE 1 -#endif - // BLTouch commands are sent as servo angles typedef unsigned char BLTCommand; @@ -71,7 +67,8 @@ typedef unsigned char BLTCommand; class BLTouch { public: static void init(const bool set_voltage=false); - static bool last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain + static bool last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain + static bool bltouch_high_speed; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed // DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing static bool deploy() { return deploy_proc(); } diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index e45e18b7fb..08539f8966 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -102,7 +102,8 @@ void GcodeSuite::G35() { // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G35 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, Z_CLEARANCE_BETWEEN_PROBES, 7)); + float z_raise_probe = Z_CLEARANCE_BETWEEN_PROBES if(bltouch.bltouch_high_speed) + 7; + do_blocking_move_to_z(z_raise_probe); const float z_probed_height = probe.probe_at_point(tramming_points[i], PROBE_PT_RAISE, 0, true); if (isnan(z_probed_height)) { diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 8f4eab2c97..5b70dc588e 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -149,7 +149,7 @@ void GcodeSuite::G34() { // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G34 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - #define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + 7.0f * BOTH(BLTOUCH, BLTOUCH_HS_MODE)) + #define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + 7.0f * bltouch.bltouch_high_speed) // Compute a worst-case clearance height to probe from. After the first // iteration this will be re-calculated based on the actual bed position diff --git a/Marlin/src/gcode/probe/M401_M402.cpp b/Marlin/src/gcode/probe/M401_M402.cpp index bd9bb44c40..aef34f3a1e 100644 --- a/Marlin/src/gcode/probe/M401_M402.cpp +++ b/Marlin/src/gcode/probe/M401_M402.cpp @@ -27,11 +27,23 @@ #include "../gcode.h" #include "../../module/motion.h" #include "../../module/probe.h" +#if ENABLED(BLTOUCH) + #include "../../feature/bltouch.h" +#endif /** * M401: Deploy and activate the Z probe */ void GcodeSuite::M401() { + #if ENABLED(BLTOUCH) + const bool seen_S = parser.seen('S'), + to_enable = (seen_S && parser.value_bool()); + if (seen_S) + if(to_enable) + bltouch.bltouch_high_speed = true; + else + bltouch.bltouch_high_speed = false; + #endif probe.deploy(); TERN_(PROBE_TARE, probe.tare()); report_current_position(); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index c9413d3cea..8b8073b5bb 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -491,6 +491,7 @@ namespace Language_en { LSTR MSG_BLTOUCH_STOW = _UxGT("Stow"); LSTR MSG_BLTOUCH_DEPLOY = _UxGT("Deploy"); LSTR MSG_BLTOUCH_SW_MODE = _UxGT("SW-Mode"); + LSTR MSG_BLTOUCH_SPEED_MODE = _UxGT("High Speed"); LSTR MSG_BLTOUCH_5V_MODE = _UxGT("5V-Mode"); LSTR MSG_BLTOUCH_OD_MODE = _UxGT("OD-Mode"); LSTR MSG_BLTOUCH_MODE_STORE = _UxGT("Mode-Store"); diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 178d466478..8dd737a805 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -221,13 +221,13 @@ static void _lcd_level_bed_corners_get_next_position() { bool _lcd_level_bed_corners_probe(bool verify=false) { if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed - TERN_(BLTOUCH_SLOW_MODE, bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action + if(!bltouch.bltouch_high_speed) bltouch.deploy(); // Deploy in LOW SPEED MODE on every probe action do_blocking_move_to_z(last_z - LEVEL_CORNERS_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered endstops.hit_on_purpose(); set_current_from_steppers_for_axis(Z_AXIS); sync_plan_position(); - TERN_(BLTOUCH_SLOW_MODE, bltouch.stow()); // Stow in LOW SPEED MODE on every trigger + if(!bltouch.bltouch_high_speed) bltouch.stow(); // Stow in LOW SPEED MODE on every trigger // Triggered outside tolerance range? if (ABS(current_position.z - last_z) > LEVEL_CORNERS_PROBE_TOLERANCE) { last_z = current_position.z; // Above tolerance. Set a new Z for subsequent corners. @@ -253,7 +253,7 @@ static void _lcd_level_bed_corners_get_next_position() { } idle(); } - TERN_(BLTOUCH_SLOW_MODE, bltouch.stow()); + if(!bltouch.bltouch_high_speed) bltouch.stow(); ui.goto_screen(_lcd_draw_probing); return (probe_triggered); } @@ -267,13 +267,14 @@ static void _lcd_level_bed_corners_get_next_position() { do { ui.refresh(LCDVIEW_REDRAW_NOW); _lcd_draw_probing(); // update screen with # of good points - do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, current_position.z + LEVEL_CORNERS_Z_HOP, 7)); // clearance + float z_raise_probe = Z_CLEARANCE_BETWEEN_PROBES if(bltouch.bltouch_high_speed) + 7; + do_blocking_move_to_z(SUM_TERN(z_raise_probe, current_position.z + LEVEL_CORNERS_Z_HOP, 7)); // clearance _lcd_level_bed_corners_get_next_position(); // Select next corner coordinates current_position -= probe.offset_xy; // Account for probe offsets do_blocking_move_to_xy(current_position); // Goto corner - TERN_(BLTOUCH_HS_MODE, bltouch.deploy()); // Deploy in HIGH SPEED MODE + if(bltouch.bltouch_high_speed) bltouch.deploy(); // Deploy in HIGH SPEED MODE if (!_lcd_level_bed_corners_probe()) { // Probe down to tolerance if (_lcd_level_bed_corners_raise()) { // Prompt user to raise bed if needed #if ENABLED(LEVEL_CORNERS_VERIFY_RAISED) // Verify @@ -294,11 +295,11 @@ static void _lcd_level_bed_corners_get_next_position() { } while (good_points < nr_edge_points); // loop until all points within tolerance - #if ENABLED(BLTOUCH_HS_MODE) + if (bltouch.bltouch_high_speed) // In HIGH SPEED MODE do clearance and stow at the very end do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); bltouch.stow(); - #endif + } ui.goto_screen(_lcd_draw_level_prompt); // prompt for bed leveling ui.set_selection(true); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 0e11cd211a..5865d4898c 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -235,6 +235,7 @@ void menu_advanced_settings(); ACTION_ITEM(MSG_BLTOUCH_DEPLOY, bltouch._deploy); ACTION_ITEM(MSG_BLTOUCH_STOW, bltouch._stow); ACTION_ITEM(MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode); + EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.bltouch_high_speed); #if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU) CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index 5cdcf75c1e..5109a699ed 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -51,7 +51,8 @@ static int8_t reference_index; // = 0 static bool probe_single_point() { do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES)); // Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety - const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], TERN(BLTOUCH_HS_MODE, PROBE_PT_STOW, PROBE_PT_RAISE), 0, true); + + const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], if(bltouch.bltouch_high_speed) PROBE_PT_STOW else PROBE_PT_RAISE), 0, true); z_measured[tram_index] = z_probed_height; if (reference_index < 0) reference_index = tram_index; move_to_tramming_wait_pos(); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 1f13bd22ee..091facc94c 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1799,8 +1799,8 @@ void prepare_line_to_destination() { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home Fast: ", move_length, "mm"); do_homing_move(axis, move_length, 0.0, !use_probe_bump); - #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE) - if (axis == Z_AXIS) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) + #if ENABLED(HOMING_Z_WITH_PROBE, BLTOUCH) + if (axis == Z_AXIS && !bltouch.bltouch_high_speed) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) #endif // If a second homing move is configured... @@ -1833,8 +1833,9 @@ void prepare_line_to_destination() { } #endif - #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE) - if (axis == Z_AXIS && bltouch.deploy()) return; // Intermediate DEPLOY (in LOW SPEED MODE) + #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH) + if(!bltouch.bltouch_high_speed) + if (axis == Z_AXIS && bltouch.deploy()) return; // Intermediate DEPLOY (in LOW SPEED MODE) #endif // Slow move towards endstop until triggered diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 4078effe76..f2f5eee520 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -487,8 +487,10 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { #if BOTH(HAS_TEMP_HOTEND, WAIT_FOR_HOTEND) thermalManager.wait_for_hotend_heating(active_extruder); #endif - - if (TERN0(BLTOUCH_SLOW_MODE, bltouch.deploy())) return true; // Deploy in LOW SPEED MODE on every probe action + #if ENABLED(BLTOUCH) + if(!bltouch.bltouch_high_speed) + if (bltouch.deploy()) return true; // Deploy in LOW SPEED MODE on every probe action + #endif // Disable stealthChop if used. Enable diag1 pin on driver. #if ENABLED(SENSORLESS_PROBING) @@ -528,10 +530,11 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { if (probe.test_sensitivity.z) tmc_disable_stallguard(stepperZ, stealth_states.z); set_homing_current(false); #endif - - if (probe_triggered && TERN0(BLTOUCH_SLOW_MODE, bltouch.stow())) // Stow in LOW SPEED MODE on every trigger - return true; - + #if ENABLED(BLTOUCH) + if(!bltouch.bltouch_high_speed) + if (probe_triggered && bltouch.stow()) // Stow in LOW SPEED MODE on every trigger + return true; + #endif // Clear endstop flags endstops.hit_on_purpose(); @@ -760,8 +763,8 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai DEBUG_POS("", current_position); } - #if BOTH(BLTOUCH, BLTOUCH_HS_MODE) - if (bltouch.triggered()) bltouch._reset(); + #if ENABLED(BLTOUCH) + if (bltouch.triggered() && bltouch.bltouch_high_speed) bltouch._reset(); #endif // On delta keep Z below clip height or do_blocking_move_to will abort diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 6b7143e82a..9698348ae3 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -36,7 +36,7 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V85" +#define EEPROM_VERSION "V86" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -277,6 +277,7 @@ typedef struct SettingsDataStruct { // BLTOUCH // bool bltouch_last_written_mode; + bool bltouch_high_speed;. // // Kinematic Settings @@ -861,6 +862,10 @@ void MarlinSettings::postprocess() { _FIELD_TEST(bltouch_last_written_mode); const bool bltouch_last_written_mode = TERN(BLTOUCH, bltouch.last_written_mode, false); EEPROM_WRITE(bltouch_last_written_mode); + + _FIELD_TEST(bltouch_high_speed); + const bool bltouch_high_speed = TERN(BLTOUCH, bltouch.bltouch_high_speed, false); + EEPROM_WRITE(bltouch_high_speed); } // @@ -1732,6 +1737,14 @@ void MarlinSettings::postprocess() { bool bltouch_last_written_mode; #endif EEPROM_READ(bltouch_last_written_mode); + + _FIELD_TEST(bltouch_high_speed); + #if ENABLED(BLTOUCH) + const bool &bltouch_high_speed = bltouch.bltouch_high_speed; + #else + bool bltouch_high_speed; + #endif + EEPROM_READ(bltouch_last_written_mode); } // @@ -2729,12 +2742,9 @@ void MarlinSettings::reset() { TERN_(EDITABLE_SERVO_ANGLES, COPY(servo_angles, base_servo_angles)); // When not editable only one copy of servo angles exists // - // BLTOUCH + // BLTouch // - //#if ENABLED(BLTOUCH) - // bltouch.last_written_mode; - //#endif - + TERN_(BLTOUCH_HS_MODE, bltouch.bltouch_high_speed = true); // // Kinematic settings // From a30ae0aecaf214b1e4a600899b8bbc76dca1d09d Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 9 Oct 2021 13:58:25 -0400 Subject: [PATCH 22/58] BLTouch High Speed EEPROM Control --- Marlin/Configuration_adv.h | 2 ++ Marlin/src/feature/bltouch.cpp | 3 ++- Marlin/src/feature/bltouch.h | 7 ++----- Marlin/src/gcode/bedlevel/G35.cpp | 3 ++- Marlin/src/gcode/calibrate/G34_M422.cpp | 2 +- Marlin/src/gcode/probe/M401_M402.cpp | 12 ++++++++++++ Marlin/src/lcd/language/language_en.h | 1 + Marlin/src/lcd/menu/menu_bed_corners.cpp | 15 ++++++++------- Marlin/src/lcd/menu/menu_configuration.cpp | 1 + Marlin/src/lcd/menu/menu_tramming.cpp | 3 ++- Marlin/src/module/motion.cpp | 9 +++++---- Marlin/src/module/probe.cpp | 19 +++++++++++-------- Marlin/src/module/settings.cpp | 22 ++++++++++++++++------ 13 files changed, 65 insertions(+), 34 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 58d00bafcb..c1251ef962 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -872,6 +872,8 @@ * Danger: Disable if your probe sometimes fails. Only suitable for stable well-adjusted systems. * This feature was designed for Deltabots with very fast Z moves; however, higher speed Cartesians * might be able to use it. If the machine can't raise Z fast enough the BLTouch may go into ALARM. + * + * This sets the default state. Can be changed through the SCD */ #define BLTOUCH_HS_MODE diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index 49a10f62b1..fbe6012bbe 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -28,7 +28,8 @@ BLTouch bltouch; -bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain +bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain +bool BLTouch::bltouch_high_speed; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed #include "../module/servo.h" #include "../module/probe.h" diff --git a/Marlin/src/feature/bltouch.h b/Marlin/src/feature/bltouch.h index 9ecccb4256..7d9a0bb126 100644 --- a/Marlin/src/feature/bltouch.h +++ b/Marlin/src/feature/bltouch.h @@ -23,10 +23,6 @@ #include "../inc/MarlinConfigPre.h" -#if DISABLED(BLTOUCH_HS_MODE) - #define BLTOUCH_SLOW_MODE 1 -#endif - // BLTouch commands are sent as servo angles typedef unsigned char BLTCommand; @@ -71,7 +67,8 @@ typedef unsigned char BLTCommand; class BLTouch { public: static void init(const bool set_voltage=false); - static bool last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain + static bool last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain + static bool bltouch_high_speed; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed // DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing static bool deploy() { return deploy_proc(); } diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index e45e18b7fb..08539f8966 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -102,7 +102,8 @@ void GcodeSuite::G35() { // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G35 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, Z_CLEARANCE_BETWEEN_PROBES, 7)); + float z_raise_probe = Z_CLEARANCE_BETWEEN_PROBES if(bltouch.bltouch_high_speed) + 7; + do_blocking_move_to_z(z_raise_probe); const float z_probed_height = probe.probe_at_point(tramming_points[i], PROBE_PT_RAISE, 0, true); if (isnan(z_probed_height)) { diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 8f4eab2c97..5b70dc588e 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -149,7 +149,7 @@ void GcodeSuite::G34() { // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G34 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - #define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + 7.0f * BOTH(BLTOUCH, BLTOUCH_HS_MODE)) + #define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + 7.0f * bltouch.bltouch_high_speed) // Compute a worst-case clearance height to probe from. After the first // iteration this will be re-calculated based on the actual bed position diff --git a/Marlin/src/gcode/probe/M401_M402.cpp b/Marlin/src/gcode/probe/M401_M402.cpp index bd9bb44c40..aef34f3a1e 100644 --- a/Marlin/src/gcode/probe/M401_M402.cpp +++ b/Marlin/src/gcode/probe/M401_M402.cpp @@ -27,11 +27,23 @@ #include "../gcode.h" #include "../../module/motion.h" #include "../../module/probe.h" +#if ENABLED(BLTOUCH) + #include "../../feature/bltouch.h" +#endif /** * M401: Deploy and activate the Z probe */ void GcodeSuite::M401() { + #if ENABLED(BLTOUCH) + const bool seen_S = parser.seen('S'), + to_enable = (seen_S && parser.value_bool()); + if (seen_S) + if(to_enable) + bltouch.bltouch_high_speed = true; + else + bltouch.bltouch_high_speed = false; + #endif probe.deploy(); TERN_(PROBE_TARE, probe.tare()); report_current_position(); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index c9413d3cea..8b8073b5bb 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -491,6 +491,7 @@ namespace Language_en { LSTR MSG_BLTOUCH_STOW = _UxGT("Stow"); LSTR MSG_BLTOUCH_DEPLOY = _UxGT("Deploy"); LSTR MSG_BLTOUCH_SW_MODE = _UxGT("SW-Mode"); + LSTR MSG_BLTOUCH_SPEED_MODE = _UxGT("High Speed"); LSTR MSG_BLTOUCH_5V_MODE = _UxGT("5V-Mode"); LSTR MSG_BLTOUCH_OD_MODE = _UxGT("OD-Mode"); LSTR MSG_BLTOUCH_MODE_STORE = _UxGT("Mode-Store"); diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 178d466478..8dd737a805 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -221,13 +221,13 @@ static void _lcd_level_bed_corners_get_next_position() { bool _lcd_level_bed_corners_probe(bool verify=false) { if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed - TERN_(BLTOUCH_SLOW_MODE, bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action + if(!bltouch.bltouch_high_speed) bltouch.deploy(); // Deploy in LOW SPEED MODE on every probe action do_blocking_move_to_z(last_z - LEVEL_CORNERS_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered endstops.hit_on_purpose(); set_current_from_steppers_for_axis(Z_AXIS); sync_plan_position(); - TERN_(BLTOUCH_SLOW_MODE, bltouch.stow()); // Stow in LOW SPEED MODE on every trigger + if(!bltouch.bltouch_high_speed) bltouch.stow(); // Stow in LOW SPEED MODE on every trigger // Triggered outside tolerance range? if (ABS(current_position.z - last_z) > LEVEL_CORNERS_PROBE_TOLERANCE) { last_z = current_position.z; // Above tolerance. Set a new Z for subsequent corners. @@ -253,7 +253,7 @@ static void _lcd_level_bed_corners_get_next_position() { } idle(); } - TERN_(BLTOUCH_SLOW_MODE, bltouch.stow()); + if(!bltouch.bltouch_high_speed) bltouch.stow(); ui.goto_screen(_lcd_draw_probing); return (probe_triggered); } @@ -267,13 +267,14 @@ static void _lcd_level_bed_corners_get_next_position() { do { ui.refresh(LCDVIEW_REDRAW_NOW); _lcd_draw_probing(); // update screen with # of good points - do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, current_position.z + LEVEL_CORNERS_Z_HOP, 7)); // clearance + float z_raise_probe = Z_CLEARANCE_BETWEEN_PROBES if(bltouch.bltouch_high_speed) + 7; + do_blocking_move_to_z(SUM_TERN(z_raise_probe, current_position.z + LEVEL_CORNERS_Z_HOP, 7)); // clearance _lcd_level_bed_corners_get_next_position(); // Select next corner coordinates current_position -= probe.offset_xy; // Account for probe offsets do_blocking_move_to_xy(current_position); // Goto corner - TERN_(BLTOUCH_HS_MODE, bltouch.deploy()); // Deploy in HIGH SPEED MODE + if(bltouch.bltouch_high_speed) bltouch.deploy(); // Deploy in HIGH SPEED MODE if (!_lcd_level_bed_corners_probe()) { // Probe down to tolerance if (_lcd_level_bed_corners_raise()) { // Prompt user to raise bed if needed #if ENABLED(LEVEL_CORNERS_VERIFY_RAISED) // Verify @@ -294,11 +295,11 @@ static void _lcd_level_bed_corners_get_next_position() { } while (good_points < nr_edge_points); // loop until all points within tolerance - #if ENABLED(BLTOUCH_HS_MODE) + if (bltouch.bltouch_high_speed) // In HIGH SPEED MODE do clearance and stow at the very end do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); bltouch.stow(); - #endif + } ui.goto_screen(_lcd_draw_level_prompt); // prompt for bed leveling ui.set_selection(true); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 0e11cd211a..5865d4898c 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -235,6 +235,7 @@ void menu_advanced_settings(); ACTION_ITEM(MSG_BLTOUCH_DEPLOY, bltouch._deploy); ACTION_ITEM(MSG_BLTOUCH_STOW, bltouch._stow); ACTION_ITEM(MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode); + EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.bltouch_high_speed); #if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU) CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index 5cdcf75c1e..5109a699ed 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -51,7 +51,8 @@ static int8_t reference_index; // = 0 static bool probe_single_point() { do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES)); // Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety - const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], TERN(BLTOUCH_HS_MODE, PROBE_PT_STOW, PROBE_PT_RAISE), 0, true); + + const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], if(bltouch.bltouch_high_speed) PROBE_PT_STOW else PROBE_PT_RAISE), 0, true); z_measured[tram_index] = z_probed_height; if (reference_index < 0) reference_index = tram_index; move_to_tramming_wait_pos(); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index f5dd5d34c9..d4974ff1a3 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1802,8 +1802,8 @@ void prepare_line_to_destination() { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home Fast: ", move_length, "mm"); do_homing_move(axis, move_length, 0.0, !use_probe_bump); - #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE) - if (axis == Z_AXIS) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) + #if ENABLED(HOMING_Z_WITH_PROBE, BLTOUCH) + if (axis == Z_AXIS && !bltouch.bltouch_high_speed) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) #endif // If a second homing move is configured... @@ -1836,8 +1836,9 @@ void prepare_line_to_destination() { } #endif - #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE) - if (axis == Z_AXIS && bltouch.deploy()) return; // Intermediate DEPLOY (in LOW SPEED MODE) + #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH) + if(!bltouch.bltouch_high_speed) + if (axis == Z_AXIS && bltouch.deploy()) return; // Intermediate DEPLOY (in LOW SPEED MODE) #endif // Slow move towards endstop until triggered diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 4078effe76..f2f5eee520 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -487,8 +487,10 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { #if BOTH(HAS_TEMP_HOTEND, WAIT_FOR_HOTEND) thermalManager.wait_for_hotend_heating(active_extruder); #endif - - if (TERN0(BLTOUCH_SLOW_MODE, bltouch.deploy())) return true; // Deploy in LOW SPEED MODE on every probe action + #if ENABLED(BLTOUCH) + if(!bltouch.bltouch_high_speed) + if (bltouch.deploy()) return true; // Deploy in LOW SPEED MODE on every probe action + #endif // Disable stealthChop if used. Enable diag1 pin on driver. #if ENABLED(SENSORLESS_PROBING) @@ -528,10 +530,11 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { if (probe.test_sensitivity.z) tmc_disable_stallguard(stepperZ, stealth_states.z); set_homing_current(false); #endif - - if (probe_triggered && TERN0(BLTOUCH_SLOW_MODE, bltouch.stow())) // Stow in LOW SPEED MODE on every trigger - return true; - + #if ENABLED(BLTOUCH) + if(!bltouch.bltouch_high_speed) + if (probe_triggered && bltouch.stow()) // Stow in LOW SPEED MODE on every trigger + return true; + #endif // Clear endstop flags endstops.hit_on_purpose(); @@ -760,8 +763,8 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai DEBUG_POS("", current_position); } - #if BOTH(BLTOUCH, BLTOUCH_HS_MODE) - if (bltouch.triggered()) bltouch._reset(); + #if ENABLED(BLTOUCH) + if (bltouch.triggered() && bltouch.bltouch_high_speed) bltouch._reset(); #endif // On delta keep Z below clip height or do_blocking_move_to will abort diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 6b7143e82a..9698348ae3 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -36,7 +36,7 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V85" +#define EEPROM_VERSION "V86" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -277,6 +277,7 @@ typedef struct SettingsDataStruct { // BLTOUCH // bool bltouch_last_written_mode; + bool bltouch_high_speed;. // // Kinematic Settings @@ -861,6 +862,10 @@ void MarlinSettings::postprocess() { _FIELD_TEST(bltouch_last_written_mode); const bool bltouch_last_written_mode = TERN(BLTOUCH, bltouch.last_written_mode, false); EEPROM_WRITE(bltouch_last_written_mode); + + _FIELD_TEST(bltouch_high_speed); + const bool bltouch_high_speed = TERN(BLTOUCH, bltouch.bltouch_high_speed, false); + EEPROM_WRITE(bltouch_high_speed); } // @@ -1732,6 +1737,14 @@ void MarlinSettings::postprocess() { bool bltouch_last_written_mode; #endif EEPROM_READ(bltouch_last_written_mode); + + _FIELD_TEST(bltouch_high_speed); + #if ENABLED(BLTOUCH) + const bool &bltouch_high_speed = bltouch.bltouch_high_speed; + #else + bool bltouch_high_speed; + #endif + EEPROM_READ(bltouch_last_written_mode); } // @@ -2729,12 +2742,9 @@ void MarlinSettings::reset() { TERN_(EDITABLE_SERVO_ANGLES, COPY(servo_angles, base_servo_angles)); // When not editable only one copy of servo angles exists // - // BLTOUCH + // BLTouch // - //#if ENABLED(BLTOUCH) - // bltouch.last_written_mode; - //#endif - + TERN_(BLTOUCH_HS_MODE, bltouch.bltouch_high_speed = true); // // Kinematic settings // From b8dfc53693e931740395b86e5ef7372d5ac3dd6c Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 9 Oct 2021 14:07:02 -0400 Subject: [PATCH 23/58] Return on mode change without deploying --- Marlin/src/gcode/probe/M401_M402.cpp | 6 +++++- Marlin/src/module/settings.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/probe/M401_M402.cpp b/Marlin/src/gcode/probe/M401_M402.cpp index aef34f3a1e..95828c23b1 100644 --- a/Marlin/src/gcode/probe/M401_M402.cpp +++ b/Marlin/src/gcode/probe/M401_M402.cpp @@ -33,16 +33,20 @@ /** * M401: Deploy and activate the Z probe + * BLTouch Only : + * S : Set High Speed Mode */ void GcodeSuite::M401() { #if ENABLED(BLTOUCH) const bool seen_S = parser.seen('S'), to_enable = (seen_S && parser.value_bool()); - if (seen_S) + if (seen_S) { if(to_enable) bltouch.bltouch_high_speed = true; else bltouch.bltouch_high_speed = false; + return; + } #endif probe.deploy(); TERN_(PROBE_TARE, probe.tare()); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 9698348ae3..80b9736478 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -277,7 +277,7 @@ typedef struct SettingsDataStruct { // BLTOUCH // bool bltouch_last_written_mode; - bool bltouch_high_speed;. + bool bltouch_high_speed; // // Kinematic Settings From 4f62ae97640a0888825d615fce4178de42e74fa9 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 9 Oct 2021 14:07:02 -0400 Subject: [PATCH 24/58] Return on mode change without deploying --- Marlin/src/gcode/probe/M401_M402.cpp | 6 +++++- Marlin/src/module/settings.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/probe/M401_M402.cpp b/Marlin/src/gcode/probe/M401_M402.cpp index aef34f3a1e..95828c23b1 100644 --- a/Marlin/src/gcode/probe/M401_M402.cpp +++ b/Marlin/src/gcode/probe/M401_M402.cpp @@ -33,16 +33,20 @@ /** * M401: Deploy and activate the Z probe + * BLTouch Only : + * S : Set High Speed Mode */ void GcodeSuite::M401() { #if ENABLED(BLTOUCH) const bool seen_S = parser.seen('S'), to_enable = (seen_S && parser.value_bool()); - if (seen_S) + if (seen_S) { if(to_enable) bltouch.bltouch_high_speed = true; else bltouch.bltouch_high_speed = false; + return; + } #endif probe.deploy(); TERN_(PROBE_TARE, probe.tare()); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 9698348ae3..80b9736478 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -277,7 +277,7 @@ typedef struct SettingsDataStruct { // BLTOUCH // bool bltouch_last_written_mode; - bool bltouch_high_speed;. + bool bltouch_high_speed; // // Kinematic Settings From ec7a4eb69ebea87362e8bbc7bd48c929c0e963d9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 9 Oct 2021 18:41:47 -0500 Subject: [PATCH 25/58] clean up and fix --- Marlin/src/feature/bltouch.cpp | 4 ++-- Marlin/src/feature/bltouch.h | 7 +++++-- Marlin/src/gcode/bedlevel/G35.cpp | 3 +-- Marlin/src/gcode/calibrate/G34_M422.cpp | 2 +- Marlin/src/gcode/probe/M401_M402.cpp | 9 ++------- Marlin/src/lcd/menu/menu_bed_corners.cpp | 13 ++++++------- Marlin/src/lcd/menu/menu_configuration.cpp | 2 +- Marlin/src/lcd/menu/menu_tramming.cpp | 2 +- Marlin/src/module/motion.cpp | 6 +++--- Marlin/src/module/probe.cpp | 11 +++++------ Marlin/src/module/settings.cpp | 16 ++++++++-------- 11 files changed, 35 insertions(+), 40 deletions(-) diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index fbe6012bbe..9450ae8ee7 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -28,8 +28,8 @@ BLTouch bltouch; -bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain -bool BLTouch::bltouch_high_speed; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed +bool BLTouch::last_written_mode, // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain + BLTouch::high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed #include "../module/servo.h" #include "../module/probe.h" diff --git a/Marlin/src/feature/bltouch.h b/Marlin/src/feature/bltouch.h index 7d9a0bb126..f1485826b5 100644 --- a/Marlin/src/feature/bltouch.h +++ b/Marlin/src/feature/bltouch.h @@ -66,9 +66,12 @@ typedef unsigned char BLTCommand; class BLTouch { public: + static void init(const bool set_voltage=false); - static bool last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain - static bool bltouch_high_speed; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed + static bool last_written_mode, // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain + high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed + + const float z_extra_clearance() { return high_speed_mode ? 7 : 0; } // DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing static bool deploy() { return deploy_proc(); } diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 08539f8966..8ce6abfb95 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -102,8 +102,7 @@ void GcodeSuite::G35() { // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G35 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - float z_raise_probe = Z_CLEARANCE_BETWEEN_PROBES if(bltouch.bltouch_high_speed) + 7; - do_blocking_move_to_z(z_raise_probe); + do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES + TERN0(BLTOUCH, bltouch.z_extra_clearance())); const float z_probed_height = probe.probe_at_point(tramming_points[i], PROBE_PT_RAISE, 0, true); if (isnan(z_probed_height)) { diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 5b70dc588e..11f3eac6fa 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -149,7 +149,7 @@ void GcodeSuite::G34() { // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G34 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - #define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + 7.0f * bltouch.bltouch_high_speed) + #define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + TERN0(BLTOUCH, bltouch.z_extra_clearance())) // Compute a worst-case clearance height to probe from. After the first // iteration this will be re-calculated based on the actual bed position diff --git a/Marlin/src/gcode/probe/M401_M402.cpp b/Marlin/src/gcode/probe/M401_M402.cpp index 95828c23b1..390c31b2db 100644 --- a/Marlin/src/gcode/probe/M401_M402.cpp +++ b/Marlin/src/gcode/probe/M401_M402.cpp @@ -38,13 +38,8 @@ */ void GcodeSuite::M401() { #if ENABLED(BLTOUCH) - const bool seen_S = parser.seen('S'), - to_enable = (seen_S && parser.value_bool()); - if (seen_S) { - if(to_enable) - bltouch.bltouch_high_speed = true; - else - bltouch.bltouch_high_speed = false; + if (parser.seen('S')) { + bltouch.high_speed_mode = parser.value_bool(); return; } #endif diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 8dd737a805..b1dfe5a4a4 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -221,13 +221,13 @@ static void _lcd_level_bed_corners_get_next_position() { bool _lcd_level_bed_corners_probe(bool verify=false) { if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed - if(!bltouch.bltouch_high_speed) bltouch.deploy(); // Deploy in LOW SPEED MODE on every probe action + if (!bltouch.high_speed_mode) bltouch.deploy(); // Deploy in LOW SPEED MODE on every probe action do_blocking_move_to_z(last_z - LEVEL_CORNERS_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered endstops.hit_on_purpose(); set_current_from_steppers_for_axis(Z_AXIS); sync_plan_position(); - if(!bltouch.bltouch_high_speed) bltouch.stow(); // Stow in LOW SPEED MODE on every trigger + if (!bltouch.high_speed_mode) bltouch.stow(); // Stow in LOW SPEED MODE on every trigger // Triggered outside tolerance range? if (ABS(current_position.z - last_z) > LEVEL_CORNERS_PROBE_TOLERANCE) { last_z = current_position.z; // Above tolerance. Set a new Z for subsequent corners. @@ -253,7 +253,7 @@ static void _lcd_level_bed_corners_get_next_position() { } idle(); } - if(!bltouch.bltouch_high_speed) bltouch.stow(); + if (!bltouch.high_speed_mode) bltouch.stow(); ui.goto_screen(_lcd_draw_probing); return (probe_triggered); } @@ -267,14 +267,13 @@ static void _lcd_level_bed_corners_get_next_position() { do { ui.refresh(LCDVIEW_REDRAW_NOW); _lcd_draw_probing(); // update screen with # of good points - float z_raise_probe = Z_CLEARANCE_BETWEEN_PROBES if(bltouch.bltouch_high_speed) + 7; - do_blocking_move_to_z(SUM_TERN(z_raise_probe, current_position.z + LEVEL_CORNERS_Z_HOP, 7)); // clearance + do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP + (bltouch.high_speed_mode ? 7, 0)); // clearance _lcd_level_bed_corners_get_next_position(); // Select next corner coordinates current_position -= probe.offset_xy; // Account for probe offsets do_blocking_move_to_xy(current_position); // Goto corner - if(bltouch.bltouch_high_speed) bltouch.deploy(); // Deploy in HIGH SPEED MODE + if (bltouch.high_speed_mode) bltouch.deploy(); // Deploy in HIGH SPEED MODE if (!_lcd_level_bed_corners_probe()) { // Probe down to tolerance if (_lcd_level_bed_corners_raise()) { // Prompt user to raise bed if needed #if ENABLED(LEVEL_CORNERS_VERIFY_RAISED) // Verify @@ -295,7 +294,7 @@ static void _lcd_level_bed_corners_get_next_position() { } while (good_points < nr_edge_points); // loop until all points within tolerance - if (bltouch.bltouch_high_speed) + if (bltouch.high_speed_mode) // In HIGH SPEED MODE do clearance and stow at the very end do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); bltouch.stow(); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 5865d4898c..6006f86891 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -235,7 +235,7 @@ void menu_advanced_settings(); ACTION_ITEM(MSG_BLTOUCH_DEPLOY, bltouch._deploy); ACTION_ITEM(MSG_BLTOUCH_STOW, bltouch._stow); ACTION_ITEM(MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode); - EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.bltouch_high_speed); + EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.high_speed_mode); #if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU) CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index 5109a699ed..ce9e50b3e7 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -52,7 +52,7 @@ static bool probe_single_point() { do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES)); // Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety - const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], if(bltouch.bltouch_high_speed) PROBE_PT_STOW else PROBE_PT_RAISE), 0, true); + const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], bltouch.high_speed_mode ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true); z_measured[tram_index] = z_probed_height; if (reference_index < 0) reference_index = tram_index; move_to_tramming_wait_pos(); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 091facc94c..f05e31a498 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1800,7 +1800,7 @@ void prepare_line_to_destination() { do_homing_move(axis, move_length, 0.0, !use_probe_bump); #if ENABLED(HOMING_Z_WITH_PROBE, BLTOUCH) - if (axis == Z_AXIS && !bltouch.bltouch_high_speed) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) + if (axis == Z_AXIS && !bltouch.high_speed_mode) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) #endif // If a second homing move is configured... @@ -1834,8 +1834,8 @@ void prepare_line_to_destination() { #endif #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH) - if(!bltouch.bltouch_high_speed) - if (axis == Z_AXIS && bltouch.deploy()) return; // Intermediate DEPLOY (in LOW SPEED MODE) + if (axis == Z_AXIS && !bltouch.high_speed_mode && bltouch.deploy()) + return; // Intermediate DEPLOY (in LOW SPEED MODE) #endif // Slow move towards endstop until triggered diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index f2f5eee520..02903419aa 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -488,8 +488,8 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { thermalManager.wait_for_hotend_heating(active_extruder); #endif #if ENABLED(BLTOUCH) - if(!bltouch.bltouch_high_speed) - if (bltouch.deploy()) return true; // Deploy in LOW SPEED MODE on every probe action + if (!bltouch.high_speed_mode && bltouch.deploy()) + return true; // Deploy in LOW SPEED MODE on every probe action #endif // Disable stealthChop if used. Enable diag1 pin on driver. @@ -531,9 +531,8 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { set_homing_current(false); #endif #if ENABLED(BLTOUCH) - if(!bltouch.bltouch_high_speed) - if (probe_triggered && bltouch.stow()) // Stow in LOW SPEED MODE on every trigger - return true; + if (!bltouch.high_speed_mode && probe_triggered && bltouch.stow()) + return true; // Stow in LOW SPEED MODE on every trigger #endif // Clear endstop flags endstops.hit_on_purpose(); @@ -764,7 +763,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai } #if ENABLED(BLTOUCH) - if (bltouch.triggered() && bltouch.bltouch_high_speed) bltouch._reset(); + if (bltouch.triggered() && bltouch.high_speed_mode) bltouch._reset(); #endif // On delta keep Z below clip height or do_blocking_move_to will abort diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 80b9736478..56b071acd2 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -277,7 +277,7 @@ typedef struct SettingsDataStruct { // BLTOUCH // bool bltouch_last_written_mode; - bool bltouch_high_speed; + bool high_speed_mode; // // Kinematic Settings @@ -863,9 +863,9 @@ void MarlinSettings::postprocess() { const bool bltouch_last_written_mode = TERN(BLTOUCH, bltouch.last_written_mode, false); EEPROM_WRITE(bltouch_last_written_mode); - _FIELD_TEST(bltouch_high_speed); - const bool bltouch_high_speed = TERN(BLTOUCH, bltouch.bltouch_high_speed, false); - EEPROM_WRITE(bltouch_high_speed); + _FIELD_TEST(high_speed_mode); + const bool high_speed_mode = TERN(BLTOUCH, bltouch.high_speed_mode, false); + EEPROM_WRITE(high_speed_mode); } // @@ -1738,11 +1738,11 @@ void MarlinSettings::postprocess() { #endif EEPROM_READ(bltouch_last_written_mode); - _FIELD_TEST(bltouch_high_speed); + _FIELD_TEST(high_speed_mode); #if ENABLED(BLTOUCH) - const bool &bltouch_high_speed = bltouch.bltouch_high_speed; + const bool &high_speed_mode = bltouch.high_speed_mode; #else - bool bltouch_high_speed; + bool high_speed_mode; #endif EEPROM_READ(bltouch_last_written_mode); } @@ -2744,7 +2744,7 @@ void MarlinSettings::reset() { // // BLTouch // - TERN_(BLTOUCH_HS_MODE, bltouch.bltouch_high_speed = true); + TERN_(BLTOUCH_HS_MODE, bltouch.high_speed_mode = true); // // Kinematic settings // From cbaf1af0fe27178a119fc4c3ddb4ed57b86f18bb Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 10 Oct 2021 19:51:56 -0400 Subject: [PATCH 26/58] Followup to IDEX fix --- Marlin/src/module/motion.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index d4974ff1a3..f55819eed9 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1193,6 +1193,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { case DXC_MIRRORED_MODE: case DXC_DUPLICATION_MODE: if (active_extruder == 0) { + set_duplication_enabled(false); // Clear stale duplication state // Restore planner to parked head (T1) X position float x0_pos = current_position.x; xyze_pos_t pos_now = current_position; From ffa8e0ce6075ab1eea3d5b7a0a045eb8135b16d8 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Mon, 11 Oct 2021 10:54:22 -0400 Subject: [PATCH 27/58] potentially fix multi nozzle duplication as well --- Marlin/src/module/planner.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index e62a9ab5ee..3e7bf4a33c 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2220,9 +2220,10 @@ bool Planner::_populate_block(block_t * const block, bool split_move, stepper.ENABLE_EXTRUDER(1); \ } \ else if (!g_uc_extruder_last_move[N]) { \ - stepper.DISABLE_EXTRUDER(N); \ - if ((N) == 0 && TERN0(HAS_DUPLICATION_MODE, extruder_duplication_enabled)) \ - stepper.DISABLE_EXTRUDER(1); \ + if ((N) == 0 && TERN0(HAS_DUPLICATION_MODE, extruder_duplication_enabled) && TERN1(MULTI_NOZZLE_DUPLICATION, TEST(duplication_e_mask, N))) \ + stepper.ENABLE_EXTRUDER(N); \ + else + stepper.DISABLE_EXTRUDER(N); \ } \ }while(0); From 097712935367c4f37bd9e810b778c8966ba94df5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 11 Oct 2021 17:29:17 -0500 Subject: [PATCH 28/58] Update planner.cpp --- Marlin/src/module/planner.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 3e7bf4a33c..a22e1a4a8c 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2211,18 +2211,18 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (g_uc_extruder_last_move[i]) g_uc_extruder_last_move[i]--; #define E_STEPPER_INDEX(E) TERN(SWITCHING_EXTRUDER, (E) / 2, E) + #define _IS_DUPE_0(N) TERN0(HAS_DUPLICATION_MODE, (N) == 0 && extruder_duplication_enabled) #define ENABLE_ONE_E(N) do{ \ if (E_STEPPER_INDEX(extruder) == N) { \ stepper.ENABLE_EXTRUDER(N); \ g_uc_extruder_last_move[N] = (BLOCK_BUFFER_SIZE) * 2; \ - if ((N) == 0 && TERN0(HAS_DUPLICATION_MODE, extruder_duplication_enabled)) \ - stepper.ENABLE_EXTRUDER(1); \ + if (_IS_DUPE_0(N)) stepper.ENABLE_EXTRUDER(1); \ } \ else if (!g_uc_extruder_last_move[N]) { \ - if ((N) == 0 && TERN0(HAS_DUPLICATION_MODE, extruder_duplication_enabled) && TERN1(MULTI_NOZZLE_DUPLICATION, TEST(duplication_e_mask, N))) \ - stepper.ENABLE_EXTRUDER(N); \ - else + if (_IS_DUPE_0(N) && TERN1(MULTI_NOZZLE_DUPLICATION, TEST(duplication_e_mask, 0))) \ + stepper.ENABLE_EXTRUDER(0); \ + else \ stepper.DISABLE_EXTRUDER(N); \ } \ }while(0); From 9a9a112673569e031d5413cbabe9aa20c96b1b97 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Mon, 11 Oct 2021 22:07:45 -0400 Subject: [PATCH 29/58] Simplify macro --- Marlin/src/module/planner.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index a22e1a4a8c..997a9fa6ea 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2211,18 +2211,14 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (g_uc_extruder_last_move[i]) g_uc_extruder_last_move[i]--; #define E_STEPPER_INDEX(E) TERN(SWITCHING_EXTRUDER, (E) / 2, E) - #define _IS_DUPE_0(N) TERN0(HAS_DUPLICATION_MODE, (N) == 0 && extruder_duplication_enabled) + #define _IS_DUPE_0(N) TERN0(HAS_DUPLICATION_MODE, (extruder_duplication_enabled && TERN1(MULTI_NOZZLE_DUPLICATION, TEST(duplication_e_mask, N)))) #define ENABLE_ONE_E(N) do{ \ - if (E_STEPPER_INDEX(extruder) == N) { \ + if (E_STEPPER_INDEX(extruder) == N || _IS_DUPE_0(N)) { \ stepper.ENABLE_EXTRUDER(N); \ g_uc_extruder_last_move[N] = (BLOCK_BUFFER_SIZE) * 2; \ - if (_IS_DUPE_0(N)) stepper.ENABLE_EXTRUDER(1); \ } \ else if (!g_uc_extruder_last_move[N]) { \ - if (_IS_DUPE_0(N) && TERN1(MULTI_NOZZLE_DUPLICATION, TEST(duplication_e_mask, 0))) \ - stepper.ENABLE_EXTRUDER(0); \ - else \ stepper.DISABLE_EXTRUDER(N); \ } \ }while(0); From 78c57f2847f88adb0b6fa40f8d8fcfbc6e80f5d8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 12 Oct 2021 22:21:43 -0500 Subject: [PATCH 30/58] Update menu_tramming.cpp --- Marlin/src/lcd/menu/menu_tramming.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index ce9e50b3e7..e0958392bb 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -51,7 +51,6 @@ static int8_t reference_index; // = 0 static bool probe_single_point() { do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES)); // Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety - const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], bltouch.high_speed_mode ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true); z_measured[tram_index] = z_probed_height; if (reference_index < 0) reference_index = tram_index; From a6c4c5a3f76419b574e948db7606f3c762959df7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 12 Oct 2021 22:22:15 -0500 Subject: [PATCH 31/58] Update motion.cpp --- Marlin/src/module/motion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 824653da1b..029625efea 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1803,7 +1803,7 @@ void prepare_line_to_destination() { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home Fast: ", move_length, "mm"); do_homing_move(axis, move_length, 0.0, !use_probe_bump); - #if ENABLED(HOMING_Z_WITH_PROBE, BLTOUCH) + #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH) if (axis == Z_AXIS && !bltouch.high_speed_mode) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) #endif From 9aaa7b11004d0a1931e2ecc3c204673f4ce29126 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Thu, 14 Oct 2021 13:34:31 -0400 Subject: [PATCH 32/58] Add missing include --- Marlin/src/gcode/calibrate/G34_M422.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 11f3eac6fa..328a40dbb4 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -45,6 +45,10 @@ #include "../../libs/least_squares_fit.h" #endif +#if ENABLED(BLTOUCH) + #include "../../feature/bltouch.h" +#endif + #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../../core/debug_out.h" From 5284f45c625ddfadaa3a9a909184f87111d70cdc Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Thu, 14 Oct 2021 13:41:31 -0400 Subject: [PATCH 33/58] Update menu_tramming.cpp --- Marlin/src/lcd/menu/menu_tramming.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index e0958392bb..4a09e4347c 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -36,6 +36,10 @@ #include "../../module/probe.h" #include "../../gcode/queue.h" +#if ENABLED(BLTOUCH) + #include "../../feature/bltouch.h" +#endif + //#define DEBUG_OUT 1 #include "../../core/debug_out.h" From 102c43dcd5737a950fe0e670039b047e9ae307e1 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Thu, 14 Oct 2021 13:50:56 -0400 Subject: [PATCH 34/58] Update G35.cpp --- Marlin/src/gcode/bedlevel/G35.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 8ce6abfb95..1013e080bb 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -33,6 +33,11 @@ #include "../../module/tool_change.h" #endif +#if ENABLED(BLTOUCH) + #include "../../feature/bltouch.h" +#endif + + #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../../core/debug_out.h" From 1fab2ef94f231e70fe28470fb169d990321ca8ac Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Thu, 14 Oct 2021 14:01:42 -0400 Subject: [PATCH 35/58] Update menu_tramming.cpp --- Marlin/src/lcd/menu/menu_tramming.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index 4a09e4347c..8573fb9235 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -55,7 +55,7 @@ static int8_t reference_index; // = 0 static bool probe_single_point() { do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES)); // Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety - const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], bltouch.high_speed_mode ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true); + const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], TERN(BLTOUCH, bltouch.high_speed_mode ? PROBE_PT_STOW : PROBE_PT_RAISE, PROBE_PT_RAISE), 0, true); z_measured[tram_index] = z_probed_height; if (reference_index < 0) reference_index = tram_index; move_to_tramming_wait_pos(); From 29f85afe50ae7a532f4e1d9723db0e702689493e Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Thu, 14 Oct 2021 18:48:59 -0400 Subject: [PATCH 36/58] Update settings.cpp --- Marlin/src/module/settings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 56b071acd2..f33fe3e7dd 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -1744,7 +1744,7 @@ void MarlinSettings::postprocess() { #else bool high_speed_mode; #endif - EEPROM_READ(bltouch_last_written_mode); + EEPROM_READ(high_speed_mode); } // From 29822ee60ea8313674d72c4164ad7ff4e3170198 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Tue, 8 Mar 2022 17:54:22 -0500 Subject: [PATCH 37/58] Update Configuration_adv.h --- Marlin/Configuration_adv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 53b8cd98bb..ce838a4aec 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2294,7 +2294,7 @@ #if BOTH(SDSUPPORT, DIRECT_STEPPING) #define BLOCK_BUFFER_SIZE 8 #elif ENABLED(SDSUPPORT) - #define BLOCK_BUFFER_SIZE 16 + #define BLOCK_BUFFER_SIZE 8 #else #define BLOCK_BUFFER_SIZE 16 // maximize block buffer #endif From 3226adf2a62397ca681e7aac63ab36d4ab06729d Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Tue, 8 Mar 2022 17:54:24 -0500 Subject: [PATCH 38/58] Update Configuration.h --- Marlin/Configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index a59115ec31..78592de115 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1675,7 +1675,7 @@ * RAMPS-based boards use SERVO3_PIN for the first runout sensor. * For other boards you may need to define FIL_RUNOUT_PIN, FIL_RUNOUT2_PIN, etc. */ - #if ANY(FilamentSensor, filamentEncoder, lerdgeFilSensor) +#if ANY(FilamentSensor, filamentEncoder, lerdgeFilSensor) #define FILAMENT_RUNOUT_SENSOR #endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) From 66efa0b09b89b22eecc04ff370b1f4458f790116 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 12 Mar 2022 15:53:04 -0500 Subject: [PATCH 39/58] Initial commit - Flexible Runout Configuration M591 --- Marlin/src/feature/host_actions.cpp | 2 +- Marlin/src/feature/mmu/mmu2.cpp | 2 +- Marlin/src/feature/runout.cpp | 18 +- Marlin/src/feature/runout.h | 155 ++++++------------ Marlin/src/gcode/feature/pause/M600.cpp | 2 +- .../feature/runout/{M412.cpp => M591.cpp} | 70 +++++--- Marlin/src/gcode/gcode.cpp | 9 +- Marlin/src/gcode/gcode.h | 5 +- Marlin/src/gcode/host/M115.cpp | 2 +- Marlin/src/inc/Conditionals_adv.h | 3 - Marlin/src/inc/SanityCheck.h | 4 - Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 32 ++-- Marlin/src/lcd/e3v2/proui/dwin.cpp | 16 +- Marlin/src/lcd/e3v2/proui/endstop_diag.cpp | 2 +- .../generic/filament_runout_screen.cpp | 21 +-- Marlin/src/lcd/extui/ui_api.cpp | 11 +- Marlin/src/lcd/extui/ui_api.h | 10 +- Marlin/src/lcd/menu/menu_advanced.cpp | 4 +- Marlin/src/lcd/menu/menu_configuration.cpp | 2 +- Marlin/src/lcd/menu/menu_filament.cpp | 2 +- Marlin/src/module/endstops.cpp | 22 ++- Marlin/src/module/settings.cpp | 66 +++++--- Marlin/src/module/stepper.cpp | 4 +- 23 files changed, 221 insertions(+), 243 deletions(-) rename Marlin/src/gcode/feature/runout/{M412.cpp => M591.cpp} (53%) diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index c03a6bc597..3385076701 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -177,7 +177,7 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { #endif #if HAS_FILAMENT_SENSOR if (runout.filament_ran_out) { // Disable a triggered sensor - runout.enabled = false; + runout.enabled[active_extruder] = false; runout.reset(); } #endif diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 2813337c63..2bb69fa9c6 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -140,7 +140,7 @@ uint8_t MMU2::get_current_tool() { } #if EITHER(HAS_PRUSA_MMU2S, MMU_EXTRUDER_SENSOR) - #define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE) + #define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != (runout.mode[0]==2 ? HIGH, LOW)) #endif void MMU2::mmu_loop() { diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 98b6bd0510..7791637699 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -32,9 +32,9 @@ FilamentMonitor runout; -bool FilamentMonitorBase::enabled = true, +bool FilamentMonitorBase::enabled[HOTENDS] = {true}, FilamentMonitorBase::filament_ran_out; // = false - +uint8_t FilamentMonitorBase::mode[HOTENDS] = FILAMENT_RUNOUT_DEFAULT_MODE; // Initialized by settings.load #if ENABLED(HOST_ACTION_COMMANDS) bool FilamentMonitorBase::host_handling; // = false #endif @@ -45,15 +45,11 @@ bool FilamentMonitorBase::enabled = true, #include "../core/debug_out.h" #endif -#if HAS_FILAMENT_RUNOUT_DISTANCE - float RunoutResponseDelayed::runout_distance_mm = FILAMENT_RUNOUT_DISTANCE_MM; - volatile float RunoutResponseDelayed::runout_mm_countdown[NUM_RUNOUT_SENSORS]; - #if ENABLED(FILAMENT_MOTION_SENSOR) - uint8_t FilamentSensorEncoder::motion_detected; - #endif -#else - int8_t RunoutResponseDebounced::runout_count[NUM_RUNOUT_SENSORS]; // = 0 -#endif + +float RunoutResponseDelayed::runout_distance_mm[HOTENDS] = FILAMENT_RUNOUT_DISTANCE_MM; +volatile float RunoutResponseDelayed::runout_mm_countdown[HOTENDS]; +uint8_t FilamentSensorCore::motion_detected; + // // Filament Runout event handler diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index e74d857a79..2844264481 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -47,16 +47,14 @@ void event_filament_runout(const uint8_t extruder); template class TFilamentMonitor; -class FilamentSensorEncoder; -class FilamentSensorSwitch; +class FilamentSensorCore; class RunoutResponseDelayed; -class RunoutResponseDebounced; /********************************* TEMPLATE SPECIALIZATION *********************************/ typedef TFilamentMonitor< - TERN(HAS_FILAMENT_RUNOUT_DISTANCE, RunoutResponseDelayed, RunoutResponseDebounced), - TERN(FILAMENT_MOTION_SENSOR, FilamentSensorEncoder, FilamentSensorSwitch) + RunoutResponseDelayed, + FilamentSensorCore > FilamentMonitor; extern FilamentMonitor runout; @@ -65,7 +63,8 @@ extern FilamentMonitor runout; class FilamentMonitorBase { public: - static bool enabled, filament_ran_out; + static bool enabled[HOTENDS], filament_ran_out; + static uint8_t mode[HOTENDS]; #if ENABLED(HOST_ACTION_COMMANDS) static bool host_handling; @@ -99,10 +98,8 @@ class TFilamentMonitor : public FilamentMonitorBase { response.filament_present(extruder); } - #if HAS_FILAMENT_RUNOUT_DISTANCE - static float& runout_distance() { return response.runout_distance_mm; } - static void set_runout_distance(const_float_t mm) { response.runout_distance_mm = mm; } - #endif + static float& runout_distance(uint8_t extruder=0) { return response.runout_distance_mm[extruder]; } + static void set_runout_distance(const_float_t mm, uint8_t extruder=0) { response.runout_distance_mm[extruder] = mm; } // Handle a block completion. RunoutResponseDelayed uses this to // add up the length of filament moved while the filament is out. @@ -116,11 +113,11 @@ class TFilamentMonitor : public FilamentMonitorBase { // Give the response a chance to update its counter. static void run() { if (enabled && !filament_ran_out && (printingIsActive() || did_pause_print)) { - TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, cli()); // Prevent RunoutResponseDelayed::block_completed from accumulating here + cli(); // Prevent RunoutResponseDelayed::block_completed from accumulating here response.run(); sensor.run(); const uint8_t runout_flags = response.has_run_out(); - TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, sei()); + sei(); #if MULTI_FILAMENT_SENSOR #if ENABLED(WATCH_ALL_RUNOUT_SENSORS) const bool ran_out = !!runout_flags; // any sensor triggers @@ -215,45 +212,49 @@ class FilamentSensorBase { static uint8_t poll_runout_states() { return poll_runout_pins() ^ uint8_t(0 #if NUM_RUNOUT_SENSORS >= 1 - | (FIL_RUNOUT1_STATE ? 0 : _BV(1 - 1)) + | ((runout.mode[0]==2) ? 0 : _BV(1 - 1)) #endif #if NUM_RUNOUT_SENSORS >= 2 - | (FIL_RUNOUT2_STATE ? 0 : _BV(2 - 1)) + | ((runout.mode[1]==2) ? 0 : _BV(2 - 1)) #endif #if NUM_RUNOUT_SENSORS >= 3 - | (FIL_RUNOUT3_STATE ? 0 : _BV(3 - 1)) + | ((runout.mode[2]==2) ? 0 : _BV(3 - 1)) #endif #if NUM_RUNOUT_SENSORS >= 4 - | (FIL_RUNOUT4_STATE ? 0 : _BV(4 - 1)) + | ((runout.mode[3]==2) ? 0 : _BV(4 - 1)) #endif #if NUM_RUNOUT_SENSORS >= 5 - | (FIL_RUNOUT5_STATE ? 0 : _BV(5 - 1)) + | ((runout.mode[4]==2) ? 0 : _BV(5 - 1)) #endif #if NUM_RUNOUT_SENSORS >= 6 - | (FIL_RUNOUT6_STATE ? 0 : _BV(6 - 1)) + | ((runout.mode[5]==2) ? 0 : _BV(6 - 1)) #endif #if NUM_RUNOUT_SENSORS >= 7 - | (FIL_RUNOUT7_STATE ? 0 : _BV(7 - 1)) + | ((runout.mode[6]==2) ? 0 : _BV(7 - 1)) #endif #if NUM_RUNOUT_SENSORS >= 8 - | (FIL_RUNOUT8_STATE ? 0 : _BV(8 - 1)) + | ((runout.mode[7]==2) ? 0 : _BV(8 - 1)) #endif ); } }; -#if ENABLED(FILAMENT_MOTION_SENSOR) - - /** - * This sensor uses a magnetic encoder disc and a Hall effect - * sensor (or a slotted disc and optical sensor). The state - * will toggle between 0 and 1 on filament movement. It can detect - * filament runout and stripouts or jams. - */ - class FilamentSensorEncoder : public FilamentSensorBase { - private: + class FilamentSensorCore : public FilamentSensorBase { + private: static uint8_t motion_detected; + static bool poll_runout_state(const uint8_t extruder) { + const uint8_t runout_states = poll_runout_states(); + #if MULTI_FILAMENT_SENSOR + if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating()) + && !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled) + ) return TEST(runout_states, extruder); // A specific extruder ran out + #else + UNUSED(extruder); + #endif + return !!runout_states; // Any extruder ran out + } + static void poll_motion_sensor() { static uint8_t old_state; const uint8_t new_state = poll_runout_pins(), @@ -274,6 +275,7 @@ class FilamentSensorBase { public: static void block_completed(const block_t * const b) { + if (runout.mode[active_extruder]!=7) return; // If the sensor wheel has moved since the last call to // this method reset the runout counter for the extruder. if (TEST(motion_detected, b->extruder)) @@ -283,54 +285,32 @@ class FilamentSensorBase { motion_detected = 0; } - static void run() { poll_motion_sensor(); } - }; - -#else - - /** - * This is a simple endstop switch in the path of the filament. - * It can detect filament runout, but not stripouts or jams. - */ - class FilamentSensorSwitch : public FilamentSensorBase { - private: - static bool poll_runout_state(const uint8_t extruder) { - const uint8_t runout_states = poll_runout_states(); - #if MULTI_FILAMENT_SENSOR - if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating()) - && !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled) - ) return TEST(runout_states, extruder); // A specific extruder ran out - #else - UNUSED(extruder); - #endif - return !!runout_states; // Any extruder ran out - } - - public: - static void block_completed(const block_t * const) {} - static void run() { - LOOP_L_N(s, NUM_RUNOUT_SENSORS) { - const bool out = poll_runout_state(s); - if (!out) filament_present(s); - #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) - static uint8_t was_out; // = 0 - if (out != TEST(was_out, s)) { - TBI(was_out, s); - SERIAL_ECHOLNF(F("Filament Sensor "), AS_DIGIT(s), out ? F(" OUT") : F(" IN")); - } - #endif + if(runout.mode[active_extruder]==7) + { + poll_motion_sensor(); + } + else if(runout.mode[active_extruder]!=0) { + LOOP_L_N(s, NUM_RUNOUT_SENSORS) { + const bool out = poll_runout_state(s); + if (!out) filament_present(s); + #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) + static uint8_t was_out; // = 0 + if (out != TEST(was_out, s)) { + TBI(was_out, s); + SERIAL_ECHOLNF(F("Filament Sensor "), AS_DIGIT(s), out ? F(" OUT") : F(" IN")); + } + #endif + } } } }; -#endif // !FILAMENT_MOTION_SENSOR + /********************************* RESPONSE TYPE *********************************/ -#if HAS_FILAMENT_RUNOUT_DISTANCE - // RunoutResponseDelayed triggers a runout event only if the length // of filament specified by FILAMENT_RUNOUT_DISTANCE_MM has been fed // during a runout condition. @@ -339,7 +319,7 @@ class FilamentSensorBase { static volatile float runout_mm_countdown[NUM_RUNOUT_SENSORS]; public: - static float runout_distance_mm; + static float runout_distance_mm[HOTENDS]; static void reset() { LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); @@ -365,7 +345,7 @@ class FilamentSensorBase { } static void filament_present(const uint8_t extruder) { - runout_mm_countdown[extruder] = runout_distance_mm; + runout_mm_countdown[extruder] = runout_distance_mm[extruder]; } static void block_completed(const block_t * const b) { @@ -378,36 +358,3 @@ class FilamentSensorBase { } }; -#else // !HAS_FILAMENT_RUNOUT_DISTANCE - - // RunoutResponseDebounced triggers a runout event after a runout - // condition has been detected runout_threshold times in a row. - - class RunoutResponseDebounced { - private: - static constexpr int8_t runout_threshold = FILAMENT_RUNOUT_THRESHOLD; - static int8_t runout_count[NUM_RUNOUT_SENSORS]; - - public: - static void reset() { - LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); - } - - static void run() { - LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_count[i] >= 0) runout_count[i]--; - } - - static uint8_t has_run_out() { - uint8_t runout_flags = 0; - LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_count[i] < 0) SBI(runout_flags, i); - return runout_flags; - } - - static void block_completed(const block_t * const) { } - - static void filament_present(const uint8_t extruder) { - runout_count[extruder] = runout_threshold; - } - }; - -#endif // !HAS_FILAMENT_RUNOUT_DISTANCE diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index 1679c90687..0b5a4d8c03 100644 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -88,7 +88,7 @@ void GcodeSuite::M600() { // In this case, for duplicating modes set DXC_ext to the extruder that ran out. #if MULTI_FILAMENT_SENSOR if (idex_is_duplicating()) - DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT2_STATE) ? 1 : 0; + DXC_ext = (READ(FIL_RUNOUT2_PIN) == (runout.mode[1]==2 ? HIGH, LOW) ? 1 : 0; #else DXC_ext = active_extruder; #endif diff --git a/Marlin/src/gcode/feature/runout/M412.cpp b/Marlin/src/gcode/feature/runout/M591.cpp similarity index 53% rename from Marlin/src/gcode/feature/runout/M412.cpp rename to Marlin/src/gcode/feature/runout/M591.cpp index bcf1e9f1b1..e80252677a 100644 --- a/Marlin/src/gcode/feature/runout/M412.cpp +++ b/Marlin/src/gcode/feature/runout/M591.cpp @@ -27,18 +27,37 @@ #include "../../gcode.h" #include "../../../feature/runout.h" + +void GcodeSuite::M412() { + SERIAL_ECHOLNPGM_P("M412 is Deprecated, please us M591."); + M591(); +} /** - * M412: Enable / Disable filament runout detection + 591: Configure filament runout detection * * Parameters * R : Reset the runout sensor * S : Reset and enable/disable the runout sensor * H : Enable/disable host handling of filament runout - * D : Extra distance to continue after runout is triggered + * L : Extra distance to continue after runout is triggered or motion interval + * D : Alias for L + * P : Mode : + 0 = none + 1 = simple sensor (high signal when filament present) + 2 = simple sensor (low signal when filament present) + 7 = motion encoder sensor */ -void GcodeSuite::M412() { - if (parser.seen("RS" - TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, "D") +void GcodeSuite::M591() { + #if HOTENDS > 1 + if(parser.seen("E")) + const uint8_t tool = parser.value_ushort(); + else + tool = active_extruder; + #else + const uint8_t tool = 0; + #endif + + if (parser.seen("RSDP" TERN_(HOST_ACTION_COMMANDS, "H") )) { #if ENABLED(HOST_ACTION_COMMANDS) @@ -46,18 +65,24 @@ void GcodeSuite::M412() { #endif const bool seenR = parser.seen_test('R'), seenS = parser.seen('S'); if (seenR || seenS) runout.reset(); - if (seenS) runout.enabled = parser.value_bool(); - #if HAS_FILAMENT_RUNOUT_DISTANCE - if (parser.seen('D')) runout.set_runout_distance(parser.value_linear_units()); - #endif + if (seenS) runout.enabled[tool] = parser.value_bool(); + if (parser.seen('D')) runout.set_runout_distance(parser.value_linear_units(), tool); + if (parser.seen('L')) runout.set_runout_distance(parser.value_linear_units(), tool); + if (parser.seen('P')) { + uint8_t tmp_mode = parser.value_int(); + if(tmp_mode > 3 || tmp_mode==7) { + runout.mode[tool] = tmp_mode; + runout.reset(); + } + } + } else { SERIAL_ECHO_START(); SERIAL_ECHOPGM("Filament runout "); - serialprint_onoff(runout.enabled); - #if HAS_FILAMENT_RUNOUT_DISTANCE - SERIAL_ECHOPGM(" ; Distance ", runout.runout_distance(), "mm"); - #endif + serialprint_onoff(runout.enabled[active_extruder]); + SERIAL_ECHOPGM(" ; Distance ", runout.runout_distance(active_extruder), "mm"); + SERIAL_ECHOPGM(" ; Mode ", runout.mode[active_extruder]); #if ENABLED(HOST_ACTION_COMMANDS) SERIAL_ECHOPGM(" ; Host handling "); serialprint_onoff(runout.host_handling); @@ -66,16 +91,17 @@ void GcodeSuite::M412() { } } -void GcodeSuite::M412_report(const bool forReplay/*=true*/) { +void GcodeSuite::M591_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_FILAMENT_RUNOUT_SENSOR)); - SERIAL_ECHOPGM( - " M412 S", runout.enabled - #if HAS_FILAMENT_RUNOUT_DISTANCE - , " D", LINEAR_UNIT(runout.runout_distance()) - #endif - , " ; Sensor " - ); - serialprintln_onoff(runout.enabled); + LOOP_S_L_N(e, 1, HOTENDS) + SERIAL_ECHOPGM( + " M591 E", e + , " S", runout.enabled[e] + , " D", LINEAR_UNIT(runout.runout_distance(e)) + , " P", runout.mode[e] + , " ; " + ); + } #endif // HAS_FILAMENT_SENSOR diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index c365f8a67b..a31341d036 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -822,10 +822,6 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 407: M407(); break; // M407: Display measured filament diameter #endif - #if HAS_FILAMENT_SENSOR - case 412: M412(); break; // M412: Enable/Disable filament runout detection - #endif - #if HAS_MULTI_LANGUAGE case 414: M414(); break; // M414: Select multi language menu #endif @@ -892,6 +888,11 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 575: M575(); break; // M575: Set serial baudrate #endif + #if HAS_FILAMENT_SENSOR + case 412: M412(); break; // Alias to M591 + case 591: M591(); break; // M591 Configure filament runout detection + #endif + #if ENABLED(ADVANCED_PAUSE_FEATURE) case 600: M600(); break; // M600: Pause for Filament Change case 603: M603(); break; // M603: Configure Filament Change diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 6e331c1273..46f4a5ddce 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -230,7 +230,6 @@ * M406 - Disable Filament Sensor flow control. (Requires FILAMENT_WIDTH_SENSOR) * M407 - Display measured filament diameter in millimeters. (Requires FILAMENT_WIDTH_SENSOR) * M410 - Quickstop. Abort all planned moves. - * M412 - Enable / Disable Filament Runout Detection. (Requires FILAMENT_RUNOUT_SENSOR) * M413 - Enable / Disable Power-Loss Recovery. (Requires POWER_LOSS_RECOVERY) * M414 - Set language by index. (Requires LCD_LANGUAGE_2...) * M420 - Enable/Disable Leveling (with current values) S1=enable S0=disable (Requires MESH_BED_LEVELING or ABL) @@ -255,6 +254,7 @@ * M554 - Get or set IP gateway. (Requires enabled Ethernet port) * M569 - Enable stealthChop on an axis. (Requires at least one _DRIVER_TYPE to be TMC2130/2160/2208/2209/5130/5160) * M575 - Change the serial baud rate. (Requires BAUD_RATE_GCODE) + * M591 - Configure Filament Runout Detection. (Requires FILAMENT_RUNOUT_SENSOR) * M600 - Pause for filament change: "M600 X Y Z E L". (Requires ADVANCED_PAUSE_FEATURE) * M603 - Configure filament change: "M603 T U L". (Requires ADVANCED_PAUSE_FEATURE) * M605 - Set Dual X-Carriage movement mode: "M605 S [X] [R]". (Requires DUAL_X_CARRIAGE) @@ -979,7 +979,8 @@ private: #if HAS_FILAMENT_SENSOR static void M412(); - static void M412_report(const bool forReplay=true); + static void M591(); + static void M591_report(const bool forReplay=true); #endif #if HAS_MULTI_LANGUAGE diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 36731c23da..50ff834d11 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -111,7 +111,7 @@ void GcodeSuite::M115() { // AUTOLEVEL (G29) cap_line(F("AUTOLEVEL"), ENABLED(HAS_AUTOLEVEL)); - // RUNOUT (M412, M600) + // RUNOUT (M591, M600) cap_line(F("RUNOUT"), ENABLED(FILAMENT_RUNOUT_SENSOR)); // Z_PROBE (G30) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index d63395a719..f0999df41f 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -548,9 +548,6 @@ #if NUM_RUNOUT_SENSORS > 1 #define MULTI_FILAMENT_SENSOR 1 #endif - #ifdef FILAMENT_RUNOUT_DISTANCE_MM - #define HAS_FILAMENT_RUNOUT_DISTANCE 1 - #endif #if ENABLED(MIXING_EXTRUDER) #define WATCH_ALL_RUNOUT_SENSORS #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index a94846275e..78117dc482 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1000,8 +1000,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "You can't enable FIL_RUNOUT7_PULLUP and FIL_RUNOUT7_PULLDOWN at the same time." #elif BOTH(FIL_RUNOUT8_PULLUP, FIL_RUNOUT8_PULLDOWN) #error "You can't enable FIL_RUNOUT8_PULLUP and FIL_RUNOUT8_PULLDOWN at the same time." - #elif FILAMENT_RUNOUT_DISTANCE_MM < 0 - #error "FILAMENT_RUNOUT_DISTANCE_MM must be greater than or equal to zero." #elif DISABLED(ADVANCED_PAUSE_FEATURE) static_assert(nullptr == strstr(FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with FILAMENT_RUNOUT_SENSOR."); #endif @@ -1238,8 +1236,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "MIXING_EXTRUDER is incompatible with SINGLENOZZLE." #elif ENABLED(DISABLE_INACTIVE_EXTRUDER) #error "MIXING_EXTRUDER is incompatible with DISABLE_INACTIVE_EXTRUDER." - #elif HAS_FILAMENT_RUNOUT_DISTANCE - #error "MIXING_EXTRUDER is incompatible with FILAMENT_RUNOUT_DISTANCE_MM." #endif #endif diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index d384bae3e3..1e70a0656c 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -2833,7 +2833,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define ADVANCED_UNLOAD (ADVANCED_LOAD + ENABLED(ADVANCED_PAUSE_FEATURE)) #define ADVANCED_COLD_EXTRUDE (ADVANCED_UNLOAD + ENABLED(PREVENT_COLD_EXTRUSION)) #define ADVANCED_FILSENSORENABLED (ADVANCED_COLD_EXTRUDE + ENABLED(FILAMENT_RUNOUT_SENSOR)) - #define ADVANCED_FILSENSORDISTANCE (ADVANCED_FILSENSORENABLED + ENABLED(HAS_FILAMENT_RUNOUT_DISTANCE)) + #define ADVANCED_FILSENSORDISTANCE (ADVANCED_FILSENSORENABLED + 1) #define ADVANCED_POWER_LOSS (ADVANCED_FILSENSORDISTANCE + ENABLED(POWER_LOSS_RECOVERY)) #define ADVANCED_TOTAL ADVANCED_POWER_LOSS @@ -2923,24 +2923,22 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case ADVANCED_FILSENSORENABLED: if (draw) { Draw_Menu_Item(row, ICON_Extruder, F("Filament Sensor")); - Draw_Checkbox(row, runout.enabled); + Draw_Checkbox(row, runout.enabled[0]); } else { - runout.enabled = !runout.enabled; - Draw_Checkbox(row, runout.enabled); + runout.enabled = !runout.enabled[0]; + Draw_Checkbox(row, runout.enabled[0]); } break; - #if ENABLED(HAS_FILAMENT_RUNOUT_DISTANCE) - case ADVANCED_FILSENSORDISTANCE: - if (draw) { - Draw_Menu_Item(row, ICON_MaxAccE, F("Runout Distance")); - Draw_Float(runout.runout_distance(), row, false, 10); - } - else - Modify_Value(runout.runout_distance(), 0, 999, 10); - break; - #endif + case ADVANCED_FILSENSORDISTANCE: + if (draw) { + Draw_Menu_Item(row, ICON_MaxAccE, F("Runout Distance")); + Draw_Float(runout.runout_distance(), row, false, 10); + } + else + Modify_Value(runout.runout_distance(), 0, 999, 10); + break; #endif // FILAMENT_RUNOUT_SENSOR #if ENABLED(POWER_LOSS_RECOVERY) @@ -3829,11 +3827,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case TUNE_FILSENSORENABLED: if (draw) { Draw_Menu_Item(row, ICON_Extruder, F("Filament Sensor")); - Draw_Checkbox(row, runout.enabled); + Draw_Checkbox(row, runout.enabled[0]); } else { - runout.enabled = !runout.enabled; - Draw_Checkbox(row, runout.enabled); + runout.enabled = !runout.enabled[0]; + Draw_Checkbox(row, runout.enabled[0]); } break; #endif diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 0a392cd563..93302406d4 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -2157,14 +2157,12 @@ void SetPID(celsius_t t, heater_id_t h) { #if HAS_FILAMENT_SENSOR void SetRunoutEnable() { runout.reset(); - runout.enabled = !runout.enabled; - Draw_Chkb_Line(CurrentMenu->line(), runout.enabled); + runout.enabled[0] = !runout.enabled[0]; + Draw_Chkb_Line(CurrentMenu->line(), runout.enabled[0]); DWIN_UpdateLCD(); } - #if HAS_FILAMENT_RUNOUT_DISTANCE - void ApplyRunoutDistance() { runout.set_runout_distance(MenuData.Value / MINUNITMULT); } - void SetRunoutDistance() { SetFloatOnClick(0, 999, UNITFDIGITS, runout.runout_distance(), ApplyRunoutDistance); } - #endif + void ApplyRunoutDistance() { runout.set_runout_distance(MenuData.Value / MINUNITMULT); } + void SetRunoutDistance() { SetFloatOnClick(0, 999, UNITFDIGITS, runout.runout_distance(), ApplyRunoutDistance); } #endif #if ENABLED(ADVANCED_PAUSE_FEATURE) @@ -2679,7 +2677,7 @@ void onDrawGetColorItem(MenuItemClass* menuitem, int8_t line) { } #if HAS_FILAMENT_SENSOR - void onDrawRunoutEnable(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, runout.enabled); } + void onDrawRunoutEnable(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, runout.enabled[0]); } #endif void onDrawPIDi(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_i(*(float*)static_cast(menuitem)->value)); } @@ -3173,9 +3171,7 @@ void Draw_Move_Menu() { #if HAS_FILAMENT_SENSOR MENU_ITEM(ICON_Runout, GET_TEXT_F(MSG_RUNOUT_ENABLE), onDrawRunoutEnable, SetRunoutEnable); #endif - #if HAS_FILAMENT_RUNOUT_DISTANCE - EDIT_ITEM(ICON_Runout, F("Runout Distance"), onDrawPFloatMenu, SetRunoutDistance, &runout.runout_distance()); - #endif + EDIT_ITEM(ICON_Runout, F("Runout Distance"), onDrawPFloatMenu, SetRunoutDistance, &runout.runout_distance()); #if ENABLED(PREVENT_COLD_EXTRUSION) EDIT_ITEM(ICON_ExtrudeMinT, F("Extrude Min Temp."), onDrawPIntMenu, SetExtMinT, &HMI_data.ExtMinT); #endif diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index 74eb94e751..ab42b2f1d8 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -100,7 +100,7 @@ void ESDiagClass::Update() { ES_REPORT(Z_MIN); #endif #if HAS_FILAMENT_SENSOR - draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE); + draw_es_state(READ(FIL_RUNOUT1_PIN) != (runout.mode[0]==2 ? HIGH, LOW); #endif DWIN_UpdateLCD(); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_runout_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_runout_screen.cpp index 68948b0c5e..a885d69cf5 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_runout_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_runout_screen.cpp @@ -34,14 +34,13 @@ void FilamentRunoutScreen::onRedraw(draw_mode_t what) { w.heading( GET_TEXT_F(MSG_FILAMENT)); w.toggle( 2, GET_TEXT_F(MSG_RUNOUT_SENSOR), getFilamentRunoutEnabled()); - #if HAS_FILAMENT_RUNOUT_DISTANCE - w.heading(GET_TEXT_F(MSG_RUNOUT_DISTANCE_MM)); - w.units(GET_TEXT_F(MSG_UNITS_MM)); - w.precision(0); - w.color(e_axis); - w.adjuster( 10, FPSTR(NUL_STR), getFilamentRunoutDistance_mm(), getFilamentRunoutEnabled()); - w.increments(); - #endif + w.heading(GET_TEXT_F(MSG_RUNOUT_DISTANCE_MM)); + w.units(GET_TEXT_F(MSG_UNITS_MM)); + w.precision(0); + w.color(e_axis); + w.adjuster( 10, FPSTR(NUL_STR), getFilamentRunoutDistance_mm(), getFilamentRunoutEnabled()); + w.increments(); + } bool FilamentRunoutScreen::onTouchHeld(uint8_t tag) { @@ -49,10 +48,8 @@ bool FilamentRunoutScreen::onTouchHeld(uint8_t tag) { const float increment = getIncrement(); switch (tag) { case 2: setFilamentRunoutEnabled(!getFilamentRunoutEnabled()); break; - #if HAS_FILAMENT_RUNOUT_DISTANCE - case 10: UI_DECREMENT(FilamentRunoutDistance_mm); break; - case 11: UI_INCREMENT(FilamentRunoutDistance_mm); break; - #endif + case 10: UI_DECREMENT(FilamentRunoutDistance_mm); break; + case 11: UI_INCREMENT(FilamentRunoutDistance_mm); break; default: return false; } diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index bfcbc39d7b..9656e86f97 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -651,15 +651,12 @@ namespace ExtUI { } #if HAS_FILAMENT_SENSOR - bool getFilamentRunoutEnabled() { return runout.enabled; } - void setFilamentRunoutEnabled(const bool value) { runout.enabled = value; } + bool getFilamentRunoutEnabled(const extruder_t extruder/*=E0*/) { return runout.enabled[extruder]; } + void setFilamentRunoutEnabled(const bool value, const extruder_t extruder/*=E0*/) { runout.enabled[extruder] = value; } bool getFilamentRunoutState() { return runout.filament_ran_out; } void setFilamentRunoutState(const bool value) { runout.filament_ran_out = value; } - - #if HAS_FILAMENT_RUNOUT_DISTANCE - float getFilamentRunoutDistance_mm() { return runout.runout_distance(); } - void setFilamentRunoutDistance_mm(const_float_t value) { runout.set_runout_distance(constrain(value, 0, 999)); } - #endif + float getFilamentRunoutDistance_mm() { return runout.runout_distance(); } + void setFilamentRunoutDistance_mm(const_float_t value) { runout.set_runout_distance(constrain(value, 0, 999)); } #endif #if ENABLED(CASE_LIGHT_ENABLE) diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 6753c53740..3d87d0208e 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -294,15 +294,13 @@ namespace ExtUI { #endif #if HAS_FILAMENT_SENSOR - bool getFilamentRunoutEnabled(); - void setFilamentRunoutEnabled(const bool); + bool getFilamentRunoutEnabled(const extruder_t extruder=E0); + void setFilamentRunoutEnabled(const bool, const extruder_t extruder=E0); bool getFilamentRunoutState(); void setFilamentRunoutState(const bool); + float getFilamentRunoutDistance_mm(); + void setFilamentRunoutDistance_mm(const_float_t); - #if HAS_FILAMENT_RUNOUT_DISTANCE - float getFilamentRunoutDistance_mm(); - void setFilamentRunoutDistance_mm(const_float_t); - #endif #endif #if ENABLED(CASE_LIGHT_ENABLE) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 1bc9b9e88e..77728201c5 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -43,7 +43,7 @@ #include "../../module/temperature.h" #endif -#if HAS_FILAMENT_RUNOUT_DISTANCE +#if HAS_FILAMENT_SENSOR #include "../../feature/runout.h" #endif @@ -150,7 +150,7 @@ void menu_backlash(); #endif #endif - #if HAS_FILAMENT_RUNOUT_DISTANCE + #if HAS_FILAMENT_SENSOR editable.decimal = runout.runout_distance(); EDIT_ITEM_FAST(float3, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, []{ runout.set_runout_distance(editable.decimal); }, true diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index b4e9287bd4..9c4164f7b6 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -550,7 +550,7 @@ void menu_configuration() { #endif #if HAS_FILAMENT_SENSOR - EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled, runout.reset); + EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled[active_extruder], runout.reset); #endif #if HAS_FANCHECK diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index 9f432c405c..98278e7a6e 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -254,7 +254,7 @@ void menu_pause_option() { #if HAS_FILAMENT_SENSOR const bool still_out = runout.filament_ran_out; if (still_out) - EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled, runout.reset); + EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled[active_extruder], runout.reset); #else constexpr bool still_out = false; #endif diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 3dd6d8aeb6..57476d89f6 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -47,6 +47,10 @@ #include "../feature/joystick.h" #endif +#if HAS_FILAMENT_SENSOR + #include "../feature/runout.h" +#endif + #if HAS_BED_PROBE #include "probe.h" #endif @@ -570,8 +574,8 @@ void _O2 Endstops::report_states() { #if USES_Z_MIN_PROBE_PIN print_es_state(PROBE_TRIGGERED(), F(STR_Z_PROBE)); #endif - #if MULTI_FILAMENT_SENSOR - #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; state = FIL_RUNOUT##N##_STATE; break; + #if HAS_FILAMENT_SENSOR + #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break; LOOP_S_LE_N(i, 1, NUM_RUNOUT_SENSORS) { pin_t pin; uint8_t state; @@ -579,13 +583,23 @@ void _O2 Endstops::report_states() { default: continue; REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) } + if(runout.mode[i]==1) + state = HIGH; + else + state = LOW; + SERIAL_ECHOPGM(STR_FILAMENT); if (i > 1) SERIAL_CHAR(' ', '0' + i); print_es_state(extDigitalRead(pin) != state); + SERIAL_ECHOPGM(": "); + if(runout.mode[i]==0) + SERIAL_ECHOLNF(F("Sensor Disabled")); + else if(extDigitalRead(pin) != state) + SERIAL_ECHOLNF(F("Fil Present")); + else + SERIAL_ECHOLNF(F("Fil Missing")); } #undef _CASE_RUNOUT - #elif HAS_FILAMENT_SENSOR - print_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE, F(STR_FILAMENT)); #endif TERN_(BLTOUCH, bltouch._reset_SW_mode()); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 6eb17d5d2e..1dccdb905e 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -235,8 +235,9 @@ typedef struct SettingsDataStruct { // // FILAMENT_RUNOUT_SENSOR // - bool runout_sensor_enabled; // M412 S - float runout_distance_mm; // M412 D + bool runout_sensor_enabled[HOTENDS]; // M591 S + float runout_distance_mm[HOTENDS]; // M591 D + uint8_t runout_mode[HOTENDS]; // M591 P // // ENABLE_LEVELING_FADE_HEIGHT @@ -793,19 +794,20 @@ void MarlinSettings::postprocess() { // { #if HAS_FILAMENT_SENSOR - const bool &runout_sensor_enabled = runout.enabled; + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_WRITE(runout.enabled[e]); + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_WRITE(runout.runout_distance(e)); + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_WRITE(runout.mode[e]); #else - constexpr int8_t runout_sensor_enabled = -1; + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_WRITE((int8_t)-1)); + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_WRITE((float)-0.0f)); + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_WRITE((uint8_t)0)); #endif - _FIELD_TEST(runout_sensor_enabled); - EEPROM_WRITE(runout_sensor_enabled); - - #if HAS_FILAMENT_RUNOUT_DISTANCE - const float &runout_distance_mm = runout.runout_distance(); - #else - constexpr float runout_distance_mm = 0; - #endif - EEPROM_WRITE(runout_distance_mm); } // @@ -1711,20 +1713,27 @@ void MarlinSettings::postprocess() { // Filament Runout Sensor // { - int8_t runout_sensor_enabled; + int8_t runout_sensor_enabled[HOTENDS]; _FIELD_TEST(runout_sensor_enabled); - EEPROM_READ(runout_sensor_enabled); + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_READ(runout_sensor_enabled); + float runout_distance_mm[HOTENDS]; + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_READ(runout_distance_mm[e]); + uint8_t runout_mode[HOTENDS]; + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_READ(runout_mode[e]); + #if HAS_FILAMENT_SENSOR - runout.enabled = runout_sensor_enabled < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled; + LOOP_S_L_N(e, 1, HOTENDS) + runout.enabled[e] = runout_sensor_enabled[e] < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled[e]; + LOOP_S_L_N(e, 1, HOTENDS) + if (!validating) runout.set_runout_distance(runout_distance_mm[e], e); + LOOP_S_L_N(e, 1, HOTENDS) + if (!validating) runout.mode[e] = runout_mode[e]; + runout.reset(); #endif - TERN_(HAS_FILAMENT_SENSOR, if (runout.enabled) runout.reset()); - - float runout_distance_mm; - EEPROM_READ(runout_distance_mm); - #if HAS_FILAMENT_RUNOUT_DISTANCE - if (!validating) runout.set_runout_distance(runout_distance_mm); - #endif } // @@ -2789,9 +2798,14 @@ void MarlinSettings::reset() { // #if HAS_FILAMENT_SENSOR - runout.enabled = FIL_RUNOUT_ENABLED_DEFAULT; + LOOP_S_L_N(e, 1, HOTENDS) + runout.enabled[e] = FIL_RUNOUT_ENABLED_DEFAULT; + LOOP_S_L_N(e, 1, HOTENDS) + runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM, e); + LOOP_S_L_N(e, 1, HOTENDS) + runout.mode[e] = FILAMENT_RUNOUT_DEFAULT_MODE; + runout.reset(); - TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM)); #endif // @@ -3481,7 +3495,7 @@ void MarlinSettings::reset() { // // Filament Runout Sensor // - TERN_(HAS_FILAMENT_SENSOR, gcode.M412_report(forReplay)); + TERN_(HAS_FILAMENT_SENSOR, gcode.M591_report(forReplay)); #if HAS_ETHERNET CONFIG_ECHO_HEADING("Ethernet"); diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index f83104fe9c..46a17b6591 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -113,7 +113,7 @@ Stepper stepper; // Singleton #include "../feature/mixing.h" #endif -#if HAS_FILAMENT_RUNOUT_DISTANCE +#if HAS_FILAMENT_SENSOR #include "../feature/runout.h" #endif @@ -1948,7 +1948,7 @@ uint32_t Stepper::block_phase_isr() { PAGE_SEGMENT_UPDATE_POS(E); } #endif - TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, runout.block_completed(current_block)); + TERN_(HAS_FILAMENT_SENSOR, runout.block_completed(current_block)); discard_current_block(); } else { From 91a094d8cb0f35c20f07cf862771ece427ca4754 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 12 Mar 2022 15:55:57 -0500 Subject: [PATCH 40/58] Update Configuration.h --- Marlin/Configuration.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index c2d5dced28..87fab7852b 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1469,6 +1469,7 @@ #define FIL_RUNOUT_ENABLED_DEFAULT true // Enable the sensor on startup. Override with M412 followed by M500. #define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each. + #define FILAMENT_RUNOUT_DEFAULT_MODE {1} // Array set that will take the place of FIL_RUNOUT_STATE and FIL_RUNOUT_ENABLED_DEFAULT as this code matures #define FIL_RUNOUT_STATE LOW // Pin state indicating that filament is NOT present. #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. @@ -1510,13 +1511,13 @@ // Commands to execute on filament runout. // With multiple runout sensors use the %c placeholder for the current tool in commands (e.g., "M600 T%c") - // NOTE: After 'M412 H1' the host handles filament runout and this script does not apply. + // NOTE: After 'M591 H1' the host handles filament runout and this script does not apply. #define FILAMENT_RUNOUT_SCRIPT "M600" // After a runout is detected, continue printing this length of filament // before executing the runout script. Useful for a sensor at the end of // a feed tube. Requires 4 bytes SRAM per sensor, plus 4 bytes overhead. - //#define FILAMENT_RUNOUT_DISTANCE_MM 25 + //#define FILAMENT_RUNOUT_DISTANCE_MM {25} #ifdef FILAMENT_RUNOUT_DISTANCE_MM // Enable this option to use an encoder disc that toggles the runout pin From 639a2dc0b3cd46e236e531c799331ac3fade40d1 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 13 Mar 2022 13:48:18 -0400 Subject: [PATCH 41/58] M591 Cleanup and tweaks --- Marlin/src/gcode/feature/runout/M591.cpp | 2 +- Marlin/src/module/endstops.cpp | 15 ++++++----- Marlin/src/module/settings.cpp | 32 ++++++++++++------------ 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Marlin/src/gcode/feature/runout/M591.cpp b/Marlin/src/gcode/feature/runout/M591.cpp index e80252677a..e4a7e5b59d 100644 --- a/Marlin/src/gcode/feature/runout/M591.cpp +++ b/Marlin/src/gcode/feature/runout/M591.cpp @@ -70,7 +70,7 @@ void GcodeSuite::M591() { if (parser.seen('L')) runout.set_runout_distance(parser.value_linear_units(), tool); if (parser.seen('P')) { uint8_t tmp_mode = parser.value_int(); - if(tmp_mode > 3 || tmp_mode==7) { + if(tmp_mode < 3 || tmp_mode==7) { runout.mode[tool] = tmp_mode; runout.reset(); } diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 57476d89f6..4fae1d4ad2 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -583,21 +583,24 @@ void _O2 Endstops::report_states() { default: continue; REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) } - if(runout.mode[i]==1) + if(runout.mode[i-1]==1) state = HIGH; else state = LOW; SERIAL_ECHOPGM(STR_FILAMENT); if (i > 1) SERIAL_CHAR(' ', '0' + i); - print_es_state(extDigitalRead(pin) != state); SERIAL_ECHOPGM(": "); - if(runout.mode[i]==0) - SERIAL_ECHOLNF(F("Sensor Disabled")); + if(runout.mode[i-1]==0) + SERIAL_ECHOLNF(F("DISABLED")); + else if(runout.mode[i-1]==7) { + SERIAL_ECHOF(F("MOTION : ")); + print_es_state(extDigitalRead(pin) != state); + } else if(extDigitalRead(pin) != state) - SERIAL_ECHOLNF(F("Fil Present")); + SERIAL_ECHOLNF(F("PRESENT")); else - SERIAL_ECHOLNF(F("Fil Missing")); + SERIAL_ECHOLNF(F("MISSING")); } #undef _CASE_RUNOUT #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 1dccdb905e..20f480faa2 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -36,7 +36,7 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V86" +#define EEPROM_VERSION "V87" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -794,18 +794,18 @@ void MarlinSettings::postprocess() { // { #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE(runout.enabled[e]); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE(runout.runout_distance(e)); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE(runout.mode[e]); #else - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE((int8_t)-1)); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE((float)-0.0f)); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE((uint8_t)0)); #endif } @@ -1715,21 +1715,21 @@ void MarlinSettings::postprocess() { { int8_t runout_sensor_enabled[HOTENDS]; _FIELD_TEST(runout_sensor_enabled); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_READ(runout_sensor_enabled); float runout_distance_mm[HOTENDS]; - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_READ(runout_distance_mm[e]); uint8_t runout_mode[HOTENDS]; - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_READ(runout_mode[e]); #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) runout.enabled[e] = runout_sensor_enabled[e] < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled[e]; - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) if (!validating) runout.set_runout_distance(runout_distance_mm[e], e); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) if (!validating) runout.mode[e] = runout_mode[e]; runout.reset(); #endif @@ -2798,11 +2798,11 @@ void MarlinSettings::reset() { // #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) runout.enabled[e] = FIL_RUNOUT_ENABLED_DEFAULT; - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM, e); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) runout.mode[e] = FILAMENT_RUNOUT_DEFAULT_MODE; runout.reset(); From 0c15e8e751e23774d61f031ce97051f48b2dcf92 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 13 Mar 2022 18:57:24 -0400 Subject: [PATCH 42/58] Fix up pause trigger, adjust config options minor changes --- Marlin/Configuration.h | 14 +------ Marlin/src/feature/pause.cpp | 28 ++++++++++--- Marlin/src/feature/runout.cpp | 8 ++-- Marlin/src/feature/runout.h | 6 +-- Marlin/src/inc/Conditionals_LCD.h | 36 ++++++---------- Marlin/src/inc/Conditionals_adv.h | 10 ----- Marlin/src/inc/SanityCheck.h | 13 +++++- .../lcd/extui/anycubic_chiron/chiron_tft.cpp | 3 -- Marlin/src/module/settings.cpp | 42 +++++++++---------- 9 files changed, 76 insertions(+), 84 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 87fab7852b..865a975b2e 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1466,46 +1466,36 @@ */ //#define FILAMENT_RUNOUT_SENSOR #if ENABLED(FILAMENT_RUNOUT_SENSOR) - #define FIL_RUNOUT_ENABLED_DEFAULT true // Enable the sensor on startup. Override with M412 followed by M500. - #define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each. + #define FIL_RUNOUT_ENABLED_DEFAULT { true } // Default state for sensors E0, E1[, E2, E3] // Enable the sensor on startup. Override with M591 followed by M500. #define FILAMENT_RUNOUT_DEFAULT_MODE {1} // Array set that will take the place of FIL_RUNOUT_STATE and FIL_RUNOUT_ENABLED_DEFAULT as this code matures - #define FIL_RUNOUT_STATE LOW // Pin state indicating that filament is NOT present. #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. //#define WATCH_ALL_RUNOUT_SENSORS // Execute runout script on any triggering sensor, not only for the active extruder. // This is automatically enabled for MIXING_EXTRUDERs. // Override individually if the runout sensors vary - //#define FIL_RUNOUT1_STATE LOW //#define FIL_RUNOUT1_PULLUP //#define FIL_RUNOUT1_PULLDOWN - //#define FIL_RUNOUT2_STATE LOW //#define FIL_RUNOUT2_PULLUP //#define FIL_RUNOUT2_PULLDOWN - //#define FIL_RUNOUT3_STATE LOW //#define FIL_RUNOUT3_PULLUP //#define FIL_RUNOUT3_PULLDOWN - //#define FIL_RUNOUT4_STATE LOW //#define FIL_RUNOUT4_PULLUP //#define FIL_RUNOUT4_PULLDOWN - //#define FIL_RUNOUT5_STATE LOW //#define FIL_RUNOUT5_PULLUP //#define FIL_RUNOUT5_PULLDOWN - //#define FIL_RUNOUT6_STATE LOW //#define FIL_RUNOUT6_PULLUP //#define FIL_RUNOUT6_PULLDOWN - //#define FIL_RUNOUT7_STATE LOW //#define FIL_RUNOUT7_PULLUP //#define FIL_RUNOUT7_PULLDOWN - //#define FIL_RUNOUT8_STATE LOW //#define FIL_RUNOUT8_PULLUP //#define FIL_RUNOUT8_PULLDOWN @@ -1517,7 +1507,7 @@ // After a runout is detected, continue printing this length of filament // before executing the runout script. Useful for a sensor at the end of // a feed tube. Requires 4 bytes SRAM per sensor, plus 4 bytes overhead. - //#define FILAMENT_RUNOUT_DISTANCE_MM {25} + #define FILAMENT_RUNOUT_DISTANCE_MM {15} #ifdef FILAMENT_RUNOUT_DISTANCE_MM // Enable this option to use an encoder disc that toggles the runout pin diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 636ac32042..7333613c83 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -209,12 +209,30 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load impatient_beep(max_beep_count); #if BOTH(FILAMENT_CHANGE_RESUME_ON_INSERT, FILAMENT_RUNOUT_SENSOR) #if ENABLED(MULTI_FILAMENT_SENSOR) - #define _CASE_INSERTED(N) case N-1: if (READ(FIL_RUNOUT##N##_PIN) != FIL_RUNOUT##N##_STATE) wait_for_user = false; break; - switch (active_extruder) { - REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_INSERTED) + #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break; + LOOP_S_LE_N(i, 1, NUM_RUNOUT_SENSORS) { + pin_t pin; + uint8_t state; + switch (i) { + default: continue; + REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) + } + if(runout.mode[i-1]==1) + state = HIGH; + else + state = LOW; + if(runout.mode[i-1]!=0 && runout.mode[i-1]!=7 && extDigitalRead(pin) != state) + wait_for_user = false; } - #else - if (READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_STATE) wait_for_user = false; + #undef _CASE_RUNOUT + #else { + uint8_t state; + if(runout.mode[active_extruder]==1) + state = HIGH; + else + state = LOW; + if (READ(FIL_RUNOUT_PIN) != state) wait_for_user = false; + } #endif #endif idle_no_sleep(); diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 7791637699..332890c0ef 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -32,9 +32,9 @@ FilamentMonitor runout; -bool FilamentMonitorBase::enabled[HOTENDS] = {true}, +bool FilamentMonitorBase::enabled[NUM_RUNOUT_SENSORS] = {true}, FilamentMonitorBase::filament_ran_out; // = false -uint8_t FilamentMonitorBase::mode[HOTENDS] = FILAMENT_RUNOUT_DEFAULT_MODE; // Initialized by settings.load +uint8_t FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS] = FILAMENT_RUNOUT_DEFAULT_MODE; // Initialized by settings.load #if ENABLED(HOST_ACTION_COMMANDS) bool FilamentMonitorBase::host_handling; // = false #endif @@ -46,8 +46,8 @@ uint8_t FilamentMonitorBase::mode[HOTENDS] = FILAMENT_RUNOUT_DEFAULT_MODE; // In #endif -float RunoutResponseDelayed::runout_distance_mm[HOTENDS] = FILAMENT_RUNOUT_DISTANCE_MM; -volatile float RunoutResponseDelayed::runout_mm_countdown[HOTENDS]; +float RunoutResponseDelayed::runout_distance_mm[NUM_RUNOUT_SENSORS] = FILAMENT_RUNOUT_DISTANCE_MM; +volatile float RunoutResponseDelayed::runout_mm_countdown[NUM_RUNOUT_SENSORS]; uint8_t FilamentSensorCore::motion_detected; diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 2844264481..7867809232 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -63,8 +63,8 @@ extern FilamentMonitor runout; class FilamentMonitorBase { public: - static bool enabled[HOTENDS], filament_ran_out; - static uint8_t mode[HOTENDS]; + static bool enabled[NUM_RUNOUT_SENSORS], filament_ran_out; + static uint8_t mode[NUM_RUNOUT_SENSORS]; #if ENABLED(HOST_ACTION_COMMANDS) static bool host_handling; @@ -319,7 +319,7 @@ class FilamentSensorBase { static volatile float runout_mm_countdown[NUM_RUNOUT_SENSORS]; public: - static float runout_distance_mm[HOTENDS]; + static float runout_distance_mm[NUM_RUNOUT_SENSORS]; static void reset() { LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 33d9e46220..e2b643ae73 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -832,11 +832,11 @@ /** * Fill in undefined Filament Sensor options */ +#ifndef NUM_RUNOUT_SENSORS + #define NUM_RUNOUT_SENSORS E_STEPPERS +#endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) #if NUM_RUNOUT_SENSORS >= 1 - #ifndef FIL_RUNOUT1_STATE - #define FIL_RUNOUT1_STATE FIL_RUNOUT_STATE - #endif #ifndef FIL_RUNOUT1_PULLUP #define FIL_RUNOUT1_PULLUP FIL_RUNOUT_PULLUP #endif @@ -845,9 +845,6 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 2 - #ifndef FIL_RUNOUT2_STATE - #define FIL_RUNOUT2_STATE FIL_RUNOUT_STATE - #endif #ifndef FIL_RUNOUT2_PULLUP #define FIL_RUNOUT2_PULLUP FIL_RUNOUT_PULLUP #endif @@ -856,9 +853,6 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 3 - #ifndef FIL_RUNOUT3_STATE - #define FIL_RUNOUT3_STATE FIL_RUNOUT_STATE - #endif #ifndef FIL_RUNOUT3_PULLUP #define FIL_RUNOUT3_PULLUP FIL_RUNOUT_PULLUP #endif @@ -867,9 +861,6 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 4 - #ifndef FIL_RUNOUT4_STATE - #define FIL_RUNOUT4_STATE FIL_RUNOUT_STATE - #endif #ifndef FIL_RUNOUT4_PULLUP #define FIL_RUNOUT4_PULLUP FIL_RUNOUT_PULLUP #endif @@ -878,9 +869,6 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 5 - #ifndef FIL_RUNOUT5_STATE - #define FIL_RUNOUT5_STATE FIL_RUNOUT_STATE - #endif #ifndef FIL_RUNOUT5_PULLUP #define FIL_RUNOUT5_PULLUP FIL_RUNOUT_PULLUP #endif @@ -889,9 +877,6 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 6 - #ifndef FIL_RUNOUT6_STATE - #define FIL_RUNOUT6_STATE FIL_RUNOUT_STATE - #endif #ifndef FIL_RUNOUT6_PULLUP #define FIL_RUNOUT6_PULLUP FIL_RUNOUT_PULLUP #endif @@ -900,9 +885,7 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 7 - #ifndef FIL_RUNOUT7_STATE - #define FIL_RUNOUT7_STATE FIL_RUNOUT_STATE - #endif + #ifndef FIL_RUNOUT7_PULLUP #define FIL_RUNOUT7_PULLUP FIL_RUNOUT_PULLUP #endif @@ -911,9 +894,6 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 8 - #ifndef FIL_RUNOUT8_STATE - #define FIL_RUNOUT8_STATE FIL_RUNOUT_STATE - #endif #ifndef FIL_RUNOUT8_PULLUP #define FIL_RUNOUT8_PULLUP FIL_RUNOUT_PULLUP #endif @@ -921,6 +901,14 @@ #define FIL_RUNOUT8_PULLDOWN FIL_RUNOUT_PULLDOWN #endif #endif + + #define HAS_FILAMENT_SENSOR 1 + #if NUM_RUNOUT_SENSORS > 1 + #define MULTI_FILAMENT_SENSOR 1 + #endif + #if ENABLED(MIXING_EXTRUDER) + #define WATCH_ALL_RUNOUT_SENSORS + #endif #endif // FILAMENT_RUNOUT_SENSOR // Homing to Min or Max diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index f0999df41f..d0004658ce 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -543,16 +543,6 @@ #define HAS_SERVICE_INTERVALS 1 #endif -#if ENABLED(FILAMENT_RUNOUT_SENSOR) - #define HAS_FILAMENT_SENSOR 1 - #if NUM_RUNOUT_SENSORS > 1 - #define MULTI_FILAMENT_SENSOR 1 - #endif - #if ENABLED(MIXING_EXTRUDER) - #define WATCH_ALL_RUNOUT_SENSORS - #endif -#endif - // Probe Temperature Compensation #if !TEMP_SENSOR_PROBE #undef PTC_PROBE diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 78117dc482..9f7b9fb056 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -561,9 +561,9 @@ #error "SHORT_MANUAL_Z_MOVE is now FINE_MANUAL_MOVE, applying to Z on most printers." #elif defined(FIL_RUNOUT_INVERTING) #if FIL_RUNOUT_INVERTING - #error "FIL_RUNOUT_INVERTING true is now FIL_RUNOUT_STATE HIGH." + #error "FIL_RUNOUT_INVERTING true is now FILAMENT_RUNOUT_DEFAULT_MODE {HIGH}." #else - #error "FIL_RUNOUT_INVERTING false is now FIL_RUNOUT_STATE LOW." + #error "FIL_RUNOUT_INVERTING false is now FILAMENT_RUNOUT_DEFAULT_MODE {LOW}." #endif #elif defined(ASSISTED_TRAMMING_MENU_ITEM) #error "ASSISTED_TRAMMING_MENU_ITEM is deprecated and should be removed." @@ -1002,7 +1002,16 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "You can't enable FIL_RUNOUT8_PULLUP and FIL_RUNOUT8_PULLDOWN at the same time." #elif DISABLED(ADVANCED_PAUSE_FEATURE) static_assert(nullptr == strstr(FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with FILAMENT_RUNOUT_SENSOR."); + #elif ANY(FIL_RUNOUT_STATE, FIL_RUNOUT1_STATE, FIL_RUNOUT2_STATE, FIL_RUNOUT3_STATE, FIL_RUNOUT4_STATE, FIL_RUNOUT5_STATE, FIL_RUNOUT6_STATE, FIL_RUNOUT7_STATE, FIL_RUNOUT8_STATE) + #error "FIL_RUNOUT#_STATE is Now set with FILAMENT_RUNOUT_DEFAULT_MODE" #endif + + constexpr uint8_t frdm[] = FILAMENT_RUNOUT_DEFAULT_MODE; + static_assert(COUNT(frdm) == NUM_RUNOUT_SENSORS, "FILAMENT_RUNOUT_DEFAULT_MODE must have NUM_RUNOUT_SENSORS values."); + constexpr bool fred[] = FIL_RUNOUT_ENABLED_DEFAULT; + static_assert(COUNT(fred) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_ENABLED_DEFAULT must have NUM_RUNOUT_SENSORS values."); + constexpr float frd[] = FILAMENT_RUNOUT_DISTANCE_MM; + static_assert(COUNT(frd) == NUM_RUNOUT_SENSORS, "FILAMENT_RUNOUT_DISTANCE_MM must have NUM_RUNOUT_SENSORS values."); #endif /** diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index c56d8aa7fb..aa5bae62bc 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -80,9 +80,6 @@ void ChironTFT::Startup() { OUT_WRITE(OUTAGECON_PIN, HIGH); #endif - // Filament runout is handled by Marlin settings in Configuration.h - // opt_set FIL_RUNOUT_STATE HIGH // Pin state indicating that filament is NOT present. - // opt_enable FIL_RUNOUT_PULLUP TFTSer.begin(115200); // wait for the TFT panel to initialise and finish the animation diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 20f480faa2..11084e325a 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -235,9 +235,9 @@ typedef struct SettingsDataStruct { // // FILAMENT_RUNOUT_SENSOR // - bool runout_sensor_enabled[HOTENDS]; // M591 S - float runout_distance_mm[HOTENDS]; // M591 D - uint8_t runout_mode[HOTENDS]; // M591 P + bool runout_sensor_enabled[NUM_RUNOUT_SENSORS]; // M591 S + float runout_distance_mm[NUM_RUNOUT_SENSORS]; // M591 D + uint8_t runout_mode[NUM_RUNOUT_SENSORS]; // M591 P // // ENABLE_LEVELING_FADE_HEIGHT @@ -794,18 +794,18 @@ void MarlinSettings::postprocess() { // { #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.enabled[e]); - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.runout_distance(e)); - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.mode[e]); #else - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_WRITE((int8_t)-1)); - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_WRITE((float)-0.0f)); - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_WRITE((uint8_t)0)); #endif } @@ -1713,23 +1713,23 @@ void MarlinSettings::postprocess() { // Filament Runout Sensor // { - int8_t runout_sensor_enabled[HOTENDS]; + int8_t runout_sensor_enabled[NUM_RUNOUT_SENSORS]; _FIELD_TEST(runout_sensor_enabled); - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_READ(runout_sensor_enabled); - float runout_distance_mm[HOTENDS]; - LOOP_S_L_N(e, 0, HOTENDS) + float runout_distance_mm[NUM_RUNOUT_SENSORS]; + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_READ(runout_distance_mm[e]); - uint8_t runout_mode[HOTENDS]; - LOOP_S_L_N(e, 0, HOTENDS) + uint8_t runout_mode[NUM_RUNOUT_SENSORS]; + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_READ(runout_mode[e]); #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) runout.enabled[e] = runout_sensor_enabled[e] < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled[e]; - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) if (!validating) runout.set_runout_distance(runout_distance_mm[e], e); - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) if (!validating) runout.mode[e] = runout_mode[e]; runout.reset(); #endif @@ -2798,11 +2798,11 @@ void MarlinSettings::reset() { // #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) runout.enabled[e] = FIL_RUNOUT_ENABLED_DEFAULT; - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM, e); - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) runout.mode[e] = FILAMENT_RUNOUT_DEFAULT_MODE; runout.reset(); From 26af3e70bc2e21aa0b54e717a25753b359071b46 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 13 Mar 2022 19:51:12 -0400 Subject: [PATCH 43/58] Remove obsolete state from tests --- buildroot/tests/BIGTREE_GTR_V1_0 | 2 +- buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive | 1 - buildroot/tests/mega2560 | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/buildroot/tests/BIGTREE_GTR_V1_0 b/buildroot/tests/BIGTREE_GTR_V1_0 index 0a80a6b78c..19ed4b6964 100755 --- a/buildroot/tests/BIGTREE_GTR_V1_0 +++ b/buildroot/tests/BIGTREE_GTR_V1_0 @@ -13,7 +13,7 @@ opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_PIN PF13 \ X_DRIVER_TYPE TMC2208 Y_DRIVER_TYPE TMC2130 \ NUM_RUNOUT_SENSORS 8 FIL_RUNOUT_PIN 3 FIL_RUNOUT2_PIN 4 FIL_RUNOUT3_PIN 5 FIL_RUNOUT4_PIN 6 FIL_RUNOUT5_PIN 7 \ - FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 FIL_RUNOUT4_STATE HIGH FIL_RUNOUT8_STATE HIGH \ + FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 \ FILAMENT_RUNOUT_SCRIPT '"M600 T%c"' 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 diff --git a/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive b/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive index 34bf77be27..48fbc10c8c 100755 --- a/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive +++ b/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive @@ -16,7 +16,6 @@ opt_enable SDSUPPORT USB_FLASH_DRIVE_SUPPORT USE_OTG_USB_HOST \ opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_PIN PF13 \ X_DRIVER_TYPE TMC2208 Y_DRIVER_TYPE TMC2130 \ FIL_RUNOUT_PIN 3 FIL_RUNOUT2_PIN 4 FIL_RUNOUT3_PIN 5 FIL_RUNOUT4_PIN 6 FIL_RUNOUT5_PIN 7 FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 \ - FIL_RUNOUT4_STATE HIGH FIL_RUNOUT8_STATE HIGH opt_enable FIL_RUNOUT4_PULLUP FIL_RUNOUT8_PULLUP exec_test $1 $2 "GTT GTR | OTG USB Flash Drive | 8 Extruders | Auto-Fan | Mixed TMC Drivers | Runout Sensors (distinct)" "$3" diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 5ae9a2dbcf..f71ba0999e 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -53,7 +53,6 @@ restore_configs opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO NUM_SERVOS 1 \ EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 \ NUM_RUNOUT_SENSORS 5 FIL_RUNOUT2_PIN 44 FIL_RUNOUT3_PIN 45 FIL_RUNOUT4_PIN 46 FIL_RUNOUT5_PIN 47 \ - FIL_RUNOUT3_STATE HIGH opt_enable VIKI2 BOOT_MARLIN_LOGO_ANIMATED SDSUPPORT AUTO_REPORT_SD_STATUS \ Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE \ EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL AUTO_REPORT_POSITION \ From fc77afd93e331f4e82ade35437ed5ffb2987df8a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 13 Mar 2022 19:57:01 -0500 Subject: [PATCH 44/58] misc. cleanup --- Marlin/Configuration.h | 21 +- Marlin/src/core/utility.cpp | 4 +- Marlin/src/feature/mmu/mmu2.cpp | 2 +- Marlin/src/feature/pause.cpp | 25 +- Marlin/src/feature/runout.cpp | 10 +- Marlin/src/feature/runout.h | 247 ++++++++---------- Marlin/src/gcode/feature/pause/M600.cpp | 2 +- Marlin/src/gcode/feature/runout/M591.cpp | 52 ++-- Marlin/src/gcode/gcode.h | 2 +- Marlin/src/inc/Conditionals_LCD.h | 20 +- Marlin/src/inc/Conditionals_adv.h | 5 +- Marlin/src/inc/SanityCheck.h | 74 +++++- Marlin/src/lcd/e3v2/proui/endstop_diag.cpp | 2 +- .../generic/endstop_state_screen.cpp | 12 +- Marlin/src/lcd/extui/ui_api.h | 1 - Marlin/src/module/endstops.cpp | 25 +- Marlin/src/module/settings.cpp | 84 +++--- buildroot/tests/BIGTREE_GTR_V1_0 | 6 +- .../tests/BIGTREE_GTR_V1_0_usb_flash_drive | 1 + buildroot/tests/DUE | 2 +- buildroot/tests/mega2560 | 7 +- buildroot/tests/rambo | 2 +- 22 files changed, 297 insertions(+), 309 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 865a975b2e..af31343880 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1466,13 +1466,12 @@ */ //#define FILAMENT_RUNOUT_SENSOR #if ENABLED(FILAMENT_RUNOUT_SENSOR) - #define FIL_RUNOUT_ENABLED_DEFAULT { true } // Default state for sensors E0, E1[, E2, E3] // Enable the sensor on startup. Override with M591 followed by M500. - - #define FILAMENT_RUNOUT_DEFAULT_MODE {1} // Array set that will take the place of FIL_RUNOUT_STATE and FIL_RUNOUT_ENABLED_DEFAULT as this code matures - #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. - //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. - //#define WATCH_ALL_RUNOUT_SENSORS // Execute runout script on any triggering sensor, not only for the active extruder. - // This is automatically enabled for MIXING_EXTRUDERs. + #define FIL_RUNOUT_ENABLED { true } // Default enabled state for sensors E0[, E1[, E2[, E3...]]]. Override with M591 followed by M500. + #define FIL_RUNOUT_MODE { 1 } // Default mode for sensors E0[, E1[, E2[, E3...]]]. 0:NONE 1:Switch NO 2:Switch NC 7:Motion Sensor + #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. + //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. + //#define WATCH_ALL_RUNOUT_SENSORS // Execute runout script on any triggering sensor, not only for the active extruder. + // This is automatically enabled for MIXING_EXTRUDERs. // Override individually if the runout sensors vary //#define FIL_RUNOUT1_PULLUP @@ -1507,12 +1506,12 @@ // After a runout is detected, continue printing this length of filament // before executing the runout script. Useful for a sensor at the end of // a feed tube. Requires 4 bytes SRAM per sensor, plus 4 bytes overhead. - #define FILAMENT_RUNOUT_DISTANCE_MM {15} + #define FIL_RUNOUT_DISTANCE_MM { 15 } - #ifdef FILAMENT_RUNOUT_DISTANCE_MM + #ifdef FIL_RUNOUT_DISTANCE_MM // Enable this option to use an encoder disc that toggles the runout pin - // as the filament moves. (Be sure to set FILAMENT_RUNOUT_DISTANCE_MM - // large enough to avoid false positives.) + // as the filament moves. (Be sure to make FIL_RUNOUT_DISTANCE_MM long + // enough to avoid false positives.) //#define FILAMENT_MOTION_SENSOR #endif #endif diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 59e59d4cb7..e3dab5aded 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -94,9 +94,9 @@ void safe_delay(millis_t ms) { SERIAL_ECHOPGM(" (Aligned With"); if (probe.offset_xy.y > 0) - SERIAL_ECHOF(F(TERN(IS_SCARA, "-Distal", "-Back"))); + SERIAL_ECHOPGM(TERN(IS_SCARA, "-Distal", "-Back")); else if (probe.offset_xy.y < 0) - SERIAL_ECHOF(F(TERN(IS_SCARA, "-Proximal", "-Front"))); + SERIAL_ECHOPGM(TERN(IS_SCARA, "-Proximal", "-Front")); else if (probe.offset_xy.x != 0) SERIAL_ECHOPGM("-Center"); diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 2bb69fa9c6..911464a5e2 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -140,7 +140,7 @@ uint8_t MMU2::get_current_tool() { } #if EITHER(HAS_PRUSA_MMU2S, MMU_EXTRUDER_SENSOR) - #define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != (runout.mode[0]==2 ? HIGH, LOW)) + #define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != runout.out_state()) #endif void MMU2::mmu_loop() { diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 7333613c83..34ebcbc7f0 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -208,31 +208,22 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load while (wait_for_user) { impatient_beep(max_beep_count); #if BOTH(FILAMENT_CHANGE_RESUME_ON_INSERT, FILAMENT_RUNOUT_SENSOR) - #if ENABLED(MULTI_FILAMENT_SENSOR) - #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break; + #if MULTI_FILAMENT_SENSOR LOOP_S_LE_N(i, 1, NUM_RUNOUT_SENSORS) { pin_t pin; - uint8_t state; switch (i) { default: continue; + #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break; REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) + #undef _CASE_RUNOUT } - if(runout.mode[i-1]==1) - state = HIGH; - else - state = LOW; - if(runout.mode[i-1]!=0 && runout.mode[i-1]!=7 && extDigitalRead(pin) != state) + const uint8_t rm = runout.mode[i - 1]; + if (rm != 0 && rm != 7 && extDigitalRead(pin) != runout.out_state(i - 1)) wait_for_user = false; } - #undef _CASE_RUNOUT - #else { - uint8_t state; - if(runout.mode[active_extruder]==1) - state = HIGH; - else - state = LOW; - if (READ(FIL_RUNOUT_PIN) != state) wait_for_user = false; - } + #else + if (READ(FIL_RUNOUT_PIN) != runout.out_state(active_extruder)) + wait_for_user = false; #endif #endif idle_no_sleep(); diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 332890c0ef..96238c0f80 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -32,9 +32,9 @@ FilamentMonitor runout; -bool FilamentMonitorBase::enabled[NUM_RUNOUT_SENSORS] = {true}, - FilamentMonitorBase::filament_ran_out; // = false -uint8_t FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS] = FILAMENT_RUNOUT_DEFAULT_MODE; // Initialized by settings.load +bool FilamentMonitorBase::enabled[NUM_RUNOUT_SENSORS], // Initialized by settings.load + FilamentMonitorBase::filament_ran_out; // = false +uint8_t FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS]; // Initialized by settings.load #if ENABLED(HOST_ACTION_COMMANDS) bool FilamentMonitorBase::host_handling; // = false #endif @@ -45,12 +45,10 @@ uint8_t FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS] = FILAMENT_RUNOUT_DEFAULT_ #include "../core/debug_out.h" #endif - -float RunoutResponseDelayed::runout_distance_mm[NUM_RUNOUT_SENSORS] = FILAMENT_RUNOUT_DISTANCE_MM; +float RunoutResponseDelayed::runout_distance_mm[NUM_RUNOUT_SENSORS]; // Initialized by settings.load volatile float RunoutResponseDelayed::runout_mm_countdown[NUM_RUNOUT_SENSORS]; uint8_t FilamentSensorCore::motion_detected; - // // Filament Runout event handler // diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 7867809232..a898cb33de 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -64,7 +64,9 @@ extern FilamentMonitor runout; class FilamentMonitorBase { public: static bool enabled[NUM_RUNOUT_SENSORS], filament_ran_out; - static uint8_t mode[NUM_RUNOUT_SENSORS]; + static uint8_t mode[NUM_RUNOUT_SENSORS]; // 0:NONE 1:Switch NC 2:Switch NO 7:Motion Sensor + + static uint8_t out_state(const uint8_t e=0) { return mode[e] == 2 ? HIGH : LOW; } #if ENABLED(HOST_ACTION_COMMANDS) static bool host_handling; @@ -94,12 +96,9 @@ class TFilamentMonitor : public FilamentMonitorBase { // Call this method when filament is present, // so the response can reset its counter. - static void filament_present(const uint8_t extruder) { - response.filament_present(extruder); - } - - static float& runout_distance(uint8_t extruder=0) { return response.runout_distance_mm[extruder]; } - static void set_runout_distance(const_float_t mm, uint8_t extruder=0) { response.runout_distance_mm[extruder] = mm; } + static void filament_present(const uint8_t e) { response.filament_present(e); } + static float& runout_distance(const uint8_t e=0) { return response.runout_distance_mm[e]; } + static void set_runout_distance(const_float_t mm, const uint8_t e=0) { response.runout_distance_mm[e] = mm; } // Handle a block completion. RunoutResponseDelayed uses this to // add up the length of filament moved while the filament is out. @@ -210,151 +209,125 @@ class FilamentSensorBase { // Return a bitmask of runout flag states (1 bits always indicates runout) static uint8_t poll_runout_states() { - return poll_runout_pins() ^ uint8_t(0 - #if NUM_RUNOUT_SENSORS >= 1 - | ((runout.mode[0]==2) ? 0 : _BV(1 - 1)) - #endif - #if NUM_RUNOUT_SENSORS >= 2 - | ((runout.mode[1]==2) ? 0 : _BV(2 - 1)) - #endif - #if NUM_RUNOUT_SENSORS >= 3 - | ((runout.mode[2]==2) ? 0 : _BV(3 - 1)) - #endif - #if NUM_RUNOUT_SENSORS >= 4 - | ((runout.mode[3]==2) ? 0 : _BV(4 - 1)) - #endif - #if NUM_RUNOUT_SENSORS >= 5 - | ((runout.mode[4]==2) ? 0 : _BV(5 - 1)) - #endif - #if NUM_RUNOUT_SENSORS >= 6 - | ((runout.mode[5]==2) ? 0 : _BV(6 - 1)) - #endif - #if NUM_RUNOUT_SENSORS >= 7 - | ((runout.mode[6]==2) ? 0 : _BV(7 - 1)) - #endif - #if NUM_RUNOUT_SENSORS >= 8 - | ((runout.mode[7]==2) ? 0 : _BV(8 - 1)) - #endif - ); + #define _OR_INVERT(N) | (runout.out_state(N) ? 0 : _BV(N)) + return poll_runout_pins() ^ uint8_t(0 REPEAT_1(NUM_RUNOUT_SENSORS, _OR_INVERT)); + #undef _OR_INVERT } }; - class FilamentSensorCore : public FilamentSensorBase { - private: - static uint8_t motion_detected; +class FilamentSensorCore : public FilamentSensorBase { + private: + static uint8_t motion_detected; - static bool poll_runout_state(const uint8_t extruder) { - const uint8_t runout_states = poll_runout_states(); - #if MULTI_FILAMENT_SENSOR - if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating()) - && !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled) - ) return TEST(runout_states, extruder); // A specific extruder ran out - #else - UNUSED(extruder); - #endif - return !!runout_states; // Any extruder ran out - } + static bool poll_runout_state(const uint8_t extruder) { + const uint8_t runout_states = poll_runout_states(); + #if MULTI_FILAMENT_SENSOR + if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating()) + && !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled) + ) return TEST(runout_states, extruder); // A specific extruder ran out + #else + UNUSED(extruder); + #endif + return !!runout_states; // Any extruder ran out + } - static void poll_motion_sensor() { - static uint8_t old_state; - const uint8_t new_state = poll_runout_pins(), - change = old_state ^ new_state; - old_state = new_state; + static void poll_motion_sensor() { + static uint8_t old_state; + const uint8_t new_state = poll_runout_pins(), + change = old_state ^ new_state; + old_state = new_state; - #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) - if (change) { - SERIAL_ECHOPGM("Motion detected:"); - LOOP_L_N(e, NUM_RUNOUT_SENSORS) - if (TEST(change, e)) SERIAL_CHAR(' ', '0' + e); - SERIAL_EOL(); - } - #endif - - motion_detected |= change; - } - - public: - static void block_completed(const block_t * const b) { - if (runout.mode[active_extruder]!=7) return; - // If the sensor wheel has moved since the last call to - // this method reset the runout counter for the extruder. - if (TEST(motion_detected, b->extruder)) - filament_present(b->extruder); - - // Clear motion triggers for next block - motion_detected = 0; - } - - static void run() { - if(runout.mode[active_extruder]==7) - { - poll_motion_sensor(); + #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) + if (change) { + SERIAL_ECHOPGM("Motion detected:"); + LOOP_L_N(e, NUM_RUNOUT_SENSORS) + if (TEST(change, e)) SERIAL_CHAR(' ', '0' + e); + SERIAL_EOL(); } - else if(runout.mode[active_extruder]!=0) { - LOOP_L_N(s, NUM_RUNOUT_SENSORS) { - const bool out = poll_runout_state(s); - if (!out) filament_present(s); - #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) - static uint8_t was_out; // = 0 - if (out != TEST(was_out, s)) { - TBI(was_out, s); - SERIAL_ECHOLNF(F("Filament Sensor "), AS_DIGIT(s), out ? F(" OUT") : F(" IN")); - } - #endif - } + #endif + + motion_detected |= change; + } + + public: + static void block_completed(const block_t * const b) { + if (runout.mode[active_extruder] != 7) return; + + // If the sensor wheel has moved since the last call to + // this method reset the runout counter for the extruder. + if (TEST(motion_detected, b->extruder)) + filament_present(b->extruder); + + // Clear motion triggers for next block + motion_detected = 0; + } + + static void run() { + if (runout.mode[active_extruder] == 7) { + poll_motion_sensor(); + } + else if (runout.mode[active_extruder] != 0) { + LOOP_L_N(s, NUM_RUNOUT_SENSORS) { + const bool out = poll_runout_state(s); + if (!out) filament_present(s); + #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) + static uint8_t was_out; // = 0 + if (out != TEST(was_out, s)) { + TBI(was_out, s); + SERIAL_ECHOLNF(F("Filament Sensor "), AS_DIGIT(s), out ? F(" OUT") : F(" IN")); + } + #endif } } - }; - - + } +}; /********************************* RESPONSE TYPE *********************************/ - // RunoutResponseDelayed triggers a runout event only if the length - // of filament specified by FILAMENT_RUNOUT_DISTANCE_MM has been fed - // during a runout condition. - class RunoutResponseDelayed { - private: - static volatile float runout_mm_countdown[NUM_RUNOUT_SENSORS]; +// RunoutResponseDelayed triggers a runout event only if the length +// of filament specified by FIL_RUNOUT_DISTANCE_MM has been fed +// during a runout condition. +class RunoutResponseDelayed { + private: + static volatile float runout_mm_countdown[NUM_RUNOUT_SENSORS]; - public: - static float runout_distance_mm[NUM_RUNOUT_SENSORS]; + public: + static float runout_distance_mm[NUM_RUNOUT_SENSORS]; - static void reset() { - LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); - } + static void reset() { + LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); + } - static void run() { - #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) - static millis_t t = 0; - const millis_t ms = millis(); - if (ELAPSED(ms, t)) { - t = millis() + 1000UL; - LOOP_L_N(i, NUM_RUNOUT_SENSORS) - SERIAL_ECHOF(i ? F(", ") : F("Remaining mm: "), runout_mm_countdown[i]); - SERIAL_EOL(); - } - #endif - } - - static uint8_t has_run_out() { - uint8_t runout_flags = 0; - LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_mm_countdown[i] < 0) SBI(runout_flags, i); - return runout_flags; - } - - static void filament_present(const uint8_t extruder) { - runout_mm_countdown[extruder] = runout_distance_mm[extruder]; - } - - static void block_completed(const block_t * const b) { - if (b->steps.x || b->steps.y || b->steps.z || did_pause_print) { // Allow pause purge move to re-trigger runout state - // Only trigger on extrusion with XYZ movement to allow filament change and retract/recover. - const uint8_t e = b->extruder; - const int32_t steps = b->steps.e; - runout_mm_countdown[e] -= (TEST(b->direction_bits, E_AXIS) ? -steps : steps) * planner.mm_per_step[E_AXIS_N(e)]; + static void run() { + #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) + static millis_t t = 0; + const millis_t ms = millis(); + if (ELAPSED(ms, t)) { + t = millis() + 1000UL; + LOOP_L_N(i, NUM_RUNOUT_SENSORS) + SERIAL_ECHOF(i ? F(", ") : F("Remaining mm: "), runout_mm_countdown[i]); + SERIAL_EOL(); } - } - }; + #endif + } + static uint8_t has_run_out() { + uint8_t runout_flags = 0; + LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_mm_countdown[i] < 0) SBI(runout_flags, i); + return runout_flags; + } + + static void filament_present(const uint8_t extruder) { + runout_mm_countdown[extruder] = runout_distance_mm[extruder]; + } + + static void block_completed(const block_t * const b) { + if (b->steps.x || b->steps.y || b->steps.z || did_pause_print) { // Allow pause purge move to re-trigger runout state + // Only trigger on extrusion with XYZ movement to allow filament change and retract/recover. + const uint8_t e = b->extruder; + const int32_t steps = b->steps.e; + runout_mm_countdown[e] -= (TEST(b->direction_bits, E_AXIS) ? -steps : steps) * planner.mm_per_step[E_AXIS_N(e)]; + } + } +}; diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index 0b5a4d8c03..e97cc25e99 100644 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -88,7 +88,7 @@ void GcodeSuite::M600() { // In this case, for duplicating modes set DXC_ext to the extruder that ran out. #if MULTI_FILAMENT_SENSOR if (idex_is_duplicating()) - DXC_ext = (READ(FIL_RUNOUT2_PIN) == (runout.mode[1]==2 ? HIGH, LOW) ? 1 : 0; + DXC_ext = (READ(FIL_RUNOUT2_PIN) == runout.out_state(1)) ? 1 : 0; #else DXC_ext = active_extruder; #endif diff --git a/Marlin/src/gcode/feature/runout/M591.cpp b/Marlin/src/gcode/feature/runout/M591.cpp index e4a7e5b59d..0751de879a 100644 --- a/Marlin/src/gcode/feature/runout/M591.cpp +++ b/Marlin/src/gcode/feature/runout/M591.cpp @@ -27,13 +27,8 @@ #include "../../gcode.h" #include "../../../feature/runout.h" - -void GcodeSuite::M412() { - SERIAL_ECHOLNPGM_P("M412 is Deprecated, please us M591."); - M591(); -} /** - 591: Configure filament runout detection + * M591: Configure filament runout detection * * Parameters * R : Reset the runout sensor @@ -41,41 +36,33 @@ void GcodeSuite::M412() { * H : Enable/disable host handling of filament runout * L : Extra distance to continue after runout is triggered or motion interval * D : Alias for L - * P : Mode : - 0 = none - 1 = simple sensor (high signal when filament present) - 2 = simple sensor (low signal when filament present) - 7 = motion encoder sensor + * P : Mode 0 = NONE + * 1 = Switch NO (HIGH = filament present) + * 2 = Switch NC (LOW = filament present) + * 7 = Encoder / Motion Sensor */ void GcodeSuite::M591() { - #if HOTENDS > 1 - if(parser.seen("E")) - const uint8_t tool = parser.value_ushort(); - else - tool = active_extruder; - #else - const uint8_t tool = 0; - #endif - - if (parser.seen("RSDP" - TERN_(HOST_ACTION_COMMANDS, "H") - )) { + if (parser.seen("RSDP" TERN_(HOST_ACTION_COMMANDS, "H"))) { #if ENABLED(HOST_ACTION_COMMANDS) if (parser.seen('H')) runout.host_handling = parser.value_bool(); #endif const bool seenR = parser.seen_test('R'), seenS = parser.seen('S'); if (seenR || seenS) runout.reset(); + #if NUM_RUNOUT_SENSORS > 1 + const uint8_t tool = parser.ushortval('E', active_extruder); + #else + constexpr uint8_t tool = 0; + #endif if (seenS) runout.enabled[tool] = parser.value_bool(); if (parser.seen('D')) runout.set_runout_distance(parser.value_linear_units(), tool); if (parser.seen('L')) runout.set_runout_distance(parser.value_linear_units(), tool); if (parser.seen('P')) { - uint8_t tmp_mode = parser.value_int(); - if(tmp_mode < 3 || tmp_mode==7) { + const uint8_t tmp_mode = parser.value_int(); + if (tmp_mode < 3 || tmp_mode == 7) { runout.mode[tool] = tmp_mode; runout.reset(); } } - } else { SERIAL_ECHO_START(); @@ -93,15 +80,16 @@ void GcodeSuite::M591() { void GcodeSuite::M591_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_FILAMENT_RUNOUT_SENSOR)); - LOOP_S_L_N(e, 1, HOTENDS) - SERIAL_ECHOPGM( - " M591 E", e - , " S", runout.enabled[e] + LOOP_S_L_N(e, 1, NUM_RUNOUT_SENSORS) + SERIAL_ECHOLNPGM( + " M591" + #if NUM_RUNOUT_SENSORS > 1 + " E", e, + #endif + " S", runout.enabled[e] , " D", LINEAR_UNIT(runout.runout_distance(e)) , " P", runout.mode[e] - , " ; " ); - } #endif // HAS_FILAMENT_SENSOR diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 46f4a5ddce..1e15756f24 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -978,7 +978,7 @@ private: #endif #if HAS_FILAMENT_SENSOR - static void M412(); + static void M412() { M591(); } static void M591(); static void M591_report(const bool forReplay=true); #endif diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index e2b643ae73..fb52d1d2f2 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -832,10 +832,14 @@ /** * Fill in undefined Filament Sensor options */ -#ifndef NUM_RUNOUT_SENSORS - #define NUM_RUNOUT_SENSORS E_STEPPERS -#endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) + #define HAS_FILAMENT_SENSOR 1 + #ifndef NUM_RUNOUT_SENSORS + #define NUM_RUNOUT_SENSORS E_STEPPERS + #endif + #if ENABLED(MIXING_EXTRUDER) + #define WATCH_ALL_RUNOUT_SENSORS + #endif #if NUM_RUNOUT_SENSORS >= 1 #ifndef FIL_RUNOUT1_PULLUP #define FIL_RUNOUT1_PULLUP FIL_RUNOUT_PULLUP @@ -845,6 +849,7 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 2 + #define MULTI_FILAMENT_SENSOR 1 #ifndef FIL_RUNOUT2_PULLUP #define FIL_RUNOUT2_PULLUP FIL_RUNOUT_PULLUP #endif @@ -885,7 +890,6 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 7 - #ifndef FIL_RUNOUT7_PULLUP #define FIL_RUNOUT7_PULLUP FIL_RUNOUT_PULLUP #endif @@ -901,14 +905,6 @@ #define FIL_RUNOUT8_PULLDOWN FIL_RUNOUT_PULLDOWN #endif #endif - - #define HAS_FILAMENT_SENSOR 1 - #if NUM_RUNOUT_SENSORS > 1 - #define MULTI_FILAMENT_SENSOR 1 - #endif - #if ENABLED(MIXING_EXTRUDER) - #define WATCH_ALL_RUNOUT_SENSORS - #endif #endif // FILAMENT_RUNOUT_SENSOR // Homing to Min or Max diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index d0004658ce..2219f311e0 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -95,11 +95,12 @@ #undef PID_EXTRUSION_SCALING #undef LIN_ADVANCE #undef FILAMENT_RUNOUT_SENSOR + #undef FIL_RUNOUT_ENABLED + #undef FIL_RUNOUT_MODE + #undef FIL_RUNOUT_DISTANCE_MM #undef ADVANCED_PAUSE_FEATURE - #undef FILAMENT_RUNOUT_DISTANCE_MM #undef FILAMENT_LOAD_UNLOAD_GCODES #undef DISABLE_INACTIVE_EXTRUDER - #undef FILAMENT_LOAD_UNLOAD_GCODES #undef EXTRUDER_RUNOUT_PREVENT #undef PREVENT_COLD_EXTRUSION #undef PREVENT_LENGTHY_EXTRUDE diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 9f7b9fb056..f281038bae 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -561,9 +561,9 @@ #error "SHORT_MANUAL_Z_MOVE is now FINE_MANUAL_MOVE, applying to Z on most printers." #elif defined(FIL_RUNOUT_INVERTING) #if FIL_RUNOUT_INVERTING - #error "FIL_RUNOUT_INVERTING true is now FILAMENT_RUNOUT_DEFAULT_MODE {HIGH}." + #error "FIL_RUNOUT_INVERTING true is now FIL_RUNOUT_MODE {HIGH}." #else - #error "FIL_RUNOUT_INVERTING false is now FILAMENT_RUNOUT_DEFAULT_MODE {LOW}." + #error "FIL_RUNOUT_INVERTING false is now FIL_RUNOUT_MODE {LOW}." #endif #elif defined(ASSISTED_TRAMMING_MENU_ITEM) #error "ASSISTED_TRAMMING_MENU_ITEM is deprecated and should be removed." @@ -1002,16 +1002,68 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "You can't enable FIL_RUNOUT8_PULLUP and FIL_RUNOUT8_PULLDOWN at the same time." #elif DISABLED(ADVANCED_PAUSE_FEATURE) static_assert(nullptr == strstr(FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with FILAMENT_RUNOUT_SENSOR."); - #elif ANY(FIL_RUNOUT_STATE, FIL_RUNOUT1_STATE, FIL_RUNOUT2_STATE, FIL_RUNOUT3_STATE, FIL_RUNOUT4_STATE, FIL_RUNOUT5_STATE, FIL_RUNOUT6_STATE, FIL_RUNOUT7_STATE, FIL_RUNOUT8_STATE) - #error "FIL_RUNOUT#_STATE is Now set with FILAMENT_RUNOUT_DEFAULT_MODE" + #elif defined(FIL_RUNOUT_ENABLED_DEFAULT) + #error "FIL_RUNOUT_ENABLED_DEFAULT is now set with the FILAMENT_RUNOUT_ENABLED array." + #elif defined(FILAMENT_RUNOUT_DISTANCE_MM) + #error "FILAMENT_RUNOUT_DISTANCE_MM is now set with the FIL_RUNOUT_DISTANCE_MM array." + #elif defined(FIL_RUNOUT_STATE) || defined(FIL_RUNOUT2_STATE) || defined(FIL_RUNOUT3_STATE) || defined(FIL_RUNOUT4_STATE) || defined(FIL_RUNOUT5_STATE) || defined(FIL_RUNOUT6_STATE) || defined(FIL_RUNOUT7_STATE) || defined(FIL_RUNOUT8_STATE) + #ifdef FIL_RUNOUT_STATE + #if FIL_RUNOUT_STATE + #error "FIL_RUNOUT_STATE HIGH is now set with FIL_RUNOUT_MODE { 2 ... }." + #else + #error "FIL_RUNOUT_STATE LOW is now set with FIL_RUNOUT_MODE { 1 ... }." + #endif + #endif + #ifdef FIL_RUNOUT2_STATE + #if FIL_RUNOUT2_STATE + #error "FIL_RUNOUT2_STATE HIGH is now set with FIL_RUNOUT_MODE { n, 2 ... }." + #else + #error "FIL_RUNOUT2_STATE LOW is now set with FIL_RUNOUT_MODE { n, 1 ... }." + #endif + #endif + #ifdef FIL_RUNOUT3_STATE + #if FIL_RUNOUT3_STATE + #error "FIL_RUNOUT3_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, 2 ... }." + #else + #error "FIL_RUNOUT3_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, 1 ... }." + #endif + #endif + #ifdef FIL_RUNOUT4_STATE + #if FIL_RUNOUT4_STATE + #error "FIL_RUNOUT4_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, 2 ... }." + #else + #error "FIL_RUNOUT4_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, 1 ... }." + #endif + #endif + #ifdef FIL_RUNOUT5_STATE + #if FIL_RUNOUT5_STATE + #error "FIL_RUNOUT5_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, n, 2 ... }." + #else + #error "FIL_RUNOUT5_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, n, 1 ... }." + #endif + #endif + #ifdef FIL_RUNOUT6_STATE + #if FIL_RUNOUT6_STATE + #error "FIL_RUNOUT6_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, n, n, 2 ... }." + #else + #error "FIL_RUNOUT6_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, n, n, 1 ... }." + #endif + #endif + #ifdef FIL_RUNOUT7_STATE + #if FIL_RUNOUT7_STATE + #error "FIL_RUNOUT7_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, n, n, n, 2 ... }." + #else + #error "FIL_RUNOUT7_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, n, n, n, 1 ... }." + #endif + #endif + #ifdef FIL_RUNOUT8_STATE + #if FIL_RUNOUT8_STATE + #error "FIL_RUNOUT8_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, n, n, n, n, 2 ... }." + #else + #error "FIL_RUNOUT8_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, n, n, n, n, 1 ... }." + #endif + #endif #endif - - constexpr uint8_t frdm[] = FILAMENT_RUNOUT_DEFAULT_MODE; - static_assert(COUNT(frdm) == NUM_RUNOUT_SENSORS, "FILAMENT_RUNOUT_DEFAULT_MODE must have NUM_RUNOUT_SENSORS values."); - constexpr bool fred[] = FIL_RUNOUT_ENABLED_DEFAULT; - static_assert(COUNT(fred) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_ENABLED_DEFAULT must have NUM_RUNOUT_SENSORS values."); - constexpr float frd[] = FILAMENT_RUNOUT_DISTANCE_MM; - static_assert(COUNT(frd) == NUM_RUNOUT_SENSORS, "FILAMENT_RUNOUT_DISTANCE_MM must have NUM_RUNOUT_SENSORS values."); #endif /** diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index ab42b2f1d8..2e4ab6a79c 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -100,7 +100,7 @@ void ESDiagClass::Update() { ES_REPORT(Z_MIN); #endif #if HAS_FILAMENT_SENSOR - draw_es_state(READ(FIL_RUNOUT1_PIN) != (runout.mode[0]==2 ? HIGH, LOW); + draw_es_state(READ(FIL_RUNOUT1_PIN) != runout.out_state()); #endif DWIN_UpdateLCD(); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp index c7042e760e..fdc5764db9 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp @@ -51,13 +51,7 @@ void EndstopStatesScreen::onRedraw(draw_mode_t) { #define PIN_ENABLED(X,Y,LABEL,PIN,INV) cmd.enabled(1).colors(READ(PIN##_PIN) != INV ? action_btn : normal_btn).PIN_BTN(X,Y,PIN,LABEL); #define PIN_DISABLED(X,Y,LABEL,PIN) cmd.enabled(0).PIN_BTN(X,Y,PIN,LABEL); - cmd.font( - #if ENABLED(TOUCH_UI_PORTRAIT) - font_large - #else - font_medium - #endif - ) + cmd.font(TERN(TOUCH_UI_PORTRAIT, font_large, font_medium)) .text(BTN_POS(1,1), BTN_SIZE(6,1), GET_TEXT_F(MSG_LCD_ENDSTOPS)) .font(font_tiny); #if HAS_X_MAX @@ -91,12 +85,12 @@ void EndstopStatesScreen::onRedraw(draw_mode_t) { PIN_DISABLED(5, 3, PSTR(STR_Z_MIN), Z_MIN) #endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT) - PIN_ENABLED (1, 4, GET_TEXT_F(MSG_RUNOUT_1), FIL_RUNOUT, FIL_RUNOUT1_STATE) + PIN_ENABLED (1, 4, GET_TEXT_F(MSG_RUNOUT_1), FIL_RUNOUT, !runout.out_state()) #else PIN_DISABLED(1, 4, GET_TEXT_F(MSG_RUNOUT_1), FIL_RUNOUT) #endif #if BOTH(HAS_MULTI_EXTRUDER, FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT2) - PIN_ENABLED (3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2, FIL_RUNOUT2_STATE) + PIN_ENABLED (3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2, !runout.out_state(1)) #else PIN_DISABLED(3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2) #endif diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 3d87d0208e..3ccf6dea70 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -300,7 +300,6 @@ namespace ExtUI { void setFilamentRunoutState(const bool); float getFilamentRunoutDistance_mm(); void setFilamentRunoutDistance_mm(const_float_t); - #endif #if ENABLED(CASE_LIGHT_ENABLE) diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 4fae1d4ad2..f41a6c9f87 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -575,34 +575,29 @@ void _O2 Endstops::report_states() { print_es_state(PROBE_TRIGGERED(), F(STR_Z_PROBE)); #endif #if HAS_FILAMENT_SENSOR - #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break; LOOP_S_LE_N(i, 1, NUM_RUNOUT_SENSORS) { pin_t pin; - uint8_t state; switch (i) { default: continue; + #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break; REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) + #undef _CASE_RUNOUT } - if(runout.mode[i-1]==1) - state = HIGH; - else - state = LOW; + const uint8_t rm = runout.mode[i - 1], + state = runout.out_state(i - 1); SERIAL_ECHOPGM(STR_FILAMENT); if (i > 1) SERIAL_CHAR(' ', '0' + i); SERIAL_ECHOPGM(": "); - if(runout.mode[i-1]==0) - SERIAL_ECHOLNF(F("DISABLED")); - else if(runout.mode[i-1]==7) { - SERIAL_ECHOF(F("MOTION : ")); - print_es_state(extDigitalRead(pin) != state); + if (rm == 0) + SERIAL_ECHOLNPGM("DISABLED"); + else if (rm == 7) { + SERIAL_ECHOPGM("MOTION : "); + print_es_state(extDigitalRead(pin) == state); } - else if(extDigitalRead(pin) != state) - SERIAL_ECHOLNF(F("PRESENT")); else - SERIAL_ECHOLNF(F("MISSING")); + SERIAL_ECHOLNPGM_P(extDigitalRead(pin) == state ? PSTR("MISSING") : PSTR("PRESENT")); } - #undef _CASE_RUNOUT #endif TERN_(BLTOUCH, bltouch._reset_SW_mode()); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 11084e325a..7c10698ccc 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -112,9 +112,9 @@ #if HAS_FILAMENT_SENSOR #include "../feature/runout.h" - #ifndef FIL_RUNOUT_ENABLED_DEFAULT - #define FIL_RUNOUT_ENABLED_DEFAULT true - #endif + #define NRS NUM_RUNOUT_SENSORS +#else + #define NRS 1 #endif #if ENABLED(EXTRA_LIN_ADVANCE_K) @@ -235,9 +235,9 @@ typedef struct SettingsDataStruct { // // FILAMENT_RUNOUT_SENSOR // - bool runout_sensor_enabled[NUM_RUNOUT_SENSORS]; // M591 S - float runout_distance_mm[NUM_RUNOUT_SENSORS]; // M591 D - uint8_t runout_mode[NUM_RUNOUT_SENSORS]; // M591 P + bool runout_enabled[NRS]; // M591 S + float runout_distance_mm[NRS]; // M591 D + uint8_t runout_mode[NRS]; // M591 P // // ENABLE_LEVELING_FADE_HEIGHT @@ -793,20 +793,15 @@ void MarlinSettings::postprocess() { // Filament Runout Sensor // { + _FIELD_TEST(runout_enabled); #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_WRITE(runout.enabled[e]); - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_WRITE(runout.runout_distance(e)); - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_WRITE(runout.mode[e]); + LOOP_L_N(e, NRS) EEPROM_WRITE(runout.enabled[e]); + LOOP_L_N(e, NRS) EEPROM_WRITE(runout.runout_distance(e)); + LOOP_L_N(e, NRS) EEPROM_WRITE(runout.mode[e]); #else - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_WRITE((int8_t)-1)); - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_WRITE((float)-0.0f)); - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_WRITE((uint8_t)0)); + EEPROM_WRITE((int8_t)-1); + EEPROM_WRITE((float)-0.0f); + EEPROM_WRITE((uint8_t)0); #endif } @@ -1713,27 +1708,28 @@ void MarlinSettings::postprocess() { // Filament Runout Sensor // { - int8_t runout_sensor_enabled[NUM_RUNOUT_SENSORS]; - _FIELD_TEST(runout_sensor_enabled); - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_READ(runout_sensor_enabled); - float runout_distance_mm[NUM_RUNOUT_SENSORS]; - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_READ(runout_distance_mm[e]); - uint8_t runout_mode[NUM_RUNOUT_SENSORS]; - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_READ(runout_mode[e]); + _FIELD_TEST(runout_enabled); + + int8_t runout_enabled[NRS]; + float runout_distance_mm[NRS]; + uint8_t runout_mode[NRS]; + + LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_enabled[e]); + LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_distance_mm[e]); + LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_mode[e]); #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - runout.enabled[e] = runout_sensor_enabled[e] < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled[e]; - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - if (!validating) runout.set_runout_distance(runout_distance_mm[e], e); - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - if (!validating) runout.mode[e] = runout_mode[e]; - runout.reset(); + if (!validating) { + LOOP_S_L_N(e, 0, NRS) { + if (runout_enabled[e] >= 0) { + runout.enabled[e] = (runout_enabled[e] > 0); + runout.set_runout_distance(runout_distance_mm[e], e); + runout.mode[e] = runout_mode[e]; + } + } + runout.reset(); + } #endif - } // @@ -2798,13 +2794,15 @@ void MarlinSettings::reset() { // #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - runout.enabled[e] = FIL_RUNOUT_ENABLED_DEFAULT; - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM, e); - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - runout.mode[e] = FILAMENT_RUNOUT_DEFAULT_MODE; - + constexpr bool fred[] = FIL_RUNOUT_ENABLED; + constexpr uint8_t frm[] = FIL_RUNOUT_MODE; + constexpr float frd[] = FIL_RUNOUT_DISTANCE_MM; + static_assert(COUNT(fred) == NRS, "FIL_RUNOUT_ENABLED must have NUM_RUNOUT_SENSORS values."); + static_assert(COUNT(frm) == NRS, "FIL_RUNOUT_MODE must have NUM_RUNOUT_SENSORS values."); + static_assert(COUNT(frd) == NRS, "FIL_RUNOUT_DISTANCE_MM must have NUM_RUNOUT_SENSORS values."); + COPY(runout.enabled, fred); + COPY(runout.mode, frm); + LOOP_L_N(e, NRS) runout.set_runout_distance(frd[e], e); runout.reset(); #endif diff --git a/buildroot/tests/BIGTREE_GTR_V1_0 b/buildroot/tests/BIGTREE_GTR_V1_0 index 19ed4b6964..a64f30b4f9 100755 --- a/buildroot/tests/BIGTREE_GTR_V1_0 +++ b/buildroot/tests/BIGTREE_GTR_V1_0 @@ -12,8 +12,10 @@ opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ # Not necessary to enable auto-fan for all extruders to hit problematic code paths opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_PIN PF13 \ X_DRIVER_TYPE TMC2208 Y_DRIVER_TYPE TMC2130 \ - NUM_RUNOUT_SENSORS 8 FIL_RUNOUT_PIN 3 FIL_RUNOUT2_PIN 4 FIL_RUNOUT3_PIN 5 FIL_RUNOUT4_PIN 6 FIL_RUNOUT5_PIN 7 \ - FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 \ + FIL_RUNOUT_ENABLED '{ true, true, true, true, true, true, true, true }' \ + FIL_RUNOUT_MODE '{ 1, 1, 1, 1, 1, 1, 1, 1 }' \ + FIL_RUNOUT_DISTANCE_MM '{ 0, 1, 5, 10, 5, 5, 5, 5 }' \ + FIL_RUNOUT_PIN 3 FIL_RUNOUT2_PIN 4 FIL_RUNOUT3_PIN 5 FIL_RUNOUT4_PIN 6 FIL_RUNOUT5_PIN 7 FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 \ FILAMENT_RUNOUT_SCRIPT '"M600 T%c"' 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 diff --git a/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive b/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive index 48fbc10c8c..3e819ba85e 100755 --- a/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive +++ b/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive @@ -16,6 +16,7 @@ opt_enable SDSUPPORT USB_FLASH_DRIVE_SUPPORT USE_OTG_USB_HOST \ opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_PIN PF13 \ X_DRIVER_TYPE TMC2208 Y_DRIVER_TYPE TMC2130 \ FIL_RUNOUT_PIN 3 FIL_RUNOUT2_PIN 4 FIL_RUNOUT3_PIN 5 FIL_RUNOUT4_PIN 6 FIL_RUNOUT5_PIN 7 FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 \ + FIL_RUNOUT_MODE '{ 2, 2, 2, 1, 2, 2, 2, 1 }' FIL_RUNOUT_DISTANCE_MM '{ 0, 1, 5, 10, 5, 5, 5, 5 }' opt_enable FIL_RUNOUT4_PULLUP FIL_RUNOUT8_PULLUP exec_test $1 $2 "GTT GTR | OTG USB Flash Drive | 8 Extruders | Auto-Fan | Mixed TMC Drivers | Runout Sensors (distinct)" "$3" diff --git a/buildroot/tests/DUE b/buildroot/tests/DUE index 9b968cbd8d..7251cd8669 100755 --- a/buildroot/tests/DUE +++ b/buildroot/tests/DUE @@ -19,7 +19,7 @@ opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \ EEPROM_SETTINGS SDSUPPORT BINARY_FILE_TRANSFER \ BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN \ NEOPIXEL_LED NEOPIXEL_PIN CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_USE_RGB_LED CASE_LIGHT_MENU \ - NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_DISTANCE_MM FILAMENT_RUNOUT_SENSOR \ + NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_SENSOR FIL_RUNOUT_DISTANCE_MM \ AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE CALIBRATION_GCODE \ BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \ diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index f71ba0999e..ad08b7487f 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -53,6 +53,7 @@ restore_configs opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO NUM_SERVOS 1 \ EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 \ NUM_RUNOUT_SENSORS 5 FIL_RUNOUT2_PIN 44 FIL_RUNOUT3_PIN 45 FIL_RUNOUT4_PIN 46 FIL_RUNOUT5_PIN 47 \ + FIL_RUNOUT_ENABLED '{ true, true, true, true, true }' FIL_RUNOUT_MODE '{ 1, 2, 7, 0, 1 }' FIL_RUNOUT_DISTANCE_MM '{ 15, 15, 15, 15, 15 }' opt_enable VIKI2 BOOT_MARLIN_LOGO_ANIMATED SDSUPPORT AUTO_REPORT_SD_STATUS \ Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE \ EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL AUTO_REPORT_POSITION \ @@ -66,9 +67,9 @@ exec_test $1 $2 "Multiple runout sensors (x5) | Distinct runout states" "$3" # Mixing Extruder with 5 steppers, Greek # restore_configs -opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO MIXING_STEPPERS 5 LCD_LANGUAGE ru \ - NUM_RUNOUT_SENSORS E_STEPPERS REDUNDANT_PART_COOLING_FAN 1 \ - FIL_RUNOUT2_PIN 16 FIL_RUNOUT3_PIN 17 FIL_RUNOUT4_PIN 4 FIL_RUNOUT5_PIN 5 +opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO MIXING_STEPPERS 5 LCD_LANGUAGE ru REDUNDANT_PART_COOLING_FAN 1 \ + FIL_RUNOUT2_PIN 16 FIL_RUNOUT3_PIN 17 FIL_RUNOUT4_PIN 4 FIL_RUNOUT5_PIN 5 \ + FIL_RUNOUT_ENABLED '{ true, true, true, true, true }' FIL_RUNOUT_MODE '{ 1, 2, 7, 0, 1 }' FIL_RUNOUT_DISTANCE_MM '{ 15, 15, 15, 15, 15 }' opt_enable MIXING_EXTRUDER GRADIENT_MIX GRADIENT_VTOOL CR10_STOCKDISPLAY \ USE_CONTROLLER_FAN CONTROLLER_FAN_EDITABLE CONTROLLER_FAN_IGNORE_Z \ FILAMENT_RUNOUT_SENSOR ADVANCED_PAUSE_FEATURE NOZZLE_PARK_FEATURE diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index e696dce96e..f5b822f691 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -25,7 +25,7 @@ opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_P NEOPIXEL_LED NEOPIXEL_PIN CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_MENU \ PID_PARAMS_PER_HOTEND PID_AUTOTUNE_MENU PID_EDIT_MENU LCD_SHOW_E_TOTAL \ PRINTCOUNTER SERVICE_NAME_1 SERVICE_INTERVAL_1 LEVEL_BED_CORNERS LEVEL_CENTER_TOO \ - NOZZLE_PARK_FEATURE FILAMENT_RUNOUT_SENSOR FILAMENT_RUNOUT_DISTANCE_MM \ + NOZZLE_PARK_FEATURE FILAMENT_RUNOUT_SENSOR FIL_RUNOUT_DISTANCE_MM \ ADVANCED_PAUSE_FEATURE FILAMENT_LOAD_UNLOAD_GCODES FILAMENT_UNLOAD_ALL_EXTRUDERS \ PASSWORD_FEATURE PASSWORD_ON_STARTUP PASSWORD_ON_SD_PRINT_MENU PASSWORD_AFTER_SD_PRINT_END PASSWORD_AFTER_SD_PRINT_ABORT \ AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DISTINCT_E_FACTORS \ From dd88eb56ee41fff10b91aa9174e1b63984e150f2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 13 Mar 2022 20:44:01 -0500 Subject: [PATCH 45/58] Allow user to change --- Marlin/Configuration.h | 1 + buildroot/tests/rambo | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index af31343880..0d387aac63 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1466,6 +1466,7 @@ */ //#define FILAMENT_RUNOUT_SENSOR #if ENABLED(FILAMENT_RUNOUT_SENSOR) + //#define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each. #define FIL_RUNOUT_ENABLED { true } // Default enabled state for sensors E0[, E1[, E2[, E3...]]]. Override with M591 followed by M500. #define FIL_RUNOUT_MODE { 1 } // Default mode for sensors E0[, E1[, E2[, E3...]]]. 0:NONE 1:Switch NO 2:Switch NC 7:Motion Sensor #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index f5b822f691..ae9d8cb295 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -15,7 +15,7 @@ opt_set MOTHERBOARD BOARD_RAMBO \ TEMP_SENSOR_PROBE 1 TEMP_PROBE_PIN 12 \ TEMP_SENSOR_CHAMBER 3 TEMP_CHAMBER_PIN 3 HEATER_CHAMBER_PIN 45 \ GRID_MAX_POINTS_X 16 AUTO_POWER_E_TEMP 80 \ - FANMUX0_PIN 53 + FANMUX0_PIN 53 NUM_RUNOUT_SENSORS 1 opt_disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN USE_WATCHDOG opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TEST \ FIX_MOUNTED_PROBE CODEPENDENT_XY_HOMING PIDTEMPBED PTC_PROBE PTC_BED \ From 07b2480d30ca70b7e8904fc114e8b409a7608da8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 13 Mar 2022 20:45:53 -0500 Subject: [PATCH 46/58] glue for CI test --- Marlin/src/inc/Conditionals_LCD.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index fb52d1d2f2..e6e92068be 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1411,3 +1411,28 @@ #if defined(NEOPIXEL_BKGD_INDEX_FIRST) && !defined(NEOPIXEL_BKGD_INDEX_LAST) #define NEOPIXEL_BKGD_INDEX_LAST NEOPIXEL_BKGD_INDEX_FIRST #endif + +/*** TEMPORARY COMPATIBILITY ***/ + +#if HAS_FILAMENT_SENSOR + #ifndef FIL_RUNOUT_ENABLED + #if FIL_RUNOUT_ENABLED_DEFAULT + #define FIL_RUNOUT_ENABLED ARRAY_N_1(NUM_RUNOUT_SENSORS, true) + #else + #define FIL_RUNOUT_ENABLED ARRAY_N_1(NUM_RUNOUT_SENSORS, false) + #endif + #endif + #ifndef FIL_RUNOUT_MODE + #if FIL_RUNOUT_STATE + #define FIL_RUNOUT_MODE ARRAY_N_1(NUM_RUNOUT_SENSORS, 1) + #else + #define FIL_RUNOUT_MODE ARRAY_N_1(NUM_RUNOUT_SENSORS, 2) + #endif + #endif + #ifndef FIL_RUNOUT_DISTANCE_MM + #define FIL_RUNOUT_DISTANCE_MM ARRAY_N_1(NUM_RUNOUT_SENSORS, 10) + #endif + #undef FIL_RUNOUT_ENABLED_DEFAULT + #undef FIL_RUNOUT_STATE + #undef FILAMENT_RUNOUT_DISTANCE_MM +#endif From 0cedad36d17a65e0090bafe429675cdf6289aa7f Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Mon, 14 Mar 2022 09:29:53 -0400 Subject: [PATCH 47/58] Reorganize config options, remove obsolete option. --- Marlin/Configuration.h | 39 ++++++++++++++++-------------------- Marlin/src/inc/SanityCheck.h | 2 ++ 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 0d387aac63..7700108136 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1459,7 +1459,7 @@ * Marlin knows a print job is running when: * 1. Running a print job from media started with M24. * 2. The Print Job Timer has been started with M75. - * 3. The heaters were turned on and PRINTJOB_TIMER_AUTOSTART is enabled. + * 3. The heaters were turned on with a wait command (M109) and PRINTJOB_TIMER_AUTOSTART is enabled. * * RAMPS-based boards use SERVO3_PIN for the first runout sensor. * For other boards you may need to define FIL_RUNOUT_PIN, FIL_RUNOUT2_PIN, etc. @@ -1467,13 +1467,25 @@ //#define FILAMENT_RUNOUT_SENSOR #if ENABLED(FILAMENT_RUNOUT_SENSOR) //#define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each. - #define FIL_RUNOUT_ENABLED { true } // Default enabled state for sensors E0[, E1[, E2[, E3...]]]. Override with M591 followed by M500. - #define FIL_RUNOUT_MODE { 1 } // Default mode for sensors E0[, E1[, E2[, E3...]]]. 0:NONE 1:Switch NO 2:Switch NC 7:Motion Sensor - #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. - //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. + #define FIL_RUNOUT_ENABLED { true } // Default enabled state for sensors E0[, E1[, E2[, E3...]]]. Override with M591EnnSn followed by M500. + #define FIL_RUNOUT_MODE { 1 } // Default mode for sensors E0[, E1[, E2[, E3...]]]. 0:NONE 1:Switch NO 2:Switch NC 7:Motion Sensor Override with M591EnPnn //#define WATCH_ALL_RUNOUT_SENSORS // Execute runout script on any triggering sensor, not only for the active extruder. // This is automatically enabled for MIXING_EXTRUDERs. + // Commands to execute on filament runout. + // With multiple runout sensors use the %c placeholder for the current tool in commands (e.g., "M600 T%c") + // NOTE: After 'M591 H1' the host handles filament runout and this script does not apply. + #define FILAMENT_RUNOUT_SCRIPT "M600" + + // In Mode 1 or 2, continue printing this length of filament after a run out occurs before executing the + // runout script. Useful for a sensor at the end of a feed tube or debounce on a flakey sensor. + // In Mode 7, extrusion distance to expect a change of state. + // Override with M591EnLnn + #define FIL_RUNOUT_DISTANCE_MM { 15 } + + #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. + //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. + // Override individually if the runout sensors vary //#define FIL_RUNOUT1_PULLUP //#define FIL_RUNOUT1_PULLDOWN @@ -1498,23 +1510,6 @@ //#define FIL_RUNOUT8_PULLUP //#define FIL_RUNOUT8_PULLDOWN - - // Commands to execute on filament runout. - // With multiple runout sensors use the %c placeholder for the current tool in commands (e.g., "M600 T%c") - // NOTE: After 'M591 H1' the host handles filament runout and this script does not apply. - #define FILAMENT_RUNOUT_SCRIPT "M600" - - // After a runout is detected, continue printing this length of filament - // before executing the runout script. Useful for a sensor at the end of - // a feed tube. Requires 4 bytes SRAM per sensor, plus 4 bytes overhead. - #define FIL_RUNOUT_DISTANCE_MM { 15 } - - #ifdef FIL_RUNOUT_DISTANCE_MM - // Enable this option to use an encoder disc that toggles the runout pin - // as the filament moves. (Be sure to make FIL_RUNOUT_DISTANCE_MM long - // enough to avoid false positives.) - //#define FILAMENT_MOTION_SENSOR - #endif #endif //=========================================================================== diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index f281038bae..12f5770ab0 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1063,6 +1063,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "FIL_RUNOUT8_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, n, n, n, n, 1 ... }." #endif #endif + #elif ENABLED(FILAMENT_MOTION_SENSOR) + #error "FILAMENT_MOTION_SENSOR is now set with FIL_RUNOUT_MODE { 7 ... }." #endif #endif From 378fc12628f49599ed2d12e88981acf8ee683b68 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Tue, 15 Mar 2022 12:24:29 -0400 Subject: [PATCH 48/58] Add runout menu, small fixes --- Marlin/src/feature/runout.h | 4 +- Marlin/src/lcd/language/language_en.h | 5 +++ Marlin/src/lcd/menu/menu_advanced.cpp | 53 +++++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index a898cb33de..72faaef449 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -103,7 +103,7 @@ class TFilamentMonitor : public FilamentMonitorBase { // Handle a block completion. RunoutResponseDelayed uses this to // add up the length of filament moved while the filament is out. static void block_completed(const block_t * const b) { - if (enabled) { + if (enabled[active_extruder]) { response.block_completed(b); sensor.block_completed(b); } @@ -111,7 +111,7 @@ class TFilamentMonitor : public FilamentMonitorBase { // Give the response a chance to update its counter. static void run() { - if (enabled && !filament_ran_out && (printingIsActive() || did_pause_print)) { + if (enabled[active_extruder] && mode[active_extruder]!=0 && !filament_ran_out && (printingIsActive() || did_pause_print)) { cli(); // Prevent RunoutResponseDelayed::block_completed from accumulating here response.run(); sensor.run(); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 7fe5c22271..1e9a7298ba 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -651,6 +651,11 @@ namespace Language_en { LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Nozzle: "); LSTR MSG_RUNOUT_SENSOR = _UxGT("Runout Sensor"); LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Runout Dist mm"); + LSTR MSG_RUNOUT_MODE = _UxGT("Runout Mode"); + LSTR MSG_RUNOUT_MODE_HIGH = _UxGT("Sensor High"); + LSTR MSG_RUNOUT_MODE_LOW = _UxGT("Sensor Low"); + LSTR MSG_RUNOUT_MODE_MOTION = _UxGT("Motion Encoder"); + LSTR MSG_RUNOUT_MODE_NONE = _UxGT("No Sensor"); LSTR MSG_RUNOUT_ENABLE = _UxGT("Enable Runout"); LSTR MSG_FANCHECK = _UxGT("Fan Tacho Check"); LSTR MSG_KILL_HOMING_FAILED = _UxGT("Homing Failed"); diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 77728201c5..1c4fbc9b97 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -97,6 +97,54 @@ void menu_backlash(); #endif +#if HAS_FILAMENT_SENSOR + + #define RUNOUT_EDIT_ITEMS(F) do{ \ + EDIT_ITEM_N(bool, F, MSG_RUNOUT_MODE_NONE, &runout.enabled[F]); \ + ACTION_ITEM_N(F, MSG_RUNOUT_MODE_NONE, []{ set_runout_mode_none(F);}); \ + ACTION_ITEM_N(F, MSG_RUNOUT_MODE_HIGH, []{ set_runout_mode_high(F);}); \ + ACTION_ITEM_N(F, MSG_RUNOUT_MODE_LOW, []{ set_runout_mode_low(F);}); \ + ACTION_ITEM_N(F, MSG_RUNOUT_MODE_MOTION, []{ set_runout_mode_motion(F);}); \ + editable.decimal = runout.runout_distance(F); \ + EDIT_ITEM_FAST_N(float3, F, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, \ + []{ runout.set_runout_distance(editable.decimal, F); }, true \ + ); \ + }while(0) + + void set_runout_mode_none(uint8_t e) { runout.mode[e] = 0; } + void set_runout_mode_high(uint8_t e) { runout.mode[e] = 1; } + void set_runout_mode_low(uint8_t e) { runout.mode[e] = 2; } + void set_runout_mode_motion(uint8_t e) { runout.mode[e] = 7; } + + void menu_runout_config() { + START_MENU(); + BACK_ITEM(MSG_CONFIGURATION); + RUNOUT_EDIT_ITEMS(0); + #if NUM_RUNOUT_SENSORS > 1 + RUNOUT_EDIT_ITEMS(1); + #endif + #if NUM_RUNOUT_SENSORS > 2 + RUNOUT_EDIT_ITEMS(2); + #endif + #if NUM_RUNOUT_SENSORS > 3 + RUNOUT_EDIT_ITEMS(3); + #endif + #if NUM_RUNOUT_SENSORS > 4 + RUNOUT_EDIT_ITEMS(4); + #endif + #if NUM_RUNOUT_SENSORS > 5 + RUNOUT_EDIT_ITEMS(5); + #endif + #if NUM_RUNOUT_SENSORS > 6 + RUNOUT_EDIT_ITEMS(6); + #endif + #if NUM_RUNOUT_SENSORS > 7 + RUNOUT_EDIT_ITEMS(7); + #endif + END_MENU(); + } +#endif + #if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE) // // Advanced Settings > Filament @@ -151,10 +199,7 @@ void menu_backlash(); #endif #if HAS_FILAMENT_SENSOR - editable.decimal = runout.runout_distance(); - EDIT_ITEM_FAST(float3, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, - []{ runout.set_runout_distance(editable.decimal); }, true - ); + SUBMENU(MSG_RUNOUT_MODE, menu_runout_config); #endif END_MENU(); From 489b75ae3ca2c957f22bc4bdde6346c51859e482 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Tue, 15 Mar 2022 12:46:57 -0400 Subject: [PATCH 49/58] Update menu_advanced.cpp --- Marlin/src/lcd/menu/menu_advanced.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 1c4fbc9b97..ac2da4d8a6 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -100,7 +100,7 @@ void menu_backlash(); #if HAS_FILAMENT_SENSOR #define RUNOUT_EDIT_ITEMS(F) do{ \ - EDIT_ITEM_N(bool, F, MSG_RUNOUT_MODE_NONE, &runout.enabled[F]); \ + EDIT_ITEM_N(bool, F, MSG_RUNOUT_SENSOR, &runout.enabled[F]); \ ACTION_ITEM_N(F, MSG_RUNOUT_MODE_NONE, []{ set_runout_mode_none(F);}); \ ACTION_ITEM_N(F, MSG_RUNOUT_MODE_HIGH, []{ set_runout_mode_high(F);}); \ ACTION_ITEM_N(F, MSG_RUNOUT_MODE_LOW, []{ set_runout_mode_low(F);}); \ From 6741f5182deb0dd24b6227c6c1238326ba6721a7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 26 Mar 2022 18:54:02 -0500 Subject: [PATCH 50/58] Simplify menu items, use enum --- Marlin/src/feature/pause.cpp | 4 ++-- Marlin/src/feature/runout.cpp | 2 +- Marlin/src/feature/runout.h | 19 +++++++++++++------ Marlin/src/lcd/menu/menu_advanced.cpp | 22 +++++++++++----------- Marlin/src/module/endstops.cpp | 8 ++++---- 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 34ebcbc7f0..8aa1ff4f03 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -217,8 +217,8 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) #undef _CASE_RUNOUT } - const uint8_t rm = runout.mode[i - 1]; - if (rm != 0 && rm != 7 && extDigitalRead(pin) != runout.out_state(i - 1)) + const RunoutMode rm = runout.mode[i - 1]; + if (rm != RM_NONE && rm != RM_MOTION_SENSOR && extDigitalRead(pin) != runout.out_state(i - 1)) wait_for_user = false; } #else diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 96238c0f80..aae92d423f 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -34,7 +34,7 @@ FilamentMonitor runout; bool FilamentMonitorBase::enabled[NUM_RUNOUT_SENSORS], // Initialized by settings.load FilamentMonitorBase::filament_ran_out; // = false -uint8_t FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS]; // Initialized by settings.load +RunoutMode FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS]; // Initialized by settings.load #if ENABLED(HOST_ACTION_COMMANDS) bool FilamentMonitorBase::host_handling; // = false #endif diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 72faaef449..3149a21d37 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -61,12 +61,19 @@ extern FilamentMonitor runout; /*******************************************************************************************/ +enum RunoutMode : uint8_t { + RM_NONE, + RM_ACTIVE_LOW, + RM_ACTIVE_HIGH, + RM_MOTION_SENSOR = 7 +}; + class FilamentMonitorBase { public: static bool enabled[NUM_RUNOUT_SENSORS], filament_ran_out; - static uint8_t mode[NUM_RUNOUT_SENSORS]; // 0:NONE 1:Switch NC 2:Switch NO 7:Motion Sensor + static RunoutMode mode[NUM_RUNOUT_SENSORS]; - static uint8_t out_state(const uint8_t e=0) { return mode[e] == 2 ? HIGH : LOW; } + static uint8_t out_state(const uint8_t e=0) { return mode[e] == RM_ACTIVE_HIGH ? HIGH : LOW; } #if ENABLED(HOST_ACTION_COMMANDS) static bool host_handling; @@ -111,7 +118,7 @@ class TFilamentMonitor : public FilamentMonitorBase { // Give the response a chance to update its counter. static void run() { - if (enabled[active_extruder] && mode[active_extruder]!=0 && !filament_ran_out && (printingIsActive() || did_pause_print)) { + if (enabled[active_extruder] && mode[active_extruder] != RM_NONE && !filament_ran_out && (printingIsActive() || did_pause_print)) { cli(); // Prevent RunoutResponseDelayed::block_completed from accumulating here response.run(); sensor.run(); @@ -251,7 +258,7 @@ class FilamentSensorCore : public FilamentSensorBase { public: static void block_completed(const block_t * const b) { - if (runout.mode[active_extruder] != 7) return; + if (runout.mode[active_extruder] != RM_MOTION_SENSOR) return; // If the sensor wheel has moved since the last call to // this method reset the runout counter for the extruder. @@ -263,10 +270,10 @@ class FilamentSensorCore : public FilamentSensorBase { } static void run() { - if (runout.mode[active_extruder] == 7) { + if (runout.mode[active_extruder] == RM_MOTION_SENSOR) { poll_motion_sensor(); } - else if (runout.mode[active_extruder] != 0) { + else if (runout.mode[active_extruder] != RM_NONE) { LOOP_L_N(s, NUM_RUNOUT_SENSORS) { const bool out = poll_runout_state(s); if (!out) filament_present(s); diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index ac2da4d8a6..6ceb4b8424 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -99,23 +99,23 @@ void menu_backlash(); #if HAS_FILAMENT_SENSOR + void set_runout_mode_none(const uint8_t e) { runout.mode[e] = RM_NONE; } + void set_runout_mode_high(const uint8_t e) { runout.mode[e] = RM_ACTIVE_HIGH; } + void set_runout_mode_low(const uint8_t e) { runout.mode[e] = RM_ACTIVE_LOW; } + void set_runout_mode_motion(const uint8_t e) { runout.mode[e] = RM_MOTION_SENSOR; } + #define RUNOUT_EDIT_ITEMS(F) do{ \ - EDIT_ITEM_N(bool, F, MSG_RUNOUT_SENSOR, &runout.enabled[F]); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_NONE, []{ set_runout_mode_none(F);}); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_HIGH, []{ set_runout_mode_high(F);}); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_LOW, []{ set_runout_mode_low(F);}); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_MOTION, []{ set_runout_mode_motion(F);}); \ + EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled[F]); \ + ACTION_ITEM(MSG_RUNOUT_MODE_NONE, []{ set_runout_mode_none(F); }); \ + ACTION_ITEM(MSG_RUNOUT_MODE_HIGH, []{ set_runout_mode_high(F); }); \ + ACTION_ITEM(MSG_RUNOUT_MODE_LOW, []{ set_runout_mode_low(F); }); \ + ACTION_ITEM(MSG_RUNOUT_MODE_MOTION, []{ set_runout_mode_motion(F); }); \ editable.decimal = runout.runout_distance(F); \ - EDIT_ITEM_FAST_N(float3, F, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, \ + EDIT_ITEM_FAST(float3, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, \ []{ runout.set_runout_distance(editable.decimal, F); }, true \ ); \ }while(0) - void set_runout_mode_none(uint8_t e) { runout.mode[e] = 0; } - void set_runout_mode_high(uint8_t e) { runout.mode[e] = 1; } - void set_runout_mode_low(uint8_t e) { runout.mode[e] = 2; } - void set_runout_mode_motion(uint8_t e) { runout.mode[e] = 7; } - void menu_runout_config() { START_MENU(); BACK_ITEM(MSG_CONFIGURATION); diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index f41a6c9f87..c9bf1f4eb9 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -583,15 +583,15 @@ void _O2 Endstops::report_states() { REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) #undef _CASE_RUNOUT } - const uint8_t rm = runout.mode[i - 1], - state = runout.out_state(i - 1); + const RunoutMode rm = runout.mode[i - 1]; + const uint8_t state = runout.out_state(i - 1); SERIAL_ECHOPGM(STR_FILAMENT); if (i > 1) SERIAL_CHAR(' ', '0' + i); SERIAL_ECHOPGM(": "); - if (rm == 0) + if (rm == RM_NONE) SERIAL_ECHOLNPGM("DISABLED"); - else if (rm == 7) { + else if (rm == RM_MOTION_SENSOR) { SERIAL_ECHOPGM("MOTION : "); print_es_state(extDigitalRead(pin) == state); } From bdfe4ca4d154c61740eb4a1d2d33bc9f21dce404 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 26 Mar 2022 18:54:02 -0500 Subject: [PATCH 51/58] Simplify menu items, use enum, adjust settings --- Marlin/src/feature/pause.cpp | 4 +- Marlin/src/feature/runout.cpp | 2 +- Marlin/src/feature/runout.h | 19 ++++-- Marlin/src/gcode/feature/runout/M591.cpp | 24 ++++---- Marlin/src/lcd/menu/menu_advanced.cpp | 22 +++---- Marlin/src/module/endstops.cpp | 14 ++--- Marlin/src/module/settings.cpp | 77 +++++++++++------------- 7 files changed, 79 insertions(+), 83 deletions(-) diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 34ebcbc7f0..8aa1ff4f03 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -217,8 +217,8 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) #undef _CASE_RUNOUT } - const uint8_t rm = runout.mode[i - 1]; - if (rm != 0 && rm != 7 && extDigitalRead(pin) != runout.out_state(i - 1)) + const RunoutMode rm = runout.mode[i - 1]; + if (rm != RM_NONE && rm != RM_MOTION_SENSOR && extDigitalRead(pin) != runout.out_state(i - 1)) wait_for_user = false; } #else diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 96238c0f80..aae92d423f 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -34,7 +34,7 @@ FilamentMonitor runout; bool FilamentMonitorBase::enabled[NUM_RUNOUT_SENSORS], // Initialized by settings.load FilamentMonitorBase::filament_ran_out; // = false -uint8_t FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS]; // Initialized by settings.load +RunoutMode FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS]; // Initialized by settings.load #if ENABLED(HOST_ACTION_COMMANDS) bool FilamentMonitorBase::host_handling; // = false #endif diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 72faaef449..57a7a0950d 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -61,12 +61,19 @@ extern FilamentMonitor runout; /*******************************************************************************************/ +enum RunoutMode : uint8_t { + RM_NONE, + RM_OUT_ON_LOW, + RM_OUT_ON_HIGH, + RM_MOTION_SENSOR +}; + class FilamentMonitorBase { public: static bool enabled[NUM_RUNOUT_SENSORS], filament_ran_out; - static uint8_t mode[NUM_RUNOUT_SENSORS]; // 0:NONE 1:Switch NC 2:Switch NO 7:Motion Sensor + static RunoutMode mode[NUM_RUNOUT_SENSORS]; - static uint8_t out_state(const uint8_t e=0) { return mode[e] == 2 ? HIGH : LOW; } + static uint8_t out_state(const uint8_t e=0) { return mode[e] == RM_OUT_ON_HIGH ? HIGH : LOW; } #if ENABLED(HOST_ACTION_COMMANDS) static bool host_handling; @@ -111,7 +118,7 @@ class TFilamentMonitor : public FilamentMonitorBase { // Give the response a chance to update its counter. static void run() { - if (enabled[active_extruder] && mode[active_extruder]!=0 && !filament_ran_out && (printingIsActive() || did_pause_print)) { + if (enabled[active_extruder] && mode[active_extruder] != RM_NONE && !filament_ran_out && (printingIsActive() || did_pause_print)) { cli(); // Prevent RunoutResponseDelayed::block_completed from accumulating here response.run(); sensor.run(); @@ -251,7 +258,7 @@ class FilamentSensorCore : public FilamentSensorBase { public: static void block_completed(const block_t * const b) { - if (runout.mode[active_extruder] != 7) return; + if (runout.mode[active_extruder] != RM_MOTION_SENSOR) return; // If the sensor wheel has moved since the last call to // this method reset the runout counter for the extruder. @@ -263,10 +270,10 @@ class FilamentSensorCore : public FilamentSensorBase { } static void run() { - if (runout.mode[active_extruder] == 7) { + if (runout.mode[active_extruder] == RM_MOTION_SENSOR) { poll_motion_sensor(); } - else if (runout.mode[active_extruder] != 0) { + else if (runout.mode[active_extruder] != RM_NONE) { LOOP_L_N(s, NUM_RUNOUT_SENSORS) { const bool out = poll_runout_state(s); if (!out) filament_present(s); diff --git a/Marlin/src/gcode/feature/runout/M591.cpp b/Marlin/src/gcode/feature/runout/M591.cpp index 0751de879a..271e56ad53 100644 --- a/Marlin/src/gcode/feature/runout/M591.cpp +++ b/Marlin/src/gcode/feature/runout/M591.cpp @@ -39,7 +39,7 @@ * P : Mode 0 = NONE * 1 = Switch NO (HIGH = filament present) * 2 = Switch NC (LOW = filament present) - * 7 = Encoder / Motion Sensor + * 3 = Encoder / Motion Sensor */ void GcodeSuite::M591() { if (parser.seen("RSDP" TERN_(HOST_ACTION_COMMANDS, "H"))) { @@ -48,19 +48,17 @@ void GcodeSuite::M591() { #endif const bool seenR = parser.seen_test('R'), seenS = parser.seen('S'); if (seenR || seenS) runout.reset(); - #if NUM_RUNOUT_SENSORS > 1 - const uint8_t tool = parser.ushortval('E', active_extruder); - #else - constexpr uint8_t tool = 0; - #endif + const uint8_t tool = TERN0(MULTI_FILAMENT_SENSOR, parser.ushortval('E', active_extruder)); if (seenS) runout.enabled[tool] = parser.value_bool(); - if (parser.seen('D')) runout.set_runout_distance(parser.value_linear_units(), tool); - if (parser.seen('L')) runout.set_runout_distance(parser.value_linear_units(), tool); + if (parser.seen('D') || parser.seen('L')) runout.set_runout_distance(parser.value_linear_units(), tool); if (parser.seen('P')) { - const uint8_t tmp_mode = parser.value_int(); - if (tmp_mode < 3 || tmp_mode == 7) { - runout.mode[tool] = tmp_mode; - runout.reset(); + const RunoutMode tmp_mode = (RunoutMode)parser.value_int(); + switch (tmp_mode) { + case RM_NONE ... RM_OUT_ON_HIGH: + case RM_MOTION_SENSOR: + runout.mode[tool] = tmp_mode; + runout.reset(); + default: break; } } } @@ -83,7 +81,7 @@ void GcodeSuite::M591_report(const bool forReplay/*=true*/) { LOOP_S_L_N(e, 1, NUM_RUNOUT_SENSORS) SERIAL_ECHOLNPGM( " M591" - #if NUM_RUNOUT_SENSORS > 1 + #if MULTI_FILAMENT_SENSOR " E", e, #endif " S", runout.enabled[e] diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index ac2da4d8a6..0b6d855974 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -99,23 +99,23 @@ void menu_backlash(); #if HAS_FILAMENT_SENSOR + void set_runout_mode_none(const uint8_t e) { runout.mode[e] = RM_NONE; } + void set_runout_mode_high(const uint8_t e) { runout.mode[e] = RM_OUT_ON_HIGH; } + void set_runout_mode_low(const uint8_t e) { runout.mode[e] = RM_OUT_ON_LOW; } + void set_runout_mode_motion(const uint8_t e) { runout.mode[e] = RM_MOTION_SENSOR; } + #define RUNOUT_EDIT_ITEMS(F) do{ \ - EDIT_ITEM_N(bool, F, MSG_RUNOUT_SENSOR, &runout.enabled[F]); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_NONE, []{ set_runout_mode_none(F);}); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_HIGH, []{ set_runout_mode_high(F);}); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_LOW, []{ set_runout_mode_low(F);}); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_MOTION, []{ set_runout_mode_motion(F);}); \ + EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled[F]); \ + ACTION_ITEM(MSG_RUNOUT_MODE_NONE, []{ set_runout_mode_none(F); }); \ + ACTION_ITEM(MSG_RUNOUT_MODE_HIGH, []{ set_runout_mode_high(F); }); \ + ACTION_ITEM(MSG_RUNOUT_MODE_LOW, []{ set_runout_mode_low(F); }); \ + ACTION_ITEM(MSG_RUNOUT_MODE_MOTION, []{ set_runout_mode_motion(F); }); \ editable.decimal = runout.runout_distance(F); \ - EDIT_ITEM_FAST_N(float3, F, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, \ + EDIT_ITEM_FAST(float3, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, \ []{ runout.set_runout_distance(editable.decimal, F); }, true \ ); \ }while(0) - void set_runout_mode_none(uint8_t e) { runout.mode[e] = 0; } - void set_runout_mode_high(uint8_t e) { runout.mode[e] = 1; } - void set_runout_mode_low(uint8_t e) { runout.mode[e] = 2; } - void set_runout_mode_motion(uint8_t e) { runout.mode[e] = 7; } - void menu_runout_config() { START_MENU(); BACK_ITEM(MSG_CONFIGURATION); diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index f41a6c9f87..0b942784ca 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -583,20 +583,20 @@ void _O2 Endstops::report_states() { REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) #undef _CASE_RUNOUT } - const uint8_t rm = runout.mode[i - 1], - state = runout.out_state(i - 1); + const RunoutMode rm = runout.mode[i - 1]; + const uint8_t outval = runout.out_state(i - 1); SERIAL_ECHOPGM(STR_FILAMENT); if (i > 1) SERIAL_CHAR(' ', '0' + i); SERIAL_ECHOPGM(": "); - if (rm == 0) - SERIAL_ECHOLNPGM("DISABLED"); - else if (rm == 7) { + if (rm == RM_NONE) + SERIAL_ECHOLNPGM(STR_OFF); + else if (rm == RM_MOTION_SENSOR) { SERIAL_ECHOPGM("MOTION : "); - print_es_state(extDigitalRead(pin) == state); + print_es_state(extDigitalRead(pin) == outval); } else - SERIAL_ECHOLNPGM_P(extDigitalRead(pin) == state ? PSTR("MISSING") : PSTR("PRESENT")); + SERIAL_ECHOLNPGM_P(extDigitalRead(pin) == outval ? PSTR("OUT") : PSTR("PRESENT")); } #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 7c10698ccc..ffb96cddf5 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -112,9 +112,6 @@ #if HAS_FILAMENT_SENSOR #include "../feature/runout.h" - #define NRS NUM_RUNOUT_SENSORS -#else - #define NRS 1 #endif #if ENABLED(EXTRA_LIN_ADVANCE_K) @@ -235,9 +232,11 @@ typedef struct SettingsDataStruct { // // FILAMENT_RUNOUT_SENSOR // - bool runout_enabled[NRS]; // M591 S - float runout_distance_mm[NRS]; // M591 D - uint8_t runout_mode[NRS]; // M591 P + #if HAS_FILAMENT_SENSOR + bool runout_enabled[NUM_RUNOUT_SENSORS]; // M591 S + float runout_distance_mm[NUM_RUNOUT_SENSORS]; // M591 D + uint8_t runout_mode[NUM_RUNOUT_SENSORS]; // M591 P + #endif // // ENABLE_LEVELING_FADE_HEIGHT @@ -781,29 +780,23 @@ void MarlinSettings::postprocess() { // // Hotend Offsets, if any // - { - #if HAS_HOTEND_OFFSET - // Skip hotend 0 which must be 0 - LOOP_S_L_N(e, 1, HOTENDS) - EEPROM_WRITE(hotend_offset[e]); - #endif - } + #if HAS_HOTEND_OFFSET + // Skip hotend 0 which must be 0 + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_WRITE(hotend_offset[e]); + #endif // // Filament Runout Sensor // + #if HAS_FILAMENT_SENSOR { _FIELD_TEST(runout_enabled); - #if HAS_FILAMENT_SENSOR - LOOP_L_N(e, NRS) EEPROM_WRITE(runout.enabled[e]); - LOOP_L_N(e, NRS) EEPROM_WRITE(runout.runout_distance(e)); - LOOP_L_N(e, NRS) EEPROM_WRITE(runout.mode[e]); - #else - EEPROM_WRITE((int8_t)-1); - EEPROM_WRITE((float)-0.0f); - EEPROM_WRITE((uint8_t)0); - #endif + LOOP_L_N(e, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.enabled[e]); + LOOP_L_N(e, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.runout_distance(e)); + LOOP_L_N(e, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.mode[e]); } + #endif // // Global Leveling @@ -1707,30 +1700,28 @@ void MarlinSettings::postprocess() { // // Filament Runout Sensor // + #if HAS_FILAMENT_SENSOR { _FIELD_TEST(runout_enabled); - int8_t runout_enabled[NRS]; - float runout_distance_mm[NRS]; - uint8_t runout_mode[NRS]; + bool runout_enabled[NUM_RUNOUT_SENSORS]; + float runout_distance_mm[NUM_RUNOUT_SENSORS]; + RunoutMode runout_mode[NUM_RUNOUT_SENSORS]; - LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_enabled[e]); - LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_distance_mm[e]); - LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_mode[e]); + EEPROM_READ(runout_enabled); + EEPROM_READ(runout_distance_mm); + EEPROM_READ(runout_mode); - #if HAS_FILAMENT_SENSOR - if (!validating) { - LOOP_S_L_N(e, 0, NRS) { - if (runout_enabled[e] >= 0) { - runout.enabled[e] = (runout_enabled[e] > 0); - runout.set_runout_distance(runout_distance_mm[e], e); - runout.mode[e] = runout_mode[e]; - } - } - runout.reset(); + if (!validating) { + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) { + runout.enabled[e] = runout_enabled[e]; + runout.set_runout_distance(runout_distance_mm[e], e); + runout.mode[e] = runout_mode[e]; } - #endif + runout.reset(); + } } + #endif // // Global Leveling @@ -2797,12 +2788,12 @@ void MarlinSettings::reset() { constexpr bool fred[] = FIL_RUNOUT_ENABLED; constexpr uint8_t frm[] = FIL_RUNOUT_MODE; constexpr float frd[] = FIL_RUNOUT_DISTANCE_MM; - static_assert(COUNT(fred) == NRS, "FIL_RUNOUT_ENABLED must have NUM_RUNOUT_SENSORS values."); - static_assert(COUNT(frm) == NRS, "FIL_RUNOUT_MODE must have NUM_RUNOUT_SENSORS values."); - static_assert(COUNT(frd) == NRS, "FIL_RUNOUT_DISTANCE_MM must have NUM_RUNOUT_SENSORS values."); + static_assert(COUNT(fred) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_ENABLED must have NUM_RUNOUT_SENSORS values."); + static_assert(COUNT(frm) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_MODE must have NUM_RUNOUT_SENSORS values."); + static_assert(COUNT(frd) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_DISTANCE_MM must have NUM_RUNOUT_SENSORS values."); COPY(runout.enabled, fred); COPY(runout.mode, frm); - LOOP_L_N(e, NRS) runout.set_runout_distance(frd[e], e); + LOOP_L_N(e, NUM_RUNOUT_SENSORS) runout.set_runout_distance(frd[e], e); runout.reset(); #endif From 46c820499018533d9165d7f608297f16ec9100b9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 27 Mar 2022 19:46:47 -0500 Subject: [PATCH 52/58] Extend enum --- Marlin/src/feature/runout.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 57a7a0950d..8002be156d 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -65,6 +65,10 @@ enum RunoutMode : uint8_t { RM_NONE, RM_OUT_ON_LOW, RM_OUT_ON_HIGH, + RM_RESERVED3, + RM_RESERVED4, + RM_RESERVED5, + RM_RESERVED6, RM_MOTION_SENSOR }; From 25172b3acf23be2475335160ebcb79ba77695253 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Sun, 3 Apr 2022 14:53:59 -0400 Subject: [PATCH 53/58] M591Fixes --- Marlin/src/feature/runout.h | 3 ++- Marlin/src/gcode/feature/runout/M591.cpp | 2 +- Marlin/src/lcd/menu/menu_advanced.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 8002be156d..261831403b 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -210,6 +210,7 @@ class FilamentSensorBase { #undef _INIT_RUNOUT_PIN #undef INIT_RUNOUT_PIN } + // Return a bitmask of runout pin states static uint8_t poll_runout_pins() { @@ -220,7 +221,7 @@ class FilamentSensorBase { // Return a bitmask of runout flag states (1 bits always indicates runout) static uint8_t poll_runout_states() { - #define _OR_INVERT(N) | (runout.out_state(N) ? 0 : _BV(N)) + #define _OR_INVERT(N) | (runout.out_state(N-1) ? 0 : _BV(N-1)) return poll_runout_pins() ^ uint8_t(0 REPEAT_1(NUM_RUNOUT_SENSORS, _OR_INVERT)); #undef _OR_INVERT } diff --git a/Marlin/src/gcode/feature/runout/M591.cpp b/Marlin/src/gcode/feature/runout/M591.cpp index 271e56ad53..e213f16ab8 100644 --- a/Marlin/src/gcode/feature/runout/M591.cpp +++ b/Marlin/src/gcode/feature/runout/M591.cpp @@ -57,7 +57,7 @@ void GcodeSuite::M591() { case RM_NONE ... RM_OUT_ON_HIGH: case RM_MOTION_SENSOR: runout.mode[tool] = tmp_mode; - runout.reset(); + runout.setup(); default: break; } } diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 4e406d17fa..c59a2aafd6 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -99,10 +99,10 @@ void menu_backlash(); #if HAS_FILAMENT_SENSOR - void set_runout_mode_none(const uint8_t e) { runout.mode[e] = RM_NONE; } - void set_runout_mode_high(const uint8_t e) { runout.mode[e] = RM_OUT_ON_HIGH; } - void set_runout_mode_low(const uint8_t e) { runout.mode[e] = RM_OUT_ON_LOW; } - void set_runout_mode_motion(const uint8_t e) { runout.mode[e] = RM_MOTION_SENSOR; } + void set_runout_mode_none(const uint8_t e) { runout.mode[e] = RM_NONE; runout.setup(); } + void set_runout_mode_high(const uint8_t e) { runout.mode[e] = RM_OUT_ON_HIGH; runout.setup(); } + void set_runout_mode_low(const uint8_t e) { runout.mode[e] = RM_OUT_ON_LOW; runout.setup(); } + void set_runout_mode_motion(const uint8_t e) { runout.mode[e] = RM_MOTION_SENSOR; runout.setup(); } #define RUNOUT_EDIT_ITEMS(F) do{ \ EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled[F]); \ From bba892e3277d97a1656c340552085ea58b900e4c Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 3 Apr 2022 17:03:52 -0400 Subject: [PATCH 54/58] Trim output on slim menus --- Marlin/src/gcode/feature/runout/M591.cpp | 22 +++++++++++-------- Marlin/src/lcd/menu/menu_advanced.cpp | 4 ++-- Marlin/src/module/endstops.cpp | 27 ++++++++++++++---------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Marlin/src/gcode/feature/runout/M591.cpp b/Marlin/src/gcode/feature/runout/M591.cpp index e213f16ab8..adb1bb8599 100644 --- a/Marlin/src/gcode/feature/runout/M591.cpp +++ b/Marlin/src/gcode/feature/runout/M591.cpp @@ -63,16 +63,20 @@ void GcodeSuite::M591() { } } else { - SERIAL_ECHO_START(); - SERIAL_ECHOPGM("Filament runout "); - serialprint_onoff(runout.enabled[active_extruder]); - SERIAL_ECHOPGM(" ; Distance ", runout.runout_distance(active_extruder), "mm"); - SERIAL_ECHOPGM(" ; Mode ", runout.mode[active_extruder]); - #if ENABLED(HOST_ACTION_COMMANDS) - SERIAL_ECHOPGM(" ; Host handling "); - serialprint_onoff(runout.host_handling); + #if DISABLED(SLIM_LCD_MENUS) + SERIAL_ECHO_START(); + SERIAL_ECHOPGM("Filament runout "); + serialprint_onoff(runout.enabled[active_extruder]); + SERIAL_ECHOPGM(" ; Distance ", runout.runout_distance(active_extruder), "mm"); + SERIAL_ECHOPGM(" ; Mode ", runout.mode[active_extruder]); + #if ENABLED(HOST_ACTION_COMMANDS) + SERIAL_ECHOPGM(" ; Host handling "); + serialprint_onoff(runout.host_handling); + #endif + SERIAL_EOL(); + #else + M591_report(false); #endif - SERIAL_EOL(); } } diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index c59a2aafd6..9acf315c91 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -97,7 +97,7 @@ void menu_backlash(); #endif -#if HAS_FILAMENT_SENSOR +#if HAS_FILAMENT_SENSOR && DISABLED(SLIM_LCD_MENUS) void set_runout_mode_none(const uint8_t e) { runout.mode[e] = RM_NONE; runout.setup(); } void set_runout_mode_high(const uint8_t e) { runout.mode[e] = RM_OUT_ON_HIGH; runout.setup(); } @@ -198,7 +198,7 @@ void menu_backlash(); #endif #endif - #if HAS_FILAMENT_SENSOR + #if HAS_FILAMENT_SENSOR && DISABLED(SLIM_LCD_MENUS) SUBMENU(MSG_RUNOUT_MODE, menu_runout_config); #endif diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 620f51c0f0..68fab98364 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -670,18 +670,23 @@ void _O2 Endstops::report_states() { const RunoutMode rm = runout.mode[i - 1]; const uint8_t outval = runout.out_state(i - 1); - SERIAL_ECHOPGM(STR_FILAMENT); - if (i > 1) SERIAL_CHAR(' ', '0' + i); - SERIAL_ECHOPGM(": "); - if (rm == RM_NONE) - SERIAL_ECHOLNPGM(STR_OFF); - else if (rm == RM_MOTION_SENSOR) { - SERIAL_ECHOPGM("MOTION : "); - print_es_state(extDigitalRead(pin) == outval); - } - else - SERIAL_ECHOLNPGM_P(extDigitalRead(pin) == outval ? PSTR("OUT") : PSTR("PRESENT")); + #if DISABLED(SLIM_LCD_MENUS) + SERIAL_ECHOPGM(STR_FILAMENT); + if (i > 1) SERIAL_CHAR(' ', '0' + i); + SERIAL_ECHOPGM(": "); + if (rm == RM_NONE) + SERIAL_ECHOLNPGM(STR_OFF); + else if (rm == RM_MOTION_SENSOR) { + SERIAL_ECHOPGM("MOTION : "); + print_es_state(extDigitalRead(pin) == outval); + } + else + SERIAL_ECHOLNPGM_P(extDigitalRead(pin) == outval ? PSTR("OUT") : PSTR("PRESENT")); + #else + print_es_state(extDigitalRead(pin) == outval, F(STR_FILAMENT)); + #endif } + #endif TERN_(BLTOUCH, bltouch._reset_SW_mode()); From 2f322e80840e5e9f1487e8e62ef79d19610e9103 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 9 Apr 2022 11:22:20 -0400 Subject: [PATCH 55/58] Update Configuration.h --- Marlin/Configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 435a4f524f..03a1ff2750 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -30,7 +30,7 @@ #define tallVersion -#define ABL_Bilinear +//#define ABL_Bilinear /* * Enables a filament sensor plugged into the laser pin. Disables the laser */ From 5c0696b51abf486bda4b64816670560f6624fa29 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Tue, 11 Oct 2022 11:36:31 -0400 Subject: [PATCH 56/58] updates --- Marlin/Configuration.h | 4 +- Marlin/Configuration_adv.h | 8 +-- Marlin/src/gcode/feature/runout/M412.cpp | 81 ------------------------ 3 files changed, 6 insertions(+), 87 deletions(-) delete mode 100644 Marlin/src/gcode/feature/runout/M412.cpp diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index b76128e990..6e5d5d41fc 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -970,8 +970,8 @@ #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature // is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. - //#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of flash) - //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of flash) + #define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of flash) + #define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of flash) #endif // @section safety diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 62101e81c2..7611eb0403 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1465,13 +1465,13 @@ // Add the G-code 'M73' to set / report the current job progress #define SET_PROGRESS_MANUALLY #if ENABLED(SET_PROGRESS_MANUALLY) - //#define SET_PROGRESS_PERCENT // Add 'P' parameter to set percentage done, otherwise use Marlin's estimate - //#define SET_REMAINING_TIME // Add 'R' parameter to set remaining time, otherwise use Marlin's estimate + #define SET_PROGRESS_PERCENT // Add 'P' parameter to set percentage done, otherwise use Marlin's estimate + #define SET_REMAINING_TIME // Add 'R' parameter to set remaining time, otherwise use Marlin's estimate //#define SET_INTERACTION_TIME // Add 'C' parameter to set time until next filament change or other user interaction #if ENABLED(SET_INTERACTION_TIME) #define SHOW_INTERACTION_TIME // Display time until next user interaction ('C' = filament change) #endif - //#define M73_REPORT // Report progress to host with 'M73' + #define M73_REPORT // Report progress to host with 'M73' #endif // LCD Print Progress options, multiple can be rotated depending on screen layout @@ -2100,7 +2100,7 @@ #define LIN_ADVANCE_K 0.0 // Unit: mm compression per 1mm/s extruder speed //#define LA_DEBUG // Print debug information to serial during operation. Disable for production use. #define EXPERIMENTAL_SCURVE // Allow S-Curve Acceleration to be used with LA. - //#define ALLOW_LOW_EJERK // Allow a DEFAULT_EJERK value of <10. Recommended for direct drive hotends. + #define ALLOW_LOW_EJERK // Allow a DEFAULT_EJERK value of <10. Recommended for direct drive hotends. //#define EXPERIMENTAL_I2S_LA // Allow I2S_STEPPER_STREAM to be used with LA. Performance degrades as the LA step rate reaches ~20kHz. #endif diff --git a/Marlin/src/gcode/feature/runout/M412.cpp b/Marlin/src/gcode/feature/runout/M412.cpp deleted file mode 100644 index 4b4ab6a68a..0000000000 --- a/Marlin/src/gcode/feature/runout/M412.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include "../../../inc/MarlinConfig.h" - -#if HAS_FILAMENT_SENSOR - -#include "../../gcode.h" -#include "../../../feature/runout.h" - -/** - * M412: Enable / Disable filament runout detection - * - * Parameters - * R : Reset the runout sensor - * S : Reset and enable/disable the runout sensor - * H : Enable/disable host handling of filament runout - * D : Extra distance to continue after runout is triggered - */ -void GcodeSuite::M412() { - if (parser.seen("RS" - TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, "D") - TERN_(HOST_ACTION_COMMANDS, "H") - )) { - #if ENABLED(HOST_ACTION_COMMANDS) - if (parser.seen('H')) runout.host_handling = parser.value_bool(); - #endif - const bool seenR = parser.seen_test('R'), seenS = parser.seen('S'); - if (seenR || seenS) runout.reset(); - if (seenS) runout.enabled = parser.value_bool(); - #if HAS_FILAMENT_RUNOUT_DISTANCE - if (parser.seenval('D')) runout.set_runout_distance(parser.value_linear_units()); - #endif - } - else { - SERIAL_ECHO_START(); - SERIAL_ECHOPGM("Filament runout "); - serialprint_onoff(runout.enabled); - #if HAS_FILAMENT_RUNOUT_DISTANCE - SERIAL_ECHOPGM(" ; Distance ", runout.runout_distance(), "mm"); - #endif - #if ENABLED(HOST_ACTION_COMMANDS) - SERIAL_ECHOPGM(" ; Host handling "); - serialprint_onoff(runout.host_handling); - #endif - SERIAL_EOL(); - } -} - -void GcodeSuite::M412_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, F(STR_FILAMENT_RUNOUT_SENSOR)); - SERIAL_ECHOPGM( - " M412 S", runout.enabled - #if HAS_FILAMENT_RUNOUT_DISTANCE - , " D", LINEAR_UNIT(runout.runout_distance()) - #endif - , " ; Sensor " - ); - serialprintln_onoff(runout.enabled); -} - -#endif // HAS_FILAMENT_SENSOR From e6680ddfdf6519bee63c72c1c98c0e2309beaf32 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Tue, 11 Oct 2022 11:37:22 -0400 Subject: [PATCH 57/58] Update menu_advanced.cpp --- Marlin/src/lcd/menu/menu_advanced.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 9e89fdc544..159d41b7aa 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -267,10 +267,10 @@ void menu_backlash(); void apply_PID_p(const int8_t e) { switch (e) { #if ENABLED(PIDTEMPBED) - case H_BED: thermalManager.temp_bed.pid.set_Ki(raw_Ki); break; + case H_BED: thermalManager.temp_bed.pid.set_Kp(raw_Kp); break; #endif #if ENABLED(PIDTEMPCHAMBER) - case H_CHAMBER: thermalManager.temp_chamber.pid.set_Ki(raw_Ki); break; + case H_CHAMBER: thermalManager.temp_chamber.pid.set_Kp(raw_Kp); break; #endif default: #if ENABLED(PIDTEMP) From 0e1b62e0949a1a448090529bb957bd041ddaa30a Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 23 Oct 2022 12:35:46 -0400 Subject: [PATCH 58/58] Reduce ram and SPI speed --- Marlin/Configuration.h | 3 ++- Marlin/Configuration_adv.h | 2 +- Marlin/src/module/settings.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 9a326fddfa..d97008061f 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -30,7 +30,7 @@ #define tallVersion -//#define ABL_Bilinear +#define ABL_Bilinear /* * Enables a filament sensor plugged into the laser pin. Disables the laser */ @@ -2685,6 +2685,7 @@ * SD Card support is disabled by default. If your controller has an SD slot, * you must uncomment the following option or it won't work. */ +#define SD_SPI_SPEED SPI_HALF_SPEED #define SDSUPPORT /** diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 29df2eeb4e..8e13c15af7 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1610,7 +1610,7 @@ // Allow international symbols in long filenames. To display correctly, the // LCD's font must contain the characters. Check your selected LCD language. - //#define UTF_FILENAME_SUPPORT + #define UTF_FILENAME_SUPPORT #define LONG_FILENAME_HOST_SUPPORT // Get the long filename of a file/folder with 'M33 ' and list long filenames with 'M20 L' //#define LONG_FILENAME_WRITE_SUPPORT // Create / delete files with long filenames via M28, M30, and Binary Transfer Protocol diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 0587c91335..d164054d97 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3231,7 +3231,7 @@ void MarlinSettings::reset() { #if ENABLED(DISTINCT_E_FACTORS) constexpr float linAdvanceK[] = ADVANCE_K; EXTRUDER_LOOP() { - const float a = linAdvanceK[_MAX(e, COUNT(linAdvanceK) - 1)]; + const float a = linAdvanceK[_MAX(e, (int8_t)COUNT(linAdvanceK) - 1)]; planner.extruder_advance_K[e] = a; TERN_(ADVANCE_K_EXTRA, other_extruder_advance_K[e] = a); }