update code base to Marlin 2.0.9.2
This commit is contained in:
68
Marlin/src/feature/mixing.cpp
Executable file → Normal file
68
Marlin/src/feature/mixing.cpp
Executable file → Normal file
@@ -16,7 +16,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -44,7 +44,7 @@ int_fast8_t Mixer::runner = 0;
|
||||
mixer_comp_t Mixer::s_color[MIXING_STEPPERS];
|
||||
mixer_accu_t Mixer::accu[MIXING_STEPPERS] = { 0 };
|
||||
|
||||
#if DUAL_MIXING_EXTRUDER || ENABLED(GRADIENT_MIX)
|
||||
#if EITHER(HAS_DUAL_MIXING, GRADIENT_MIX)
|
||||
mixer_perc_t Mixer::mix[MIXING_STEPPERS];
|
||||
#endif
|
||||
|
||||
@@ -90,15 +90,13 @@ void Mixer::normalize(const uint8_t tool_index) {
|
||||
SERIAL_ECHOLNPGM("]");
|
||||
#endif
|
||||
|
||||
#if ENABLED(GRADIENT_MIX)
|
||||
refresh_gradient();
|
||||
#endif
|
||||
TERN_(GRADIENT_MIX, refresh_gradient());
|
||||
}
|
||||
|
||||
void Mixer::reset_vtools() {
|
||||
// Virtual Tools 0, 1, 2, 3 = Filament 1, 2, 3, 4, etc.
|
||||
// Every virtual tool gets a pure filament
|
||||
LOOP_L_N(t, MIXING_VIRTUAL_TOOLS && t < MIXING_STEPPERS)
|
||||
LOOP_L_N(t, _MIN(MIXING_VIRTUAL_TOOLS, MIXING_STEPPERS))
|
||||
MIXER_STEPPER_LOOP(i)
|
||||
color[t][i] = (t == i) ? COLOR_A_MASK : 0;
|
||||
|
||||
@@ -108,28 +106,45 @@ void Mixer::reset_vtools() {
|
||||
MIXER_STEPPER_LOOP(i)
|
||||
color[t][i] = (i == 0) ? COLOR_A_MASK : 0;
|
||||
#endif
|
||||
|
||||
// MIXING_PRESETS: Set a variety of obvious mixes as presets
|
||||
#if ENABLED(MIXING_PRESETS) && WITHIN(MIXING_STEPPERS, 2, 3)
|
||||
#if MIXING_STEPPERS == 2
|
||||
if (MIXING_VIRTUAL_TOOLS > 2) { collector[0] = 1; collector[1] = 1; mixer.normalize(2); } // 1:1
|
||||
if (MIXING_VIRTUAL_TOOLS > 3) { collector[0] = 3; mixer.normalize(3); } // 3:1
|
||||
if (MIXING_VIRTUAL_TOOLS > 4) { collector[0] = 1; collector[1] = 3; mixer.normalize(4); } // 1:3
|
||||
if (MIXING_VIRTUAL_TOOLS > 5) { collector[1] = 2; mixer.normalize(5); } // 1:2
|
||||
if (MIXING_VIRTUAL_TOOLS > 6) { collector[0] = 2; collector[1] = 1; mixer.normalize(6); } // 2:1
|
||||
if (MIXING_VIRTUAL_TOOLS > 7) { collector[0] = 3; collector[1] = 2; mixer.normalize(7); } // 3:2
|
||||
#else
|
||||
if (MIXING_VIRTUAL_TOOLS > 3) { collector[0] = 1; collector[1] = 1; collector[2] = 1; mixer.normalize(3); } // 1:1:1
|
||||
if (MIXING_VIRTUAL_TOOLS > 4) { collector[1] = 3; collector[2] = 0; mixer.normalize(4); } // 1:3:0
|
||||
if (MIXING_VIRTUAL_TOOLS > 5) { collector[0] = 0; collector[2] = 1; mixer.normalize(5); } // 0:3:1
|
||||
if (MIXING_VIRTUAL_TOOLS > 6) { collector[1] = 1; mixer.normalize(6); } // 0:1:1
|
||||
if (MIXING_VIRTUAL_TOOLS > 7) { collector[0] = 1; collector[2] = 0; mixer.normalize(7); } // 1:1:0
|
||||
#endif
|
||||
ZERO(collector);
|
||||
#endif
|
||||
}
|
||||
|
||||
// called at boot
|
||||
void Mixer::init() {
|
||||
|
||||
ZERO(collector);
|
||||
|
||||
reset_vtools();
|
||||
|
||||
#if ENABLED(RETRACT_SYNC_MIXING)
|
||||
#if HAS_MIXER_SYNC_CHANNEL
|
||||
// AUTORETRACT_TOOL gets the same amount of all filaments
|
||||
MIXER_STEPPER_LOOP(i)
|
||||
color[MIXER_AUTORETRACT_TOOL][i] = COLOR_A_MASK;
|
||||
#endif
|
||||
|
||||
ZERO(collector);
|
||||
|
||||
#if DUAL_MIXING_EXTRUDER || ENABLED(GRADIENT_MIX)
|
||||
#if EITHER(HAS_DUAL_MIXING, GRADIENT_MIX)
|
||||
update_mix_from_vtool();
|
||||
#endif
|
||||
|
||||
#if ENABLED(GRADIENT_MIX)
|
||||
update_gradient_for_planner_z();
|
||||
#endif
|
||||
TERN_(GRADIENT_MIX, update_gradient_for_planner_z());
|
||||
}
|
||||
|
||||
void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*=selected_vtool*/, float (&c)[MIXING_STEPPERS]/*=collector*/) {
|
||||
@@ -139,11 +154,11 @@ void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*=
|
||||
cmax = _MAX(cmax, v);
|
||||
csum += v;
|
||||
}
|
||||
//SERIAL_ECHOPAIR("Mixer::refresh_collector(", proportion, ", ", int(t), ") cmax=", cmax, " csum=", csum, " color");
|
||||
//SERIAL_ECHOPGM("Mixer::refresh_collector(", proportion, ", ", t, ") cmax=", cmax, " csum=", csum, " color");
|
||||
const float inv_prop = proportion / csum;
|
||||
MIXER_STEPPER_LOOP(i) {
|
||||
c[i] = color[t][i] * inv_prop;
|
||||
//SERIAL_ECHOPAIR(" [", int(t), "][", int(i), "] = ", int(color[t][i]), " (", c[i], ") ");
|
||||
//SERIAL_ECHOPGM(" [", t, "][", i, "] = ", color[t][i], " (", c[i], ") ");
|
||||
}
|
||||
//SERIAL_EOL();
|
||||
}
|
||||
@@ -154,19 +169,17 @@ void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*=
|
||||
#include "../module/planner.h"
|
||||
|
||||
gradient_t Mixer::gradient = {
|
||||
false, // enabled
|
||||
{0}, // color (array)
|
||||
0, 0, // start_z, end_z
|
||||
0, 1, // start_vtool, end_vtool
|
||||
{0}, {0} // start_mix[], end_mix[]
|
||||
#if ENABLED(GRADIENT_VTOOL)
|
||||
, -1 // vtool_index
|
||||
#endif
|
||||
false, // enabled
|
||||
{0}, // color (array)
|
||||
0, 0, // start_z, end_z
|
||||
0, 1, // start_vtool, end_vtool
|
||||
{0}, {0} // start_mix[], end_mix[]
|
||||
OPTARG(GRADIENT_VTOOL, -1) // vtool_index
|
||||
};
|
||||
|
||||
float Mixer::prev_z; // = 0
|
||||
|
||||
void Mixer::update_gradient_for_z(const float z) {
|
||||
void Mixer::update_gradient_for_z(const_float_t z) {
|
||||
if (z == prev_z) return;
|
||||
prev_z = z;
|
||||
|
||||
@@ -184,7 +197,12 @@ void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*=
|
||||
}
|
||||
|
||||
void Mixer::update_gradient_for_planner_z() {
|
||||
update_gradient_for_z(planner.get_axis_position_mm(Z_AXIS));
|
||||
#if ENABLED(DELTA)
|
||||
get_cartesian_from_steppers();
|
||||
update_gradient_for_z(cartes.z);
|
||||
#else
|
||||
update_gradient_for_z(planner.get_axis_position_mm(Z_AXIS));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // GRADIENT_MIX
|
||||
|
Reference in New Issue
Block a user