New Continuous Filament Mixer (#12098)
This commit is contained in:
@ -643,7 +643,7 @@ void GcodeSuite::G33() {
|
||||
|
||||
if (verbose_level != 0) { // !dry run
|
||||
|
||||
// normalise angles to least squares
|
||||
// Normalize angles to least-squares
|
||||
if (_angle_results) {
|
||||
float a_sum = 0.0;
|
||||
LOOP_XYZ(axis) a_sum += delta_tower_angle_trim[axis];
|
||||
|
@ -30,7 +30,7 @@
|
||||
/**
|
||||
* M163: Set a single mix factor for a mixing extruder
|
||||
* This is called "weight" by some systems.
|
||||
* The 'P' values must sum to 1.0 or must be followed by M164 to normalize them.
|
||||
* Must be followed by M164 to normalize and commit them.
|
||||
*
|
||||
* S[index] The channel index to set
|
||||
* P[float] The mix value
|
||||
@ -38,24 +38,23 @@
|
||||
void GcodeSuite::M163() {
|
||||
const int mix_index = parser.intval('S');
|
||||
if (mix_index < MIXING_STEPPERS)
|
||||
mixing_factor[mix_index] = MAX(parser.floatval('P'), 0.0);
|
||||
mixer.set_M163_collector(mix_index, MAX(parser.floatval('P'), 0.0));
|
||||
}
|
||||
|
||||
/**
|
||||
* M164: Normalize and commit the mix.
|
||||
* If 'S' is given store as a virtual tool. (Requires MIXING_VIRTUAL_TOOLS > 1)
|
||||
* If 'S' is given store as a virtual tool. Else in T0.
|
||||
*
|
||||
* S[index] The virtual tool to store
|
||||
*/
|
||||
void GcodeSuite::M164() {
|
||||
normalize_mix();
|
||||
#if MIXING_VIRTUAL_TOOLS > 1
|
||||
const int tool_index = parser.intval('S', -1);
|
||||
if (WITHIN(tool_index, 0, MIXING_VIRTUAL_TOOLS - 1)) {
|
||||
for (uint8_t i = 0; i < MIXING_STEPPERS; i++)
|
||||
mixing_virtual_tool_mix[tool_index][i] = mixing_factor[i];
|
||||
}
|
||||
#else
|
||||
constexpr int tool_index = 0;
|
||||
#endif
|
||||
if (WITHIN(tool_index, 0, MIXING_VIRTUAL_TOOLS - 1))
|
||||
mixer.normalize(tool_index);
|
||||
}
|
||||
|
||||
#if ENABLED(DIRECT_MIXING_IN_G1)
|
||||
@ -63,7 +62,7 @@ void GcodeSuite::M164() {
|
||||
/**
|
||||
* M165: Set multiple mix factors for a mixing extruder.
|
||||
* Factors that are left out will be set to 0.
|
||||
* All factors should sum to 1.0, but they will be normalized regardless.
|
||||
* All factors will be normalized and stored in the current v-tool.
|
||||
*
|
||||
* A[factor] Mix factor for extruder stepper 1
|
||||
* B[factor] Mix factor for extruder stepper 2
|
||||
@ -72,7 +71,39 @@ void GcodeSuite::M164() {
|
||||
* H[factor] Mix factor for extruder stepper 5
|
||||
* I[factor] Mix factor for extruder stepper 6
|
||||
*/
|
||||
void GcodeSuite::M165() { gcode_get_mix(); }
|
||||
void GcodeSuite::M165() {
|
||||
// Get mixing parameters from the GCode
|
||||
// The total "must" be 1.0 (but it will be normalized)
|
||||
// If no mix factors are given, the old mix is preserved
|
||||
const char mixing_codes[] = { 'A', 'B'
|
||||
#if MIXING_STEPPERS > 2
|
||||
, 'C'
|
||||
#if MIXING_STEPPERS > 3
|
||||
, 'D'
|
||||
#if MIXING_STEPPERS > 4
|
||||
, 'H'
|
||||
#if MIXING_STEPPERS > 5
|
||||
, 'I'
|
||||
#endif // MIXING_STEPPERS > 5
|
||||
#endif // MIXING_STEPPERS > 4
|
||||
#endif // MIXING_STEPPERS > 3
|
||||
#endif // MIXING_STEPPERS > 2
|
||||
};
|
||||
uint8_t mix_bits = 0;
|
||||
MIXER_STEPPER_LOOP(i) {
|
||||
if (parser.seenval(mixing_codes[i])) {
|
||||
SBI(mix_bits, i);
|
||||
mixer.set_M163_collector(i, MAX(parser.value_float(), 0.0f));
|
||||
}
|
||||
}
|
||||
// If any mixing factors were included, clear the rest
|
||||
// If none were included, preserve the last mix
|
||||
if (mix_bits) {
|
||||
MIXER_STEPPER_LOOP(i)
|
||||
if (!TEST(mix_bits, i)) mixer.set_M163_collector(i, 0.0f);
|
||||
mixer.normalize(mixer.get_current_v_tool());
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DIRECT_MIXING_IN_G1
|
||||
|
||||
|
@ -36,10 +36,6 @@ GcodeSuite gcode;
|
||||
#include "../module/printcounter.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(DIRECT_MIXING_IN_G1)
|
||||
#include "../feature/mixing.h"
|
||||
#endif
|
||||
|
||||
#include "../Marlin.h" // for idle() and suspend_auto_report
|
||||
|
||||
uint8_t GcodeSuite::target_extruder;
|
||||
@ -113,7 +109,7 @@ void GcodeSuite::get_destination_from_command() {
|
||||
|
||||
// Get ABCDHI mixing factors
|
||||
#if ENABLED(MIXING_EXTRUDER) && ENABLED(DIRECT_MIXING_IN_G1)
|
||||
gcode_get_mix();
|
||||
M165();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -441,9 +437,7 @@ void GcodeSuite::process_parsed_command(
|
||||
|
||||
#if ENABLED(MIXING_EXTRUDER)
|
||||
case 163: M163(); break; // M163: Set a component weight for mixing extruder
|
||||
#if MIXING_VIRTUAL_TOOLS > 1
|
||||
case 164: M164(); break; // M164: Save current mix as a virtual extruder
|
||||
#endif
|
||||
case 164: M164(); break; // M164: Save current mix as a virtual extruder
|
||||
#if ENABLED(DIRECT_MIXING_IN_G1)
|
||||
case 165: M165(); break; // M165: Set multiple mix weights
|
||||
#endif
|
||||
|
@ -146,8 +146,8 @@
|
||||
* M150 - Set Status LED Color as R<red> U<green> B<blue> P<bright>. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED, or PCA9632).
|
||||
* M155 - Auto-report temperatures with interval of S<seconds>. (Requires AUTO_REPORT_TEMPERATURES)
|
||||
* M163 - Set a single proportion for a mixing extruder. (Requires MIXING_EXTRUDER)
|
||||
* M164 - Commit the mix (Req. MIXING_EXTRUDER) and optionally save as a virtual tool (Req. MIXING_VIRTUAL_TOOLS > 1)
|
||||
* M165 - Set the mix for a mixing extruder wuth parameters ABCDHI. (Requires MIXING_EXTRUDER and DIRECT_MIXING_IN_G1)
|
||||
* M164 - Commit the mix (Req. MIXING_EXTRUDER) and optionally save as a virtual tool (Requires MIXING_EXTRUDER)
|
||||
* M165 - Set the mix for a mixing extruder with parameters ABCDHI. (Requires MIXING_EXTRUDER and DIRECT_MIXING_IN_G1)
|
||||
* M190 - Sxxx Wait for bed current temp to reach target temp. ** Waits only when heating! **
|
||||
* Rxxx Wait for bed current temp to reach target temp. ** Waits for heating or cooling. **
|
||||
* M200 - Set filament diameter, D<diameter>, setting E axis units to cubic. (Use S0 to revert to linear units.)
|
||||
@ -581,9 +581,7 @@ private:
|
||||
|
||||
#if ENABLED(MIXING_EXTRUDER)
|
||||
static void M163();
|
||||
#if MIXING_VIRTUAL_TOOLS > 1
|
||||
static void M164();
|
||||
#endif
|
||||
static void M164();
|
||||
#if ENABLED(DIRECT_MIXING_IN_G1)
|
||||
static void M165();
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user