Move volumetric flag to GCodeParser
This commit is contained in:
parent
bf7af95db3
commit
63228fc453
7 changed files with 17 additions and 21 deletions
|
@ -169,7 +169,6 @@ static float saved_feedrate_mm_s;
|
||||||
int16_t feedrate_percentage = 100, saved_feedrate_percentage;
|
int16_t feedrate_percentage = 100, saved_feedrate_percentage;
|
||||||
|
|
||||||
// Initialized by settings.load()
|
// Initialized by settings.load()
|
||||||
bool volumetric_enabled;
|
|
||||||
float filament_size[EXTRUDERS], volumetric_multiplier[EXTRUDERS];
|
float filament_size[EXTRUDERS], volumetric_multiplier[EXTRUDERS];
|
||||||
|
|
||||||
#if HAS_WORKSPACE_OFFSET
|
#if HAS_WORKSPACE_OFFSET
|
||||||
|
@ -3295,7 +3294,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
||||||
#endif // FILAMENT_RUNOUT_SENSOR
|
#endif // FILAMENT_RUNOUT_SENSOR
|
||||||
|
|
||||||
float calculate_volumetric_multiplier(const float diameter) {
|
float calculate_volumetric_multiplier(const float diameter) {
|
||||||
if (!volumetric_enabled || diameter == 0) return 1.0;
|
if (!parser.volumetric_enabled || diameter == 0) return 1.0;
|
||||||
return 1.0 / (M_PI * sq(diameter * 0.5));
|
return 1.0 / (M_PI * sq(diameter * 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,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 volumetric_enabled;
|
|
||||||
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 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 float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,8 @@ void GcodeSuite::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);
|
parser.volumetric_enabled = (parser.value_linear_units() != 0.0);
|
||||||
if (volumetric_enabled) {
|
if (parser.volumetric_enabled) {
|
||||||
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(filament_size); i++)
|
||||||
|
|
|
@ -35,6 +35,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
|
||||||
|
|
|
@ -33,10 +33,6 @@
|
||||||
|
|
||||||
//#define DEBUG_GCODE_PARSER
|
//#define DEBUG_GCODE_PARSER
|
||||||
|
|
||||||
#if ENABLED(INCH_MODE_SUPPORT)
|
|
||||||
extern bool volumetric_enabled;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GCode parser
|
* GCode parser
|
||||||
*
|
*
|
||||||
|
@ -65,6 +61,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
|
||||||
|
|
|
@ -3445,9 +3445,9 @@ 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, 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, &filament_size[0], 1.5, 3.25, calculate_volumetric_multipliers);
|
||||||
#else // EXTRUDERS > 1
|
#else // EXTRUDERS > 1
|
||||||
|
|
|
@ -137,7 +137,7 @@
|
||||||
* 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 filament_size (float x5) (T0..3)
|
||||||
*
|
*
|
||||||
* HAVE_TMC2130: 20 bytes
|
* HAVE_TMC2130: 20 bytes
|
||||||
|
@ -185,9 +185,7 @@ MarlinSettings settings;
|
||||||
#include "../core/language.h"
|
#include "../core/language.h"
|
||||||
#include "../Marlin.h"
|
#include "../Marlin.h"
|
||||||
|
|
||||||
#if ENABLED(INCH_MODE_SUPPORT) || (ENABLED(ULTIPANEL) && ENABLED(TEMPERATURE_UNITS_SUPPORT))
|
|
||||||
#include "../gcode/parser.h"
|
#include "../gcode/parser.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAS_BED_PROBE
|
#if HAS_BED_PROBE
|
||||||
#include "../module/probe.h"
|
#include "../module/probe.h"
|
||||||
|
@ -511,7 +509,7 @@ void MarlinSettings::postprocess() {
|
||||||
EEPROM_WRITE(fwretract.swap_retract_recover_feedrate_mm_s);
|
EEPROM_WRITE(fwretract.swap_retract_recover_feedrate_mm_s);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
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++) {
|
||||||
|
@ -897,7 +895,7 @@ void MarlinSettings::postprocess() {
|
||||||
for (uint8_t q=8; q--;) EEPROM_READ(dummy);
|
for (uint8_t q=8; q--;) EEPROM_READ(dummy);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
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);
|
||||||
|
@ -1259,7 +1257,7 @@ void MarlinSettings::reset() {
|
||||||
fwretract.reset();
|
fwretract.reset();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
volumetric_enabled =
|
parser.volumetric_enabled =
|
||||||
#if ENABLED(VOLUMETRIC_DEFAULT_ON)
|
#if ENABLED(VOLUMETRIC_DEFAULT_ON)
|
||||||
true
|
true
|
||||||
#else
|
#else
|
||||||
|
@ -1350,7 +1348,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 ");
|
||||||
|
@ -1387,7 +1385,7 @@ 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");
|
||||||
|
@ -1417,7 +1415,7 @@ void MarlinSettings::reset() {
|
||||||
#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");
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue