🚸 TFT optional axes/extruder (#25624)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Alexey D. Filimonov 2023-05-14 00:25:36 +03:00 committed by GitHub
parent 06aed792c0
commit d5fdbb89ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 662 additions and 487 deletions

View File

@ -222,6 +222,8 @@ void Touch::touch(touch_control_t *control) {
ui.clear_lcd(); ui.clear_lcd();
MenuItem_int3::action(GET_TEXT_F(MSG_SPEED), &feedrate_percentage, 10, 999); MenuItem_int3::action(GET_TEXT_F(MSG_SPEED), &feedrate_percentage, 10, 999);
break; break;
#if HAS_EXTRUDERS
case FLOWRATE: case FLOWRATE:
ui.clear_lcd(); ui.clear_lcd();
MenuItemBase::itemIndex = control->data; MenuItemBase::itemIndex = control->data;
@ -231,6 +233,8 @@ void Touch::touch(touch_control_t *control) {
MenuItem_int3::action(GET_TEXT_F(MSG_FLOW_N), &planner.flow_percentage[MenuItemBase::itemIndex], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); MenuItem_int3::action(GET_TEXT_F(MSG_FLOW_N), &planner.flow_percentage[MenuItemBase::itemIndex], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); });
#endif #endif
break; break;
#endif
case STOP: case STOP:
ui.goto_screen([]{ ui.goto_screen([]{
MenuItem_confirm::select_screen(GET_TEXT_F(MSG_BUTTON_STOP), MenuItem_confirm::select_screen(GET_TEXT_F(MSG_BUTTON_STOP),

View File

@ -124,8 +124,12 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
celsius_t currentTemperature, targetTemperature; celsius_t currentTemperature, targetTemperature;
if (Heater >= 0) { // HotEnd if (Heater >= 0) { // HotEnd
#if HAS_EXTRUDERS
currentTemperature = thermalManager.wholeDegHotend(Heater); currentTemperature = thermalManager.wholeDegHotend(Heater);
targetTemperature = thermalManager.degTargetHotend(Heater); targetTemperature = thermalManager.degTargetHotend(Heater);
#else
return;
#endif
} }
#if HAS_HEATED_BED #if HAS_HEATED_BED
else if (Heater == H_BED) { else if (Heater == H_BED) {
@ -270,6 +274,7 @@ void MarlinUI::draw_status_screen() {
#endif #endif
} }
else { else {
#if HAS_X_AXIS
tft.add_text(200, 3, COLOR_AXIS_HOMED , "X"); tft.add_text(200, 3, COLOR_AXIS_HOMED , "X");
const bool nhx = axis_should_home(X_AXIS); const bool nhx = axis_should_home(X_AXIS);
if (blink && nhx) if (blink && nhx)
@ -277,7 +282,9 @@ void MarlinUI::draw_status_screen() {
else else
tft_string.set(ftostr4sign(LOGICAL_X_POSITION(current_position.x))); 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); tft.add_text(300 - tft_string.width(), 3, nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
#endif
#if HAS_Y_AXIS
tft.add_text(500, 3, COLOR_AXIS_HOMED , "Y"); tft.add_text(500, 3, COLOR_AXIS_HOMED , "Y");
const bool nhy = axis_should_home(Y_AXIS); const bool nhy = axis_should_home(Y_AXIS);
if (blink && nhy) if (blink && nhy)
@ -285,7 +292,10 @@ void MarlinUI::draw_status_screen() {
else else
tft_string.set(ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); 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); tft.add_text(600 - tft_string.width(), 3, nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
#endif
} }
#if HAS_Z_AXIS
tft.add_text(800, 3, COLOR_AXIS_HOMED , "Z"); tft.add_text(800, 3, COLOR_AXIS_HOMED , "Z");
uint16_t offset = 32; uint16_t offset = 32;
const bool nhz = axis_should_home(Z_AXIS); const bool nhz = axis_should_home(Z_AXIS);
@ -301,6 +311,8 @@ void MarlinUI::draw_status_screen() {
offset -= tft_string.width(); offset -= tft_string.width();
} }
tft.add_text(900 - tft_string.width() - offset, 3, nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); 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)); TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT));
y += 100; y += 100;
@ -314,7 +326,8 @@ void MarlinUI::draw_status_screen() {
tft.add_text(36, 1, color , tft_string); tft.add_text(36, 1, color , tft_string);
TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, 274, y, 128, 32)); TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, 274, y, 128, 32));
// flow rate // Flow rate
#if HAS_EXTRUDERS
tft.canvas(650, y, 128, 32); tft.canvas(650, y, 128, 32);
tft.set_background(COLOR_BACKGROUND); tft.set_background(COLOR_BACKGROUND);
color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED; color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
@ -323,6 +336,7 @@ void MarlinUI::draw_status_screen() {
tft_string.add('%'); tft_string.add('%');
tft.add_text(36, 1, color , tft_string); tft.add_text(36, 1, color , tft_string);
TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, 650, y, 128, 32, active_extruder)); TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, 650, y, 128, 32, active_extruder));
#endif
#if ENABLED(TOUCH_SCREEN) #if ENABLED(TOUCH_SCREEN)
add_control(900, y, menu_main, imgSettings); 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 1
#define Z_SELECTION_Z_PROBE -1 #define Z_SELECTION_Z_PROBE -1
struct MotionAxisState { struct {
xy_int_t xValuePos, yValuePos, zValuePos, eValuePos, stepValuePos, zTypePos, eNamePos; #if HAS_X_AXIS
float currentStepSize = 10.0; 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; int z_selection = Z_SELECTION_Z;
#endif
#if HAS_EXTRUDERS
xy_int_t eValuePos, eNamePos;
uint8_t e_selection = 0; uint8_t e_selection = 0;
#endif
xy_int_t stepValuePos;
float currentStepSize = 10.0;
bool blocked = false; bool blocked = false;
char message[32]; char message[32];
}; } motionAxisState;
MotionAxisState motionAxisState;
#define BTN_WIDTH 64 #define BTN_WIDTH 64
#define BTN_HEIGHT 52 #define BTN_HEIGHT 52
@ -620,6 +644,7 @@ static void drawCurStepValue() {
tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string); tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string);
} }
#if HAS_Z_AXIS
static void drawCurZSelection() { static void drawCurZSelection() {
tft_string.set('Z'); tft_string.set('Z');
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34); tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34);
@ -629,11 +654,12 @@ static void drawCurZSelection() {
tft_string.set(F("Offset")); tft_string.set(F("Offset"));
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34); tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34);
tft.set_background(COLOR_BACKGROUND); tft.set_background(COLOR_BACKGROUND);
if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE)
tft.add_text(0, 0, Z_BTN_COLOR, tft_string); tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
} }
} #endif
#if HAS_EXTRUDERS
static void drawCurESelection() { static void drawCurESelection() {
tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT); tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT);
tft.set_background(COLOR_BACKGROUND); tft.set_background(COLOR_BACKGROUND);
@ -641,6 +667,7 @@ static void drawCurESelection() {
tft.add_text(0, 0, E_BTN_COLOR , tft_string); tft.add_text(0, 0, E_BTN_COLOR , tft_string);
tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection));
} }
#endif
static void drawMessage(PGM_P const msg) { static void drawMessage(PGM_P const msg) {
tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 34, TFT_HEIGHT / 2, 34); 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; xy_int_t pos;
uint16_t color; uint16_t color;
switch (axis) { switch (axis) {
#if HAS_X_AXIS
case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break; 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; 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; 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; case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break;
#endif
default: return; default: return;
} }
tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, BTN_HEIGHT); tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, BTN_HEIGHT);
@ -673,13 +708,16 @@ static void drawAxisValue(const AxisEnum axis) {
static void moveAxis(const AxisEnum axis, const int8_t direction) { static void moveAxis(const AxisEnum axis, const int8_t direction) {
quick_feedback(); quick_feedback();
#if HAS_EXTRUDERS
if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) {
drawMessage(F("Too cold")); drawMessage(F("Too cold"));
return; return;
} }
#endif
const float diff = motionAxisState.currentStepSize * direction; const float diff = motionAxisState.currentStepSize * direction;
#if HAS_Z_AXIS
if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) {
#if ENABLED(BABYSTEP_ZPROBE_OFFSET) #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z;
@ -720,6 +758,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
#endif #endif
return; return;
} }
#endif // HAS_Z_AXIS
if (!ui.manual_move.processing) { if (!ui.manual_move.processing) {
// Get motion limit from software endstops, if any // 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 // Delta limits XY based on the current offset from center
// This assumes the center is 0,0 // This assumes the center is 0,0
#if ENABLED(DELTA) #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 max = SQRT(sq(float(PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis
min = -max; min = -max;
} }
@ -750,35 +789,44 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
drawAxisValue(axis); drawAxisValue(axis);
} }
#if HAS_EXTRUDERS
static void e_plus() { moveAxis(E_AXIS, 1); } static void e_plus() { moveAxis(E_AXIS, 1); }
static void e_minus() { 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_minus() { moveAxis(X_AXIS, -1); }
static void x_plus() { 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_plus() { moveAxis(Y_AXIS, 1); }
static void y_minus() { 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_plus() { moveAxis(Z_AXIS, 1); }
static void z_minus() { moveAxis(Z_AXIS, -1); } static void z_minus() { moveAxis(Z_AXIS, -1); }
#endif
#if ENABLED(TOUCH_SCREEN) #if ENABLED(TOUCH_SCREEN)
#if HAS_EXTRUDERS
static void e_select() { static void e_select() {
if (++motionAxisState.e_selection >= EXTRUDERS) if (++motionAxisState.e_selection >= EXTRUDERS)
motionAxisState.e_selection = 0; motionAxisState.e_selection = 0;
quick_feedback(); quick_feedback();
drawCurESelection(); drawCurESelection();
drawAxisValue(E_AXIS); drawAxisValue(E_AXIS);
} }
#endif
static void do_home() { static void do_home() {
quick_feedback(); quick_feedback();
drawMessage(GET_TEXT_F(MSG_LEVEL_BED_HOMING)); drawMessage(GET_TEXT_F(MSG_LEVEL_BED_HOMING));
queue.inject_P(G28_STR); queue.inject_P(G28_STR);
// Disable touch until home is done // Disable touch until home is done
TERN_(TOUCH_SCREEN, touch.disable()); touch.disable();
drawAxisValue(E_AXIS); TERN_(HAS_EXTRUDERS, drawAxisValue(E_AXIS));
drawAxisValue(X_AXIS); TERN_(HAS_X_AXIS, drawAxisValue(X_AXIS));
drawAxisValue(Y_AXIS); TERN_(HAS_Y_AXIS, drawAxisValue(Y_AXIS));
drawAxisValue(Z_AXIS); TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS));
} }
static void step_size() { static void step_size() {
@ -845,7 +893,7 @@ void MarlinUI::move_axis_screen() {
// ROW 1 -> E- Y- CurY Z+ // ROW 1 -> E- Y- CurY Z+
int x = X_MARGIN, y = Y_MARGIN, spacing = 0; 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; spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2;
x += BTN_WIDTH + spacing; x += BTN_WIDTH + spacing;
@ -858,7 +906,9 @@ void MarlinUI::move_axis_screen() {
drawAxisValue(Y_AXIS); drawAxisValue(Y_AXIS);
x += spacing; x += spacing;
#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 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" // ROW 2 -> "Ex" X- HOME X+ "Z"
y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; 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.x = x;
motionAxisState.eNamePos.y = y; motionAxisState.eNamePos.y = y;
#if HAS_EXTRUDERS
drawCurESelection(); drawCurESelection();
TERN_(TOUCH_SCREEN, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); TERN_(TOUCH_SCREEN, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select));
#endif
x += BTN_WIDTH + spacing; x += BTN_WIDTH + spacing;
drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy); 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; x += BTN_WIDTH + spacing;
motionAxisState.zTypePos.x = x; motionAxisState.zTypePos.x = x;
motionAxisState.zTypePos.y = y; motionAxisState.zTypePos.y = y;
drawCurZSelection(); TERN_(HAS_Z_AXIS, drawCurZSelection());
#if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) #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 #endif
@ -893,12 +945,12 @@ void MarlinUI::move_axis_screen() {
x = X_MARGIN; x = X_MARGIN;
spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; 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 // Cur E
motionAxisState.eValuePos.x = x; motionAxisState.eValuePos.x = x;
motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2; motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2;
drawAxisValue(E_AXIS); TERN_(HAS_EXTRUDERS, drawAxisValue(E_AXIS));
// Cur X // Cur X
motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos 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); drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy);
x += BTN_WIDTH + spacing; x += BTN_WIDTH + spacing;
#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 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 // Cur Z
motionAxisState.zValuePos.x = x; motionAxisState.zValuePos.x = x;
motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2; motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2;
drawAxisValue(Z_AXIS); TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS));
// ROW 4 -> step_size disable steppers back // ROW 4 -> step_size disable steppers back
y = TFT_HEIGHT - Y_MARGIN - 32; // y = TFT_HEIGHT - Y_MARGIN - 32; //

View File

@ -126,8 +126,12 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
celsius_t currentTemperature, targetTemperature; celsius_t currentTemperature, targetTemperature;
if (Heater >= 0) { // HotEnd if (Heater >= 0) { // HotEnd
#if HAS_EXTRUDERS
currentTemperature = thermalManager.wholeDegHotend(Heater); currentTemperature = thermalManager.wholeDegHotend(Heater);
targetTemperature = thermalManager.degTargetHotend(Heater); targetTemperature = thermalManager.degTargetHotend(Heater);
#else
return;
#endif
} }
#if HAS_HEATED_BED #if HAS_HEATED_BED
else if (Heater == H_BED) { else if (Heater == H_BED) {
@ -283,6 +287,7 @@ void MarlinUI::draw_status_screen() {
#endif #endif
} }
else { else {
#if HAS_X_AXIS
tft.add_text(TERN(TFT_COLOR_UI_PORTRAIT, 32, 10), tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , "X"); 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); const bool nhx = axis_should_home(X_AXIS);
tft_string.set(blink && nhx ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x))); tft_string.set(blink && nhx ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
@ -294,7 +299,9 @@ void MarlinUI::draw_status_screen() {
#endif #endif
nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string
); );
#endif
#if HAS_Y_AXIS
tft.add_text(TERN(TFT_COLOR_UI_PORTRAIT, 110, 127), tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED , "Y"); 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); const bool nhy = axis_should_home(Y_AXIS);
tft_string.set(blink && nhy ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); tft_string.set(blink && nhy ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
@ -306,8 +313,10 @@ void MarlinUI::draw_status_screen() {
#endif #endif
nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string 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"); 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); const bool nhz = axis_should_home(Z_AXIS);
uint16_t offset = 25; uint16_t offset = 25;
@ -329,6 +338,8 @@ void MarlinUI::draw_status_screen() {
301 - tft_string.width() - offset, tft_string.vcenter(FONT_LINE_HEIGHT), 301 - tft_string.width() - offset, tft_string.vcenter(FONT_LINE_HEIGHT),
#endif #endif
nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); nhz ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
#endif
TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 0, 103, TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 0, 103,
#if ENABLED(TFT_COLOR_UI_PORTRAIT) #if ENABLED(TFT_COLOR_UI_PORTRAIT)
232, FONT_LINE_HEIGHT * 2 232, FONT_LINE_HEIGHT * 2
@ -361,7 +372,8 @@ void MarlinUI::draw_status_screen() {
, 32 , 32
)); ));
// flow rate // Flow rate
#if HAS_EXTRUDERS
tft.canvas( tft.canvas(
#if ENABLED(TFT_COLOR_UI_PORTRAIT) #if ENABLED(TFT_COLOR_UI_PORTRAIT)
140, 172, 80 140, 172, 80
@ -384,6 +396,7 @@ void MarlinUI::draw_status_screen() {
#endif #endif
, 32, active_extruder , 32, active_extruder
)); ));
#endif // HAS_EXTRUDERS
// print duration // print duration
char buffer[14]; 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 1
#define Z_SELECTION_Z_PROBE -1 #define Z_SELECTION_Z_PROBE -1
struct MotionAxisState { struct {
xy_int_t xValuePos, yValuePos, zValuePos, eValuePos, stepValuePos, zTypePos, eNamePos; #if HAS_X_AXIS
float currentStepSize = 10.0; 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; int z_selection = Z_SELECTION_Z;
#endif
#if HAS_EXTRUDERS
xy_int_t eValuePos, eNamePos;
uint8_t e_selection = 0; uint8_t e_selection = 0;
#endif
xy_int_t stepValuePos;
float currentStepSize = 10.0;
bool blocked = false; bool blocked = false;
char message[32]; char message[32];
}; } motionAxisState;
MotionAxisState motionAxisState;
#define BTN_WIDTH 48 #define BTN_WIDTH 48
#define BTN_HEIGHT 39 #define BTN_HEIGHT 39
@ -706,6 +729,7 @@ static void drawCurStepValue() {
tft.add_text(CUR_STEP_VALUE_WIDTH - tft_string.width(), 0, COLOR_AXIS_HOMED, tft_string); tft.add_text(CUR_STEP_VALUE_WIDTH - tft_string.width(), 0, COLOR_AXIS_HOMED, tft_string);
} }
#if HAS_Z_AXIS
static void drawCurZSelection() { static void drawCurZSelection() {
tft_string.set('Z'); tft_string.set('Z');
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 20); tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 20);
@ -715,11 +739,12 @@ static void drawCurZSelection() {
tft_string.set(F("Offset")); tft_string.set(F("Offset"));
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 20); tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 20);
tft.set_background(COLOR_BACKGROUND); tft.set_background(COLOR_BACKGROUND);
if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE)
tft.add_text(0, 0, Z_BTN_COLOR, tft_string); tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
} }
} #endif
#if HAS_EXTRUDERS
static void drawCurESelection() { static void drawCurESelection() {
tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT); tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT);
tft.set_background(COLOR_BACKGROUND); tft.set_background(COLOR_BACKGROUND);
@ -727,6 +752,7 @@ static void drawCurESelection() {
tft.add_text(0, 0, E_BTN_COLOR , tft_string); tft.add_text(0, 0, E_BTN_COLOR , tft_string);
tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection));
} }
#endif
static void drawMessage(PGM_P const msg) { static void drawMessage(PGM_P const msg) {
tft.canvas(X_MARGIN, tft.canvas(X_MARGIN,
@ -751,10 +777,18 @@ static void drawAxisValue(const AxisEnum axis) {
xy_int_t pos; xy_int_t pos;
uint16_t color; uint16_t color;
switch (axis) { switch (axis) {
#if HAS_X_AXIS
case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break; 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; 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; 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; case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break;
#endif
default: return; default: return;
} }
tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, FONT_LINE_HEIGHT); tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, FONT_LINE_HEIGHT);
@ -766,13 +800,16 @@ static void drawAxisValue(const AxisEnum axis) {
static void moveAxis(const AxisEnum axis, const int8_t direction) { static void moveAxis(const AxisEnum axis, const int8_t direction) {
quick_feedback(); quick_feedback();
#if HAS_EXTRUDERS
if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) {
drawMessage(F("Too cold")); drawMessage(F("Too cold"));
return; return;
} }
#endif
const float diff = motionAxisState.currentStepSize * direction; const float diff = motionAxisState.currentStepSize * direction;
#if HAS_Z_AXIS
if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) {
#if ENABLED(BABYSTEP_ZPROBE_OFFSET) #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z;
@ -813,6 +850,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
#endif #endif
return; return;
} }
#endif // HAS_Z_AXIS
if (!ui.manual_move.processing) { if (!ui.manual_move.processing) {
// Get motion limit from software endstops, if any // 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 // Delta limits XY based on the current offset from center
// This assumes the center is 0,0 // This assumes the center is 0,0
#if ENABLED(DELTA) #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 max = SQRT(sq(float(PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis
min = -max; min = -max;
} }
@ -843,35 +881,44 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
drawAxisValue(axis); drawAxisValue(axis);
} }
#if HAS_EXTRUDERS
static void e_plus() { moveAxis(E_AXIS, 1); } static void e_plus() { moveAxis(E_AXIS, 1); }
static void e_minus() { 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_minus() { moveAxis(X_AXIS, -1); }
static void x_plus() { 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_plus() { moveAxis(Y_AXIS, 1); }
static void y_minus() { 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_plus() { moveAxis(Z_AXIS, 1); }
static void z_minus() { moveAxis(Z_AXIS, -1); } static void z_minus() { moveAxis(Z_AXIS, -1); }
#endif
#if ENABLED(TOUCH_SCREEN) #if ENABLED(TOUCH_SCREEN)
#if HAS_EXTRUDERS
static void e_select() { static void e_select() {
if (++motionAxisState.e_selection >= EXTRUDERS) if (++motionAxisState.e_selection >= EXTRUDERS)
motionAxisState.e_selection = 0; motionAxisState.e_selection = 0;
quick_feedback(); quick_feedback();
drawCurESelection(); drawCurESelection();
drawAxisValue(E_AXIS); drawAxisValue(E_AXIS);
} }
#endif
static void do_home() { static void do_home() {
quick_feedback(); quick_feedback();
drawMessage(GET_TEXT_F(MSG_LEVEL_BED_HOMING)); drawMessage(GET_TEXT_F(MSG_LEVEL_BED_HOMING));
queue.inject_P(G28_STR); queue.inject_P(G28_STR);
// Disable touch until home is done // Disable touch until home is done
TERN_(HAS_TFT_XPT2046, touch.disable()); touch.disable();
drawAxisValue(E_AXIS); TERN_(HAS_EXTRUDERS, drawAxisValue(E_AXIS));
drawAxisValue(X_AXIS); TERN_(HAS_X_AXIS, drawAxisValue(X_AXIS));
drawAxisValue(Y_AXIS); TERN_(HAS_Y_AXIS, drawAxisValue(Y_AXIS));
drawAxisValue(Z_AXIS); TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS));
} }
static void step_size() { static void step_size() {
@ -916,14 +963,14 @@ static void drawBtn(int x, int y, const char *label, intptr_t data, MarlinImage
else else
tft.add_image(0, 0, img, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY); 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() { void MarlinUI::move_axis_screen() {
// Reset // Reset
defer_status_screen(true); defer_status_screen(true);
motionAxisState.blocked = false; motionAxisState.blocked = false;
TERN_(HAS_TFT_XPT2046, touch.enable()); TERN_(TOUCH_SCREEN, touch.enable());
ui.clear_lcd(); ui.clear_lcd();
@ -949,7 +996,9 @@ void MarlinUI::move_axis_screen() {
x += BTN_WIDTH + spacing; x += BTN_WIDTH + spacing;
uint16_t zplus_x = x; uint16_t zplus_x = x;
#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 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" // ROW 2 -> "Ex" CurY "Z"
x = X_MARGIN; x = X_MARGIN;
@ -957,8 +1006,10 @@ void MarlinUI::move_axis_screen() {
motionAxisState.eNamePos.x = x; motionAxisState.eNamePos.x = x;
motionAxisState.eNamePos.y = y; motionAxisState.eNamePos.y = y;
#if HAS_EXTRUDERS
drawCurESelection(); drawCurESelection();
TERN_(HAS_TFT_XPT2046, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); 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.x = yplus_x;
motionAxisState.yValuePos.y = y; motionAxisState.yValuePos.y = y;
@ -966,7 +1017,7 @@ void MarlinUI::move_axis_screen() {
motionAxisState.zTypePos.x = zplus_x; motionAxisState.zTypePos.x = zplus_x;
motionAxisState.zTypePos.y = y; motionAxisState.zTypePos.y = y;
drawCurZSelection(); TERN_(HAS_Z_AXIS, drawCurZSelection());
// ROW 3 -> X- HOME X+ // ROW 3 -> X- HOME X+
y += (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3 - 2; 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); 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); 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; y += (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3 - 2;
x = X_MARGIN; x = X_MARGIN;
#if HAS_EXTRUDERS
drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy); drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy);
#endif
// Cur E // Cur E
motionAxisState.eValuePos.x = x; motionAxisState.eValuePos.x = x;
motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2; motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2;
drawAxisValue(E_AXIS); TERN_(HAS_EXTRUDERS, drawAxisValue(E_AXIS));
x += BTN_WIDTH + spacing; x += BTN_WIDTH + spacing;
drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy); drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy);
x += BTN_WIDTH + spacing; x += BTN_WIDTH + spacing;
#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 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 // Cur Z
motionAxisState.zValuePos.x = x; motionAxisState.zValuePos.x = x;
motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2; motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2;
drawAxisValue(Z_AXIS); TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS));
// ROW 6 -> step_size disable steppers back // ROW 6 -> step_size disable steppers back
y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT; // y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT; //
@ -1019,7 +1074,7 @@ void MarlinUI::move_axis_screen() {
if (!busy) { if (!busy) {
drawCurStepValue(); 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+ // aligned with x+
@ -1030,7 +1085,7 @@ void MarlinUI::move_axis_screen() {
// ROW 1 -> E+ Y+ CurY Z+ // ROW 1 -> E+ Y+ CurY Z+
int x = X_MARGIN, y = Y_MARGIN, spacing = 0; 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; spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2;
x += BTN_WIDTH + spacing; x += BTN_WIDTH + spacing;
@ -1044,7 +1099,9 @@ void MarlinUI::move_axis_screen() {
drawAxisValue(Y_AXIS); drawAxisValue(Y_AXIS);
x += spacing; x += spacing;
#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 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" // ROW 2 -> "Ex" X- HOME X+ "Z"
y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; 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.x = x;
motionAxisState.eNamePos.y = y; motionAxisState.eNamePos.y = y;
#if HAS_EXTRUDERS
drawCurESelection(); drawCurESelection();
TERN_(HAS_TFT_XPT2046, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); TERN_(TOUCH_SCREEN, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select));
#endif
x += BTN_WIDTH + spacing; x += BTN_WIDTH + spacing;
drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy); drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy);
x += BTN_WIDTH + spacing; //imgHome is 64x64 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; x += BTN_WIDTH + spacing;
uint16_t xplus_x = x; uint16_t xplus_x = x;
@ -1069,7 +1128,7 @@ void MarlinUI::move_axis_screen() {
x += BTN_WIDTH + spacing; x += BTN_WIDTH + spacing;
motionAxisState.zTypePos.x = x; motionAxisState.zTypePos.x = x;
motionAxisState.zTypePos.y = y; motionAxisState.zTypePos.y = y;
drawCurZSelection(); TERN_(HAS_Z_AXIS, drawCurZSelection());
#if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) #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 #endif
@ -1079,12 +1138,12 @@ void MarlinUI::move_axis_screen() {
x = X_MARGIN; x = X_MARGIN;
spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; 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 // Cur E
motionAxisState.eValuePos.x = x; motionAxisState.eValuePos.x = x;
motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2; motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2;
drawAxisValue(E_AXIS); TERN_(HAS_EXTRUDERS, drawAxisValue(E_AXIS));
// Cur X // Cur X
motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos 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); drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy);
x += BTN_WIDTH + spacing; x += BTN_WIDTH + spacing;
#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 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 // Cur Z
motionAxisState.zValuePos.x = x; motionAxisState.zValuePos.x = x;
motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2; motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2;
drawAxisValue(Z_AXIS); TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS));
// ROW 4 -> step_size disable steppers back // ROW 4 -> step_size disable steppers back
y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT; // 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; motionAxisState.stepValuePos.y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT;
if (!busy) { if (!busy) {
drawCurStepValue(); 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+ // aligned with x+
@ -1117,7 +1178,7 @@ void MarlinUI::move_axis_screen() {
#endif // !TFT_COLOR_UI_PORTRAIT #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 #endif // HAS_UI_320x240

View File

@ -124,8 +124,12 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
celsius_t currentTemperature, targetTemperature; celsius_t currentTemperature, targetTemperature;
if (Heater >= 0) { // HotEnd if (Heater >= 0) { // HotEnd
#if HAS_EXTRUDERS
currentTemperature = thermalManager.wholeDegHotend(Heater); currentTemperature = thermalManager.wholeDegHotend(Heater);
targetTemperature = thermalManager.degTargetHotend(Heater); targetTemperature = thermalManager.degTargetHotend(Heater);
#else
return;
#endif
} }
#if HAS_HEATED_BED #if HAS_HEATED_BED
else if (Heater == H_BED) { else if (Heater == H_BED) {
@ -271,6 +275,7 @@ void MarlinUI::draw_status_screen() {
} }
else { else {
// Coords in mask "X____Y____Z____" // Coords in mask "X____Y____Z____"
#if HAS_X_AXIS
tft_string.set("X"); 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); tft.add_text(coords_width / 30 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED, tft_string);
@ -278,7 +283,9 @@ void MarlinUI::draw_status_screen() {
tft_string.set(blink && nhx ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x))); tft_string.set(blink && nhx ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
tft_string.ltrim(); 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); 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
#if HAS_Y_AXIS
tft_string.set("Y"); 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); tft.add_text(11 * coords_width / 30 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED, tft_string);
@ -286,8 +293,10 @@ void MarlinUI::draw_status_screen() {
tft_string.set(blink && nhy ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); tft_string.set(blink && nhy ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
tft_string.ltrim(); 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); 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
} }
#if HAS_Z_AXIS
tft_string.set("Z"); 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); tft.add_text(7 * coords_width / 10 - tft_string.width() / 2, tft_string.vcenter(FONT_LINE_HEIGHT), COLOR_AXIS_HOMED, tft_string);
@ -296,6 +305,7 @@ void MarlinUI::draw_status_screen() {
tft_string.ltrim(); tft_string.ltrim();
tft_string.rtrim(); 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); 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)); TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT));
@ -315,6 +325,7 @@ void MarlinUI::draw_status_screen() {
tft.add_text(36, tft_string.vcenter(30), color , tft_string); tft.add_text(36, tft_string.vcenter(30), color , tft_string);
TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, x, y, component_width, 32)); TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, x, y, component_width, 32));
#if HAS_EXTRUDERS
// Flow rate (preparing) // Flow rate (preparing)
tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder])); tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder]));
tft_string.add('%'); tft_string.add('%');
@ -328,6 +339,7 @@ void MarlinUI::draw_status_screen() {
tft.add_image(0, 0, imgFlowRate, color); tft.add_image(0, 0, imgFlowRate, color);
tft.add_text(36, tft_string.vcenter(30), color , tft_string); 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)); TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, x, y, component_width, 32, active_extruder));
#endif
#if TFT_COLOR_UI_PORTRAIT || DISABLED(TOUCH_SCREEN) #if TFT_COLOR_UI_PORTRAIT || DISABLED(TOUCH_SCREEN)
y += STATUS_MARGIN_SIZE + 32; 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 1
#define Z_SELECTION_Z_PROBE -1 #define Z_SELECTION_Z_PROBE -1
struct MotionAxisState { struct {
xy_int_t xValuePos, yValuePos, zValuePos, eValuePos, stepValuePos, zTypePos, eNamePos; #if HAS_X_AXIS
float currentStepSize = 10.0; 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; int z_selection = Z_SELECTION_Z;
#endif
#if HAS_EXTRUDERS
xy_int_t eValuePos, eNamePos;
uint8_t e_selection = 0; uint8_t e_selection = 0;
#endif
xy_int_t stepValuePos;
float currentStepSize = 10.0;
bool blocked = false; bool blocked = false;
char message[32]; char message[32];
}; } motionAxisState;
MotionAxisState motionAxisState;
#define BTN_WIDTH 64 #define BTN_WIDTH 64
#define BTN_HEIGHT 52 #define BTN_HEIGHT 52
@ -622,6 +644,7 @@ static void drawCurStepValue() {
tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string); tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string);
} }
#if HAS_Z_AXIS
static void drawCurZSelection() { static void drawCurZSelection() {
tft_string.set('Z'); tft_string.set('Z');
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34); tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34);
@ -631,11 +654,12 @@ static void drawCurZSelection() {
tft_string.set(F("Offset")); tft_string.set(F("Offset"));
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34); tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34);
tft.set_background(COLOR_BACKGROUND); tft.set_background(COLOR_BACKGROUND);
if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE)
tft.add_text(0, 0, Z_BTN_COLOR, tft_string); tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
} }
} #endif
#if HAS_EXTRUDERS
static void drawCurESelection() { static void drawCurESelection() {
tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT); tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT);
tft.set_background(COLOR_BACKGROUND); tft.set_background(COLOR_BACKGROUND);
@ -643,6 +667,7 @@ static void drawCurESelection() {
tft.add_text(0, 0, E_BTN_COLOR , tft_string); tft.add_text(0, 0, E_BTN_COLOR , tft_string);
tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection));
} }
#endif
static void drawMessage(PGM_P const msg) { static void drawMessage(PGM_P const msg) {
tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 34, TFT_HEIGHT / 2, 34); 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; xy_int_t pos;
uint16_t color; uint16_t color;
switch (axis) { switch (axis) {
#if HAS_X_AXIS
case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break; 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; 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; 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; case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break;
#endif
default: return; default: return;
} }
tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, BTN_HEIGHT); tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, BTN_HEIGHT);
@ -675,13 +708,16 @@ static void drawAxisValue(const AxisEnum axis) {
static void moveAxis(const AxisEnum axis, const int8_t direction) { static void moveAxis(const AxisEnum axis, const int8_t direction) {
quick_feedback(); quick_feedback();
#if HAS_EXTRUDERS
if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) {
drawMessage(F("Too cold")); drawMessage(F("Too cold"));
return; return;
} }
#endif
const float diff = motionAxisState.currentStepSize * direction; const float diff = motionAxisState.currentStepSize * direction;
#if HAS_Z_AXIS
if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) {
#if ENABLED(BABYSTEP_ZPROBE_OFFSET) #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z;
@ -722,6 +758,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
#endif #endif
return; return;
} }
#endif // HAS_Z_AXIS
if (!ui.manual_move.processing) { if (!ui.manual_move.processing) {
// Get motion limit from software endstops, if any // 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 // Delta limits XY based on the current offset from center
// This assumes the center is 0,0 // This assumes the center is 0,0
#if ENABLED(DELTA) #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 max = SQRT(sq(float(PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis
min = -max; min = -max;
} }
@ -752,35 +789,44 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
drawAxisValue(axis); drawAxisValue(axis);
} }
#if HAS_EXTRUDERS
static void e_plus() { moveAxis(E_AXIS, 1); } static void e_plus() { moveAxis(E_AXIS, 1); }
static void e_minus() { 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_minus() { moveAxis(X_AXIS, -1); }
static void x_plus() { 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_plus() { moveAxis(Y_AXIS, 1); }
static void y_minus() { 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_plus() { moveAxis(Z_AXIS, 1); }
static void z_minus() { moveAxis(Z_AXIS, -1); } static void z_minus() { moveAxis(Z_AXIS, -1); }
#endif
#if ENABLED(TOUCH_SCREEN) #if ENABLED(TOUCH_SCREEN)
#if HAS_EXTRUDERS
static void e_select() { static void e_select() {
if (++motionAxisState.e_selection >= EXTRUDERS) if (++motionAxisState.e_selection >= EXTRUDERS)
motionAxisState.e_selection = 0; motionAxisState.e_selection = 0;
quick_feedback(); quick_feedback();
drawCurESelection(); drawCurESelection();
drawAxisValue(E_AXIS); drawAxisValue(E_AXIS);
} }
#endif
static void do_home() { static void do_home() {
quick_feedback(); quick_feedback();
drawMessage(GET_TEXT_F(MSG_LEVEL_BED_HOMING)); drawMessage(GET_TEXT_F(MSG_LEVEL_BED_HOMING));
queue.inject_P(G28_STR); queue.inject_P(G28_STR);
// Disable touch until home is done // Disable touch until home is done
TERN_(HAS_TFT_XPT2046, touch.disable()); touch.disable();
drawAxisValue(E_AXIS); TERN_(HAS_EXTRUDERS, drawAxisValue(E_AXIS));
drawAxisValue(X_AXIS); TERN_(HAS_X_AXIS, drawAxisValue(X_AXIS));
drawAxisValue(Y_AXIS); TERN_(HAS_Y_AXIS, drawAxisValue(Y_AXIS));
drawAxisValue(Z_AXIS); TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS));
} }
static void step_size() { static void step_size() {
@ -789,7 +835,7 @@ static void z_minus() { moveAxis(Z_AXIS, -1); }
quick_feedback(); quick_feedback();
drawCurStepValue(); drawCurStepValue();
} }
#endif #endif // TOUCH_SCREEN
#if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) #if BOTH(HAS_BED_PROBE, TOUCH_SCREEN)
static void z_select() { 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); 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() { void MarlinUI::move_axis_screen() {
// Reset // Reset
defer_status_screen(true); defer_status_screen(true);
motionAxisState.blocked = false; motionAxisState.blocked = false;
TERN_(HAS_TFT_XPT2046, touch.enable()); TERN_(TOUCH_SCREEN, touch.enable());
ui.clear_lcd(); ui.clear_lcd();
@ -842,25 +888,31 @@ void MarlinUI::move_axis_screen() {
// Babysteps during printing? Select babystep for Z probe offset // Babysteps during printing? Select babystep for Z probe offset
if (busy && ENABLED(BABYSTEP_ZPROBE_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+ // ROW 1 -> E- Y- CurY Z+
int x = X_MARGIN, y = Y_MARGIN, spacing = 0; 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; spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2;
x += BTN_WIDTH + spacing; 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 // Cur Y
x += BTN_WIDTH; x += BTN_WIDTH;
#if HAS_Y_AXIS
motionAxisState.yValuePos.x = x + 2; motionAxisState.yValuePos.x = x + 2;
motionAxisState.yValuePos.y = y; motionAxisState.yValuePos.y = y;
drawAxisValue(Y_AXIS); drawAxisValue(Y_AXIS);
#endif
x += spacing; x += spacing;
#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 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" // ROW 2 -> "Ex" X- HOME X+ "Z"
y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; 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.x = x;
motionAxisState.eNamePos.y = y; motionAxisState.eNamePos.y = y;
#if HAS_EXTRUDERS
drawCurESelection(); drawCurESelection();
TERN_(HAS_TFT_XPT2046, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); TERN_(TOUCH_SCREEN, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select));
#endif
x += BTN_WIDTH + spacing; x += BTN_WIDTH + spacing;
drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy); drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy);
x += BTN_WIDTH + spacing; //imgHome is 64x64 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; x += BTN_WIDTH + spacing;
uint16_t xplus_x = x; uint16_t xplus_x = x;
@ -885,7 +939,7 @@ void MarlinUI::move_axis_screen() {
x += BTN_WIDTH + spacing; x += BTN_WIDTH + spacing;
motionAxisState.zTypePos.x = x; motionAxisState.zTypePos.x = x;
motionAxisState.zTypePos.y = y; motionAxisState.zTypePos.y = y;
drawCurZSelection(); TERN_(HAS_Z_AXIS, drawCurZSelection());
#if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) #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 #endif
@ -895,28 +949,30 @@ void MarlinUI::move_axis_screen() {
x = X_MARGIN; x = X_MARGIN;
spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; 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 // Cur E
motionAxisState.eValuePos.x = x; motionAxisState.eValuePos.x = x;
motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2; motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2;
drawAxisValue(E_AXIS); TERN_(HAS_EXTRUDERS, drawAxisValue(E_AXIS));
// Cur X // Cur X
motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos
motionAxisState.xValuePos.y = y - 10; motionAxisState.xValuePos.y = y - 10;
drawAxisValue(X_AXIS); TERN_(HAS_X_AXIS, drawAxisValue(X_AXIS));
x += BTN_WIDTH + spacing; x += BTN_WIDTH + spacing;
drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy); drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy);
x += BTN_WIDTH + spacing; x += BTN_WIDTH + spacing;
#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 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 // Cur Z
motionAxisState.zValuePos.x = x; motionAxisState.zValuePos.x = x;
motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2; motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2;
drawAxisValue(Z_AXIS); TERN_(HAS_Z_AXIS, drawAxisValue(Z_AXIS));
// ROW 4 -> step_size disable steppers back // ROW 4 -> step_size disable steppers back
y = TFT_HEIGHT - Y_MARGIN - 32; y = TFT_HEIGHT - Y_MARGIN - 32;
@ -925,13 +981,13 @@ void MarlinUI::move_axis_screen() {
motionAxisState.stepValuePos.y = y; motionAxisState.stepValuePos.y = y;
if (!busy) { if (!busy) {
drawCurStepValue(); 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+ // aligned with x+
drawBtn(xplus_x, TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT, "off", (intptr_t)disable_steppers, imgCancel, COLOR_WHITE, !busy); 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 #endif // HAS_UI_480x320