M166 Gradients, LCD Menu for 2-channel Mixer (Geeetech A10M/A20M) (#13022)

This commit is contained in:
Scott Lahteine
2019-02-10 04:54:23 -06:00
committed by GitHub
parent 7ee35c2611
commit 6de3d34378
114 changed files with 9901 additions and 61 deletions

View File

@ -38,7 +38,7 @@
void GcodeSuite::M163() {
const int mix_index = parser.intval('S');
if (mix_index < MIXING_STEPPERS)
mixer.set_collector(mix_index, MAX(parser.floatval('P'), 0.0));
mixer.set_collector(mix_index, parser.floatval('P'));
}
/**
@ -53,10 +53,12 @@ void GcodeSuite::M164() {
#else
constexpr int tool_index = 0;
#endif
if (WITHIN(tool_index, 0, MIXING_VIRTUAL_TOOLS - 1))
mixer.normalize(tool_index);
if (tool_index >= 0) {
if (tool_index < MIXING_VIRTUAL_TOOLS)
mixer.normalize(tool_index);
}
else
mixer.normalize(mixer.get_current_vtool());
mixer.normalize();
}
#if ENABLED(DIRECT_MIXING_IN_G1)
@ -95,7 +97,7 @@ void GcodeSuite::M164() {
MIXER_STEPPER_LOOP(i) {
if (parser.seenval(mixing_codes[i])) {
SBI(mix_bits, i);
mixer.set_collector(i, MAX(parser.value_float(), 0.0f));
mixer.set_collector(i, parser.value_float());
}
}
// If any mixing factors were included, clear the rest
@ -103,7 +105,7 @@ void GcodeSuite::M164() {
if (mix_bits) {
MIXER_STEPPER_LOOP(i)
if (!TEST(mix_bits, i)) mixer.set_collector(i, 0.0f);
mixer.normalize(mixer.get_current_vtool());
mixer.normalize();
}
}

View File

@ -0,0 +1,100 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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/>.
*
*/
#include "../../../inc/MarlinConfig.h"
#if ENABLED(GRADIENT_MIX)
#include "../../gcode.h"
#include "../../../module/motion.h"
#include "../../../module/planner.h"
#include "../../../feature/mixing.h"
inline void echo_mix() {
SERIAL_ECHOPAIR(" (", int(mixer.mix[0]));
SERIAL_ECHOPAIR("%|", int(mixer.mix[1]));
SERIAL_ECHOPGM("%)");
}
inline void echo_zt(const int t, const float &z) {
mixer.update_mix_from_vtool(t);
SERIAL_ECHOPAIR(" Z", z);
SERIAL_ECHOPAIR(" T", t);
echo_mix();
}
/**
* M166: Set a simple gradient mix for a two-component mixer
* based on the Geeetech A10M implementation by Jone Liu.
*
* S[bool] - Enable / disable gradients
* A[float] - Starting Z for the gradient
* Z[float] - Ending Z for the gradient. (Must be greater than the starting Z.)
* I[index] - V-Tool to use as the starting mix.
* J[index] - V-Tool to use as the ending mix.
*
* T[index] - A V-Tool index to use as an alias for the Gradient (Requires GRADIENT_VTOOL)
* T with no index clears the setting. Note: This can match the I or J value.
*
* Example: M166 S1 A0 Z20 I0 J1
*/
void GcodeSuite::M166() {
if (parser.seenval('A')) mixer.gradient.start_z = parser.value_float();
if (parser.seenval('Z')) mixer.gradient.end_z = parser.value_float();
if (parser.seenval('I')) mixer.gradient.start_vtool = (uint8_t)constrain(parser.value_int(), 0, MIXING_VIRTUAL_TOOLS);
if (parser.seenval('J')) mixer.gradient.end_vtool = (uint8_t)constrain(parser.value_int(), 0, MIXING_VIRTUAL_TOOLS);
#if ENABLED(GRADIENT_VTOOL)
if (parser.seen('T')) mixer.gradient.vtool_index = parser.byteval('T', -1);
#endif
if (parser.seen('S')) mixer.gradient.enabled = parser.value_bool();
SERIAL_ECHOPGM("Gradient Mix ");
serialprint_onoff(mixer.gradient.enabled);
if (mixer.gradient.enabled) {
mixer.refresh_gradient();
#if ENABLED(GRADIENT_VTOOL)
if (mixer.gradient.vtool_index >= 0) {
SERIAL_ECHOPAIR(" (T", int(mixer.gradient.vtool_index));
SERIAL_CHAR(')');
}
#endif
SERIAL_ECHOPGM(" ; Start");
echo_zt(mixer.gradient.start_vtool, mixer.gradient.start_z);
SERIAL_ECHOPGM(" ; End");
echo_zt(mixer.gradient.end_vtool, mixer.gradient.end_z);
mixer.update_mix_from_gradient();
SERIAL_ECHOPAIR(" ; Current Z", planner.get_axis_position_mm(Z_AXIS));
echo_mix();
}
SERIAL_EOL();
}
#endif // GRADIENT_MIX

View File

@ -443,6 +443,9 @@ void GcodeSuite::process_parsed_command(
#if ENABLED(DIRECT_MIXING_IN_G1)
case 165: M165(); break; // M165: Set multiple mix weights
#endif
#if ENABLED(GRADIENT_MIX)
case 166: M166(); break; // M166: Set Gradient Mix
#endif
#endif
#if DISABLED(NO_VOLUMETRICS)

View File

@ -149,6 +149,7 @@
* M163 - Set a single proportion for a mixing extruder. (Requires MIXING_EXTRUDER)
* M164 - Commit the mix and save to a virtual tool (current, or as specified by 'S'). (Requires MIXING_EXTRUDER)
* M165 - Set the mix for the mixing extruder (and current virtual tool) with parameters ABCDHI. (Requires MIXING_EXTRUDER and DIRECT_MIXING_IN_G1)
* M166 - Set the Gradient Mix for the mixing extruder. (Requires GRADIENT_MIX)
* 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.)
@ -593,6 +594,9 @@ private:
#if ENABLED(DIRECT_MIXING_IN_G1)
static void M165();
#endif
#if ENABLED(GRADIENT_MIX)
static void M166();
#endif
#endif
static void M200();