From 5beca894121848fb7e482e77395329025fd7b51d Mon Sep 17 00:00:00 2001 From: thisiskeithb <13375512+thisiskeithb@users.noreply.github.com> Date: Wed, 8 Jan 2020 15:43:36 -0800 Subject: [PATCH] Add menu item Tune > Advance K (#16488) --- Marlin/src/lcd/menu/menu_advanced.cpp | 56 ++++++++++-------------- Marlin/src/lcd/menu/menu_temperature.cpp | 4 +- Marlin/src/lcd/menu/menu_tune.cpp | 28 ++++++++---- 3 files changed, 46 insertions(+), 42 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 3deb5ec04..5e0bb924e 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -114,9 +114,8 @@ void menu_cancelobject(); #if EXTRUDERS == 1 EDIT_ITEM(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999); #elif EXTRUDERS > 1 - #define EDIT_ADVANCE_K(N) EDIT_ITEM_N(float52, N, MSG_ADVANCE_K_E, &planner.extruder_advance_K[N], 0, 999) for (uint8_t n = 0; n < EXTRUDERS; n++) - EDIT_ADVANCE_K(n); + EDIT_ITEM_N(float52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999); #endif #endif @@ -124,12 +123,10 @@ void menu_cancelobject(); EDIT_ITEM(bool, MSG_VOLUMETRIC_ENABLED, &parser.volumetric_enabled, planner.calculate_volumetric_multipliers); if (parser.volumetric_enabled) { - #if EXTRUDERS == 1 - EDIT_ITEM_FAST(float43, MSG_FILAMENT_DIAM, &planner.filament_size[0], 1.5f, 3.25f, planner.calculate_volumetric_multipliers); - #elif EXTRUDERS > 1 - #define EDIT_FIL_DIAM(N) EDIT_ITEM_FAST_N(float43, N, MSG_FILAMENT_DIAM_E, &planner.filament_size[N], 1.5f, 3.25f, planner.calculate_volumetric_multipliers) - EDIT_ITEM_FAST(float43, MSG_FILAMENT_DIAM, &planner.filament_size[active_extruder], 1.5f, 3.25f, planner.calculate_volumetric_multipliers); - for (uint8_t n = 0; n < EXTRUDERS; n++) EDIT_FIL_DIAM(n); + EDIT_ITEM_FAST(float43, MSG_FILAMENT_DIAM, &planner.filament_size[active_extruder], 1.5f, 3.25f, planner.calculate_volumetric_multipliers); + #if EXTRUDERS > 1 + for (uint8_t n = 0; n < EXTRUDERS; n++) + EDIT_ITEM_FAST_N(float43, n, MSG_FILAMENT_DIAM_E, &planner.filament_size[n], 1.5f, 3.25f, planner.calculate_volumetric_multipliers); #endif } #endif @@ -143,20 +140,16 @@ void menu_cancelobject(); #endif ; - #if EXTRUDERS == 1 - EDIT_ITEM_FAST(float3, MSG_FILAMENT_UNLOAD, &fc_settings[0].unload_length, 0, extrude_maxlength); - #elif EXTRUDERS > 1 - #define EDIT_FIL_UNLOAD(N) EDIT_ITEM_FAST_N(float3, N, MSG_FILAMENTUNLOAD_E, &fc_settings[N].unload_length, 0, extrude_maxlength) - EDIT_ITEM_FAST(float3, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength); - for (uint8_t n = 0; n < EXTRUDERS; n++) EDIT_FIL_UNLOAD(n); + EDIT_ITEM_FAST(float3, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength); + #if EXTRUDERS > 1 + for (uint8_t n = 0; n < EXTRUDERS; n++) + EDIT_ITEM_FAST_N(float3, n, MSG_FILAMENTUNLOAD_E, &fc_settings[n].unload_length, 0, extrude_maxlength); #endif - #if EXTRUDERS == 1 - EDIT_ITEM_FAST(float3, MSG_FILAMENT_LOAD, &fc_settings[0].load_length, 0, extrude_maxlength); - #elif EXTRUDERS > 1 - #define EDIT_FIL_LOAD(N) EDIT_ITEM_FAST_N(float3, N, MSG_FILAMENTLOAD_E, &fc_settings[N].load_length, 0, extrude_maxlength) - EDIT_ITEM_FAST(float3, MSG_FILAMENT_LOAD, &fc_settings[active_extruder].load_length, 0, extrude_maxlength); - for (uint8_t n = 0; n < EXTRUDERS; n++) EDIT_FIL_LOAD(n); + EDIT_ITEM_FAST(float3, MSG_FILAMENT_LOAD, &fc_settings[active_extruder].load_length, 0, extrude_maxlength); + #if EXTRUDERS > 1 + for (uint8_t n = 0; n < EXTRUDERS; n++) + EDIT_ITEM_FAST_N(float3, n, MSG_FILAMENTLOAD_E, &fc_settings[n].load_length, 0, extrude_maxlength); #endif #endif @@ -385,12 +378,12 @@ void menu_cancelobject(); EDIT_VMAX(B); EDIT_VMAX(C); - #if ENABLED(DISTINCT_E_FACTORS) - #define EDIT_VMAX_E(N) EDIT_ITEM_FAST_N(float3, N, MSG_VMAX_EN, &planner.settings.max_feedrate_mm_s[E_AXIS_N(N)], 1, max_fr_edit_scaled.e) + #if E_STEPPERS EDIT_ITEM_FAST(float3, MSG_VMAX_E, &planner.settings.max_feedrate_mm_s[E_AXIS_N(active_extruder)], 1, max_fr_edit_scaled.e); - for (uint8_t n = 0; n < E_STEPPERS; n++) EDIT_VMAX_E(n); - #elif E_STEPPERS - EDIT_ITEM_FAST(float3, MSG_VMAX_E, &planner.settings.max_feedrate_mm_s[E_AXIS], 1, max_fr_edit_scaled.e); + #endif + #if ENABLED(DISTINCT_E_FACTORS) + for (uint8_t n = 0; n < E_STEPPERS; n++) + EDIT_ITEM_FAST_N(float3, n, MSG_VMAX_EN, &planner.settings.max_feedrate_mm_s[E_AXIS_N(n)], 1, max_fr_edit_scaled.e); #endif // M205 S Min Feedrate @@ -434,15 +427,14 @@ void menu_cancelobject(); #endif #define EDIT_AMAX(Q,L) EDIT_ITEM_FAST(long5_25, MSG_AMAX_##Q, &planner.settings.max_acceleration_mm_per_s2[_AXIS(Q)], L, max_accel_edit_scaled[_AXIS(Q)], []{ planner.reset_acceleration_rates(); }) - EDIT_AMAX(A,100); EDIT_AMAX(B,100); EDIT_AMAX(C, 10); #if ENABLED(DISTINCT_E_FACTORS) - #define EDIT_AMAX_E(N) EDIT_ITEM_FAST_N(long5_25, N, MSG_AMAX_EN, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(N)], 100, max_accel_edit_scaled.e, []{ _reset_e_acceleration_rate(MenuItemBase::itemIndex); }) EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); }); - for (uint8_t n = 0; n < E_STEPPERS; n++) EDIT_AMAX_E(n); + for (uint8_t n = 0; n < E_STEPPERS; n++) + EDIT_ITEM_FAST_N(long5_25, n, MSG_AMAX_EN, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(n)], 100, max_accel_edit_scaled.e, []{ _reset_e_acceleration_rate(MenuItemBase::itemIndex); }); #elif E_STEPPERS EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); }); #endif @@ -499,9 +491,9 @@ void menu_cancelobject(); EDIT_QSTEPS(C); #if ENABLED(DISTINCT_E_FACTORS) - #define EDIT_ESTEPS(N) EDIT_ITEM_FAST_N(float51, N, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(N)], 5, 9999, []{ _planner_refresh_e_positioning(MenuItemBase::itemIndex); }) EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(active_extruder)], 5, 9999, []{ planner.refresh_positioning(); }); - for (uint8_t n = 0; n < E_STEPPERS; n++) EDIT_ESTEPS(n); + for (uint8_t n = 0; n < E_STEPPERS; n++) + EDIT_ITEM_FAST_N(float51, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ _planner_refresh_e_positioning(MenuItemBase::itemIndex); }); #elif E_STEPPERS EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); #endif @@ -571,8 +563,8 @@ void menu_advanced_settings() { #if EXTRUDERS == 1 EDIT_ITEM(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999); #elif EXTRUDERS > 1 - #define EDIT_ADVANCE_K(N) EDIT_ITEM_N(float52, N, MSG_ADVANCE_K_E, &planner.extruder_advance_K[N], 0, 999) - for (uint8_t n = 0; n < E_STEPPERS; n++) EDIT_ADVANCE_K(n); + for (uint8_t n = 0; n < E_STEPPERS; n++) + EDIT_ITEM_N(float52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999); #endif #endif diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 0c90a8875..0a774e04d 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -172,8 +172,8 @@ void menu_temperature() { #if HOTENDS == 1 EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - 15, []{ thermalManager.start_watching_hotend(0); }); #elif HOTENDS > 1 - #define EDIT_TARGET(N) EDIT_ITEM_FAST_N(int3, N, MSG_NOZZLE_N, &thermalManager.temp_hotend[N].target, 0, heater_maxtemp[N] - 15, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }) - HOTEND_LOOP() EDIT_TARGET(e); + HOTEND_LOOP() + EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, heater_maxtemp[e] - 15, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); #endif #if ENABLED(SINGLENOZZLE) diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index 3a5cdc1b9..1ece7f6ce 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -128,8 +128,8 @@ void menu_tune() { #if HOTENDS == 1 EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - 15, []{ thermalManager.start_watching_hotend(0); }); #elif HOTENDS > 1 - #define EDIT_NOZZLE(N) EDIT_ITEM_FAST_N(int3, N, MSG_NOZZLE_N, &thermalManager.temp_hotend[N].target, 0, heater_maxtemp[N] - 15, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }) - HOTEND_LOOP() EDIT_NOZZLE(e); + HOTEND_LOOP() + EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, heater_maxtemp[e] - 15, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); #endif #if ENABLED(SINGLENOZZLE) @@ -178,14 +178,26 @@ void menu_tune() { // // Flow: - // Flow [1-5]: // - #if EXTRUDERS == 1 - EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[0], 10, 999, []{ planner.refresh_e_factor(0); }); - #elif EXTRUDERS + #if EXTRUDERS EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); }); - #define EDIT_FLOW(N) EDIT_ITEM_N(int3, N, MSG_FLOW_N, &planner.flow_percentage[N], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }) - for (uint8_t n = 0; n < EXTRUDERS; n++) EDIT_FLOW(n); + // Flow En: + #if EXTRUDERS > 1 + for (uint8_t n = 0; n < EXTRUDERS; n++) + EDIT_ITEM_N(int3, n, MSG_FLOW_N, &planner.flow_percentage[n], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); + #endif + #endif + + // + // Advance K: + // + #if ENABLED(LIN_ADVANCE) && DISABLED(SLIM_LCD_MENUS) + #if EXTRUDERS == 1 + EDIT_ITEM(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999); + #elif EXTRUDERS > 1 + for (uint8_t n = 0; n < EXTRUDERS; n++) + EDIT_ITEM_N(float52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999); + #endif #endif //