From d06bcd6dd39b48dcf23a26feaf7d6a07cc67da68 Mon Sep 17 00:00:00 2001 From: Marcio T Date: Fri, 2 Oct 2020 16:30:32 -0600 Subject: [PATCH] Touch UI support for X2, Y2 and Z2 (#19538) --- .../ftdi_eve_touch_ui/language/language_en.h | 3 + .../screens/advanced_settings_menu.cpp | 2 +- .../screens/stepper_current_screen.cpp | 101 ++++++++++++------ Marlin/src/lcd/extui/ui_api.cpp | 40 +++++-- 4 files changed, 104 insertions(+), 42 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h index bd6403272..cc96c8b9c 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h @@ -57,8 +57,11 @@ namespace Language_en { PROGMEM Language_Str MSG_AMAX_Y = u8"Amax Y"; PROGMEM Language_Str MSG_AMAX_Z = u8"Amax Z"; PROGMEM Language_Str MSG_AXIS_X = u8"X"; + PROGMEM Language_Str MSG_AXIS_X2 = u8"X2"; PROGMEM Language_Str MSG_AXIS_Y = u8"Y"; + PROGMEM Language_Str MSG_AXIS_Y2 = u8"Y2"; PROGMEM Language_Str MSG_AXIS_Z = u8"Z"; + PROGMEM Language_Str MSG_AXIS_Z2 = u8"Z2"; PROGMEM Language_Str MSG_AXIS_E = u8"E"; PROGMEM Language_Str MSG_AXIS_E1 = u8"E1"; PROGMEM Language_Str MSG_AXIS_E2 = u8"E2"; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/advanced_settings_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/advanced_settings_menu.cpp index 67b077a55..cfb268f0b 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/advanced_settings_menu.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/advanced_settings_menu.cpp @@ -38,7 +38,7 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { } #ifdef TOUCH_UI_PORTRAIT - #if EITHER(CASE_LIGHT_ENABLE, SENSORLESS_HOMING) + #if EITHER(HAS_MULTI_HOTEND, SENSORLESS_HOMING) #define GRID_ROWS 9 #else #define GRID_ROWS 8 diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.cpp index e89bbd202..136582f09 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.cpp @@ -35,20 +35,41 @@ void StepperCurrentScreen::onRedraw(draw_mode_t what) { w.precision(0); w.units(GET_TEXT_F(MSG_UNITS_MILLIAMP)); w.heading( GET_TEXT_F(MSG_TMC_CURRENT)); - w.color(x_axis) .adjuster( 2, GET_TEXT_F(MSG_AXIS_X), getAxisCurrent_mA(X) ); - w.color(y_axis) .adjuster( 4, GET_TEXT_F(MSG_AXIS_Y), getAxisCurrent_mA(Y) ); - w.color(z_axis) .adjuster( 6, GET_TEXT_F(MSG_AXIS_Z), getAxisCurrent_mA(Z) ); - #if EXTRUDERS == 1 - w.color(e_axis).adjuster( 8, GET_TEXT_F(MSG_AXIS_E), getAxisCurrent_mA(E0) ); - #elif HAS_MULTI_EXTRUDER - w.color(e_axis).adjuster( 8, GET_TEXT_F(MSG_AXIS_E1), getAxisCurrent_mA(E0) ); - w.color(e_axis).adjuster(10, GET_TEXT_F(MSG_AXIS_E2), getAxisCurrent_mA(E1) ); - #if EXTRUDERS > 2 - w.color(e_axis).adjuster(12, GET_TEXT_F(MSG_AXIS_E3), getAxisCurrent_mA(E2) ); - #endif - #if EXTRUDERS > 3 - w.color(e_axis).adjuster(14, GET_TEXT_F(MSG_AXIS_E4), getAxisCurrent_mA(E3) ); + #if AXIS_IS_TMC(X) + w.color(x_axis) .adjuster( 2, GET_TEXT_F(MSG_AXIS_X), getAxisCurrent_mA(X) ); + #endif + #if AXIS_IS_TMC(X2) + w.color(x_axis) .adjuster( 4, GET_TEXT_F(MSG_AXIS_X2), getAxisCurrent_mA(X2) ); + #endif + #if AXIS_IS_TMC(Y) + w.color(y_axis) .adjuster( 6, GET_TEXT_F(MSG_AXIS_Y), getAxisCurrent_mA(Y) ); + #endif + #if AXIS_IS_TMC(Y2) + w.color(x_axis) .adjuster( 8, GET_TEXT_F(MSG_AXIS_Y2), getAxisCurrent_mA(Y2) ); + #endif + #if AXIS_IS_TMC(Z) + w.color(z_axis) .adjuster(10, GET_TEXT_F(MSG_AXIS_Z), getAxisCurrent_mA(Z) ); + #endif + #if AXIS_IS_TMC(Z2) + w.color(z_axis) .adjuster(12, GET_TEXT_F(MSG_AXIS_Z2), getAxisCurrent_mA(Z2) ); + #endif + #if AXIS_IS_TMC(E0) + w.color(e_axis) .adjuster(14, GET_TEXT_F( + #if EXTRUDERS == 1 + MSG_AXIS_E + #else + MSG_AXIS_E1 #endif + ), getAxisCurrent_mA(E0) ); + #endif + #if AXIS_IS_TMC(E1) + w.color(e_axis).adjuster(16, GET_TEXT_F(MSG_AXIS_E2), getAxisCurrent_mA(E1) ); + #endif + #if AXIS_IS_TMC(E2) + w.color(e_axis).adjuster(18, GET_TEXT_F(MSG_AXIS_E3), getAxisCurrent_mA(E2) ); + #endif + #if AXIS_IS_TMC(E3) + w.color(e_axis).adjuster(20, GET_TEXT_F(MSG_AXIS_E4), getAxisCurrent_mA(E3) ); #endif w.increments(); } @@ -56,25 +77,45 @@ void StepperCurrentScreen::onRedraw(draw_mode_t what) { bool StepperCurrentScreen::onTouchHeld(uint8_t tag) { const float increment = getIncrement(); switch (tag) { - case 2: UI_DECREMENT(AxisCurrent_mA, X ); break; - case 3: UI_INCREMENT(AxisCurrent_mA, X ); break; - case 4: UI_DECREMENT(AxisCurrent_mA, Y ); break; - case 5: UI_INCREMENT(AxisCurrent_mA, Y ); break; - case 6: UI_DECREMENT(AxisCurrent_mA, Z ); break; - case 7: UI_INCREMENT(AxisCurrent_mA, Z ); break; - case 8: UI_DECREMENT(AxisCurrent_mA, E0); break; - case 9: UI_INCREMENT(AxisCurrent_mA, E0); break; - #if HAS_MULTI_EXTRUDER - case 10: UI_DECREMENT(AxisCurrent_mA, E1); break; - case 11: UI_INCREMENT(AxisCurrent_mA, E1); break; + #if AXIS_IS_TMC(X) + case 2: UI_DECREMENT(AxisCurrent_mA, X ); break; + case 3: UI_INCREMENT(AxisCurrent_mA, X ); break; #endif - #if EXTRUDERS > 2 - case 12: UI_DECREMENT(AxisCurrent_mA, E2); break; - case 13: UI_INCREMENT(AxisCurrent_mA, E2); break; + #if AXIS_IS_TMC(X2) + case 4: UI_DECREMENT(AxisCurrent_mA, X2 ); break; + case 5: UI_INCREMENT(AxisCurrent_mA, X2 ); break; #endif - #if EXTRUDERS > 3 - case 14: UI_DECREMENT(AxisCurrent_mA, E3); break; - case 15: UI_INCREMENT(AxisCurrent_mA, E3); break; + #if AXIS_IS_TMC(Y) + case 6: UI_DECREMENT(AxisCurrent_mA, Y ); break; + case 7: UI_INCREMENT(AxisCurrent_mA, Y ); break; + #endif + #if AXIS_IS_TMC(Y2) + case 8: UI_DECREMENT(AxisCurrent_mA, Y2 ); break; + case 9: UI_INCREMENT(AxisCurrent_mA, Y2 ); break; + #endif + #if AXIS_IS_TMC(Z) + case 10: UI_DECREMENT(AxisCurrent_mA, Z ); break; + case 11: UI_INCREMENT(AxisCurrent_mA, Z ); break; + #endif + #if AXIS_IS_TMC(Z2) + case 12: UI_DECREMENT(AxisCurrent_mA, Z2 ); break; + case 13: UI_INCREMENT(AxisCurrent_mA, Z2 ); break; + #endif + #if AXIS_IS_TMC(E0) + case 14: UI_DECREMENT(AxisCurrent_mA, E0); break; + case 15: UI_INCREMENT(AxisCurrent_mA, E0); break; + #endif + #if AXIS_IS_TMC(E1) + case 16: UI_DECREMENT(AxisCurrent_mA, E1); break; + case 17: UI_INCREMENT(AxisCurrent_mA, E1); break; + #endif + #if AXIS_IS_TMC(E2) + case 18: UI_DECREMENT(AxisCurrent_mA, E2); break; + case 19: UI_INCREMENT(AxisCurrent_mA, E2); break; + #endif + #if AXIS_IS_TMC(E3) + case 20: UI_DECREMENT(AxisCurrent_mA, E3); break; + case 21: UI_INCREMENT(AxisCurrent_mA, E3); break; #endif default: return false; diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 1270e3d64..0acfc9c02 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -399,12 +399,21 @@ namespace ExtUI { #if AXIS_IS_TMC(X) case X: return stepperX.getMilliamps(); #endif + #if AXIS_IS_TMC(X2) + case X2: return stepperX2.getMilliamps(); + #endif #if AXIS_IS_TMC(Y) case Y: return stepperY.getMilliamps(); #endif + #if AXIS_IS_TMC(Y2) + case Y2: return stepperY2.getMilliamps(); + #endif #if AXIS_IS_TMC(Z) case Z: return stepperZ.getMilliamps(); #endif + #if AXIS_IS_TMC(Z2) + case Z2: return stepperZ2.getMilliamps(); + #endif default: return NAN; }; } @@ -442,13 +451,22 @@ namespace ExtUI { void setAxisCurrent_mA(const float mA, const axis_t axis) { switch (axis) { #if AXIS_IS_TMC(X) - case X: stepperX.rms_current(constrain(mA, 500, 1500)); break; + case X: stepperX.rms_current(constrain(mA, 400, 1500)); break; + #endif + #if AXIS_IS_TMC(X2) + case X2: stepperX2.rms_current(constrain(mA, 400, 1500)); break; #endif #if AXIS_IS_TMC(Y) - case Y: stepperY.rms_current(constrain(mA, 500, 1500)); break; + case Y: stepperY.rms_current(constrain(mA, 400, 1500)); break; + #endif + #if AXIS_IS_TMC(Y2) + case Y2: stepperY2.rms_current(constrain(mA, 400, 1500)); break; #endif #if AXIS_IS_TMC(Z) - case Z: stepperZ.rms_current(constrain(mA, 500, 1500)); break; + case Z: stepperZ.rms_current(constrain(mA, 400, 1500)); break; + #endif + #if AXIS_IS_TMC(Z2) + case Z2: stepperZ2.rms_current(constrain(mA, 400, 1500)); break; #endif default: break; }; @@ -457,28 +475,28 @@ namespace ExtUI { void setAxisCurrent_mA(const float mA, const extruder_t extruder) { switch (extruder) { #if AXIS_IS_TMC(E0) - case E0: stepperE0.rms_current(constrain(mA, 500, 1500)); break; + case E0: stepperE0.rms_current(constrain(mA, 400, 1500)); break; #endif #if AXIS_IS_TMC(E1) - case E1: stepperE1.rms_current(constrain(mA, 500, 1500)); break; + case E1: stepperE1.rms_current(constrain(mA, 400, 1500)); break; #endif #if AXIS_IS_TMC(E2) - case E2: stepperE2.rms_current(constrain(mA, 500, 1500)); break; + case E2: stepperE2.rms_current(constrain(mA, 400, 1500)); break; #endif #if AXIS_IS_TMC(E3) - case E3: stepperE3.rms_current(constrain(mA, 500, 1500)); break; + case E3: stepperE3.rms_current(constrain(mA, 400, 1500)); break; #endif #if AXIS_IS_TMC(E4) - case E4: stepperE4.rms_current(constrain(mA, 500, 1500)); break; + case E4: stepperE4.rms_current(constrain(mA, 400, 1500)); break; #endif #if AXIS_IS_TMC(E5) - case E5: stepperE5.rms_current(constrain(mA, 500, 1500)); break; + case E5: stepperE5.rms_current(constrain(mA, 400, 1500)); break; #endif #if AXIS_IS_TMC(E6) - case E6: stepperE6.rms_current(constrain(mA, 500, 1500)); break; + case E6: stepperE6.rms_current(constrain(mA, 400, 1500)); break; #endif #if AXIS_IS_TMC(E7) - case E7: stepperE7.rms_current(constrain(mA, 500, 1500)); break; + case E7: stepperE7.rms_current(constrain(mA, 400, 1500)); break; #endif default: break; };