2018-10-23 23:00:34 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 15:00:57 +01:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2018-10-23 23:00:34 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2018-10-23 23:00:34 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2020-07-23 05:20:14 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2018-10-23 23:00:34 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../../inc/MarlinConfigPre.h"
|
|
|
|
|
2018-10-30 22:34:45 +01:00
|
|
|
#if HAS_LCD_MENU
|
2018-10-23 23:00:34 +02:00
|
|
|
|
|
|
|
#include "menu.h"
|
|
|
|
#include "../../module/planner.h"
|
|
|
|
#include "../../module/motion.h"
|
2019-02-12 22:55:47 +01:00
|
|
|
#include "../../module/printcounter.h"
|
2018-10-23 23:00:34 +02:00
|
|
|
#include "../../gcode/queue.h"
|
2019-10-03 01:54:20 +02:00
|
|
|
|
2019-07-29 02:14:50 +02:00
|
|
|
#if HAS_BUZZER
|
|
|
|
#include "../../libs/buzzer.h"
|
|
|
|
#endif
|
2018-10-28 08:59:21 +01:00
|
|
|
|
|
|
|
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
|
|
|
#include "../../module/probe.h"
|
|
|
|
#endif
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2019-03-17 05:43:06 +01:00
|
|
|
#if EITHER(ENABLE_LEVELING_FADE_HEIGHT, AUTO_BED_LEVELING_UBL)
|
2018-10-28 08:59:21 +01:00
|
|
|
#include "../../feature/bedlevel/bedlevel.h"
|
2018-10-23 23:00:34 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
///////////// Global Variables /////////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Menu Navigation
|
2019-04-04 09:29:44 +02:00
|
|
|
int8_t encoderTopLine, encoderLine, screen_items;
|
|
|
|
|
2018-10-23 23:00:34 +02:00
|
|
|
typedef struct {
|
2021-06-27 07:33:44 +02:00
|
|
|
screenFunc_t menu_function; // The screen's function
|
|
|
|
uint32_t encoder_position; // The position of the encoder
|
|
|
|
int8_t top_line, items; // The amount of scroll, and the number of items
|
|
|
|
#if SCREENS_CAN_TIME_OUT
|
|
|
|
bool sticky; // The screen is sticky
|
|
|
|
#endif
|
2018-10-23 23:00:34 +02:00
|
|
|
} menuPosition;
|
|
|
|
menuPosition screen_history[6];
|
|
|
|
uint8_t screen_history_depth = 0;
|
2018-11-07 02:25:57 +01:00
|
|
|
|
2020-06-11 01:35:56 +02:00
|
|
|
int8_t MenuItemBase::itemIndex; // Index number for draw and action
|
2020-07-09 10:11:57 +02:00
|
|
|
PGM_P MenuItemBase::itemString; // A PSTR for substitution
|
2019-11-15 03:30:30 +01:00
|
|
|
chimera_t editable; // Value Editing
|
|
|
|
|
|
|
|
// Menu Edit Items
|
|
|
|
PGM_P MenuEditItemBase::editLabel;
|
|
|
|
void* MenuEditItemBase::editValue;
|
|
|
|
int32_t MenuEditItemBase::minEditValue,
|
|
|
|
MenuEditItemBase::maxEditValue;
|
2019-10-03 02:04:16 +02:00
|
|
|
screenFunc_t MenuEditItemBase::callbackFunc;
|
2019-11-15 03:30:30 +01:00
|
|
|
bool MenuEditItemBase::liveEdit;
|
2018-10-23 23:00:34 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
//////// Menu Navigation & History /////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
2018-11-11 19:16:24 +01:00
|
|
|
void MarlinUI::return_to_status() { goto_screen(status_screen); }
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2021-06-27 07:33:44 +02:00
|
|
|
void MarlinUI::push_current_screen() {
|
2019-04-04 09:29:44 +02:00
|
|
|
if (screen_history_depth < COUNT(screen_history))
|
2021-06-27 07:33:44 +02:00
|
|
|
screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items OPTARG(SCREENS_CAN_TIME_OUT, screen_is_sticky()) };
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
|
2020-04-26 00:53:06 +02:00
|
|
|
void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) {
|
2020-11-08 01:28:29 +01:00
|
|
|
IF_DISABLED(TURBO_BACK_MENU_ITEM, constexpr bool is_back = false);
|
2020-11-15 23:39:58 +01:00
|
|
|
TERN_(HAS_TOUCH_BUTTONS, on_edit_screen = false);
|
2018-10-23 23:00:34 +02:00
|
|
|
if (screen_history_depth > 0) {
|
2019-04-04 09:29:44 +02:00
|
|
|
menuPosition &sh = screen_history[--screen_history_depth];
|
2019-08-21 02:37:03 +02:00
|
|
|
goto_screen(sh.menu_function,
|
|
|
|
is_back ? 0 : sh.encoder_position,
|
|
|
|
is_back ? 0 : sh.top_line,
|
|
|
|
sh.items
|
|
|
|
);
|
2021-06-27 07:33:44 +02:00
|
|
|
defer_status_screen(TERN_(SCREENS_CAN_TIME_OUT, sh.sticky));
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
else
|
2018-11-11 19:16:24 +01:00
|
|
|
return_to_status();
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
/////////// Menu Editing Actions ///////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
2021-10-04 07:24:41 +02:00
|
|
|
// All Edit Screens run the same way, but `draw_edit_screen` is implementation-specific
|
2019-11-15 03:30:30 +01:00
|
|
|
void MenuEditItemBase::edit_screen(strfunc_t strfunc, loadfunc_t loadfunc) {
|
2021-10-04 07:24:41 +02:00
|
|
|
// Reset repeat_delay for Touch Buttons
|
2020-11-15 23:39:58 +01:00
|
|
|
TERN_(HAS_TOUCH_BUTTONS, ui.repeat_delay = BUTTON_DELAY_EDIT);
|
2021-10-04 07:24:41 +02:00
|
|
|
// Constrain ui.encoderPosition to 0 ... maxEditValue (calculated in encoder steps)
|
2019-10-22 01:34:29 +02:00
|
|
|
if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
|
|
|
|
if (int32_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
|
2021-10-04 07:24:41 +02:00
|
|
|
// If drawing is flagged then redraw the (whole) edit screen
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.should_draw())
|
2019-11-15 03:30:30 +01:00
|
|
|
draw_edit_screen(strfunc(ui.encoderPosition + minEditValue));
|
2021-10-04 07:24:41 +02:00
|
|
|
// If there was a click or "live editing" and encoder moved...
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.lcd_clicked || (liveEdit && ui.should_draw())) {
|
2021-10-04 07:24:41 +02:00
|
|
|
// Pass the editValue pointer to the loadfunc along with the encoder plus min
|
2020-10-25 00:13:10 +02:00
|
|
|
if (editValue) loadfunc(editValue, ui.encoderPosition + minEditValue);
|
2021-10-04 07:24:41 +02:00
|
|
|
// If a callbackFunc was set, call it for click or always for "live editing"
|
2018-11-11 19:16:24 +01:00
|
|
|
if (callbackFunc && (liveEdit || ui.lcd_clicked)) (*callbackFunc)();
|
2021-10-04 07:24:41 +02:00
|
|
|
// Use up the click to finish editing and go to the previous screen
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.use_click()) ui.goto_previous_screen();
|
2018-11-06 05:51:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-04 07:24:41 +02:00
|
|
|
// Going to an edit screen sets up some persistent values first
|
2019-11-15 03:30:30 +01:00
|
|
|
void MenuEditItemBase::goto_edit_screen(
|
|
|
|
PGM_P const el, // Edit label
|
|
|
|
void * const ev, // Edit value pointer
|
|
|
|
const int32_t minv, // Encoder minimum
|
|
|
|
const int32_t maxv, // Encoder maximum
|
|
|
|
const uint16_t ep, // Initial encoder value
|
|
|
|
const screenFunc_t cs, // MenuItem_type::draw_edit_screen => MenuEditItemBase::edit()
|
|
|
|
const screenFunc_t cb, // Callback after edit
|
|
|
|
const bool le // Flag to call cb() during editing
|
|
|
|
) {
|
2020-11-15 23:39:58 +01:00
|
|
|
TERN_(HAS_TOUCH_BUTTONS, ui.on_edit_screen = true);
|
2019-11-15 03:30:30 +01:00
|
|
|
ui.screen_changed = true;
|
2021-06-27 07:33:44 +02:00
|
|
|
ui.push_current_screen();
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.refresh();
|
2018-11-06 05:51:10 +01:00
|
|
|
editLabel = el;
|
|
|
|
editValue = ev;
|
|
|
|
minEditValue = minv;
|
|
|
|
maxEditValue = maxv;
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.encoderPosition = ep;
|
|
|
|
ui.currentScreen = cs;
|
2018-11-06 05:51:10 +01:00
|
|
|
callbackFunc = cb;
|
|
|
|
liveEdit = le;
|
|
|
|
}
|
|
|
|
|
2018-10-23 23:00:34 +02:00
|
|
|
////////////////////////////////////////////
|
|
|
|
///////////////// Menu Tree ////////////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
2020-01-03 02:01:38 +01:00
|
|
|
#include "../../MarlinCore.h"
|
2019-10-03 01:54:20 +02:00
|
|
|
|
2019-02-12 22:55:47 +01:00
|
|
|
bool printer_busy() {
|
2019-10-03 01:54:20 +02:00
|
|
|
return planner.movesplanned() || printingIsActive();
|
2019-02-12 22:55:47 +01:00
|
|
|
}
|
2018-10-23 23:00:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* General function to go directly to a screen
|
|
|
|
*/
|
2019-04-09 04:10:41 +02:00
|
|
|
void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, const uint8_t top/*=0*/, const uint8_t items/*=0*/) {
|
2018-10-23 23:00:34 +02:00
|
|
|
if (currentScreen != screen) {
|
|
|
|
|
2021-08-22 12:25:07 +02:00
|
|
|
TERN_(IS_DWIN_MARLINUI, did_first_redraw = false);
|
|
|
|
|
2020-11-15 23:39:58 +01:00
|
|
|
TERN_(HAS_TOUCH_BUTTONS, repeat_delay = BUTTON_DELAY_MENU);
|
2019-09-13 05:14:24 +02:00
|
|
|
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(LCD_SET_PROGRESS_MANUALLY, progress_reset());
|
2019-07-17 10:12:39 +02:00
|
|
|
|
2019-03-17 05:43:06 +01:00
|
|
|
#if BOTH(DOUBLECLICK_FOR_Z_BABYSTEPPING, BABYSTEPPING)
|
2018-10-23 23:00:34 +02:00
|
|
|
static millis_t doubleclick_expire_ms = 0;
|
|
|
|
// Going to menu_main from status screen? Remember first click time.
|
|
|
|
// Going back to status screen within a very short time? Go to Z babystepping.
|
|
|
|
if (screen == menu_main) {
|
2018-11-11 19:16:24 +01:00
|
|
|
if (on_status_screen())
|
2018-10-23 23:00:34 +02:00
|
|
|
doubleclick_expire_ms = millis() + DOUBLECLICK_MAX_INTERVAL;
|
|
|
|
}
|
2020-05-12 05:01:47 +02:00
|
|
|
else if (screen == status_screen && currentScreen == menu_main && PENDING(millis(), doubleclick_expire_ms)) {
|
2020-11-30 02:06:40 +01:00
|
|
|
if (BABYSTEP_ALLOWED())
|
2020-04-26 00:53:06 +02:00
|
|
|
screen = TERN(BABYSTEP_ZPROBE_OFFSET, lcd_babystep_zoffset, lcd_babystep_z);
|
|
|
|
else {
|
|
|
|
#if ENABLED(MOVE_Z_WHEN_IDLE)
|
2020-07-03 16:53:22 +02:00
|
|
|
ui.manual_move.menu_scale = MOVE_Z_IDLE_MULTIPLICATOR;
|
2018-10-23 23:00:34 +02:00
|
|
|
screen = lcd_move_z;
|
2020-04-26 00:53:06 +02:00
|
|
|
#endif
|
|
|
|
}
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
currentScreen = screen;
|
|
|
|
encoderPosition = encoder;
|
2019-04-04 09:29:44 +02:00
|
|
|
encoderTopLine = top;
|
|
|
|
screen_items = items;
|
2020-05-10 07:12:56 +02:00
|
|
|
if (on_status_screen()) {
|
2019-02-06 02:04:26 +01:00
|
|
|
defer_status_screen(false);
|
2020-11-22 01:21:43 +01:00
|
|
|
clear_menu_history();
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(AUTO_BED_LEVELING_UBL, ubl.lcd_map_control = false);
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
2018-10-30 22:34:45 +01:00
|
|
|
|
2018-11-11 19:16:24 +01:00
|
|
|
clear_lcd();
|
2018-10-30 22:34:45 +01:00
|
|
|
|
2018-10-23 23:00:34 +02:00
|
|
|
// Re-initialize custom characters that may be re-used
|
2020-09-28 08:13:27 +02:00
|
|
|
#if HAS_MARLINUI_HD44780
|
2020-04-26 00:53:06 +02:00
|
|
|
if (TERN1(AUTO_BED_LEVELING_UBL, !ubl.lcd_map_control))
|
2020-05-10 07:12:56 +02:00
|
|
|
set_custom_characters(on_status_screen() ? CHARSET_INFO : CHARSET_MENU);
|
2018-10-23 23:00:34 +02:00
|
|
|
#endif
|
2018-10-30 22:34:45 +01:00
|
|
|
|
2018-11-11 19:16:24 +01:00
|
|
|
refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
2018-10-23 23:00:34 +02:00
|
|
|
screen_changed = true;
|
2020-09-28 08:13:27 +02:00
|
|
|
TERN_(HAS_MARLINUI_U8GLIB, drawing_screen = false);
|
2019-04-24 17:13:44 +02:00
|
|
|
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(HAS_LCD_MENU, encoder_direction_normal());
|
2019-07-18 02:41:15 +02:00
|
|
|
|
|
|
|
set_selection(false);
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
///////////// Manual Movement //////////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
|
|
|
//
|
2020-04-12 03:36:17 +02:00
|
|
|
// Display a "synchronize" screen with a custom message until
|
|
|
|
// all moves are finished. Go back to calling screen when done.
|
2018-10-23 23:00:34 +02:00
|
|
|
//
|
2019-05-09 18:45:55 +02:00
|
|
|
void MarlinUI::synchronize(PGM_P const msg/*=nullptr*/) {
|
2020-04-12 03:36:17 +02:00
|
|
|
static PGM_P sync_message = msg ?: GET_TEXT(MSG_MOVING);
|
2021-06-27 07:33:44 +02:00
|
|
|
push_current_screen();
|
2020-04-12 03:36:17 +02:00
|
|
|
goto_screen([]{
|
|
|
|
if (should_draw()) MenuItem_static::draw(LCD_HEIGHT >= 4, sync_message);
|
|
|
|
});
|
|
|
|
defer_status_screen();
|
|
|
|
planner.synchronize(); // idle() is called until moves complete
|
|
|
|
goto_previous_screen_no_defer();
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Scrolling for menus and other line-based screens
|
|
|
|
*
|
|
|
|
* encoderLine is the position based on the encoder
|
|
|
|
* encoderTopLine is the top menu line to display
|
|
|
|
* screen_items is the total number of items in the menu (after one call)
|
|
|
|
*/
|
|
|
|
void scroll_screen(const uint8_t limit, const bool is_menu) {
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.encoder_direction_menus();
|
2018-10-23 23:00:34 +02:00
|
|
|
ENCODER_RATE_MULTIPLY(false);
|
2019-10-22 01:34:29 +02:00
|
|
|
if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.first_page) {
|
|
|
|
encoderLine = ui.encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);
|
2019-11-15 03:30:30 +01:00
|
|
|
ui.screen_changed = false;
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
if (screen_items > 0 && encoderLine >= screen_items - limit) {
|
2019-07-06 01:01:21 +02:00
|
|
|
encoderLine = _MAX(0, screen_items - limit);
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM);
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
if (is_menu) {
|
|
|
|
NOMORE(encoderTopLine, encoderLine);
|
2018-10-27 20:07:03 +02:00
|
|
|
if (encoderLine >= encoderTopLine + LCD_HEIGHT)
|
|
|
|
encoderTopLine = encoderLine - LCD_HEIGHT + 1;
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
encoderTopLine = encoderLine;
|
|
|
|
}
|
|
|
|
|
2019-07-29 02:14:50 +02:00
|
|
|
#if HAS_BUZZER
|
|
|
|
void MarlinUI::completion_feedback(const bool good/*=true*/) {
|
2021-09-14 04:07:08 +02:00
|
|
|
TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up on rotary encoder click...
|
2019-07-29 02:14:50 +02:00
|
|
|
if (good) {
|
|
|
|
BUZZ(100, 659);
|
|
|
|
BUZZ(100, 698);
|
|
|
|
}
|
|
|
|
else BUZZ(20, 440);
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
2019-07-29 02:14:50 +02:00
|
|
|
#endif
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2018-10-28 08:59:21 +01:00
|
|
|
#if HAS_LINE_TO_Z
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2021-04-02 00:59:57 +02:00
|
|
|
void line_to_z(const_float_t z) {
|
2019-09-29 11:25:39 +02:00
|
|
|
current_position.z = z;
|
2020-02-03 07:00:35 +01:00
|
|
|
line_to_current_position(manual_feedrate_mm_s.z);
|
2018-10-28 08:59:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2018-10-27 21:53:05 +02:00
|
|
|
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2019-04-07 01:04:34 +02:00
|
|
|
#include "../../feature/babystep.h"
|
|
|
|
|
2018-10-27 21:53:05 +02:00
|
|
|
void lcd_babystep_zoffset() {
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
|
2019-03-23 22:30:43 +01:00
|
|
|
ui.defer_status_screen();
|
2020-03-09 01:42:18 +01:00
|
|
|
const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0;
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.encoderPosition) {
|
2020-07-03 16:24:41 +02:00
|
|
|
const int16_t babystep_increment = int16_t(ui.encoderPosition) * (BABYSTEP_SIZE_Z);
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.encoderPosition = 0;
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2021-09-27 21:05:52 +02:00
|
|
|
const float diff = planner.mm_per_step[Z_AXIS] * babystep_increment,
|
2020-02-01 11:21:36 +01:00
|
|
|
new_probe_offset = probe.offset.z + diff,
|
2020-04-26 00:53:06 +02:00
|
|
|
new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET
|
|
|
|
, do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff
|
|
|
|
, new_probe_offset
|
|
|
|
);
|
2018-10-27 21:53:05 +02:00
|
|
|
if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2019-04-07 01:04:34 +02:00
|
|
|
babystep.add_steps(Z_AXIS, babystep_increment);
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2020-04-22 23:35:03 +02:00
|
|
|
if (do_probe)
|
|
|
|
probe.offset.z = new_offs;
|
|
|
|
else
|
|
|
|
TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP);
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
}
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.should_draw()) {
|
2020-03-09 01:42:18 +01:00
|
|
|
if (do_probe) {
|
2020-03-17 21:12:52 +01:00
|
|
|
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), BABYSTEP_TO_STR(probe.offset.z));
|
2021-10-02 09:33:14 +02:00
|
|
|
TERN_(BABYSTEP_ZPROBE_GFX_OVERLAY, ui.zoffset_overlay(probe.offset.z));
|
2020-03-09 01:42:18 +01:00
|
|
|
}
|
2020-04-26 00:53:06 +02:00
|
|
|
else {
|
|
|
|
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
|
|
|
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), ftostr54sign(hotend_offset[active_extruder].z));
|
|
|
|
#endif
|
|
|
|
}
|
2018-10-27 21:53:05 +02:00
|
|
|
}
|
|
|
|
}
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2018-10-27 21:53:05 +02:00
|
|
|
#endif // BABYSTEP_ZPROBE_OFFSET
|
2018-10-23 23:00:34 +02:00
|
|
|
|
|
|
|
void _lcd_draw_homing() {
|
2020-09-28 08:01:35 +02:00
|
|
|
if (ui.should_draw()) {
|
|
|
|
constexpr uint8_t line = (LCD_HEIGHT - 1) / 2;
|
|
|
|
MenuItem_static::draw(line, GET_TEXT(MSG_LEVEL_BED_HOMING));
|
|
|
|
}
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))
|
2018-10-28 07:59:47 +01:00
|
|
|
#include "../../feature/bedlevel/bedlevel.h"
|
2018-10-23 23:00:34 +02:00
|
|
|
void _lcd_toggle_bed_leveling() { set_bed_leveling_enabled(!planner.leveling_active); }
|
|
|
|
#endif
|
|
|
|
|
2019-04-24 17:13:44 +02:00
|
|
|
//
|
|
|
|
// Selection screen presents a prompt and two options
|
|
|
|
//
|
2019-07-18 02:41:15 +02:00
|
|
|
bool MarlinUI::selection; // = false
|
|
|
|
bool MarlinUI::update_selection() {
|
2019-07-31 00:42:57 +02:00
|
|
|
encoder_direction_select();
|
2019-07-18 02:41:15 +02:00
|
|
|
if (encoderPosition) {
|
|
|
|
selection = int16_t(encoderPosition) > 0;
|
|
|
|
encoderPosition = 0;
|
2019-04-08 20:44:35 +02:00
|
|
|
}
|
2019-07-18 02:41:15 +02:00
|
|
|
return selection;
|
|
|
|
}
|
2019-11-02 13:28:20 +01:00
|
|
|
|
2020-05-10 07:37:19 +02:00
|
|
|
void MenuItem_confirm::select_screen(
|
|
|
|
PGM_P const yes, PGM_P const no,
|
|
|
|
selectFunc_t yesFunc, selectFunc_t noFunc,
|
|
|
|
PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/
|
|
|
|
) {
|
2021-06-27 07:33:44 +02:00
|
|
|
ui.defer_status_screen();
|
2019-07-18 02:41:15 +02:00
|
|
|
const bool ui_selection = ui.update_selection(), got_click = ui.use_click();
|
2019-04-24 17:13:44 +02:00
|
|
|
if (got_click || ui.should_draw()) {
|
|
|
|
draw_select_screen(yes, no, ui_selection, pref, string, suff);
|
2020-08-21 09:41:33 +02:00
|
|
|
if (got_click) {
|
|
|
|
selectFunc_t callFunc = ui_selection ? yesFunc : noFunc;
|
|
|
|
if (callFunc) callFunc(); else ui.goto_previous_screen();
|
|
|
|
}
|
2019-04-24 17:13:44 +02:00
|
|
|
}
|
2019-04-08 20:44:35 +02:00
|
|
|
}
|
|
|
|
|
2018-10-30 22:34:45 +01:00
|
|
|
#endif // HAS_LCD_MENU
|