2018-10-23 23:00:34 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-02-12 22:06:53 +01:00
|
|
|
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2018-10-23 23:00:34 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
|
|
|
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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 "../ultralcd.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"
|
2018-10-28 08:59:21 +01:00
|
|
|
#include "../../sd/cardreader.h"
|
2018-11-11 19:16:24 +01:00
|
|
|
#include "../../libs/buzzer.h"
|
2018-10-28 08:59:21 +01:00
|
|
|
|
|
|
|
#if ENABLED(EEPROM_SETTINGS)
|
|
|
|
#include "../../module/configuration_store.h"
|
|
|
|
#endif
|
|
|
|
|
2019-04-07 01:04:34 +02:00
|
|
|
#if WATCH_HOTENDS || WATCH_BED
|
2018-10-28 08:59:21 +01:00
|
|
|
#include "../../module/temperature.h"
|
|
|
|
#endif
|
2018-10-23 23:00:34 +02:00
|
|
|
|
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 {
|
|
|
|
screenFunc_t menu_function;
|
|
|
|
uint32_t encoder_position;
|
2019-04-07 23:53:30 +02:00
|
|
|
int8_t top_line, items;
|
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
|
|
|
bool screen_changed;
|
|
|
|
|
2018-10-23 23:00:34 +02:00
|
|
|
// Value Editing
|
2019-04-09 04:10:41 +02:00
|
|
|
PGM_P MenuItemBase::editLabel;
|
|
|
|
void* MenuItemBase::editValue;
|
2019-05-12 01:44:35 +02:00
|
|
|
int32_t MenuItemBase::minEditValue, MenuItemBase::maxEditValue;
|
2019-04-09 04:10:41 +02:00
|
|
|
screenFunc_t MenuItemBase::callbackFunc;
|
|
|
|
bool MenuItemBase::liveEdit;
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2018-10-28 08:59:21 +01:00
|
|
|
// Prevent recursion into screen handlers
|
2018-10-23 23:00:34 +02:00
|
|
|
bool no_reentry = false;
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
//////// 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
|
|
|
|
2018-11-11 19:16:24 +01:00
|
|
|
void MarlinUI::save_previous_screen() {
|
2019-04-04 09:29:44 +02:00
|
|
|
if (screen_history_depth < COUNT(screen_history))
|
|
|
|
screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items };
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
|
2018-11-11 19:16:24 +01:00
|
|
|
void MarlinUI::goto_previous_screen() {
|
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];
|
|
|
|
goto_screen(sh.menu_function, sh.encoder_position, sh.top_line, sh.items);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
2018-10-28 08:59:21 +01:00
|
|
|
/////////// Common Menu Actions ////////////
|
2018-10-23 23:00:34 +02:00
|
|
|
////////////////////////////////////////////
|
|
|
|
|
2019-06-23 10:43:36 +02:00
|
|
|
void MenuItem_gcode::action(PGM_P const pgcode) { queue.inject_P(pgcode); }
|
2018-10-23 23:00:34 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
/////////// Menu Editing Actions ///////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Functions for editing single values
|
|
|
|
*
|
2018-11-06 05:51:10 +01:00
|
|
|
* The "DEFINE_MENU_EDIT_ITEM" macro generates the functions needed to edit a numerical value.
|
2018-10-23 23:00:34 +02:00
|
|
|
*
|
2018-11-06 05:51:10 +01:00
|
|
|
* The prerequisite is that in the header the type was already declared:
|
2018-10-23 23:00:34 +02:00
|
|
|
*
|
2019-01-12 23:01:04 +01:00
|
|
|
* DECLARE_MENU_EDIT_TYPE(int16_t, int3, i16tostr3, 1)
|
2018-11-06 05:51:10 +01:00
|
|
|
*
|
|
|
|
* For example, DEFINE_MENU_EDIT_ITEM(int3) expands into these functions:
|
|
|
|
*
|
2018-11-14 20:13:51 +01:00
|
|
|
* bool MenuItem_int3::_edit();
|
|
|
|
* void MenuItem_int3::edit(); // edit int16_t (interactively)
|
|
|
|
* void MenuItem_int3::action_edit(PGM_P const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue, const screenFunc_t callback = null, const bool live = false);
|
2018-10-23 23:00:34 +02:00
|
|
|
*
|
|
|
|
* You can then use one of the menu macros to present the edit interface:
|
|
|
|
* MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
|
|
|
|
*
|
|
|
|
* This expands into a more primitive menu item:
|
2018-11-14 20:13:51 +01:00
|
|
|
* MENU_ITEM_VARIANT(int3, _edit, MSG_SPEED, PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
|
2018-10-23 23:00:34 +02:00
|
|
|
*
|
|
|
|
* ...which calls:
|
2018-11-14 20:13:51 +01:00
|
|
|
* MenuItem_int3::action_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
|
2018-10-23 23:00:34 +02:00
|
|
|
*/
|
2018-11-11 19:16:24 +01:00
|
|
|
void MenuItemBase::edit(strfunc_t strfunc, loadfunc_t loadfunc) {
|
|
|
|
ui.encoder_direction_normal();
|
2019-04-09 04:10:41 +02:00
|
|
|
if (int16_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
|
|
|
|
if (int16_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.should_draw())
|
|
|
|
draw_edit_screen(editLabel, strfunc(ui.encoderPosition + minEditValue));
|
|
|
|
if (ui.lcd_clicked || (liveEdit && ui.should_draw())) {
|
2019-05-09 18:45:55 +02:00
|
|
|
if (editValue != nullptr) loadfunc(editValue, ui.encoderPosition + minEditValue);
|
2018-11-11 19:16:24 +01:00
|
|
|
if (callbackFunc && (liveEdit || ui.lcd_clicked)) (*callbackFunc)();
|
|
|
|
if (ui.use_click()) ui.goto_previous_screen();
|
2018-11-06 05:51:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-12 01:44:35 +02:00
|
|
|
void MenuItemBase::init(PGM_P const el, void * const ev, const int32_t minv, const int32_t maxv, const uint16_t ep, const screenFunc_t cs, const screenFunc_t cb, const bool le) {
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.save_previous_screen();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-02-10 11:54:23 +01:00
|
|
|
#define DEFINE_MENU_EDIT_ITEM(NAME) template class TMenuItem<MenuItemInfo_##NAME>
|
2018-11-06 05:51:10 +01:00
|
|
|
|
2019-01-29 03:18:58 +01:00
|
|
|
DEFINE_MENU_EDIT_ITEM(int3); // 123, -12 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM(int4); // 1234, -123 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM(int8); // 123, -12 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM(uint8); // 123 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM(uint16_3); // 123, -12 right-justified
|
2019-06-28 06:06:49 +02:00
|
|
|
DEFINE_MENU_EDIT_ITEM(uint16_4); // 1234 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM(uint16_5); // 12345 right-justified
|
2019-01-29 03:18:58 +01:00
|
|
|
DEFINE_MENU_EDIT_ITEM(float3); // 123 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM(float52); // 123.45
|
|
|
|
DEFINE_MENU_EDIT_ITEM(float43); // 1.234
|
|
|
|
DEFINE_MENU_EDIT_ITEM(float5); // 12345 right-justified
|
2019-05-05 00:21:58 +02:00
|
|
|
DEFINE_MENU_EDIT_ITEM(float5_25); // 12345 right-justified (25 increment)
|
2019-04-16 22:45:31 +02:00
|
|
|
DEFINE_MENU_EDIT_ITEM(float51); // 1234.5 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM(float51sign); // +1234.5
|
2019-01-29 03:18:58 +01:00
|
|
|
DEFINE_MENU_EDIT_ITEM(float52sign); // +123.45
|
|
|
|
DEFINE_MENU_EDIT_ITEM(long5); // 12345 right-justified
|
2019-05-05 00:21:58 +02:00
|
|
|
DEFINE_MENU_EDIT_ITEM(long5_25); // 12345 right-justified (25 increment)
|
2018-11-06 05:51:10 +01:00
|
|
|
|
2018-11-14 20:13:51 +01:00
|
|
|
void MenuItem_bool::action_edit(PGM_P pstr, bool *ptr, screenFunc_t callback) {
|
2018-11-11 19:16:24 +01:00
|
|
|
UNUSED(pstr); *ptr ^= true; ui.refresh();
|
2018-11-06 05:51:10 +01:00
|
|
|
if (callback) (*callback)();
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
///////////////// Menu Tree ////////////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
|
|
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
|
|
|
float lcd_z_fade_height;
|
|
|
|
void _lcd_set_z_fade_height() { set_z_fade_height(lcd_z_fade_height); }
|
|
|
|
#endif
|
|
|
|
|
2019-02-12 22:55:47 +01:00
|
|
|
bool printer_busy() {
|
|
|
|
return planner.movesplanned() || IS_SD_PRINTING() || print_job_timer.isRunning();
|
|
|
|
}
|
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) {
|
|
|
|
|
|
|
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
|
|
|
// Shadow for editing the fade height
|
|
|
|
lcd_z_fade_height = planner.z_fade_height;
|
|
|
|
#endif
|
|
|
|
|
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;
|
|
|
|
}
|
2018-11-11 19:16:24 +01:00
|
|
|
else if (screen == status_screen && currentScreen == menu_main && PENDING(millis(), doubleclick_expire_ms)) {
|
2019-02-27 11:38:56 +01:00
|
|
|
|
|
|
|
#if ENABLED(BABYSTEP_WITHOUT_HOMING)
|
|
|
|
constexpr bool can_babystep = true;
|
|
|
|
#else
|
|
|
|
const bool can_babystep = all_axes_known();
|
|
|
|
#endif
|
|
|
|
#if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
|
|
|
|
constexpr bool should_babystep = true;
|
|
|
|
#else
|
|
|
|
const bool should_babystep = printer_busy();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (should_babystep && can_babystep) {
|
2018-10-23 23:00:34 +02:00
|
|
|
screen =
|
|
|
|
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
|
|
|
lcd_babystep_zoffset
|
|
|
|
#else
|
|
|
|
lcd_babystep_z
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
}
|
|
|
|
#if ENABLED(MOVE_Z_WHEN_IDLE)
|
|
|
|
else {
|
|
|
|
move_menu_scale = MOVE_Z_IDLE_MULTIPLICATOR;
|
|
|
|
screen = lcd_move_z;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
currentScreen = screen;
|
|
|
|
encoderPosition = encoder;
|
2019-04-04 09:29:44 +02:00
|
|
|
encoderTopLine = top;
|
|
|
|
screen_items = items;
|
2018-11-11 19:16:24 +01:00
|
|
|
if (screen == status_screen) {
|
2019-02-06 02:04:26 +01:00
|
|
|
defer_status_screen(false);
|
2018-10-23 23:00:34 +02:00
|
|
|
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
|
|
|
ubl.lcd_map_control = false;
|
|
|
|
#endif
|
|
|
|
screen_history_depth = 0;
|
|
|
|
}
|
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
|
2018-10-30 22:34:45 +01:00
|
|
|
#if HAS_CHARACTER_LCD
|
2019-02-27 11:38:56 +01:00
|
|
|
if (true
|
|
|
|
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
|
|
|
&& !ubl.lcd_map_control
|
|
|
|
#endif
|
|
|
|
) set_custom_characters(screen == 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;
|
|
|
|
#if HAS_GRAPHICAL_LCD
|
|
|
|
drawing_screen = false;
|
|
|
|
#endif
|
2019-04-24 17:13:44 +02:00
|
|
|
|
|
|
|
set_ui_selection(false);
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
///////////// Manual Movement //////////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
|
|
|
//
|
|
|
|
// Display the synchronize screen until moves are
|
|
|
|
// finished, and don't return to the caller until
|
|
|
|
// done. ** This blocks the command queue! **
|
|
|
|
//
|
|
|
|
static PGM_P sync_message;
|
|
|
|
|
2018-11-11 19:16:24 +01:00
|
|
|
void MarlinUI::_synchronize() {
|
|
|
|
if (should_draw()) draw_menu_item_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message);
|
2018-10-23 23:00:34 +02:00
|
|
|
if (no_reentry) return;
|
|
|
|
// Make this the current handler till all moves are done
|
|
|
|
no_reentry = true;
|
|
|
|
const screenFunc_t old_screen = currentScreen;
|
2018-11-11 19:16:24 +01:00
|
|
|
goto_screen(_synchronize);
|
2018-10-23 23:00:34 +02:00
|
|
|
planner.synchronize(); // idle() is called until moves complete
|
|
|
|
no_reentry = false;
|
2018-11-11 19:16:24 +01:00
|
|
|
goto_screen(old_screen);
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Display the synchronize screen with a custom message
|
|
|
|
// ** This blocks the command queue! **
|
2019-05-09 18:45:55 +02:00
|
|
|
void MarlinUI::synchronize(PGM_P const msg/*=nullptr*/) {
|
2018-10-23 23:00:34 +02:00
|
|
|
static const char moving[] PROGMEM = MSG_MOVING;
|
|
|
|
sync_message = msg ? msg : moving;
|
2018-11-11 19:16:24 +01:00
|
|
|
_synchronize();
|
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
|
|
|
|
* _lcdLineNr is the index of the LCD line (e.g., 0-3)
|
|
|
|
* _menuLineNr is the menu item to draw and process
|
|
|
|
* _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
|
|
|
|
* 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);
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.encoderPosition > 0x8000) ui.encoderPosition = 0;
|
|
|
|
if (ui.first_page) {
|
|
|
|
encoderLine = ui.encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);
|
2018-10-23 23:00:34 +02:00
|
|
|
screen_changed = false;
|
|
|
|
}
|
|
|
|
if (screen_items > 0 && encoderLine >= screen_items - limit) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-11-11 19:16:24 +01:00
|
|
|
void MarlinUI::completion_feedback(const bool good/*=true*/) {
|
2018-10-23 23:00:34 +02:00
|
|
|
if (good) {
|
2018-11-11 19:16:24 +01:00
|
|
|
BUZZ(100, 659);
|
|
|
|
BUZZ(100, 698);
|
2018-10-23 23:00:34 +02:00
|
|
|
}
|
2018-11-11 19:16:24 +01:00
|
|
|
else BUZZ(20, 440);
|
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
|
|
|
|
2018-10-28 08:59:21 +01:00
|
|
|
void line_to_z(const float &z) {
|
|
|
|
current_position[Z_AXIS] = z;
|
|
|
|
planner.buffer_line(current_position, MMM_TO_MMS(manual_feedrate_mm_m[Z_AXIS]), active_extruder);
|
|
|
|
}
|
|
|
|
|
|
|
|
#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();
|
2018-10-27 21:53:05 +02:00
|
|
|
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
|
|
|
const bool do_probe = (active_extruder == 0);
|
|
|
|
#else
|
|
|
|
constexpr bool do_probe = true;
|
|
|
|
#endif
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.encoder_direction_normal();
|
|
|
|
if (ui.encoderPosition) {
|
2019-04-09 04:10:41 +02:00
|
|
|
const int16_t babystep_increment = int16_t(ui.encoderPosition) * (BABYSTEP_MULTIPLICATOR);
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.encoderPosition = 0;
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2018-10-27 21:53:05 +02:00
|
|
|
const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
|
|
|
|
new_probe_offset = zprobe_zoffset + diff,
|
|
|
|
new_offs =
|
|
|
|
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
|
|
|
do_probe ? new_probe_offset : hotend_offset[Z_AXIS][active_extruder] - diff
|
|
|
|
#else
|
|
|
|
new_probe_offset
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
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
|
|
|
|
2018-10-27 21:53:05 +02:00
|
|
|
if (do_probe) zprobe_zoffset = new_offs;
|
2018-10-23 23:00:34 +02:00
|
|
|
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
2018-10-27 21:53:05 +02:00
|
|
|
else hotend_offset[Z_AXIS][active_extruder] = new_offs;
|
2018-10-23 23:00:34 +02:00
|
|
|
#endif
|
|
|
|
|
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()) {
|
2018-10-27 21:53:05 +02:00
|
|
|
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
|
|
|
if (!do_probe)
|
2019-04-10 01:33:40 +02:00
|
|
|
draw_edit_screen(PSTR(MSG_Z_OFFSET), ftostr43sign(hotend_offset[Z_AXIS][active_extruder]));
|
2018-10-27 21:53:05 +02:00
|
|
|
else
|
|
|
|
#endif
|
2018-11-11 19:16:24 +01:00
|
|
|
draw_edit_screen(PSTR(MSG_ZPROBE_ZOFFSET), ftostr43sign(zprobe_zoffset));
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2018-10-27 21:53:05 +02:00
|
|
|
#if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY)
|
|
|
|
if (do_probe) _lcd_zoffset_overlay_gfx(zprobe_zoffset);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
2019-03-17 05:43:06 +01:00
|
|
|
#if ANY(AUTO_BED_LEVELING_UBL, PID_AUTOTUNE_MENU, ADVANCED_PAUSE_FEATURE)
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2019-06-19 07:00:19 +02:00
|
|
|
void lcd_enqueue_one_now(const char * const cmd) {
|
2018-10-23 23:00:34 +02:00
|
|
|
no_reentry = true;
|
2019-06-19 07:00:19 +02:00
|
|
|
queue.enqueue_one_now(cmd);
|
2018-10-23 23:00:34 +02:00
|
|
|
no_reentry = false;
|
|
|
|
}
|
|
|
|
|
2019-06-19 07:00:19 +02:00
|
|
|
void lcd_enqueue_one_now_P(PGM_P const cmd) {
|
2018-10-23 23:00:34 +02:00
|
|
|
no_reentry = true;
|
2019-06-19 07:00:19 +02:00
|
|
|
queue.enqueue_now_P(cmd);
|
2018-10-23 23:00:34 +02:00
|
|
|
no_reentry = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(EEPROM_SETTINGS)
|
2018-11-11 19:16:24 +01:00
|
|
|
void lcd_store_settings() { ui.completion_feedback(settings.save()); }
|
|
|
|
void lcd_load_settings() { ui.completion_feedback(settings.load()); }
|
2018-10-23 23:00:34 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void _lcd_draw_homing() {
|
|
|
|
constexpr uint8_t line = (LCD_HEIGHT - 1) / 2;
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.should_draw()) draw_menu_item_static(line, PSTR(MSG_LEVEL_BED_HOMING));
|
|
|
|
ui.refresh(LCDVIEW_CALL_NO_REDRAW);
|
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
|
|
|
|
//
|
|
|
|
bool ui_selection; // = false
|
|
|
|
void set_ui_selection(const bool sel) { ui_selection = sel; }
|
2019-05-09 18:45:55 +02:00
|
|
|
void do_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*/) {
|
2019-04-08 20:44:35 +02:00
|
|
|
if (ui.encoderPosition) {
|
2019-04-24 17:13:44 +02:00
|
|
|
ui_selection = int16_t(ui.encoderPosition) > 0;
|
2019-04-08 20:44:35 +02:00
|
|
|
ui.encoderPosition = 0;
|
|
|
|
}
|
2019-04-24 17:13:44 +02:00
|
|
|
const bool got_click = ui.use_click();
|
|
|
|
if (got_click || ui.should_draw()) {
|
|
|
|
draw_select_screen(yes, no, ui_selection, pref, string, suff);
|
|
|
|
if (got_click) { ui_selection ? yesFunc() : noFunc(); }
|
|
|
|
}
|
2019-04-08 20:44:35 +02:00
|
|
|
}
|
|
|
|
|
2018-10-30 22:34:45 +01:00
|
|
|
#endif // HAS_LCD_MENU
|