Move flow_percentage to Planner

This commit is contained in:
Scott Lahteine 2017-09-08 23:50:46 -05:00
parent 8dc2838d98
commit bf7af95db3
8 changed files with 19 additions and 16 deletions

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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();
}

View file

@ -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]);
}

View file

@ -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

View file

@ -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

View file

@ -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];