Add pre-calculated planner.e_factor

master
Scott Lahteine 7 years ago
parent 24b302c001
commit 3293823642

@ -215,10 +215,6 @@ extern int16_t feedrate_percentage;
#define MMS_SCALED(MM_S) ((MM_S)*feedrate_percentage*0.01) #define MMS_SCALED(MM_S) ((MM_S)*feedrate_percentage*0.01)
extern bool axis_relative_modes[]; extern bool axis_relative_modes[];
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
extern bool axis_known_position[XYZ]; extern bool axis_known_position[XYZ];
extern bool axis_homed[XYZ]; extern bool axis_homed[XYZ];
extern volatile bool wait_for_heatup; extern volatile bool wait_for_heatup;
@ -427,8 +423,6 @@ extern uint8_t active_extruder;
extern float mixing_factor[MIXING_STEPPERS]; extern float mixing_factor[MIXING_STEPPERS];
#endif #endif
void calculate_volumetric_multipliers();
/** /**
* Blocking movement and shorthand functions * Blocking movement and shorthand functions
*/ */

@ -452,13 +452,10 @@ FORCE_INLINE float homing_feedrate(const AxisEnum a) { return pgm_read_float(&ho
float feedrate_mm_s = MMM_TO_MMS(1500.0); float feedrate_mm_s = MMM_TO_MMS(1500.0);
static float saved_feedrate_mm_s; static float saved_feedrate_mm_s;
int16_t feedrate_percentage = 100, saved_feedrate_percentage, int16_t feedrate_percentage = 100, saved_feedrate_percentage;
flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100);
// Initialized by settings.load() // Initialized by settings.load()
bool axis_relative_modes[] = AXIS_RELATIVE_MODES, bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
volumetric_enabled;
float filament_size[EXTRUDERS], volumetric_multiplier[EXTRUDERS];
#if HAS_WORKSPACE_OFFSET #if HAS_WORKSPACE_OFFSET
#if HAS_POSITION_SHIFT #if HAS_POSITION_SHIFT
@ -3226,7 +3223,7 @@ static void homeaxis(const AxisEnum axis) {
set_destination_from_current(); set_destination_from_current();
stepper.synchronize(); // Wait for buffered moves to complete stepper.synchronize(); // Wait for buffered moves to complete
const float renormalize = 100.0 / flow_percentage[active_extruder] / volumetric_multiplier[active_extruder]; const float renormalize = 1.0 / planner.e_factor[active_extruder];
if (retracting) { if (retracting) {
// Retract by moving from a faux E position back to the current E position // Retract by moving from a faux E position back to the current E position
@ -6553,7 +6550,7 @@ inline void gcode_M17() {
#endif #endif
void do_pause_e_move(const float &length, const float fr) { void do_pause_e_move(const float &length, const float fr) {
current_position[E_AXIS] += length * 100.0 / flow_percentage[active_extruder] / volumetric_multiplier[active_extruder]; current_position[E_AXIS] += length / planner.e_factor[active_extruder];
set_destination_from_current(); set_destination_from_current();
RUNPLAN(fr); RUNPLAN(fr);
stepper.synchronize(); stepper.synchronize();
@ -8832,15 +8829,14 @@ inline void gcode_M200() {
// setting any extruder filament size disables volumetric on the assumption that // setting any extruder filament size disables volumetric on the assumption that
// slicers either generate in extruder values as cubic mm or as as filament feeds // slicers either generate in extruder values as cubic mm or as as filament feeds
// for all extruders // for all extruders
volumetric_enabled = (parser.value_linear_units() != 0.0); if ( (parser.volumetric_enabled = (parser.value_linear_units() != 0.0)) ) {
if (volumetric_enabled) { planner.filament_size[target_extruder] = parser.value_linear_units();
filament_size[target_extruder] = parser.value_linear_units();
// make sure all extruders have some sane value for the filament size // make sure all extruders have some sane value for the filament size
for (uint8_t i = 0; i < COUNT(filament_size); i++) for (uint8_t i = 0; i < COUNT(planner.filament_size); i++)
if (! filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA; if (!planner.filament_size[i]) planner.filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
} }
} }
calculate_volumetric_multipliers(); planner.calculate_volumetric_multipliers();
} }
/** /**
@ -9201,8 +9197,10 @@ inline void gcode_M220() {
*/ */
inline void gcode_M221() { inline void gcode_M221() {
if (get_target_extruder_from_command(221)) return; if (get_target_extruder_from_command(221)) return;
if (parser.seenval('S')) if (parser.seenval('S')) {
flow_percentage[target_extruder] = parser.value_int(); planner.flow_percentage[target_extruder] = parser.value_int();
planner.refresh_e_factor(target_extruder);
}
} }
/** /**
@ -9735,7 +9733,7 @@ inline void gcode_M400() { stepper.synchronize(); }
//SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); //SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
//SERIAL_PROTOCOL(filament_width_meas); //SERIAL_PROTOCOL(filament_width_meas);
//SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); //SERIAL_PROTOCOLPGM("Extrusion ratio(%):");
//SERIAL_PROTOCOL(flow_percentage[active_extruder]); //SERIAL_PROTOCOL(planner.flow_percentage[active_extruder]);
} }
/** /**
@ -9743,7 +9741,7 @@ inline void gcode_M400() { stepper.synchronize(); }
*/ */
inline void gcode_M406() { inline void gcode_M406() {
filament_sensor = false; filament_sensor = false;
calculate_volumetric_multipliers(); // Restore correct 'volumetric_multiplier' value planner.calculate_volumetric_multipliers(); // Restore correct 'volumetric_multiplier' value
} }
/** /**
@ -12967,7 +12965,7 @@ void prepare_move_to_destination() {
} }
#endif // PREVENT_COLD_EXTRUSION #endif // PREVENT_COLD_EXTRUSION
#if ENABLED(PREVENT_LENGTHY_EXTRUDE) #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
if (FABS(destination[E_AXIS] - current_position[E_AXIS]) > (EXTRUDE_MAXLENGTH) / volumetric_multiplier[active_extruder]) { if (FABS(destination[E_AXIS] - current_position[E_AXIS]) * planner.e_factor[active_extruder] > (EXTRUDE_MAXLENGTH)) {
current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
SERIAL_ECHO_START(); SERIAL_ECHO_START();
SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP); SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
@ -13387,16 +13385,6 @@ void prepare_move_to_destination() {
#endif // FAST_PWM_FAN #endif // FAST_PWM_FAN
float calculate_volumetric_multiplier(const float diameter) {
if (!volumetric_enabled || diameter == 0) return 1.0;
return 1.0 / (M_PI * sq(diameter * 0.5));
}
void calculate_volumetric_multipliers() {
for (uint8_t i = 0; i < COUNT(filament_size); i++)
volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
}
void enable_all_steppers() { void enable_all_steppers() {
enable_X(); enable_X();
enable_Y(); enable_Y();

@ -138,8 +138,8 @@
* 533 M208 R swap_retract_recover_feedrate_mm_s (float) * 533 M208 R swap_retract_recover_feedrate_mm_s (float)
* *
* Volumetric Extrusion: 21 bytes * Volumetric Extrusion: 21 bytes
* 537 M200 D volumetric_enabled (bool) * 537 M200 D parser.volumetric_enabled (bool)
* 538 M200 T D filament_size (float x5) (T0..3) * 538 M200 T D planner.filament_size (float x5) (T0..3)
* *
* HAVE_TMC2130: 22 bytes * HAVE_TMC2130: 22 bytes
* 558 M906 X Stepper X current (uint16_t) * 558 M906 X Stepper X current (uint16_t)
@ -188,10 +188,7 @@ MarlinSettings settings;
#include "temperature.h" #include "temperature.h"
#include "ultralcd.h" #include "ultralcd.h"
#include "stepper.h" #include "stepper.h"
#include "gcode.h"
#if ENABLED(INCH_MODE_SUPPORT) || (ENABLED(ULTIPANEL) && ENABLED(TEMPERATURE_UNITS_SUPPORT))
#include "gcode.h"
#endif
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
#include "mesh_bed_leveling.h" #include "mesh_bed_leveling.h"
@ -238,7 +235,7 @@ void MarlinSettings::postprocess() {
thermalManager.updatePID(); thermalManager.updatePID();
#endif #endif
calculate_volumetric_multipliers(); planner.calculate_volumetric_multipliers();
#if HAS_HOME_OFFSET || ENABLED(DUAL_X_CARRIAGE) #if HAS_HOME_OFFSET || ENABLED(DUAL_X_CARRIAGE)
// Software endstops depend on home_offset // Software endstops depend on home_offset
@ -569,11 +566,11 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(swap_retract_recover_length); EEPROM_WRITE(swap_retract_recover_length);
EEPROM_WRITE(swap_retract_recover_feedrate_mm_s); EEPROM_WRITE(swap_retract_recover_feedrate_mm_s);
EEPROM_WRITE(volumetric_enabled); EEPROM_WRITE(parser.volumetric_enabled);
// Save filament sizes // Save filament sizes
for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) { for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
if (q < COUNT(filament_size)) dummy = filament_size[q]; if (q < COUNT(planner.filament_size)) dummy = planner.filament_size[q];
EEPROM_WRITE(dummy); EEPROM_WRITE(dummy);
} }
@ -1018,10 +1015,10 @@ void MarlinSettings::postprocess() {
// Volumetric & Filament Size // Volumetric & Filament Size
// //
EEPROM_READ(volumetric_enabled); EEPROM_READ(parser.volumetric_enabled);
for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) { for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
EEPROM_READ(dummy); EEPROM_READ(dummy);
if (q < COUNT(filament_size)) filament_size[q] = dummy; if (q < COUNT(planner.filament_size)) planner.filament_size[q] = dummy;
} }
// //
@ -1424,15 +1421,15 @@ void MarlinSettings::reset() {
swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP; swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
#endif // FWRETRACT #endif // FWRETRACT
volumetric_enabled = parser.volumetric_enabled =
#if ENABLED(VOLUMETRIC_DEFAULT_ON) #if ENABLED(VOLUMETRIC_DEFAULT_ON)
true true
#else #else
false false
#endif #endif
; ;
for (uint8_t q = 0; q < COUNT(filament_size); q++) for (uint8_t q = 0; q < COUNT(planner.filament_size); q++)
filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA; planner.filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
endstops.enable_globally( endstops.enable_globally(
#if ENABLED(ENDSTOPS_ALWAYS_ON_DEFAULT) #if ENABLED(ENDSTOPS_ALWAYS_ON_DEFAULT)
@ -1515,7 +1512,7 @@ void MarlinSettings::reset() {
CONFIG_ECHO_START; CONFIG_ECHO_START;
#if ENABLED(INCH_MODE_SUPPORT) #if ENABLED(INCH_MODE_SUPPORT)
#define LINEAR_UNIT(N) ((N) / parser.linear_unit_factor) #define LINEAR_UNIT(N) ((N) / parser.linear_unit_factor)
#define VOLUMETRIC_UNIT(N) ((N) / (volumetric_enabled ? parser.volumetric_unit_factor : parser.linear_unit_factor)) #define VOLUMETRIC_UNIT(N) ((N) / (parser.volumetric_enabled ? parser.volumetric_unit_factor : parser.linear_unit_factor))
SERIAL_ECHOPGM(" G2"); SERIAL_ECHOPGM(" G2");
SERIAL_CHAR(parser.linear_unit_factor == 1.0 ? '1' : '0'); SERIAL_CHAR(parser.linear_unit_factor == 1.0 ? '1' : '0');
SERIAL_ECHOPGM(" ; Units in "); SERIAL_ECHOPGM(" ; Units in ");
@ -1552,37 +1549,37 @@ void MarlinSettings::reset() {
if (!forReplay) { if (!forReplay) {
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPGM("Filament settings:"); SERIAL_ECHOPGM("Filament settings:");
if (volumetric_enabled) if (parser.volumetric_enabled)
SERIAL_EOL(); SERIAL_EOL();
else else
SERIAL_ECHOLNPGM(" Disabled"); SERIAL_ECHOLNPGM(" Disabled");
} }
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" M200 D", filament_size[0]); SERIAL_ECHOPAIR(" M200 D", planner.filament_size[0]);
SERIAL_EOL(); SERIAL_EOL();
#if EXTRUDERS > 1 #if EXTRUDERS > 1
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]); SERIAL_ECHOPAIR(" M200 T1 D", planner.filament_size[1]);
SERIAL_EOL(); SERIAL_EOL();
#if EXTRUDERS > 2 #if EXTRUDERS > 2
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]); SERIAL_ECHOPAIR(" M200 T2 D", planner.filament_size[2]);
SERIAL_EOL(); SERIAL_EOL();
#if EXTRUDERS > 3 #if EXTRUDERS > 3
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" M200 T3 D", filament_size[3]); SERIAL_ECHOPAIR(" M200 T3 D", planner.filament_size[3]);
SERIAL_EOL(); SERIAL_EOL();
#if EXTRUDERS > 4 #if EXTRUDERS > 4
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" M200 T4 D", filament_size[4]); SERIAL_ECHOPAIR(" M200 T4 D", planner.filament_size[4]);
SERIAL_EOL(); SERIAL_EOL();
#endif // EXTRUDERS > 4 #endif // EXTRUDERS > 4
#endif // EXTRUDERS > 3 #endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2 #endif // EXTRUDERS > 2
#endif // EXTRUDERS > 1 #endif // EXTRUDERS > 1
if (!volumetric_enabled) { if (!parser.volumetric_enabled) {
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOLNPGM(" M200 D0"); SERIAL_ECHOLNPGM(" M200 D0");
} }

@ -32,6 +32,8 @@
// Must be declared for allocation and to satisfy the linker // Must be declared for allocation and to satisfy the linker
// Zero values need no initialization. // Zero values need no initialization.
bool GCodeParser::volumetric_enabled;
#if ENABLED(INCH_MODE_SUPPORT) #if ENABLED(INCH_MODE_SUPPORT)
float GCodeParser::linear_unit_factor, GCodeParser::volumetric_unit_factor; float GCodeParser::linear_unit_factor, GCodeParser::volumetric_unit_factor;
#endif #endif

@ -44,10 +44,6 @@
#include "serial.h" #include "serial.h"
#endif #endif
#if ENABLED(INCH_MODE_SUPPORT)
extern bool volumetric_enabled;
#endif
/** /**
* GCode parser * GCode parser
* *
@ -76,6 +72,8 @@ public:
// Global states for GCode-level units features // Global states for GCode-level units features
static bool volumetric_enabled;
#if ENABLED(INCH_MODE_SUPPORT) #if ENABLED(INCH_MODE_SUPPORT)
static float linear_unit_factor, volumetric_unit_factor; static float linear_unit_factor, volumetric_unit_factor;
#endif #endif

@ -91,6 +91,12 @@ float Planner::max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second
uint8_t Planner::last_extruder = 0; // Respond to extruder change uint8_t Planner::last_extruder = 0; // Respond to extruder change
#endif #endif
int16_t Planner::flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100); // Extrusion factor for each extruder
float Planner::e_factor[EXTRUDERS], // The flow percentage and volumetric multiplier combine to scale E movement
Planner::filament_size[EXTRUDERS], // diameter of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder
Planner::volumetric_multiplier[EXTRUDERS]; // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner
uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N], uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N],
Planner::max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software Planner::max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
@ -521,6 +527,18 @@ void Planner::check_axes_activity() {
#endif #endif
} }
inline float calculate_volumetric_multiplier(const float &diameter) {
if (!parser.volumetric_enabled || diameter == 0) return 1.0;
return 1.0 / CIRCLE_AREA(diameter * 0.5);
}
void Planner::calculate_volumetric_multipliers() {
for (uint8_t i = 0; i < COUNT(filament_size); i++) {
volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
refresh_e_factor(i);
}
}
#if PLANNER_LEVELING #if PLANNER_LEVELING
/** /**
* rx, ry, rz - cartesian position in mm * rx, ry, rz - cartesian position in mm
@ -719,10 +737,8 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
long de = target[E_AXIS] - position[E_AXIS]; long de = target[E_AXIS] - position[E_AXIS];
const float e_factor = volumetric_multiplier[extruder] * flow_percentage[extruder] * 0.01;
#if ENABLED(LIN_ADVANCE) #if ENABLED(LIN_ADVANCE)
float de_float = e - position_float[E_AXIS]; float de_float = e - position_float[E_AXIS]; // Should this include e_factor?
#endif #endif
#if ENABLED(PREVENT_COLD_EXTRUSION) || ENABLED(PREVENT_LENGTHY_EXTRUDE) #if ENABLED(PREVENT_COLD_EXTRUSION) || ENABLED(PREVENT_LENGTHY_EXTRUDE)
@ -740,8 +756,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
} }
#endif // PREVENT_COLD_EXTRUSION #endif // PREVENT_COLD_EXTRUSION
#if ENABLED(PREVENT_LENGTHY_EXTRUDE) #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
const int32_t de_mm = labs(de * e_factor); if (labs(de * e_factor[extruder]) > (int32_t)axis_steps_per_mm[E_AXIS_N] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
if (de_mm > (int32_t)axis_steps_per_mm[E_AXIS_N] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
de = 0; // no difference de = 0; // no difference
#if ENABLED(LIN_ADVANCE) #if ENABLED(LIN_ADVANCE)
@ -782,7 +797,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
#endif #endif
if (de < 0) SBI(dm, E_AXIS); if (de < 0) SBI(dm, E_AXIS);
const float esteps_float = de * e_factor; const float esteps_float = de * e_factor[extruder];
const int32_t esteps = abs(esteps_float) + 0.5; const int32_t esteps = abs(esteps_float) + 0.5;
// Calculate the buffer head after we push this byte // Calculate the buffer head after we push this byte

@ -140,6 +140,13 @@ class Planner {
static uint8_t last_extruder; // Respond to extruder change static uint8_t last_extruder; // Respond to extruder change
#endif #endif
static int16_t flow_percentage[EXTRUDERS]; // Extrusion factor for each extruder
static float e_factor[EXTRUDERS], // The flow percentage and volumetric multiplier combine to scale E movement
filament_size[EXTRUDERS], // diameter of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder
volumetric_multiplier[EXTRUDERS]; // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner
// May be auto-adjusted by a filament width sensor
static float max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second static float max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second
axis_steps_per_mm[XYZE_N], axis_steps_per_mm[XYZE_N],
steps_to_mm[XYZE_N]; steps_to_mm[XYZE_N];
@ -236,9 +243,15 @@ class Planner {
static void reset_acceleration_rates(); static void reset_acceleration_rates();
static void refresh_positioning(); static void refresh_positioning();
FORCE_INLINE static void refresh_e_factor(const uint8_t e) {
e_factor[e] = volumetric_multiplier[e] * flow_percentage[e] * 0.01;
}
// Manage fans, paste pressure, etc. // Manage fans, paste pressure, etc.
static void check_axes_activity(); static void check_axes_activity();
static void calculate_volumetric_multipliers();
/** /**
* Number of moves currently in the planner * Number of moves currently in the planner
*/ */

@ -815,7 +815,8 @@ void Temperature::manage_heater() {
// Get the delayed info and add 100 to reconstitute to a percent of // Get the delayed info and add 100 to reconstitute to a percent of
// the nominal filament diameter then square it to get an area // the nominal filament diameter then square it to get an area
const float vmroot = measurement_delay[meas_shift_index] * 0.01 + 1.0; const float vmroot = measurement_delay[meas_shift_index] * 0.01 + 1.0;
volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vmroot <= 0.1 ? 0.01 : sq(vmroot); planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vmroot <= 0.1 ? 0.01 : sq(vmroot);
planner.refresh_e_factor(FILAMENT_SENSOR_EXTRUDER_NUM);
} }
#endif // FILAMENT_WIDTH_SENSOR #endif // FILAMENT_WIDTH_SENSOR

@ -33,6 +33,7 @@
#include "stepper.h" #include "stepper.h"
#include "configuration_store.h" #include "configuration_store.h"
#include "utility.h" #include "utility.h"
#include "gcode.h"
#if HAS_BUZZER && DISABLED(LCD_USE_I2C_BUZZER) #if HAS_BUZZER && DISABLED(LCD_USE_I2C_BUZZER)
#include "buzzer.h" #include "buzzer.h"
@ -1248,6 +1249,22 @@ void kill_screen(const char* lcd_msg) {
#endif #endif
#endif #endif
// Refresh the E factor after changing flow
inline void _lcd_refresh_e_factor_0() { planner.refresh_e_factor(0); }
#if EXTRUDERS > 1
inline void _lcd_refresh_e_factor() { planner.refresh_e_factor(active_extruder); }
inline void _lcd_refresh_e_factor_1() { planner.refresh_e_factor(1); }
#if EXTRUDERS > 2
inline void _lcd_refresh_e_factor_2() { planner.refresh_e_factor(2); }
#if EXTRUDERS > 3
inline void _lcd_refresh_e_factor_3() { planner.refresh_e_factor(3); }
#if EXTRUDERS > 4
inline void _lcd_refresh_e_factor_4() { planner.refresh_e_factor(4); }
#endif // EXTRUDERS > 4
#endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2
#endif // EXTRUDERS > 1
/** /**
* *
* "Tune" submenu * "Tune" submenu
@ -1327,17 +1344,17 @@ void kill_screen(const char* lcd_msg) {
// Flow [1-5]: // Flow [1-5]:
// //
#if EXTRUDERS == 1 #if EXTRUDERS == 1
MENU_ITEM_EDIT(int3, MSG_FLOW, &flow_percentage[0], 10, 999); MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW, &planner.flow_percentage[0], 10, 999, _lcd_refresh_e_factor_0);
#else // EXTRUDERS > 1 #else // EXTRUDERS > 1
MENU_ITEM_EDIT(int3, MSG_FLOW, &flow_percentage[active_extruder], 10, 999); MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, _lcd_refresh_e_factor);
MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N1, &flow_percentage[0], 10, 999); MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N1, &planner.flow_percentage[0], 10, 999, _lcd_refresh_e_factor_0);
MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N2, &flow_percentage[1], 10, 999); MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N2, &planner.flow_percentage[1], 10, 999, _lcd_refresh_e_factor_1);
#if EXTRUDERS > 2 #if EXTRUDERS > 2
MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N3, &flow_percentage[2], 10, 999); MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N3, &planner.flow_percentage[2], 10, 999, _lcd_refresh_e_factor_2);
#if EXTRUDERS > 3 #if EXTRUDERS > 3
MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N4, &flow_percentage[3], 10, 999); MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N4, &planner.flow_percentage[3], 10, 999, _lcd_refresh_e_factor_3);
#if EXTRUDERS > 4 #if EXTRUDERS > 4
MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N5, &flow_percentage[4], 10, 999); MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N5, &planner.flow_percentage[4], 10, 999, _lcd_refresh_e_factor_4);
#endif // EXTRUDERS > 4 #endif // EXTRUDERS > 4
#endif // EXTRUDERS > 3 #endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2 #endif // EXTRUDERS > 2
@ -3678,20 +3695,20 @@ void kill_screen(const char* lcd_msg) {
MENU_ITEM_EDIT(float3, MSG_ADVANCE_K, &planner.extruder_advance_k, 0, 999); MENU_ITEM_EDIT(float3, MSG_ADVANCE_K, &planner.extruder_advance_k, 0, 999);
#endif #endif
MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &volumetric_enabled, calculate_volumetric_multipliers); MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &parser.volumetric_enabled, planner.calculate_volumetric_multipliers);
if (volumetric_enabled) { if (parser.volumetric_enabled) {
#if EXTRUDERS == 1 #if EXTRUDERS == 1
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &filament_size[0], 1.5, 3.25, calculate_volumetric_multipliers); MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &planner.filament_size[0], 1.5, 3.25, planner.calculate_volumetric_multipliers);
#else // EXTRUDERS > 1 #else // EXTRUDERS > 1
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E1, &filament_size[0], 1.5, 3.25, calculate_volumetric_multipliers); MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E1, &planner.filament_size[0], 1.5, 3.25, planner.calculate_volumetric_multipliers);
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E2, &filament_size[1], 1.5, 3.25, calculate_volumetric_multipliers); MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E2, &planner.filament_size[1], 1.5, 3.25, planner.calculate_volumetric_multipliers);
#if EXTRUDERS > 2 #if EXTRUDERS > 2
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E3, &filament_size[2], 1.5, 3.25, calculate_volumetric_multipliers); MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E3, &planner.filament_size[2], 1.5, 3.25, planner.calculate_volumetric_multipliers);
#if EXTRUDERS > 3 #if EXTRUDERS > 3
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E4, &filament_size[3], 1.5, 3.25, calculate_volumetric_multipliers); MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E4, &planner.filament_size[3], 1.5, 3.25, planner.calculate_volumetric_multipliers);
#if EXTRUDERS > 4 #if EXTRUDERS > 4
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E5, &filament_size[4], 1.5, 3.25, calculate_volumetric_multipliers); MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E5, &planner.filament_size[4], 1.5, 3.25, planner.calculate_volumetric_multipliers);
#endif // EXTRUDERS > 4 #endif // EXTRUDERS > 4
#endif // EXTRUDERS > 3 #endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2 #endif // EXTRUDERS > 2

@ -650,7 +650,7 @@ static void lcd_implementation_status_screen() {
strcpy(zstring, ftostr52sp(FIXFLOAT(LOGICAL_Z_POSITION(current_position[Z_AXIS])))); strcpy(zstring, ftostr52sp(FIXFLOAT(LOGICAL_Z_POSITION(current_position[Z_AXIS]))));
#if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT) #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
strcpy(wstring, ftostr12ns(filament_width_meas)); strcpy(wstring, ftostr12ns(filament_width_meas));
strcpy(mstring, itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM])); strcpy(mstring, itostr3(100.0 * planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
#endif #endif
} }
@ -739,7 +739,7 @@ static void lcd_implementation_status_screen() {
lcd_print(ftostr12ns(filament_width_meas)); lcd_print(ftostr12ns(filament_width_meas));
lcd_printPGM(PSTR(" " LCD_STR_FILAM_MUL)); lcd_printPGM(PSTR(" " LCD_STR_FILAM_MUL));
u8g.print(':'); u8g.print(':');
lcd_print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM])); lcd_print(itostr3(100.0 * planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
u8g.print('%'); u8g.print('%');
} }
#else #else

@ -857,7 +857,7 @@ static void lcd_implementation_status_screen() {
lcd_printPGM(PSTR("Dia ")); lcd_printPGM(PSTR("Dia "));
lcd.print(ftostr12ns(filament_width_meas)); lcd.print(ftostr12ns(filament_width_meas));
lcd_printPGM(PSTR(" V")); lcd_printPGM(PSTR(" V"));
lcd.print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM])); lcd.print(itostr3(100.0 * planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
lcd.write('%'); lcd.write('%');
return; return;
} }

Loading…
Cancel
Save