mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-07-06 14:37:27 -06:00
🧑💻 Use 'DISTINCT_E_FACTORS'
This commit is contained in:
parent
6cda10de0f
commit
fad7bc66e9
7 changed files with 28 additions and 24 deletions
|
@ -36,9 +36,11 @@
|
|||
/**
|
||||
* 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 ADVANCE_K_EXTRA.
|
||||
* S<0/1> Activate slot 0 or 1. Requires ADVANCE_K_EXTRA.
|
||||
* K<factor> Set current advance K factor (aka Slot 0).
|
||||
*
|
||||
* With ADVANCE_K_EXTRA:
|
||||
* S<0/1> Activate slot 0 or 1.
|
||||
* L<factor> Set secondary advance K factor (Slot 1).
|
||||
*/
|
||||
void GcodeSuite::M900() {
|
||||
|
||||
|
@ -72,31 +74,31 @@ void GcodeSuite::M900() {
|
|||
|
||||
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)
|
||||
const bool old_slot = TEST(lin_adv_slot, tool_index), // Each tool uses 1 bit to store its current slot (0 or 1)
|
||||
new_slot = parser.boolval('S', old_slot); // The new slot (0 or 1) to set for the tool (default = no change)
|
||||
|
||||
// If a new slot is being selected swap the current and
|
||||
// saved K values. Do here so K/L will apply correctly.
|
||||
if (new_slot != old_slot) { // Not the same slot?
|
||||
SET_BIT_TO(lin_adv_slot, tool_index, new_slot); // Update the slot for the tool
|
||||
newK = lref; // Get new K value from backup
|
||||
lref = oldK; // Save K to backup
|
||||
newK = lref; // Get the backup K value (to apply below)
|
||||
lref = oldK; // Back up the active K value
|
||||
}
|
||||
|
||||
// Set the main K value. Apply if the main slot is active.
|
||||
if (parser.seenval('K')) {
|
||||
const float K = parser.value_float();
|
||||
if (!WITHIN(K, 0, 10)) echo_value_oor('K');
|
||||
else if (new_slot) lref = K; // S1 Knn
|
||||
else newK = K; // S0 Knn
|
||||
else if (new_slot) lref = K; // S1 Knn (set main K in its backup slot)
|
||||
else newK = K; // S0 Knn (use main K now)
|
||||
}
|
||||
|
||||
// Set the extra K value. Apply if the extra slot is active.
|
||||
if (parser.seenval('L')) {
|
||||
const float L = parser.value_float();
|
||||
if (!WITHIN(L, 0, 10)) echo_value_oor('L');
|
||||
else if (!new_slot) lref = L; // S0 Lnn
|
||||
else newK = L; // S1 Lnn
|
||||
else if (!new_slot) lref = L; // S0 Lnn (set extra K in its backup slot)
|
||||
else newK = L; // S1 Lnn (use extra K now)
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -133,7 +135,7 @@ void GcodeSuite::M900() {
|
|||
|
||||
#if ENABLED(ADVANCE_K_EXTRA)
|
||||
|
||||
#if DISTINCT_E < 2
|
||||
#if DISABLED(DISTINCT_E_FACTORS)
|
||||
SERIAL_ECHOLNPGM("Advance S", new_slot, " K", kref, "(S", !new_slot, " K", lref, ")");
|
||||
#else
|
||||
EXTRUDER_LOOP() {
|
||||
|
@ -146,7 +148,7 @@ void GcodeSuite::M900() {
|
|||
#else // !ADVANCE_K_EXTRA
|
||||
|
||||
SERIAL_ECHO_START();
|
||||
#if DISTINCT_E < 2
|
||||
#if DISABLED(DISTINCT_E_FACTORS)
|
||||
SERIAL_ECHOPGM("Advance K=", planner.extruder_advance_K[0]);
|
||||
#if ENABLED(SMOOTH_LIN_ADVANCE)
|
||||
SERIAL_ECHOPGM(" TAU=", stepper.get_advance_tau());
|
||||
|
@ -172,7 +174,7 @@ void GcodeSuite::M900_report(const bool forReplay/*=true*/) {
|
|||
TERN_(MARLIN_SMALL_BUILD, return);
|
||||
|
||||
report_heading(forReplay, F(STR_LINEAR_ADVANCE));
|
||||
#if DISTINCT_E < 2
|
||||
#if DISABLED(DISTINCT_E_FACTORS)
|
||||
report_echo_start(forReplay);
|
||||
SERIAL_ECHOPGM(" M900 K", planner.extruder_advance_K[0]);
|
||||
#if ENABLED(SMOOTH_LIN_ADVANCE)
|
||||
|
|
|
@ -544,6 +544,8 @@
|
|||
#endif
|
||||
|
||||
// Helper macros for extruder and hotend arrays
|
||||
#define _DISTINCT_E_LOOP(E) for (int8_t E = 0; E < DISTINCT_E; E++)
|
||||
#define DISTINCT_E_LOOP() _DISTINCT_E_LOOP(e)
|
||||
#define _EXTRUDER_LOOP(E) for (int8_t E = 0; E < EXTRUDERS; E++)
|
||||
#define EXTRUDER_LOOP() _EXTRUDER_LOOP(e)
|
||||
#define _HOTEND_LOOP(H) for (int8_t H = 0; H < HOTENDS; H++)
|
||||
|
|
|
@ -846,7 +846,7 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
|
|||
* Linear Advance 1.5 - Check K value range
|
||||
*/
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
#if DISTINCT_E > 1
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
constexpr float lak[] = ADVANCE_K;
|
||||
static_assert(COUNT(lak) <= DISTINCT_E, "The ADVANCE_K array has too many elements (i.e., more than " STRINGIFY(DISTINCT_E) ").");
|
||||
#define _LIN_ASSERT(N) static_assert(N >= COUNT(lak) || WITHIN(lak[N], 0, 10), "ADVANCE_K values must be from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9).");
|
||||
|
|
|
@ -39,7 +39,7 @@ void MaxAccelerationScreen::onRedraw(draw_mode_t what) {
|
|||
w.color(z_axis) .adjuster( 6, GET_TEXT_F(MSG_AMAX_Z), getAxisMaxAcceleration_mm_s2(Z) );
|
||||
#if DISTINCT_E == 1
|
||||
w.color(e_axis).adjuster( 8, GET_TEXT_F(MSG_AMAX_E), getAxisMaxAcceleration_mm_s2(E0) );
|
||||
#elif DISTINCT_E > 1
|
||||
#elif ENABLED(DISTINCT_E_FACTORS)
|
||||
w.heading(GET_TEXT_F(MSG_AMAX_E));
|
||||
w.color(e_axis).adjuster( 8, F(STR_E0), getAxisMaxAcceleration_mm_s2(E0) );
|
||||
w.color(e_axis).adjuster(10, F(STR_E1), getAxisMaxAcceleration_mm_s2(E1) );
|
||||
|
@ -64,7 +64,7 @@ bool MaxAccelerationScreen::onTouchHeld(uint8_t tag) {
|
|||
case 7: UI_INCREMENT(AxisMaxAcceleration_mm_s2, Z ); break;
|
||||
case 8: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E0); break;
|
||||
case 9: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E0); break;
|
||||
#if DISTINCT_E > 1
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
case 10: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E1); break;
|
||||
case 11: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E1); break;
|
||||
#if DISTINCT_E > 2
|
||||
|
|
|
@ -66,7 +66,7 @@ bool MaxVelocityScreen::onTouchHeld(uint8_t tag) {
|
|||
#if DISTINCT_E
|
||||
case 8: UI_DECREMENT(AxisMaxFeedrate_mm_s, E0); break;
|
||||
case 9: UI_INCREMENT(AxisMaxFeedrate_mm_s, E0); break;
|
||||
#if DISTINCT_E > 1
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
case 10: UI_DECREMENT(AxisMaxFeedrate_mm_s, E1); break;
|
||||
case 11: UI_INCREMENT(AxisMaxFeedrate_mm_s, E1); break;
|
||||
#if DISTINCT_E > 2
|
||||
|
|
|
@ -116,14 +116,14 @@ void menu_backlash();
|
|||
BACK_ITEM(MSG_ADVANCED_SETTINGS);
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
#if DISTINCT_E < 2
|
||||
#if DISABLED(DISTINCT_E_FACTORS)
|
||||
EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10);
|
||||
#else
|
||||
EXTRUDER_LOOP()
|
||||
EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10);
|
||||
#endif
|
||||
#if ENABLED(SMOOTH_LIN_ADVANCE)
|
||||
#if DISTINCT_E < 2
|
||||
#if DISABLED(DISTINCT_E_FACTORS)
|
||||
editable.decimal = stepper.get_advance_tau();
|
||||
EDIT_ITEM(float54, MSG_ADVANCE_TAU, &editable.decimal, 0.0f, 0.5f, []{ stepper.set_advance_tau(editable.decimal); });
|
||||
#else
|
||||
|
@ -749,14 +749,14 @@ void menu_advanced_settings() {
|
|||
#endif
|
||||
|
||||
#if ENABLED(LIN_ADVANCE) && DISABLED(HAS_ADV_FILAMENT_MENU)
|
||||
#if DISTINCT_E < 2
|
||||
#if DISABLED(DISTINCT_E_FACTORS)
|
||||
EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10);
|
||||
#else
|
||||
EXTRUDER_LOOP()
|
||||
EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10);
|
||||
#endif
|
||||
#if ENABLED(SMOOTH_LIN_ADVANCE)
|
||||
#if DISTINCT_E < 2
|
||||
#if DISABLED(DISTINCT_E_FACTORS)
|
||||
editable.decimal = stepper.get_advance_tau();
|
||||
EDIT_ITEM(float54, MSG_ADVANCE_TAU, &editable.decimal, 0.0f, 0.5f, []{ stepper.set_advance_tau(editable.decimal); });
|
||||
#else
|
||||
|
|
|
@ -215,14 +215,14 @@ void menu_tune() {
|
|||
// Advance K:
|
||||
//
|
||||
#if ENABLED(LIN_ADVANCE) && DISABLED(SLIM_LCD_MENUS)
|
||||
#if DISTINCT_E < 2
|
||||
#if DISABLED(DISTINCT_E_FACTORS)
|
||||
EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10);
|
||||
#else
|
||||
EXTRUDER_LOOP()
|
||||
EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10);
|
||||
#endif
|
||||
#if ENABLED(SMOOTH_LIN_ADVANCE)
|
||||
#if DISTINCT_E < 2
|
||||
#if DISABLED(DISTINCT_E_FACTORS)
|
||||
editable.decimal = stepper.get_advance_tau();
|
||||
EDIT_ITEM(float54, MSG_ADVANCE_TAU, &editable.decimal, 0.0f, 0.5f, []{ stepper.set_advance_tau(editable.decimal); });
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue