ADVANCE_K per-extruder (#24821)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Giuliano Zaro
2022-10-10 20:49:37 +02:00
committed by Scott Lahteine
parent 051b95c845
commit efde96131d
13 changed files with 68 additions and 52 deletions

View File

@@ -27,8 +27,8 @@
#include "../../gcode.h"
#include "../../../module/planner.h"
#if ENABLED(EXTRA_LIN_ADVANCE_K)
float other_extruder_advance_K[EXTRUDERS];
#if ENABLED(ADVANCE_K_EXTRA)
float other_extruder_advance_K[DISTINCT_E];
uint8_t lin_adv_slot = 0;
#endif
@@ -36,8 +36,8 @@
* M900: Get or Set Linear Advance K-factor
* T<tool> Which tool to address
* K<factor> Set current advance K factor (Slot 0).
* L<factor> Set secondary advance K factor (Slot 1). Requires EXTRA_LIN_ADVANCE_K.
* S<0/1> Activate slot 0 or 1. Requires EXTRA_LIN_ADVANCE_K.
* L<factor> Set secondary advance K factor (Slot 1). Requires ADVANCE_K_EXTRA.
* S<0/1> Activate slot 0 or 1. Requires ADVANCE_K_EXTRA.
*/
void GcodeSuite::M900() {
@@ -58,12 +58,12 @@ void GcodeSuite::M900() {
}
#endif
float &kref = planner.extruder_advance_K[tool_index], newK = kref;
float &kref = planner.extruder_advance_K[E_INDEX_N(tool_index)], newK = kref;
const float oldK = newK;
#if ENABLED(EXTRA_LIN_ADVANCE_K)
#if ENABLED(ADVANCE_K_EXTRA)
float &lref = other_extruder_advance_K[tool_index];
float &lref = other_extruder_advance_K[E_INDEX_N(tool_index)];
const bool old_slot = TEST(lin_adv_slot, tool_index), // The tool's current slot (0 or 1)
new_slot = parser.boolval('S', old_slot); // The passed slot (default = current)
@@ -111,9 +111,9 @@ void GcodeSuite::M900() {
if (!parser.seen_any()) {
#if ENABLED(EXTRA_LIN_ADVANCE_K)
#if ENABLED(ADVANCE_K_EXTRA)
#if EXTRUDERS < 2
#if DISTINCT_E < 2
SERIAL_ECHOLNPGM("Advance S", new_slot, " K", kref, "(S", !new_slot, " K", lref, ")");
#else
EXTRUDER_LOOP() {
@@ -127,7 +127,7 @@ void GcodeSuite::M900() {
#else
SERIAL_ECHO_START();
#if EXTRUDERS < 2
#if DISTINCT_E < 2
SERIAL_ECHOLNPGM("Advance K=", planner.extruder_advance_K[0]);
#else
SERIAL_ECHOPGM("Advance K");
@@ -145,7 +145,7 @@ void GcodeSuite::M900() {
void GcodeSuite::M900_report(const bool forReplay/*=true*/) {
report_heading(forReplay, F(STR_LINEAR_ADVANCE));
#if EXTRUDERS < 2
#if DISTINCT_E < 2
report_echo_start(forReplay);
SERIAL_ECHOLNPGM(" M900 K", planner.extruder_advance_K[0]);
#else