diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 10c223849a..f93f3115df 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -166,8 +166,7 @@ static const float homing_feedrate_mm_s[] PROGMEM = { FORCE_INLINE float homing_feedrate(const AxisEnum a) { return pgm_read_float(&homing_feedrate_mm_s[a]); } static float saved_feedrate_mm_s; -int16_t feedrate_percentage = 100, saved_feedrate_percentage, - flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100); +int16_t feedrate_percentage = 100, saved_feedrate_percentage; // Initialized by settings.load() bool volumetric_enabled; diff --git a/Marlin/src/Marlin.h b/Marlin/src/Marlin.h index 527a030e12..0d84af3d6c 100644 --- a/Marlin/src/Marlin.h +++ b/Marlin/src/Marlin.h @@ -187,7 +187,6 @@ extern int16_t feedrate_percentage; #define MMS_SCALED(MM_S) ((MM_S)*feedrate_percentage*0.01) extern bool volumetric_enabled; -extern int16_t flow_percentage[EXTRUDERS]; // Extrusion factor for each extruder extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder. extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner diff --git a/Marlin/src/feature/fwretract.cpp b/Marlin/src/feature/fwretract.cpp index 60191f84e8..421761b666 100644 --- a/Marlin/src/feature/fwretract.cpp +++ b/Marlin/src/feature/fwretract.cpp @@ -33,6 +33,7 @@ FWRetract fwretract; // Single instance #include "../module/motion.h" +#include "../module/planner.h" bool FWRetract::autoretract_enabled, // M209 S - Autoretract switch FWRetract::retracted[EXTRUDERS] = { false }; // Which extruders are currently retracted @@ -108,10 +109,10 @@ void FWRetract::retract(const bool retracting const bool has_zhop = retract_zlift > 0.01; // Is there a hop set? const float old_feedrate_mm_s = feedrate_mm_s; - const int16_t old_flow = flow_percentage[active_extruder]; + const int16_t old_flow = planner.flow_percentage[active_extruder]; // Don't apply flow multiplication to retract/recover - flow_percentage[active_extruder] = 100; + planner.flow_percentage[active_extruder] = 100; // The current position will be the destination for E and Z moves set_destination_to_current(); @@ -155,7 +156,7 @@ void FWRetract::retract(const bool retracting } // Restore flow and feedrate - flow_percentage[active_extruder] = old_flow; + planner.flow_percentage[active_extruder] = old_flow; feedrate_mm_s = old_feedrate_mm_s; // The active extruder is now retracted or recovered diff --git a/Marlin/src/gcode/config/M221.cpp b/Marlin/src/gcode/config/M221.cpp index f62903e86f..74fd127d74 100644 --- a/Marlin/src/gcode/config/M221.cpp +++ b/Marlin/src/gcode/config/M221.cpp @@ -21,7 +21,7 @@ */ #include "../gcode.h" -#include "../../Marlin.h" +#include "../../module/planner.h" /** * M221: Set extrusion percentage (M221 T0 S95) @@ -29,5 +29,5 @@ void GcodeSuite::M221() { if (get_target_extruder_from_command()) return; if (parser.seenval('S')) - flow_percentage[target_extruder] = parser.value_int(); + planner.flow_percentage[target_extruder] = parser.value_int(); } diff --git a/Marlin/src/gcode/sensor/M405.h b/Marlin/src/gcode/sensor/M405.h index ed7496e9b6..bd1ed80880 100644 --- a/Marlin/src/gcode/sensor/M405.h +++ b/Marlin/src/gcode/sensor/M405.h @@ -45,5 +45,5 @@ void gcode_M405() { //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); //SERIAL_PROTOCOL(filament_width_meas); //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); - //SERIAL_PROTOCOL(flow_percentage[active_extruder]); + //SERIAL_PROTOCOL(planner.flow_percentage[active_extruder]); } diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 72a2288c61..d796f45faa 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -1224,17 +1224,17 @@ void kill_screen(const char* lcd_msg) { // Flow [1-5]: // #if EXTRUDERS == 1 - MENU_ITEM_EDIT(int3, MSG_FLOW, &flow_percentage[0], 10, 999); + MENU_ITEM_EDIT(int3, MSG_FLOW, &planner.flow_percentage[0], 10, 999); #else // EXTRUDERS > 1 - MENU_ITEM_EDIT(int3, MSG_FLOW, &flow_percentage[active_extruder], 10, 999); - MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N1, &flow_percentage[0], 10, 999); - MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N2, &flow_percentage[1], 10, 999); + MENU_ITEM_EDIT(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999); + MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N1, &planner.flow_percentage[0], 10, 999); + MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N2, &planner.flow_percentage[1], 10, 999); #if EXTRUDERS > 2 - MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N3, &flow_percentage[2], 10, 999); + MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N3, &planner.flow_percentage[2], 10, 999); #if EXTRUDERS > 3 - MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N4, &flow_percentage[3], 10, 999); + MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N4, &planner.flow_percentage[3], 10, 999); #if EXTRUDERS > 4 - MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N5, &flow_percentage[4], 10, 999); + MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N5, &planner.flow_percentage[4], 10, 999); #endif // EXTRUDERS > 4 #endif // EXTRUDERS > 3 #endif // EXTRUDERS > 2 diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index c239b324b4..6e5aca6c1c 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -92,6 +92,8 @@ float Planner::max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second uint8_t Planner::last_extruder = 0; // Respond to extruder change #endif +int16_t Planner::flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100); // Extrusion factor for each extruder + uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N], Planner::max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index bd6a86da40..3ac5784e1c 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -143,6 +143,8 @@ class Planner { static uint8_t last_extruder; // Respond to extruder change #endif + static int16_t flow_percentage[EXTRUDERS]; // Extrusion factor for each extruder + static float max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second axis_steps_per_mm[XYZE_N], steps_to_mm[XYZE_N];