Skip to content

Commit

Permalink
🚸 Stop button for Touch UI (MarlinFirmware#25379)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgrach authored and thinkyhead committed Feb 21, 2023
1 parent 68ffb25 commit 642a885
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
7 changes: 7 additions & 0 deletions Marlin/src/lcd/tft/touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ 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); });
#endif
break;
case STOP:
ui.goto_screen([]{
MenuItem_confirm::select_screen(GET_TEXT_F(MSG_BUTTON_STOP),
GET_TEXT_F(MSG_BACK), ui.abort_print, ui.goto_previous_screen,
GET_TEXT_F(MSG_STOP_PRINT), FSTR_P(nullptr), FPSTR("?"));
});
break;

#if ENABLED(AUTO_BED_LEVELING_UBL)
case UBL: hold(control, UBL_REPEAT_DELAY); ui.encoderPosition += control->data; break;
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/tft/touch.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ enum TouchControlType : uint16_t {
FLOWRATE,
UBL,
MOVE_AXIS,
STOP,
BUTTON,
};

Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/lcd/tft/ui_1024x600.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,10 @@ void MarlinUI::draw_status_screen() {
add_control(900, y, menu_main, imgSettings);
#if ENABLED(SDSUPPORT)
const bool cm = card.isMounted(), pa = printingIsActive();
add_control(12, y, menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, cm && pa ? COLOR_BUSY : COLOR_CONTROL_DISABLED);
if (cm && pa)
add_control(12, y, STOP, imgCancel, true, COLOR_CONTROL_CANCEL);
else
add_control(12, y, menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, COLOR_CONTROL_DISABLED);
#endif
#endif

Expand Down
11 changes: 7 additions & 4 deletions Marlin/src/lcd/tft/ui_320x240.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,12 @@ void MarlinUI::draw_status_screen() {
);
#if ENABLED(SDSUPPORT)
const bool cm = card.isMounted(), pa = printingIsActive();
add_control(0, TERN(TFT_COLOR_UI_PORTRAIT, 210, 130), menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, cm && pa ? COLOR_BUSY : COLOR_CONTROL_DISABLED);
if (cm && pa)
add_control(0, TERN(TFT_COLOR_UI_PORTRAIT, 210, 130), STOP, imgCancel, true, COLOR_CONTROL_CANCEL);
else
add_control(0, TERN(TFT_COLOR_UI_PORTRAIT, 210, 130), menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, COLOR_CONTROL_DISABLED);
#endif
} // (sublime)
}
#endif // TOUCH_SCREEN
}

Expand Down Expand Up @@ -549,8 +552,8 @@ void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, con
tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
}
#if ENABLED(TOUCH_SCREEN)
if (no) add_control(TERN(TFT_COLOR_UI_PORTRAIT, 32, 48), TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL);
if (yes) add_control(TERN(TFT_COLOR_UI_PORTRAIT, 172, 208), TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM));
if (no) add_control(TERN(TFT_COLOR_UI_PORTRAIT, 16, 48), TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL);
if (yes) add_control(TERN(TFT_COLOR_UI_PORTRAIT, 160, 208), TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM));
#endif
}

Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/lcd/tft/ui_480x320.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,10 @@ void MarlinUI::draw_status_screen() {
add_control(404, y, menu_main, imgSettings);
#if ENABLED(SDSUPPORT)
const bool cm = card.isMounted(), pa = printingIsActive();
add_control(12, y, menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, cm && pa ? COLOR_BUSY : COLOR_CONTROL_DISABLED);
if (cm && pa)
add_control(12, y, STOP, imgCancel, true, COLOR_CONTROL_CANCEL);
else
add_control(12, y, menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, COLOR_CONTROL_DISABLED);
#endif
#endif

Expand Down

0 comments on commit 642a885

Please sign in to comment.