diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index 17784ff527..1765ae0a8e 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -222,15 +222,19 @@ void Touch::touch(touch_control_t *control) { ui.clear_lcd(); MenuItem_int3::action(GET_TEXT_F(MSG_SPEED), &feedrate_percentage, 10, 999); break; - case FLOWRATE: - ui.clear_lcd(); - MenuItemBase::itemIndex = control->data; - #if EXTRUDERS == 1 - MenuItem_int3::action(GET_TEXT_F(MSG_FLOW), &planner.flow_percentage[MenuItemBase::itemIndex], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); - #else - MenuItem_int3::action(GET_TEXT_F(MSG_FLOW_N), &planner.flow_percentage[MenuItemBase::itemIndex], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); - #endif - break; + + #if HAS_EXTRUDERS + case FLOWRATE: + ui.clear_lcd(); + MenuItemBase::itemIndex = control->data; + #if EXTRUDERS == 1 + MenuItem_int3::action(GET_TEXT_F(MSG_FLOW), &planner.flow_percentage[MenuItemBase::itemIndex], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); + #else + MenuItem_int3::action(GET_TEXT_F(MSG_FLOW_N), &planner.flow_percentage[MenuItemBase::itemIndex], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); + #endif + break; + #endif + case STOP: ui.goto_screen([]{ MenuItem_confirm::select_screen(GET_TEXT_F(MSG_BUTTON_STOP), diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index cf5911cdc1..460f3a345b 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -124,8 +124,12 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { celsius_t currentTemperature, targetTemperature; if (Heater >= 0) { // HotEnd - currentTemperature = thermalManager.wholeDegHotend(Heater); - targetTemperature = thermalManager.degTargetHotend(Heater); + #if HAS_EXTRUDERS + currentTemperature = thermalManager.wholeDegHotend(Heater); + targetTemperature = thermalManager.degTargetHotend(Heater); + #else + return; + #endif } #if HAS_HEATED_BED else if (Heater == H_BED) { @@ -270,37 +274,45 @@ void MarlinUI::draw_status_screen() { #endif } else { - tft.add_text(200, 3, COLOR_AXIS_HOMED , "X"); - const bool nhx = axis_should_home(X_AXIS); - if (blink && nhx) - tft_string.set('?'); - else - tft_string.set(ftostr4sign(LOGICAL_X_POSITION(current_position.x))); - tft.add_text(300 - tft_string.width(), 3, nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + #if HAS_X_AXIS + tft.add_text(200, 3, COLOR_AXIS_HOMED , "X"); + const bool nhx = axis_should_home(X_AXIS); + if (blink && nhx) + tft_string.set('?'); + else + tft_string.set(ftostr4sign(LOGICAL_X_POSITION(current_position.x))); + tft.add_text(300 - tft_string.width(), 3, nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + #endif - tft.add_text(500, 3, COLOR_AXIS_HOMED , "Y"); - const bool nhy = axis_should_home(Y_AXIS); - if (blink && nhy) - tft_string.set('?'); - else - tft_string.set(ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); - tft.add_text(600 - tft_string.width(), 3, nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + #if HAS_Y_AXIS + tft.add_text(500, 3, COLOR_AXIS_HOMED , "Y"); + const bool nhy = axis_should_home(Y_AXIS); + if (blink && nhy) + tft_string.set('?'); + else + tft_string.set(ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); + tft.add_text(600 - tft_string.width(), 3, nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + #endif } - tft.add_text(800, 3, COLOR_AXIS_HOMED , "Z"); - uint16_t offset = 32; - const bool nhz = axis_should_home(Z_AXIS); - if (blink && nhz) - tft_string.set('?'); - else { - const float z = LOGICAL_Z_POSITION(current_position.z); - tft_string.set(ftostr52sp((int16_t)z)); - tft_string.rtrim(); - offset += tft_string.width(); - tft_string.set(ftostr52sp(z)); - offset -= tft_string.width(); - } - tft.add_text(900 - tft_string.width() - offset, 3, nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + #if HAS_Z_AXIS + tft.add_text(800, 3, COLOR_AXIS_HOMED , "Z"); + uint16_t offset = 32; + const bool nhz = axis_should_home(Z_AXIS); + if (blink && nhz) + tft_string.set('?'); + else { + const float z = LOGICAL_Z_POSITION(current_position.z); + tft_string.set(ftostr52sp((int16_t)z)); + tft_string.rtrim(); + offset += tft_string.width(); + + tft_string.set(ftostr52sp(z)); + offset -= tft_string.width(); + } + tft.add_text(900 - tft_string.width() - offset, 3, nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + #endif // HAS_Z_AXIS + TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT)); y += 100; @@ -314,15 +326,17 @@ void MarlinUI::draw_status_screen() { tft.add_text(36, 1, color , tft_string); TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, 274, y, 128, 32)); - // flow rate - tft.canvas(650, y, 128, 32); - tft.set_background(COLOR_BACKGROUND); - color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED; - tft.add_image(0, 0, imgFlowRate, color); - tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder])); - tft_string.add('%'); - tft.add_text(36, 1, color , tft_string); - TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, 650, y, 128, 32, active_extruder)); + // Flow rate + #if HAS_EXTRUDERS + tft.canvas(650, y, 128, 32); + tft.set_background(COLOR_BACKGROUND); + color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED; + tft.add_image(0, 0, imgFlowRate, color); + tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder])); + tft_string.add('%'); + tft.add_text(36, 1, color , tft_string); + TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, 650, y, 128, 32, active_extruder)); + #endif #if ENABLED(TOUCH_SCREEN) add_control(900, y, menu_main, imgSettings); @@ -584,16 +598,26 @@ void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, con #define Z_SELECTION_Z 1 #define Z_SELECTION_Z_PROBE -1 -struct MotionAxisState { - xy_int_t xValuePos, yValuePos, zValuePos, eValuePos, stepValuePos, zTypePos, eNamePos; +struct { + #if HAS_X_AXIS + xy_int_t xValuePos; + #endif + #if HAS_Y_AXIS + xy_int_t yValuePos; + #endif + #if HAS_Z_AXIS + xy_int_t zValuePos, zTypePos; + int z_selection = Z_SELECTION_Z; + #endif + #if HAS_EXTRUDERS + xy_int_t eValuePos, eNamePos; + uint8_t e_selection = 0; + #endif + xy_int_t stepValuePos; float currentStepSize = 10.0; - int z_selection = Z_SELECTION_Z; - uint8_t e_selection = 0; bool blocked = false; char message[32]; -}; - -MotionAxisState motionAxisState; +} motionAxisState; #define BTN_WIDTH 64 #define BTN_HEIGHT 52 @@ -620,27 +644,30 @@ static void drawCurStepValue() { tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string); } -static void drawCurZSelection() { - tft_string.set('Z'); - tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34); - tft.set_background(COLOR_BACKGROUND); - tft.add_text(0, 0, Z_BTN_COLOR, tft_string); - tft.queue.sync(); - tft_string.set(F("Offset")); - tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34); - tft.set_background(COLOR_BACKGROUND); - if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { +#if HAS_Z_AXIS + static void drawCurZSelection() { + tft_string.set('Z'); + tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34); + tft.set_background(COLOR_BACKGROUND); tft.add_text(0, 0, Z_BTN_COLOR, tft_string); + tft.queue.sync(); + tft_string.set(F("Offset")); + tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34); + tft.set_background(COLOR_BACKGROUND); + if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) + tft.add_text(0, 0, Z_BTN_COLOR, tft_string); } -} +#endif -static void drawCurESelection() { - tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT); - tft.set_background(COLOR_BACKGROUND); - tft_string.set('E'); - tft.add_text(0, 0, E_BTN_COLOR , tft_string); - tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); -} +#if HAS_EXTRUDERS + static void drawCurESelection() { + tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft_string.set('E'); + tft.add_text(0, 0, E_BTN_COLOR , tft_string); + tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); + } +#endif static void drawMessage(PGM_P const msg) { tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 34, TFT_HEIGHT / 2, 34); @@ -658,10 +685,18 @@ static void drawAxisValue(const AxisEnum axis) { xy_int_t pos; uint16_t color; switch (axis) { - case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break; - case Y_AXIS: pos = motionAxisState.yValuePos; color = Y_BTN_COLOR; break; - case Z_AXIS: pos = motionAxisState.zValuePos; color = Z_BTN_COLOR; break; - case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break; + #if HAS_X_AXIS + case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break; + #endif + #if HAS_Y_AXIS + case Y_AXIS: pos = motionAxisState.yValuePos; color = Y_BTN_COLOR; break; + #endif + #if HAS_Z_AXIS + case Z_AXIS: pos = motionAxisState.zValuePos; color = Z_BTN_COLOR; break; + #endif + #if HAS_EXTRUDERS + case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break; + #endif default: return; } tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, BTN_HEIGHT); @@ -673,53 +708,57 @@ static void drawAxisValue(const AxisEnum axis) { static void moveAxis(const AxisEnum axis, const int8_t direction) { quick_feedback(); - if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { - drawMessage(F("Too cold")); - return; - } + #if HAS_EXTRUDERS + if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { + drawMessage(F("Too cold")); + return; + } + #endif const float diff = motionAxisState.currentStepSize * direction; - if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { - #if ENABLED(BABYSTEP_ZPROBE_OFFSET) - const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; - const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0; - const float bsDiff = planner.mm_per_step[Z_AXIS] * babystep_increment, - new_probe_offset = probe.offset.z + bsDiff, - new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET - , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff - , new_probe_offset - ); - if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { - babystep.add_steps(Z_AXIS, babystep_increment); - if (do_probe) - probe.offset.z = new_offs; + #if HAS_Z_AXIS + if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { + #if ENABLED(BABYSTEP_ZPROBE_OFFSET) + const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; + const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0; + const float bsDiff = planner.mm_per_step[Z_AXIS] * babystep_increment, + new_probe_offset = probe.offset.z + bsDiff, + new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET + , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff + , new_probe_offset + ); + if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { + babystep.add_steps(Z_AXIS, babystep_increment); + if (do_probe) + probe.offset.z = new_offs; + else + TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP); + drawMessage(F("")); // clear the error + drawAxisValue(axis); + } else - TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP); - drawMessage(F("")); // clear the error + drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); + + #elif HAS_BED_PROBE + // only change probe.offset.z + probe.offset.z += diff; + if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) { + current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN; + drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); + } + else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) { + current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX; + drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); + } + else + drawMessage(F("")); // clear the error + drawAxisValue(axis); - } - else - drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); - - #elif HAS_BED_PROBE - // only change probe.offset.z - probe.offset.z += diff; - if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) { - current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN; - drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); - } - else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) { - current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX; - drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); - } - else - drawMessage(F("")); // clear the error - - drawAxisValue(axis); - #endif - return; - } + #endif + return; + } + #endif // HAS_Z_AXIS if (!ui.manual_move.processing) { // Get motion limit from software endstops, if any @@ -729,7 +768,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { // Delta limits XY based on the current offset from center // This assumes the center is 0,0 #if ENABLED(DELTA) - if (axis != Z_AXIS && axis != E_AXIS) { + if (axis != Z_AXIS && TERN1(HAS_EXTRUDERS, axis != E_AXIS)) { max = SQRT(sq(float(PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis min = -max; } @@ -750,35 +789,44 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { drawAxisValue(axis); } -static void e_plus() { moveAxis(E_AXIS, 1); } -static void e_minus() { moveAxis(E_AXIS, -1); } -static void x_minus() { moveAxis(X_AXIS, -1); } -static void x_plus() { moveAxis(X_AXIS, 1); } -static void y_plus() { moveAxis(Y_AXIS, 1); } -static void y_minus() { moveAxis(Y_AXIS, -1); } -static void z_plus() { moveAxis(Z_AXIS, 1); } -static void z_minus() { moveAxis(Z_AXIS, -1); } +#if HAS_EXTRUDERS + static void e_plus() { moveAxis(E_AXIS, 1); } + static void e_minus() { moveAxis(E_AXIS, -1); } +#endif +#if HAS_X_AXIS + static void x_minus() { moveAxis(X_AXIS, -1); } + static void x_plus() { moveAxis(X_AXIS, 1); } +#endif +#if HAS_Y_AXIS + static void y_plus() { moveAxis(Y_AXIS, 1); } + static void y_minus() { moveAxis(Y_AXIS, -1); } +#endif +#if HAS_Z_AXIS + static void z_plus() { moveAxis(Z_AXIS, 1); } + static void z_minus() { moveAxis(Z_AXIS, -1); } +#endif #if ENABLED(TOUCH_SCREEN) - static void e_select() { - if (++motionAxisState.e_selection >= EXTRUDERS) - motionAxisState.e_selection = 0; - - quick_feedback(); - drawCurESelection(); - drawAxisValue(E_AXIS); - } + #if HAS_EXTRUDERS + static void e_select() { + if (++motionAxisState.e_selection >= EXTRUDERS) + motionAxisState.e_selection = 0; + quick_feedback(); + drawCurESelection(); + drawAxisValue(E_AXIS); + } + #endif static void do_home() { quick_feedback(); drawMessage(GET_TEXT_F(MSG_LEVEL_BED_HOMING)); queue.inject_P(G28_STR); // Disable touch until home is done - TERN_(TOUCH_SCREEN, touch.disable()); - drawAxisValue(E_AXIS); - drawAxisValue(X_AXIS); - drawAxisValue(Y_AXIS); - drawAxisValue(Z_AXIS); + touch.disable(); + TERN_(HAS_EXTRUDERS, drawAxisValue(E_AXIS)); + TERN_(HAS_X_AXIS, drawAxisValue(X_AXIS)); + TERN_(HAS_Y_AXIS, drawAxisValue(Y_AXIS)); + TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS)); } static void step_size() { @@ -845,7 +893,7 @@ void MarlinUI::move_axis_screen() { // ROW 1 -> E- Y- CurY Z+ int x = X_MARGIN, y = Y_MARGIN, spacing = 0; - drawBtn(x, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy); + TERN_(HAS_EXTRUDERS, drawBtn(x, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy)); spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; x += BTN_WIDTH + spacing; @@ -858,7 +906,9 @@ void MarlinUI::move_axis_screen() { drawAxisValue(Y_AXIS); x += spacing; - drawBtn(x, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #if HAS_Z_AXIS + drawBtn(x, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #endif // ROW 2 -> "Ex" X- HOME X+ "Z" y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; @@ -867,8 +917,10 @@ void MarlinUI::move_axis_screen() { motionAxisState.eNamePos.x = x; motionAxisState.eNamePos.y = y; - drawCurESelection(); - TERN_(TOUCH_SCREEN, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); + #if HAS_EXTRUDERS + drawCurESelection(); + TERN_(TOUCH_SCREEN, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); + #endif x += BTN_WIDTH + spacing; drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy); @@ -883,7 +935,7 @@ void MarlinUI::move_axis_screen() { x += BTN_WIDTH + spacing; motionAxisState.zTypePos.x = x; motionAxisState.zTypePos.y = y; - drawCurZSelection(); + TERN_(HAS_Z_AXIS, drawCurZSelection()); #if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, 34 * 2, (intptr_t)z_select); #endif @@ -893,12 +945,12 @@ void MarlinUI::move_axis_screen() { x = X_MARGIN; spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; - drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy); + TERN_(HAS_EXTRUDERS, drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy)); // Cur E motionAxisState.eValuePos.x = x; motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2; - drawAxisValue(E_AXIS); + TERN_(HAS_EXTRUDERS, drawAxisValue(E_AXIS)); // Cur X motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos @@ -909,12 +961,14 @@ void MarlinUI::move_axis_screen() { drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy); x += BTN_WIDTH + spacing; - drawBtn(x, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #if HAS_Z_AXIS + drawBtn(x, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #endif // Cur Z motionAxisState.zValuePos.x = x; motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2; - drawAxisValue(Z_AXIS); + TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS)); // ROW 4 -> step_size disable steppers back y = TFT_HEIGHT - Y_MARGIN - 32; // diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index bac7586a25..c2918711f4 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -126,8 +126,12 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { celsius_t currentTemperature, targetTemperature; if (Heater >= 0) { // HotEnd - currentTemperature = thermalManager.wholeDegHotend(Heater); - targetTemperature = thermalManager.degTargetHotend(Heater); + #if HAS_EXTRUDERS + currentTemperature = thermalManager.wholeDegHotend(Heater); + targetTemperature = thermalManager.degTargetHotend(Heater); + #else + return; + #endif } #if HAS_HEATED_BED else if (Heater == H_BED) { @@ -283,52 +287,59 @@ void MarlinUI::draw_status_screen() { #endif } else { - tft.add_text(TERN(TFT_COLOR_UI_PORTRAIT, 32, 10), tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , "X"); - const bool nhx = axis_should_home(X_AXIS); - tft_string.set(blink && nhx ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x))); - tft.add_text( - #if ENABLED(TFT_COLOR_UI_PORTRAIT) - 32 - tft_string.width() / 2, FONT_LINE_HEIGHT + tft_string.vcenter(FONT_LINE_HEIGHT), - #else - 68 - tft_string.width(), tft_string.vcenter(FONT_LINE_HEIGHT), - #endif - nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string - ); - - tft.add_text(TERN(TFT_COLOR_UI_PORTRAIT, 110, 127), tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , "Y"); - const bool nhy = axis_should_home(Y_AXIS); - tft_string.set(blink && nhy ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); - tft.add_text( - #if ENABLED(TFT_COLOR_UI_PORTRAIT) - 110 - tft_string.width() / 2, FONT_LINE_HEIGHT + tft_string.vcenter(FONT_LINE_HEIGHT), - #else - 185 - tft_string.width(), tft_string.vcenter(FONT_LINE_HEIGHT), - #endif - nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string - ); - } - - tft.add_text(TERN(TFT_COLOR_UI_PORTRAIT, 192, 219), tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , "Z"); - const bool nhz = axis_should_home(Z_AXIS); - uint16_t offset = 25; - if (blink && nhz) - tft_string.set('?'); - else { - const float z = LOGICAL_Z_POSITION(current_position.z); - tft_string.set(ftostr52sp((int16_t)z)); - tft_string.rtrim(); - offset += tft_string.width(); - - tft_string.set(ftostr52sp(z)); - offset -= tft_string.width(); - } - tft.add_text( - #if ENABLED(TFT_COLOR_UI_PORTRAIT) - 192 - tft_string.width() / 2, FONT_LINE_HEIGHT + tft_string.vcenter(FONT_LINE_HEIGHT), - #else - 301 - tft_string.width() - offset, tft_string.vcenter(FONT_LINE_HEIGHT), + #if HAS_X_AXIS + tft.add_text(TERN(TFT_COLOR_UI_PORTRAIT, 32, 10), tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , "X"); + const bool nhx = axis_should_home(X_AXIS); + tft_string.set(blink && nhx ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x))); + tft.add_text( + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 32 - tft_string.width() / 2, FONT_LINE_HEIGHT + tft_string.vcenter(FONT_LINE_HEIGHT), + #else + 68 - tft_string.width(), tft_string.vcenter(FONT_LINE_HEIGHT), + #endif + nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string + ); #endif - nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + + #if HAS_Y_AXIS + tft.add_text(TERN(TFT_COLOR_UI_PORTRAIT, 110, 127), tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , "Y"); + const bool nhy = axis_should_home(Y_AXIS); + tft_string.set(blink && nhy ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); + tft.add_text( + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 110 - tft_string.width() / 2, FONT_LINE_HEIGHT + tft_string.vcenter(FONT_LINE_HEIGHT), + #else + 185 - tft_string.width(), tft_string.vcenter(FONT_LINE_HEIGHT), + #endif + nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string + ); + #endif + } + + #if HAS_Z_AXIS + tft.add_text(TERN(TFT_COLOR_UI_PORTRAIT, 192, 219), tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , "Z"); + const bool nhz = axis_should_home(Z_AXIS); + uint16_t offset = 25; + if (blink && nhz) + tft_string.set('?'); + else { + const float z = LOGICAL_Z_POSITION(current_position.z); + tft_string.set(ftostr52sp((int16_t)z)); + tft_string.rtrim(); + offset += tft_string.width(); + + tft_string.set(ftostr52sp(z)); + offset -= tft_string.width(); + } + tft.add_text( + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 192 - tft_string.width() / 2, FONT_LINE_HEIGHT + tft_string.vcenter(FONT_LINE_HEIGHT), + #else + 301 - tft_string.width() - offset, tft_string.vcenter(FONT_LINE_HEIGHT), + #endif + nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + #endif + TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 0, 103, #if ENABLED(TFT_COLOR_UI_PORTRAIT) 232, FONT_LINE_HEIGHT * 2 @@ -361,29 +372,31 @@ void MarlinUI::draw_status_screen() { , 32 )); - // flow rate - tft.canvas( - #if ENABLED(TFT_COLOR_UI_PORTRAIT) - 140, 172, 80 - #else - 170, 136, 84 - #endif - , 32 - ); - tft.set_background(COLOR_BACKGROUND); - color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED; - tft.add_image(0, 0, imgFlowRate, color); - tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder])); - tft_string.add('%'); - tft.add_text(32, tft_string.vcenter(30), color , tft_string); - TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, - #if ENABLED(TFT_COLOR_UI_PORTRAIT) - 140, 172, 80 - #else - 170, 136, 84 - #endif - , 32, active_extruder - )); + // Flow rate + #if HAS_EXTRUDERS + tft.canvas( + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 140, 172, 80 + #else + 170, 136, 84 + #endif + , 32 + ); + tft.set_background(COLOR_BACKGROUND); + color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED; + tft.add_image(0, 0, imgFlowRate, color); + tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder])); + tft_string.add('%'); + tft.add_text(32, tft_string.vcenter(30), color , tft_string); + TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, + #if ENABLED(TFT_COLOR_UI_PORTRAIT) + 140, 172, 80 + #else + 170, 136, 84 + #endif + , 32, active_extruder + )); + #endif // HAS_EXTRUDERS // print duration char buffer[14]; @@ -666,16 +679,26 @@ void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, con #define Z_SELECTION_Z 1 #define Z_SELECTION_Z_PROBE -1 -struct MotionAxisState { - xy_int_t xValuePos, yValuePos, zValuePos, eValuePos, stepValuePos, zTypePos, eNamePos; +struct { + #if HAS_X_AXIS + xy_int_t xValuePos; + #endif + #if HAS_Y_AXIS + xy_int_t yValuePos; + #endif + #if HAS_Z_AXIS + xy_int_t zValuePos, zTypePos; + int z_selection = Z_SELECTION_Z; + #endif + #if HAS_EXTRUDERS + xy_int_t eValuePos, eNamePos; + uint8_t e_selection = 0; + #endif + xy_int_t stepValuePos; float currentStepSize = 10.0; - int z_selection = Z_SELECTION_Z; - uint8_t e_selection = 0; bool blocked = false; char message[32]; -}; - -MotionAxisState motionAxisState; +} motionAxisState; #define BTN_WIDTH 48 #define BTN_HEIGHT 39 @@ -706,27 +729,30 @@ static void drawCurStepValue() { tft.add_text(CUR_STEP_VALUE_WIDTH - tft_string.width(), 0, COLOR_AXIS_HOMED, tft_string); } -static void drawCurZSelection() { - tft_string.set('Z'); - tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 20); - tft.set_background(COLOR_BACKGROUND); - tft.add_text(0, 0, Z_BTN_COLOR, tft_string); - tft.queue.sync(); - tft_string.set(F("Offset")); - tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 20); - tft.set_background(COLOR_BACKGROUND); - if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { +#if HAS_Z_AXIS + static void drawCurZSelection() { + tft_string.set('Z'); + tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 20); + tft.set_background(COLOR_BACKGROUND); tft.add_text(0, 0, Z_BTN_COLOR, tft_string); + tft.queue.sync(); + tft_string.set(F("Offset")); + tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 20); + tft.set_background(COLOR_BACKGROUND); + if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) + tft.add_text(0, 0, Z_BTN_COLOR, tft_string); } -} +#endif -static void drawCurESelection() { - tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT); - tft.set_background(COLOR_BACKGROUND); - tft_string.set('E'); - tft.add_text(0, 0, E_BTN_COLOR , tft_string); - tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); -} +#if HAS_EXTRUDERS + static void drawCurESelection() { + tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft_string.set('E'); + tft.add_text(0, 0, E_BTN_COLOR , tft_string); + tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); + } +#endif static void drawMessage(PGM_P const msg) { tft.canvas(X_MARGIN, @@ -751,10 +777,18 @@ static void drawAxisValue(const AxisEnum axis) { xy_int_t pos; uint16_t color; switch (axis) { - case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break; - case Y_AXIS: pos = motionAxisState.yValuePos; color = Y_BTN_COLOR; break; - case Z_AXIS: pos = motionAxisState.zValuePos; color = Z_BTN_COLOR; break; - case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break; + #if HAS_X_AXIS + case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break; + #endif + #if HAS_Y_AXIS + case Y_AXIS: pos = motionAxisState.yValuePos; color = Y_BTN_COLOR; break; + #endif + #if HAS_Z_AXIS + case Z_AXIS: pos = motionAxisState.zValuePos; color = Z_BTN_COLOR; break; + #endif + #if HAS_EXTRUDERS + case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break; + #endif default: return; } tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, FONT_LINE_HEIGHT); @@ -766,53 +800,57 @@ static void drawAxisValue(const AxisEnum axis) { static void moveAxis(const AxisEnum axis, const int8_t direction) { quick_feedback(); - if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { - drawMessage(F("Too cold")); - return; - } + #if HAS_EXTRUDERS + if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { + drawMessage(F("Too cold")); + return; + } + #endif const float diff = motionAxisState.currentStepSize * direction; - if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { - #if ENABLED(BABYSTEP_ZPROBE_OFFSET) - const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; - const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0; - const float bsDiff = planner.mm_per_step[Z_AXIS] * babystep_increment, - new_probe_offset = probe.offset.z + bsDiff, - new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET - , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff - , new_probe_offset - ); - if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { - babystep.add_steps(Z_AXIS, babystep_increment); - if (do_probe) - probe.offset.z = new_offs; - else - TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP); - drawMessage(NUL_STR); // clear the error + #if HAS_Z_AXIS + if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { + #if ENABLED(BABYSTEP_ZPROBE_OFFSET) + const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; + const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0; + const float bsDiff = planner.mm_per_step[Z_AXIS] * babystep_increment, + new_probe_offset = probe.offset.z + bsDiff, + new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET + , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff + , new_probe_offset + ); + if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { + babystep.add_steps(Z_AXIS, babystep_increment); + if (do_probe) + probe.offset.z = new_offs; + else + TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP); + drawMessage(NUL_STR); // clear the error + drawAxisValue(axis); + } + else { + drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); + } + #elif HAS_BED_PROBE + // only change probe.offset.z + probe.offset.z += diff; + if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) { + current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN; + drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); + } + else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) { + current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX; + drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); + } + else { + drawMessage(NUL_STR); // clear the error + } drawAxisValue(axis); - } - else { - drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); - } - #elif HAS_BED_PROBE - // only change probe.offset.z - probe.offset.z += diff; - if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) { - current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN; - drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); - } - else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) { - current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX; - drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); - } - else { - drawMessage(NUL_STR); // clear the error - } - drawAxisValue(axis); - #endif - return; - } + #endif + return; + } + #endif // HAS_Z_AXIS if (!ui.manual_move.processing) { // Get motion limit from software endstops, if any @@ -822,7 +860,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { // Delta limits XY based on the current offset from center // This assumes the center is 0,0 #if ENABLED(DELTA) - if (axis != Z_AXIS && axis != E_AXIS) { + if (axis != Z_AXIS && TERN1(HAS_EXTRUDERS, axis != E_AXIS)) { max = SQRT(sq(float(PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis min = -max; } @@ -843,35 +881,44 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { drawAxisValue(axis); } -static void e_plus() { moveAxis(E_AXIS, 1); } -static void e_minus() { moveAxis(E_AXIS, -1); } -static void x_minus() { moveAxis(X_AXIS, -1); } -static void x_plus() { moveAxis(X_AXIS, 1); } -static void y_plus() { moveAxis(Y_AXIS, 1); } -static void y_minus() { moveAxis(Y_AXIS, -1); } -static void z_plus() { moveAxis(Z_AXIS, 1); } -static void z_minus() { moveAxis(Z_AXIS, -1); } +#if HAS_EXTRUDERS + static void e_plus() { moveAxis(E_AXIS, 1); } + static void e_minus() { moveAxis(E_AXIS, -1); } +#endif +#if HAS_X_AXIS + static void x_minus() { moveAxis(X_AXIS, -1); } + static void x_plus() { moveAxis(X_AXIS, 1); } +#endif +#if HAS_Y_AXIS + static void y_plus() { moveAxis(Y_AXIS, 1); } + static void y_minus() { moveAxis(Y_AXIS, -1); } +#endif +#if HAS_Z_AXIS + static void z_plus() { moveAxis(Z_AXIS, 1); } + static void z_minus() { moveAxis(Z_AXIS, -1); } +#endif #if ENABLED(TOUCH_SCREEN) - static void e_select() { - if (++motionAxisState.e_selection >= EXTRUDERS) - motionAxisState.e_selection = 0; - - quick_feedback(); - drawCurESelection(); - drawAxisValue(E_AXIS); - } + #if HAS_EXTRUDERS + static void e_select() { + if (++motionAxisState.e_selection >= EXTRUDERS) + motionAxisState.e_selection = 0; + quick_feedback(); + drawCurESelection(); + drawAxisValue(E_AXIS); + } + #endif static void do_home() { quick_feedback(); drawMessage(GET_TEXT_F(MSG_LEVEL_BED_HOMING)); queue.inject_P(G28_STR); // Disable touch until home is done - TERN_(HAS_TFT_XPT2046, touch.disable()); - drawAxisValue(E_AXIS); - drawAxisValue(X_AXIS); - drawAxisValue(Y_AXIS); - drawAxisValue(Z_AXIS); + touch.disable(); + TERN_(HAS_EXTRUDERS, drawAxisValue(E_AXIS)); + TERN_(HAS_X_AXIS, drawAxisValue(X_AXIS)); + TERN_(HAS_Y_AXIS, drawAxisValue(Y_AXIS)); + TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS)); } static void step_size() { @@ -916,14 +963,14 @@ static void drawBtn(int x, int y, const char *label, intptr_t data, MarlinImage else tft.add_image(0, 0, img, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY); - TERN_(HAS_TFT_XPT2046, if (enabled) touch.add_control(BUTTON, x, y, width, height, data)); + TERN_(TOUCH_SCREEN, if (enabled) touch.add_control(BUTTON, x, y, width, height, data)); } void MarlinUI::move_axis_screen() { // Reset defer_status_screen(true); motionAxisState.blocked = false; - TERN_(HAS_TFT_XPT2046, touch.enable()); + TERN_(TOUCH_SCREEN, touch.enable()); ui.clear_lcd(); @@ -949,7 +996,9 @@ void MarlinUI::move_axis_screen() { x += BTN_WIDTH + spacing; uint16_t zplus_x = x; - drawBtn(x, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #if HAS_Z_AXIS + drawBtn(x, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #endif // ROW 2 -> "Ex" CurY "Z" x = X_MARGIN; @@ -957,8 +1006,10 @@ void MarlinUI::move_axis_screen() { motionAxisState.eNamePos.x = x; motionAxisState.eNamePos.y = y; - drawCurESelection(); - TERN_(HAS_TFT_XPT2046, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); + #if HAS_EXTRUDERS + drawCurESelection(); + TERN_(TOUCH_SCREEN, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); + #endif motionAxisState.yValuePos.x = yplus_x; motionAxisState.yValuePos.y = y; @@ -966,7 +1017,7 @@ void MarlinUI::move_axis_screen() { motionAxisState.zTypePos.x = zplus_x; motionAxisState.zTypePos.y = y; - drawCurZSelection(); + TERN_(HAS_Z_AXIS, drawCurZSelection()); // ROW 3 -> X- HOME X+ y += (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3 - 2; @@ -974,7 +1025,7 @@ void MarlinUI::move_axis_screen() { drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy); - TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy)); + TERN_(TOUCH_SCREEN, add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy)); drawBtn(zplus_x, y, "X+", (intptr_t)x_plus, imgRight, X_BTN_COLOR, !busy); @@ -993,23 +1044,27 @@ void MarlinUI::move_axis_screen() { y += (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3 - 2; x = X_MARGIN; - drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy); + #if HAS_EXTRUDERS + drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy); + #endif // Cur E motionAxisState.eValuePos.x = x; motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2; - drawAxisValue(E_AXIS); + TERN_(HAS_EXTRUDERS, drawAxisValue(E_AXIS)); x += BTN_WIDTH + spacing; drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy); x += BTN_WIDTH + spacing; - drawBtn(x, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #if HAS_Z_AXIS + drawBtn(x, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #endif // Cur Z motionAxisState.zValuePos.x = x; motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2; - drawAxisValue(Z_AXIS); + TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS)); // ROW 6 -> step_size disable steppers back y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT; // @@ -1019,7 +1074,7 @@ void MarlinUI::move_axis_screen() { if (!busy) { drawCurStepValue(); - TERN_(HAS_TFT_XPT2046, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size)); + TERN_(TOUCH_SCREEN, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size)); } // aligned with x+ @@ -1030,7 +1085,7 @@ void MarlinUI::move_axis_screen() { // ROW 1 -> E+ Y+ CurY Z+ int x = X_MARGIN, y = Y_MARGIN, spacing = 0; - drawBtn(x, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy); + TERN_(HAS_EXTRUDERS, drawBtn(x, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy)); spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; x += BTN_WIDTH + spacing; @@ -1044,7 +1099,9 @@ void MarlinUI::move_axis_screen() { drawAxisValue(Y_AXIS); x += spacing; - drawBtn(x, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #if HAS_Z_AXIS + drawBtn(x, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #endif // ROW 2 -> "Ex" X- HOME X+ "Z" y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; @@ -1053,14 +1110,16 @@ void MarlinUI::move_axis_screen() { motionAxisState.eNamePos.x = x; motionAxisState.eNamePos.y = y; - drawCurESelection(); - TERN_(HAS_TFT_XPT2046, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); + #if HAS_EXTRUDERS + drawCurESelection(); + TERN_(TOUCH_SCREEN, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); + #endif x += BTN_WIDTH + spacing; drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy); x += BTN_WIDTH + spacing; //imgHome is 64x64 - TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy)); + TERN_(TOUCH_SCREEN, add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy)); x += BTN_WIDTH + spacing; uint16_t xplus_x = x; @@ -1069,9 +1128,9 @@ void MarlinUI::move_axis_screen() { x += BTN_WIDTH + spacing; motionAxisState.zTypePos.x = x; motionAxisState.zTypePos.y = y; - drawCurZSelection(); + TERN_(HAS_Z_AXIS, drawCurZSelection()); #if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) - if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, 34 * 2, (intptr_t)z_select); + if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, 34 * 2, (intptr_t)z_select); #endif // ROW 3 -> E- CurX Y- Z- @@ -1079,12 +1138,12 @@ void MarlinUI::move_axis_screen() { x = X_MARGIN; spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; - drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy); + TERN_(HAS_EXTRUDERS, drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy)); // Cur E motionAxisState.eValuePos.x = x; motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2; - drawAxisValue(E_AXIS); + TERN_(HAS_EXTRUDERS, drawAxisValue(E_AXIS)); // Cur X motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos @@ -1095,12 +1154,14 @@ void MarlinUI::move_axis_screen() { drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy); x += BTN_WIDTH + spacing; - drawBtn(x, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #if HAS_Z_AXIS + drawBtn(x, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #endif // Cur Z motionAxisState.zValuePos.x = x; motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2; - drawAxisValue(Z_AXIS); + TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS)); // ROW 4 -> step_size disable steppers back y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT; // @@ -1109,7 +1170,7 @@ void MarlinUI::move_axis_screen() { motionAxisState.stepValuePos.y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT; if (!busy) { drawCurStepValue(); - TERN_(HAS_TFT_XPT2046, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size)); + TERN_(TOUCH_SCREEN, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size)); } // aligned with x+ @@ -1117,7 +1178,7 @@ void MarlinUI::move_axis_screen() { #endif // !TFT_COLOR_UI_PORTRAIT - TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack)); + TERN_(TOUCH_SCREEN, add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack)); } #endif // HAS_UI_320x240 diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index bc4ea0e5e2..e1ddfe5e1a 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -124,8 +124,12 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { celsius_t currentTemperature, targetTemperature; if (Heater >= 0) { // HotEnd - currentTemperature = thermalManager.wholeDegHotend(Heater); - targetTemperature = thermalManager.degTargetHotend(Heater); + #if HAS_EXTRUDERS + currentTemperature = thermalManager.wholeDegHotend(Heater); + targetTemperature = thermalManager.degTargetHotend(Heater); + #else + return; + #endif } #if HAS_HEATED_BED else if (Heater == H_BED) { @@ -271,31 +275,37 @@ void MarlinUI::draw_status_screen() { } else { // Coords in mask "X____Y____Z____" - tft_string.set("X"); - tft.add_text(coords_width / 30 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED, tft_string); + #if HAS_X_AXIS + tft_string.set("X"); + tft.add_text(coords_width / 30 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED, tft_string); - const bool nhx = axis_should_home(X_AXIS); - tft_string.set(blink && nhx ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x))); - tft_string.ltrim(); - tft.add_text(coords_width / 5 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + const bool nhx = axis_should_home(X_AXIS); + tft_string.set(blink && nhx ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x))); + tft_string.ltrim(); + tft.add_text(coords_width / 5 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + #endif - tft_string.set("Y"); - tft.add_text(11 * coords_width / 30 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED, tft_string); + #if HAS_Y_AXIS + tft_string.set("Y"); + tft.add_text(11 * coords_width / 30 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED, tft_string); - const bool nhy = axis_should_home(Y_AXIS); - tft_string.set(blink && nhy ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); - tft_string.ltrim(); - tft.add_text(8 * coords_width / 15 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + const bool nhy = axis_should_home(Y_AXIS); + tft_string.set(blink && nhy ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); + tft_string.ltrim(); + tft.add_text(8 * coords_width / 15 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + #endif } - tft_string.set("Z"); - tft.add_text(7 * coords_width / 10 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED, tft_string); + #if HAS_Z_AXIS + tft_string.set("Z"); + tft.add_text(7 * coords_width / 10 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED, tft_string); - const bool nhz = axis_should_home(Z_AXIS); - tft_string.set(blink && nhz ? "?" : ftostr52sp(LOGICAL_Z_POSITION(current_position.z))); - tft_string.ltrim(); - tft_string.rtrim(); - tft.add_text(13 * coords_width / 15 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + const bool nhz = axis_should_home(Z_AXIS); + tft_string.set(blink && nhz ? "?" : ftostr52sp(LOGICAL_Z_POSITION(current_position.z))); + tft_string.ltrim(); + tft_string.rtrim(); + tft.add_text(13 * coords_width / 15 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + #endif TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT)); @@ -315,19 +325,21 @@ void MarlinUI::draw_status_screen() { tft.add_text(36, tft_string.vcenter(30), color , tft_string); TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, x, y, component_width, 32)); - // Flow rate (preparing) - tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder])); - tft_string.add('%'); - component_width = 36 + tft_string.width(); - color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED; - x = FLOWRATE_X(component_width); + #if HAS_EXTRUDERS + // Flow rate (preparing) + tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder])); + tft_string.add('%'); + component_width = 36 + tft_string.width(); + color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED; + x = FLOWRATE_X(component_width); - // Flow rate (drawing) - tft.canvas(x, y, component_width, 32); - tft.set_background(COLOR_BACKGROUND); - tft.add_image(0, 0, imgFlowRate, color); - tft.add_text(36, tft_string.vcenter(30), color , tft_string); - TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, x, y, component_width, 32, active_extruder)); + // Flow rate (drawing) + tft.canvas(x, y, component_width, 32); + tft.set_background(COLOR_BACKGROUND); + tft.add_image(0, 0, imgFlowRate, color); + tft.add_text(36, tft_string.vcenter(30), color , tft_string); + TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, x, y, component_width, 32, active_extruder)); + #endif #if TFT_COLOR_UI_PORTRAIT || DISABLED(TOUCH_SCREEN) y += STATUS_MARGIN_SIZE + 32; @@ -586,16 +598,26 @@ void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, con #define Z_SELECTION_Z 1 #define Z_SELECTION_Z_PROBE -1 -struct MotionAxisState { - xy_int_t xValuePos, yValuePos, zValuePos, eValuePos, stepValuePos, zTypePos, eNamePos; +struct { + #if HAS_X_AXIS + xy_int_t xValuePos; + #endif + #if HAS_Y_AXIS + xy_int_t yValuePos; + #endif + #if HAS_Z_AXIS + xy_int_t zValuePos, zTypePos; + int z_selection = Z_SELECTION_Z; + #endif + #if HAS_EXTRUDERS + xy_int_t eValuePos, eNamePos; + uint8_t e_selection = 0; + #endif + xy_int_t stepValuePos; float currentStepSize = 10.0; - int z_selection = Z_SELECTION_Z; - uint8_t e_selection = 0; bool blocked = false; char message[32]; -}; - -MotionAxisState motionAxisState; +} motionAxisState; #define BTN_WIDTH 64 #define BTN_HEIGHT 52 @@ -622,27 +644,30 @@ static void drawCurStepValue() { tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string); } -static void drawCurZSelection() { - tft_string.set('Z'); - tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34); - tft.set_background(COLOR_BACKGROUND); - tft.add_text(0, 0, Z_BTN_COLOR, tft_string); - tft.queue.sync(); - tft_string.set(F("Offset")); - tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34); - tft.set_background(COLOR_BACKGROUND); - if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { +#if HAS_Z_AXIS + static void drawCurZSelection() { + tft_string.set('Z'); + tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34); + tft.set_background(COLOR_BACKGROUND); tft.add_text(0, 0, Z_BTN_COLOR, tft_string); + tft.queue.sync(); + tft_string.set(F("Offset")); + tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34); + tft.set_background(COLOR_BACKGROUND); + if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) + tft.add_text(0, 0, Z_BTN_COLOR, tft_string); } -} +#endif -static void drawCurESelection() { - tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT); - tft.set_background(COLOR_BACKGROUND); - tft_string.set('E'); - tft.add_text(0, 0, E_BTN_COLOR , tft_string); - tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); -} +#if HAS_EXTRUDERS + static void drawCurESelection() { + tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft_string.set('E'); + tft.add_text(0, 0, E_BTN_COLOR , tft_string); + tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); + } +#endif static void drawMessage(PGM_P const msg) { tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 34, TFT_HEIGHT / 2, 34); @@ -660,10 +685,18 @@ static void drawAxisValue(const AxisEnum axis) { xy_int_t pos; uint16_t color; switch (axis) { - case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break; - case Y_AXIS: pos = motionAxisState.yValuePos; color = Y_BTN_COLOR; break; - case Z_AXIS: pos = motionAxisState.zValuePos; color = Z_BTN_COLOR; break; - case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break; + #if HAS_X_AXIS + case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break; + #endif + #if HAS_Y_AXIS + case Y_AXIS: pos = motionAxisState.yValuePos; color = Y_BTN_COLOR; break; + #endif + #if HAS_Z_AXIS + case Z_AXIS: pos = motionAxisState.zValuePos; color = Z_BTN_COLOR; break; + #endif + #if HAS_EXTRUDERS + case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break; + #endif default: return; } tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, BTN_HEIGHT); @@ -675,53 +708,57 @@ static void drawAxisValue(const AxisEnum axis) { static void moveAxis(const AxisEnum axis, const int8_t direction) { quick_feedback(); - if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { - drawMessage(F("Too cold")); - return; - } + #if HAS_EXTRUDERS + if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { + drawMessage(F("Too cold")); + return; + } + #endif const float diff = motionAxisState.currentStepSize * direction; - if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { - #if ENABLED(BABYSTEP_ZPROBE_OFFSET) - const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; - const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0; - const float bsDiff = planner.mm_per_step[Z_AXIS] * babystep_increment, - new_probe_offset = probe.offset.z + bsDiff, - new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET - , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff - , new_probe_offset - ); - if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { - babystep.add_steps(Z_AXIS, babystep_increment); - if (do_probe) - probe.offset.z = new_offs; - else - TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP); - drawMessage(NUL_STR); // clear the error + #if HAS_Z_AXIS + if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { + #if ENABLED(BABYSTEP_ZPROBE_OFFSET) + const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; + const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0; + const float bsDiff = planner.mm_per_step[Z_AXIS] * babystep_increment, + new_probe_offset = probe.offset.z + bsDiff, + new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET + , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff + , new_probe_offset + ); + if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { + babystep.add_steps(Z_AXIS, babystep_increment); + if (do_probe) + probe.offset.z = new_offs; + else + TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP); + drawMessage(NUL_STR); // clear the error + drawAxisValue(axis); + } + else { + drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); + } + #elif HAS_BED_PROBE + // only change probe.offset.z + probe.offset.z += diff; + if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) { + current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN; + drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); + } + else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) { + current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX; + drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); + } + else { + drawMessage(NUL_STR); // clear the error + } drawAxisValue(axis); - } - else { - drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); - } - #elif HAS_BED_PROBE - // only change probe.offset.z - probe.offset.z += diff; - if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) { - current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN; - drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); - } - else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) { - current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX; - drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); - } - else { - drawMessage(NUL_STR); // clear the error - } - drawAxisValue(axis); - #endif - return; - } + #endif + return; + } + #endif // HAS_Z_AXIS if (!ui.manual_move.processing) { // Get motion limit from software endstops, if any @@ -731,7 +768,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { // Delta limits XY based on the current offset from center // This assumes the center is 0,0 #if ENABLED(DELTA) - if (axis != Z_AXIS && axis != E_AXIS) { + if (axis != Z_AXIS && TERN1(HAS_EXTRUDERS, axis != E_AXIS)) { max = SQRT(sq(float(PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis min = -max; } @@ -752,35 +789,44 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { drawAxisValue(axis); } -static void e_plus() { moveAxis(E_AXIS, 1); } -static void e_minus() { moveAxis(E_AXIS, -1); } -static void x_minus() { moveAxis(X_AXIS, -1); } -static void x_plus() { moveAxis(X_AXIS, 1); } -static void y_plus() { moveAxis(Y_AXIS, 1); } -static void y_minus() { moveAxis(Y_AXIS, -1); } -static void z_plus() { moveAxis(Z_AXIS, 1); } -static void z_minus() { moveAxis(Z_AXIS, -1); } +#if HAS_EXTRUDERS + static void e_plus() { moveAxis(E_AXIS, 1); } + static void e_minus() { moveAxis(E_AXIS, -1); } +#endif +#if HAS_X_AXIS + static void x_minus() { moveAxis(X_AXIS, -1); } + static void x_plus() { moveAxis(X_AXIS, 1); } +#endif +#if HAS_Y_AXIS + static void y_plus() { moveAxis(Y_AXIS, 1); } + static void y_minus() { moveAxis(Y_AXIS, -1); } +#endif +#if HAS_Z_AXIS + static void z_plus() { moveAxis(Z_AXIS, 1); } + static void z_minus() { moveAxis(Z_AXIS, -1); } +#endif #if ENABLED(TOUCH_SCREEN) - static void e_select() { - if (++motionAxisState.e_selection >= EXTRUDERS) - motionAxisState.e_selection = 0; - - quick_feedback(); - drawCurESelection(); - drawAxisValue(E_AXIS); - } + #if HAS_EXTRUDERS + static void e_select() { + if (++motionAxisState.e_selection >= EXTRUDERS) + motionAxisState.e_selection = 0; + quick_feedback(); + drawCurESelection(); + drawAxisValue(E_AXIS); + } + #endif static void do_home() { quick_feedback(); drawMessage(GET_TEXT_F(MSG_LEVEL_BED_HOMING)); queue.inject_P(G28_STR); // Disable touch until home is done - TERN_(HAS_TFT_XPT2046, touch.disable()); - drawAxisValue(E_AXIS); - drawAxisValue(X_AXIS); - drawAxisValue(Y_AXIS); - drawAxisValue(Z_AXIS); + touch.disable(); + TERN_(HAS_EXTRUDERS, drawAxisValue(E_AXIS)); + TERN_(HAS_X_AXIS, drawAxisValue(X_AXIS)); + TERN_(HAS_Y_AXIS, drawAxisValue(Y_AXIS)); + TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS)); } static void step_size() { @@ -789,7 +835,7 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } quick_feedback(); drawCurStepValue(); } -#endif +#endif // TOUCH_SCREEN #if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) static void z_select() { @@ -825,14 +871,14 @@ static void drawBtn(int x, int y, const char *label, intptr_t data, MarlinImage tft.add_image(0, 0, img, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY); } - TERN_(HAS_TFT_XPT2046, if (enabled) touch.add_control(BUTTON, x, y, width, height, data)); + TERN_(TOUCH_SCREEN, if (enabled) touch.add_control(BUTTON, x, y, width, height, data)); } void MarlinUI::move_axis_screen() { // Reset defer_status_screen(true); motionAxisState.blocked = false; - TERN_(HAS_TFT_XPT2046, touch.enable()); + TERN_(TOUCH_SCREEN, touch.enable()); ui.clear_lcd(); @@ -842,25 +888,31 @@ void MarlinUI::move_axis_screen() { // Babysteps during printing? Select babystep for Z probe offset if (busy && ENABLED(BABYSTEP_ZPROBE_OFFSET)) - motionAxisState.z_selection = Z_SELECTION_Z_PROBE; + + TERN_(HAS_Z_AXIS, motionAxisState.z_selection = Z_SELECTION_Z_PROBE); // ROW 1 -> E- Y- CurY Z+ int x = X_MARGIN, y = Y_MARGIN, spacing = 0; - drawBtn(x, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy); + TERN_(HAS_EXTRUDERS, drawBtn(x, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy)); spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; x += BTN_WIDTH + spacing; - drawBtn(x, y, "Y+", (intptr_t)y_plus, imgUp, Y_BTN_COLOR, !busy); + + TERN_(HAS_Y_AXIS, drawBtn(x, y, "Y+", (intptr_t)y_plus, imgUp, Y_BTN_COLOR, !busy)); // Cur Y x += BTN_WIDTH; - motionAxisState.yValuePos.x = x + 2; - motionAxisState.yValuePos.y = y; - drawAxisValue(Y_AXIS); + #if HAS_Y_AXIS + motionAxisState.yValuePos.x = x + 2; + motionAxisState.yValuePos.y = y; + drawAxisValue(Y_AXIS); + #endif x += spacing; - drawBtn(x, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #if HAS_Z_AXIS + drawBtn(x, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #endif // ROW 2 -> "Ex" X- HOME X+ "Z" y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; @@ -869,14 +921,16 @@ void MarlinUI::move_axis_screen() { motionAxisState.eNamePos.x = x; motionAxisState.eNamePos.y = y; - drawCurESelection(); - TERN_(HAS_TFT_XPT2046, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); + #if HAS_EXTRUDERS + drawCurESelection(); + TERN_(TOUCH_SCREEN, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); + #endif x += BTN_WIDTH + spacing; drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy); x += BTN_WIDTH + spacing; //imgHome is 64x64 - TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy)); + TERN_(TOUCH_SCREEN, add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy)); x += BTN_WIDTH + spacing; uint16_t xplus_x = x; @@ -885,7 +939,7 @@ void MarlinUI::move_axis_screen() { x += BTN_WIDTH + spacing; motionAxisState.zTypePos.x = x; motionAxisState.zTypePos.y = y; - drawCurZSelection(); + TERN_(HAS_Z_AXIS, drawCurZSelection()); #if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, 34 * 2, (intptr_t)z_select); #endif @@ -895,28 +949,30 @@ void MarlinUI::move_axis_screen() { x = X_MARGIN; spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; - drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy); + TERN_(HAS_EXTRUDERS, drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy)); // Cur E motionAxisState.eValuePos.x = x; motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2; - drawAxisValue(E_AXIS); + TERN_(HAS_EXTRUDERS, drawAxisValue(E_AXIS)); // Cur X motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos motionAxisState.xValuePos.y = y - 10; - drawAxisValue(X_AXIS); + TERN_(HAS_X_AXIS, drawAxisValue(X_AXIS)); x += BTN_WIDTH + spacing; drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy); x += BTN_WIDTH + spacing; - drawBtn(x, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #if HAS_Z_AXIS + drawBtn(x, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + #endif // Cur Z motionAxisState.zValuePos.x = x; motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2; - drawAxisValue(Z_AXIS); + TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS)); // ROW 4 -> step_size disable steppers back y = TFT_HEIGHT - Y_MARGIN - 32; @@ -925,13 +981,13 @@ void MarlinUI::move_axis_screen() { motionAxisState.stepValuePos.y = y; if (!busy) { drawCurStepValue(); - TERN_(HAS_TFT_XPT2046, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size)); + TERN_(TOUCH_SCREEN, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size)); } // aligned with x+ drawBtn(xplus_x, TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT, "off", (intptr_t)disable_steppers, imgCancel, COLOR_WHITE, !busy); - TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack)); + TERN_(TOUCH_SCREEN, add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack)); } #endif // HAS_UI_480x320