update code base to Marlin 2.0.9.2

This commit is contained in:
Stefan Kalscheuer
2021-10-03 18:57:12 +02:00
parent b9d7ba838e
commit 7077da3591
2617 changed files with 332093 additions and 103438 deletions

6
Marlin/src/lcd/menu/game/brickout.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -50,8 +50,8 @@ inline void reset_bricks(const uint16_t v) {
void reset_ball() {
constexpr uint8_t ball_dist = 24;
bdat.bally = BTOF(PADDLE_Y - ball_dist);
bdat.ballv = FTOP(1.3f);
bdat.ballh = -FTOP(1.25f);
bdat.ballv = FTOF(1.3f);
bdat.ballh = -FTOF(1.25f);
uint8_t bx = bdat.paddle_x + (PADDLE_W) / 2 + ball_dist;
if (bx >= LCD_PIXEL_WIDTH - 10) { bx -= ball_dist * 2; bdat.ballh = -bdat.ballh; }
bdat.ballx = BTOF(bx);

2
Marlin/src/lcd/menu/game/brickout.h Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

2
Marlin/src/lcd/menu/game/game.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

6
Marlin/src/lcd/menu/game/game.h Executable file → Normal file
View File

@@ -16,15 +16,15 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../../../inc/MarlinConfigPre.h"
#include "../../dogm/ultralcd_DOGM.h"
#include "../../dogm/marlinui_DOGM.h"
#include "../../lcdprint.h"
#include "../../ultralcd.h"
#include "../../marlinui.h"
//#define MUTE_GAMES

2
Marlin/src/lcd/menu/game/invaders.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

2
Marlin/src/lcd/menu/game/invaders.h Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

2
Marlin/src/lcd/menu/game/maze.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

2
Marlin/src/lcd/menu/game/maze.h Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

6
Marlin/src/lcd/menu/game/snake.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -63,7 +63,7 @@
#define SNAKE_SIZ SNAKE_BOX
#endif
constexpr fixed_t snakev = FTOP(0.20);
constexpr fixed_t snakev = FTOF(0.20);
snake_data_t &sdat = marlin_game_data.snake;
@@ -125,7 +125,7 @@ void snake_reset() {
// Init the head and velocity
sdat.snakex = BTOF(1);
sdat.snakey = BTOF(GAME_H / 2);
//snakev = FTOP(0.25);
//snakev = FTOF(0.25);
// Init the tail with a cw turn
sdat.snake_dir = 0;

2
Marlin/src/lcd/menu/game/snake.h Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

4
Marlin/src/lcd/menu/game/types.h Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
@@ -27,7 +27,7 @@ typedef struct { int8_t x, y; } pos_t;
// Simple 8:8 fixed-point
typedef int16_t fixed_t;
#define FTOP(F) fixed_t((F)*256.0f)
#define FTOF(F) fixed_t((F)*256.0f)
#define PTOF(P) (float(P)*(1.0f/256.0f))
#define BTOF(X) (fixed_t(X)<<8)
#define FTOB(X) int8_t(fixed_t(X)>>8)

271
Marlin/src/lcd/menu/menu.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -34,14 +34,6 @@
#include "../../libs/buzzer.h"
#endif
#if ENABLED(EEPROM_SETTINGS)
#include "../../module/configuration_store.h"
#endif
#if WATCH_HOTENDS || WATCH_BED
#include "../../module/temperature.h"
#endif
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
#include "../../module/probe.h"
#endif
@@ -58,14 +50,18 @@
int8_t encoderTopLine, encoderLine, screen_items;
typedef struct {
screenFunc_t menu_function;
uint32_t encoder_position;
int8_t top_line, items;
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
} menuPosition;
menuPosition screen_history[6];
uint8_t screen_history_depth = 0;
uint8_t MenuItemBase::itemIndex; // Index number for draw and action
int8_t MenuItemBase::itemIndex; // Index number for draw and action
PGM_P MenuItemBase::itemString; // A PSTR for substitution
chimera_t editable; // Value Editing
// Menu Edit Items
@@ -76,28 +72,20 @@ int32_t MenuEditItemBase::minEditValue,
screenFunc_t MenuEditItemBase::callbackFunc;
bool MenuEditItemBase::liveEdit;
// Prevent recursion into screen handlers
bool no_reentry = false;
////////////////////////////////////////////
//////// Menu Navigation & History /////////
////////////////////////////////////////////
void MarlinUI::return_to_status() { goto_screen(status_screen); }
void MarlinUI::save_previous_screen() {
void MarlinUI::push_current_screen() {
if (screen_history_depth < COUNT(screen_history))
screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items };
screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items OPTARG(SCREENS_CAN_TIME_OUT, screen_is_sticky()) };
}
void MarlinUI::_goto_previous_screen(
#if ENABLED(TURBO_BACK_MENU_ITEM)
const bool is_back/*=false*/
#endif
) {
#if DISABLED(TURBO_BACK_MENU_ITEM)
constexpr bool is_back = false;
#endif
void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) {
IF_DISABLED(TURBO_BACK_MENU_ITEM, constexpr bool is_back = false);
TERN_(HAS_TOUCH_BUTTONS, on_edit_screen = false);
if (screen_history_depth > 0) {
menuPosition &sh = screen_history[--screen_history_depth];
goto_screen(sh.menu_function,
@@ -105,17 +93,12 @@ void MarlinUI::_goto_previous_screen(
is_back ? 0 : sh.top_line,
sh.items
);
defer_status_screen(TERN_(SCREENS_CAN_TIME_OUT, sh.sticky));
}
else
return_to_status();
}
////////////////////////////////////////////
/////////// Common Menu Actions ////////////
////////////////////////////////////////////
void MenuItem_gcode::action(PGM_P const, PGM_P const pgcode) { queue.inject_P(pgcode); }
////////////////////////////////////////////
/////////// Menu Editing Actions ///////////
////////////////////////////////////////////
@@ -144,15 +127,13 @@ void MenuItem_gcode::action(PGM_P const, PGM_P const pgcode) { queue.inject_P(pg
* MenuItem_int3::draw(encoderLine == _thisItemNr, _lcdLineNr, plabel, &feedrate_percentage, 10, 999)
*/
void MenuEditItemBase::edit_screen(strfunc_t strfunc, loadfunc_t loadfunc) {
#if ENABLED(TOUCH_BUTTONS)
ui.repeat_delay = BUTTON_DELAY_EDIT;
#endif
TERN_(HAS_TOUCH_BUTTONS, ui.repeat_delay = BUTTON_DELAY_EDIT);
if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
if (int32_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
if (ui.should_draw())
draw_edit_screen(strfunc(ui.encoderPosition + minEditValue));
if (ui.lcd_clicked || (liveEdit && ui.should_draw())) {
if (editValue != nullptr) loadfunc(editValue, ui.encoderPosition + minEditValue);
if (editValue) loadfunc(editValue, ui.encoderPosition + minEditValue);
if (callbackFunc && (liveEdit || ui.lcd_clicked)) (*callbackFunc)();
if (ui.use_click()) ui.goto_previous_screen();
}
@@ -168,8 +149,9 @@ void MenuEditItemBase::goto_edit_screen(
const screenFunc_t cb, // Callback after edit
const bool le // Flag to call cb() during editing
) {
TERN_(HAS_TOUCH_BUTTONS, ui.on_edit_screen = true);
ui.screen_changed = true;
ui.save_previous_screen();
ui.push_current_screen();
ui.refresh();
editLabel = el;
editValue = ev;
@@ -181,34 +163,6 @@ void MenuEditItemBase::goto_edit_screen(
liveEdit = le;
}
// TODO: Remove these but test build size with and without
#define DEFINE_MENU_EDIT_ITEM(NAME) template class TMenuEditItem<MenuEditItemInfo_##NAME>
DEFINE_MENU_EDIT_ITEM(percent); // 100% right-justified
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 right-justified
DEFINE_MENU_EDIT_ITEM(uint16_4); // 1234 right-justified
DEFINE_MENU_EDIT_ITEM(uint16_5); // 12345 right-justified
DEFINE_MENU_EDIT_ITEM(float3); // 123 right-justified
DEFINE_MENU_EDIT_ITEM(float42_52); // _2.34, 12.34, -2.34 or 123.45, -23.45
DEFINE_MENU_EDIT_ITEM(float43); // 1.234
DEFINE_MENU_EDIT_ITEM(float5); // 12345 right-justified
DEFINE_MENU_EDIT_ITEM(float5_25); // 12345 right-justified (25 increment)
DEFINE_MENU_EDIT_ITEM(float51); // 1234.5 right-justified
DEFINE_MENU_EDIT_ITEM(float41sign); // +123.4
DEFINE_MENU_EDIT_ITEM(float51sign); // +1234.5
DEFINE_MENU_EDIT_ITEM(float52sign); // +123.45
DEFINE_MENU_EDIT_ITEM(long5); // 12345 right-justified
DEFINE_MENU_EDIT_ITEM(long5_25); // 12345 right-justified (25 increment)
void MenuItem_bool::action(PGM_P const, bool * const ptr, screenFunc_t callback) {
*ptr ^= true; ui.refresh();
if (callback) (*callback)();
}
////////////////////////////////////////////
///////////////// Menu Tree ////////////////
////////////////////////////////////////////
@@ -225,13 +179,11 @@ bool printer_busy() {
void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, const uint8_t top/*=0*/, const uint8_t items/*=0*/) {
if (currentScreen != screen) {
#if ENABLED(TOUCH_BUTTONS)
repeat_delay = BUTTON_DELAY_MENU;
#endif
TERN_(IS_DWIN_MARLINUI, did_first_redraw = false);
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
progress_reset();
#endif
TERN_(HAS_TOUCH_BUTTONS, repeat_delay = BUTTON_DELAY_MENU);
TERN_(LCD_SET_PROGRESS_MANUALLY, progress_reset());
#if BOTH(DOUBLECLICK_FOR_Z_BABYSTEPPING, BABYSTEPPING)
static millis_t doubleclick_expire_ms = 0;
@@ -242,33 +194,14 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
doubleclick_expire_ms = millis() + DOUBLECLICK_MAX_INTERVAL;
}
else if (screen == status_screen && currentScreen == menu_main && PENDING(millis(), doubleclick_expire_ms)) {
#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) {
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;
if (BABYSTEP_ALLOWED())
screen = TERN(BABYSTEP_ZPROBE_OFFSET, lcd_babystep_zoffset, lcd_babystep_z);
else {
#if ENABLED(MOVE_Z_WHEN_IDLE)
ui.manual_move.menu_scale = MOVE_Z_IDLE_MULTIPLICATOR;
screen = lcd_move_z;
}
#endif
#endif
}
}
#endif
@@ -276,34 +209,25 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
encoderPosition = encoder;
encoderTopLine = top;
screen_items = items;
if (screen == status_screen) {
if (on_status_screen()) {
defer_status_screen(false);
#if ENABLED(AUTO_BED_LEVELING_UBL)
ubl.lcd_map_control = false;
#endif
screen_history_depth = 0;
clear_menu_history();
TERN_(AUTO_BED_LEVELING_UBL, ubl.lcd_map_control = false);
}
clear_lcd();
// Re-initialize custom characters that may be re-used
#if HAS_CHARACTER_LCD
if (true
#if ENABLED(AUTO_BED_LEVELING_UBL)
&& !ubl.lcd_map_control
#endif
) set_custom_characters(screen == status_screen ? CHARSET_INFO : CHARSET_MENU);
#if HAS_MARLINUI_HD44780
if (TERN1(AUTO_BED_LEVELING_UBL, !ubl.lcd_map_control))
set_custom_characters(on_status_screen() ? CHARSET_INFO : CHARSET_MENU);
#endif
refresh(LCDVIEW_CALL_REDRAW_NEXT);
screen_changed = true;
#if HAS_GRAPHICAL_LCD
drawing_screen = false;
#endif
TERN_(HAS_MARLINUI_U8GLIB, drawing_screen = false);
#if HAS_LCD_MENU
encoder_direction_normal();
#endif
TERN_(HAS_LCD_MENU, encoder_direction_normal());
set_selection(false);
}
@@ -314,29 +238,18 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
////////////////////////////////////////////
//
// Display the synchronize screen until moves are
// finished, and don't return to the caller until
// done. ** This blocks the command queue! **
// Display a "synchronize" screen with a custom message until
// all moves are finished. Go back to calling screen when done.
//
static PGM_P sync_message;
void MarlinUI::_synchronize() {
if (should_draw()) MenuItem_static::draw(LCD_HEIGHT >= 4, sync_message);
if (no_reentry) return;
// Make this the current handler till all moves are done
const screenFunc_t old_screen = currentScreen;
goto_screen(_synchronize);
no_reentry = true;
planner.synchronize(); // idle() is called until moves complete
no_reentry = false;
goto_screen(old_screen);
}
// Display the synchronize screen with a custom message
// ** This blocks the command queue! **
void MarlinUI::synchronize(PGM_P const msg/*=nullptr*/) {
sync_message = msg ?: GET_TEXT(MSG_MOVING);
_synchronize();
static PGM_P sync_message = msg ?: GET_TEXT(MSG_MOVING);
push_current_screen();
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();
}
/**
@@ -372,6 +285,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
#if HAS_BUZZER
void MarlinUI::completion_feedback(const bool good/*=true*/) {
TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up on rotary encoder click...
if (good) {
BUZZ(100, 659);
BUZZ(100, 698);
@@ -382,7 +296,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
#if HAS_LINE_TO_Z
void line_to_z(const float &z) {
void line_to_z(const_float_t z) {
current_position.z = z;
line_to_current_position(manual_feedrate_mm_s.z);
}
@@ -398,39 +312,35 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
ui.defer_status_screen();
const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0;
if (ui.encoderPosition) {
const int16_t babystep_increment = int16_t(ui.encoderPosition) * (BABYSTEP_MULTIPLICATOR_Z);
const int16_t babystep_increment = int16_t(ui.encoderPosition) * (BABYSTEP_SIZE_Z);
ui.encoderPosition = 0;
const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
const float diff = planner.mm_per_step[Z_AXIS] * babystep_increment,
new_probe_offset = probe.offset.z + diff,
new_offs =
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff
#else
new_probe_offset
#endif
;
new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET
, do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff
, new_probe_offset
);
if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
babystep.add_steps(Z_AXIS, babystep_increment);
if (do_probe) probe.offset.z = new_offs;
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
else hotend_offset[active_extruder].z = new_offs;
#endif
if (do_probe)
probe.offset.z = new_offs;
else
TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP);
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
}
}
if (ui.should_draw()) {
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
if (!do_probe)
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), ftostr54sign(hotend_offset[active_extruder].z));
#endif
if (do_probe) {
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), BABYSTEP_TO_STR(probe.offset.z));
#if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY)
_lcd_zoffset_overlay_gfx(probe.offset.z);
TERN_(BABYSTEP_ZPROBE_GFX_OVERLAY, _lcd_zoffset_overlay_gfx(probe.offset.z));
}
else {
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), ftostr54sign(hotend_offset[active_extruder].z));
#endif
}
}
@@ -438,42 +348,11 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
#endif // BABYSTEP_ZPROBE_OFFSET
#if ANY(AUTO_BED_LEVELING_UBL, PID_AUTOTUNE_MENU, ADVANCED_PAUSE_FEATURE)
void lcd_enqueue_one_now(const char * const cmd) {
no_reentry = true;
queue.enqueue_one_now(cmd);
no_reentry = false;
}
void lcd_enqueue_one_now_P(PGM_P const cmd) {
no_reentry = true;
queue.enqueue_now_P(cmd);
no_reentry = false;
}
#endif
#if ENABLED(EEPROM_SETTINGS)
void lcd_store_settings() {
const bool saved = settings.save();
#if HAS_BUZZER
ui.completion_feedback(saved);
#endif
UNUSED(saved);
}
void lcd_load_settings() {
const bool loaded = settings.load();
#if HAS_BUZZER
ui.completion_feedback(loaded);
#endif
UNUSED(loaded);
}
#endif
void _lcd_draw_homing() {
constexpr uint8_t line = (LCD_HEIGHT - 1) / 2;
if (ui.should_draw()) MenuItem_static::draw(line, GET_TEXT(MSG_LEVEL_BED_HOMING));
if (ui.should_draw()) {
constexpr uint8_t line = (LCD_HEIGHT - 1) / 2;
MenuItem_static::draw(line, GET_TEXT(MSG_LEVEL_BED_HOMING));
}
}
#if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))
@@ -494,11 +373,19 @@ bool MarlinUI::update_selection() {
return selection;
}
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*/) {
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*/
) {
ui.defer_status_screen();
const bool ui_selection = ui.update_selection(), 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(); }
if (got_click) {
selectFunc_t callFunc = ui_selection ? yesFunc : noFunc;
if (callFunc) callFunc(); else ui.goto_previous_screen();
}
}
}

457
Marlin/src/lcd/menu/menu.h Executable file → Normal file
View File

@@ -16,12 +16,12 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../ultralcd.h"
#include "../marlinui.h"
#include "../../libs/numtostr.h"
#include "../../inc/MarlinConfig.h"
@@ -29,10 +29,6 @@
extern int8_t encoderLine, encoderTopLine, screen_items;
#if HOTENDS
constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP);
#endif
void scroll_screen(const uint8_t limit, const bool is_menu);
bool printer_busy();
@@ -43,16 +39,8 @@ typedef void (*selectFunc_t)();
#define SS_INVERT 0x02
#define SS_DEFAULT SS_CENTER
#if HAS_GRAPHICAL_LCD && EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY)
void _lcd_zoffset_overlay_gfx(const float zvalue);
#endif
#if HAS_BED_PROBE
#if Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9
#define LCD_Z_OFFSET_TYPE float43 // Values from -9.000 to +9.000
#else
#define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99
#endif
#if EITHER(HAS_MARLINUI_U8GLIB, IS_DWIN_MARLINUI) && EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY)
void _lcd_zoffset_overlay_gfx(const_float_t zvalue);
#endif
#if ENABLED(BABYSTEP_ZPROBE_OFFSET) && Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9
@@ -67,12 +55,14 @@ typedef void (*selectFunc_t)();
class MenuItemBase {
public:
// An index to interject in the item label and for
// use by the action
static uint8_t itemIndex;
// Index to interject in the item label and/or for use by its action.
static int8_t itemIndex;
// An optional pointer for use in display or by the action
static PGM_P itemString;
// Store the index of the item ahead of use by indexed items
FORCE_INLINE static void init(const uint8_t ind) { itemIndex = ind; }
FORCE_INLINE static void init(const int8_t ind=0, PGM_P const pstr=nullptr) { itemIndex = ind; itemString = pstr; }
// Draw an item either selected (pre_char) or not (space) with post_char
static void _draw(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char);
@@ -83,13 +73,24 @@ class MenuItemBase {
}
};
// STATIC_ITEM(LABEL,...)
class MenuItem_static : public MenuItemBase {
public:
static void draw(const uint8_t row, PGM_P const pstr, const uint8_t style=SS_DEFAULT, const char * const valstr=nullptr);
static void draw(const uint8_t row, PGM_P const pstr, const uint8_t style=SS_DEFAULT, const char * const vstr=nullptr);
};
// CONFIRM_ITEM(LABEL,Y,N,FY,FN,V...),
// YESNO_ITEM(LABEL,FY,FN,V...)
// BACK_ITEM(LABEL)
class MenuItem_back : public MenuItemBase {
public:
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) {
_draw(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]);
}
// Back Item action goes back one step in history
FORCE_INLINE static void action(PGM_P const=nullptr) { ui.go_back(); }
};
// CONFIRM_ITEM(LABEL,Y,N,FY,FN,...),
// YESNO_ITEM(LABEL,FY,FN,...)
class MenuItem_confirm : public MenuItemBase {
public:
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
@@ -113,7 +114,7 @@ class MenuItem_confirm : public MenuItemBase {
static inline void select_screen(
PGM_P const yes, PGM_P const no,
selectFunc_t yesFunc, selectFunc_t noFunc,
PGM_P const pref, const progmem_str string, PGM_P const suff=nullptr
PGM_P const pref, FSTR_P const string, PGM_P const suff=nullptr
) {
char str[strlen_P((PGM_P)string) + 1];
strcpy_P(str, (PGM_P)string);
@@ -125,74 +126,21 @@ class MenuItem_confirm : public MenuItemBase {
}
};
// BACK_ITEM(LABEL)
class MenuItem_back : public MenuItemBase {
public:
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) {
_draw(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]);
}
// Back Item action goes back one step in history
FORCE_INLINE static void action(PGM_P const=nullptr) { ui.go_back(); }
};
// SUBMENU(LABEL, screen_handler)
class MenuItem_submenu : public MenuItemBase {
public:
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
_draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]);
}
static inline void action(PGM_P const, const screenFunc_t func) { ui.save_previous_screen(); ui.goto_screen(func); }
};
// Any menu item that invokes an immediate action
class MenuItem_button : public MenuItemBase {
public:
// Button-y Items are selectable lines with no other indicator
static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
_draw(sel, row, pstr, '>', ' ');
}
};
// GCODES_ITEM(LABEL, GCODES)
class MenuItem_gcode : public MenuItem_button {
public:
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
_draw(sel, row, pstr, '>', ' ');
}
static void action(PGM_P const, const char * const pgcode);
static inline void action(PGM_P const pstr, const uint8_t, const char * const pgcode) { action(pstr, pgcode); }
};
// ACTION_ITEM(LABEL, FUNC)
class MenuItem_function : public MenuItem_button {
public:
//static inline void action(PGM_P const, const uint8_t, const menuAction_t func) { (*func)(); };
static inline void action(PGM_P const, const menuAction_t func) { (*func)(); };
};
#if ENABLED(SDSUPPORT)
class CardReader;
class MenuItem_sdbase {
public:
// Implemented for HD44780 and DOGM
static void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir);
};
#endif
////////////////////////////////////////////
///////////// Edit Menu Items //////////////
////////////////////////////////////////////
// The Menu Edit shadow value
typedef union {
bool state;
float decimal;
int8_t int8;
int16_t int16;
int32_t int32;
uint8_t uint8;
uint16_t uint16;
uint32_t uint32;
bool state;
float decimal;
int8_t int8;
int16_t int16;
int32_t int32;
uint8_t uint8;
uint16_t uint16;
uint32_t uint32;
celsius_t celsius;
} chimera_t;
extern chimera_t editable;
@@ -225,295 +173,25 @@ class MenuEditItemBase : public MenuItemBase {
public:
// Implemented for HD44780 and DOGM
// Draw the current item at specified row with edit data
static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm=false);
static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const char * const inStr, const bool pgm=false);
// Implemented for HD44780 and DOGM
// This low-level method is good to draw from anywhere
static void draw_edit_screen(PGM_P const pstr, const char* const value);
static void draw_edit_screen(PGM_P const pstr, const char * const value);
// This method is for the current menu item
static inline void draw_edit_screen(const char* const value) { draw_edit_screen(editLabel, value); }
static inline void draw_edit_screen(const char * const value) { draw_edit_screen(editLabel, value); }
};
// Template for specific Menu Edit Item Types
template<typename NAME>
class TMenuEditItem : MenuEditItemBase {
private:
typedef typename NAME::type_t type_t;
static inline float scale(const float value) { return NAME::scale(value); }
static inline float unscale(const float value) { return NAME::unscale(value); }
static const char* to_string(const int32_t value) { return NAME::strfunc(unscale(value)); }
static void load(void *ptr, const int32_t value) { *((type_t*)ptr) = unscale(value); }
public:
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t * const data, ...) {
MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(*(data)));
}
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t (*pget)(), ...) {
MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(pget()));
}
// Edit screen for this type of item
static void edit_screen() { MenuEditItemBase::edit_screen(to_string, load); }
static void action(
PGM_P const pstr, // Edit label
type_t * const ptr, // Value pointer
const type_t minValue, // Value range
const type_t maxValue,
const screenFunc_t callback=nullptr, // Value update callback
const bool live=false // Callback during editing
) {
// Make sure minv and maxv fit within int32_t
const int32_t minv = _MAX(scale(minValue), INT32_MIN),
maxv = _MIN(scale(maxValue), INT32_MAX);
goto_edit_screen(pstr, ptr, minv, maxv - minv, scale(*ptr) - minv,
edit_screen, callback, live);
}
};
// Provide a set of Edit Item Types which encompass a primitive
// type, a string function, and a scale factor for edit and display.
// These items call the Edit Item draw method passing the prepared string.
#define __DOFIXfloat PROBE()
#define _DOFIX(TYPE,V) TYPE(TERN(IS_PROBE(__DOFIX##TYPE),FIXFLOAT(V),(V)))
#define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, V...) \
struct MenuEditItemInfo_##NAME { \
typedef TYPE type_t; \
static inline float scale(const float value) { return value * (SCALE) + (V+0); } \
static inline float unscale(const float value) { return value / (SCALE) + (V+0); } \
static inline const char* strfunc(const float value) { return STRFUNC(_DOFIX(TYPE,value)); } \
}; \
typedef TMenuEditItem<MenuEditItemInfo_##NAME> MenuItem_##NAME
// NAME TYPE STRFUNC SCALE +ROUND
DEFINE_MENU_EDIT_ITEM_TYPE(percent ,uint8_t ,ui8tostr4pctrj , 100.f/255.f, 0.5f); // 100% right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(int3 ,int16_t ,i16tostr3rj , 1 ); // 123, -12 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(int4 ,int16_t ,i16tostr4signrj , 1 ); // 1234, -123 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(int8 ,int8_t ,i8tostr3rj , 1 ); // 123, -12 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(uint8 ,uint8_t ,ui8tostr3rj , 1 ); // 123 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(uint16_3 ,uint16_t ,ui16tostr3rj , 1 ); // 123 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(uint16_4 ,uint16_t ,ui16tostr4rj , 0.1f ); // 1234 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(uint16_5 ,uint16_t ,ui16tostr5rj , 0.01f ); // 12345 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(float3 ,float ,ftostr3 , 1 ); // 123 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(float42_52 ,float ,ftostr42_52 , 100 ); // _2.34, 12.34, -2.34 or 123.45, -23.45
DEFINE_MENU_EDIT_ITEM_TYPE(float43 ,float ,ftostr43sign ,1000 ); // -1.234, _1.234, +1.234
DEFINE_MENU_EDIT_ITEM_TYPE(float5 ,float ,ftostr5rj , 1 ); // 12345 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(float5_25 ,float ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment)
DEFINE_MENU_EDIT_ITEM_TYPE(float51 ,float ,ftostr51rj , 10 ); // 1234.5 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(float41sign ,float ,ftostr41sign , 10 ); // +123.4
DEFINE_MENU_EDIT_ITEM_TYPE(float51sign ,float ,ftostr51sign , 10 ); // +1234.5
DEFINE_MENU_EDIT_ITEM_TYPE(float52sign ,float ,ftostr52sign , 100 ); // +123.45
DEFINE_MENU_EDIT_ITEM_TYPE(long5 ,uint32_t ,ftostr5rj , 0.01f ); // 12345 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(long5_25 ,uint32_t ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment)
class MenuItem_bool : public MenuEditItemBase {
public:
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const bool onoff) {
MenuEditItemBase::draw(sel, row, pstr, onoff ? GET_TEXT(MSG_LCD_ON) : GET_TEXT(MSG_LCD_OFF), true);
}
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, bool * const data, ...) {
draw(sel, row, pstr, *data);
}
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const, bool (*pget)(), ...) {
draw(sel, row, pstr, pget());
}
static void action(PGM_P const pstr, bool * const ptr, const screenFunc_t callbackFunc=nullptr);
};
////////////////////////////////////////////
//////////// Menu System Macros ////////////
////////////////////////////////////////////
/**
* SCREEN_OR_MENU_LOOP generates init code for a screen or menu
*
* 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
*/
#define SCREEN_OR_MENU_LOOP(IS_MENU) \
scroll_screen(IS_MENU ? 1 : LCD_HEIGHT, IS_MENU); \
int8_t _menuLineNr = encoderTopLine, _thisItemNr = 0; \
bool _skipStatic = IS_MENU; UNUSED(_thisItemNr); \
for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT; _lcdLineNr++, _menuLineNr++) { \
_thisItemNr = 0
/**
* START_SCREEN Opening code for a screen having only static items.
* Do simplified scrolling of the entire screen.
*
* START_MENU Opening code for a screen with menu items.
* Scroll as-needed to keep the selected line in view.
*/
#define START_SCREEN() SCREEN_OR_MENU_LOOP(false)
#define START_MENU() SCREEN_OR_MENU_LOOP(true)
#define NEXT_ITEM() (++_thisItemNr)
#define SKIP_ITEM() NEXT_ITEM()
#define END_SCREEN() } screen_items = _thisItemNr
#define END_MENU() END_SCREEN(); UNUSED(_skipStatic)
#if ENABLED(ENCODER_RATE_MULTIPLIER)
#define ENCODER_RATE_MULTIPLY(F) (ui.encoderRateMultiplierEnabled = F)
#define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER) do{ if (USE_MULTIPLIER) ui.enable_encoder_multiplier(true); }while(0)
//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value
#else
#define ENCODER_RATE_MULTIPLY(F) NOOP
#define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER)
#if ENABLED(SDSUPPORT)
class CardReader;
class MenuItem_sdbase {
public:
// Implemented for HD44780 and DOGM
static void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir);
};
#endif
/**
* MENU_ITEM generates draw & handler code for a menu item, potentially calling:
*
* MenuItem_<type>::draw(sel, row, label, arg3...)
* MenuItem_<type>::action(arg3...)
*
* Examples:
* BACK_ITEM(MSG_INFO_SCREEN)
* MenuItem_back::action(plabel, ...)
* MenuItem_back::draw(sel, row, plabel, ...)
*
* ACTION_ITEM(MSG_PAUSE_PRINT, lcd_sdcard_pause)
* MenuItem_function::action(plabel, lcd_sdcard_pause)
* MenuItem_function::draw(sel, row, plabel, lcd_sdcard_pause)
*
* EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
* MenuItem_int3::action(plabel, &feedrate_percentage, 10, 999)
* MenuItem_int3::draw(sel, row, plabel, &feedrate_percentage, 10, 999)
*/
#define _MENU_INNER_P(TYPE, USE_MULTIPLIER, PLABEL, V...) do { \
PGM_P const plabel = PLABEL; \
if (encoderLine == _thisItemNr && ui.use_click()) { \
_MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER); \
MenuItem_##TYPE::action(plabel, ##V); \
if (ui.screen_changed) return; \
} \
if (ui.should_draw()) \
MenuItem_##TYPE::draw \
(encoderLine == _thisItemNr, _lcdLineNr, plabel, ##V); \
}while(0)
#define _MENU_ITEM_P(TYPE, V...) do { \
_skipStatic = false; \
if (_menuLineNr == _thisItemNr) \
_MENU_INNER_P(TYPE, ##V); \
NEXT_ITEM(); \
}while(0)
// Indexed items set a global index value
#define _MENU_ITEM_N_P(TYPE, N, V...) do{ \
_skipStatic = false; \
if (_menuLineNr == _thisItemNr) { \
MenuItemBase::init(N); \
_MENU_INNER_P(TYPE, ##V); \
} \
NEXT_ITEM(); \
}while(0)
// STATIC_ITEM draws a styled string with no highlight.
// Parameters: label [, style [, char *value] ]
#define STATIC_ITEM_INNER_P(PLABEL, V...) do{ \
if (_skipStatic && encoderLine <= _thisItemNr) { \
ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
++encoderLine; \
} \
if (ui.should_draw()) \
MenuItem_static::draw(_lcdLineNr, PLABEL, ##V); \
} while(0)
#define STATIC_ITEM_P(PLABEL, V...) do{ \
if (_menuLineNr == _thisItemNr) \
STATIC_ITEM_INNER_P(PLABEL, ##V); \
NEXT_ITEM(); \
} while(0)
#define STATIC_ITEM_N_P(PLABEL, N, V...) do{ \
if (_menuLineNr == _thisItemNr) { \
MenuItemBase::init(N); \
STATIC_ITEM_INNER_P(PLABEL, ##V); \
} \
NEXT_ITEM(); \
}while(0)
#define STATIC_ITEM(LABEL, V...) STATIC_ITEM_P( GET_TEXT(LABEL), ##V)
#define STATIC_ITEM_N(LABEL, N, V...) STATIC_ITEM_N_P(GET_TEXT(LABEL), ##V)
#define MENU_ITEM_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, false, PLABEL, ##V)
#define MENU_ITEM(TYPE, LABEL, V...) MENU_ITEM_P(TYPE, GET_TEXT(LABEL), ##V)
#define MENU_ITEM_N_P(TYPE, N, PLABEL, V...) _MENU_ITEM_N_P(TYPE, N, false, PLABEL, ##V)
#define MENU_ITEM_N(TYPE, N, LABEL, V...) MENU_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
#define BACK_ITEM(LABEL) MENU_ITEM(back, LABEL)
#define ACTION_ITEM_P(PLABEL, ACTION) MENU_ITEM_P(function, PLABEL, ACTION)
#define ACTION_ITEM(LABEL, ACTION) ACTION_ITEM_P(GET_TEXT(LABEL), ACTION)
#define ACTION_ITEM_N_P(N, PLABEL, ACTION) MENU_ITEM_N_P(function, N, PLABEL, ACTION)
#define ACTION_ITEM_N(N, LABEL, ACTION) ACTION_ITEM_N_P(N, GET_TEXT(LABEL), ACTION)
#define GCODES_ITEM_P(PLABEL, GCODES) MENU_ITEM_P(gcode, PLABEL, GCODES)
#define GCODES_ITEM(LABEL, GCODES) GCODES_ITEM_P(GET_TEXT(LABEL), GCODES)
#define GCODES_ITEM_N_P(N, PLABEL, GCODES) MENU_ITEM_N_P(gcode, N, PLABEL, GCODES)
#define GCODES_ITEM_N(N, LABEL, GCODES) GCODES_ITEM_N_P(N, GET_TEXT(LABEL), GCODES)
#define SUBMENU_P(PLABEL, DEST) MENU_ITEM_P(submenu, PLABEL, DEST)
#define SUBMENU(LABEL, DEST) SUBMENU_P(GET_TEXT(LABEL), DEST)
#define SUBMENU_N_P(N, PLABEL, DEST) MENU_ITEM_N_P(submenu, N, PLABEL, DEST)
#define SUBMENU_N(N, LABEL, DEST) SUBMENU_N_P(N, GET_TEXT(LABEL), DEST)
#define EDIT_ITEM_P(TYPE, PLABEL, V...) MENU_ITEM_P(TYPE, PLABEL, ##V)
#define EDIT_ITEM(TYPE, LABEL, V...) EDIT_ITEM_P(TYPE, GET_TEXT(LABEL), ##V)
#define EDIT_ITEM_N_P(TYPE, N, PLABEL, V...) MENU_ITEM_N_P(TYPE, N, PLABEL, ##V)
#define EDIT_ITEM_N(TYPE, N, LABEL, V...) EDIT_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
#define EDIT_ITEM_FAST_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, true, PLABEL, ##V)
#define EDIT_ITEM_FAST(TYPE, LABEL, V...) EDIT_ITEM_FAST_P(TYPE, GET_TEXT(LABEL), ##V)
#define EDIT_ITEM_FAST_N_P(TYPE, N, PLABEL, V...) _MENU_ITEM_N_P(TYPE, N, true, PLABEL, ##V)
#define EDIT_ITEM_FAST_N(TYPE, N, LABEL, V...) EDIT_ITEM_FAST_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
#define _CONFIRM_ITEM_INNER_P(PLABEL, V...) do { \
if (encoderLine == _thisItemNr && ui.use_click()) { \
ui.goto_screen([]{MenuItem_confirm::select_screen(V);}); \
return; \
} \
if (ui.should_draw()) MenuItem_confirm::draw \
(encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ##V); \
}while(0)
#define _CONFIRM_ITEM_P(PLABEL, V...) do { \
_skipStatic = false; \
if (_menuLineNr == _thisItemNr) \
_CONFIRM_ITEM_INNER_P(PLABEL, ##V); \
NEXT_ITEM(); \
}while(0)
// Indexed items set a global index value
#define _CONFIRM_ITEM_N_P(N, V...) do{ \
_skipStatic = false; \
if (_menuLineNr == _thisItemNr) { \
MenuItemBase::init(N); \
_CONFIRM_ITEM_INNER_P(TYPE, ##V); \
} \
NEXT_ITEM(); \
}while(0)
#define CONFIRM_ITEM_P(PLABEL,A,B,V...) _CONFIRM_ITEM_P(PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
#define CONFIRM_ITEM(LABEL, V...) CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V)
#define YESNO_ITEM_P(PLABEL, V...) _CONFIRM_ITEM_P(PLABEL, ##V)
#define YESNO_ITEM(LABEL, V...) YESNO_ITEM_P(GET_TEXT(LABEL), ##V)
#define CONFIRM_ITEM_N_P(N,PLABEL,A,B,V...) _CONFIRM_ITEM_N_P(N, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
#define CONFIRM_ITEM_N(N,LABEL, V...) CONFIRM_ITEM_N_P(N, GET_TEXT(LABEL), ##V)
#define YESNO_ITEM_N_P(N,PLABEL, V...) _CONFIRM_ITEM_N_P(N, PLABEL, ##V)
#define YESNO_ITEM_N(N,LABEL, V...) YESNO_ITEM_N_P(N, GET_TEXT(LABEL), ##V)
////////////////////////////////////////////
/////////////// Menu Screens ///////////////
////////////////////////////////////////////
@@ -525,15 +203,6 @@ void menu_move();
void menu_media();
#endif
// First Fan Speed title in "Tune" and "Control>Temperature" menus
#if FAN_COUNT > 0 && HAS_FAN0
#if FAN_COUNT > 1
#define FAN_SPEED_1_SUFFIX " 1"
#else
#define FAN_SPEED_1_SUFFIX ""
#endif
#endif
////////////////////////////////////////////
//////// Menu Item Helper Functions ////////
////////////////////////////////////////////
@@ -544,20 +213,11 @@ void _lcd_draw_homing();
#define HAS_LINE_TO_Z ANY(DELTA, PROBE_MANUALLY, MESH_BED_LEVELING, LEVEL_BED_CORNERS)
#if HAS_LINE_TO_Z
void line_to_z(const float &z);
void line_to_z(const_float_t z);
#endif
#if ANY(AUTO_BED_LEVELING_UBL, PID_AUTOTUNE_MENU, ADVANCED_PAUSE_FEATURE)
void lcd_enqueue_one_now(const char * const cmd);
void lcd_enqueue_one_now_P(PGM_P const cmd);
#endif
#if HAS_GRAPHICAL_LCD && EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY)
void _lcd_zoffset_overlay_gfx(const float zvalue);
#endif
#if ENABLED(LEVEL_BED_CORNERS)
void _lcd_level_bed_corners();
#if ENABLED(PROBE_OFFSET_WIZARD)
void goto_probe_offset_wizard();
#endif
#if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))
@@ -570,13 +230,24 @@ void _lcd_draw_homing();
#else
void lcd_babystep_z();
#endif
#if ENABLED(BABYSTEP_MILLIMETER_UNITS)
#define BABYSTEP_SIZE_X int32_t((BABYSTEP_MULTIPLICATOR_XY) * planner.settings.axis_steps_per_mm[X_AXIS])
#define BABYSTEP_SIZE_Y int32_t((BABYSTEP_MULTIPLICATOR_XY) * planner.settings.axis_steps_per_mm[Y_AXIS])
#define BABYSTEP_SIZE_Z int32_t((BABYSTEP_MULTIPLICATOR_Z) * planner.settings.axis_steps_per_mm[Z_AXIS])
#else
#define BABYSTEP_SIZE_X BABYSTEP_MULTIPLICATOR_XY
#define BABYSTEP_SIZE_Y BABYSTEP_MULTIPLICATOR_XY
#define BABYSTEP_SIZE_Z BABYSTEP_MULTIPLICATOR_Z
#endif
#endif
#if ENABLED(EEPROM_SETTINGS)
void lcd_store_settings();
void lcd_load_settings();
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
void touch_screen_calibration();
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
void menu_job_recovery();
#endif
extern uint8_t screen_history_depth;
inline void clear_menu_history() { screen_history_depth = 0; }
#define STICKY_SCREEN(S) []{ ui.defer_status_screen(); ui.goto_screen(S); }

12
Marlin/src/lcd/menu/menu_addon.h Executable file → Normal file
View File

@@ -16,18 +16,18 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../lcdprint.h"
#if HAS_GRAPHICAL_LCD
#include "../dogm/ultralcd_DOGM.h"
#endif
#define MENU_ITEM_ADDON_START(X) do{ \
#define _MENU_ITEM_ADDON_START(N,X) do{ \
if (ui.should_draw() && _menuLineNr == _thisItemNr - 1) { \
SETCURSOR(X, _lcdLineNr)
N(X)
#define MENU_ITEM_ADDON_START(X) _MENU_ITEM_ADDON_START(SETCURSOR_X, X)
#define MENU_ITEM_ADDON_START_RJ(X) _MENU_ITEM_ADDON_START(SETCURSOR_X_RJ, X)
#define MENU_ITEM_ADDON_END() } }while(0)

409
Marlin/src/lcd/menu/menu_advanced.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -28,7 +28,7 @@
#if HAS_LCD_MENU
#include "menu.h"
#include "menu_item.h"
#include "../../module/planner.h"
#if DISABLED(NO_VOLUMETRICS)
@@ -43,34 +43,33 @@
#include "../../module/temperature.h"
#endif
#if ENABLED(FILAMENT_RUNOUT_SENSOR) && FILAMENT_RUNOUT_DISTANCE_MM
#if HAS_FILAMENT_RUNOUT_DISTANCE
#include "../../feature/runout.h"
float lcd_runout_distance_mm;
#endif
#if ENABLED(EEPROM_SETTINGS) && DISABLED(SLIM_LCD_MENUS)
#include "../../module/configuration_store.h"
#if ENABLED(SD_FIRMWARE_UPDATE)
#include "../../module/settings.h"
#endif
#if ENABLED(PASSWORD_FEATURE)
#include "../../feature/password/password.h"
#endif
void menu_tmc();
void menu_backlash();
void menu_cancelobject();
#if ENABLED(DAC_STEPPER_CURRENT)
#if HAS_MOTOR_CURRENT_DAC
#include "../../feature/dac/stepper_dac.h"
void menu_dac() {
static xyze_uint8_t driverPercent;
LOOP_XYZE(i) driverPercent[i] = dac_current_get_percent((AxisEnum)i);
LOOP_LOGICAL_AXES(i) driverPercent[i] = stepper_dac.get_current_percent((AxisEnum)i);
START_MENU();
BACK_ITEM(MSG_ADVANCED_SETTINGS);
#define EDIT_DAC_PERCENT(A) EDIT_ITEM(uint8, MSG_DAC_PERCENT_##A, &driverPercent[_AXIS(A)], 0, 100, []{ dac_current_set_percents(driverPercent); })
EDIT_DAC_PERCENT(X);
EDIT_DAC_PERCENT(Y);
EDIT_DAC_PERCENT(Z);
EDIT_DAC_PERCENT(E);
ACTION_ITEM(MSG_DAC_EEPROM_WRITE, dac_commit_eeprom);
#define EDIT_DAC_PERCENT(A) EDIT_ITEM(uint8, MSG_DAC_PERCENT_##A, &driverPercent[_AXIS(A)], 0, 100, []{ stepper_dac.set_current_percents(driverPercent); })
LOGICAL_AXIS_CODE(EDIT_DAC_PERCENT(E), EDIT_DAC_PERCENT(A), EDIT_DAC_PERCENT(B), EDIT_DAC_PERCENT(C), EDIT_DAC_PERCENT(I), EDIT_DAC_PERCENT(J), EDIT_DAC_PERCENT(K));
ACTION_ITEM(MSG_DAC_EEPROM_WRITE, stepper_dac.commit_eeprom);
END_MENU();
}
@@ -98,10 +97,6 @@ void menu_cancelobject();
#endif
#if ENABLED(SD_FIRMWARE_UPDATE)
#include "../../module/configuration_store.h"
#endif
#if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE)
//
// Advanced Settings > Filament
@@ -112,19 +107,27 @@ void menu_cancelobject();
#if ENABLED(LIN_ADVANCE)
#if EXTRUDERS == 1
EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
#elif EXTRUDERS > 1
EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10);
#elif HAS_MULTI_EXTRUDER
LOOP_L_N(n, EXTRUDERS)
EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 10);
#endif
#endif
#if DISABLED(NO_VOLUMETRICS)
EDIT_ITEM(bool, MSG_VOLUMETRIC_ENABLED, &parser.volumetric_enabled, planner.calculate_volumetric_multipliers);
#if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT)
EDIT_ITEM_FAST(float42_52, MSG_VOLUMETRIC_LIMIT, &planner.volumetric_extruder_limit[active_extruder], 0.0f, 20.0f, planner.calculate_volumetric_extruder_limits);
#if HAS_MULTI_EXTRUDER
LOOP_L_N(n, EXTRUDERS)
EDIT_ITEM_FAST_N(float42_52, n, MSG_VOLUMETRIC_LIMIT_E, &planner.volumetric_extruder_limit[n], 0.0f, 20.00f, planner.calculate_volumetric_extruder_limits);
#endif
#endif
if (parser.volumetric_enabled) {
EDIT_ITEM_FAST(float43, MSG_FILAMENT_DIAM, &planner.filament_size[active_extruder], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
#if EXTRUDERS > 1
#if HAS_MULTI_EXTRUDER
LOOP_L_N(n, EXTRUDERS)
EDIT_ITEM_FAST_N(float43, n, MSG_FILAMENT_DIAM_E, &planner.filament_size[n], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
#endif
@@ -132,31 +135,26 @@ void menu_cancelobject();
#endif
#if ENABLED(ADVANCED_PAUSE_FEATURE)
constexpr float extrude_maxlength =
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
EXTRUDE_MAXLENGTH
#else
999
#endif
;
constexpr float extrude_maxlength = TERN(PREVENT_LENGTHY_EXTRUDE, EXTRUDE_MAXLENGTH, 999);
EDIT_ITEM_FAST(float3, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength);
#if EXTRUDERS > 1
EDIT_ITEM_FAST(float4, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength);
#if HAS_MULTI_EXTRUDER
LOOP_L_N(n, EXTRUDERS)
EDIT_ITEM_FAST_N(float3, n, MSG_FILAMENTUNLOAD_E, &fc_settings[n].unload_length, 0, extrude_maxlength);
EDIT_ITEM_FAST_N(float4, n, MSG_FILAMENTUNLOAD_E, &fc_settings[n].unload_length, 0, extrude_maxlength);
#endif
EDIT_ITEM_FAST(float3, MSG_FILAMENT_LOAD, &fc_settings[active_extruder].load_length, 0, extrude_maxlength);
#if EXTRUDERS > 1
EDIT_ITEM_FAST(float4, MSG_FILAMENT_LOAD, &fc_settings[active_extruder].load_length, 0, extrude_maxlength);
#if HAS_MULTI_EXTRUDER
LOOP_L_N(n, EXTRUDERS)
EDIT_ITEM_FAST_N(float3, n, MSG_FILAMENTLOAD_E, &fc_settings[n].load_length, 0, extrude_maxlength);
EDIT_ITEM_FAST_N(float4, n, MSG_FILAMENTLOAD_E, &fc_settings[n].load_length, 0, extrude_maxlength);
#endif
#endif
#if ENABLED(FILAMENT_RUNOUT_SENSOR) && FILAMENT_RUNOUT_DISTANCE_MM
EDIT_ITEM(float3, MSG_RUNOUT_DISTANCE_MM, &lcd_runout_distance_mm, 1, 30, []{
runout.set_runout_distance(lcd_runout_distance_mm);
});
#if HAS_FILAMENT_RUNOUT_DISTANCE
editable.decimal = runout.runout_distance();
EDIT_ITEM_FAST(float3, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999,
[]{ runout.set_runout_distance(editable.decimal); }, true
);
#endif
END_MENU();
@@ -171,25 +169,32 @@ void menu_cancelobject();
#if ENABLED(PID_AUTOTUNE_MENU)
#if ENABLED(PIDTEMP)
int16_t autotune_temp[HOTENDS] = ARRAY_BY_HOTENDS1(150);
int16_t autotune_temp[HOTENDS] = ARRAY_BY_HOTENDS1(PREHEAT_1_TEMP_HOTEND);
#endif
#if ENABLED(PIDTEMPBED)
int16_t autotune_temp_bed = 70;
int16_t autotune_temp_bed = PREHEAT_1_TEMP_BED;
#endif
#if ENABLED(PIDTEMPCHAMBER)
int16_t autotune_temp_chamber = PREHEAT_1_TEMP_CHAMBER;
#endif
void _lcd_autotune(const int16_t e) {
#include "../../gcode/queue.h"
void _lcd_autotune(const heater_id_t hid) {
char cmd[30];
sprintf_P(cmd, PSTR("M303 U1 E%i S%i"), e,
#if HAS_PID_FOR_BOTH
e < 0 ? autotune_temp_bed : autotune_temp[e]
#elif ENABLED(PIDTEMPBED)
autotune_temp_bed
#else
autotune_temp[e]
int16_t tune_temp;
switch (hid) {
#if ENABLED(PIDTEMPBED)
case H_BED: tune_temp = autotune_temp_bed; break;
#endif
);
lcd_enqueue_one_now(cmd);
#if ENABLED(PIDTEMPCHAMBER)
case H_CHAMBER: tune_temp = autotune_temp_chamber; break;
#endif
default: tune_temp = autotune_temp[hid]; break;
}
sprintf_P(cmd, PSTR("M303 U1 E%i S%i"), hid, tune_temp);
queue.inject(cmd);
ui.return_to_status();
}
#endif // PID_AUTOTUNE_MENU
@@ -201,16 +206,12 @@ void menu_cancelobject();
// Helpers for editing PID Ki & Kd values
// grab the PID value out of the temp variable; scale it; then update the PID driver
void copy_and_scalePID_i(int16_t e) {
#if DISABLED(PID_PARAMS_PER_HOTEND) || HOTENDS == 1
UNUSED(e);
#endif
UNUSED(e);
PID_PARAM(Ki, e) = scalePID_i(raw_Ki);
thermalManager.updatePID();
}
void copy_and_scalePID_d(int16_t e) {
#if DISABLED(PID_PARAMS_PER_HOTEND) || HOTENDS == 1
UNUSED(e);
#endif
UNUSED(e);
PID_PARAM(Kd, e) = scalePID_d(raw_Kd);
thermalManager.updatePID();
}
@@ -228,19 +229,21 @@ void menu_cancelobject();
#if ENABLED(PID_AUTOTUNE_MENU)
#define DEFINE_PIDTEMP_FUNCS(N) \
_DEFINE_PIDTEMP_BASE_FUNCS(N); \
void lcd_autotune_callback_E##N() { _lcd_autotune(N); }
void lcd_autotune_callback_E##N() { _lcd_autotune(heater_id_t(N)); }
#else
#define DEFINE_PIDTEMP_FUNCS(N) _DEFINE_PIDTEMP_BASE_FUNCS(N);
#endif
#if HOTENDS
#if HAS_HOTEND
DEFINE_PIDTEMP_FUNCS(0);
#if HOTENDS > 1 && ENABLED(PID_PARAMS_PER_HOTEND)
#if ENABLED(PID_PARAMS_PER_HOTEND)
REPEAT_S(1, HOTENDS, DEFINE_PIDTEMP_FUNCS)
#endif
#endif
#define SHOW_MENU_ADVANCED_TEMPERATURE ((ENABLED(AUTOTEMP) && HAS_TEMP_HOTEND) || EITHER(PID_AUTOTUNE_MENU, PID_EDIT_MENU))
#if BOTH(AUTOTEMP, HAS_TEMP_HOTEND) || EITHER(PID_AUTOTUNE_MENU, PID_EDIT_MENU)
#define SHOW_MENU_ADVANCED_TEMPERATURE 1
#endif
//
// Advanced Settings > Temperature
@@ -253,10 +256,10 @@ void menu_cancelobject();
//
// Autotemp, Min, Max, Fact
//
#if ENABLED(AUTOTEMP) && HAS_TEMP_HOTEND
#if BOTH(AUTOTEMP, HAS_TEMP_HOTEND)
EDIT_ITEM(bool, MSG_AUTOTEMP, &planner.autotemp_enabled);
EDIT_ITEM(float3, MSG_MIN, &planner.autotemp_min, 0, float(HEATER_0_MAXTEMP) - 15);
EDIT_ITEM(float3, MSG_MAX, &planner.autotemp_max, 0, float(HEATER_0_MAXTEMP) - 15);
EDIT_ITEM(int3, MSG_MIN, &planner.autotemp_min, 0, thermalManager.hotend_max_target(0));
EDIT_ITEM(int3, MSG_MAX, &planner.autotemp_max, 0, thermalManager.hotend_max_target(0));
EDIT_ITEM(float42_52, MSG_FACTOR, &planner.autotemp_factor, 0, 10);
#endif
@@ -270,46 +273,71 @@ void menu_cancelobject();
//
#if ENABLED(PID_EDIT_MENU)
#define __PID_BASE_MENU_ITEMS(N) \
#define _PID_EDIT_ITEMS_TMPL(N,T) \
raw_Ki = unscalePID_i(T.pid.Ki); \
raw_Kd = unscalePID_d(T.pid.Kd); \
EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_P_E, &T.pid.Kp, 1, 9990); \
EDIT_ITEM_FAST_N(float52sign, N, MSG_PID_I_E, &raw_Ki, 0.01f, 9990, []{ copy_and_scalePID_i(N); }); \
EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_D_E, &raw_Kd, 1, 9990, []{ copy_and_scalePID_d(N); })
#define __PID_HOTEND_MENU_ITEMS(N) \
raw_Ki = unscalePID_i(PID_PARAM(Ki, N)); \
raw_Kd = unscalePID_d(PID_PARAM(Kd, N)); \
EDIT_ITEM_N(float52sign, N, MSG_PID_P_E, &PID_PARAM(Kp, N), 1, 9990); \
EDIT_ITEM_N(float52sign, N, MSG_PID_I_E, &raw_Ki, 0.01f, 9990, []{ copy_and_scalePID_i(N); }); \
EDIT_ITEM_N(float52sign, N, MSG_PID_D_E, &raw_Kd, 1, 9990, []{ copy_and_scalePID_d(N); })
EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_P_E, &PID_PARAM(Kp, N), 1, 9990); \
EDIT_ITEM_FAST_N(float52sign, N, MSG_PID_I_E, &raw_Ki, 0.01f, 9990, []{ copy_and_scalePID_i(N); }); \
EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_D_E, &raw_Kd, 1, 9990, []{ copy_and_scalePID_d(N); })
#if ENABLED(PID_EXTRUSION_SCALING)
#define _PID_BASE_MENU_ITEMS(N) \
__PID_BASE_MENU_ITEMS(N); \
EDIT_ITEM_N(float3, N, MSG_PID_C_E, &PID_PARAM(Kc, N), 1, 9990)
#define _PID_HOTEND_MENU_ITEMS(N) \
__PID_HOTEND_MENU_ITEMS(N); \
EDIT_ITEM_N(float4, N, MSG_PID_C_E, &PID_PARAM(Kc, N), 1, 9990)
#else
#define _PID_BASE_MENU_ITEMS(N) __PID_BASE_MENU_ITEMS(N)
#define _PID_HOTEND_MENU_ITEMS(N) __PID_HOTEND_MENU_ITEMS(N)
#endif
#if ENABLED(PID_FAN_SCALING)
#define _PID_EDIT_MENU_ITEMS(N) \
_PID_BASE_MENU_ITEMS(N); \
EDIT_ITEM_N(float3, N, MSG_PID_F_E, &PID_PARAM(Kf, N), 1, 9990)
#define _HOTEND_PID_EDIT_MENU_ITEMS(N) \
_PID_HOTEND_MENU_ITEMS(N); \
EDIT_ITEM_N(float4, N, MSG_PID_F_E, &PID_PARAM(Kf, N), 1, 9990)
#else
#define _PID_EDIT_MENU_ITEMS(N) _PID_BASE_MENU_ITEMS(N)
#define _HOTEND_PID_EDIT_MENU_ITEMS(N) _PID_HOTEND_MENU_ITEMS(N)
#endif
#else
#define _PID_EDIT_MENU_ITEMS(N) NOOP
#define _HOTEND_PID_EDIT_MENU_ITEMS(N) NOOP
#endif
#if ENABLED(PID_AUTOTUNE_MENU)
#define PID_EDIT_MENU_ITEMS(N) \
_PID_EDIT_MENU_ITEMS(N); \
EDIT_ITEM_FAST_N(int3, N, MSG_PID_AUTOTUNE_E, &autotune_temp[N], 150, heater_maxtemp[N] - 15, []{ _lcd_autotune(MenuItemBase::itemIndex); });
#define HOTEND_PID_EDIT_MENU_ITEMS(N) \
_HOTEND_PID_EDIT_MENU_ITEMS(N); \
EDIT_ITEM_FAST_N(int3, N, MSG_PID_AUTOTUNE_E, &autotune_temp[N], 150, thermalManager.hotend_max_target(N), []{ _lcd_autotune(heater_id_t(MenuItemBase::itemIndex)); });
#else
#define PID_EDIT_MENU_ITEMS(N) _PID_EDIT_MENU_ITEMS(N);
#define HOTEND_PID_EDIT_MENU_ITEMS(N) _HOTEND_PID_EDIT_MENU_ITEMS(N);
#endif
PID_EDIT_MENU_ITEMS(0);
#if HOTENDS > 1 && ENABLED(PID_PARAMS_PER_HOTEND)
REPEAT_S(1, HOTENDS, PID_EDIT_MENU_ITEMS)
HOTEND_PID_EDIT_MENU_ITEMS(0);
#if ENABLED(PID_PARAMS_PER_HOTEND)
REPEAT_S(1, HOTENDS, HOTEND_PID_EDIT_MENU_ITEMS)
#endif
#if ENABLED(PIDTEMPBED)
#if ENABLED(PID_EDIT_MENU)
_PID_EDIT_ITEMS_TMPL(H_BED, thermalManager.temp_bed);
#endif
#if ENABLED(PID_AUTOTUNE_MENU)
EDIT_ITEM_FAST_N(int3, H_BED, MSG_PID_AUTOTUNE_E, &autotune_temp_bed, PREHEAT_1_TEMP_BED, BED_MAX_TARGET, []{ _lcd_autotune(H_BED); });
#endif
#endif
#if ENABLED(PIDTEMPCHAMBER)
#if ENABLED(PID_EDIT_MENU)
_PID_EDIT_ITEMS_TMPL(H_CHAMBER, thermalManager.temp_chamber);
#endif
#if ENABLED(PID_AUTOTUNE_MENU)
EDIT_ITEM_FAST_N(int3, H_CHAMBER, MSG_PID_AUTOTUNE_E, &autotune_temp_chamber, PREHEAT_1_TEMP_CHAMBER, CHAMBER_MAX_TARGET, []{ _lcd_autotune(H_CHAMBER); });
#endif
#endif
END_MENU();
@@ -319,21 +347,8 @@ void menu_cancelobject();
#if DISABLED(SLIM_LCD_MENUS)
#if ENABLED(DISTINCT_E_FACTORS)
inline void _reset_e_acceleration_rate(const uint8_t e) { if (e == active_extruder) planner.reset_acceleration_rates(); }
inline void _planner_refresh_e_positioning(const uint8_t e) {
if (e == active_extruder)
planner.refresh_positioning();
else
planner.steps_to_mm[E_AXIS_N(e)] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS_N(e)];
}
#endif
// M203 / M205 Velocity options
void menu_advanced_velocity() {
START_MENU();
BACK_ITEM(MSG_ADVANCED_SETTINGS);
// M203 Max Feedrate
constexpr xyze_feedrate_t max_fr_edit =
#ifdef MAX_FEEDRATE_EDIT_VALUES
@@ -341,7 +356,7 @@ void menu_cancelobject();
#elif ENABLED(LIMITED_MAX_FR_EDITING)
DEFAULT_MAX_FEEDRATE
#else
{ 999, 999, 999, 999 }
LOGICAL_AXIS_ARRAY(9999, 9999, 9999, 9999, 9999, 9999, 9999)
#endif
;
#if ENABLED(LIMITED_MAX_FR_EDITING) && !defined(MAX_FEEDRATE_EDIT_VALUES)
@@ -349,42 +364,33 @@ void menu_cancelobject();
#else
const xyze_feedrate_t &max_fr_edit_scaled = max_fr_edit;
#endif
#define EDIT_VMAX(N) EDIT_ITEM_FAST(float3, MSG_VMAX_##N, &planner.settings.max_feedrate_mm_s[_AXIS(N)], 1, max_fr_edit_scaled[_AXIS(N)])
EDIT_VMAX(A);
EDIT_VMAX(B);
EDIT_VMAX(C);
START_MENU();
BACK_ITEM(MSG_ADVANCED_SETTINGS);
#define EDIT_VMAX(N) EDIT_ITEM_FAST(float5, MSG_VMAX_##N, &planner.settings.max_feedrate_mm_s[_AXIS(N)], 1, max_fr_edit_scaled[_AXIS(N)])
LINEAR_AXIS_CODE(EDIT_VMAX(A), EDIT_VMAX(B), EDIT_VMAX(C), EDIT_VMAX(I), EDIT_VMAX(J), EDIT_VMAX(K));
#if E_STEPPERS
EDIT_ITEM_FAST(float3, MSG_VMAX_E, &planner.settings.max_feedrate_mm_s[E_AXIS_N(active_extruder)], 1, max_fr_edit_scaled.e);
EDIT_ITEM_FAST(float5, MSG_VMAX_E, &planner.settings.max_feedrate_mm_s[E_AXIS_N(active_extruder)], 1, max_fr_edit_scaled.e);
#endif
#if ENABLED(DISTINCT_E_FACTORS)
LOOP_L_N(n, E_STEPPERS)
EDIT_ITEM_FAST_N(float3, n, MSG_VMAX_EN, &planner.settings.max_feedrate_mm_s[E_AXIS_N(n)], 1, max_fr_edit_scaled.e);
EDIT_ITEM_FAST_N(float5, n, MSG_VMAX_EN, &planner.settings.max_feedrate_mm_s[E_AXIS_N(n)], 1, max_fr_edit_scaled.e);
#endif
// M205 S Min Feedrate
EDIT_ITEM_FAST(float3, MSG_VMIN, &planner.settings.min_feedrate_mm_s, 0, 999);
EDIT_ITEM_FAST(float5, MSG_VMIN, &planner.settings.min_feedrate_mm_s, 0, 9999);
// M205 T Min Travel Feedrate
EDIT_ITEM_FAST(float3, MSG_VTRAV_MIN, &planner.settings.min_travel_feedrate_mm_s, 0, 999);
EDIT_ITEM_FAST(float5, MSG_VTRAV_MIN, &planner.settings.min_travel_feedrate_mm_s, 0, 9999);
END_MENU();
}
// M201 / M204 Accelerations
void menu_advanced_acceleration() {
START_MENU();
BACK_ITEM(MSG_ADVANCED_SETTINGS);
const float max_accel = _MAX(planner.settings.max_acceleration_mm_per_s2[A_AXIS], planner.settings.max_acceleration_mm_per_s2[B_AXIS], planner.settings.max_acceleration_mm_per_s2[C_AXIS]);
// M204 P Acceleration
EDIT_ITEM_FAST(float5_25, MSG_ACC, &planner.settings.acceleration, 25, max_accel);
// M204 R Retract Acceleration
EDIT_ITEM_FAST(float5, MSG_A_RETRACT, &planner.settings.retract_acceleration, 100, planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)]);
// M204 T Travel Acceleration
EDIT_ITEM_FAST(float5_25, MSG_A_TRAVEL, &planner.settings.travel_acceleration, 25, max_accel);
// M201 settings
constexpr xyze_ulong_t max_accel_edit =
@@ -393,7 +399,7 @@ void menu_cancelobject();
#elif ENABLED(LIMITED_MAX_ACCEL_EDITING)
DEFAULT_MAX_ACCELERATION
#else
{ 99000, 99000, 99000, 99000 }
LOGICAL_AXIS_ARRAY(99000, 99000, 99000, 99000, 99000, 99000, 99000)
#endif
;
#if ENABLED(LIMITED_MAX_ACCEL_EDITING) && !defined(MAX_ACCEL_EDIT_VALUES)
@@ -402,59 +408,90 @@ void menu_cancelobject();
const xyze_ulong_t &max_accel_edit_scaled = max_accel_edit;
#endif
START_MENU();
BACK_ITEM(MSG_ADVANCED_SETTINGS);
// M204 P Acceleration
EDIT_ITEM_FAST(float5_25, MSG_ACC, &planner.settings.acceleration, 25, max_accel);
#if HAS_EXTRUDERS
// M204 R Retract Acceleration
EDIT_ITEM_FAST(float5, MSG_A_RETRACT, &planner.settings.retract_acceleration, 100, planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)]);
#endif
// M204 T Travel Acceleration
EDIT_ITEM_FAST(float5_25, MSG_A_TRAVEL, &planner.settings.travel_acceleration, 25, max_accel);
#define EDIT_AMAX(Q,L) EDIT_ITEM_FAST(long5_25, MSG_AMAX_##Q, &planner.settings.max_acceleration_mm_per_s2[_AXIS(Q)], L, max_accel_edit_scaled[_AXIS(Q)], []{ planner.reset_acceleration_rates(); })
EDIT_AMAX(A,100);
EDIT_AMAX(B,100);
EDIT_AMAX(C, 10);
LINEAR_AXIS_CODE(
EDIT_AMAX(A, 100), EDIT_AMAX(B, 100), EDIT_AMAX(C, 10),
EDIT_AMAX(I, 10), EDIT_AMAX(J, 10), EDIT_AMAX(K, 10)
);
#if ENABLED(DISTINCT_E_FACTORS)
EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); });
LOOP_L_N(n, E_STEPPERS)
EDIT_ITEM_FAST_N(long5_25, n, MSG_AMAX_EN, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(n)], 100, max_accel_edit_scaled.e, []{ _reset_e_acceleration_rate(MenuItemBase::itemIndex); });
EDIT_ITEM_FAST_N(long5_25, n, MSG_AMAX_EN, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(n)], 100, max_accel_edit_scaled.e, []{
if (MenuItemBase::itemIndex == active_extruder)
planner.reset_acceleration_rates();
});
#elif E_STEPPERS
EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); });
#endif
#ifdef XY_FREQUENCY_LIMIT
EDIT_ITEM(int8, MSG_XY_FREQUENCY_LIMIT, &planner.xy_freq_limit_hz, 0, 100, planner.refresh_frequency_limit, true);
editable.uint8 = uint8_t(LROUND(planner.xy_freq_min_speed_factor * 255)); // percent to u8
EDIT_ITEM(percent, MSG_XY_FREQUENCY_FEEDRATE, &editable.uint8, 3, 255, []{ planner.set_min_speed_factor_u8(editable.uint8); }, true);
#endif
END_MENU();
}
// M205 Jerk
void menu_advanced_jerk() {
START_MENU();
BACK_ITEM(MSG_ADVANCED_SETTINGS);
#if HAS_CLASSIC_JERK
#if DISABLED(CLASSIC_JERK)
#if ENABLED(LIN_ADVANCE)
EDIT_ITEM(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.001f, 0.3f, planner.recalculate_max_e_jerk);
#else
EDIT_ITEM(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.001f, 0.5f);
void menu_advanced_jerk() {
START_MENU();
BACK_ITEM(MSG_ADVANCED_SETTINGS);
#if HAS_JUNCTION_DEVIATION
#if ENABLED(LIN_ADVANCE)
EDIT_ITEM(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.001f, 0.3f, planner.recalculate_max_e_jerk);
#else
EDIT_ITEM(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.001f, 0.5f);
#endif
#endif
#endif
#if HAS_CLASSIC_JERK
constexpr xyze_float_t max_jerk_edit =
#ifdef MAX_ACCEL_EDIT_VALUES
#ifdef MAX_JERK_EDIT_VALUES
MAX_JERK_EDIT_VALUES
#elif ENABLED(LIMITED_JERK_EDITING)
{ (DEFAULT_XJERK) * 2, (DEFAULT_YJERK) * 2, (DEFAULT_ZJERK) * 2, (DEFAULT_EJERK) * 2 }
{ LOGICAL_AXIS_LIST((DEFAULT_EJERK) * 2,
(DEFAULT_XJERK) * 2, (DEFAULT_YJERK) * 2, (DEFAULT_ZJERK) * 2,
(DEFAULT_IJERK) * 2, (DEFAULT_JJERK) * 2, (DEFAULT_KJERK) * 2) }
#else
{ 990, 990, 990, 990 }
{ LOGICAL_AXIS_LIST(990, 990, 990, 990, 990, 990, 990) }
#endif
;
#define EDIT_JERK(N) EDIT_ITEM_FAST(float3, MSG_V##N##_JERK, &planner.max_jerk[_AXIS(N)], 1, max_jerk_edit[_AXIS(N)])
EDIT_JERK(A);
EDIT_JERK(B);
#if ENABLED(DELTA)
EDIT_JERK(C);
#define EDIT_JERK_C() EDIT_JERK(C)
#else
EDIT_ITEM_FAST(float52sign, MSG_VC_JERK, &planner.max_jerk.c, 0.1f, max_jerk_edit.c);
#define EDIT_JERK_C() EDIT_ITEM_FAST(float52sign, MSG_VC_JERK, &planner.max_jerk.c, 0.1f, max_jerk_edit.c)
#endif
#if HAS_CLASSIC_E_JERK
LINEAR_AXIS_CODE(
EDIT_JERK(A), EDIT_JERK(B), EDIT_JERK_C(),
EDIT_JERK(I), EDIT_JERK(J), EDIT_JERK(K)
);
#if HAS_EXTRUDERS
EDIT_ITEM_FAST(float52sign, MSG_VE_JERK, &planner.max_jerk.e, 0.1f, max_jerk_edit.e);
#endif
#endif
END_MENU();
}
END_MENU();
}
#endif
// M851 - Z Probe Offsets
#if HAS_BED_PROBE
@@ -462,10 +499,15 @@ void menu_cancelobject();
START_MENU();
BACK_ITEM(MSG_ADVANCED_SETTINGS);
#if HAS_PROBE_XY_OFFSET
EDIT_ITEM(float51sign, MSG_ZPROBE_XOFFSET, &probe.offset.x, -(X_BED_SIZE), X_BED_SIZE);
EDIT_ITEM(float51sign, MSG_ZPROBE_YOFFSET, &probe.offset.y, -(Y_BED_SIZE), Y_BED_SIZE);
EDIT_ITEM(float31sign, MSG_ZPROBE_XOFFSET, &probe.offset.x, -(X_BED_SIZE), X_BED_SIZE);
EDIT_ITEM(float31sign, MSG_ZPROBE_YOFFSET, &probe.offset.y, -(Y_BED_SIZE), Y_BED_SIZE);
#endif
EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
#if ENABLED(PROBE_OFFSET_WIZARD)
SUBMENU(MSG_PROBE_WIZARD, goto_probe_offset_wizard);
#endif
END_MENU();
}
#endif
@@ -478,14 +520,20 @@ void menu_advanced_steps_per_mm() {
BACK_ITEM(MSG_ADVANCED_SETTINGS);
#define EDIT_QSTEPS(Q) EDIT_ITEM_FAST(float51, MSG_##Q##_STEPS, &planner.settings.axis_steps_per_mm[_AXIS(Q)], 5, 9999, []{ planner.refresh_positioning(); })
EDIT_QSTEPS(A);
EDIT_QSTEPS(B);
EDIT_QSTEPS(C);
LINEAR_AXIS_CODE(
EDIT_QSTEPS(A), EDIT_QSTEPS(B), EDIT_QSTEPS(C),
EDIT_QSTEPS(I), EDIT_QSTEPS(J), EDIT_QSTEPS(K)
);
#if ENABLED(DISTINCT_E_FACTORS)
EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(active_extruder)], 5, 9999, []{ planner.refresh_positioning(); });
LOOP_L_N(n, E_STEPPERS)
EDIT_ITEM_FAST_N(float51, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ _planner_refresh_e_positioning(MenuItemBase::itemIndex); });
EDIT_ITEM_FAST_N(float51, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{
const uint8_t e = MenuItemBase::itemIndex;
if (e == active_extruder)
planner.refresh_positioning();
else
planner.mm_per_step[E_AXIS_N(e)] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS_N(e)];
});
#elif E_STEPPERS
EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); });
#endif
@@ -494,9 +542,12 @@ void menu_advanced_steps_per_mm() {
}
void menu_advanced_settings() {
#if ENABLED(FILAMENT_RUNOUT_SENSOR) && FILAMENT_RUNOUT_DISTANCE_MM
lcd_runout_distance_mm = runout.runout_distance();
const bool is_busy = printer_busy();
#if ENABLED(SD_FIRMWARE_UPDATE)
bool sd_update_state = settings.sd_update_status();
#endif
START_MENU();
BACK_ITEM(MSG_CONFIGURATION);
@@ -515,29 +566,31 @@ void menu_advanced_settings() {
// M201 - Acceleration items
SUBMENU(MSG_ACCELERATION, menu_advanced_acceleration);
// M205 - Max Jerk
SUBMENU(MSG_JERK, menu_advanced_jerk);
#if HAS_CLASSIC_JERK
// M205 - Max Jerk
SUBMENU(MSG_JERK, menu_advanced_jerk);
#elif HAS_JUNCTION_DEVIATION
EDIT_ITEM(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.001f, 0.3f
OPTARG(LIN_ADVANCE, planner.recalculate_max_e_jerk)
);
#endif
// M851 - Z Probe Offsets
#if HAS_BED_PROBE
if (!printer_busy())
SUBMENU(MSG_ZPROBE_OFFSETS, menu_probe_offsets);
if (!is_busy) SUBMENU(MSG_ZPROBE_OFFSETS, menu_probe_offsets);
#endif
#endif // !SLIM_LCD_MENUS
// M92 - Steps Per mm
if (!printer_busy())
if (!is_busy)
SUBMENU(MSG_STEPS_PER_MM, menu_advanced_steps_per_mm);
#if ENABLED(BACKLASH_GCODE)
SUBMENU(MSG_BACKLASH, menu_backlash);
#endif
#if ENABLED(CANCEL_OBJECTS)
SUBMENU(MSG_CANCEL_OBJECT, []{ editable.int8 = -1; ui.goto_screen(menu_cancelobject); });
#endif
#if ENABLED(DAC_STEPPER_CURRENT)
#if HAS_MOTOR_CURRENT_DAC
SUBMENU(MSG_DRIVE_STRENGTH, menu_dac);
#endif
#if HAS_MOTOR_CURRENT_PWM
@@ -556,10 +609,10 @@ void menu_advanced_settings() {
SUBMENU(MSG_FILAMENT, menu_advanced_filament);
#elif ENABLED(LIN_ADVANCE)
#if EXTRUDERS == 1
EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
#elif EXTRUDERS > 1
EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10);
#elif HAS_MULTI_EXTRUDER
LOOP_L_N(n, E_STEPPERS)
EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 10);
#endif
#endif
@@ -569,33 +622,27 @@ void menu_advanced_settings() {
#endif
#if ENABLED(SD_FIRMWARE_UPDATE)
bool sd_update_state = settings.sd_update_status();
EDIT_ITEM(bool, MSG_MEDIA_UPDATE, &sd_update_state, []{
//
// Toggle the SD Firmware Update state in EEPROM
//
const bool new_state = !settings.sd_update_status(),
didset = settings.set_sd_update_status(new_state);
#if HAS_BUZZER
ui.completion_feedback(didset);
#endif
ui.completion_feedback(didset);
ui.return_to_status();
if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status();
});
#endif
#if ENABLED(PASSWORD_FEATURE)
SUBMENU(MSG_PASSWORD_SETTINGS, password.access_menu_password);
#endif
#if ENABLED(EEPROM_SETTINGS) && DISABLED(SLIM_LCD_MENUS)
CONFIRM_ITEM(MSG_INIT_EEPROM,
MSG_BUTTON_INIT, MSG_BUTTON_CANCEL,
[]{
const bool inited = settings.init_eeprom();
#if HAS_BUZZER
ui.completion_feedback(inited);
#endif
UNUSED(inited);
},
ui.goto_previous_screen,
GET_TEXT(MSG_INIT_EEPROM), (PGM_P)nullptr, PSTR("?")
ui.init_eeprom, nullptr,
GET_TEXT(MSG_INIT_EEPROM), (const char *)nullptr, PSTR("?")
);
#endif

32
Marlin/src/lcd/menu/menu_backlash.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -26,9 +26,9 @@
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU && ENABLED(BACKLASH_GCODE)
#if BOTH(HAS_LCD_MENU, BACKLASH_GCODE)
#include "menu.h"
#include "menu_item.h"
#include "../../feature/backlash.h"
@@ -38,10 +38,28 @@ void menu_backlash() {
EDIT_ITEM_FAST(percent, MSG_BACKLASH_CORRECTION, &backlash.correction, all_off, all_on);
#if DISABLED(CORE_BACKLASH) || ENABLED(MARKFORGED_XY)
#define _CAN_CALI AXIS_CAN_CALIBRATE
#else
#define _CAN_CALI(A) true
#endif
#define EDIT_BACKLASH_DISTANCE(N) EDIT_ITEM_FAST(float43, MSG_BACKLASH_##N, &backlash.distance_mm[_AXIS(N)], 0.0f, 9.9f);
if (AXIS_CAN_CALIBRATE(A)) EDIT_BACKLASH_DISTANCE(A);
if (AXIS_CAN_CALIBRATE(B)) EDIT_BACKLASH_DISTANCE(B);
if (AXIS_CAN_CALIBRATE(C)) EDIT_BACKLASH_DISTANCE(C);
if (_CAN_CALI(A)) EDIT_BACKLASH_DISTANCE(A);
#if HAS_Y_AXIS && _CAN_CALI(B)
EDIT_BACKLASH_DISTANCE(B);
#endif
#if HAS_Z_AXIS && _CAN_CALI(C)
EDIT_BACKLASH_DISTANCE(C);
#endif
#if LINEAR_AXES >= 4 && _CAN_CALI(I)
EDIT_BACKLASH_DISTANCE(I);
#endif
#if LINEAR_AXES >= 5 && _CAN_CALI(J)
EDIT_BACKLASH_DISTANCE(J);
#endif
#if LINEAR_AXES >= 6 && _CAN_CALI(K)
EDIT_BACKLASH_DISTANCE(K);
#endif
#ifdef BACKLASH_SMOOTHING_MM
EDIT_ITEM_FAST(float43, MSG_BACKLASH_SMOOTHING, &backlash.smoothing_mm, 0.0f, 9.9f);
@@ -50,4 +68,4 @@ void menu_backlash() {
END_MENU();
}
#endif // HAS_LCD_MENU && BACKLASH_COMPENSATION
#endif // HAS_LCD_MENU && BACKLASH_GCODE

334
Marlin/src/lcd/menu/menu_bed_corners.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -26,9 +26,9 @@
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU && ENABLED(LEVEL_BED_CORNERS)
#if BOTH(HAS_LCD_MENU, LEVEL_BED_CORNERS)
#include "menu.h"
#include "menu_item.h"
#include "../../module/motion.h"
#include "../../module/planner.h"
@@ -39,75 +39,317 @@
#ifndef LEVEL_CORNERS_Z_HOP
#define LEVEL_CORNERS_Z_HOP 4.0
#endif
#ifndef LEVEL_CORNERS_HEIGHT
#define LEVEL_CORNERS_HEIGHT 0.0
#endif
#if ENABLED(LEVEL_CORNERS_USE_PROBE)
#include "../../module/probe.h"
#include "../../module/endstops.h"
#if ENABLED(BLTOUCH)
#include "../../feature/bltouch.h"
#endif
#ifndef LEVEL_CORNERS_PROBE_TOLERANCE
#define LEVEL_CORNERS_PROBE_TOLERANCE 0.2
#endif
float last_z;
int good_points;
bool corner_probing_done, wait_for_probe;
#if HAS_MARLINUI_U8GLIB
#include "../dogm/marlinui_DOGM.h"
#endif
#define GOOD_POINTS_TO_STR(N) ui8tostr2(N)
#define LAST_Z_TO_STR(N) ftostr53_63(N) //ftostr42_52(N)
#endif
static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration.");
#if HAS_LEVELING
static bool leveling_was_active = false;
#endif
#ifndef LEVEL_CORNERS_LEVELING_ORDER
#define LEVEL_CORNERS_LEVELING_ORDER { LF, RF, LB, RB } // Default
//#define LEVEL_CORNERS_LEVELING_ORDER { LF, LB, RF } // 3 hard-coded points
//#define LEVEL_CORNERS_LEVELING_ORDER { LF, RF } // 3-Point tramming - Rear
//#define LEVEL_CORNERS_LEVELING_ORDER { LF, LB } // 3-Point tramming - Right
//#define LEVEL_CORNERS_LEVELING_ORDER { RF, RB } // 3-Point tramming - Left
//#define LEVEL_CORNERS_LEVELING_ORDER { LB, RB } // 3-Point tramming - Front
#endif
#define LF 1
#define RF 2
#define RB 3
#define LB 4
constexpr int lco[] = LEVEL_CORNERS_LEVELING_ORDER;
constexpr bool level_corners_3_points = COUNT(lco) == 2;
static_assert(level_corners_3_points || COUNT(lco) == 4, "LEVEL_CORNERS_LEVELING_ORDER must have exactly 2 or 4 corners.");
constexpr int lcodiff = ABS(lco[0] - lco[1]);
static_assert(COUNT(lco) == 4 || lcodiff == 1 || lcodiff == 3, "The first two LEVEL_CORNERS_LEVELING_ORDER corners must be on the same edge.");
constexpr int nr_edge_points = level_corners_3_points ? 3 : 4;
constexpr int available_points = nr_edge_points + ENABLED(LEVEL_CENTER_TOO);
constexpr int center_index = TERN(LEVEL_CENTER_TOO, available_points - 1, -1);
constexpr float inset_lfrb[4] = LEVEL_CORNERS_INSET_LFRB;
constexpr xy_pos_t lf { (X_MIN_BED) + inset_lfrb[0], (Y_MIN_BED) + inset_lfrb[1] },
rb { (X_MAX_BED) - inset_lfrb[2], (Y_MAX_BED) - inset_lfrb[3] };
static int8_t bed_corner;
/**
* Select next corner coordinates
*/
static void _lcd_level_bed_corners_get_next_position() {
if (level_corners_3_points) {
if (bed_corner >= available_points) bed_corner = 0; // Above max position -> move back to first corner
switch (bed_corner) {
case 0 ... 1:
// First two corners set explicitly by the configuration
current_position = lf; // Left front
switch (lco[bed_corner]) {
case RF: current_position.x = rb.x; break; // Right Front
case RB: current_position = rb; break; // Right Back
case LB: current_position.y = rb.y; break; // Left Back
}
break;
case 2:
// Determine which edge to probe for 3rd point
current_position.set(lf.x + (rb.x - lf.x) / 2, lf.y + (rb.y - lf.y) / 2);
if ((lco[0] == LB && lco[1] == RB) || (lco[0] == RB && lco[1] == LB)) current_position.y = lf.y; // Front Center
if ((lco[0] == LF && lco[1] == LB) || (lco[0] == LB && lco[1] == LF)) current_position.x = rb.x; // Center Right
if ((lco[0] == RF && lco[1] == RB) || (lco[0] == RB && lco[1] == RF)) current_position.x = lf.x; // Left Center
if ((lco[0] == LF && lco[1] == RF) || (lco[0] == RF && lco[1] == LF)) current_position.y = rb.y; // Center Back
#if DISABLED(LEVEL_CENTER_TOO) && ENABLED(LEVEL_CORNERS_USE_PROBE)
bed_corner++; // Must increment the count to ensure it resets the loop if the 3rd point is out of tolerance
#endif
break;
#if ENABLED(LEVEL_CENTER_TOO)
case 3:
current_position.set(X_CENTER, Y_CENTER);
break;
#endif
}
}
else {
// Four-Corner Bed Tramming with optional center
if (TERN0(LEVEL_CENTER_TOO, bed_corner == center_index)) {
current_position.set(X_CENTER, Y_CENTER);
TERN_(LEVEL_CORNERS_USE_PROBE, good_points--); // Decrement to allow one additional probe point
}
else {
current_position = lf; // Left front
switch (lco[bed_corner]) {
case RF: current_position.x = rb.x; break; // Right front
case RB: current_position = rb; break; // Right rear
case LB: current_position.y = rb.y; break; // Left rear
}
}
}
}
/**
* Level corners, starting in the front-left corner.
*/
static int8_t bed_corner;
static inline void _lcd_goto_next_corner() {
constexpr float lfrb[4] = LEVEL_CORNERS_INSET_LFRB;
constexpr xy_pos_t lf { (X_MIN_BED) + lfrb[0], (Y_MIN_BED) + lfrb[1] },
rb { (X_MAX_BED) - lfrb[2], (Y_MAX_BED) - lfrb[3] };
line_to_z(LEVEL_CORNERS_Z_HOP);
switch (bed_corner) {
case 0: current_position = lf; break; // copy xy
case 1: current_position.x = rb.x; break;
case 2: current_position.y = rb.y; break;
case 3: current_position.x = lf.x; break;
#if ENABLED(LEVEL_CENTER_TOO)
case 4: current_position.set(X_CENTER, Y_CENTER); break;
#endif
}
line_to_current_position(manual_feedrate_mm_s.x);
line_to_z(LEVEL_CORNERS_HEIGHT);
if (++bed_corner > (3
#if ENABLED(LEVEL_CENTER_TOO)
+ 1
#endif
)) bed_corner = 0;
}
#if ENABLED(LEVEL_CORNERS_USE_PROBE)
static inline void _lcd_level_bed_corners_homing() {
#define VALIDATE_POINT(X, Y, STR) static_assert(Probe::build_time::can_reach((X), (Y)), \
"LEVEL_CORNERS_INSET_LFRB " STR " inset is not reachable with the default NOZZLE_TO_PROBE offset and PROBING_MARGIN.")
VALIDATE_POINT(lf.x, Y_CENTER, "left"); VALIDATE_POINT(X_CENTER, lf.y, "front");
VALIDATE_POINT(rb.x, Y_CENTER, "right"); VALIDATE_POINT(X_CENTER, rb.y, "back");
#ifndef PAGE_CONTAINS
#define PAGE_CONTAINS(...) true
#endif
void _lcd_draw_probing() {
if (!ui.should_draw()) return;
TERN_(HAS_MARLINUI_U8GLIB, ui.set_font(FONT_MENU)); // Set up the font for extra info
MenuItem_static::draw(0, GET_TEXT(MSG_PROBING_POINT), SS_INVERT); // "Probing Mesh" heading
uint8_t cy = TERN(TFT_COLOR_UI, 3, LCD_HEIGHT - 1), y = LCD_ROW_Y(cy);
// Display # of good points found vs total needed
if (PAGE_CONTAINS(y - (MENU_FONT_HEIGHT), y)) {
SETCURSOR(TERN(TFT_COLOR_UI, 2, 0), cy);
lcd_put_u8str_P(GET_TEXT(MSG_BED_TRAMMING_GOOD_POINTS));
IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, cy));
lcd_put_u8str(GOOD_POINTS_TO_STR(good_points));
lcd_put_wchar('/');
lcd_put_u8str(GOOD_POINTS_TO_STR(nr_edge_points));
}
--cy;
y -= MENU_LINE_HEIGHT;
// Display the Last Z value
if (PAGE_CONTAINS(y - (MENU_FONT_HEIGHT), y)) {
SETCURSOR(TERN(TFT_COLOR_UI, 2, 0), cy);
lcd_put_u8str_P(GET_TEXT(MSG_BED_TRAMMING_LAST_Z));
IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, 2));
lcd_put_u8str(LAST_Z_TO_STR(last_z));
}
}
void _lcd_draw_raise() {
if (!ui.should_draw()) return;
MenuItem_confirm::select_screen(
GET_TEXT(MSG_BUTTON_DONE), GET_TEXT(MSG_BUTTON_SKIP)
, []{ corner_probing_done = true; wait_for_probe = false; }
, []{ wait_for_probe = false; }
, GET_TEXT(MSG_BED_TRAMMING_RAISE)
, (const char*)nullptr, NUL_STR
);
}
void _lcd_draw_level_prompt() {
if (!ui.should_draw()) return;
MenuItem_confirm::confirm_screen(
[]{ queue.inject_P(TERN(HAS_LEVELING, PSTR("G29N"), G28_STR)); ui.return_to_status(); }
, []{ ui.goto_previous_screen_no_defer(); }
, GET_TEXT(MSG_BED_TRAMMING_IN_RANGE)
, (const char*)nullptr, PSTR("?")
);
}
bool _lcd_level_bed_corners_probe(bool verify=false) {
if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed
TERN_(BLTOUCH_SLOW_MODE, bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action
do_blocking_move_to_z(last_z - LEVEL_CORNERS_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance
if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered
endstops.hit_on_purpose();
set_current_from_steppers_for_axis(Z_AXIS);
sync_plan_position();
TERN_(BLTOUCH_SLOW_MODE, bltouch.stow()); // Stow in LOW SPEED MODE on every trigger
// Triggered outside tolerance range?
if (ABS(current_position.z - last_z) > LEVEL_CORNERS_PROBE_TOLERANCE) {
last_z = current_position.z; // Above tolerance. Set a new Z for subsequent corners.
good_points = 0; // ...and start over
}
return true; // probe triggered
}
do_blocking_move_to_z(last_z); // go back to tolerance middle point before raise
return false; // probe not triggered
}
bool _lcd_level_bed_corners_raise() {
bool probe_triggered = false;
corner_probing_done = false;
wait_for_probe = true;
ui.goto_screen(_lcd_draw_raise); // show raise screen
ui.set_selection(true);
while (wait_for_probe && !probe_triggered) { // loop while waiting to bed raise and probe trigger
probe_triggered = PROBE_TRIGGERED();
if (probe_triggered) {
endstops.hit_on_purpose();
TERN_(LEVEL_CORNERS_AUDIO_FEEDBACK, ui.buzz(200, 600));
}
idle();
}
TERN_(BLTOUCH_SLOW_MODE, bltouch.stow());
ui.goto_screen(_lcd_draw_probing);
return (probe_triggered);
}
void _lcd_test_corners() {
bed_corner = TERN(LEVEL_CENTER_TOO, center_index, 0);
last_z = LEVEL_CORNERS_HEIGHT;
endstops.enable_z_probe(true);
good_points = 0;
ui.goto_screen(_lcd_draw_probing);
do {
ui.refresh(LCDVIEW_REDRAW_NOW);
_lcd_draw_probing(); // update screen with # of good points
do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, current_position.z + LEVEL_CORNERS_Z_HOP, 7)); // clearance
_lcd_level_bed_corners_get_next_position(); // Select next corner coordinates
current_position -= probe.offset_xy; // Account for probe offsets
do_blocking_move_to_xy(current_position); // Goto corner
TERN_(BLTOUCH_HS_MODE, bltouch.deploy()); // Deploy in HIGH SPEED MODE
if (!_lcd_level_bed_corners_probe()) { // Probe down to tolerance
if (_lcd_level_bed_corners_raise()) { // Prompt user to raise bed if needed
#if ENABLED(LEVEL_CORNERS_VERIFY_RAISED) // Verify
while (!_lcd_level_bed_corners_probe(true)) { // Loop while corner verified
if (!_lcd_level_bed_corners_raise()) { // Prompt user to raise bed if needed
if (corner_probing_done) return; // Done was selected
break; // Skip was selected
}
}
#endif
}
else if (corner_probing_done) // Done was selected
return;
}
if (bed_corner != center_index) good_points++; // ignore center
if (++bed_corner > 3) bed_corner = 0;
} while (good_points < nr_edge_points); // loop until all points within tolerance
#if ENABLED(BLTOUCH_HS_MODE)
// In HIGH SPEED MODE do clearance and stow at the very end
do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP);
bltouch.stow();
#endif
ui.goto_screen(_lcd_draw_level_prompt); // prompt for bed leveling
ui.set_selection(true);
}
#else // !LEVEL_CORNERS_USE_PROBE
static void _lcd_goto_next_corner() {
line_to_z(LEVEL_CORNERS_Z_HOP);
// Select next corner coordinates
_lcd_level_bed_corners_get_next_position();
line_to_current_position(manual_feedrate_mm_s.x);
line_to_z(LEVEL_CORNERS_HEIGHT);
if (++bed_corner >= available_points) bed_corner = 0;
}
#endif // !LEVEL_CORNERS_USE_PROBE
static void _lcd_level_bed_corners_homing() {
_lcd_draw_homing();
if (all_axes_homed()) {
if (!all_axes_homed()) return;
#if ENABLED(LEVEL_CORNERS_USE_PROBE)
_lcd_test_corners();
if (corner_probing_done) ui.goto_previous_screen_no_defer();
TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active));
endstops.enable_z_probe(false);
#else
bed_corner = 0;
ui.goto_screen([]{
MenuItem_confirm::select_screen(
GET_TEXT(MSG_BUTTON_NEXT), GET_TEXT(MSG_BUTTON_DONE),
_lcd_goto_next_corner,
[]{
#if HAS_LEVELING
set_bed_leveling_enabled(leveling_was_active);
#endif
ui.goto_previous_screen_no_defer();
},
GET_TEXT(
#if ENABLED(LEVEL_CENTER_TOO)
MSG_LEVEL_BED_NEXT_POINT
#else
MSG_NEXT_CORNER
#endif
), (PGM_P)nullptr, PSTR("?")
GET_TEXT(MSG_BUTTON_NEXT), GET_TEXT(MSG_BUTTON_DONE)
, _lcd_goto_next_corner
, []{
line_to_z(LEVEL_CORNERS_Z_HOP); // Raise Z off the bed when done
TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active));
ui.goto_previous_screen_no_defer();
}
, GET_TEXT(TERN(LEVEL_CENTER_TOO, MSG_LEVEL_BED_NEXT_POINT, MSG_NEXT_CORNER))
, (const char*)nullptr, PSTR("?")
);
});
ui.set_selection(true);
_lcd_goto_next_corner();
}
#endif
}
void _lcd_level_bed_corners() {
ui.defer_status_screen();
if (!all_axes_known()) {
if (!all_axes_trusted()) {
set_all_unhomed();
queue.inject_P(G28_STR);
}

76
Marlin/src/lcd/menu/menu_bed_leveling.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -28,7 +28,7 @@
#if ENABLED(LCD_BED_LEVELING)
#include "menu.h"
#include "menu_item.h"
#include "../../module/planner.h"
#include "../../feature/bedlevel/bedlevel.h"
@@ -36,6 +36,13 @@
#include "../../module/probe.h"
#endif
#if HAS_GRAPHICAL_TFT
#include "../tft/tft.h"
#if ENABLED(TOUCH_SCREEN)
#include "../tft/touch.h"
#endif
#endif
#if EITHER(PROBE_MANUALLY, MESH_BED_LEVELING)
#include "../../module/motion.h"
@@ -48,13 +55,7 @@
static uint8_t manual_probe_index;
// LCD probed points are from defaults
constexpr uint8_t total_probe_points = (
#if ENABLED(AUTO_BED_LEVELING_3POINT)
3
#elif ABL_GRID || ENABLED(MESH_BED_LEVELING)
GRID_MAX_POINTS
#endif
);
constexpr uint8_t total_probe_points = TERN(AUTO_BED_LEVELING_3POINT, 3, GRID_MAX_POINTS);
//
// Bed leveling is done. Wait for G29 to complete.
@@ -62,22 +63,20 @@
// and allow the command queue to be processed.
//
// When G29 finishes the last move:
// - Raise Z to the "manual probe height"
// - Raise Z to the "Z after probing" height
// - Don't return until done.
//
// ** This blocks the command queue! **
//
void _lcd_level_bed_done() {
if (!ui.wait_for_move) {
#if MANUAL_PROBE_HEIGHT > 0 && DISABLED(MESH_BED_LEVELING)
#if Z_AFTER_PROBING > 0 && DISABLED(MESH_BED_LEVELING)
// Display "Done" screen and wait for moves to complete
line_to_z(MANUAL_PROBE_HEIGHT);
line_to_z(Z_AFTER_PROBING);
ui.synchronize(GET_TEXT(MSG_LEVEL_BED_DONE));
#endif
ui.goto_previous_screen_no_defer();
#if HAS_BUZZER
ui.completion_feedback();
#endif
ui.completion_feedback();
}
if (ui.should_draw()) MenuItem_static::draw(LCD_HEIGHT >= 4, GET_TEXT(MSG_LEVEL_BED_DONE));
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
@@ -104,9 +103,9 @@
ui.wait_for_move = true;
ui.goto_screen(_lcd_level_bed_done);
#if ENABLED(MESH_BED_LEVELING)
queue.inject_P(PSTR("G29 S2"));
queue.inject_P(PSTR("G29S2"));
#elif ENABLED(PROBE_MANUALLY)
queue.inject_P(PSTR("G29 V1"));
queue.inject_P(PSTR("G29V1"));
#endif
}
else
@@ -156,9 +155,9 @@
// G29 Records Z, moves, and signals when it pauses
ui.wait_for_move = true;
#if ENABLED(MESH_BED_LEVELING)
queue.inject_P(manual_probe_index ? PSTR("G29 S2") : PSTR("G29 S1"));
queue.inject_P(manual_probe_index ? PSTR("G29S2") : PSTR("G29S1"));
#elif ENABLED(PROBE_MANUALLY)
queue.inject_P(PSTR("G29 V1"));
queue.inject_P(PSTR("G29V1"));
#endif
}
@@ -167,7 +166,13 @@
// Move to the first probe position
//
void _lcd_level_bed_homing_done() {
if (ui.should_draw()) MenuItem_static::draw(1, GET_TEXT(MSG_LEVEL_BED_WAITING));
if (ui.should_draw()) {
MenuItem_static::draw(1, GET_TEXT(MSG_LEVEL_BED_WAITING));
// Color UI needs a control to detect a touch
#if BOTH(TOUCH_SCREEN, HAS_GRAPHICAL_TFT)
touch.add_control(CLICK, 0, 0, TFT_WIDTH, TFT_HEIGHT);
#endif
}
if (ui.use_click()) {
manual_probe_index = 0;
_lcd_level_goto_next_point();
@@ -201,7 +206,7 @@
#if ENABLED(MESH_EDIT_MENU)
inline void refresh_planner() {
set_current_from_steppers_for_axis(ALL_AXES);
set_current_from_steppers_for_axis(ALL_AXES_ENUM);
sync_plan_position();
}
@@ -209,8 +214,8 @@
static uint8_t xind, yind; // =0
START_MENU();
BACK_ITEM(MSG_BED_LEVELING);
EDIT_ITEM(uint8, MSG_MESH_X, &xind, 0, GRID_MAX_POINTS_X - 1);
EDIT_ITEM(uint8, MSG_MESH_Y, &yind, 0, GRID_MAX_POINTS_Y - 1);
EDIT_ITEM(uint8, MSG_MESH_X, &xind, 0, (GRID_MAX_POINTS_X) - 1);
EDIT_ITEM(uint8, MSG_MESH_Y, &yind, 0, (GRID_MAX_POINTS_Y) - 1);
EDIT_ITEM_FAST(float43, MSG_MESH_EDIT_Z, &Z_VALUES(xind, yind), -(LCD_PROBE_Z_RANGE) * 0.5, (LCD_PROBE_Z_RANGE) * 0.5, refresh_planner);
END_MENU();
}
@@ -232,11 +237,12 @@
* Save Settings (Req: EEPROM_SETTINGS)
*/
void menu_bed_leveling() {
const bool is_homed = all_axes_trusted(),
is_valid = leveling_is_valid();
START_MENU();
BACK_ITEM(MSG_MOTION);
const bool is_homed = all_axes_known();
// Auto Home if not using manual probing
#if NONE(PROBE_MANUALLY, MESH_BED_LEVELING)
if (!is_homed) GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
@@ -248,16 +254,15 @@ void menu_bed_leveling() {
SUBMENU(MSG_LEVEL_BED, _lcd_level_bed_continue);
#else
// Automatic leveling can just run the G-code
GCODES_ITEM(MSG_LEVEL_BED, is_homed ? PSTR("G29") : PSTR("G28\nG29"));
GCODES_ITEM(MSG_LEVEL_BED, is_homed ? PSTR("G29") : PSTR("G29N"));
#endif
#if ENABLED(MESH_EDIT_MENU)
if (leveling_is_valid())
SUBMENU(MSG_EDIT_MESH, menu_edit_mesh);
if (is_valid) SUBMENU(MSG_EDIT_MESH, menu_edit_mesh);
#endif
// Homed and leveling is valid? Then leveling can be toggled.
if (is_homed && leveling_is_valid()) {
if (is_homed && is_valid) {
bool show_state = planner.leveling_active;
EDIT_ITEM(bool, MSG_BED_LEVELING, &show_state, _lcd_toggle_bed_leveling);
}
@@ -273,7 +278,12 @@ void menu_bed_leveling() {
// Mesh Bed Leveling Z-Offset
//
#if ENABLED(MESH_BED_LEVELING)
EDIT_ITEM(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
#if WITHIN(Z_PROBE_OFFSET_RANGE_MIN, -9, 9)
#define LCD_Z_OFFSET_TYPE float43 // Values from -9.000 to +9.000
#else
#define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99
#endif
EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_BED_Z, &mbl.z_offset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
#endif
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
@@ -283,12 +293,12 @@ void menu_bed_leveling() {
#endif
#if ENABLED(LEVEL_BED_CORNERS)
SUBMENU(MSG_LEVEL_CORNERS, _lcd_level_bed_corners);
SUBMENU(MSG_BED_TRAMMING, _lcd_level_bed_corners);
#endif
#if ENABLED(EEPROM_SETTINGS)
ACTION_ITEM(MSG_LOAD_EEPROM, lcd_load_settings);
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
ACTION_ITEM(MSG_LOAD_EEPROM, ui.load_settings);
ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
#endif
END_MENU();
}

26
Marlin/src/lcd/menu/menu_cancelobject.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -26,9 +26,9 @@
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU && ENABLED(CANCEL_OBJECTS)
#if BOTH(HAS_LCD_MENU, CANCEL_OBJECTS)
#include "menu.h"
#include "menu_item.h"
#include "menu_addon.h"
#include "../../feature/cancel_object.h"
@@ -43,10 +43,8 @@ static void lcd_cancel_object_confirm() {
};
MenuItem_confirm::confirm_screen(
[]{
cancelable.cancel_object(MenuItemBase::itemIndex - 1);
#if HAS_BUZZER
ui.completion_feedback();
#endif
cancelable.cancel_object(MenuItemBase::itemIndex);
ui.completion_feedback();
ui.goto_previous_screen();
},
ui.goto_previous_screen,
@@ -55,17 +53,19 @@ static void lcd_cancel_object_confirm() {
}
void menu_cancelobject() {
const int8_t ao = cancelable.active_object;
START_MENU();
BACK_ITEM(MSG_MAIN);
// Draw cancelable items in a loop
int8_t a = cancelable.active_object;
for (int8_t i = -1; i < cancelable.object_count; i++) {
if (i == a) continue;
int8_t j = i < 0 ? a : i;
if (!cancelable.is_canceled(j))
SUBMENU_N(j, MSG_CANCEL_OBJECT_N, lcd_cancel_object_confirm);
if (i < 0) SKIP_ITEM();
if (i == ao) continue; // Active is drawn on -1 index
const int8_t j = i < 0 ? ao : i; // Active or index item
if (!cancelable.is_canceled(j)) { // Not canceled already?
SUBMENU_N(j, MSG_CANCEL_OBJECT_N, lcd_cancel_object_confirm); // Offer the option.
if (i < 0) SKIP_ITEM(); // Extra line after active
}
}
END_MENU();

339
Marlin/src/lcd/menu/menu_configuration.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -28,9 +28,7 @@
#if HAS_LCD_MENU
#include "menu.h"
#include "../../module/configuration_store.h"
#include "menu_item.h"
#if HAS_FILAMENT_SENSOR
#include "../../feature/runout.h"
@@ -47,6 +45,10 @@
#endif
#endif
#if ENABLED(SOUND_MENU_ITEM)
#include "../../libs/buzzer.h"
#endif
#define HAS_DEBUG_MENU ENABLED(LCD_PROGRESS_BAR_TEST)
void menu_advanced_settings();
@@ -62,20 +64,24 @@ void menu_advanced_settings();
static int8_t bar_percent = 0;
if (ui.use_click()) {
ui.goto_previous_screen();
ui.set_custom_characters(CHARSET_MENU);
#if HAS_MARLINUI_HD44780
ui.set_custom_characters(CHARSET_MENU);
#endif
return;
}
bar_percent += (int8_t)ui.encoderPosition;
LIMIT(bar_percent, 0, 100);
ui.encoderPosition = 0;
MenuItem_static::draw(0, GET_TEXT(MSG_PROGRESS_BAR_TEST), SS_CENTER|SS_INVERT);
MenuItem_static::draw(0, GET_TEXT(MSG_PROGRESS_BAR_TEST), SS_DEFAULT|SS_INVERT);
lcd_put_int((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2, bar_percent); lcd_put_wchar('%');
lcd_moveto(0, LCD_HEIGHT - 1); ui.draw_progress_bar(bar_percent);
}
void _progress_bar_test() {
ui.goto_screen(progress_bar_test);
ui.set_custom_characters(CHARSET_INFO);
#if HAS_MARLINUI_HD44780
ui.set_custom_characters(CHARSET_INFO);
#endif
}
#endif // LCD_PROGRESS_BAR_TEST
@@ -96,7 +102,7 @@ void menu_advanced_settings();
#endif
#if EXTRUDERS > 1
#if HAS_MULTI_EXTRUDER
#include "../../module/tool_change.h"
@@ -104,22 +110,52 @@ void menu_advanced_settings();
START_MENU();
BACK_ITEM(MSG_CONFIGURATION);
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
static constexpr float max_extrude =
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
EXTRUDE_MAXLENGTH
#else
500
#endif
;
static constexpr float max_extrude = TERN(PREVENT_LENGTHY_EXTRUDE, EXTRUDE_MAXLENGTH, 500);
#if ENABLED(TOOLCHANGE_PARK)
EDIT_ITEM(bool, MSG_FILAMENT_PARK_ENABLED, &toolchange_settings.enable_park);
#endif
EDIT_ITEM(float3, MSG_FILAMENT_SWAP_LENGTH, &toolchange_settings.swap_length, 0, max_extrude);
EDIT_ITEM(float41sign, MSG_FILAMENT_SWAP_EXTRA, &toolchange_settings.extra_resume, -10, 10);
EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_RETRACT_SPEED, &toolchange_settings.retract_speed, 10, 5400);
EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_UNRETRACT_SPEED, &toolchange_settings.unretract_speed, 10, 5400);
EDIT_ITEM(float3, MSG_FILAMENT_PURGE_LENGTH, &toolchange_settings.extra_prime, 0, max_extrude);
EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_RETRACT_SPD, &toolchange_settings.retract_speed, 10, 5400);
EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_PRIME_SPD, &toolchange_settings.prime_speed, 10, 5400);
EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_PRIME_SPEED, &toolchange_settings.prime_speed, 10, 5400);
EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_FAN_SPEED, &toolchange_settings.fan_speed, 0, 255);
EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_FAN_TIME, &toolchange_settings.fan_time, 1, 30);
#endif
EDIT_ITEM(float3, MSG_TOOL_CHANGE_ZLIFT, &toolchange_settings.z_raise, 0, 10);
END_MENU();
}
#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
#include "../../module/motion.h" // for active_extruder
#include "../../gcode/queue.h"
void menu_toolchange_migration() {
PGM_P const msg_migrate = GET_TEXT(MSG_TOOL_MIGRATION_SWAP);
START_MENU();
BACK_ITEM(MSG_CONFIGURATION);
// Auto mode ON/OFF
EDIT_ITEM(bool, MSG_TOOL_MIGRATION_AUTO, &migration.automode);
EDIT_ITEM(uint8, MSG_TOOL_MIGRATION_END, &migration.last, 0, EXTRUDERS - 1);
// Migrate to a chosen extruder
LOOP_L_N(s, EXTRUDERS) {
if (s != active_extruder) {
ACTION_ITEM_N_P(s, msg_migrate, []{
char cmd[12];
sprintf_P(cmd, PSTR("M217 T%i"), int(MenuItemBase::itemIndex));
queue.inject(cmd);
});
}
}
END_MENU();
}
#endif
#endif
#if HAS_HOTEND_OFFSET
@@ -129,7 +165,7 @@ void menu_advanced_settings();
void menu_tool_offsets() {
auto _recalc_offsets = []{
if (active_extruder && all_axes_known()) { // For the 2nd extruder re-home so the next tool-change gets the new offsets.
if (active_extruder && all_axes_trusted()) { // For the 2nd extruder re-home so the next tool-change gets the new offsets.
queue.inject_P(G28_STR); // In future, we can babystep the 2nd extruder (if active), making homing unnecessary.
active_extruder = 0;
}
@@ -145,7 +181,7 @@ void menu_advanced_settings();
EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_Y, &hotend_offset[1].y, -99.0, 99.0, _recalc_offsets);
EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_Z, &hotend_offset[1].z, Z_PROBE_LOW_POINT, 10.0, _recalc_offsets);
#if ENABLED(EEPROM_SETTINGS)
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
#endif
END_MENU();
}
@@ -154,20 +190,24 @@ void menu_advanced_settings();
#if ENABLED(DUAL_X_CARRIAGE)
void menu_idex() {
const bool need_g28 = axes_should_home(_BV(Y_AXIS)|_BV(Z_AXIS));
START_MENU();
BACK_ITEM(MSG_CONFIGURATION);
GCODES_ITEM(MSG_IDEX_MODE_AUTOPARK, PSTR("M605 S1\nG28 X\nG1 X100"));
const bool need_g28 = !(TEST(axis_known_position, Y_AXIS) && TEST(axis_known_position, Z_AXIS));
GCODES_ITEM(MSG_IDEX_MODE_AUTOPARK, PSTR("M605S1\nG28X\nG1X0"));
GCODES_ITEM(MSG_IDEX_MODE_DUPLICATE, need_g28
? PSTR("M605 S1\nT0\nG28\nM605 S2 X200\nG28 X\nG1 X100") // If Y or Z is not homed, do a full G28 first
: PSTR("M605 S1\nT0\nM605 S2 X200\nG28 X\nG1 X100")
? PSTR("M605S1\nT0\nG28\nM605S2\nG28X\nG1X0") // If Y or Z is not homed, do a full G28 first
: PSTR("M605S1\nT0\nM605S2\nG28X\nG1X0")
);
GCODES_ITEM(MSG_IDEX_MODE_MIRRORED_COPY, need_g28
? PSTR("M605 S1\nT0\nG28\nM605 S2 X200\nG28 X\nG1 X100\nM605 S3 X200") // If Y or Z is not homed, do a full G28 first
: PSTR("M605 S1\nT0\nM605 S2 X200\nG28 X\nG1 X100\nM605 S3 X200")
? PSTR("M605S1\nT0\nG28\nM605S2\nG28X\nG1X0\nM605S3") // If Y or Z is not homed, do a full G28 first
: PSTR("M605S1\nT0\nM605S2\nG28 X\nG1X0\nM605S3")
);
GCODES_ITEM(MSG_IDEX_MODE_FULL_CTRL, PSTR("M605 S0\nG28 X"));
GCODES_ITEM(MSG_IDEX_MODE_FULL_CTRL, PSTR("M605S0\nG28X"));
EDIT_ITEM(float42_52, MSG_IDEX_DUPE_GAP, &duplicate_extruder_x_offset, (X2_MIN_POS) - (X1_MIN_POS), (X_BED_SIZE) - 20);
END_MENU();
}
@@ -177,14 +217,8 @@ void menu_advanced_settings();
#if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU)
void bltouch_report() {
SERIAL_ECHOLNPAIR("EEPROM Last BLTouch Mode - ", (int)bltouch.last_written_mode);
SERIAL_ECHOLNPGM("Configuration BLTouch Mode - "
#if ENABLED(BLTOUCH_SET_5V_MODE)
"5V"
#else
"OD"
#endif
);
SERIAL_ECHOLNPGM("EEPROM Last BLTouch Mode - ", bltouch.last_written_mode);
SERIAL_ECHOLNPGM("Configuration BLTouch Mode - " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD"));
char mess[21];
strcpy_P(mess, PSTR("BLTouch Mode - "));
strcpy_P(&mess[15], bltouch.last_written_mode ? PSTR("5V") : PSTR("OD"));
@@ -202,11 +236,11 @@ void menu_advanced_settings();
ACTION_ITEM(MSG_BLTOUCH_STOW, bltouch._stow);
ACTION_ITEM(MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode);
#if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU)
CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, ui.goto_previous_screen, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, ui.goto_previous_screen, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
ACTION_ITEM(MSG_BLTOUCH_MODE_STORE, bltouch._mode_store);
CONFIRM_ITEM(MSG_BLTOUCH_MODE_STORE_5V, MSG_BLTOUCH_MODE_STORE_5V, MSG_BUTTON_CANCEL, bltouch.mode_conv_5V, ui.goto_previous_screen, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
CONFIRM_ITEM(MSG_BLTOUCH_MODE_STORE_OD, MSG_BLTOUCH_MODE_STORE_OD, MSG_BUTTON_CANCEL, bltouch.mode_conv_OD, ui.goto_previous_screen, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
CONFIRM_ITEM(MSG_BLTOUCH_MODE_STORE_5V, MSG_BLTOUCH_MODE_STORE_5V, MSG_BUTTON_CANCEL, bltouch.mode_conv_5V, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
CONFIRM_ITEM(MSG_BLTOUCH_MODE_STORE_OD, MSG_BLTOUCH_MODE_STORE_OD, MSG_BUTTON_CANCEL, bltouch.mode_conv_OD, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
ACTION_ITEM(MSG_BLTOUCH_MODE_ECHO, bltouch_report);
#endif
END_MENU();
@@ -215,9 +249,10 @@ void menu_advanced_settings();
#endif
#if ENABLED(TOUCH_MI_PROBE)
void menu_touchmi() {
START_MENU();
ui.defer_status_screen();
START_MENU();
BACK_ITEM(MSG_CONFIGURATION);
GCODES_ITEM(MSG_TOUCHMI_INIT, PSTR("M851 Z0\nG28\nG1 F200 Z0"));
SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
@@ -225,6 +260,7 @@ void menu_advanced_settings();
GCODES_ITEM(MSG_TOUCHMI_ZTEST, PSTR("G28\nG1 F200 Z0"));
END_MENU();
}
#endif
#if ENABLED(CONTROLLER_FAN_MENU)
@@ -245,24 +281,6 @@ void menu_advanced_settings();
#endif
#if ENABLED(CASE_LIGHT_MENU)
#include "../../feature/caselight.h"
#if DISABLED(CASE_LIGHT_NO_BRIGHTNESS)
void menu_case_light() {
START_MENU();
BACK_ITEM(MSG_CONFIGURATION);
EDIT_ITEM(percent, MSG_CASE_LIGHT_BRIGHTNESS, &case_light_brightness, 0, 255, update_case_light, true);
EDIT_ITEM(bool, MSG_CASE_LIGHT, (bool*)&case_light_on, update_case_light);
END_MENU();
}
#endif
#endif
#if ENABLED(FWRETRACT)
#include "../../feature/fwretract.h"
@@ -274,17 +292,17 @@ void menu_advanced_settings();
EDIT_ITEM(bool, MSG_AUTORETRACT, &fwretract.autoretract_enabled, fwretract.refresh_autoretract);
#endif
EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT, &fwretract.settings.retract_length, 0, 100);
#if EXTRUDERS > 1
#if HAS_MULTI_EXTRUDER
EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_SWAP, &fwretract.settings.swap_retract_length, 0, 100);
#endif
EDIT_ITEM(float3, MSG_CONTROL_RETRACTF, &fwretract.settings.retract_feedrate_mm_s, 1, 999);
EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_ZHOP, &fwretract.settings.retract_zraise, 0, 999);
EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_RECOVER, &fwretract.settings.retract_recover_extra, -100, 100);
#if EXTRUDERS > 1
#if HAS_MULTI_EXTRUDER
EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_RECOVER_SWAP, &fwretract.settings.swap_retract_recover_extra, -100, 100);
#endif
EDIT_ITEM(float3, MSG_CONTROL_RETRACT_RECOVERF, &fwretract.settings.retract_recover_feedrate_mm_s, 1, 999);
#if EXTRUDERS > 1
#if HAS_MULTI_EXTRUDER
EDIT_ITEM(float3, MSG_CONTROL_RETRACT_RECOVER_SWAPF, &fwretract.settings.swap_retract_recover_feedrate_mm_s, 1, 999);
#endif
END_MENU();
@@ -292,34 +310,157 @@ void menu_advanced_settings();
#endif
#if DISABLED(SLIM_LCD_MENUS)
#if PREHEAT_COUNT && DISABLED(SLIM_LCD_MENUS)
void _menu_configuration_preheat_settings(const uint8_t material) {
void _menu_configuration_preheat_settings() {
#define _MINTEMP_ITEM(N) HEATER_##N##_MINTEMP,
#define _MAXTEMP_ITEM(N) HEATER_##N##_MAXTEMP,
#define MINTEMP_ALL _MIN(REPEAT(HOTENDS, _MINTEMP_ITEM) 999)
#define MAXTEMP_ALL _MAX(REPEAT(HOTENDS, _MAXTEMP_ITEM) 0)
const uint8_t m = MenuItemBase::itemIndex;
START_MENU();
STATIC_ITEM_P(ui.get_preheat_label(m), SS_DEFAULT|SS_INVERT);
BACK_ITEM(MSG_CONFIGURATION);
EDIT_ITEM(percent, MSG_FAN_SPEED, &ui.preheat_fan_speed[material], 0, 255);
#if HAS_FAN
editable.uint8 = uint8_t(ui.material_preset[m].fan_speed);
EDIT_ITEM_N(percent, m, MSG_FAN_SPEED, &editable.uint8, 0, 255, []{ ui.material_preset[MenuItemBase::itemIndex].fan_speed = editable.uint8; });
#endif
#if HAS_TEMP_HOTEND
EDIT_ITEM(int3, MSG_NOZZLE, &ui.preheat_hotend_temp[material], MINTEMP_ALL, MAXTEMP_ALL - 15);
EDIT_ITEM(int3, MSG_NOZZLE, &ui.material_preset[m].hotend_temp, MINTEMP_ALL, MAXTEMP_ALL - (HOTEND_OVERSHOOT));
#endif
#if HAS_HEATED_BED
EDIT_ITEM(int3, MSG_BED, &ui.preheat_bed_temp[material], BED_MINTEMP, BED_MAXTEMP - 10);
EDIT_ITEM(int3, MSG_BED, &ui.material_preset[m].bed_temp, BED_MINTEMP, BED_MAX_TARGET);
#endif
#if ENABLED(EEPROM_SETTINGS)
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
#endif
END_MENU();
}
void menu_preheat_material1_settings() { _menu_configuration_preheat_settings(0); }
void menu_preheat_material2_settings() { _menu_configuration_preheat_settings(1); }
#endif
#if ENABLED(CUSTOM_MENU_CONFIG)
void _lcd_custom_menus_configuration_gcode(PGM_P const cmd) {
queue.inject_P(cmd);
TERN_(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK, ui.completion_feedback());
TERN_(CUSTOM_MENU_CONFIG_SCRIPT_RETURN, ui.return_to_status());
}
void custom_menus_configuration() {
START_MENU();
BACK_ITEM(MSG_MAIN);
#define HAS_CUSTOM_ITEM_CONF(N) (defined(CONFIG_MENU_ITEM_##N##_DESC) && defined(CONFIG_MENU_ITEM_##N##_GCODE))
#ifdef CUSTOM_MENU_CONFIG_SCRIPT_DONE
#define _DONE_SCRIPT "\n" CUSTOM_MENU_CONFIG_SCRIPT_DONE
#else
#define _DONE_SCRIPT ""
#endif
#define GCODE_LAMBDA_CONF(N) []{ _lcd_custom_menus_configuration_gcode(PSTR(CONFIG_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); }
#define _CUSTOM_ITEM_CONF(N) ACTION_ITEM_P(PSTR(CONFIG_MENU_ITEM_##N##_DESC), GCODE_LAMBDA_CONF(N));
#define _CUSTOM_ITEM_CONF_CONFIRM(N) \
SUBMENU_P(PSTR(CONFIG_MENU_ITEM_##N##_DESC), []{ \
MenuItem_confirm::confirm_screen( \
GCODE_LAMBDA_CONF(N), \
ui.goto_previous_screen, \
PSTR(CONFIG_MENU_ITEM_##N##_DESC "?") \
); \
})
#define CUSTOM_ITEM_CONF(N) do{ \
constexpr char c = CONFIG_MENU_ITEM_##N##_GCODE[strlen(CONFIG_MENU_ITEM_##N##_GCODE) - 1]; \
static_assert(c != '\n' && c != '\r', "CONFIG_MENU_ITEM_" STRINGIFY(N) "_GCODE cannot have a newline at the end. Please remove it."); \
if (ENABLED(CONFIG_MENU_ITEM_##N##_CONFIRM)) \
_CUSTOM_ITEM_CONF_CONFIRM(N); \
else \
_CUSTOM_ITEM_CONF(N); \
}while(0)
#if HAS_CUSTOM_ITEM_CONF(1)
CUSTOM_ITEM_CONF(1);
#endif
#if HAS_CUSTOM_ITEM_CONF(2)
CUSTOM_ITEM_CONF(2);
#endif
#if HAS_CUSTOM_ITEM_CONF(3)
CUSTOM_ITEM_CONF(3);
#endif
#if HAS_CUSTOM_ITEM_CONF(4)
CUSTOM_ITEM_CONF(4);
#endif
#if HAS_CUSTOM_ITEM_CONF(5)
CUSTOM_ITEM_CONF(5);
#endif
#if HAS_CUSTOM_ITEM_CONF(6)
CUSTOM_ITEM_CONF(6);
#endif
#if HAS_CUSTOM_ITEM_CONF(7)
CUSTOM_ITEM_CONF(7);
#endif
#if HAS_CUSTOM_ITEM_CONF(8)
CUSTOM_ITEM_CONF(8);
#endif
#if HAS_CUSTOM_ITEM_CONF(9)
CUSTOM_ITEM_CONF(9);
#endif
#if HAS_CUSTOM_ITEM_CONF(10)
CUSTOM_ITEM_CONF(10);
#endif
#if HAS_CUSTOM_ITEM_CONF(11)
CUSTOM_ITEM_CONF(11);
#endif
#if HAS_CUSTOM_ITEM_CONF(12)
CUSTOM_ITEM_CONF(12);
#endif
#if HAS_CUSTOM_ITEM_CONF(13)
CUSTOM_ITEM_CONF(13);
#endif
#if HAS_CUSTOM_ITEM_CONF(14)
CUSTOM_ITEM_CONF(14);
#endif
#if HAS_CUSTOM_ITEM_CONF(15)
CUSTOM_ITEM_CONF(15);
#endif
#if HAS_CUSTOM_ITEM_CONF(16)
CUSTOM_ITEM_CONF(16);
#endif
#if HAS_CUSTOM_ITEM_CONF(17)
CUSTOM_ITEM_CONF(17);
#endif
#if HAS_CUSTOM_ITEM_CONF(18)
CUSTOM_ITEM_CONF(18);
#endif
#if HAS_CUSTOM_ITEM_CONF(19)
CUSTOM_ITEM_CONF(19);
#endif
#if HAS_CUSTOM_ITEM_CONF(20)
CUSTOM_ITEM_CONF(20);
#endif
#if HAS_CUSTOM_ITEM_CONF(21)
CUSTOM_ITEM_CONF(21);
#endif
#if HAS_CUSTOM_ITEM_CONF(22)
CUSTOM_ITEM_CONF(22);
#endif
#if HAS_CUSTOM_ITEM_CONF(23)
CUSTOM_ITEM_CONF(23);
#endif
#if HAS_CUSTOM_ITEM_CONF(24)
CUSTOM_ITEM_CONF(24);
#endif
#if HAS_CUSTOM_ITEM_CONF(25)
CUSTOM_ITEM_CONF(25);
#endif
END_MENU();
}
#endif // CUSTOM_MENU_CONFIG
void menu_configuration() {
const bool busy = printer_busy();
START_MENU();
BACK_ITEM(MSG_MAIN);
@@ -330,6 +471,16 @@ void menu_configuration() {
SUBMENU(MSG_DEBUG_MENU, menu_debug);
#endif
#if ENABLED(CUSTOM_MENU_CONFIG)
if (TERN1(CUSTOM_MENU_CONFIG_ONLY_IDLE, !busy)) {
#ifdef CUSTOM_MENU_CONFIG_TITLE
SUBMENU_P(PSTR(CUSTOM_MENU_CONFIG_TITLE), custom_menus_configuration);
#else
SUBMENU(MSG_CUSTOM_COMMANDS, custom_menus_configuration);
#endif
}
#endif
SUBMENU(MSG_ADVANCED_SETTINGS, menu_advanced_settings);
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
@@ -345,7 +496,6 @@ void menu_configuration() {
SUBMENU(MSG_CONTROLLER_FAN, menu_controller_fan);
#endif
const bool busy = printer_busy();
if (!busy) {
#if EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION)
SUBMENU(MSG_DELTA_CALIBRATE, menu_delta_calibrate);
@@ -371,28 +521,18 @@ void menu_configuration() {
//
// Set single nozzle filament retract and prime length
//
#if EXTRUDERS > 1
#if HAS_MULTI_EXTRUDER
SUBMENU(MSG_TOOL_CHANGE, menu_tool_change);
#endif
//
// Set Case light on/off/brightness
//
#if ENABLED(CASE_LIGHT_MENU)
#if DISABLED(CASE_LIGHT_NO_BRIGHTNESS)
if (true
#if DISABLED(CASE_LIGHT_USE_NEOPIXEL)
&& PWM_PIN(CASE_LIGHT_PIN)
#endif
)
SUBMENU(MSG_CASE_LIGHT, menu_case_light);
else
#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
SUBMENU(MSG_TOOL_MIGRATION, menu_toolchange_migration);
#endif
EDIT_ITEM(bool, MSG_CASE_LIGHT, (bool*)&case_light_on, update_case_light);
#endif
#if HAS_LCD_BRIGHTNESS
EDIT_ITEM_FAST(uint8, MSG_BRIGHTNESS, &ui.brightness, LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, ui.refresh_brightness, true);
#endif
#if HAS_LCD_CONTRAST
EDIT_ITEM(int3, MSG_CONTRAST, &ui.contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, ui.refresh_contrast, true);
EDIT_ITEM_FAST(uint8, MSG_CONTRAST, &ui.contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, ui.refresh_contrast, true);
#endif
#if ENABLED(FWRETRACT)
SUBMENU(MSG_RETRACT, menu_config_retract);
@@ -406,25 +546,22 @@ void menu_configuration() {
EDIT_ITEM(bool, MSG_OUTAGE_RECOVERY, &recovery.enabled, recovery.changed);
#endif
#if DISABLED(SLIM_LCD_MENUS)
// Preheat configurations
SUBMENU(MSG_PREHEAT_1_SETTINGS, menu_preheat_material1_settings);
SUBMENU(MSG_PREHEAT_2_SETTINGS, menu_preheat_material2_settings);
// Preheat configurations
#if PREHEAT_COUNT && DISABLED(SLIM_LCD_MENUS)
LOOP_L_N(m, PREHEAT_COUNT)
SUBMENU_N_S(m, ui.get_preheat_label(m), MSG_PREHEAT_M_SETTINGS, _menu_configuration_preheat_settings);
#endif
#if ENABLED(SOUND_MENU_ITEM)
EDIT_ITEM(bool, MSG_SOUND, &ui.buzzer_enabled, []{ ui.chirp(); });
#endif
#if ENABLED(EEPROM_SETTINGS)
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
if (!busy)
ACTION_ITEM(MSG_LOAD_EEPROM, lcd_load_settings);
ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
if (!busy) ACTION_ITEM(MSG_LOAD_EEPROM, ui.load_settings);
#endif
if (!busy)
ACTION_ITEM(MSG_RESTORE_DEFAULTS, []{
settings.reset();
#if HAS_BUZZER
ui.completion_feedback();
#endif
});
if (!busy) ACTION_ITEM(MSG_RESTORE_DEFAULTS, ui.reset_settings);
END_MENU();
}

View File

@@ -1,133 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* 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/>.
*
*/
//
// Custom User Menu
//
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU && ENABLED(CUSTOM_USER_MENUS)
#include "menu.h"
#include "../../gcode/queue.h"
#ifdef USER_SCRIPT_DONE
#define _DONE_SCRIPT "\n" USER_SCRIPT_DONE
#else
#define _DONE_SCRIPT ""
#endif
void _lcd_user_gcode(PGM_P const cmd) {
queue.inject_P(cmd);
#if ENABLED(USER_SCRIPT_AUDIBLE_FEEDBACK) && HAS_BUZZER
ui.completion_feedback();
#endif
#if ENABLED(USER_SCRIPT_RETURN)
ui.return_to_status();
#endif
}
void menu_user() {
START_MENU();
BACK_ITEM(MSG_MAIN);
#define HAS_USER_ITEM(N) (defined(USER_DESC_##N) && defined(USER_GCODE_##N))
#define USER_ITEM(N) ACTION_ITEM_P(PSTR(USER_DESC_##N), []{ _lcd_user_gcode(PSTR(USER_GCODE_##N _DONE_SCRIPT)); });
#if HAS_USER_ITEM(1)
USER_ITEM(1);
#endif
#if HAS_USER_ITEM(2)
USER_ITEM(2);
#endif
#if HAS_USER_ITEM(3)
USER_ITEM(3);
#endif
#if HAS_USER_ITEM(4)
USER_ITEM(4);
#endif
#if HAS_USER_ITEM(5)
USER_ITEM(5);
#endif
#if HAS_USER_ITEM(6)
USER_ITEM(6);
#endif
#if HAS_USER_ITEM(7)
USER_ITEM(7);
#endif
#if HAS_USER_ITEM(8)
USER_ITEM(8);
#endif
#if HAS_USER_ITEM(9)
USER_ITEM(9);
#endif
#if HAS_USER_ITEM(10)
USER_ITEM(10);
#endif
#if HAS_USER_ITEM(11)
USER_ITEM(11);
#endif
#if HAS_USER_ITEM(12)
USER_ITEM(12);
#endif
#if HAS_USER_ITEM(13)
USER_ITEM(13);
#endif
#if HAS_USER_ITEM(14)
USER_ITEM(14);
#endif
#if HAS_USER_ITEM(15)
USER_ITEM(15);
#endif
#if HAS_USER_ITEM(16)
USER_ITEM(16);
#endif
#if HAS_USER_ITEM(17)
USER_ITEM(17);
#endif
#if HAS_USER_ITEM(18)
USER_ITEM(18);
#endif
#if HAS_USER_ITEM(19)
USER_ITEM(19);
#endif
#if HAS_USER_ITEM(20)
USER_ITEM(20);
#endif
#if HAS_USER_ITEM(21)
USER_ITEM(21);
#endif
#if HAS_USER_ITEM(22)
USER_ITEM(22);
#endif
#if HAS_USER_ITEM(23)
USER_ITEM(23);
#endif
#if HAS_USER_ITEM(24)
USER_ITEM(24);
#endif
#if HAS_USER_ITEM(25)
USER_ITEM(25);
#endif
END_MENU();
}
#endif // HAS_LCD_MENU && CUSTOM_USER_MENUS

45
Marlin/src/lcd/menu/menu_delta_calibrate.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -28,16 +28,17 @@
#if HAS_LCD_MENU && EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION)
#include "menu.h"
#include "menu_item.h"
#include "../../module/delta.h"
#include "../../module/motion.h"
#include "../../module/planner.h"
#if HAS_LEVELING
#include "../../feature/bedlevel/bedlevel.h"
#endif
#if ENABLED(EXTENSIBLE_UI)
#include "../../lcd/extui/ui_api.h"
#include "../extui/ui_api.h"
#endif
void _man_probe_pt(const xy_pos_t &xy) {
@@ -46,15 +47,16 @@ void _man_probe_pt(const xy_pos_t &xy) {
do_blocking_move_to_xy_z(xy, Z_CLEARANCE_BETWEEN_PROBES);
ui.wait_for_move = false;
ui.synchronize();
move_menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
ui.manual_move.menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / planner.settings.axis_steps_per_mm[0]); // Use first axis as for delta XYZ should always match
ui.goto_screen(lcd_move_z);
}
}
#if ENABLED(DELTA_AUTO_CALIBRATION)
#include "../../gcode/gcode.h"
#if HAS_RESUME_CONTINUE
#include "../../MarlinCore.h" // for wait_for_user_response()
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
#include "../../feature/host_actions.h" // for host_prompt_do
#endif
@@ -62,13 +64,9 @@ void _man_probe_pt(const xy_pos_t &xy) {
float lcd_probe_pt(const xy_pos_t &xy) {
_man_probe_pt(xy);
ui.defer_status_screen();
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Delta Calibration in progress"), CONTINUE_STR);
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired_P(PSTR("Delta Calibration in progress"));
#endif
wait_for_user_response();
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Delta Calibration in progress"), CONTINUE_STR));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Delta Calibration in progress")));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
ui.goto_previous_screen_no_defer();
return current_position.z;
}
@@ -89,9 +87,10 @@ void _man_probe_pt(const xy_pos_t &xy) {
ui.goto_screen(_lcd_calibrate_homing);
}
void _goto_tower_a(const float &a) {
void _goto_tower_a(const_float_t a) {
constexpr float dcr = DELTA_PRINTABLE_RADIUS;
xy_pos_t tower_vec = { cos(RADIANS(a)), sin(RADIANS(a)) };
_man_probe_pt(tower_vec * delta_calibration_radius());
_man_probe_pt(tower_vec * dcr);
}
void _goto_tower_x() { _goto_tower_a(210); }
void _goto_tower_y() { _goto_tower_a(330); }
@@ -102,15 +101,13 @@ void _man_probe_pt(const xy_pos_t &xy) {
void lcd_delta_settings() {
auto _recalc_delta_settings = []{
#if HAS_LEVELING
reset_bed_level(); // After changing kinematics bed-level data is no longer valid
#endif
TERN_(HAS_LEVELING, reset_bed_level()); // After changing kinematics bed-level data is no longer valid
recalc_delta_settings();
};
START_MENU();
BACK_ITEM(MSG_DELTA_CALIBRATE);
EDIT_ITEM(float52sign, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10, delta_height + 10, _recalc_delta_settings);
#define EDIT_ENDSTOP_ADJ(LABEL,N) EDIT_ITEM_P(float43, PSTR(LABEL), &delta_endstop_adj.N, -5, 5, _recalc_delta_settings)
#define EDIT_ENDSTOP_ADJ(LABEL,N) EDIT_ITEM_P(float43, PSTR(LABEL), &delta_endstop_adj.N, -5, 0, _recalc_delta_settings)
EDIT_ENDSTOP_ADJ("Ex", a);
EDIT_ENDSTOP_ADJ("Ey", b);
EDIT_ENDSTOP_ADJ("Ez", c);
@@ -124,14 +121,18 @@ void lcd_delta_settings() {
}
void menu_delta_calibrate() {
#if ENABLED(DELTA_CALIBRATION_MENU)
const bool all_homed = all_axes_homed(); // Acquire ahead of loop
#endif
START_MENU();
BACK_ITEM(MSG_MAIN);
#if ENABLED(DELTA_AUTO_CALIBRATION)
GCODES_ITEM(MSG_DELTA_AUTO_CALIBRATE, PSTR("G33"));
#if ENABLED(EEPROM_SETTINGS)
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
ACTION_ITEM(MSG_LOAD_EEPROM, lcd_load_settings);
ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
ACTION_ITEM(MSG_LOAD_EEPROM, ui.load_settings);
#endif
#endif
@@ -139,7 +140,7 @@ void menu_delta_calibrate() {
#if ENABLED(DELTA_CALIBRATION_MENU)
SUBMENU(MSG_AUTO_HOME, _lcd_delta_calibrate_home);
if (all_axes_homed()) {
if (all_homed) {
SUBMENU(MSG_DELTA_CALIBRATE_X, _goto_tower_x);
SUBMENU(MSG_DELTA_CALIBRATE_Y, _goto_tower_y);
SUBMENU(MSG_DELTA_CALIBRATE_Z, _goto_tower_z);

161
Marlin/src/lcd/menu/menu_filament.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -26,11 +26,12 @@
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU && ENABLED(ADVANCED_PAUSE_FEATURE)
#if BOTH(HAS_LCD_MENU, ADVANCED_PAUSE_FEATURE)
#include "menu.h"
#include "menu_item.h"
#include "../../module/temperature.h"
#include "../../feature/pause.h"
#include "../../gcode/queue.h"
#if HAS_FILAMENT_SENSOR
#include "../../feature/runout.h"
#endif
@@ -38,29 +39,35 @@
//
// Change Filament > Change/Unload/Load Filament
//
static PauseMode _change_filament_temp_mode; // =PAUSE_MODE_PAUSE_PRINT
static int8_t _change_filament_temp_extruder; // =0
static PauseMode _change_filament_mode; // = PAUSE_MODE_PAUSE_PRINT
static int8_t _change_filament_extruder; // = 0
inline PGM_P _change_filament_temp_command() {
switch (_change_filament_temp_mode) {
case PAUSE_MODE_LOAD_FILAMENT:
return PSTR("M701 T%d");
case PAUSE_MODE_UNLOAD_FILAMENT:
return _change_filament_temp_extruder >= 0 ? PSTR("M702 T%d") : PSTR("M702 ;%d");
inline PGM_P _change_filament_command() {
switch (_change_filament_mode) {
case PAUSE_MODE_LOAD_FILAMENT: return PSTR("M701 T%d");
case PAUSE_MODE_UNLOAD_FILAMENT: return _change_filament_extruder >= 0
? PSTR("M702 T%d") : PSTR("M702 ;%d");
case PAUSE_MODE_CHANGE_FILAMENT:
case PAUSE_MODE_PAUSE_PRINT:
default:
return PSTR("M600 B0 T%d");
default: break;
}
return GET_TEXT(MSG_FILAMENTCHANGE);
return PSTR("M600 B0 T%d");
}
// Initiate Filament Load/Unload/Change at the specified temperature
static void _change_filament_temp(const uint16_t temperature) {
static void _change_filament_with_temp(const uint16_t celsius) {
char cmd[11];
sprintf_P(cmd, _change_filament_temp_command(), _change_filament_temp_extruder);
thermalManager.setTargetHotend(temperature, _change_filament_temp_extruder);
lcd_enqueue_one_now(cmd);
sprintf_P(cmd, _change_filament_command(), _change_filament_extruder);
thermalManager.setTargetHotend(celsius, _change_filament_extruder);
queue.inject(cmd);
}
static void _change_filament_with_preset() {
_change_filament_with_temp(ui.material_preset[MenuItemBase::itemIndex].hotend_temp);
}
static void _change_filament_with_custom() {
_change_filament_with_temp(thermalManager.degTargetHotend(MenuItemBase::itemIndex));
}
//
@@ -69,42 +76,57 @@ static void _change_filament_temp(const uint16_t temperature) {
inline PGM_P change_filament_header(const PauseMode mode) {
switch (mode) {
case PAUSE_MODE_LOAD_FILAMENT:
return GET_TEXT(MSG_FILAMENTLOAD);
case PAUSE_MODE_UNLOAD_FILAMENT:
return GET_TEXT(MSG_FILAMENTUNLOAD);
case PAUSE_MODE_LOAD_FILAMENT: return GET_TEXT(MSG_FILAMENTLOAD);
case PAUSE_MODE_UNLOAD_FILAMENT: return GET_TEXT(MSG_FILAMENTUNLOAD);
default: break;
}
return GET_TEXT(MSG_FILAMENTCHANGE);
}
void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
_change_filament_temp_mode = mode;
_change_filament_temp_extruder = extruder;
_change_filament_mode = mode;
_change_filament_extruder = extruder;
const int8_t old_index = MenuItemBase::itemIndex;
START_MENU();
if (LCD_HEIGHT >= 4) STATIC_ITEM_P(change_filament_header(mode), SS_CENTER|SS_INVERT);
if (LCD_HEIGHT >= 4) STATIC_ITEM_P(change_filament_header(mode), SS_DEFAULT|SS_INVERT);
BACK_ITEM(MSG_BACK);
ACTION_ITEM(MSG_PREHEAT_1, []{ _change_filament_temp(ui.preheat_hotend_temp[0]); });
ACTION_ITEM(MSG_PREHEAT_2, []{ _change_filament_temp(ui.preheat_hotend_temp[1]); });
EDIT_ITEM_FAST(int3, MSG_PREHEAT_CUSTOM, &thermalManager.temp_hotend[_change_filament_temp_extruder].target, EXTRUDE_MINTEMP, heater_maxtemp[extruder] - 15, []{
_change_filament_temp(thermalManager.temp_hotend[_change_filament_temp_extruder].target);
});
#if PREHEAT_COUNT
LOOP_L_N(m, PREHEAT_COUNT)
ACTION_ITEM_N_S(m, ui.get_preheat_label(m), MSG_PREHEAT_M, _change_filament_with_preset);
#endif
EDIT_ITEM_FAST_N(int3, extruder, MSG_PREHEAT_CUSTOM, &thermalManager.temp_hotend[extruder].target,
EXTRUDE_MINTEMP, thermalManager.hotend_max_target(extruder),
_change_filament_with_custom
);
END_MENU();
MenuItemBase::itemIndex = old_index;
}
/**
*
* "Change Filament" submenu
*
*/
#if E_STEPPERS > 1 || ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
void menu_change_filament() {
START_MENU();
BACK_ITEM(MSG_MAIN);
bool printingIsPaused();
#endif
void menu_change_filament() {
#if E_STEPPERS > 1 || ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
// Say "filament change" when no print is active
editable.int8 = printingIsPaused() ? PAUSE_MODE_PAUSE_PRINT : PAUSE_MODE_CHANGE_FILAMENT;
#if E_STEPPERS > 1 && ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
bool too_cold = false;
for (uint8_t s = 0; !too_cold && s < E_STEPPERS; s++)
too_cold = thermalManager.targetTooColdToExtrude(s);
#endif
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
const bool is_busy = printer_busy();
#endif
START_MENU();
BACK_ITEM(MSG_MAIN);
// Change filament
#if E_STEPPERS == 1
PGM_P const msg = GET_TEXT(MSG_FILAMENTCHANGE);
@@ -119,16 +141,17 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
SUBMENU_N_P(s, msg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, MenuItemBase::itemIndex); });
else {
ACTION_ITEM_N_P(s, msg, []{
char cmd[13];
sprintf_P(cmd, PSTR("M600 B0 T%i"), int(MenuItemBase::itemIndex));
lcd_enqueue_one_now(cmd);
PGM_P const cmdpstr = PSTR("M600 B0 T%i");
char cmd[strlen_P(cmdpstr) + 3 + 1];
sprintf_P(cmd, cmdpstr, int(MenuItemBase::itemIndex));
queue.inject(cmd);
});
}
}
#endif
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
if (!printer_busy()) {
if (!is_busy) {
// Load filament
#if E_STEPPERS == 1
PGM_P const msg_load = GET_TEXT(MSG_FILAMENTLOAD);
@@ -145,7 +168,7 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
ACTION_ITEM_N_P(s, msg_load, []{
char cmd[12];
sprintf_P(cmd, PSTR("M701 T%i"), int(MenuItemBase::itemIndex));
lcd_enqueue_one_now(cmd);
queue.inject(cmd);
});
}
}
@@ -160,18 +183,10 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
GCODES_ITEM_P(msg_unload, PSTR("M702"));
#else
#if ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
{
bool too_cold = false;
LOOP_L_N(s, E_STEPPERS) {
if (thermalManager.targetTooColdToExtrude(s)) {
too_cold = true; break;
}
}
if (!too_cold)
GCODES_ITEM(MSG_FILAMENTUNLOAD_ALL, PSTR("M702"));
else
if (too_cold)
SUBMENU(MSG_FILAMENTUNLOAD_ALL, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, -1); });
}
else
GCODES_ITEM(MSG_FILAMENTUNLOAD_ALL, PSTR("M702"));
#endif
PGM_P const msg_unload = GET_TEXT(MSG_FILAMENTUNLOAD_E);
LOOP_L_N(s, E_STEPPERS) {
@@ -181,7 +196,7 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
ACTION_ITEM_N_P(s, msg_unload, []{
char cmd[12];
sprintf_P(cmd, PSTR("M702 T%i"), int(MenuItemBase::itemIndex));
lcd_enqueue_one_now(cmd);
queue.inject(cmd);
});
}
}
@@ -190,19 +205,24 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
#endif
END_MENU();
}
#endif
#else
if (thermalManager.targetHotEnoughToExtrude(active_extruder))
queue.inject_P(PSTR("M600B0"));
else
ui.goto_screen([]{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, 0); });
#endif
}
static uint8_t hotend_status_extruder = 0;
static PGM_P pause_header() {
switch (pause_mode) {
case PAUSE_MODE_CHANGE_FILAMENT:
return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER);
case PAUSE_MODE_LOAD_FILAMENT:
return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER_LOAD);
case PAUSE_MODE_UNLOAD_FILAMENT:
return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER_UNLOAD);
case PAUSE_MODE_CHANGE_FILAMENT: return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER);
case PAUSE_MODE_LOAD_FILAMENT: return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER_LOAD);
case PAUSE_MODE_UNLOAD_FILAMENT: return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER_UNLOAD);
default: break;
}
return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER_PAUSE);
@@ -212,7 +232,7 @@ static PGM_P pause_header() {
#define HOTEND_STATUS_ITEM() do { \
if (_menuLineNr == _thisItemNr) { \
if (ui.should_draw()) { \
MenuItem_static::draw(_lcdLineNr, GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE), SS_INVERT); \
IF_DISABLED(HAS_GRAPHICAL_TFT, MenuItem_static::draw(_lcdLineNr, GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE), SS_INVERT)); \
ui.draw_hotend_status(_lcdLineNr, hotend_status_extruder); \
} \
if (_skipStatic && encoderLine <= _thisItemNr) { \
@@ -230,11 +250,18 @@ void menu_pause_option() {
STATIC_ITEM(MSG_FILAMENT_CHANGE_OPTION_HEADER);
#endif
ACTION_ITEM(MSG_FILAMENT_CHANGE_OPTION_PURGE, []{ pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; });
#if HAS_FILAMENT_SENSOR
if (runout.filament_ran_out)
const bool still_out = runout.filament_ran_out;
if (still_out)
EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled, runout.reset);
#else
constexpr bool still_out = false;
#endif
ACTION_ITEM(MSG_FILAMENT_CHANGE_OPTION_RESUME, []{ pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; });
if (!still_out)
ACTION_ITEM(MSG_FILAMENT_CHANGE_OPTION_RESUME, []{ pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; });
END_MENU();
}
@@ -251,7 +278,7 @@ void _lcd_pause_message(PGM_P const msg) {
skip1 = !has2 && (LCD_HEIGHT) >= 5;
START_SCREEN();
STATIC_ITEM_P(pause_header(), SS_CENTER|SS_INVERT); // 1: Header
STATIC_ITEM_P(pause_header(), SS_DEFAULT|SS_INVERT); // 1: Header
if (skip1) SKIP_ITEM(); // Move a single-line message down
STATIC_ITEM_P(msg1); // 2: Message Line 1
if (has2) STATIC_ITEM_P(msg2); // 3: Message Line 2
@@ -261,7 +288,7 @@ void _lcd_pause_message(PGM_P const msg) {
END_SCREEN();
}
void lcd_pause_pausing_message() { _lcd_pause_message(GET_TEXT(MSG_PAUSE_PRINT_INIT)); }
void lcd_pause_parking_message() { _lcd_pause_message(GET_TEXT(MSG_PAUSE_PRINT_PARKING)); }
void lcd_pause_changing_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_INIT)); }
void lcd_pause_unload_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_UNLOAD)); }
void lcd_pause_heating_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_HEATING)); }
@@ -281,7 +308,7 @@ void lcd_pause_purge_message() {
FORCE_INLINE screenFunc_t ap_message_screen(const PauseMessage message) {
switch (message) {
case PAUSE_MESSAGE_PAUSING: return lcd_pause_pausing_message;
case PAUSE_MESSAGE_PARKING: return lcd_pause_parking_message;
case PAUSE_MESSAGE_CHANGING: return lcd_pause_changing_message;
case PAUSE_MESSAGE_UNLOAD: return lcd_pause_unload_message;
case PAUSE_MESSAGE_WAITING: return lcd_pause_waiting_message;
@@ -299,7 +326,7 @@ FORCE_INLINE screenFunc_t ap_message_screen(const PauseMessage message) {
return nullptr;
}
void lcd_pause_show_message(
void MarlinUI::pause_show_message(
const PauseMessage message,
const PauseMode mode/*=PAUSE_MODE_SAME*/,
const uint8_t extruder/*=active_extruder*/

12
Marlin/src/lcd/menu/menu_game.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -24,18 +24,12 @@
#if HAS_GAME_MENU
#include "menu.h"
#include "menu_item.h"
#include "game/game.h"
void menu_game() {
START_MENU();
BACK_ITEM(
#if ENABLED(LCD_INFO_MENU)
MSG_INFO_MENU
#else
MSG_MAIN
#endif
);
BACK_ITEM(TERN(LCD_INFO_MENU, MSG_INFO_MENU, MSG_MAIN));
#if ENABLED(MARLIN_BRICKOUT)
SUBMENU(MSG_BRICKOUT, brickout.enter_game);
#endif

222
Marlin/src/lcd/menu/menu_info.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -26,16 +26,16 @@
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU && ENABLED(LCD_INFO_MENU)
#if BOTH(HAS_LCD_MENU, LCD_INFO_MENU)
#include "menu.h"
#include "menu_item.h"
#if HAS_GAMES
#include "game/game.h"
#endif
#define VALUE_ITEM(MSG, VALUE, STYL) do{ strcpy_P(buffer, PSTR(": ")); strcpy(buffer + 2, VALUE); STATIC_ITEM(MSG, STYL, buffer); }while(0)
#define VALUE_ITEM_P(MSG, PVALUE, STYL) do{ strcpy_P(buffer, PSTR(": ")); strcpy_P(buffer + 2, PSTR(PVALUE)); STATIC_ITEM(MSG, STYL, buffer); }while(0)
#define VALUE_ITEM(MSG, VALUE, STYL) do{ char msg[21]; strcpy_P(msg, PSTR(": ")); strcpy(msg + 2, VALUE); STATIC_ITEM(MSG, STYL, msg); }while(0)
#define VALUE_ITEM_P(MSG, PVALUE, STYL) do{ char msg[21]; strcpy_P(msg, PSTR(": ")); strcpy_P(msg + 2, PSTR(PVALUE)); STATIC_ITEM(MSG, STYL, msg); }while(0)
#if ENABLED(PRINTCOUNTER)
@@ -47,31 +47,34 @@
void menu_info_stats() {
if (ui.use_click()) return ui.go_back();
char buffer[21]; // For macro usage
printStatistics stats = print_job_timer.getStats();
START_SCREEN(); // 12345678901234567890
VALUE_ITEM(MSG_INFO_PRINT_COUNT, i16tostr3left(stats.totalPrints), SS_LEFT); // Print Count: 999
VALUE_ITEM(MSG_INFO_COMPLETED_PRINTS, i16tostr3left(stats.finishedPrints), SS_LEFT); // Completed : 666
char buffer[21];
STATIC_ITEM(MSG_INFO_PRINT_TIME, SS_LEFT); // Total print Time:
STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.printTime).toString(buffer)); // > 99y 364d 23h 59m 59s
START_SCREEN(); // 12345678901234567890
VALUE_ITEM(MSG_INFO_PRINT_COUNT, i16tostr3left(stats.totalPrints), SS_LEFT); // Print Count: 999
VALUE_ITEM(MSG_INFO_COMPLETED_PRINTS, i16tostr3left(stats.finishedPrints), SS_LEFT); // Completed : 666
STATIC_ITEM(MSG_INFO_PRINT_LONGEST, SS_LEFT); // Longest job time:
STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.longestPrint).toString(buffer)); // > 99y 364d 23h 59m 59s
STATIC_ITEM(MSG_INFO_PRINT_TIME, SS_LEFT); // Total print Time:
STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.printTime).toString(buffer)); // > 99y 364d 23h 59m 59s
STATIC_ITEM(MSG_INFO_PRINT_FILAMENT, SS_LEFT); // Extruded total:
sprintf_P(buffer, PSTR("%ld.%im"), long(stats.filamentUsed / 1000), int16_t(stats.filamentUsed / 100) % 10);
STATIC_ITEM_P(PSTR("> "), SS_LEFT, buffer); // > 125m
STATIC_ITEM(MSG_INFO_PRINT_LONGEST, SS_LEFT); // Longest job time:
STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.longestPrint).toString(buffer)); // > 99y 364d 23h 59m 59s
STATIC_ITEM(MSG_INFO_PRINT_FILAMENT, SS_LEFT); // Extruded total:
sprintf_P(buffer, PSTR("%ld.%im")
, long(stats.filamentUsed / 1000)
, int16_t(stats.filamentUsed / 100) % 10
);
STATIC_ITEM_P(PSTR("> "), SS_LEFT, buffer); // > 125m
#if SERVICE_INTERVAL_1 > 0 || SERVICE_INTERVAL_2 > 0 || SERVICE_INTERVAL_3 > 0
strcpy_P(buffer, GET_TEXT(MSG_SERVICE_IN));
#endif
#if SERVICE_INTERVAL_1 > 0
STATIC_ITEM_P(PSTR(SERVICE_NAME_1 " "), SS_LEFT, buffer); // Service X in:
STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.nextService1).toString(buffer)); // > 7d 12h 11m 10s
STATIC_ITEM_P(PSTR(SERVICE_NAME_1 " "), SS_LEFT, buffer); // Service X in:
STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.nextService1).toString(buffer)); // > 7d 12h 11m 10s
#endif
#if SERVICE_INTERVAL_2 > 0
@@ -95,16 +98,15 @@
void menu_info_thermistors() {
if (ui.use_click()) return ui.go_back();
char buffer[21]; // For macro usage
START_SCREEN();
#if EXTRUDERS
#if HAS_EXTRUDERS
#define THERMISTOR_ID TEMP_SENSOR_0
#include "../thermistornames.h"
STATIC_ITEM_P(PSTR(LCD_STR_E0 ": " THERMISTOR_NAME), SS_INVERT);
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_0_MINTEMP), SS_LEFT);
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_0_MAXTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_0_MINTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_0_MAXTEMP), SS_LEFT);
STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT);
#endif
#if TEMP_SENSOR_1 != 0
@@ -112,8 +114,9 @@ void menu_info_thermistors() {
#define THERMISTOR_ID TEMP_SENSOR_1
#include "../thermistornames.h"
STATIC_ITEM_P(PSTR(LCD_STR_E1 ": " THERMISTOR_NAME), SS_INVERT);
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_1_MINTEMP), SS_LEFT);
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_1_MAXTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_1_MINTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_1_MAXTEMP), SS_LEFT);
STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT);
#endif
#if TEMP_SENSOR_2 != 0
@@ -121,8 +124,9 @@ void menu_info_thermistors() {
#define THERMISTOR_ID TEMP_SENSOR_2
#include "../thermistornames.h"
STATIC_ITEM_P(PSTR(LCD_STR_E2 ": " THERMISTOR_NAME), SS_INVERT);
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_2_MINTEMP), SS_LEFT);
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_2_MAXTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_2_MINTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_2_MAXTEMP), SS_LEFT);
STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT);
#endif
#if TEMP_SENSOR_3 != 0
@@ -130,8 +134,9 @@ void menu_info_thermistors() {
#define THERMISTOR_ID TEMP_SENSOR_3
#include "../thermistornames.h"
STATIC_ITEM_P(PSTR(LCD_STR_E3 ": " THERMISTOR_NAME), SS_INVERT);
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_3_MINTEMP), SS_LEFT);
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_3_MAXTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_3_MINTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_3_MAXTEMP), SS_LEFT);
STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT);
#endif
#if TEMP_SENSOR_4 != 0
@@ -139,8 +144,9 @@ void menu_info_thermistors() {
#define THERMISTOR_ID TEMP_SENSOR_4
#include "../thermistornames.h"
STATIC_ITEM_P(PSTR(LCD_STR_E4 ": " THERMISTOR_NAME), SS_INVERT);
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_4_MINTEMP), SS_LEFT);
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_4_MAXTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_4_MINTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_4_MAXTEMP), SS_LEFT);
STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT);
#endif
#if TEMP_SENSOR_5 != 0
@@ -148,8 +154,9 @@ void menu_info_thermistors() {
#define THERMISTOR_ID TEMP_SENSOR_5
#include "../thermistornames.h"
STATIC_ITEM_P(PSTR(LCD_STR_E5 ": " THERMISTOR_NAME), SS_INVERT);
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_5_MINTEMP), SS_LEFT);
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_5_MAXTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_5_MINTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_5_MAXTEMP), SS_LEFT);
STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT);
#endif
#if TEMP_SENSOR_6 != 0
@@ -157,8 +164,9 @@ void menu_info_thermistors() {
#define THERMISTOR_ID TEMP_SENSOR_6
#include "../thermistornames.h"
STATIC_ITEM_P(PSTR(LCD_STR_E6 ": " THERMISTOR_NAME), SS_INVERT);
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_6_MINTEMP), SS_LEFT);
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_6_MAXTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_6_MINTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_6_MAXTEMP), SS_LEFT);
STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT);
#endif
#if TEMP_SENSOR_7 != 0
@@ -166,59 +174,39 @@ void menu_info_thermistors() {
#define THERMISTOR_ID TEMP_SENSOR_7
#include "../thermistornames.h"
STATIC_ITEM_P(PSTR(LCD_STR_E7 ": " THERMISTOR_NAME), SS_INVERT);
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_7_MINTEMP), SS_LEFT);
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_7_MAXTEMP), SS_LEFT);
#endif
#if EXTRUDERS
{
STATIC_ITEM(
#if WATCH_HOTENDS
MSG_INFO_RUNAWAY_ON
#else
MSG_INFO_RUNAWAY_OFF
#endif
, SS_LEFT
);
}
PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_7_MINTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_7_MAXTEMP), SS_LEFT);
STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT);
#endif
#if HAS_HEATED_BED
{
#undef THERMISTOR_ID
#define THERMISTOR_ID TEMP_SENSOR_BED
#include "../thermistornames.h"
STATIC_ITEM_P(PSTR("BED:" THERMISTOR_NAME), SS_INVERT);
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(BED_MINTEMP), SS_LEFT);
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(BED_MAXTEMP), SS_LEFT);
STATIC_ITEM(
#if WATCH_BED
MSG_INFO_RUNAWAY_ON
#else
MSG_INFO_RUNAWAY_OFF
#endif
, SS_LEFT
);
}
STATIC_ITEM_P(PSTR("BED: " THERMISTOR_NAME), SS_INVERT);
PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(BED_MINTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(BED_MAXTEMP), SS_LEFT);
STATIC_ITEM(TERN(WATCH_BED, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT);
#endif
#if HAS_HEATED_CHAMBER
{
#undef THERMISTOR_ID
#define THERMISTOR_ID TEMP_SENSOR_CHAMBER
#include "../thermistornames.h"
STATIC_ITEM_P(PSTR("CHAM:" THERMISTOR_NAME), SS_INVERT);
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(CHAMBER_MINTEMP), SS_LEFT);
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(CHAMBER_MAXTEMP), SS_LEFT);
STATIC_ITEM(
#if WATCH_CHAMBER
MSG_INFO_RUNAWAY_ON
#else
MSG_INFO_RUNAWAY_OFF
#endif
, SS_LEFT
);
}
STATIC_ITEM_P(PSTR("CHAM: " THERMISTOR_NAME), SS_INVERT);
PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(CHAMBER_MINTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(CHAMBER_MAXTEMP), SS_LEFT);
STATIC_ITEM(TERN(WATCH_CHAMBER, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT);
#endif
#if HAS_COOLER
#undef THERMISTOR_ID
#define THERMISTOR_ID TEMP_SENSOR_COOLER
#include "../thermistornames.h"
STATIC_ITEM_P(PSTR("COOL: " THERMISTOR_NAME), SS_INVERT);
PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(COOLER_MINTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(COOLER_MAXTEMP), SS_LEFT);
STATIC_ITEM(TERN(WATCH_COOLER, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT);
#endif
END_SCREEN();
@@ -230,16 +218,14 @@ void menu_info_thermistors() {
void menu_info_board() {
if (ui.use_click()) return ui.go_back();
char buffer[21]; // For macro usage
START_SCREEN();
STATIC_ITEM_P(PSTR(BOARD_INFO_NAME), SS_CENTER|SS_INVERT); // MyPrinterController
STATIC_ITEM_P(PSTR(BOARD_INFO_NAME), SS_DEFAULT|SS_INVERT); // MyPrinterController
#ifdef BOARD_WEBSITE_URL
STATIC_ITEM_P(PSTR(BOARD_WEBSITE_URL), SS_LEFT); // www.my3dprinter.com
#endif
VALUE_ITEM_P(MSG_INFO_BAUDRATE, STRINGIFY(BAUDRATE), SS_CENTER); // Baud: 250000
VALUE_ITEM_P(MSG_INFO_PROTOCOL, PROTOCOL_VERSION, SS_CENTER); // Protocol: 1.0
VALUE_ITEM_P(MSG_INFO_PSU, PSU_NAME, SS_CENTER);
PSTRING_ITEM(MSG_INFO_BAUDRATE, STRINGIFY(BAUDRATE), SS_CENTER); // Baud: 250000
PSTRING_ITEM(MSG_INFO_PROTOCOL, PROTOCOL_VERSION, SS_CENTER); // Protocol: 1.0
PSTRING_ITEM(MSG_INFO_PSU, PSU_NAME, SS_CENTER);
END_SCREEN();
}
@@ -265,23 +251,20 @@ void menu_info_board() {
void menu_info_printer() {
if (ui.use_click()) return ui.go_back();
START_SCREEN();
STATIC_ITEM(MSG_MARLIN, SS_CENTER|SS_INVERT); // Marlin
STATIC_ITEM(MSG_MARLIN, SS_DEFAULT|SS_INVERT); // Marlin
STATIC_ITEM_P(PSTR(SHORT_BUILD_VERSION)); // x.x.x-Branch
STATIC_ITEM_P(PSTR(STRING_DISTRIBUTION_DATE)); // YYYY-MM-DD HH:MM
STATIC_ITEM_P(PSTR(MACHINE_NAME)); // My3DPrinter
STATIC_ITEM_P(PSTR(MACHINE_NAME), SS_DEFAULT|SS_INVERT); // My3DPrinter
STATIC_ITEM_P(PSTR(WEBSITE_URL)); // www.my3dprinter.com
char buffer[21];
VALUE_ITEM_P(MSG_INFO_EXTRUDERS, STRINGIFY(EXTRUDERS), SS_CENTER); // Extruders: 2
#if ENABLED(AUTO_BED_LEVELING_3POINT)
STATIC_ITEM(MSG_3POINT_LEVELING); // 3-Point Leveling
#elif ENABLED(AUTO_BED_LEVELING_LINEAR)
STATIC_ITEM(MSG_LINEAR_LEVELING); // Linear Leveling
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
STATIC_ITEM(MSG_BILINEAR_LEVELING); // Bi-linear Leveling
#elif ENABLED(AUTO_BED_LEVELING_UBL)
STATIC_ITEM(MSG_UBL_LEVELING); // Unified Bed Leveling
#elif ENABLED(MESH_BED_LEVELING)
STATIC_ITEM(MSG_MESH_LEVELING); // Mesh Leveling
PSTRING_ITEM(MSG_INFO_EXTRUDERS, STRINGIFY(EXTRUDERS), SS_CENTER); // Extruders: 2
#if HAS_LEVELING
STATIC_ITEM(
TERN_(AUTO_BED_LEVELING_3POINT, MSG_3POINT_LEVELING) // 3-Point Leveling
TERN_(AUTO_BED_LEVELING_LINEAR, MSG_LINEAR_LEVELING) // Linear Leveling
TERN_(AUTO_BED_LEVELING_BILINEAR, MSG_BILINEAR_LEVELING) // Bi-linear Leveling
TERN_(AUTO_BED_LEVELING_UBL, MSG_UBL_LEVELING) // Unified Bed Leveling
TERN_(MESH_BED_LEVELING, MSG_MESH_LEVELING) // Mesh Leveling
);
#endif
END_SCREEN();
}
@@ -295,17 +278,11 @@ void menu_info() {
START_MENU();
BACK_ITEM(MSG_MAIN);
#if ENABLED(LCD_PRINTER_INFO_IS_BOOTSCREEN)
SUBMENU(MSG_INFO_PRINTER_MENU, (
#if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
menu_show_custom_bootscreen
#else
menu_show_marlin_bootscreen
#endif
));
SUBMENU(MSG_INFO_PRINTER_MENU, TERN(SHOW_CUSTOM_BOOTSCREEN, menu_show_custom_bootscreen, menu_show_marlin_bootscreen));
#else
SUBMENU(MSG_INFO_PRINTER_MENU, menu_info_printer); // Printer Info >
SUBMENU(MSG_INFO_BOARD_MENU, menu_info_board); // Board Info >
#if EXTRUDERS
#if HAS_EXTRUDERS
SUBMENU(MSG_INFO_THERMISTOR_MENU, menu_info_thermistors); // Thermistors >
#endif
#endif
@@ -315,27 +292,26 @@ void menu_info() {
#endif
#if HAS_GAMES
{
#if ENABLED(GAMES_EASTER_EGG)
SKIP_ITEM();
SKIP_ITEM();
SKIP_ITEM();
SKIP_ITEM(); SKIP_ITEM(); SKIP_ITEM();
#endif
// Game sub-menu or the individual game
{
SUBMENU(
#if HAS_GAME_MENU
MSG_GAMES, menu_game
#elif ENABLED(MARLIN_BRICKOUT)
MSG_BRICKOUT, brickout.enter_game
#elif ENABLED(MARLIN_INVADERS)
MSG_INVADERS, invaders.enter_game
#elif ENABLED(MARLIN_SNAKE)
MSG_SNAKE, snake.enter_game
#elif ENABLED(MARLIN_MAZE)
MSG_MAZE, maze.enter_game
#endif
);
}
SUBMENU(
#if HAS_GAME_MENU
MSG_GAMES, menu_game
#elif ENABLED(MARLIN_BRICKOUT)
MSG_BRICKOUT, brickout.enter_game
#elif ENABLED(MARLIN_INVADERS)
MSG_INVADERS, invaders.enter_game
#elif ENABLED(MARLIN_SNAKE)
MSG_SNAKE, snake.enter_game
#elif ENABLED(MARLIN_MAZE)
MSG_MAZE, maze.enter_game
#endif
);
}
#endif
END_MENU();

View File

@@ -0,0 +1,495 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* 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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "menu.h"
#include "../marlinui.h"
#include "../../gcode/queue.h" // for inject_P
#include "../../inc/MarlinConfigPre.h"
void lcd_move_z();
////////////////////////////////////////////
///////////// Base Menu Items //////////////
////////////////////////////////////////////
// SUBMENU(LABEL, screen_handler)
class MenuItem_submenu : public MenuItemBase {
public:
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
_draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]);
}
static inline void action(PGM_P const, const screenFunc_t func) { ui.push_current_screen(); ui.goto_screen(func); }
};
// Any menu item that invokes an immediate action
class MenuItem_button : public MenuItemBase {
public:
// Button-y Items are selectable lines with no other indicator
static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
_draw(sel, row, pstr, '>', ' ');
}
};
// ACTION_ITEM(LABEL, FUNC)
class MenuItem_function : public MenuItem_button {
public:
//static inline void action(PGM_P const, const uint8_t, const menuAction_t func) { (*func)(); };
static inline void action(PGM_P const, const menuAction_t func) { (*func)(); };
};
// GCODES_ITEM(LABEL, GCODES)
class MenuItem_gcode : public MenuItem_button {
public:
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
_draw(sel, row, pstr, '>', ' ');
}
static void action(PGM_P const, PGM_P const pgcode) { queue.inject_P(pgcode); }
static inline void action(PGM_P const pstr, const uint8_t, const char * const pgcode) { action(pstr, pgcode); }
};
////////////////////////////////////////////
///////////// Edit Menu Items //////////////
////////////////////////////////////////////
// Template for specific Menu Edit Item Types
template<typename NAME>
class TMenuEditItem : MenuEditItemBase {
private:
typedef typename NAME::type_t type_t;
static inline float scale(const_float_t value) { return NAME::scale(value); }
static inline float unscale(const_float_t value) { return NAME::unscale(value); }
static const char* to_string(const int32_t value) { return NAME::strfunc(unscale(value)); }
static void load(void *ptr, const int32_t value) { *((type_t*)ptr) = unscale(value); }
public:
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t * const data, ...) {
MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(*(data)));
}
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t (*pget)(), ...) {
MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(pget()));
}
// Edit screen for this type of item
static void edit_screen() { MenuEditItemBase::edit_screen(to_string, load); }
static void action(
PGM_P const pstr, // Edit label
type_t * const ptr, // Value pointer
const type_t minValue, // Value range
const type_t maxValue,
const screenFunc_t callback=nullptr, // Value update callback
const bool live=false // Callback during editing
) {
// Make sure minv and maxv fit within int32_t
const int32_t minv = _MAX(scale(minValue), INT32_MIN),
maxv = _MIN(scale(maxValue), INT32_MAX);
goto_edit_screen(pstr, ptr, minv, maxv - minv, scale(*ptr) - minv,
edit_screen, callback, live);
}
};
// Provide a set of Edit Item Types which encompass a primitive
// type, a string function, and a scale factor for edit and display.
// These items call the Edit Item draw method passing the prepared string.
#define __DOFIXfloat PROBE()
#define _DOFIX(TYPE,V) TYPE(TERN(IS_PROBE(__DOFIX##TYPE),FIXFLOAT(V),(V)))
#define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, ETC...) \
struct MenuEditItemInfo_##NAME { \
typedef TYPE type_t; \
static inline float scale(const_float_t value) { return value * (SCALE) ETC; } \
static inline float unscale(const_float_t value) { return value / (SCALE) ETC; } \
static inline const char* strfunc(const_float_t value) { return STRFUNC(_DOFIX(TYPE,value)); } \
}; \
typedef TMenuEditItem<MenuEditItemInfo_##NAME> MenuItem_##NAME
// NAME TYPE STRFUNC SCALE ROUND
DEFINE_MENU_EDIT_ITEM_TYPE(percent ,uint8_t ,ui8tostr4pctrj , 100.f/255.f, +0.5f); // 100% right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(percent_3 ,uint8_t ,pcttostrpctrj , 1 ); // 100% right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(int3 ,int16_t ,i16tostr3rj , 1 ); // 123, -12 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(int4 ,int16_t ,i16tostr4signrj , 1 ); // 1234, -123 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(int8 ,int8_t ,i8tostr3rj , 1 ); // 123, -12 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(uint8 ,uint8_t ,ui8tostr3rj , 1 ); // 123 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(uint16_3 ,uint16_t ,ui16tostr3rj , 1 ); // 123 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(uint16_4 ,uint16_t ,ui16tostr4rj , 0.1f ); // 1234 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(uint16_5 ,uint16_t ,ui16tostr5rj , 0.01f ); // 12345 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(float3 ,float ,ftostr3 , 1 ); // 123 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(float42_52 ,float ,ftostr42_52 , 100 ); // _2.34, 12.34, -2.34 or 123.45, -23.45
DEFINE_MENU_EDIT_ITEM_TYPE(float43 ,float ,ftostr43sign ,1000 ); // -1.234, _1.234, +1.234
DEFINE_MENU_EDIT_ITEM_TYPE(float4 ,float ,ftostr4sign , 1 ); // 1234 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(float5 ,float ,ftostr5rj , 1 ); // 12345 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(float5_25 ,float ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment)
DEFINE_MENU_EDIT_ITEM_TYPE(float51 ,float ,ftostr51rj , 10 ); // 1234.5 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(float31sign ,float ,ftostr31sign , 10 ); // +12.3
DEFINE_MENU_EDIT_ITEM_TYPE(float41sign ,float ,ftostr41sign , 10 ); // +123.4
DEFINE_MENU_EDIT_ITEM_TYPE(float51sign ,float ,ftostr51sign , 10 ); // +1234.5
DEFINE_MENU_EDIT_ITEM_TYPE(float52sign ,float ,ftostr52sign , 100 ); // +123.45
DEFINE_MENU_EDIT_ITEM_TYPE(long5 ,uint32_t ,ftostr5rj , 0.01f ); // 12345 right-justified
DEFINE_MENU_EDIT_ITEM_TYPE(long5_25 ,uint32_t ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment)
#if HAS_BED_PROBE
#if Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9
#define LCD_Z_OFFSET_TYPE float43 // Values from -9.000 to +9.000
#else
#define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99
#endif
#endif
class MenuItem_bool : public MenuEditItemBase {
public:
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const bool onoff) {
MenuEditItemBase::draw(sel, row, pstr, onoff ? GET_TEXT(MSG_LCD_ON) : GET_TEXT(MSG_LCD_OFF), true);
}
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, bool * const data, ...) {
draw(sel, row, pstr, *data);
}
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const, bool (*pget)(), ...) {
draw(sel, row, pstr, pget());
}
static void action(PGM_P const pstr, bool * const ptr, const screenFunc_t callbackFunc=nullptr) {
*ptr ^= true; ui.refresh();
if (callbackFunc) (*callbackFunc)();
}
};
/**
* ////////////////////////////////////////////
* //////////// Menu System Macros ////////////
* ////////////////////////////////////////////
*
* Marlin's native menu screens work by running a loop from the top visible line index
* to the bottom visible line index (according to how much the screen has been scrolled).
* This complete loop is done on every menu screen call.
*
* The menu system is highly dynamic, so it doesn't know ahead of any menu loop which
* items will be visible or hidden, so menu items don't have a fixed index number.
*
* During the loop, each menu item checks to see if its line is the current one. If it is,
* then it checks to see if a click has arrived so it can run its action. If the action
* doesn't redirect to another screen then the menu item calls its draw method.
*
* Menu item add-ons can do whatever they like.
*
* This mixture of drawing and processing inside a loop has the advantage that a single
* line can be used to represent a menu item, and that is the rationale for this design.
*
* One of the pitfalls of this method is that DOGM displays call the screen handler 2x,
* 4x, or 8x per screen update to draw just one segment of the screen. As a result, any
* menu item that exists in two screen segments is drawn and processed twice per screen
* update. With each item processed 5, 10, 20, or 40 times the logic has to be simple.
*
* To avoid repetition and side-effects, function calls for testing menu item conditions
* should be done before the menu loop (START_MENU / START_SCREEN).
*/
/**
* SCREEN_OR_MENU_LOOP generates header code for a screen or menu
*
* 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
*/
#define SCREEN_OR_MENU_LOOP(IS_MENU) \
scroll_screen(IS_MENU ? 1 : LCD_HEIGHT, IS_MENU); \
int8_t _menuLineNr = encoderTopLine, _thisItemNr = 0; \
bool _skipStatic = IS_MENU; UNUSED(_thisItemNr); \
for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT; _lcdLineNr++, _menuLineNr++) { \
_thisItemNr = 0
/**
* START_SCREEN Opening code for a screen having only static items.
* Do simplified scrolling of the entire screen.
*
* START_MENU Opening code for a screen with menu items.
* Scroll as-needed to keep the selected line in view.
*/
#define START_SCREEN() SCREEN_OR_MENU_LOOP(false)
#define START_MENU() SCREEN_OR_MENU_LOOP(true)
#define NEXT_ITEM() (++_thisItemNr)
#define SKIP_ITEM() NEXT_ITEM()
#define END_SCREEN() } screen_items = _thisItemNr
#define END_MENU() END_SCREEN(); UNUSED(_skipStatic)
/**
* MENU_ITEM generates draw & handler code for a menu item, potentially calling:
*
* MenuItem_<type>::draw(sel, row, label, arg3...)
* MenuItem_<type>::action(arg3...)
*
* Examples:
* BACK_ITEM(MSG_INFO_SCREEN)
* MenuItem_back::action(plabel, ...)
* MenuItem_back::draw(sel, row, plabel, ...)
*
* ACTION_ITEM(MSG_PAUSE_PRINT, lcd_sdcard_pause)
* MenuItem_function::action(plabel, lcd_sdcard_pause)
* MenuItem_function::draw(sel, row, plabel, lcd_sdcard_pause)
*
* EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
* MenuItem_int3::action(plabel, &feedrate_percentage, 10, 999)
* MenuItem_int3::draw(sel, row, plabel, &feedrate_percentage, 10, 999)
*/
#if ENABLED(ENCODER_RATE_MULTIPLIER)
#define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER) do{ if (USE_MULTIPLIER) ui.enable_encoder_multiplier(true); }while(0)
#else
#define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER)
#endif
#define _MENU_INNER_P(TYPE, USE_MULTIPLIER, PLABEL, V...) do { \
PGM_P const plabel = PLABEL; \
if (encoderLine == _thisItemNr && ui.use_click()) { \
_MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER); \
MenuItem_##TYPE::action(plabel, ##V); \
if (ui.screen_changed) return; \
} \
if (ui.should_draw()) \
MenuItem_##TYPE::draw \
(encoderLine == _thisItemNr, _lcdLineNr, plabel, ##V); \
}while(0)
#define _MENU_ITEM_P(TYPE, V...) do { \
if (_menuLineNr == _thisItemNr) { \
_skipStatic = false; \
_MENU_INNER_P(TYPE, ##V); \
} \
NEXT_ITEM(); \
}while(0)
// Indexed items set a global index value and optional data
#define _MENU_ITEM_N_S_P(TYPE, N, S, V...) do{ \
if (_menuLineNr == _thisItemNr) { \
_skipStatic = false; \
MenuItemBase::init(N, S); \
_MENU_INNER_P(TYPE, ##V); \
} \
NEXT_ITEM(); \
}while(0)
// Indexed items set a global index value
#define _MENU_ITEM_N_P(TYPE, N, V...) do{ \
if (_menuLineNr == _thisItemNr) { \
_skipStatic = false; \
MenuItemBase::itemIndex = N; \
_MENU_INNER_P(TYPE, ##V); \
} \
NEXT_ITEM(); \
}while(0)
// Items with a unique string
#define _MENU_ITEM_S_P(TYPE, S, V...) do{ \
if (_menuLineNr == _thisItemNr) { \
_skipStatic = false; \
MenuItemBase::itemString = S; \
_MENU_INNER_P(TYPE, ##V); \
} \
NEXT_ITEM(); \
}while(0)
// STATIC_ITEM draws a styled string with no highlight.
// Parameters: label [, style [, char *value] ]
#define STATIC_ITEM_INNER_P(PLABEL, V...) do{ \
if (_skipStatic && encoderLine <= _thisItemNr) { \
ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
++encoderLine; \
} \
if (ui.should_draw()) \
MenuItem_static::draw(_lcdLineNr, PLABEL, ##V); \
} while(0)
#define STATIC_ITEM_P(PLABEL, V...) do{ \
if (_menuLineNr == _thisItemNr) \
STATIC_ITEM_INNER_P(PLABEL, ##V); \
NEXT_ITEM(); \
} while(0)
#define STATIC_ITEM_N_P(PLABEL, N, V...) do{ \
if (_menuLineNr == _thisItemNr) { \
MenuItemBase::init(N); \
STATIC_ITEM_INNER_P(PLABEL, ##V); \
} \
NEXT_ITEM(); \
}while(0)
// PSTRING_ITEM is like STATIC_ITEM but it takes
// two PSTRs with the style as the last parameter.
#define PSTRING_ITEM_P(PLABEL, PVAL, STYL) do{ \
constexpr int m = 20; \
char msg[m+1]; \
msg[0] = ':'; msg[1] = ' '; \
strncpy_P(msg+2, PSTR(PVAL), m-2); \
if (msg[m-1] & 0x80) msg[m-1] = '\0'; \
STATIC_ITEM_P(PLABEL, STYL, msg); \
}while(0)
#define PSTRING_ITEM(LABEL, V...) PSTRING_ITEM_P(GET_TEXT(LABEL), ##V)
#define STATIC_ITEM(LABEL, V...) STATIC_ITEM_P(GET_TEXT(LABEL), ##V)
#define STATIC_ITEM_N(LABEL, N, V...) STATIC_ITEM_N_P(GET_TEXT(LABEL), N, ##V)
#define MENU_ITEM_N_S_P(TYPE, N, S, PLABEL, V...) _MENU_ITEM_N_S_P(TYPE, N, S, false, PLABEL, ##V)
#define MENU_ITEM_N_S(TYPE, N, S, LABEL, V...) MENU_ITEM_N_S_P(TYPE, N, S, GET_TEXT(LABEL), ##V)
#define MENU_ITEM_S_P(TYPE, S, PLABEL, V...) _MENU_ITEM_S_P(TYPE, S, false, PLABEL, ##V)
#define MENU_ITEM_S(TYPE, S, LABEL, V...) MENU_ITEM_S_P(TYPE, S, GET_TEXT(LABEL), ##V)
#define MENU_ITEM_N_P(TYPE, N, PLABEL, V...) _MENU_ITEM_N_P(TYPE, N, false, PLABEL, ##V)
#define MENU_ITEM_N(TYPE, N, LABEL, V...) MENU_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
#define MENU_ITEM_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, false, PLABEL, ##V)
#define MENU_ITEM(TYPE, LABEL, V...) MENU_ITEM_P(TYPE, GET_TEXT(LABEL), ##V)
#define BACK_ITEM_P(PLABEL) MENU_ITEM_P(back, PLABEL)
#define BACK_ITEM(LABEL) MENU_ITEM(back, LABEL)
#define ACTION_ITEM_N_S_P(N, S, PLABEL, ACTION) MENU_ITEM_N_S_P(function, N, S, PLABEL, ACTION)
#define ACTION_ITEM_N_S(N, S, LABEL, ACTION) ACTION_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ACTION)
#define ACTION_ITEM_S_P(S, PLABEL, ACTION) MENU_ITEM_S_P(function, S, PLABEL, ACTION)
#define ACTION_ITEM_S(S, LABEL, ACTION) ACTION_ITEM_S_P(S, GET_TEXT(LABEL), ACTION)
#define ACTION_ITEM_N_P(N, PLABEL, ACTION) MENU_ITEM_N_P(function, N, PLABEL, ACTION)
#define ACTION_ITEM_N(N, LABEL, ACTION) ACTION_ITEM_N_P(N, GET_TEXT(LABEL), ACTION)
#define ACTION_ITEM_P(PLABEL, ACTION) MENU_ITEM_P(function, PLABEL, ACTION)
#define ACTION_ITEM(LABEL, ACTION) ACTION_ITEM_P(GET_TEXT(LABEL), ACTION)
#define GCODES_ITEM_N_S_P(N, S, PLABEL, GCODES) MENU_ITEM_N_S_P(gcode, N, S, PLABEL, GCODES)
#define GCODES_ITEM_N_S(N, S, LABEL, GCODES) GCODES_ITEM_N_S_P(N, S, GET_TEXT(LABEL), GCODES)
#define GCODES_ITEM_S_P(S, PLABEL, GCODES) MENU_ITEM_S_P(gcode, S, PLABEL, GCODES)
#define GCODES_ITEM_S(S, LABEL, GCODES) GCODES_ITEM_S_P(S, GET_TEXT(LABEL), GCODES)
#define GCODES_ITEM_N_P(N, PLABEL, GCODES) MENU_ITEM_N_P(gcode, N, PLABEL, GCODES)
#define GCODES_ITEM_N(N, LABEL, GCODES) GCODES_ITEM_N_P(N, GET_TEXT(LABEL), GCODES)
#define GCODES_ITEM_P(PLABEL, GCODES) MENU_ITEM_P(gcode, PLABEL, GCODES)
#define GCODES_ITEM(LABEL, GCODES) GCODES_ITEM_P(GET_TEXT(LABEL), GCODES)
#define SUBMENU_N_S_P(N, S, PLABEL, DEST) MENU_ITEM_N_S_P(submenu, N, S, PLABEL, DEST)
#define SUBMENU_N_S(N, S, LABEL, DEST) SUBMENU_N_S_P(N, S, GET_TEXT(LABEL), DEST)
#define SUBMENU_S_P(S, PLABEL, DEST) MENU_ITEM_S_P(submenu, S, PLABEL, DEST)
#define SUBMENU_S(S, LABEL, DEST) SUBMENU_S_P(S, GET_TEXT(LABEL), DEST)
#define SUBMENU_N_P(N, PLABEL, DEST) MENU_ITEM_N_P(submenu, N, PLABEL, DEST)
#define SUBMENU_N(N, LABEL, DEST) SUBMENU_N_P(N, GET_TEXT(LABEL), DEST)
#define SUBMENU_P(PLABEL, DEST) MENU_ITEM_P(submenu, PLABEL, DEST)
#define SUBMENU(LABEL, DEST) SUBMENU_P(GET_TEXT(LABEL), DEST)
#define EDIT_ITEM_N_S_P(TYPE, N, S, PLABEL, V...) MENU_ITEM_N_S_P(TYPE, N, S, PLABEL, ##V)
#define EDIT_ITEM_N_S(TYPE, N, S, LABEL, V...) EDIT_ITEM_N_S_P(TYPE, N, S, GET_TEXT(LABEL), ##V)
#define EDIT_ITEM_S_P(TYPE, S, PLABEL, V...) MENU_ITEM_S_P(TYPE, S, PLABEL, ##V)
#define EDIT_ITEM_S(TYPE, S, LABEL, V...) EDIT_ITEM_S_P(TYPE, S, GET_TEXT(LABEL), ##V)
#define EDIT_ITEM_N_P(TYPE, N, PLABEL, V...) MENU_ITEM_N_P(TYPE, N, PLABEL, ##V)
#define EDIT_ITEM_N(TYPE, N, LABEL, V...) EDIT_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
#define EDIT_ITEM_P(TYPE, PLABEL, V...) MENU_ITEM_P(TYPE, PLABEL, ##V)
#define EDIT_ITEM(TYPE, LABEL, V...) EDIT_ITEM_P(TYPE, GET_TEXT(LABEL), ##V)
#define EDIT_ITEM_FAST_N_S_P(TYPE, N, S, PLABEL, V...) _MENU_ITEM_N_S_P(TYPE, N, S, true, PLABEL, ##V)
#define EDIT_ITEM_FAST_N_S(TYPE, N, S, LABEL, V...) EDIT_ITEM_FAST_N_S_P(TYPE, N, S, true, GET_TEXT(LABEL), ##V)
#define EDIT_ITEM_FAST_S_P(TYPE, S, PLABEL, V...) _MENU_ITEM_S_P(TYPE, S, true, PLABEL, ##V)
#define EDIT_ITEM_FAST_S(TYPE, S, LABEL, V...) EDIT_ITEM_FAST_S_P(TYPE, S, GET_TEXT(LABEL), ##V)
#define EDIT_ITEM_FAST_N_P(TYPE, N, PLABEL, V...) _MENU_ITEM_N_P(TYPE, N, true, PLABEL, ##V)
#define EDIT_ITEM_FAST_N(TYPE, N, LABEL, V...) EDIT_ITEM_FAST_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
#define EDIT_ITEM_FAST_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, true, PLABEL, ##V)
#define EDIT_ITEM_FAST(TYPE, LABEL, V...) EDIT_ITEM_FAST_P(TYPE, GET_TEXT(LABEL), ##V)
#define _CONFIRM_ITEM_INNER_P(PLABEL, V...) do { \
if (encoderLine == _thisItemNr && ui.use_click()) { \
ui.push_current_screen(); \
ui.goto_screen([]{MenuItem_confirm::select_screen(V);}); \
return; \
} \
if (ui.should_draw()) MenuItem_confirm::draw \
(encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ##V); \
}while(0)
// Indexed items set a global index value and optional data
#define _CONFIRM_ITEM_P(PLABEL, V...) do { \
if (_menuLineNr == _thisItemNr) { \
_skipStatic = false; \
_CONFIRM_ITEM_INNER_P(PLABEL, ##V); \
} \
NEXT_ITEM(); \
}while(0)
// Indexed items set a global index value
#define _CONFIRM_ITEM_N_S_P(N, S, V...) do{ \
if (_menuLineNr == _thisItemNr) { \
_skipStatic = false; \
MenuItemBase::init(N, S); \
_CONFIRM_ITEM_INNER_P(TYPE, ##V); \
} \
NEXT_ITEM(); \
}while(0)
// Indexed items set a global index value
#define _CONFIRM_ITEM_N_P(N, V...) _CONFIRM_ITEM_N_S_P(N, nullptr, V)
#define CONFIRM_ITEM_P(PLABEL,A,B,V...) _CONFIRM_ITEM_P(PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
#define CONFIRM_ITEM(LABEL, V...) CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V)
#define YESNO_ITEM_P(PLABEL, V...) CONFIRM_ITEM_P(PLABEL, MSG_YES, MSG_NO, ##V)
#define YESNO_ITEM(LABEL, V...) YESNO_ITEM_P(GET_TEXT(LABEL), ##V)
#define CONFIRM_ITEM_N_S_P(N,S,PLABEL,A,B,V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
#define CONFIRM_ITEM_N_S(N,S,LABEL,V...) CONFIRM_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V)
#define CONFIRM_ITEM_N_P(N,PLABEL,A,B,V...) _CONFIRM_ITEM_N_P(N, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
#define CONFIRM_ITEM_N(N,LABEL, V...) CONFIRM_ITEM_N_P(N, GET_TEXT(LABEL), ##V)
#define YESNO_ITEM_N_S_P(N,S,PLABEL, V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, MSG_YES, MSG_NO, ##V)
#define YESNO_ITEM_N_S(N,S,LABEL, V...) YESNO_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V)
#define YESNO_ITEM_N_P(N,PLABEL, V...) CONFIRM_ITEM_N_P(N, PLABEL, MSG_YES, MSG_NO, ##V)
#define YESNO_ITEM_N(N,LABEL, V...) YESNO_ITEM_N_P(N, GET_TEXT(LABEL), ##V)
#if ENABLED(LEVEL_BED_CORNERS)
void _lcd_level_bed_corners();
#endif
#if HAS_FAN
#include "../../module/temperature.h"
inline void on_fan_update() {
thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8);
}
#if ENABLED(EXTRA_FAN_SPEED)
#define EDIT_EXTRA_FAN_SPEED(V...) EDIT_ITEM_FAST_N(V)
#else
#define EDIT_EXTRA_FAN_SPEED(...)
#endif
#define _FAN_EDIT_ITEMS(F,L) do{ \
editable.uint8 = thermalManager.fan_speed[F]; \
EDIT_ITEM_FAST_N(percent, F, MSG_##L, &editable.uint8, 0, 255, on_fan_update); \
EDIT_EXTRA_FAN_SPEED(percent, F, MSG_EXTRA_##L, &thermalManager.extra_fan_speed[F].speed, 3, 255); \
}while(0)
#if FAN_COUNT > 1
#define FAN_EDIT_ITEMS(F) _FAN_EDIT_ITEMS(F,FAN_SPEED_N)
#endif
#define SNFAN(N) (ENABLED(SINGLENOZZLE_STANDBY_FAN) && !HAS_FAN##N && EXTRUDERS > N)
#if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
#define DEFINE_SINGLENOZZLE_ITEM() \
auto singlenozzle_item = [&](const uint8_t f) { \
editable.uint8 = thermalManager.singlenozzle_fan_speed[f]; \
EDIT_ITEM_FAST_N(percent, f, MSG_STORED_FAN_N, &editable.uint8, 0, 255, on_fan_update); \
}
#else
#define DEFINE_SINGLENOZZLE_ITEM() NOOP
#endif
#endif // HAS_FAN

6
Marlin/src/lcd/menu/menu_job_recovery.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -26,9 +26,9 @@
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU && ENABLED(POWER_LOSS_RECOVERY)
#if BOTH(HAS_LCD_MENU, POWER_LOSS_RECOVERY)
#include "menu.h"
#include "menu_item.h"
#include "../../gcode/queue.h"
#include "../../sd/cardreader.h"
#include "../../feature/powerloss.h"

View File

@@ -0,0 +1,59 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* 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 <https://www.gnu.org/licenses/>.
*
*/
//
// Language Selection Menu
//
#include "../../inc/MarlinConfig.h"
#if HAS_MULTI_LANGUAGE
#include "menu_item.h"
#include "../../MarlinCore.h"
#include "../../module/settings.h"
static void set_lcd_language(const uint8_t inlang) {
ui.set_language(inlang);
TERN_(LCD_LANGUAGE_AUTO_SAVE, (void)settings.save());
}
void menu_language() {
START_MENU();
BACK_ITEM(MSG_MAIN);
MENU_ITEM_P(function, GET_LANG(LCD_LANGUAGE )::LANGUAGE, []{ set_lcd_language(0); });
MENU_ITEM_P(function, GET_LANG(LCD_LANGUAGE_2)::LANGUAGE, []{ set_lcd_language(1); });
#if NUM_LANGUAGES > 2
MENU_ITEM_P(function, GET_LANG(LCD_LANGUAGE_3)::LANGUAGE, []{ set_lcd_language(2); });
#if NUM_LANGUAGES > 3
MENU_ITEM_P(function, GET_LANG(LCD_LANGUAGE_4)::LANGUAGE, []{ set_lcd_language(3); });
#if NUM_LANGUAGES > 4
MENU_ITEM_P(function, GET_LANG(LCD_LANGUAGE_5)::LANGUAGE, []{ set_lcd_language(4); });
#endif
#endif
#endif
END_MENU();
}
#endif // HAS_MULTI_LANGUAGE

167
Marlin/src/lcd/menu/menu_led.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -26,57 +26,146 @@
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU && ENABLED(LED_CONTROL_MENU)
#if HAS_LCD_MENU && EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU)
#include "menu.h"
#include "../../feature/leds/leds.h"
#if ENABLED(LED_COLOR_PRESETS)
void menu_led_presets() {
START_MENU();
#if LCD_HEIGHT > 2
STATIC_ITEM(MSG_LED_PRESETS, SS_CENTER|SS_INVERT);
#endif
BACK_ITEM(MSG_LED_CONTROL);
ACTION_ITEM(MSG_SET_LEDS_WHITE, leds.set_white);
ACTION_ITEM(MSG_SET_LEDS_RED, leds.set_red);
ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds.set_orange);
ACTION_ITEM(MSG_SET_LEDS_YELLOW,leds.set_yellow);
ACTION_ITEM(MSG_SET_LEDS_GREEN, leds.set_green);
ACTION_ITEM(MSG_SET_LEDS_BLUE, leds.set_blue);
ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds.set_indigo);
ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds.set_violet);
END_MENU();
}
#include "menu_item.h"
#if ENABLED(PSU_CONTROL)
#include "../../feature/power.h"
#endif
void menu_led_custom() {
START_MENU();
BACK_ITEM(MSG_LED_CONTROL);
EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true);
EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true);
EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true);
#if EITHER(RGBW_LED, NEOPIXEL_LED)
EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds.color.w, 0, 255, leds.update, true);
#if ENABLED(LED_CONTROL_MENU)
#include "../../feature/leds/leds.h"
#if ENABLED(LED_COLOR_PRESETS)
void menu_led_presets() {
START_MENU();
#if LCD_HEIGHT > 2
STATIC_ITEM(MSG_LED_PRESETS, SS_DEFAULT|SS_INVERT);
#endif
BACK_ITEM(MSG_LED_CONTROL);
ACTION_ITEM(MSG_SET_LEDS_WHITE, leds.set_white);
ACTION_ITEM(MSG_SET_LEDS_RED, leds.set_red);
ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds.set_orange);
ACTION_ITEM(MSG_SET_LEDS_YELLOW, leds.set_yellow);
ACTION_ITEM(MSG_SET_LEDS_GREEN, leds.set_green);
ACTION_ITEM(MSG_SET_LEDS_BLUE, leds.set_blue);
ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds.set_indigo);
ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds.set_violet);
END_MENU();
}
#endif
#if ENABLED(NEO2_COLOR_PRESETS)
void menu_leds2_presets() {
START_MENU();
#if LCD_HEIGHT > 2
STATIC_ITEM(MSG_NEO2_PRESETS, SS_DEFAULT|SS_INVERT);
#endif
BACK_ITEM(MSG_LED_CONTROL);
ACTION_ITEM(MSG_SET_LEDS_WHITE, leds2.set_white);
ACTION_ITEM(MSG_SET_LEDS_RED, leds2.set_red);
ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds2.set_orange);
ACTION_ITEM(MSG_SET_LEDS_YELLOW, leds2.set_yellow);
ACTION_ITEM(MSG_SET_LEDS_GREEN, leds2.set_green);
ACTION_ITEM(MSG_SET_LEDS_BLUE, leds2.set_blue);
ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds2.set_indigo);
ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds2.set_violet);
END_MENU();
}
#endif
void menu_led_custom() {
START_MENU();
BACK_ITEM(MSG_LED_CONTROL);
#if ENABLED(NEOPIXEL2_SEPARATE)
STATIC_ITEM_N(MSG_LED_CHANNEL_N, 1, SS_DEFAULT|SS_INVERT);
#endif
EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true);
EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true);
EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true);
#if HAS_WHITE_LED
EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds.color.w, 0, 255, leds.update, true);
#endif
#if ENABLED(NEOPIXEL_LED)
EDIT_ITEM(uint8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true);
#endif
#if ENABLED(NEOPIXEL2_SEPARATE)
STATIC_ITEM_N(MSG_LED_CHANNEL_N, 2, SS_DEFAULT|SS_INVERT);
EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds2.color.r, 0, 255, leds2.update, true);
EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds2.color.g, 0, 255, leds2.update, true);
EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds2.color.b, 0, 255, leds2.update, true);
#if HAS_WHITE_LED2
EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds2.color.w, 0, 255, leds2.update, true);
#endif
EDIT_ITEM(uint8, MSG_NEO2_BRIGHTNESS, &leds2.color.i, 0, 255, leds2.update, true);
#endif
END_MENU();
}
#endif
#if ENABLED(CASE_LIGHT_MENU)
#include "../../feature/caselight.h"
#define CASELIGHT_TOGGLE_ITEM() EDIT_ITEM(bool, MSG_CASE_LIGHT, (bool*)&caselight.on, caselight.update_enabled)
#if CASELIGHT_USES_BRIGHTNESS
void menu_case_light() {
START_MENU();
BACK_ITEM(MSG_CONFIGURATION);
EDIT_ITEM(percent, MSG_CASE_LIGHT_BRIGHTNESS, &caselight.brightness, 0, 255, caselight.update_brightness, true);
CASELIGHT_TOGGLE_ITEM();
END_MENU();
}
#endif
END_MENU();
}
#endif
void menu_led() {
START_MENU();
BACK_ITEM(MSG_MAIN);
bool led_on = leds.lights_on;
EDIT_ITEM(bool, MSG_LEDS, &led_on, leds.toggle);
ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds.set_default);
#if ENABLED(LED_COLOR_PRESETS)
SUBMENU(MSG_LED_PRESETS, menu_led_presets);
#if ENABLED(LED_CONTROL_MENU)
if (TERN1(PSU_CONTROL, powerManager.psu_on)) {
editable.state = leds.lights_on;
EDIT_ITEM(bool, MSG_LEDS, &editable.state, leds.toggle);
}
#if ENABLED(LED_COLOR_PRESETS)
ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds.set_default);
#endif
#if ENABLED(NEOPIXEL2_SEPARATE)
editable.state = leds2.lights_on;
EDIT_ITEM(bool, MSG_LEDS2, &editable.state, leds2.toggle);
#if ENABLED(NEO2_COLOR_PRESETS)
ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds2.set_default);
#endif
#endif
#if ENABLED(LED_COLOR_PRESETS)
SUBMENU(MSG_LED_PRESETS, menu_led_presets);
#endif
#if ENABLED(NEO2_COLOR_PRESETS)
SUBMENU(MSG_NEO2_PRESETS, menu_leds2_presets);
#endif
SUBMENU(MSG_CUSTOM_LEDS, menu_led_custom);
#endif
SUBMENU(MSG_CUSTOM_LEDS, menu_led_custom);
//
// Set Case light on/off/brightness
//
#if ENABLED(CASE_LIGHT_MENU)
#if CASELIGHT_USES_BRIGHTNESS
if (caselight.has_brightness())
SUBMENU(MSG_CASE_LIGHT, menu_case_light);
else
#endif
CASELIGHT_TOGGLE_ITEM();
#endif
END_MENU();
}

357
Marlin/src/lcd/menu/menu_main.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -28,35 +28,59 @@
#if HAS_LCD_MENU
#include "menu.h"
#include "menu_item.h"
#include "../../module/temperature.h"
#include "../../gcode/queue.h"
#include "../../module/printcounter.h"
#include "../../module/stepper.h"
#include "../../sd/cardreader.h"
#if ENABLED(PSU_CONTROL)
#include "../../feature/power.h"
#endif
#if HAS_GAMES && DISABLED(LCD_INFO_MENU)
#include "game/game.h"
#endif
#define MACHINE_CAN_STOP (EITHER(SDSUPPORT, HOST_PROMPT_SUPPORT) || defined(ACTION_ON_CANCEL))
#define MACHINE_CAN_PAUSE (ANY(SDSUPPORT, HOST_PROMPT_SUPPORT, PARK_HEAD_ON_PAUSE) || defined(ACTION_ON_PAUSE))
#if EITHER(SDSUPPORT, HOST_PROMPT_SUPPORT) || defined(ACTION_ON_CANCEL)
#define MACHINE_CAN_STOP 1
#endif
#if ANY(SDSUPPORT, HOST_PROMPT_SUPPORT, PARK_HEAD_ON_PAUSE) || defined(ACTION_ON_PAUSE)
#define MACHINE_CAN_PAUSE 1
#endif
#if ENABLED(PRUSA_MMU2)
#include "../../lcd/menu/menu_mmu2.h"
#if ENABLED(MMU2_MENUS)
#include "menu_mmu2.h"
#endif
#if ENABLED(PASSWORD_FEATURE)
#include "../../feature/password/password.h"
#endif
#if ENABLED(HOST_START_MENU_ITEM) && defined(ACTION_ON_START)
#include "../../feature/host_actions.h"
#endif
#if ENABLED(GCODE_REPEAT_MARKERS)
#include "../../feature/repeat.h"
#endif
void menu_tune();
void menu_cancelobject();
void menu_motion();
void menu_temperature();
void menu_configuration();
#if ENABLED(CUSTOM_USER_MENUS)
void menu_user();
#if HAS_POWER_MONITOR
void menu_power_monitor();
#endif
#if ENABLED(MIXING_EXTRUDER)
void menu_mixer();
#endif
#if ENABLED(ADVANCED_PAUSE_FEATURE)
void _menu_temp_filament_op(const PauseMode, const int8_t);
void menu_change_filament();
#endif
@@ -64,25 +88,142 @@ void menu_configuration();
void menu_info();
#endif
#if ENABLED(LED_CONTROL_MENU)
#if EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU)
void menu_led();
#endif
#if HAS_CUTTER
#include "../../feature/spindle_laser.h"
void menu_spindle_laser();
#endif
#if ENABLED(MIXING_EXTRUDER)
void menu_mixer();
#if ENABLED(PREHEAT_SHORTCUT_MENU_ITEM)
void menu_preheat_only();
#endif
extern const char M21_STR[];
#if HAS_MULTI_LANGUAGE
void menu_language();
#endif
#if ENABLED(CUSTOM_MENU_MAIN)
void _lcd_custom_menu_main_gcode(PGM_P const cmd) {
queue.inject_P(cmd);
TERN_(CUSTOM_MENU_MAIN_SCRIPT_AUDIBLE_FEEDBACK, ui.completion_feedback());
TERN_(CUSTOM_MENU_MAIN_SCRIPT_RETURN, ui.return_to_status());
}
void custom_menus_main() {
START_MENU();
BACK_ITEM(MSG_MAIN);
#define HAS_CUSTOM_ITEM_MAIN(N) (defined(MAIN_MENU_ITEM_##N##_DESC) && defined(MAIN_MENU_ITEM_##N##_GCODE))
#ifdef CUSTOM_MENU_MAIN_SCRIPT_DONE
#define _DONE_SCRIPT "\n" CUSTOM_MENU_MAIN_SCRIPT_DONE
#else
#define _DONE_SCRIPT ""
#endif
#define GCODE_LAMBDA_MAIN(N) []{ _lcd_custom_menu_main_gcode(PSTR(MAIN_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); }
#define _CUSTOM_ITEM_MAIN(N) ACTION_ITEM_P(PSTR(MAIN_MENU_ITEM_##N##_DESC), GCODE_LAMBDA_MAIN(N));
#define _CUSTOM_ITEM_MAIN_CONFIRM(N) \
SUBMENU_P(PSTR(MAIN_MENU_ITEM_##N##_DESC), []{ \
MenuItem_confirm::confirm_screen( \
GCODE_LAMBDA_MAIN(N), \
ui.goto_previous_screen, \
PSTR(MAIN_MENU_ITEM_##N##_DESC "?") \
); \
})
#define CUSTOM_ITEM_MAIN(N) do{ \
constexpr char c = MAIN_MENU_ITEM_##N##_GCODE[strlen(MAIN_MENU_ITEM_##N##_GCODE) - 1]; \
static_assert(c != '\n' && c != '\r', "MAIN_MENU_ITEM_" STRINGIFY(N) "_GCODE cannot have a newline at the end. Please remove it."); \
if (ENABLED(MAIN_MENU_ITEM_##N##_CONFIRM)) \
_CUSTOM_ITEM_MAIN_CONFIRM(N); \
else \
_CUSTOM_ITEM_MAIN(N); \
}while(0)
#if HAS_CUSTOM_ITEM_MAIN(1)
CUSTOM_ITEM_MAIN(1);
#endif
#if HAS_CUSTOM_ITEM_MAIN(2)
CUSTOM_ITEM_MAIN(2);
#endif
#if HAS_CUSTOM_ITEM_MAIN(3)
CUSTOM_ITEM_MAIN(3);
#endif
#if HAS_CUSTOM_ITEM_MAIN(4)
CUSTOM_ITEM_MAIN(4);
#endif
#if HAS_CUSTOM_ITEM_MAIN(5)
CUSTOM_ITEM_MAIN(5);
#endif
#if HAS_CUSTOM_ITEM_MAIN(6)
CUSTOM_ITEM_MAIN(6);
#endif
#if HAS_CUSTOM_ITEM_MAIN(7)
CUSTOM_ITEM_MAIN(7);
#endif
#if HAS_CUSTOM_ITEM_MAIN(8)
CUSTOM_ITEM_MAIN(8);
#endif
#if HAS_CUSTOM_ITEM_MAIN(9)
CUSTOM_ITEM_MAIN(9);
#endif
#if HAS_CUSTOM_ITEM_MAIN(10)
CUSTOM_ITEM_MAIN(10);
#endif
#if HAS_CUSTOM_ITEM_MAIN(11)
CUSTOM_ITEM_MAIN(11);
#endif
#if HAS_CUSTOM_ITEM_MAIN(12)
CUSTOM_ITEM_MAIN(12);
#endif
#if HAS_CUSTOM_ITEM_MAIN(13)
CUSTOM_ITEM_MAIN(13);
#endif
#if HAS_CUSTOM_ITEM_MAIN(14)
CUSTOM_ITEM_MAIN(14);
#endif
#if HAS_CUSTOM_ITEM_MAIN(15)
CUSTOM_ITEM_MAIN(15);
#endif
#if HAS_CUSTOM_ITEM_MAIN(16)
CUSTOM_ITEM_MAIN(16);
#endif
#if HAS_CUSTOM_ITEM_MAIN(17)
CUSTOM_ITEM_MAIN(17);
#endif
#if HAS_CUSTOM_ITEM_MAIN(18)
CUSTOM_ITEM_MAIN(18);
#endif
#if HAS_CUSTOM_ITEM_MAIN(19)
CUSTOM_ITEM_MAIN(19);
#endif
#if HAS_CUSTOM_ITEM_MAIN(20)
CUSTOM_ITEM_MAIN(20);
#endif
#if HAS_CUSTOM_ITEM_MAIN(21)
CUSTOM_ITEM_MAIN(21);
#endif
#if HAS_CUSTOM_ITEM_MAIN(22)
CUSTOM_ITEM_MAIN(22);
#endif
#if HAS_CUSTOM_ITEM_MAIN(23)
CUSTOM_ITEM_MAIN(23);
#endif
#if HAS_CUSTOM_ITEM_MAIN(24)
CUSTOM_ITEM_MAIN(24);
#endif
#if HAS_CUSTOM_ITEM_MAIN(25)
CUSTOM_ITEM_MAIN(25);
#endif
END_MENU();
}
#endif // CUSTOM_MENU_MAIN
void menu_main() {
START_MENU();
BACK_ITEM(MSG_INFO_SCREEN);
const bool busy = printingIsActive()
#if ENABLED(SDSUPPORT)
, card_detected = card.isMounted()
@@ -90,6 +231,41 @@ void menu_main() {
#endif
;
START_MENU();
BACK_ITEM(MSG_INFO_SCREEN);
#if ENABLED(SDSUPPORT)
#if !defined(MEDIA_MENU_AT_TOP) && !HAS_ENCODER_WHEEL
#define MEDIA_MENU_AT_TOP
#endif
auto sdcard_menu_items = [&]{
#if ENABLED(MENU_ADDAUTOSTART)
ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files
#endif
if (card_detected) {
if (!card_open) {
#if PIN_EXISTS(SD_DETECT)
GCODES_ITEM(MSG_CHANGE_MEDIA, PSTR("M21")); // M21 Change Media
#else // - or -
GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22")); // M22 Release Media
#endif
SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First)
}
}
else {
#if PIN_EXISTS(SD_DETECT)
ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media"
#else
GCODES_ITEM(MSG_ATTACH_MEDIA, PSTR("M21")); // M21 Attach Media
#endif
}
};
#endif
if (busy) {
#if MACHINE_CAN_PAUSE
ACTION_ITEM(MSG_PAUSE_PRINT, ui.pause_print);
@@ -99,60 +275,53 @@ void menu_main() {
MenuItem_confirm::select_screen(
GET_TEXT(MSG_BUTTON_STOP), GET_TEXT(MSG_BACK),
ui.abort_print, ui.goto_previous_screen,
GET_TEXT(MSG_STOP_PRINT), (PGM_P)nullptr, PSTR("?")
GET_TEXT(MSG_STOP_PRINT), (const char *)nullptr, PSTR("?")
);
});
#endif
#if ENABLED(GCODE_REPEAT_MARKERS)
if (repeat.is_active())
ACTION_ITEM(MSG_END_LOOPS, repeat.cancel);
#endif
SUBMENU(MSG_TUNE, menu_tune);
#if ENABLED(CANCEL_OBJECTS) && DISABLED(SLIM_LCD_MENUS)
SUBMENU(MSG_CANCEL_OBJECT, []{ editable.int8 = -1; ui.goto_screen(menu_cancelobject); });
#endif
}
else {
#if !HAS_ENCODER_WHEEL && ENABLED(SDSUPPORT)
#if BOTH(SDSUPPORT, MEDIA_MENU_AT_TOP)
sdcard_menu_items();
#endif
// *** IF THIS SECTION IS CHANGED, REPRODUCE BELOW ***
if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused()))
ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print);
//
// Autostart
//
#if ENABLED(MENU_ADDAUTOSTART)
if (!busy) ACTION_ITEM(MSG_AUTOSTART, card.beginautostart);
#endif
#if ENABLED(HOST_START_MENU_ITEM) && defined(ACTION_ON_START)
ACTION_ITEM(MSG_HOST_START_PRINT, host_action_start);
#endif
if (card_detected) {
if (!card_open) {
SUBMENU(MSG_MEDIA_MENU, menu_media);
MENU_ITEM(gcode,
#if PIN_EXISTS(SD_DETECT)
MSG_CHANGE_MEDIA, M21_STR
#else
MSG_RELEASE_MEDIA, PSTR("M22")
#endif
);
}
}
else {
#if PIN_EXISTS(SD_DETECT)
ACTION_ITEM(MSG_NO_MEDIA, nullptr);
#else
GCODES_ITEM(MSG_ATTACH_MEDIA, M21_STR);
ACTION_ITEM(MSG_MEDIA_RELEASED, nullptr);
#endif
}
#endif // !HAS_ENCODER_WHEEL && SDSUPPORT
#if MACHINE_CAN_PAUSE
if (printingIsPaused()) ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print);
#if ENABLED(PREHEAT_SHORTCUT_MENU_ITEM)
SUBMENU(MSG_PREHEAT_CUSTOM, menu_preheat_only);
#endif
SUBMENU(MSG_MOTION, menu_motion);
}
#if HAS_CUTTER
SUBMENU(MSG_CUTTER(MENU), menu_spindle_laser);
SUBMENU(MSG_CUTTER(MENU), STICKY_SCREEN(menu_spindle_laser));
#endif
SUBMENU(MSG_TEMPERATURE, menu_temperature);
#if HAS_TEMPERATURE
SUBMENU(MSG_TEMPERATURE, menu_temperature);
#endif
#if HAS_POWER_MONITOR
SUBMENU(MSG_POWER_MONITOR, menu_power_monitor);
#endif
#if ENABLED(MIXING_EXTRUDER)
SUBMENU(MSG_MIXER, menu_mixer);
@@ -164,20 +333,22 @@ void menu_main() {
SUBMENU(MSG_CONFIGURATION, menu_configuration);
#if ENABLED(CUSTOM_USER_MENUS)
#ifdef CUSTOM_USER_MENU_TITLE
SUBMENU_P(PSTR(CUSTOM_USER_MENU_TITLE), menu_user);
#else
SUBMENU(MSG_USER_MENU, menu_user);
#endif
#if ENABLED(CUSTOM_MENU_MAIN)
if (TERN1(CUSTOM_MENU_MAIN_ONLY_IDLE, !busy)) {
#ifdef CUSTOM_MENU_MAIN_TITLE
SUBMENU_P(PSTR(CUSTOM_MENU_MAIN_TITLE), custom_menus_main);
#else
SUBMENU(MSG_CUSTOM_COMMANDS, custom_menus_main);
#endif
}
#endif
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES)
if (thermalManager.targetHotEnoughToExtrude(active_extruder))
GCODES_ITEM(MSG_FILAMENTCHANGE, PSTR("M600 B0"));
else
SUBMENU(MSG_FILAMENTCHANGE, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, 0); });
YESNO_ITEM(MSG_FILAMENTCHANGE,
menu_change_filament, ui.goto_previous_screen,
GET_TEXT(MSG_FILAMENTCHANGE), (const char *)nullptr, PSTR("?")
);
#else
SUBMENU(MSG_FILAMENTCHANGE, menu_change_filament);
#endif
@@ -187,60 +358,36 @@ void menu_main() {
SUBMENU(MSG_INFO_MENU, menu_info);
#endif
#if ENABLED(LED_CONTROL_MENU)
SUBMENU(MSG_LED_CONTROL, menu_led);
#if EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU)
SUBMENU(MSG_LEDS, menu_led);
#endif
//
// Switch power on/off
//
#if ENABLED(PSU_CONTROL)
if (powersupply_on)
GCODES_ITEM(MSG_SWITCH_PS_OFF, PSTR("M81"));
if (powerManager.psu_on)
#if ENABLED(PS_OFF_CONFIRM)
CONFIRM_ITEM(MSG_SWITCH_PS_OFF,
MSG_YES, MSG_NO,
ui.poweroff, ui.goto_previous_screen,
GET_TEXT(MSG_SWITCH_PS_OFF), (const char *)nullptr, PSTR("?")
);
#else
GCODES_ITEM(MSG_SWITCH_PS_OFF, PSTR("M81"));
#endif
else
GCODES_ITEM(MSG_SWITCH_PS_ON, PSTR("M80"));
#endif
#if HAS_ENCODER_WHEEL && ENABLED(SDSUPPORT)
// *** IF THIS SECTION IS CHANGED, REPRODUCE ABOVE ***
//
// Autostart
//
#if ENABLED(MENU_ADDAUTOSTART)
if (!busy) ACTION_ITEM(MSG_AUTOSTART, card.beginautostart);
#endif
if (card_detected) {
if (!card_open) {
MENU_ITEM(gcode,
#if PIN_EXISTS(SD_DETECT)
MSG_CHANGE_MEDIA, M21_STR
#else
MSG_RELEASE_MEDIA, PSTR("M22")
#endif
);
SUBMENU(MSG_MEDIA_MENU, menu_media);
}
}
else {
#if PIN_EXISTS(SD_DETECT)
ACTION_ITEM(MSG_NO_MEDIA, nullptr);
#else
GCODES_ITEM(MSG_ATTACH_MEDIA, M21_STR);
ACTION_ITEM(MSG_MEDIA_RELEASED, nullptr);
#endif
}
#endif // HAS_ENCODER_WHEEL && SDSUPPORT
#if ENABLED(SDSUPPORT) && DISABLED(MEDIA_MENU_AT_TOP)
sdcard_menu_items();
#endif
#if HAS_SERVICE_INTERVALS
static auto _service_reset = [](const int index) {
print_job_timer.resetServiceInterval(index);
#if HAS_BUZZER
ui.completion_feedback();
#endif
ui.completion_feedback();
ui.reset_status();
ui.return_to_status();
};
@@ -291,6 +438,10 @@ void menu_main() {
}
#endif
#if HAS_MULTI_LANGUAGE
SUBMENU(LANGUAGE, menu_language);
#endif
END_MENU();
}

69
Marlin/src/lcd/menu/menu_media.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -26,9 +26,9 @@
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU && ENABLED(SDSUPPORT)
#if BOTH(HAS_LCD_MENU, SDSUPPORT)
#include "menu.h"
#include "menu_item.h"
#include "../../sd/cardreader.h"
void lcd_sd_updir() {
@@ -45,25 +45,12 @@ void lcd_sd_updir() {
void MarlinUI::reselect_last_file() {
if (sd_encoder_position == 0xFFFF) return;
//#if HAS_GRAPHICAL_LCD
// // This is a hack to force a screen update.
// ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
// ui.synchronize();
// safe_delay(50);
// ui.synchronize();
// ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
// ui.drawing_screen = ui.screen_changed = true;
//#endif
goto_screen(menu_media, sd_encoder_position, sd_top_line, sd_items);
sd_encoder_position = 0xFFFF;
defer_status_screen();
//#if HAS_GRAPHICAL_LCD
// update();
//#endif
TERN_(HAS_TOUCH_SLEEP, ui.wakeup_screen());
}
#endif
inline void sdcard_start_selected_file() {
@@ -113,17 +100,15 @@ class MenuItem_sdfolder : public MenuItem_sdbase {
encoderTopLine = 0;
ui.encoderPosition = 2 * (ENCODER_STEPS_PER_MENU_ITEM);
ui.screen_changed = true;
#if HAS_GRAPHICAL_LCD
ui.drawing_screen = false;
#endif
TERN_(HAS_MARLINUI_U8GLIB, ui.drawing_screen = false);
ui.refresh();
}
};
void menu_media() {
void menu_media_filelist() {
ui.encoder_direction_menus();
#if HAS_GRAPHICAL_LCD
#if HAS_MARLINUI_U8GLIB
static uint16_t fileCnt;
if (ui.first_page) fileCnt = card.get_num_Files();
#else
@@ -131,35 +116,49 @@ void menu_media() {
#endif
START_MENU();
BACK_ITEM(MSG_MAIN);
#if ENABLED(MULTI_VOLUME)
ACTION_ITEM(MSG_BACK, []{ ui.goto_screen(menu_media); });
#else
BACK_ITEM_P(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT(MSG_MAIN) : GET_TEXT(MSG_BACK));
#endif
if (card.flag.workDirIsRoot) {
#if !PIN_EXISTS(SD_DETECT)
ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); });
#endif
}
else if (card.isMounted())
ACTION_ITEM_P(PSTR(LCD_STR_FOLDER ".."), lcd_sd_updir);
ACTION_ITEM_P(PSTR(LCD_STR_FOLDER " .."), lcd_sd_updir);
if (ui.should_draw()) for (uint16_t i = 0; i < fileCnt; i++) {
if (_menuLineNr == _thisItemNr) {
const uint16_t nr =
#if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA)
fileCnt - 1 -
#endif
i;
card.getfilename_sorted(nr);
card.getfilename_sorted(SD_ORDER(i, fileCnt));
if (card.flag.filenameIsDir)
MENU_ITEM(sdfolder, MSG_MEDIA_MENU, card);
else
MENU_ITEM(sdfile, MSG_MEDIA_MENU, card);
}
else {
else
SKIP_ITEM();
}
}
END_MENU();
}
#if ENABLED(MULTI_VOLUME)
void menu_media_select() {
START_MENU();
BACK_ITEM_P(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT(MSG_MAIN) : GET_TEXT(MSG_BACK));
#if ENABLED(VOLUME_SD_ONBOARD)
ACTION_ITEM(MSG_SD_CARD, []{ card.changeMedia(&card.media_driver_sdcard); card.mount(); ui.goto_screen(menu_media_filelist); });
#endif
#if ENABLED(VOLUME_USB_FLASH_DRIVE)
ACTION_ITEM(MSG_USB_DISK, []{ card.changeMedia(&card.media_driver_usbFlash); card.mount(); ui.goto_screen(menu_media_filelist); });
#endif
END_MENU();
}
#endif
void menu_media() {
TERN(MULTI_VOLUME, menu_media_select, menu_media_filelist)();
}
#endif // HAS_LCD_MENU && SDSUPPORT

114
Marlin/src/lcd/menu/menu_mixer.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -26,65 +26,53 @@
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU && ENABLED(MIXING_EXTRUDER)
#if BOTH(HAS_LCD_MENU, MIXING_EXTRUDER)
#include "menu.h"
#include "menu_item.h"
#include "menu_addon.h"
#include "../../feature/mixing.h"
#define CHANNEL_MIX_EDITING !DUAL_MIXING_EXTRUDER
#if HAS_GRAPHICAL_TFT
#include "../tft/tft.h"
#endif
#define CHANNEL_MIX_EDITING !HAS_DUAL_MIXING
#if ENABLED(GRADIENT_MIX)
void lcd_mixer_gradient_z_start_edit() {
void _lcd_mixer_gradient_z_edit(const bool isend) {
ui.defer_status_screen();
ENCODER_RATE_MULTIPLY(true);
if (ui.encoderPosition != 0) {
mixer.gradient.start_z += float(int32_t(ui.encoderPosition)) * 0.1;
float &zvar = isend ? mixer.gradient.end_z : mixer.gradient.start_z;
if (ui.encoderPosition) {
zvar += float(int32_t(ui.encoderPosition)) * 0.1;
ui.encoderPosition = 0;
NOLESS(mixer.gradient.start_z, 0);
NOMORE(mixer.gradient.start_z, Z_MAX_POS);
NOLESS(zvar, 0);
NOMORE(zvar, Z_MAX_POS);
}
if (ui.should_draw()) {
char tmp[21];
strcpy_P(tmp, GET_TEXT(MSG_START_Z));
sprintf_P(tmp + strlen(tmp), PSTR(": %4d.%d mm"), int(mixer.gradient.start_z), int(mixer.gradient.start_z * 10) % 10);
SETCURSOR(2, (LCD_HEIGHT - 1) / 2);
char tmp[16];
SETCURSOR(1, (LCD_HEIGHT - 1) / 2);
lcd_put_u8str_P(isend ? GET_TEXT(MSG_END_Z) : GET_TEXT(MSG_START_Z));
sprintf_P(tmp, PSTR("%4d.%d mm"), int(zvar), int(zvar * 10) % 10);
SETCURSOR_RJ(9, (LCD_HEIGHT - 1) / 2);
lcd_put_u8str(tmp);
}
if (ui.lcd_clicked) {
if (mixer.gradient.start_z > mixer.gradient.end_z)
mixer.gradient.end_z = mixer.gradient.start_z;
if (isend && zvar < mixer.gradient.start_z)
mixer.gradient.start_z = zvar;
else if (!isend && zvar > mixer.gradient.end_z)
mixer.gradient.end_z = zvar;
mixer.refresh_gradient();
ui.goto_previous_screen();
}
}
void lcd_mixer_gradient_z_end_edit() {
ui.defer_status_screen();
ENCODER_RATE_MULTIPLY(true);
if (ui.encoderPosition != 0) {
mixer.gradient.end_z += float(int32_t(ui.encoderPosition)) * 0.1;
ui.encoderPosition = 0;
NOLESS(mixer.gradient.end_z, 0);
NOMORE(mixer.gradient.end_z, Z_MAX_POS);
}
if (ui.should_draw()) {
char tmp[21];
strcpy_P(tmp, GET_TEXT(MSG_END_Z));
sprintf_P(tmp + strlen(tmp), PSTR(": %4d.%d mm"), int(mixer.gradient.end_z), int(mixer.gradient.end_z * 10) % 10);
SETCURSOR(2, (LCD_HEIGHT - 1) / 2);
lcd_put_u8str(tmp);
}
if (ui.lcd_clicked) {
if (mixer.gradient.end_z < mixer.gradient.start_z)
mixer.gradient.start_z = mixer.gradient.end_z;
mixer.refresh_gradient();
ui.goto_previous_screen();
else {
TERN_(HAS_GRAPHICAL_TFT, tft.draw_edit_screen_buttons());
}
}
@@ -96,19 +84,21 @@
EDIT_ITEM(int8, MSG_END_VTOOL, &mixer.gradient.end_vtool, 0, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient);
#if ENABLED(GRADIENT_VTOOL)
EDIT_ITEM(int8, MSG_GRADIENT_ALIAS, &mixer.gradient.vtool_index, 0, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient);
EDIT_ITEM(int8, MSG_GRADIENT_ALIAS, &mixer.gradient.vtool_index, -1, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient);
#endif
char tmp[18];
SUBMENU(MSG_START_Z, lcd_mixer_gradient_z_start_edit);
MENU_ITEM_ADDON_START(9);
PGM_P const slabel = GET_TEXT(MSG_START_Z);
SUBMENU_P(slabel, []{ _lcd_mixer_gradient_z_edit(false); });
MENU_ITEM_ADDON_START_RJ(11);
sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.start_z), int(mixer.gradient.start_z * 10) % 10);
lcd_put_u8str(tmp);
MENU_ITEM_ADDON_END();
SUBMENU(MSG_END_Z, lcd_mixer_gradient_z_end_edit);
MENU_ITEM_ADDON_START(9);
PGM_P const elabel = GET_TEXT(MSG_END_Z);
SUBMENU_P(elabel, []{ _lcd_mixer_gradient_z_edit(true); });
MENU_ITEM_ADDON_START_RJ(11);
sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.end_z), int(mixer.gradient.end_z * 10) % 10);
lcd_put_u8str(tmp);
MENU_ITEM_ADDON_END();
@@ -120,20 +110,18 @@
static uint8_t v_index;
#if DUAL_MIXING_EXTRUDER
#if HAS_DUAL_MIXING
void _lcd_draw_mix(const uint8_t y) {
char tmp[20]; // "100%_100%"
sprintf_P(tmp, PSTR("%3d%% %3d%%"), int(mixer.mix[0]), int(mixer.mix[1]));
SETCURSOR(2, y); lcd_put_u8str_P(GET_TEXT(MSG_MIX));
SETCURSOR_RJ(9, y); lcd_put_u8str(tmp);
SETCURSOR_RJ(10, y); lcd_put_u8str(tmp);
}
#endif
void _lcd_mixer_select_vtool() {
mixer.T(v_index);
#if DUAL_MIXING_EXTRUDER
_lcd_draw_mix(LCD_HEIGHT - 1);
#endif
TERN_(HAS_DUAL_MIXING, _lcd_draw_mix(LCD_HEIGHT - 1));
}
#if CHANNEL_MIX_EDITING
@@ -156,10 +144,10 @@ void _lcd_mixer_select_vtool() {
void lcd_mixer_mix_edit() {
#if DUAL_MIXING_EXTRUDER && !CHANNEL_MIX_EDITING
#if HAS_DUAL_MIXING && !CHANNEL_MIX_EDITING
// Adjust 2-channel mix from the encoder
if (ui.encoderPosition != 0) {
if (ui.encoderPosition) {
mixer.mix[0] += int32_t(ui.encoderPosition);
ui.encoderPosition = 0;
if (mixer.mix[0] < 0) mixer.mix[0] += 101;
@@ -174,6 +162,8 @@ void lcd_mixer_mix_edit() {
ui.goto_previous_screen();
}
TERN_(HAS_GRAPHICAL_TFT, tft.draw_edit_screen_buttons());
#else
START_MENU();
@@ -194,7 +184,7 @@ void lcd_mixer_mix_edit() {
#endif
}
#if DUAL_MIXING_EXTRUDER
#if HAS_DUAL_MIXING
//
// Toggle Dual-Mix
@@ -239,17 +229,13 @@ void menu_mixer() {
BACK_ITEM(MSG_MAIN);
v_index = mixer.get_current_vtool();
EDIT_ITEM(uint8, MSG_ACTIVE_VTOOL, &v_index, 0, MIXING_VIRTUAL_TOOLS - 1, _lcd_mixer_select_vtool
#if DUAL_MIXING_EXTRUDER
, true
#endif
);
EDIT_ITEM(uint8, MSG_ACTIVE_VTOOL, &v_index, 0, MIXING_VIRTUAL_TOOLS - 1, _lcd_mixer_select_vtool, ENABLED(HAS_DUAL_MIXING));
#if DUAL_MIXING_EXTRUDER
#if HAS_DUAL_MIXING
{
char tmp[10];
char tmp[11];
SUBMENU(MSG_MIX, lcd_mixer_mix_edit);
MENU_ITEM_ADDON_START(10);
MENU_ITEM_ADDON_START_RJ(9);
mixer.update_mix_from_vtool();
sprintf_P(tmp, PSTR("%3d;%3d%%"), int(mixer.mix[0]), int(mixer.mix[1]));
lcd_put_u8str(tmp);
@@ -270,15 +256,15 @@ void menu_mixer() {
LCD_MESSAGEPGM(MSG_VTOOLS_RESET);
ui.return_to_status();
},
ui.goto_previous_screen,
GET_TEXT(MSG_RESET_VTOOLS), (PGM_P)nullptr, PSTR("?")
nullptr,
GET_TEXT(MSG_RESET_VTOOLS), (const char *)nullptr, PSTR("?")
);
#if ENABLED(GRADIENT_MIX)
{
char tmp[13];
SUBMENU(MSG_GRADIENT, lcd_mixer_edit_gradient_menu);
MENU_ITEM_ADDON_START(10);
MENU_ITEM_ADDON_START_RJ(9);
sprintf_P(tmp, PSTR("T%i->T%i"), mixer.gradient.start_vtool, mixer.gradient.end_vtool);
lcd_put_u8str(tmp);
MENU_ITEM_ADDON_END();

66
Marlin/src/lcd/menu/menu_mmu2.cpp Executable file → Normal file
View File

@@ -16,34 +16,28 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../inc/MarlinConfig.h"
#if HAS_LCD_MENU && ENABLED(MMU2_MENUS)
#if BOTH(HAS_LCD_MENU, MMU2_MENUS)
#include "../../feature/mmu2/mmu2.h"
#include "../../MarlinCore.h"
#include "../../feature/mmu/mmu2.h"
#include "menu_mmu2.h"
#include "menu.h"
uint8_t currentTool;
bool mmuMenuWait;
#include "menu_item.h"
//
// Load Filament
//
void _mmu2_load_filamentToNozzle(uint8_t index) {
inline void action_mmu2_load_filament_to_nozzle(const uint8_t tool) {
ui.reset_status();
ui.return_to_status();
ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
if (mmu2.load_filament_to_nozzle(index)) ui.reset_status();
}
inline void action_mmu2_load_filament_to_nozzle(const uint8_t tool) {
_mmu2_load_filamentToNozzle(tool);
ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(tool + 1));
if (mmu2.load_filament_to_nozzle(tool)) ui.reset_status();
ui.return_to_status();
}
@@ -54,8 +48,7 @@ void _mmu2_load_filament(uint8_t index) {
ui.reset_status();
}
void action_mmu2_load_all() {
LOOP_L_N(i, EXTRUDERS)
_mmu2_load_filament(i);
LOOP_L_N(i, EXTRUDERS) _mmu2_load_filament(i);
ui.return_to_status();
}
@@ -63,14 +56,14 @@ void menu_mmu2_load_filament() {
START_MENU();
BACK_ITEM(MSG_MMU2_MENU);
ACTION_ITEM(MSG_MMU2_ALL, action_mmu2_load_all);
LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ _mmu2_load_filament(MenuItemBase::itemIndex); });
LOOP_L_N(i, EXTRUDERS) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ _mmu2_load_filament(MenuItemBase::itemIndex); });
END_MENU();
}
void menu_mmu2_load_to_nozzle() {
START_MENU();
BACK_ITEM(MSG_MMU2_MENU);
LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_load_filament_to_nozzle(MenuItemBase::itemIndex); });
LOOP_L_N(i, EXTRUDERS) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_load_filament_to_nozzle(MenuItemBase::itemIndex); });
END_MENU();
}
@@ -96,7 +89,7 @@ void action_mmu2_unload_filament() {
void menu_mmu2_eject_filament() {
START_MENU();
BACK_ITEM(MSG_MMU2_MENU);
LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ _mmu2_eject_filament(MenuItemBase::itemIndex); });
LOOP_L_N(i, EXTRUDERS) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ _mmu2_eject_filament(MenuItemBase::itemIndex); });
END_MENU();
}
@@ -124,17 +117,20 @@ void menu_mmu2() {
// T* Choose Filament
//
inline void action_mmu2_choose(const uint8_t tool) {
currentTool = tool;
mmuMenuWait = false;
uint8_t feeder_index;
bool wait_for_mmu_menu;
inline void action_mmu2_chosen(const uint8_t index) {
feeder_index = index;
wait_for_mmu_menu = false;
}
void menu_mmu2_choose_filament() {
START_MENU();
#if LCD_HEIGHT > 2
STATIC_ITEM(MSG_MMU2_CHOOSE_FILAMENT_HEADER, SS_CENTER|SS_INVERT);
STATIC_ITEM(MSG_MMU2_CHOOSE_FILAMENT_HEADER, SS_DEFAULT|SS_INVERT);
#endif
LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_choose(MenuItemBase::itemIndex); });
LOOP_L_N(i, EXTRUDERS) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_chosen(MenuItemBase::itemIndex); });
END_MENU();
}
@@ -143,32 +139,32 @@ void menu_mmu2_choose_filament() {
//
void menu_mmu2_pause() {
currentTool = mmu2.get_current_tool();
feeder_index = mmu2.get_current_tool();
START_MENU();
#if LCD_HEIGHT > 2
STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, SS_CENTER|SS_INVERT);
STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, SS_DEFAULT|SS_INVERT);
#endif
ACTION_ITEM(MSG_MMU2_RESUME, []{ mmuMenuWait = false; });
ACTION_ITEM(MSG_MMU2_RESUME, []{ wait_for_mmu_menu = false; });
ACTION_ITEM(MSG_MMU2_UNLOAD_FILAMENT, []{ mmu2.unload(); });
ACTION_ITEM(MSG_MMU2_LOAD_FILAMENT, []{ mmu2.load_filament(currentTool); });
ACTION_ITEM(MSG_MMU2_LOAD_TO_NOZZLE, []{ mmu2.load_filament_to_nozzle(currentTool); });
ACTION_ITEM(MSG_MMU2_LOAD_FILAMENT, []{ mmu2.load_filament(feeder_index); });
ACTION_ITEM(MSG_MMU2_LOAD_TO_NOZZLE, []{ mmu2.load_filament_to_nozzle(feeder_index); });
END_MENU();
}
void mmu2_M600() {
ui.defer_status_screen();
ui.goto_screen(menu_mmu2_pause);
mmuMenuWait = true;
while (mmuMenuWait) idle();
wait_for_mmu_menu = true;
while (wait_for_mmu_menu) idle();
}
uint8_t mmu2_choose_filament() {
ui.defer_status_screen();
ui.goto_screen(menu_mmu2_choose_filament);
mmuMenuWait = true;
while (mmuMenuWait) idle();
wait_for_mmu_menu = true;
while (wait_for_mmu_menu) idle();
ui.return_to_status();
return currentTool;
return feeder_index;
}
#endif // HAS_LCD_MENU && ENABLED(PRUSA_MMU2_MENUS)
#endif // HAS_LCD_MENU && MMU2_MENUS

2
Marlin/src/lcd/menu/menu_mmu2.h Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

390
Marlin/src/lcd/menu/menu_motion.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -28,10 +28,13 @@
#if HAS_LCD_MENU
#include "menu.h"
#define LARGE_AREA_TEST ((X_BED_SIZE) >= 1000 || (Y_BED_SIZE) >= 1000 || (Z_MAX_POS) >= 1000)
#include "menu_item.h"
#include "menu_addon.h"
#include "../../module/motion.h"
#include "../../gcode/parser.h" // for inch support
#if ENABLED(DELTA)
#include "../../module/delta.h"
@@ -46,29 +49,9 @@
#include "../../feature/bedlevel/bedlevel.h"
#endif
extern millis_t manual_move_start_time;
extern int8_t manual_move_axis;
#if ENABLED(MANUAL_E_MOVES_RELATIVE)
float manual_move_e_origin = 0;
#endif
#if IS_KINEMATIC
extern float manual_move_offset;
#endif
//
// Tell ui.update() to start a move to current_position" after a short delay.
//
inline void manual_move_to_current(AxisEnum axis
#if E_MANUAL > 1
, const int8_t eindex=-1
#endif
) {
#if E_MANUAL > 1
if (axis == E_AXIS) ui.manual_move_e_index = eindex >= 0 ? eindex : active_extruder;
#endif
manual_move_start_time = millis() + (move_menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
manual_move_axis = (int8_t)axis;
}
//
// "Motion" > "Move Axis" submenu
@@ -76,41 +59,10 @@ inline void manual_move_to_current(AxisEnum axis
static void _lcd_move_xyz(PGM_P const name, const AxisEnum axis) {
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
if (ui.encoderPosition && !ui.processing_manual_move) {
// Start with no limits to movement
float min = current_position[axis] - 1000,
max = current_position[axis] + 1000;
// Limit to software endstops, if enabled
#if HAS_SOFTWARE_ENDSTOPS
if (soft_endstops_enabled) switch (axis) {
case X_AXIS:
#if ENABLED(MIN_SOFTWARE_ENDSTOP_X)
min = soft_endstop.min.x;
#endif
#if ENABLED(MAX_SOFTWARE_ENDSTOP_X)
max = soft_endstop.max.x;
#endif
break;
case Y_AXIS:
#if ENABLED(MIN_SOFTWARE_ENDSTOP_Y)
min = soft_endstop.min.y;
#endif
#if ENABLED(MAX_SOFTWARE_ENDSTOP_Y)
max = soft_endstop.max.y;
#endif
break;
case Z_AXIS:
#if ENABLED(MIN_SOFTWARE_ENDSTOP_Z)
min = soft_endstop.min.z;
#endif
#if ENABLED(MAX_SOFTWARE_ENDSTOP_Z)
max = soft_endstop.max.z;
#endif
default: break;
}
#endif // HAS_SOFTWARE_ENDSTOPS
if (ui.encoderPosition && !ui.manual_move.processing) {
// Get motion limit from software endstops, if any
float min, max;
soft_endstop.get_manual_axis_limits(axis, min, max);
// Delta limits XY based on the current offset from center
// This assumes the center is 0,0
@@ -122,82 +74,59 @@ static void _lcd_move_xyz(PGM_P const name, const AxisEnum axis) {
#endif
// Get the new position
const float diff = float(int32_t(ui.encoderPosition)) * move_menu_scale;
#if IS_KINEMATIC
manual_move_offset += diff;
if (int32_t(ui.encoderPosition) < 0)
NOLESS(manual_move_offset, min - current_position[axis]);
else
NOMORE(manual_move_offset, max - current_position[axis]);
#else
current_position[axis] += diff;
if (int32_t(ui.encoderPosition) < 0)
NOLESS(current_position[axis], min);
else
NOMORE(current_position[axis], max);
#endif
manual_move_to_current(axis);
const float diff = float(int32_t(ui.encoderPosition)) * ui.manual_move.menu_scale;
(void)ui.manual_move.apply_diff(axis, diff, min, max);
ui.manual_move.soon(axis);
ui.refresh(LCDVIEW_REDRAW_NOW);
}
ui.encoderPosition = 0;
if (ui.should_draw()) {
const float pos = NATIVE_TO_LOGICAL(ui.processing_manual_move ? destination[axis] : current_position[axis]
#if IS_KINEMATIC
+ manual_move_offset
#endif
, axis);
MenuEditItemBase::draw_edit_screen(name, move_menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr43sign(pos));
const float pos = ui.manual_move.axis_value(axis);
if (parser.using_inch_units()) {
const float imp_pos = LINEAR_UNIT(pos);
MenuEditItemBase::draw_edit_screen(name, ftostr63(imp_pos));
}
else
MenuEditItemBase::draw_edit_screen(name, ui.manual_move.menu_scale >= 0.1f ? (LARGE_AREA_TEST ? ftostr51sign(pos) : ftostr41sign(pos)) : ftostr63(pos));
}
}
void lcd_move_x() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_X), X_AXIS); }
void lcd_move_y() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Y), Y_AXIS); }
void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); }
#if HAS_Y_AXIS
void lcd_move_y() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Y), Y_AXIS); }
#endif
#if HAS_Z_AXIS
void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); }
#endif
#if LINEAR_AXES >= 4
void lcd_move_i() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_I), I_AXIS); }
#endif
#if LINEAR_AXES >= 5
void lcd_move_j() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_J), J_AXIS); }
#endif
#if LINEAR_AXES >= 6
void lcd_move_k() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_K), K_AXIS); }
#endif
#if E_MANUAL
static void lcd_move_e(
#if E_MANUAL > 1
const int8_t eindex=-1
#endif
) {
static void lcd_move_e(TERN_(MULTI_E_MANUAL, const int8_t eindex=active_extruder)) {
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
if (ui.encoderPosition) {
if (!ui.processing_manual_move) {
const float diff = float(int32_t(ui.encoderPosition)) * move_menu_scale;
#if IS_KINEMATIC
manual_move_offset += diff;
#else
current_position.e += diff;
#endif
manual_move_to_current(E_AXIS
#if E_MANUAL > 1
, eindex
#endif
);
if (!ui.manual_move.processing) {
const float diff = float(int32_t(ui.encoderPosition)) * ui.manual_move.menu_scale;
TERN(IS_KINEMATIC, ui.manual_move.offset, current_position.e) += diff;
ui.manual_move.soon(E_AXIS OPTARG(MULTI_E_MANUAL, eindex));
ui.refresh(LCDVIEW_REDRAW_NOW);
}
ui.encoderPosition = 0;
}
if (ui.should_draw()) {
#if E_MANUAL > 1
MenuItemBase::init(eindex);
#endif
TERN_(MULTI_E_MANUAL, MenuItemBase::init(eindex));
MenuEditItemBase::draw_edit_screen(
GET_TEXT(
#if E_MANUAL > 1
MSG_MOVE_EN
#else
MSG_MOVE_E
#endif
),
GET_TEXT(TERN(MULTI_E_MANUAL, MSG_MOVE_EN, MSG_MOVE_E)),
ftostr41sign(current_position.e
#if IS_KINEMATIC
+ manual_move_offset
#endif
#if ENABLED(MANUAL_E_MOVES_RELATIVE)
- manual_move_e_origin
#endif
PLUS_TERN0(IS_KINEMATIC, ui.manual_move.offset)
MINUS_TERN0(MANUAL_E_MOVES_RELATIVE, manual_move_e_origin)
)
);
} // should_draw
@@ -209,95 +138,122 @@ void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); }
// "Motion" > "Move Xmm" > "Move XYZ" submenu
//
#ifndef SHORT_MANUAL_Z_MOVE
#define SHORT_MANUAL_Z_MOVE 0.025
#ifndef FINE_MANUAL_MOVE
#define FINE_MANUAL_MOVE 0.025
#endif
screenFunc_t _manual_move_func_ptr;
void _goto_manual_move(const float scale) {
void _goto_manual_move(const_float_t scale) {
ui.defer_status_screen();
move_menu_scale = scale;
ui.manual_move.menu_scale = scale;
ui.goto_screen(_manual_move_func_ptr);
}
void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=-1) {
void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=active_extruder) {
_manual_move_func_ptr = func;
START_MENU();
if (LCD_HEIGHT >= 4) {
switch (axis) {
case X_AXIS: STATIC_ITEM(MSG_MOVE_X, SS_CENTER|SS_INVERT); break;
case Y_AXIS: STATIC_ITEM(MSG_MOVE_Y, SS_CENTER|SS_INVERT); break;
case Z_AXIS: STATIC_ITEM(MSG_MOVE_Z, SS_CENTER|SS_INVERT); break;
case X_AXIS: STATIC_ITEM(MSG_MOVE_X, SS_DEFAULT|SS_INVERT); break;
case Y_AXIS: STATIC_ITEM(MSG_MOVE_Y, SS_DEFAULT|SS_INVERT); break;
case Z_AXIS: STATIC_ITEM(MSG_MOVE_Z, SS_DEFAULT|SS_INVERT); break;
default:
#if ENABLED(MANUAL_E_MOVES_RELATIVE)
manual_move_e_origin = current_position.e;
#endif
STATIC_ITEM(MSG_MOVE_E, SS_CENTER|SS_INVERT);
TERN_(MANUAL_E_MOVES_RELATIVE, manual_move_e_origin = current_position.e);
STATIC_ITEM(MSG_MOVE_E, SS_DEFAULT|SS_INVERT);
break;
}
}
#if ENABLED(PREVENT_COLD_EXTRUSION)
if (axis == E_AXIS && thermalManager.tooColdToExtrude(eindex >= 0 ? eindex : active_extruder))
BACK_ITEM(MSG_HOTEND_TOO_COLD);
else
#endif
{
BACK_ITEM(MSG_MOVE_AXIS);
BACK_ITEM(MSG_MOVE_AXIS);
if (parser.using_inch_units()) {
if (LARGE_AREA_TEST) SUBMENU(MSG_MOVE_1IN, []{ _goto_manual_move(IN_TO_MM(1.000f)); });
SUBMENU(MSG_MOVE_01IN, []{ _goto_manual_move(IN_TO_MM(0.100f)); });
SUBMENU(MSG_MOVE_001IN, []{ _goto_manual_move(IN_TO_MM(0.010f)); });
SUBMENU(MSG_MOVE_0001IN, []{ _goto_manual_move(IN_TO_MM(0.001f)); });
}
else {
if (LARGE_AREA_TEST) SUBMENU(MSG_MOVE_100MM, []{ _goto_manual_move(100); });
SUBMENU(MSG_MOVE_10MM, []{ _goto_manual_move(10); });
SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move( 1); });
SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move( 0.1f); });
if (axis == Z_AXIS && (SHORT_MANUAL_Z_MOVE) > 0.0f && (SHORT_MANUAL_Z_MOVE) < 0.1f) {
extern const char NUL_STR[];
SUBMENU_P(NUL_STR, []{ _goto_manual_move(float(SHORT_MANUAL_Z_MOVE)); });
MENU_ITEM_ADDON_START(0
#if HAS_CHARACTER_LCD
+ 1
#endif
);
char tmp[20], numstr[10];
// Determine digits needed right of decimal
const uint8_t digs = !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 1000 - int((SHORT_MANUAL_Z_MOVE) * 1000)) ? 4 :
!UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 100 - int((SHORT_MANUAL_Z_MOVE) * 100)) ? 3 : 2;
sprintf_P(tmp, GET_TEXT(MSG_MOVE_Z_DIST), dtostrf(SHORT_MANUAL_Z_MOVE, 1, digs, numstr));
if (axis == Z_AXIS && (FINE_MANUAL_MOVE) > 0.0f && (FINE_MANUAL_MOVE) < 0.1f) {
// Determine digits needed right of decimal
constexpr uint8_t digs = !UNEAR_ZERO((FINE_MANUAL_MOVE) * 1000 - int((FINE_MANUAL_MOVE) * 1000)) ? 4 :
!UNEAR_ZERO((FINE_MANUAL_MOVE) * 100 - int((FINE_MANUAL_MOVE) * 100)) ? 3 : 2;
PGM_P const label = GET_TEXT(MSG_MOVE_N_MM);
char tmp[strlen_P(label) + 10 + 1], numstr[10];
sprintf_P(tmp, label, dtostrf(FINE_MANUAL_MOVE, 1, digs, numstr));
#if DISABLED(HAS_GRAPHICAL_TFT)
SUBMENU_P(NUL_STR, []{ _goto_manual_move(float(FINE_MANUAL_MOVE)); });
MENU_ITEM_ADDON_START(0 + ENABLED(HAS_MARLINUI_HD44780));
lcd_put_u8str(tmp);
MENU_ITEM_ADDON_END();
MENU_ITEM_ADDON_END();
#else
SUBMENU_P(tmp, []{ _goto_manual_move(float(FINE_MANUAL_MOVE)); });
#endif
}
}
END_MENU();
}
#if E_MANUAL
inline void _goto_menu_move_distance_e() {
ui.goto_screen([]{ _menu_move_distance(E_AXIS, []{ lcd_move_e(); }); });
}
inline void _menu_move_distance_e_maybe() {
#if ENABLED(PREVENT_COLD_EXTRUSION)
const bool too_cold = thermalManager.tooColdToExtrude(active_extruder);
if (too_cold) {
ui.goto_screen([]{
MenuItem_confirm::select_screen(
GET_TEXT(MSG_BUTTON_PROCEED), GET_TEXT(MSG_BACK),
_goto_menu_move_distance_e, ui.goto_previous_screen,
GET_TEXT(MSG_HOTEND_TOO_COLD), (const char *)nullptr, PSTR("!")
);
});
return;
}
#endif
_goto_menu_move_distance_e();
}
#endif // E_MANUAL
void menu_move() {
START_MENU();
BACK_ITEM(MSG_MOTION);
#if HAS_SOFTWARE_ENDSTOPS && ENABLED(SOFT_ENDSTOPS_MENU_ITEM)
EDIT_ITEM(bool, MSG_LCD_SOFT_ENDSTOPS, &soft_endstops_enabled);
#if BOTH(HAS_SOFTWARE_ENDSTOPS, SOFT_ENDSTOPS_MENU_ITEM)
EDIT_ITEM(bool, MSG_LCD_SOFT_ENDSTOPS, &soft_endstop._enabled);
#endif
if (
#if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING)
all_axes_homed()
#else
true
#endif
) {
if (
#if ENABLED(DELTA)
current_position.z <= delta_clip_start_height
#else
true
#endif
) {
if (NONE(IS_KINEMATIC, NO_MOTION_BEFORE_HOMING) || all_axes_homed()) {
if (TERN1(DELTA, current_position.z <= delta_clip_start_height)) {
SUBMENU(MSG_MOVE_X, []{ _menu_move_distance(X_AXIS, lcd_move_x); });
SUBMENU(MSG_MOVE_Y, []{ _menu_move_distance(Y_AXIS, lcd_move_y); });
#if HAS_Y_AXIS
SUBMENU(MSG_MOVE_Y, []{ _menu_move_distance(Y_AXIS, lcd_move_y); });
#endif
}
#if ENABLED(DELTA)
else
ACTION_ITEM(MSG_FREE_XY, []{ line_to_z(delta_clip_start_height); ui.synchronize(); });
#endif
SUBMENU(MSG_MOVE_Z, []{ _menu_move_distance(Z_AXIS, lcd_move_z); });
#if HAS_Z_AXIS
SUBMENU(MSG_MOVE_Z, []{ _menu_move_distance(Z_AXIS, lcd_move_z); });
#endif
#if LINEAR_AXES >= 4
SUBMENU(MSG_MOVE_I, []{ _menu_move_distance(I_AXIS, lcd_move_i); });
#endif
#if LINEAR_AXES >= 5
SUBMENU(MSG_MOVE_J, []{ _menu_move_distance(J_AXIS, lcd_move_j); });
#endif
#if LINEAR_AXES >= 6
SUBMENU(MSG_MOVE_K, []{ _menu_move_distance(K_AXIS, lcd_move_k); });
#endif
}
else
GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
@@ -341,20 +297,18 @@ void menu_move() {
#if E_MANUAL
// The current extruder
SUBMENU(MSG_MOVE_E, []{ _menu_move_distance(E_AXIS, []{ lcd_move_e(); }, -1); });
SUBMENU(MSG_MOVE_E, []{ _menu_move_distance_e_maybe(); });
#define SUBMENU_MOVE_E(N) SUBMENU_N(N, MSG_MOVE_EN, []{ _menu_move_distance(E_AXIS, []{ lcd_move_e(MenuItemBase::itemIndex); }, MenuItemBase::itemIndex); });
#if EITHER(SWITCHING_EXTRUDER, SWITCHING_NOZZLE)
// ...and the non-switching
#if E_MANUAL == 5
SUBMENU_MOVE_E(4);
#elif E_MANUAL == 3
SUBMENU_MOVE_E(2);
#if E_MANUAL == 7 || E_MANUAL == 5 || E_MANUAL == 3
SUBMENU_MOVE_E(E_MANUAL - 1);
#endif
#elif E_MANUAL > 1
#elif MULTI_E_MANUAL
// Independent extruders with one E-stepper per hotend
LOOP_L_N(n, E_MANUAL) SUBMENU_MOVE_E(n);
@@ -366,12 +320,46 @@ void menu_move() {
END_MENU();
}
#if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU)
//
// "Motion" > "Homing" submenu
//
void menu_home() {
START_MENU();
BACK_ITEM(MSG_MOTION);
GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
GCODES_ITEM(MSG_AUTO_HOME_X, PSTR("G28X"));
#if HAS_Y_AXIS
GCODES_ITEM(MSG_AUTO_HOME_Y, PSTR("G28Y"));
#endif
#if HAS_Z_AXIS
GCODES_ITEM(MSG_AUTO_HOME_Z, PSTR("G28Z"));
#endif
#if LINEAR_AXES >= 4
GCODES_ITEM(MSG_AUTO_HOME_I, PSTR("G28" AXIS4_STR));
#endif
#if LINEAR_AXES >= 5
GCODES_ITEM(MSG_AUTO_HOME_J, PSTR("G28" AXIS5_STR));
#endif
#if LINEAR_AXES >= 6
GCODES_ITEM(MSG_AUTO_HOME_K, PSTR("G28" AXIS6_STR));
#endif
END_MENU();
}
#endif
#if ENABLED(AUTO_BED_LEVELING_UBL)
void _lcd_ubl_level_bed();
#elif ENABLED(LCD_BED_LEVELING)
void menu_bed_leveling();
#endif
#if ENABLED(ASSISTED_TRAMMING_WIZARD)
void goto_tramming_wizard();
#endif
void menu_motion() {
START_MENU();
@@ -383,28 +371,57 @@ void menu_motion() {
//
// Move Axis
//
#if ENABLED(DELTA)
if (all_axes_homed())
#endif
SUBMENU(MSG_MOVE_AXIS, menu_move);
if (TERN1(DELTA, all_axes_homed()))
SUBMENU(MSG_MOVE_AXIS, menu_move);
//
// Auto Home
//
GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
#if ENABLED(INDIVIDUAL_AXIS_HOMING_MENU)
GCODES_ITEM(MSG_AUTO_HOME_X, PSTR("G28X"));
GCODES_ITEM(MSG_AUTO_HOME_Y, PSTR("G28Y"));
GCODES_ITEM(MSG_AUTO_HOME_Z, PSTR("G28Z"));
#if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU)
SUBMENU(MSG_HOMING, menu_home);
#else
GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
#if ENABLED(INDIVIDUAL_AXIS_HOMING_MENU)
GCODES_ITEM(MSG_AUTO_HOME_X, PSTR("G28X"));
#if HAS_Y_AXIS
GCODES_ITEM(MSG_AUTO_HOME_Y, PSTR("G28Y"));
#endif
#if HAS_Z_AXIS
GCODES_ITEM(MSG_AUTO_HOME_Z, PSTR("G28Z"));
#endif
#if LINEAR_AXES >= 4
GCODES_ITEM(MSG_AUTO_HOME_I, PSTR("G28" AXIS4_STR));
#endif
#if LINEAR_AXES >= 5
GCODES_ITEM(MSG_AUTO_HOME_J, PSTR("G28" AXIS5_STR));
#endif
#if LINEAR_AXES >= 6
GCODES_ITEM(MSG_AUTO_HOME_K, PSTR("G28" AXIS6_STR));
#endif
#endif
#endif
//
// Auto-calibration
//
#if ENABLED(CALIBRATION_GCODE)
GCODES_ITEM(MSG_AUTO_CALIBRATE, PSTR("G425"));
#endif
//
// Auto Z-Align
//
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
#if EITHER(Z_STEPPER_AUTO_ALIGN, MECHANICAL_GANTRY_CALIBRATION)
GCODES_ITEM(MSG_AUTO_Z_ALIGN, PSTR("G34"));
#endif
//
// Assisted Bed Tramming
//
#if ENABLED(ASSISTED_TRAMMING_WIZARD)
SUBMENU(MSG_TRAMMING_WIZARD, goto_tramming_wizard);
#endif
//
// Level Bed
//
@@ -414,17 +431,20 @@ void menu_motion() {
#elif ENABLED(LCD_BED_LEVELING)
if (!g29_in_progress) SUBMENU(MSG_BED_LEVELING, menu_bed_leveling);
if (!g29_in_progress)
SUBMENU(MSG_BED_LEVELING, menu_bed_leveling);
#elif HAS_LEVELING && DISABLED(SLIM_LCD_MENUS)
#if DISABLED(PROBE_MANUALLY)
GCODES_ITEM(MSG_LEVEL_BED, PSTR("G28\nG29"));
GCODES_ITEM(MSG_LEVEL_BED, PSTR("G29N"));
#endif
if (all_axes_homed() && leveling_is_valid()) {
bool show_state = planner.leveling_active;
EDIT_ITEM(bool, MSG_BED_LEVELING, &show_state, _lcd_toggle_bed_leveling);
}
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
editable.decimal = planner.z_fade_height;
EDIT_ITEM_FAST(float3, MSG_Z_FADE_HEIGHT, &editable.decimal, 0, 100, []{ set_z_fade_height(editable.decimal); });
@@ -433,11 +453,11 @@ void menu_motion() {
#endif
#if ENABLED(LEVEL_BED_CORNERS) && DISABLED(LCD_BED_LEVELING)
ACTION_ITEM(MSG_LEVEL_CORNERS, _lcd_level_bed_corners);
SUBMENU(MSG_BED_TRAMMING, _lcd_level_bed_corners);
#endif
#if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
GCODES_ITEM(MSG_M48_TEST, PSTR("G28\nM48 P10"));
GCODES_ITEM(MSG_M48_TEST, PSTR("G28O\nM48 P10"));
#endif
//

View File

@@ -0,0 +1,187 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* 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 <https://www.gnu.org/licenses/>.
*
*/
//
// Advanced Settings Menus
//
#include "../../inc/MarlinConfigPre.h"
#if BOTH(HAS_LCD_MENU, PASSWORD_FEATURE)
#include "../../feature/password/password.h"
#include "menu_item.h"
#include "menu_addon.h"
void menu_advanced_settings();
screenFunc_t success_screen, fail_screen;
bool authenticating; // = false
char string[(PASSWORD_LENGTH) + 1];
static uint8_t digit_no;
//
// Screen for both editing and setting the password
//
void Password::menu_password_entry() {
ui.defer_status_screen(!did_first_run); // No timeout to status before first auth
START_MENU();
// "Login" or "New Code"
STATIC_ITEM_P(authenticating ? GET_TEXT(MSG_LOGIN_REQUIRED) : GET_TEXT(MSG_EDIT_PASSWORD), SS_CENTER|SS_INVERT);
STATIC_ITEM_P(NUL_STR, SS_CENTER, string);
#if HAS_MARLINUI_U8GLIB
STATIC_ITEM_P(NUL_STR, SS_CENTER, "");
#endif
// Make the digit edit item look like a sub-menu
PGM_P const label = GET_TEXT(MSG_ENTER_DIGIT);
EDIT_ITEM_P(uint8, label, &editable.uint8, 0, 9, digit_entered);
MENU_ITEM_ADDON_START(utf8_strlen_P(label) + 1);
lcd_put_wchar(' ');
lcd_put_wchar('1' + digit_no);
SETCURSOR_X(LCD_WIDTH - 2);
lcd_put_wchar('>');
MENU_ITEM_ADDON_END();
ACTION_ITEM(MSG_START_OVER, start_over);
if (!authenticating) BACK_ITEM(MSG_BUTTON_CANCEL);
END_MENU();
}
//
// Authentication check
//
void Password::authentication_done() {
ui.goto_screen(is_locked ? fail_screen : success_screen);
ui.completion_feedback(!is_locked);
}
// A single digit was completed
void Password::digit_entered() {
uint32_t multiplier = CAT(1e, PASSWORD_LENGTH); // 1e5 = 100000
LOOP_LE_N(i, digit_no) multiplier /= 10;
value_entry += editable.uint8 * multiplier;
string[digit_no++] = '0' + editable.uint8;
// Exit edit screen menu and go to another screen
ui.goto_previous_screen();
ui.use_click();
ui.goto_screen(menu_password_entry);
// After password has been keyed in
if (digit_no == PASSWORD_LENGTH) {
if (authenticating)
authentication_check();
else
set_password_done();
}
}
//
// Set/Change Password
//
void Password::screen_password_entry() {
value_entry = 0;
digit_no = 0;
editable.uint8 = 0;
memset(string, '_', PASSWORD_LENGTH);
string[PASSWORD_LENGTH] = '\0';
menu_password_entry();
}
void Password::screen_set_password() {
authenticating = false;
screen_password_entry();
}
void Password::authenticate_user(const screenFunc_t in_succ_scr, const screenFunc_t in_fail_scr) {
success_screen = in_succ_scr;
fail_screen = in_fail_scr;
if (is_set) {
authenticating = true;
ui.goto_screen(screen_password_entry);
ui.update();
}
else {
ui.goto_screen(in_succ_scr);
is_locked = false;
}
}
void Password::access_menu_password() {
authenticate_user(menu_password, menu_advanced_settings);
}
#if ENABLED(PASSWORD_ON_SD_PRINT_MENU)
void Password::media_gatekeeper() {
authenticate_user(menu_media, menu_main);
}
#endif
void Password::start_over() {
ui.goto_previous_screen(); // Goto previous screen, if any
ui.goto_screen(screen_password_entry);
}
void Password::menu_password_report() {
START_SCREEN();
BACK_ITEM(MSG_PASSWORD_SETTINGS);
STATIC_ITEM(MSG_PASSWORD_SET, SS_LEFT, string);
STATIC_ITEM(MSG_REMINDER_SAVE_SETTINGS, SS_LEFT);
END_SCREEN();
}
void Password::set_password_done(const bool with_set/*=true*/) {
is_set = with_set;
value = value_entry;
ui.completion_feedback(true);
ui.goto_screen(menu_password_report);
}
void Password::remove_password() {
string[0] = '0';
string[1] = '\0';
set_password_done(false);
}
//
// Password Menu
//
void Password::menu_password() {
START_MENU();
BACK_ITEM(MSG_ADVANCED_SETTINGS);
SUBMENU(MSG_CHANGE_PASSWORD, screen_set_password);
ACTION_ITEM(MSG_REMOVE_PASSWORD, []{ ui.push_current_screen(); remove_password(); } );
#if ENABLED(EEPROM_SETTINGS)
ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
#endif
END_MENU();
}
#endif // HAS_LCD_MENU && PASSWORD_FEATURE

View File

@@ -0,0 +1,62 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* 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 <https://www.gnu.org/licenses/>.
*
*/
//
// Power Monitor Menu
//
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU && HAS_POWER_MONITOR
#include "menu_item.h"
#include "../../feature/power_monitor.h"
void menu_power_monitor() {
START_MENU();
BACK_ITEM(MSG_MAIN);
#if ENABLED(POWER_MONITOR_CURRENT)
{
bool ena = power_monitor.current_display_enabled();
EDIT_ITEM(bool, MSG_CURRENT, &ena, power_monitor.toggle_current_display);
}
#endif
#if ENABLED(POWER_MONITOR_VOLTAGE)
{
bool ena = power_monitor.voltage_display_enabled();
EDIT_ITEM(bool, MSG_VOLTAGE, &ena, power_monitor.toggle_voltage_display);
}
#endif
#if HAS_POWER_MONITOR_WATTS
{
bool ena = power_monitor.power_display_enabled();
EDIT_ITEM(bool, MSG_POWER, &ena, power_monitor.toggle_power_display);
}
#endif
END_MENU();
}
#endif // HAS_LCD_MENU && HAS_POWER_MONITOR

View File

@@ -0,0 +1,192 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* 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 <https://www.gnu.org/licenses/>.
*
*/
//
// Calibrate Probe offset menu.
//
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(PROBE_OFFSET_WIZARD)
#include "menu_item.h"
#include "menu_addon.h"
#include "../../gcode/queue.h"
#include "../../module/motion.h"
#include "../../module/planner.h"
#include "../../module/probe.h"
#if HAS_LEVELING
#include "../../feature/bedlevel/bedlevel.h"
#endif
// Global storage
float z_offset_backup, calculated_z_offset, z_offset_ref;
#if HAS_LEVELING
bool leveling_was_active;
#endif
inline void z_clearance_move() {
do_z_clearance(
#ifdef Z_AFTER_HOMING
Z_AFTER_HOMING
#elif defined(Z_HOMING_HEIGHT)
Z_HOMING_HEIGHT
#else
10
#endif
);
}
void set_offset_and_go_back(const_float_t z) {
probe.offset.z = z;
SET_SOFT_ENDSTOP_LOOSE(false);
TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active));
ui.goto_previous_screen_no_defer();
}
void _goto_manual_move_z(const_float_t scale) {
ui.manual_move.menu_scale = scale;
ui.goto_screen(lcd_move_z);
}
void probe_offset_wizard_menu() {
START_MENU();
calculated_z_offset = probe.offset.z + current_position.z - z_offset_ref;
if (LCD_HEIGHT >= 4)
STATIC_ITEM(MSG_MOVE_NOZZLE_TO_BED, SS_CENTER|SS_INVERT);
STATIC_ITEM_P(PSTR("Z="), SS_CENTER, ftostr42_52(current_position.z));
STATIC_ITEM(MSG_ZPROBE_ZOFFSET, SS_LEFT, ftostr42_52(calculated_z_offset));
SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move_z( 1); });
SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move_z( 0.1f); });
if ((FINE_MANUAL_MOVE) > 0.0f && (FINE_MANUAL_MOVE) < 0.1f) {
char tmp[20], numstr[10];
// Determine digits needed right of decimal
const uint8_t digs = !UNEAR_ZERO((FINE_MANUAL_MOVE) * 1000 - int((FINE_MANUAL_MOVE) * 1000)) ? 4 :
!UNEAR_ZERO((FINE_MANUAL_MOVE) * 100 - int((FINE_MANUAL_MOVE) * 100)) ? 3 : 2;
sprintf_P(tmp, GET_TEXT(MSG_MOVE_N_MM), dtostrf(FINE_MANUAL_MOVE, 1, digs, numstr));
#if DISABLED(HAS_GRAPHICAL_TFT)
SUBMENU_P(NUL_STR, []{ _goto_manual_move_z(float(FINE_MANUAL_MOVE)); });
MENU_ITEM_ADDON_START(0 + ENABLED(HAS_MARLINUI_HD44780));
lcd_put_u8str(tmp);
MENU_ITEM_ADDON_END();
#else
SUBMENU_P(tmp, []{ _goto_manual_move_z(float(FINE_MANUAL_MOVE)); });
#endif
}
ACTION_ITEM(MSG_BUTTON_DONE, []{
set_offset_and_go_back(calculated_z_offset);
current_position.z = z_offset_ref; // Set Z to z_offset_ref, as we can expect it is at probe height
sync_plan_position();
z_clearance_move(); // Raise Z as if it was homed
});
ACTION_ITEM(MSG_BUTTON_CANCEL, []{
set_offset_and_go_back(z_offset_backup);
// If wizard-homing was done by probe with PROBE_OFFSET_WIZARD_START_Z
#if HOMING_Z_WITH_PROBE && defined(PROBE_OFFSET_WIZARD_START_Z)
set_axis_never_homed(Z_AXIS); // On cancel the Z position needs correction
queue.inject_P(PSTR("G28Z"));
#else // Otherwise do a Z clearance move like after Homing
z_clearance_move();
#endif
});
END_MENU();
}
void prepare_for_probe_offset_wizard() {
#if defined(PROBE_OFFSET_WIZARD_XY_POS) || !HOMING_Z_WITH_PROBE
if (ui.should_draw()) MenuItem_static::draw(1, GET_TEXT(MSG_PROBE_WIZARD_PROBING));
if (ui.wait_for_move) return;
#ifndef PROBE_OFFSET_WIZARD_XY_POS
#define PROBE_OFFSET_WIZARD_XY_POS XY_CENTER
#endif
// Get X and Y from configuration, or use center
constexpr xy_pos_t wizard_pos = PROBE_OFFSET_WIZARD_XY_POS;
// Probe for Z reference
ui.wait_for_move = true;
z_offset_ref = probe.probe_at_point(wizard_pos, PROBE_PT_RAISE, 0, true);
ui.wait_for_move = false;
// Stow the probe, as the last call to probe.probe_at_point(...) left
// the probe deployed if it was successful.
probe.stow();
#else
if (ui.wait_for_move) return;
#endif
// Move Nozzle to Probing/Homing Position
ui.wait_for_move = true;
current_position += probe.offset_xy;
line_to_current_position(MMM_TO_MMS(XY_PROBE_FEEDRATE));
ui.synchronize(GET_TEXT(MSG_PROBE_WIZARD_MOVING));
ui.wait_for_move = false;
SET_SOFT_ENDSTOP_LOOSE(true); // Disable soft endstops for free Z movement
// Go to Calibration Menu
ui.goto_screen(probe_offset_wizard_menu);
ui.defer_status_screen();
}
void goto_probe_offset_wizard() {
ui.defer_status_screen();
set_all_unhomed();
// Store probe.offset.z for Case: Cancel
z_offset_backup = probe.offset.z;
#ifdef PROBE_OFFSET_WIZARD_START_Z
probe.offset.z = PROBE_OFFSET_WIZARD_START_Z;
#endif
// Store Bed-Leveling-State and disable
#if HAS_LEVELING
leveling_was_active = planner.leveling_active;
set_bed_leveling_enabled(false);
#endif
// Home all axes
queue.inject_P(G28_STR);
ui.goto_screen([]{
_lcd_draw_homing();
if (all_axes_homed()) {
z_offset_ref = 0; // Set Z Value for Wizard Position to 0
ui.goto_screen(prepare_for_probe_offset_wizard);
ui.defer_status_screen();
}
});
}
#endif // PROBE_OFFSET_WIZARD

58
Marlin/src/lcd/menu/menu_spindle_laser.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -28,26 +28,56 @@
#if HAS_LCD_MENU && HAS_CUTTER
#include "menu.h"
#include "menu_item.h"
#include "../../feature/spindle_laser.h"
void menu_spindle_laser() {
bool is_enabled = cutter.enabled() && cutter.isReady;
#if ENABLED(SPINDLE_CHANGE_DIR)
bool is_rev = cutter.is_reverse();
#endif
START_MENU();
BACK_ITEM(MSG_MAIN);
if (cutter.enabled()) {
#if ENABLED(SPINDLE_LASER_PWM)
EDIT_ITEM(CUTTER_MENU_TYPE, MSG_CUTTER(POWER), &cutter.power, SPEED_POWER_MIN, SPEED_POWER_MAX);
#endif
ACTION_ITEM(MSG_CUTTER(OFF), cutter.disable);
}
else {
ACTION_ITEM(MSG_CUTTER(ON), cutter.enable_forward);
#if ENABLED(SPINDLE_CHANGE_DIR)
ACTION_ITEM(MSG_SPINDLE_REVERSE, cutter.enable_reverse);
#endif
}
#if ENABLED(SPINDLE_LASER_USE_PWM)
// Change the cutter's "current power" value without turning the cutter on or off
// Power is displayed and set in units and range according to CUTTER_POWER_UNIT
EDIT_ITEM_FAST(CUTTER_MENU_POWER_TYPE, MSG_CUTTER(POWER), &cutter.menuPower,
cutter.mpower_min(), cutter.mpower_max(), cutter.update_from_mpower);
#endif
editable.state = is_enabled;
EDIT_ITEM(bool, MSG_CUTTER(TOGGLE), &is_enabled, []{ if (editable.state) cutter.disable(); else cutter.enable_same_dir(); });
#if ENABLED(AIR_EVACUATION)
bool evac_state = cutter.air_evac_state();
EDIT_ITEM(bool, MSG_CUTTER(EVAC_TOGGLE), &evac_state, cutter.air_evac_toggle);
#endif
#if ENABLED(AIR_ASSIST)
bool air_assist_state = cutter.air_assist_state();
EDIT_ITEM(bool, MSG_CUTTER(ASSIST_TOGGLE), &air_assist_state, cutter.air_assist_toggle);
#endif
#if ENABLED(SPINDLE_CHANGE_DIR)
if (!is_enabled) {
editable.state = is_rev;
ACTION_ITEM_P(is_rev ? GET_TEXT(MSG_CUTTER(REVERSE)) : GET_TEXT(MSG_CUTTER(FORWARD)), []{ cutter.set_reverse(!editable.state); });
}
#endif
#if ENABLED(LASER_FEATURE)
// Setup and fire a test pulse using the current PWM power level for for a duration of test_pulse_min to test_pulse_max ms.
EDIT_ITEM_FAST(CUTTER_MENU_PULSE_TYPE, MSG_LASER_PULSE_MS, &cutter.testPulse, LASER_TEST_PULSE_MIN, LASER_TEST_PULSE_MAX);
ACTION_ITEM(MSG_LASER_FIRE_PULSE, cutter.test_fire_pulse);
#endif
#if BOTH(MARLIN_DEV_MODE, HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY)
EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency);
#endif
END_MENU();
}

371
Marlin/src/lcd/menu/menu_temperature.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -24,135 +24,123 @@
// Temperature Menu
//
#include "../../inc/MarlinConfigPre.h"
#include "../../inc/MarlinConfig.h"
#if HAS_LCD_MENU
#if HAS_LCD_MENU && HAS_TEMPERATURE
#include "menu.h"
#include "menu_item.h"
#include "../../module/temperature.h"
#if FAN_COUNT > 1 || ENABLED(SINGLENOZZLE)
#if HAS_FAN || ENABLED(SINGLENOZZLE)
#include "../../module/motion.h"
#endif
#if ENABLED(SINGLENOZZLE)
#include "../../module/tool_change.h"
#if EITHER(HAS_COOLER, LASER_COOLANT_FLOW_METER)
#include "../../feature/cooler.h"
#endif
// Initialized by settings.load()
int16_t MarlinUI::preheat_hotend_temp[2], MarlinUI::preheat_bed_temp[2];
uint8_t MarlinUI::preheat_fan_speed[2];
#if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
#include "../../module/tool_change.h"
#endif
//
// "Temperature" submenu items
//
void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const uint8_t fan) {
#if HOTENDS
if (temph > 0) thermalManager.setTargetHotend(_MIN(heater_maxtemp[endnum] - 15, temph), endnum);
void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb) {
UNUSED(e); UNUSED(indh); UNUSED(indb);
#if HAS_HOTEND
if (indh >= 0 && ui.material_preset[indh].hotend_temp > 0)
setTargetHotend(_MIN(thermalManager.hotend_max_target(e), ui.material_preset[indh].hotend_temp), e);
#endif
#if HAS_HEATED_BED
if (tempb >= 0) thermalManager.setTargetBed(tempb);
#else
UNUSED(tempb);
if (indb >= 0 && ui.material_preset[indb].bed_temp > 0) setTargetBed(ui.material_preset[indb].bed_temp);
#endif
#if FAN_COUNT > 0
#if FAN_COUNT > 1
thermalManager.set_fan_speed(active_extruder < FAN_COUNT ? active_extruder : 0, fan);
#else
thermalManager.set_fan_speed(0, fan);
#endif
#else
UNUSED(fan);
#if HAS_FAN
if (indh >= 0) {
const uint8_t fan_index = active_extruder < (FAN_COUNT) ? active_extruder : 0;
if (true
#if REDUNDANT_PART_COOLING_FAN
&& fan_index != REDUNDANT_PART_COOLING_FAN
#endif
) set_fan_speed(fan_index, ui.material_preset[indh].fan_speed);
}
#endif
ui.return_to_status();
}
#if HAS_TEMP_HOTEND
inline void _preheat_end(const uint8_t m, const uint8_t e) {
_lcd_preheat(e, ui.preheat_hotend_temp[m], -1, ui.preheat_fan_speed[m]);
}
#if HAS_HEATED_BED
inline void _preheat_both(const uint8_t m, const uint8_t e) {
_lcd_preheat(e, ui.preheat_hotend_temp[m], ui.preheat_bed_temp[m], ui.preheat_fan_speed[m]);
}
#if PREHEAT_COUNT
#if HAS_TEMP_HOTEND
inline void _preheat_end(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); }
void do_preheat_end_m() { _preheat_end(editable.int8, 0); }
#endif
#endif
#if HAS_HEATED_BED
inline void _preheat_bed(const uint8_t m) {
_lcd_preheat(0, 0, ui.preheat_bed_temp[m], ui.preheat_fan_speed[m]);
}
#endif
#if HAS_HEATED_BED
inline void _preheat_bed(const uint8_t m) { thermalManager.lcd_preheat(0, -1, m); }
#endif
#if HAS_COOLER
inline void _precool_laser(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); }
void do_precool_laser_m() { _precool_laser(editable.int8, thermalManager.temp_cooler.target); }
#endif
#if HAS_TEMP_HOTEND && HAS_HEATED_BED
inline void _preheat_both(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, m); }
// Indexed "Preheat ABC" and "Heat Bed" items
#define PREHEAT_ITEMS(M,E) do{ \
ACTION_ITEM_N_S(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_both(M, MenuItemBase::itemIndex); }); \
ACTION_ITEM_N_S(E, ui.get_preheat_label(M), MSG_PREHEAT_M_END_E, []{ _preheat_end(M, MenuItemBase::itemIndex); }); \
}while(0)
#elif HAS_MULTI_HOTEND
// No heated bed, so just indexed "Preheat ABC" items
#define PREHEAT_ITEMS(M,E) ACTION_ITEM_N_S(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_end(M, MenuItemBase::itemIndex); })
#endif
#if HAS_MULTI_HOTEND || HAS_HEATED_BED
// Set editable.int8 to the Material index before entering this menu
// because MenuItemBase::itemIndex will be re-used by PREHEAT_ITEMS
void menu_preheat_m() {
const uint8_t m = editable.int8; // Don't re-use 'editable' in this menu
START_MENU();
BACK_ITEM(MSG_TEMPERATURE);
#if HOTENDS == 1
#if HAS_HEATED_BED
ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, []{ _preheat_both(editable.int8, 0); });
ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M_END, do_preheat_end_m);
#else
ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
#endif
#elif HAS_MULTI_HOTEND
HOTEND_LOOP() PREHEAT_ITEMS(editable.int8, e);
ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M_ALL, []() {
HOTEND_LOOP() thermalManager.setTargetHotend(ui.material_preset[editable.int8].hotend_temp, e);
TERN(HAS_HEATED_BED, _preheat_bed(editable.int8), ui.return_to_status());
});
#endif
#if HAS_HEATED_BED
ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M_BEDONLY, []{ _preheat_bed(editable.int8); });
#endif
END_MENU();
}
#endif // HAS_MULTI_HOTEND || HAS_HEATED_BED
#endif // PREHEAT_COUNT
#if HAS_TEMP_HOTEND || HAS_HEATED_BED
#define _PREHEAT_ITEMS(M,N) do{ \
ACTION_ITEM_N(N, MSG_PREHEAT_##M##_H, []{ _preheat_both(M-1, MenuItemBase::itemIndex); }); \
ACTION_ITEM_N(N, MSG_PREHEAT_##M##_END_E, []{ _preheat_end(M-1, MenuItemBase::itemIndex); }); \
}while(0)
#if HAS_HEATED_BED
#define PREHEAT_ITEMS(M,N) _PREHEAT_ITEMS(M,N)
#else
#define PREHEAT_ITEMS(M,N) \
ACTION_ITEM_N(N, MSG_PREHEAT_##M##_H, []{ _preheat_end(M-1, MenuItemBase::itemIndex); })
#endif
void menu_preheat_m1() {
START_MENU();
BACK_ITEM(MSG_TEMPERATURE);
#if HOTENDS == 1
#if HAS_HEATED_BED
ACTION_ITEM(MSG_PREHEAT_1, []{ _preheat_both(0, 0); });
ACTION_ITEM(MSG_PREHEAT_1_END, []{ _preheat_end(0, 0); });
#else
ACTION_ITEM(MSG_PREHEAT_1, []{ _preheat_end(0, 0); });
#endif
#elif HOTENDS > 1
#if HAS_HEATED_BED
_PREHEAT_ITEMS(1,0);
#endif
LOOP_S_L_N(n, 1, HOTENDS) PREHEAT_ITEMS(1,n);
ACTION_ITEM(MSG_PREHEAT_1_ALL, []() {
#if HAS_HEATED_BED
_preheat_bed(0);
#endif
HOTEND_LOOP() thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], e);
});
#endif // HOTENDS > 1
#if HAS_HEATED_BED
ACTION_ITEM(MSG_PREHEAT_1_BEDONLY, []{ _preheat_bed(0); });
#endif
END_MENU();
}
void menu_preheat_m2() {
START_MENU();
BACK_ITEM(MSG_TEMPERATURE);
#if HOTENDS == 1
#if HAS_HEATED_BED
ACTION_ITEM(MSG_PREHEAT_2, []{ _preheat_both(1, 0); });
ACTION_ITEM(MSG_PREHEAT_2_END, []{ _preheat_end(1, 0); });
#else
ACTION_ITEM(MSG_PREHEAT_2, []{ _preheat_end(1, 0); });
#endif
#elif HOTENDS > 1
#if HAS_HEATED_BED
_PREHEAT_ITEMS(2,0);
#endif
LOOP_S_L_N(n, 1, HOTENDS) PREHEAT_ITEMS(2,n);
ACTION_ITEM(MSG_PREHEAT_2_ALL, []() {
#if HAS_HEATED_BED
_preheat_bed(1);
#endif
HOTEND_LOOP() thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], e);
});
#endif // HOTENDS > 1
#if HAS_HEATED_BED
ACTION_ITEM(MSG_PREHEAT_2_BEDONLY, []{ _preheat_bed(1); });
#endif
END_MENU();
}
void lcd_cooldown() {
thermalManager.zero_fan_speeds();
thermalManager.disable_all_heaters();
@@ -162,6 +150,17 @@ void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb
#endif // HAS_TEMP_HOTEND || HAS_HEATED_BED
void menu_temperature() {
#if HAS_TEMP_HOTEND || HAS_HEATED_BED
bool has_heat = false;
#if HAS_TEMP_HOTEND
HOTEND_LOOP() if (thermalManager.degTargetHotend(HOTEND_INDEX)) { has_heat = true; break; }
#endif
#endif
#if HAS_COOLER
if (thermalManager.temp_cooler.target == 0) thermalManager.temp_cooler.target = COOLER_DEFAULT_TEMP;
#endif
START_MENU();
BACK_ITEM(MSG_MAIN);
@@ -170,128 +169,142 @@ void menu_temperature() {
// Nozzle [1-5]:
//
#if HOTENDS == 1
EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - 15, []{ thermalManager.start_watching_hotend(0); });
#elif HOTENDS > 1
HOTEND_LOOP()
EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, heater_maxtemp[e] - 15, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); });
editable.celsius = thermalManager.temp_hotend[0].target;
EDIT_ITEM_FAST(int3, MSG_NOZZLE, &editable.celsius, 0, thermalManager.hotend_max_target(0), []{ thermalManager.setTargetHotend(editable.celsius, 0); });
#elif HAS_MULTI_HOTEND
HOTEND_LOOP() {
editable.celsius = thermalManager.temp_hotend[e].target;
EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &editable.celsius, 0, thermalManager.hotend_max_target(e), []{ thermalManager.setTargetHotend(editable.celsius, MenuItemBase::itemIndex); });
}
#endif
#if ENABLED(SINGLENOZZLE)
EDIT_ITEM_FAST(uint16_3, MSG_NOZZLE_STANDBY, &singlenozzle_temp[active_extruder ? 0 : 1], 0, HEATER_0_MAXTEMP - 15);
#if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
LOOP_S_L_N(e, 1, EXTRUDERS)
EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_STANDBY, &thermalManager.singlenozzle_temp[e], 0, thermalManager.hotend_max_target(0));
#endif
//
// Bed:
//
#if HAS_HEATED_BED
EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAXTEMP - 10, thermalManager.start_watching_bed);
EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed);
#endif
//
// Chamber:
//
#if HAS_HEATED_CHAMBER
EDIT_ITEM_FAST(int3, MSG_CHAMBER, &thermalManager.temp_chamber.target, 0, CHAMBER_MAXTEMP - 10, thermalManager.start_watching_chamber);
EDIT_ITEM_FAST(int3, MSG_CHAMBER, &thermalManager.temp_chamber.target, 0, CHAMBER_MAX_TARGET, thermalManager.start_watching_chamber);
#endif
//
// Cooler:
//
#if HAS_COOLER
bool cstate = cooler.enabled;
EDIT_ITEM(bool, MSG_COOLER_TOGGLE, &cstate, cooler.toggle);
EDIT_ITEM_FAST(int3, MSG_COOLER, &thermalManager.temp_cooler.target, COOLER_MIN_TARGET, COOLER_MAX_TARGET, thermalManager.start_watching_cooler);
#endif
//
// Flow Meter Safety Shutdown:
//
#if ENABLED(FLOWMETER_SAFETY)
bool fstate = cooler.flowsafety_enabled;
EDIT_ITEM(bool, MSG_FLOWMETER_SAFETY, &fstate, cooler.flowsafety_toggle);
#endif
//
// Fan Speed:
//
#if FAN_COUNT > 0
#if HAS_FAN
auto on_fan_update = []{
thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8);
};
#if HAS_FAN1 || HAS_FAN2 || HAS_FAN3 || HAS_FAN4 || HAS_FAN5 || HAS_FAN6 || HAS_FAN7
auto fan_edit_items = [&](const uint8_t f) {
editable.uint8 = thermalManager.fan_speed[f];
EDIT_ITEM_FAST_N(percent, f, MSG_FAN_SPEED_N, &editable.uint8, 0, 255, on_fan_update);
#if ENABLED(EXTRA_FAN_SPEED)
EDIT_ITEM_FAST_N(percent, f, MSG_EXTRA_FAN_SPEED_N, &thermalManager.new_fan_speed[f], 3, 255);
#endif
};
#endif
#define SNFAN(N) (ENABLED(SINGLENOZZLE) && !HAS_FAN##N && EXTRUDERS > N)
#if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
auto singlenozzle_item = [&](const uint8_t f) {
editable.uint8 = thermalManager.fan_speed[f];
EDIT_ITEM_FAST_N(percent, f, MSG_STORED_FAN_N, &editable.uint8, 0, 255, on_fan_update);
};
#endif
DEFINE_SINGLENOZZLE_ITEM();
#if HAS_FAN0
editable.uint8 = thermalManager.fan_speed[0];
EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_FAN_SPEED, &editable.uint8, 0, 255, on_fan_update);
#if ENABLED(EXTRA_FAN_SPEED)
EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_EXTRA_FAN_SPEED, &thermalManager.new_fan_speed[0], 3, 255);
#endif
_FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED);
#endif
#if HAS_FAN1
fan_edit_items(1);
#if HAS_FAN1 && REDUNDANT_PART_COOLING_FAN != 1
FAN_EDIT_ITEMS(1);
#elif SNFAN(1)
singlenozzle_item(1);
#endif
#if HAS_FAN2
fan_edit_items(2);
#if HAS_FAN2 && REDUNDANT_PART_COOLING_FAN != 2
FAN_EDIT_ITEMS(2);
#elif SNFAN(2)
singlenozzle_item(1);
singlenozzle_item(2);
#endif
#if HAS_FAN3
fan_edit_items(3);
#if HAS_FAN3 && REDUNDANT_PART_COOLING_FAN != 3
FAN_EDIT_ITEMS(3);
#elif SNFAN(3)
singlenozzle_item(1);
singlenozzle_item(3);
#endif
#if HAS_FAN4
fan_edit_items(4);
#if HAS_FAN4 && REDUNDANT_PART_COOLING_FAN != 4
FAN_EDIT_ITEMS(4);
#elif SNFAN(4)
singlenozzle_item(1);
singlenozzle_item(4);
#endif
#if HAS_FAN5
fan_edit_items(5);
#if HAS_FAN5 && REDUNDANT_PART_COOLING_FAN != 5
FAN_EDIT_ITEMS(5);
#elif SNFAN(5)
singlenozzle_item(1);
singlenozzle_item(5);
#endif
#if HAS_FAN6
fan_edit_items(6);
#if HAS_FAN6 && REDUNDANT_PART_COOLING_FAN != 6
FAN_EDIT_ITEMS(6);
#elif SNFAN(6)
singlenozzle_item(1);
singlenozzle_item(6);
#endif
#if HAS_FAN7
fan_edit_items(7);
#if HAS_FAN7 && REDUNDANT_PART_COOLING_FAN != 7
FAN_EDIT_ITEMS(7);
#elif SNFAN(7)
singlenozzle_item(1);
singlenozzle_item(7);
#endif
#endif // FAN_COUNT > 0
#if HAS_TEMP_HOTEND
#endif // HAS_FAN
#if PREHEAT_COUNT
//
// Preheat for Material 1 and 2
// Preheat for all Materials
//
#if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_4 != 0 || TEMP_SENSOR_5 != 0 || TEMP_SENSOR_6 != 0 || TEMP_SENSOR_7 != 0 || HAS_HEATED_BED
SUBMENU(MSG_PREHEAT_1, menu_preheat_m1);
SUBMENU(MSG_PREHEAT_2, menu_preheat_m2);
#else
ACTION_ITEM(MSG_PREHEAT_1, []{ _preheat_end(0, 0); });
ACTION_ITEM(MSG_PREHEAT_2, []{ _preheat_end(1, 0); });
#endif
LOOP_L_N(m, PREHEAT_COUNT) {
editable.int8 = m;
#if HOTENDS > 1 || HAS_HEATED_BED
SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m);
#elif HAS_HOTEND
ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
#endif
}
#endif
#if HAS_TEMP_HOTEND || HAS_HEATED_BED
//
// Cooldown
//
bool has_heat = false;
HOTEND_LOOP() if (thermalManager.temp_hotend[HOTEND_INDEX].target) { has_heat = true; break; }
#if HAS_TEMP_BED
if (thermalManager.temp_bed.target) has_heat = true;
#endif
if (TERN0(HAS_HEATED_BED, thermalManager.degTargetBed())) has_heat = true;
if (has_heat) ACTION_ITEM(MSG_COOLDOWN, lcd_cooldown);
#endif // HAS_TEMP_HOTEND
#endif
END_MENU();
}
#endif // HAS_LCD_MENU
#if ENABLED(PREHEAT_SHORTCUT_MENU_ITEM)
void menu_preheat_only() {
START_MENU();
BACK_ITEM(MSG_MAIN);
LOOP_L_N(m, PREHEAT_COUNT) {
editable.int8 = m;
#if HOTENDS > 1 || HAS_HEATED_BED
SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m);
#else
ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
#endif
}
END_MENU();
}
#endif
#endif // HAS_LCD_MENU && HAS_TEMPERATURE

171
Marlin/src/lcd/menu/menu_tmc.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -26,9 +26,9 @@
#include "../../inc/MarlinConfigPre.h"
#if HAS_TRINAMIC_CONFIG && HAS_LCD_MENU
#if HAS_LCD_MENU && HAS_TRINAMIC_CONFIG
#include "menu.h"
#include "menu_item.h"
#include "../../module/stepper/indirection.h"
#include "../../feature/tmc_util.h"
@@ -95,54 +95,22 @@ void menu_tmc_current() {
void menu_tmc_hybrid_thrs() {
START_MENU();
BACK_ITEM(MSG_TMC_DRIVERS);
#if AXIS_HAS_STEALTHCHOP(X)
TMC_EDIT_STORED_HYBRID_THRS(X, STR_X);
#endif
#if AXIS_HAS_STEALTHCHOP(Y)
TMC_EDIT_STORED_HYBRID_THRS(Y, STR_Y);
#endif
#if AXIS_HAS_STEALTHCHOP(Z)
TMC_EDIT_STORED_HYBRID_THRS(Z, STR_Z);
#endif
#if AXIS_HAS_STEALTHCHOP(X2)
TMC_EDIT_STORED_HYBRID_THRS(X2, STR_X2);
#endif
#if AXIS_HAS_STEALTHCHOP(Y2)
TMC_EDIT_STORED_HYBRID_THRS(Y2, STR_Y2);
#endif
#if AXIS_HAS_STEALTHCHOP(Z2)
TMC_EDIT_STORED_HYBRID_THRS(Z2, STR_Z2);
#endif
#if AXIS_HAS_STEALTHCHOP(Z3)
TMC_EDIT_STORED_HYBRID_THRS(Z3, STR_Z3);
#endif
#if AXIS_HAS_STEALTHCHOP(Z4)
TMC_EDIT_STORED_HYBRID_THRS(Z4, STR_Z4);
#endif
#if AXIS_HAS_STEALTHCHOP(E0)
TMC_EDIT_STORED_HYBRID_THRS(E0, LCD_STR_E0);
#endif
#if AXIS_HAS_STEALTHCHOP(E1)
TMC_EDIT_STORED_HYBRID_THRS(E1, LCD_STR_E1);
#endif
#if AXIS_HAS_STEALTHCHOP(E2)
TMC_EDIT_STORED_HYBRID_THRS(E2, LCD_STR_E2);
#endif
#if AXIS_HAS_STEALTHCHOP(E3)
TMC_EDIT_STORED_HYBRID_THRS(E3, LCD_STR_E3);
#endif
#if AXIS_HAS_STEALTHCHOP(E4)
TMC_EDIT_STORED_HYBRID_THRS(E4, LCD_STR_E4);
#endif
#if AXIS_HAS_STEALTHCHOP(E5)
TMC_EDIT_STORED_HYBRID_THRS(E5, LCD_STR_E5);
#endif
#if AXIS_HAS_STEALTHCHOP(E6)
TMC_EDIT_STORED_HYBRID_THRS(E6, LCD_STR_E6);
#endif
#if AXIS_HAS_STEALTHCHOP(E7)
TMC_EDIT_STORED_HYBRID_THRS(E7, LCD_STR_E7);
#endif
TERN_(X_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(X, STR_X));
TERN_(Y_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Y, STR_Y));
TERN_(Z_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z, STR_Z));
TERN_(X2_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(X2, STR_X2));
TERN_(Y2_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Y2, STR_Y2));
TERN_(Z2_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z2, STR_Z2));
TERN_(Z3_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z3, STR_Z3));
TERN_(Z4_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z4, STR_Z4));
TERN_(E0_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E0, LCD_STR_E0));
TERN_(E1_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E1, LCD_STR_E1));
TERN_(E2_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E2, LCD_STR_E2));
TERN_(E3_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E3, LCD_STR_E3));
TERN_(E4_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E4, LCD_STR_E4));
TERN_(E5_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E5, LCD_STR_E5));
TERN_(E6_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E6, LCD_STR_E6));
TERN_(E7_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E7, LCD_STR_E7));
END_MENU();
}
@@ -155,18 +123,17 @@ void menu_tmc_current() {
void menu_tmc_homing_thrs() {
START_MENU();
BACK_ITEM(MSG_TMC_DRIVERS);
#if X_SENSORLESS
TMC_EDIT_STORED_SGT(X);
#endif
#if X2_SENSORLESS
TMC_EDIT_STORED_SGT(X2);
#endif
#if Y_SENSORLESS
TMC_EDIT_STORED_SGT(Y);
#endif
#if Z_SENSORLESS
TMC_EDIT_STORED_SGT(Z);
#endif
TERN_( X_SENSORLESS, TMC_EDIT_STORED_SGT(X));
TERN_(X2_SENSORLESS, TMC_EDIT_STORED_SGT(X2));
TERN_( Y_SENSORLESS, TMC_EDIT_STORED_SGT(Y));
TERN_(Y2_SENSORLESS, TMC_EDIT_STORED_SGT(Y2));
TERN_( Z_SENSORLESS, TMC_EDIT_STORED_SGT(Z));
TERN_(Z2_SENSORLESS, TMC_EDIT_STORED_SGT(Z2));
TERN_(Z3_SENSORLESS, TMC_EDIT_STORED_SGT(Z3));
TERN_(Z4_SENSORLESS, TMC_EDIT_STORED_SGT(Z4));
TERN_( I_SENSORLESS, TMC_EDIT_STORED_SGT(I));
TERN_( J_SENSORLESS, TMC_EDIT_STORED_SGT(J));
TERN_( K_SENSORLESS, TMC_EDIT_STORED_SGT(K));
END_MENU();
}
@@ -180,54 +147,22 @@ void menu_tmc_current() {
START_MENU();
STATIC_ITEM(MSG_TMC_STEALTH_ENABLED);
BACK_ITEM(MSG_TMC_DRIVERS);
#if AXIS_HAS_STEALTHCHOP(X)
TMC_EDIT_STEP_MODE(X, STR_X);
#endif
#if AXIS_HAS_STEALTHCHOP(Y)
TMC_EDIT_STEP_MODE(Y, STR_Y);
#endif
#if AXIS_HAS_STEALTHCHOP(Z)
TMC_EDIT_STEP_MODE(Z, STR_Z);
#endif
#if AXIS_HAS_STEALTHCHOP(X2)
TMC_EDIT_STEP_MODE(X2, STR_X2);
#endif
#if AXIS_HAS_STEALTHCHOP(Y2)
TMC_EDIT_STEP_MODE(Y2, STR_Y2);
#endif
#if AXIS_HAS_STEALTHCHOP(Z2)
TMC_EDIT_STEP_MODE(Z2, STR_Z2);
#endif
#if AXIS_HAS_STEALTHCHOP(Z3)
TMC_EDIT_STEP_MODE(Z3, STR_Z3);
#endif
#if AXIS_HAS_STEALTHCHOP(Z4)
TMC_EDIT_STEP_MODE(Z4, STR_Z4);
#endif
#if AXIS_HAS_STEALTHCHOP(E0)
TMC_EDIT_STEP_MODE(E0, LCD_STR_E0);
#endif
#if AXIS_HAS_STEALTHCHOP(E1)
TMC_EDIT_STEP_MODE(E1, LCD_STR_E1);
#endif
#if AXIS_HAS_STEALTHCHOP(E2)
TMC_EDIT_STEP_MODE(E2, LCD_STR_E2);
#endif
#if AXIS_HAS_STEALTHCHOP(E3)
TMC_EDIT_STEP_MODE(E3, LCD_STR_E3);
#endif
#if AXIS_HAS_STEALTHCHOP(E4)
TMC_EDIT_STEP_MODE(E4, LCD_STR_E4);
#endif
#if AXIS_HAS_STEALTHCHOP(E5)
TMC_EDIT_STEP_MODE(E5, LCD_STR_E5);
#endif
#if AXIS_HAS_STEALTHCHOP(E6)
TMC_EDIT_STEP_MODE(E6, LCD_STR_E6);
#endif
#if AXIS_HAS_STEALTHCHOP(E7)
TMC_EDIT_STEP_MODE(E7, LCD_STR_E7);
#endif
TERN_( X_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(X, STR_X));
TERN_(X2_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(X2, STR_X2));
TERN_( Y_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(Y, STR_Y));
TERN_(Y2_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(Y2, STR_Y2));
TERN_( Z_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(Z, STR_Z));
TERN_(Z2_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(Z2, STR_Z2));
TERN_(Z3_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(Z3, STR_Z3));
TERN_(Z4_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(Z4, STR_Z4));
TERN_(E0_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E0, LCD_STR_E0));
TERN_(E1_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E1, LCD_STR_E1));
TERN_(E2_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E2, LCD_STR_E2));
TERN_(E3_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E3, LCD_STR_E3));
TERN_(E4_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E4, LCD_STR_E4));
TERN_(E5_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E5, LCD_STR_E5));
TERN_(E6_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E6, LCD_STR_E6));
TERN_(E7_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E7, LCD_STR_E7));
END_MENU();
}
@@ -235,17 +170,11 @@ void menu_tmc_current() {
void menu_tmc() {
START_MENU();
BACK_ITEM(MSG_CONTROL);
BACK_ITEM(MSG_ADVANCED_SETTINGS);
SUBMENU(MSG_TMC_CURRENT, menu_tmc_current);
#if ENABLED(HYBRID_THRESHOLD)
SUBMENU(MSG_TMC_HYBRID_THRS, menu_tmc_hybrid_thrs);
#endif
#if ENABLED(SENSORLESS_HOMING)
SUBMENU(MSG_TMC_HOMING_THRS, menu_tmc_homing_thrs);
#endif
#if HAS_STEALTHCHOP
SUBMENU(MSG_TMC_STEPPING_MODE, menu_tmc_step_mode);
#endif
TERN_(HYBRID_THRESHOLD, SUBMENU(MSG_TMC_HYBRID_THRS, menu_tmc_hybrid_thrs));
TERN_(SENSORLESS_HOMING, SUBMENU(MSG_TMC_HOMING_THRS, menu_tmc_homing_thrs));
TERN_(HAS_STEALTHCHOP, SUBMENU(MSG_TMC_STEPPING_MODE, menu_tmc_step_mode));
END_MENU();
}

View File

@@ -0,0 +1,36 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* 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 <https://www.gnu.org/licenses/>.
*
*/
#include "../../inc/MarlinConfigPre.h"
#if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION)
#include "menu_item.h"
#include "../marlinui.h"
void touch_screen_calibration() {
ui.touch_calibration_screen();
}
#endif // TOUCH_SCREEN_CALIBRATION

View File

@@ -0,0 +1,108 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* 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 <https://www.gnu.org/licenses/>.
*
*/
//
// Bed Tramming Wizard
//
#include "../../inc/MarlinConfigPre.h"
#if BOTH(HAS_LCD_MENU, ASSISTED_TRAMMING_WIZARD)
#include "menu_item.h"
#include "../../feature/tramming.h"
#include "../../module/motion.h"
#include "../../module/probe.h"
#include "../../gcode/queue.h"
//#define DEBUG_OUT 1
#include "../../core/debug_out.h"
static float z_measured[G35_PROBE_COUNT];
static bool z_isvalid[G35_PROBE_COUNT];
static uint8_t tram_index = 0;
static int8_t reference_index; // = 0
#if HAS_LEVELING
#include "../../feature/bedlevel/bedlevel.h"
#endif
static bool probe_single_point() {
do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES));
// Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety
const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], TERN(BLTOUCH_HS_MODE, PROBE_PT_STOW, PROBE_PT_RAISE), 0, true);
z_measured[tram_index] = z_probed_height;
if (reference_index < 0) reference_index = tram_index;
move_to_tramming_wait_pos();
DEBUG_ECHOLNPGM("probe_single_point(", tram_index, ") = ", z_probed_height, "mm");
return (z_isvalid[tram_index] = !isnan(z_probed_height));
}
static void _menu_single_probe() {
DEBUG_ECHOLNPGM("Screen: single probe screen Arg:", tram_index);
START_MENU();
STATIC_ITEM(MSG_BED_TRAMMING, SS_LEFT);
STATIC_ITEM(MSG_LAST_VALUE_SP, SS_LEFT, z_isvalid[tram_index] ? ftostr42_52(z_measured[reference_index] - z_measured[tram_index]) : "---");
ACTION_ITEM(MSG_UBL_BC_INSERT2, []{ if (probe_single_point()) ui.refresh(); });
ACTION_ITEM(MSG_BUTTON_DONE, []{ ui.goto_previous_screen(); });
END_MENU();
}
static void tramming_wizard_menu() {
START_MENU();
STATIC_ITEM(MSG_SELECT_ORIGIN);
// Draw a menu item for each tramming point
for (tram_index = 0; tram_index < G35_PROBE_COUNT; tram_index++)
SUBMENU_P((char*)pgm_read_ptr(&tramming_point_name[tram_index]), _menu_single_probe);
ACTION_ITEM(MSG_BUTTON_DONE, []{
probe.stow(); // Stow before exiting Tramming Wizard
ui.goto_previous_screen_no_defer();
});
END_MENU();
}
// Init the wizard and enter the submenu
void goto_tramming_wizard() {
DEBUG_ECHOLNPGM("Screen: goto_tramming_wizard", 1);
ui.defer_status_screen();
// Initialize measured point flags
ZERO(z_isvalid);
reference_index = -1;
// Inject G28, wait for homing to complete,
set_all_unhomed();
queue.inject_P(TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR));
ui.goto_screen([]{
_lcd_draw_homing();
if (all_axes_homed())
ui.goto_screen(tramming_wizard_menu);
});
}
#endif // HAS_LCD_MENU && ASSISTED_TRAMMING_WIZARD

129
Marlin/src/lcd/menu/menu_tune.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -28,26 +28,26 @@
#if HAS_LCD_MENU
#include "menu.h"
#include "menu_item.h"
#include "../../module/motion.h"
#include "../../module/planner.h"
#include "../../module/temperature.h"
#include "../../MarlinCore.h"
#if HAS_LEVELING
#include "../../feature/bedlevel/bedlevel.h"
#if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
#include "../../module/tool_change.h"
#endif
#if ENABLED(SINGLENOZZLE)
#include "../../module/tool_change.h"
#if HAS_LEVELING
#include "../../feature/bedlevel/bedlevel.h"
#endif
#if ENABLED(BABYSTEPPING)
#include "../../feature/babystep.h"
#include "../lcdprint.h"
#if HAS_GRAPHICAL_LCD
#include "../dogm/ultralcd_DOGM.h"
#if HAS_MARLINUI_U8GLIB
#include "../dogm/marlinui_DOGM.h"
#endif
void _lcd_babystep(const AxisEnum axis, PGM_P const msg) {
@@ -55,33 +55,33 @@
if (ui.encoderPosition) {
const int16_t steps = int16_t(ui.encoderPosition) * (
#if ENABLED(BABYSTEP_XY)
axis != Z_AXIS ? BABYSTEP_MULTIPLICATOR_XY :
axis == X_AXIS ? BABYSTEP_SIZE_X :
axis == Y_AXIS ? BABYSTEP_SIZE_Y :
#endif
BABYSTEP_MULTIPLICATOR_Z
BABYSTEP_SIZE_Z
);
ui.encoderPosition = 0;
ui.refresh(LCDVIEW_REDRAW_NOW);
babystep.add_steps(axis, steps);
}
if (ui.should_draw()) {
const float spm = planner.steps_to_mm[axis];
MenuEditItemBase::draw_edit_screen(msg, BABYSTEP_TO_STR(spm * babystep.accum));
const float mps = planner.mm_per_step[axis];
MenuEditItemBase::draw_edit_screen(msg, BABYSTEP_TO_STR(mps * babystep.accum));
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
const bool in_view = (true
#if HAS_GRAPHICAL_LCD
&& PAGE_CONTAINS(LCD_PIXEL_HEIGHT - MENU_FONT_HEIGHT, LCD_PIXEL_HEIGHT - 1)
#endif
);
const bool in_view = TERN1(HAS_MARLINUI_U8GLIB, PAGE_CONTAINS(LCD_PIXEL_HEIGHT - MENU_FONT_HEIGHT, LCD_PIXEL_HEIGHT - 1));
if (in_view) {
#if HAS_GRAPHICAL_LCD
ui.set_font(FONT_MENU);
lcd_moveto(0, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT);
TERN_(HAS_MARLINUI_U8GLIB, ui.set_font(FONT_MENU));
#if ENABLED(TFT_COLOR_UI)
lcd_moveto(4, 3);
lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL));
lcd_put_wchar(':');
lcd_moveto(10, 3);
#else
lcd_moveto(0, LCD_HEIGHT - 1);
lcd_moveto(0, TERN(HAS_MARLINUI_U8GLIB, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT, LCD_HEIGHT - 1));
lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL));
lcd_put_wchar(':');
#endif
lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL));
lcd_put_wchar(':');
lcd_put_u8str(BABYSTEP_TO_STR(spm * babystep.axis_total[BS_TOTAL_IND(axis)]));
lcd_put_u8str(BABYSTEP_TO_STR(mps * babystep.axis_total[BS_TOTAL_IND(axis)]));
}
#endif
}
@@ -126,102 +126,79 @@ void menu_tune() {
// Nozzle [1-4]:
//
#if HOTENDS == 1
EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - 15, []{ thermalManager.start_watching_hotend(0); });
#elif HOTENDS > 1
EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, thermalManager.hotend_max_target(0), []{ thermalManager.start_watching_hotend(0); });
#elif HAS_MULTI_HOTEND
HOTEND_LOOP()
EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, heater_maxtemp[e] - 15, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); });
EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, thermalManager.hotend_max_target(e), []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); });
#endif
#if ENABLED(SINGLENOZZLE)
EDIT_ITEM_FAST(uint16_3, MSG_NOZZLE_STANDBY, &singlenozzle_temp[active_extruder ? 0 : 1], 0, HEATER_0_MAXTEMP - 15);
#if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
LOOP_S_L_N(e, 1, EXTRUDERS)
EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_STANDBY, &thermalManager.singlenozzle_temp[e], 0, thermalManager.hotend_max_target(0));
#endif
//
// Bed:
//
#if HAS_HEATED_BED
EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAXTEMP - 10, thermalManager.start_watching_bed);
EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed);
#endif
//
// Fan Speed:
//
#if FAN_COUNT > 0
#if HAS_FAN
auto on_fan_update = []{
thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8);
};
#if HAS_FAN1 || HAS_FAN2 || HAS_FAN3 || HAS_FAN4 || HAS_FAN5 || HAS_FAN6 || HAS_FAN7
auto fan_edit_items = [&](const uint8_t f) {
editable.uint8 = thermalManager.fan_speed[f];
EDIT_ITEM_FAST_N(percent, f, MSG_FAN_SPEED_N, &editable.uint8, 0, 255, on_fan_update);
#if ENABLED(EXTRA_FAN_SPEED)
EDIT_ITEM_FAST_N(percent, f, MSG_EXTRA_FAN_SPEED_N, &thermalManager.new_fan_speed[f], 3, 255);
#endif
};
#endif
#define SNFAN(N) (ENABLED(SINGLENOZZLE) && !HAS_FAN##N && EXTRUDERS > N)
#if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
auto singlenozzle_item = [&](const uint8_t f) {
editable.uint8 = thermalManager.fan_speed[f];
EDIT_ITEM_FAST_N(percent, f, MSG_STORED_FAN_N, &editable.uint8, 0, 255, on_fan_update);
};
#endif
DEFINE_SINGLENOZZLE_ITEM();
#if HAS_FAN0
editable.uint8 = thermalManager.fan_speed[0];
EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_FAN_SPEED, &editable.uint8, 0, 255, on_fan_update);
#if ENABLED(EXTRA_FAN_SPEED)
EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_EXTRA_FAN_SPEED, &thermalManager.new_fan_speed[0], 3, 255);
#endif
_FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED);
#endif
#if HAS_FAN1
fan_edit_items(1);
FAN_EDIT_ITEMS(1);
#elif SNFAN(1)
singlenozzle_item(1);
#endif
#if HAS_FAN2
fan_edit_items(2);
FAN_EDIT_ITEMS(2);
#elif SNFAN(2)
singlenozzle_item(1);
singlenozzle_item(2);
#endif
#if HAS_FAN3
fan_edit_items(3);
FAN_EDIT_ITEMS(3);
#elif SNFAN(3)
singlenozzle_item(1);
singlenozzle_item(3);
#endif
#if HAS_FAN4
fan_edit_items(4);
FAN_EDIT_ITEMS(4);
#elif SNFAN(4)
singlenozzle_item(1);
singlenozzle_item(4);
#endif
#if HAS_FAN5
fan_edit_items(5);
FAN_EDIT_ITEMS(5);
#elif SNFAN(5)
singlenozzle_item(1);
singlenozzle_item(5);
#endif
#if HAS_FAN6
fan_edit_items(6);
FAN_EDIT_ITEMS(6);
#elif SNFAN(6)
singlenozzle_item(1);
singlenozzle_item(6);
#endif
#if HAS_FAN7
fan_edit_items(7);
FAN_EDIT_ITEMS(7);
#elif SNFAN(7)
singlenozzle_item(1);
singlenozzle_item(7);
#endif
#endif // FAN_COUNT > 0
#endif // HAS_FAN
//
// Flow:
//
#if EXTRUDERS
#if HAS_EXTRUDERS
EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); });
// Flow En:
#if EXTRUDERS > 1
#if HAS_MULTI_EXTRUDER
LOOP_L_N(n, EXTRUDERS)
EDIT_ITEM_N(int3, n, MSG_FLOW_N, &planner.flow_percentage[n], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); });
#endif
@@ -232,10 +209,10 @@ void menu_tune() {
//
#if ENABLED(LIN_ADVANCE) && DISABLED(SLIM_LCD_MENUS)
#if EXTRUDERS == 1
EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
#elif EXTRUDERS > 1
EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10);
#elif HAS_MULTI_EXTRUDER
LOOP_L_N(n, EXTRUDERS)
EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 10);
#endif
#endif

634
Marlin/src/lcd/menu/menu_ubl.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -26,95 +26,94 @@
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU && ENABLED(AUTO_BED_LEVELING_UBL)
#if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL)
#include "menu.h"
#include "menu_item.h"
#include "../../gcode/gcode.h"
#include "../../gcode/queue.h"
#include "../../module/motion.h"
#include "../../module/planner.h"
#include "../../module/configuration_store.h"
#include "../../module/settings.h"
#include "../../feature/bedlevel/bedlevel.h"
static int16_t ubl_storage_slot = 0,
custom_hotend_temp = 190,
custom_hotend_temp = 150,
side_points = 3,
ubl_fillin_amount = 5,
ubl_height_amount = 1;
static uint8_t n_edit_pts = 1, x_plot = 0, y_plot = 0;
static uint8_t n_edit_pts = 1;
static int8_t x_plot = 0, y_plot = 0; // May be negative during move
#if HAS_HEATED_BED
static int16_t custom_bed_temp = 50;
#endif
float mesh_edit_value, mesh_edit_accumulator; // We round mesh_edit_value to 2.5 decimal places. So we keep a
// separate value that doesn't lose precision.
static int16_t ubl_encoderPosition = 0;
float mesh_edit_accumulator; // Rounded to 2.5 decimal places on use
static void _lcd_mesh_fine_tune(PGM_P msg) {
inline float rounded_mesh_value() {
const int32_t rounded = int32_t(mesh_edit_accumulator * 1000);
return float(rounded - (rounded % 5L)) / 1000;
}
/**
* This screen displays the temporary mesh value and updates it based on encoder
* movement. While this screen is active ubl.fine_tune_mesh sits in a loop getting
* the current value via ubl_mesh_value, moves the Z axis, and updates the mesh
* value until the encoder button is pressed.
*
* - Update the 'mesh_edit_accumulator' from encoder rotation
* - Draw the mesh value (with draw_edit_screen)
* - Draw the graphical overlay, if enabled.
* - Update the 'refresh' state according to the display type
*/
void _lcd_mesh_fine_tune(PGM_P const msg) {
constexpr float mesh_edit_step = 1.0f / 200.0f;
ui.defer_status_screen();
if (ubl.encoder_diff) {
ubl_encoderPosition = (ubl.encoder_diff > 0) ? 1 : -1;
mesh_edit_accumulator += TERN(IS_TFTGLCD_PANEL,
ubl.encoder_diff * mesh_edit_step / ENCODER_PULSES_PER_STEP,
ubl.encoder_diff > 0 ? mesh_edit_step : -mesh_edit_step
);
ubl.encoder_diff = 0;
mesh_edit_accumulator += float(ubl_encoderPosition) * 0.005f * 0.5f;
mesh_edit_value = mesh_edit_accumulator;
ui.encoderPosition = 0;
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
const int32_t rounded = (int32_t)(mesh_edit_value * 1000);
mesh_edit_value = float(rounded - (rounded % 5L)) / 1000;
IF_DISABLED(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT));
}
TERN_(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT));
if (ui.should_draw()) {
MenuEditItemBase::draw_edit_screen(msg, ftostr43sign(mesh_edit_value));
#if ENABLED(MESH_EDIT_GFX_OVERLAY)
_lcd_zoffset_overlay_gfx(mesh_edit_value);
#endif
const float rounded_f = rounded_mesh_value();
MenuEditItemBase::draw_edit_screen(msg, ftostr43sign(rounded_f));
TERN_(MESH_EDIT_GFX_OVERLAY, _lcd_zoffset_overlay_gfx(rounded_f));
TERN_(HAS_GRAPHICAL_TFT, ui.refresh(LCDVIEW_NONE));
}
}
void _lcd_mesh_edit_NOP() {
ui.defer_status_screen();
//
// Init mesh editing and go to the fine tuning screen (ubl.fine_tune_mesh)
// To capture encoder events UBL will also call ui.capture and ui.release.
//
void MarlinUI::ubl_mesh_edit_start(const_float_t initial) {
TERN_(HAS_GRAPHICAL_TFT, clear_lcd());
mesh_edit_accumulator = initial;
goto_screen([]{ _lcd_mesh_fine_tune(GET_TEXT(MSG_MESH_EDIT_Z)); });
}
float lcd_mesh_edit() {
ui.goto_screen(_lcd_mesh_edit_NOP);
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
_lcd_mesh_fine_tune(GET_TEXT(MSG_MESH_EDITOR));
return mesh_edit_value;
}
void lcd_mesh_edit_setup(const float &initial) {
mesh_edit_value = mesh_edit_accumulator = initial;
ui.goto_screen(_lcd_mesh_edit_NOP);
}
void _lcd_z_offset_edit() {
_lcd_mesh_fine_tune(GET_TEXT(MSG_UBL_Z_OFFSET));
}
float lcd_z_offset_edit() {
ui.goto_screen(_lcd_z_offset_edit);
return mesh_edit_value;
}
void lcd_z_offset_edit_setup(const float &initial) {
mesh_edit_value = mesh_edit_accumulator = initial;
ui.goto_screen(_lcd_z_offset_edit);
}
//
// Get the mesh value within a Z adjustment loop (ubl.fine_tune_mesh)
//
float MarlinUI::ubl_mesh_value() { return rounded_mesh_value(); }
/**
* UBL Build Custom Mesh Command
*/
void _lcd_ubl_build_custom_mesh() {
char ubl_lcd_gcode[20];
queue.inject_P(G28_STR);
char ubl_lcd_gcode[64];
#if HAS_HEATED_BED
sprintf_P(ubl_lcd_gcode, PSTR("M190 S%i"), custom_bed_temp);
lcd_enqueue_one_now(ubl_lcd_gcode);
sprintf_P(ubl_lcd_gcode, PSTR("G28\nM190 S%i\nM109 S%i\nG29 P1"), custom_bed_temp, custom_hotend_temp);
#else
sprintf_P(ubl_lcd_gcode, PSTR("G28\nM109 S%i\nG29 P1"), custom_hotend_temp);
#endif
sprintf_P(ubl_lcd_gcode, PSTR("M109 S%i"), custom_hotend_temp);
lcd_enqueue_one_now(ubl_lcd_gcode);
queue.inject_P(PSTR("G29 P1"));
queue.inject(ubl_lcd_gcode);
}
/**
@@ -128,9 +127,11 @@ void _lcd_ubl_build_custom_mesh() {
void _lcd_ubl_custom_mesh() {
START_MENU();
BACK_ITEM(MSG_UBL_BUILD_MESH_MENU);
EDIT_ITEM(int3, MSG_UBL_HOTEND_TEMP_CUSTOM, &custom_hotend_temp, EXTRUDE_MINTEMP, (HEATER_0_MAXTEMP - 10));
#if HAS_HOTEND
EDIT_ITEM(int3, MSG_UBL_HOTEND_TEMP_CUSTOM, &custom_hotend_temp, EXTRUDE_MINTEMP, thermalManager.hotend_max_target(0));
#endif
#if HAS_HEATED_BED
EDIT_ITEM(int3, MSG_UBL_BED_TEMP_CUSTOM, &custom_bed_temp, BED_MINTEMP, (BED_MAXTEMP - 10));
EDIT_ITEM(int3, MSG_UBL_BED_TEMP_CUSTOM, &custom_bed_temp, BED_MINTEMP, BED_MAX_TARGET);
#endif
ACTION_ITEM(MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_build_custom_mesh);
END_MENU();
@@ -140,11 +141,11 @@ void _lcd_ubl_custom_mesh() {
* UBL Adjust Mesh Height Command
*/
void _lcd_ubl_adjust_height_cmd() {
char ubl_lcd_gcode[16];
const int ind = ubl_height_amount > 0 ? 9 : 10;
strcpy_P(ubl_lcd_gcode, PSTR("G29 P6 C -"));
char ubl_lcd_gcode[13];
const int ind = ubl_height_amount > 0 ? 6 : 7;
strcpy_P(ubl_lcd_gcode, PSTR("G29P6C-"));
sprintf_P(&ubl_lcd_gcode[ind], PSTR(".%i"), ABS(ubl_height_amount));
lcd_enqueue_one_now(ubl_lcd_gcode);
queue.inject(ubl_lcd_gcode);
}
/**
@@ -175,53 +176,67 @@ void _menu_ubl_height_adjust() {
void _lcd_ubl_edit_mesh() {
START_MENU();
BACK_ITEM(MSG_UBL_TOOLS);
GCODES_ITEM(MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
GCODES_ITEM(MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29 P4 T"));
GCODES_ITEM(MSG_UBL_FINE_TUNE_ALL, PSTR("G29P4RT"));
GCODES_ITEM(MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29P4T"));
SUBMENU(MSG_UBL_MESH_HEIGHT_ADJUST, _menu_ubl_height_adjust);
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
END_MENU();
}
/**
* UBL Validate Custom Mesh Command
*/
void _lcd_ubl_validate_custom_mesh() {
char ubl_lcd_gcode[24];
const int temp =
#if HAS_HEATED_BED
custom_bed_temp
#else
0
#endif
;
sprintf_P(ubl_lcd_gcode, PSTR("G26 C B%i H%i P"), temp, custom_hotend_temp);
lcd_enqueue_one_now_P(G28_STR);
lcd_enqueue_one_now(ubl_lcd_gcode);
}
#if ENABLED(G26_MESH_VALIDATION)
/**
* UBL Validate Mesh submenu
*
* << UBL Tools
* Mesh Validation with Material 1
* Mesh Validation with Material 2
* Validate Custom Mesh
* << Info Screen
*/
void _lcd_ubl_validate_mesh() {
START_MENU();
BACK_ITEM(MSG_UBL_TOOLS);
#if HAS_HEATED_BED
GCODES_ITEM(MSG_UBL_VALIDATE_MESH_M1, PSTR("G28\nG26 C B" STRINGIFY(PREHEAT_1_TEMP_BED) " H" STRINGIFY(PREHEAT_1_TEMP_HOTEND) " P"));
GCODES_ITEM(MSG_UBL_VALIDATE_MESH_M2, PSTR("G28\nG26 C B" STRINGIFY(PREHEAT_2_TEMP_BED) " H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
#else
GCODES_ITEM(MSG_UBL_VALIDATE_MESH_M1, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_1_TEMP_HOTEND) " P"));
GCODES_ITEM(MSG_UBL_VALIDATE_MESH_M2, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
#endif
ACTION_ITEM(MSG_UBL_VALIDATE_CUSTOM_MESH, _lcd_ubl_validate_custom_mesh);
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
END_MENU();
}
/**
* UBL Validate Custom Mesh Command
*/
void _lcd_ubl_validate_custom_mesh() {
char ubl_lcd_gcode[20];
sprintf_P(ubl_lcd_gcode, PSTR("G28\nG26CPH%" PRIi16 TERN_(HAS_HEATED_BED, "B%" PRIi16))
, custom_hotend_temp
OPTARG(HAS_HEATED_BED, custom_bed_temp)
);
queue.inject(ubl_lcd_gcode);
}
/**
* UBL Validate Mesh submenu
*
* << UBL Tools
* Mesh Validation with Material 1 up to 5
* Validate Custom Mesh
* << Info Screen
*/
void _lcd_ubl_validate_mesh() {
START_MENU();
BACK_ITEM(MSG_UBL_TOOLS);
#if PREHEAT_COUNT
#if HAS_HEATED_BED
#define VALIDATE_MESH_GCODE_ITEM(M) \
GCODES_ITEM_N_S(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, PSTR("G28\nG26CPI" STRINGIFY(M)))
#else
#define VALIDATE_MESH_GCODE_ITEM(M) \
GCODES_ITEM_N_S(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, PSTR("G28\nG26CPB0I" STRINGIFY(M)))
#endif
VALIDATE_MESH_GCODE_ITEM(0);
#if PREHEAT_COUNT > 1
VALIDATE_MESH_GCODE_ITEM(1);
#if PREHEAT_COUNT > 2
VALIDATE_MESH_GCODE_ITEM(2);
#if PREHEAT_COUNT > 3
VALIDATE_MESH_GCODE_ITEM(3);
#if PREHEAT_COUNT > 4
VALIDATE_MESH_GCODE_ITEM(4);
#endif
#endif
#endif
#endif
#endif // PREHEAT_COUNT
ACTION_ITEM(MSG_UBL_VALIDATE_CUSTOM_MESH, _lcd_ubl_validate_custom_mesh);
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
END_MENU();
}
#endif
/**
* UBL Grid Leveling submenu
@@ -236,8 +251,8 @@ void _lcd_ubl_grid_level() {
EDIT_ITEM(int3, MSG_UBL_SIDE_POINTS, &side_points, 2, 6);
ACTION_ITEM(MSG_UBL_MESH_LEVEL, []{
char ubl_lcd_gcode[12];
sprintf_P(ubl_lcd_gcode, PSTR("G29 J%i"), side_points);
lcd_enqueue_one_now(ubl_lcd_gcode);
sprintf_P(ubl_lcd_gcode, PSTR("G29J%i"), side_points);
queue.inject(ubl_lcd_gcode);
});
END_MENU();
}
@@ -253,7 +268,7 @@ void _lcd_ubl_grid_level() {
void _lcd_ubl_mesh_leveling() {
START_MENU();
BACK_ITEM(MSG_UBL_TOOLS);
GCODES_ITEM(MSG_UBL_3POINT_MESH_LEVELING, PSTR("G29 J0"));
GCODES_ITEM(MSG_UBL_3POINT_MESH_LEVELING, PSTR("G29J0"));
SUBMENU(MSG_UBL_GRID_MESH_LEVELING, _lcd_ubl_grid_level);
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
END_MENU();
@@ -264,8 +279,8 @@ void _lcd_ubl_mesh_leveling() {
*/
void _lcd_ubl_fillin_amount_cmd() {
char ubl_lcd_gcode[18];
sprintf_P(ubl_lcd_gcode, PSTR("G29 P3 R C.%i"), ubl_fillin_amount);
lcd_enqueue_one_now(ubl_lcd_gcode);
sprintf_P(ubl_lcd_gcode, PSTR("G29P3RC.%i"), ubl_fillin_amount);
gcode.process_subcommands_now(ubl_lcd_gcode);
}
/**
@@ -282,8 +297,8 @@ void _menu_ubl_fillin() {
START_MENU();
BACK_ITEM(MSG_UBL_BUILD_MESH_MENU);
EDIT_ITEM(int3, MSG_UBL_FILLIN_AMOUNT, &ubl_fillin_amount, 0, 9, _lcd_ubl_fillin_amount_cmd);
GCODES_ITEM(MSG_UBL_SMART_FILLIN, PSTR("G29 P3 T0"));
GCODES_ITEM(MSG_UBL_MANUAL_FILLIN, PSTR("G29 P2 B T0"));
GCODES_ITEM(MSG_UBL_SMART_FILLIN, PSTR("G29P3T0"));
GCODES_ITEM(MSG_UBL_MANUAL_FILLIN, PSTR("G29P2BT0"));
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
END_MENU();
}
@@ -297,8 +312,7 @@ void _lcd_ubl_invalidate() {
* UBL Build Mesh submenu
*
* << UBL Tools
* Build Mesh with Material 1
* Build Mesh with Material 2
* Build Mesh with Material 1 up to 5
* - Build Custom Mesh >>
* Build Cold Mesh
* - Fill-in Mesh >>
@@ -310,68 +324,57 @@ void _lcd_ubl_invalidate() {
void _lcd_ubl_build_mesh() {
START_MENU();
BACK_ITEM(MSG_UBL_TOOLS);
#if HAS_HEATED_BED
GCODES_ITEM(MSG_UBL_BUILD_MESH_M1, PSTR(
"G28\n"
"M190 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\n"
"M109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) "\n"
"G29 P1\n"
"M104 S0\n"
"M140 S0"
));
GCODES_ITEM(MSG_UBL_BUILD_MESH_M2, PSTR(
"G28\n"
"M190 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\n"
"M109 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) "\n"
"G29 P1\n"
"M104 S0\n"
"M140 S0"
));
#else
GCODES_ITEM(MSG_UBL_BUILD_MESH_M1, PSTR(
"G28\n"
"M109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) "\n"
"G29 P1\n"
"M104 S0"
));
GCODES_ITEM(MSG_UBL_BUILD_MESH_M2, PSTR(
"G28\n"
"M109 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) "\n"
"G29 P1\n"
"M104 S0"
));
#endif
#if PREHEAT_COUNT
#if HAS_HEATED_BED
#define PREHEAT_BED_GCODE(M) "M190I" STRINGIFY(M) "\n"
#else
#define PREHEAT_BED_GCODE(M) ""
#endif
#define BUILD_MESH_GCODE_ITEM(M) GCODES_ITEM_S(ui.get_preheat_label(M), MSG_UBL_BUILD_MESH_M, \
PSTR( \
"G28\n" \
PREHEAT_BED_GCODE(M) \
"M109I" STRINGIFY(M) "\n" \
"G29P1\n" \
"M104S0\n" \
"M140S0" \
) )
BUILD_MESH_GCODE_ITEM(0);
#if PREHEAT_COUNT > 1
BUILD_MESH_GCODE_ITEM(1);
#if PREHEAT_COUNT > 2
BUILD_MESH_GCODE_ITEM(2);
#if PREHEAT_COUNT > 3
BUILD_MESH_GCODE_ITEM(3);
#if PREHEAT_COUNT > 4
BUILD_MESH_GCODE_ITEM(4);
#endif
#endif
#endif
#endif
#endif // PREHEAT_COUNT
SUBMENU(MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_custom_mesh);
GCODES_ITEM(MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29 P1"));
GCODES_ITEM(MSG_UBL_BUILD_COLD_MESH, PSTR("G29NP1"));
SUBMENU(MSG_UBL_FILLIN_MESH, _menu_ubl_fillin);
GCODES_ITEM(MSG_UBL_CONTINUE_MESH, PSTR("G29 P1 C"));
GCODES_ITEM(MSG_UBL_CONTINUE_MESH, PSTR("G29P1C"));
ACTION_ITEM(MSG_UBL_INVALIDATE_ALL, _lcd_ubl_invalidate);
GCODES_ITEM(MSG_UBL_INVALIDATE_CLOSEST, PSTR("G29 I"));
GCODES_ITEM(MSG_UBL_INVALIDATE_CLOSEST, PSTR("G29I"));
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
END_MENU();
}
/**
* UBL Load Mesh Command
* UBL Load / Save Mesh Commands
*/
void _lcd_ubl_load_mesh_cmd() {
char ubl_lcd_gcode[25];
sprintf_P(ubl_lcd_gcode, PSTR("G29 L%i"), ubl_storage_slot);
lcd_enqueue_one_now(ubl_lcd_gcode);
sprintf_P(ubl_lcd_gcode, GET_TEXT(MSG_MESH_LOADED), ubl_storage_slot);
lcd_enqueue_one_now(ubl_lcd_gcode);
}
/**
* UBL Save Mesh Command
*/
void _lcd_ubl_save_mesh_cmd() {
char ubl_lcd_gcode[25];
sprintf_P(ubl_lcd_gcode, PSTR("G29 S%i"), ubl_storage_slot);
lcd_enqueue_one_now(ubl_lcd_gcode);
sprintf_P(ubl_lcd_gcode, GET_TEXT(MSG_MESH_SAVED), ubl_storage_slot);
lcd_enqueue_one_now(ubl_lcd_gcode);
inline void _lcd_ubl_load_save_cmd(const char loadsave, PGM_P const msg) {
char ubl_lcd_gcode[40];
sprintf_P(ubl_lcd_gcode, PSTR("G29%c%i\nM117 "), loadsave, ubl_storage_slot);
sprintf_P(&ubl_lcd_gcode[strlen(ubl_lcd_gcode)], msg, ubl_storage_slot);
gcode.process_subcommands_now(ubl_lcd_gcode);
}
void _lcd_ubl_load_mesh_cmd() { _lcd_ubl_load_save_cmd('L', GET_TEXT(MSG_MESH_LOADED)); }
void _lcd_ubl_save_mesh_cmd() { _lcd_ubl_load_save_cmd('S', GET_TEXT(MSG_MESH_SAVED)); }
/**
* UBL Mesh Storage submenu
@@ -385,9 +388,8 @@ void _lcd_ubl_storage_mesh() {
int16_t a = settings.calc_num_meshes();
START_MENU();
BACK_ITEM(MSG_UBL_LEVEL_BED);
if (!WITHIN(ubl_storage_slot, 0, a - 1)) {
if (!WITHIN(ubl_storage_slot, 0, a - 1))
STATIC_ITEM(MSG_UBL_NO_STORAGE);
}
else {
EDIT_ITEM(int3, MSG_UBL_STORAGE_SLOT, &ubl_storage_slot, 0, a - 1);
ACTION_ITEM(MSG_UBL_LOAD_MESH, _lcd_ubl_load_mesh_cmd);
@@ -396,132 +398,139 @@ void _lcd_ubl_storage_mesh() {
END_MENU();
}
/**
* UBL LCD "radar" map homing
*/
void _lcd_ubl_output_map_lcd();
void _lcd_ubl_map_homing() {
ui.defer_status_screen();
_lcd_draw_homing();
if (all_axes_homed()) {
ubl.lcd_map_control = true; // Return to the map screen
ui.goto_screen(_lcd_ubl_output_map_lcd);
}
}
/**
* UBL LCD "radar" map point editing
*/
void _lcd_ubl_map_lcd_edit_cmd() {
void _lcd_ubl_map_edit_cmd() {
char ubl_lcd_gcode[50], str[10], str2[10];
dtostrf(ubl.mesh_index_to_xpos(x_plot), 0, 2, str);
dtostrf(ubl.mesh_index_to_ypos(y_plot), 0, 2, str2);
snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29 P4 X%s Y%s R%i"), str, str2, int(n_edit_pts));
lcd_enqueue_one_now(ubl_lcd_gcode);
snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29P4X%sY%sR%i"), str, str2, int(n_edit_pts));
queue.inject(ubl_lcd_gcode);
}
/**
* UBL LCD Map Movement
*/
void ubl_map_move_to_xy() {
const feedRate_t fr_mm_s = MMM_TO_MMS(XY_PROBE_SPEED);
const xy_pos_t xy = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) };
destination = current_position; // sync destination at the start
// Some printers have unreachable areas in the mesh. Skip the move if unreachable.
if (!position_is_reachable(xy)) return;
#if ENABLED(DELTA)
if (current_position.z > delta_clip_start_height) {
if (current_position.z > delta_clip_start_height) { // Make sure the delta has fully free motion
destination = current_position;
destination.z = delta_clip_start_height;
prepare_internal_move_to_destination(fr_mm_s);
prepare_internal_fast_move_to_destination(homing_feedrate(Z_AXIS)); // Set current_position from destination
}
#endif
destination.set(ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot));
prepare_internal_move_to_destination(fr_mm_s);
// Use the built-in manual move handler to move to the mesh point.
ui.manual_move.set_destination(xy);
ui.manual_move.soon(ALL_AXES_ENUM);
}
inline int32_t grid_index(const uint8_t x, const uint8_t y) {
return (GRID_MAX_POINTS_X) * y + x;
}
/**
* UBL LCD "radar" map
*/
void set_current_from_steppers_for_axis(const AxisEnum axis);
void sync_plan_position();
void ubl_map_screen() {
// static millis_t next_move = 0;
// const millis_t ms = millis();
void _lcd_do_nothing() {}
void _lcd_hard_stop() {
const screenFunc_t old_screen = ui.currentScreen;
ui.currentScreen = _lcd_do_nothing;
planner.quick_stop();
ui.currentScreen = old_screen;
set_current_from_steppers_for_axis(ALL_AXES);
sync_plan_position();
}
uint8_t x, y;
void _lcd_ubl_output_map_lcd() {
static int16_t step_scaler = 0;
if (ui.first_page) {
if (ui.use_click()) return _lcd_ubl_map_lcd_edit_cmd();
// On click send "G29 P4 ..." to edit the Z value
if (ui.use_click()) {
_lcd_ubl_map_edit_cmd();
return;
}
if (ui.encoderPosition) {
step_scaler += int32_t(ui.encoderPosition);
x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM);
ui.encoderPosition = 0;
ui.refresh(LCDVIEW_REDRAW_NOW);
}
#if IS_KINEMATIC
#define KEEP_LOOPING true // Loop until a valid point is found
#else
#define KEEP_LOOPING false
#endif
do {
// Encoder to the right (++)
if (x_plot >= GRID_MAX_POINTS_X) { x_plot = 0; y_plot++; }
if (y_plot >= GRID_MAX_POINTS_Y) y_plot = 0;
// Encoder to the left (--)
if (x_plot < 0) { x_plot = GRID_MAX_POINTS_X - 1; y_plot--; }
if (y_plot < 0) y_plot = GRID_MAX_POINTS_Y - 1;
ui.defer_status_screen();
#if IS_KINEMATIC
const xy_pos_t xy = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) };
if (position_is_reachable(xy)) break; // Found a valid point
x_plot += (step_scaler < 0) ? -1 : 1;
// Index of the mesh point upon entry
const int32_t old_pos_index = grid_index(x_plot, y_plot);
// Direction from new (unconstrained) encoder value
const int8_t step_dir = int32_t(ui.encoderPosition) < old_pos_index ? -1 : 1;
#endif
} while(KEEP_LOOPING);
do {
// Now, keep the encoder position within range
if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = GRID_MAX_POINTS + TERN(TOUCH_SCREEN, ui.encoderPosition, -1);
if (int32_t(ui.encoderPosition) > GRID_MAX_POINTS - 1) ui.encoderPosition = TERN(TOUCH_SCREEN, ui.encoderPosition - GRID_MAX_POINTS, 0);
// Determine number of points to edit
#if IS_KINEMATIC
n_edit_pts = 9; //TODO: Delta accessible edit points
#else
const bool xc = WITHIN(x_plot, 1, GRID_MAX_POINTS_X - 2),
yc = WITHIN(y_plot, 1, GRID_MAX_POINTS_Y - 2);
n_edit_pts = yc ? (xc ? 9 : 6) : (xc ? 6 : 4); // Corners
#endif
// Draw the grid point based on the encoder
x = ui.encoderPosition % (GRID_MAX_POINTS_X);
y = ui.encoderPosition / (GRID_MAX_POINTS_X);
// Cleanup
if (ABS(step_scaler) >= ENCODER_STEPS_PER_MENU_ITEM) step_scaler = 0;
// Validate if needed
#if IS_KINEMATIC
const xy_pos_t xy = { ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) };
if (position_is_reachable(xy)) break; // Found a valid point
ui.encoderPosition += step_dir; // Test the next point
#endif
} while (ENABLED(IS_KINEMATIC));
if (ui.should_draw()) {
ui.ubl_plot(x_plot, y_plot);
// Determine number of points to edit
#if IS_KINEMATIC
n_edit_pts = 9; // TODO: Delta accessible edit points
#else
const bool xc = WITHIN(x, 1, (GRID_MAX_POINTS_X) - 2),
yc = WITHIN(y, 1, (GRID_MAX_POINTS_Y) - 2);
n_edit_pts = yc ? (xc ? 9 : 6) : (xc ? 6 : 4); // Corners
#endif
if (planner.movesplanned()) // If the nozzle is already moving, cancel the move.
_lcd_hard_stop();
// Refresh is also set by encoder movement
//if (int32_t(ui.encoderPosition) != grid_index(x, y))
// ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
}
ubl_map_move_to_xy(); // Move to new location
// Draw the grid point based on the encoder
x = ui.encoderPosition % (GRID_MAX_POINTS_X);
y = ui.encoderPosition / (GRID_MAX_POINTS_X);
if (ui.should_draw()) ui.ubl_plot(x, y);
// Add a move if needed to match the grid point
if (x != x_plot || y != y_plot) {
x_plot = x; y_plot = y; // The move is always posted, so update the grid point now
ubl_map_move_to_xy(); // Sets up a "manual move"
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); // Clean up a half drawn box
}
}
/**
* UBL LCD "radar" map homing
*/
void _ubl_map_screen_homing() {
ui.defer_status_screen();
_lcd_draw_homing();
if (all_axes_homed()) {
ubl.lcd_map_control = true; // Return to the map screen after editing Z
ui.goto_screen(ubl_map_screen, grid_index(x_plot, y_plot)); // Pre-set the encoder value
ui.manual_move.menu_scale = 0; // Immediate move
ubl_map_move_to_xy(); // Move to current mesh point
ui.manual_move.menu_scale = 1; // Delayed moves
}
}
/**
* UBL Homing before LCD map
*/
void _lcd_ubl_output_map_lcd_cmd() {
if (!all_axes_known()) {
void _ubl_goto_map_screen() {
if (planner.movesplanned()) return; // The ACTION_ITEM will do nothing
if (!all_axes_trusted()) {
set_all_unhomed();
queue.inject_P(G28_STR);
}
ui.goto_screen(_lcd_ubl_map_homing);
ui.goto_screen(_ubl_map_screen_homing); // Go to the "Homing" screen
}
/**
@@ -535,9 +544,9 @@ void _lcd_ubl_output_map_lcd_cmd() {
void _lcd_ubl_output_map() {
START_MENU();
BACK_ITEM(MSG_UBL_LEVEL_BED);
GCODES_ITEM(MSG_UBL_OUTPUT_MAP_HOST, PSTR("G29 T0"));
GCODES_ITEM(MSG_UBL_OUTPUT_MAP_CSV, PSTR("G29 T1"));
GCODES_ITEM(MSG_UBL_OUTPUT_MAP_BACKUP, PSTR("G29 S-1"));
GCODES_ITEM(MSG_UBL_OUTPUT_MAP_HOST, PSTR("G29T0"));
GCODES_ITEM(MSG_UBL_OUTPUT_MAP_CSV, PSTR("G29T1"));
GCODES_ITEM(MSG_UBL_OUTPUT_MAP_BACKUP, PSTR("G29S-1"));
END_MENU();
}
@@ -554,37 +563,88 @@ void _menu_ubl_tools() {
START_MENU();
BACK_ITEM(MSG_UBL_LEVEL_BED);
SUBMENU(MSG_UBL_BUILD_MESH_MENU, _lcd_ubl_build_mesh);
GCODES_ITEM(MSG_UBL_MANUAL_MESH, PSTR("G29 I999\nG29 P2 B T0"));
SUBMENU(MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
GCODES_ITEM(MSG_UBL_MANUAL_MESH, PSTR("G29I999\nG29P2BT0"));
#if ENABLED(G26_MESH_VALIDATION)
SUBMENU(MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
#endif
SUBMENU(MSG_EDIT_MESH, _lcd_ubl_edit_mesh);
SUBMENU(MSG_UBL_MESH_LEVELING, _lcd_ubl_mesh_leveling);
END_MENU();
}
/**
* UBL Step-By-Step submenu
*
* << Unified Bed Leveling
* 1 Build Cold Mesh
* 2 Smart Fill-in
* - 3 Validate Mesh >>
* 4 Fine Tune All
* - 5 Validate Mesh >>
* 6 Fine Tune All
* 7 Save Bed Mesh
*/
void _lcd_ubl_step_by_step() {
START_MENU();
BACK_ITEM(MSG_UBL_LEVEL_BED);
GCODES_ITEM(MSG_UBL_1_BUILD_COLD_MESH, PSTR("G28\nG29 P1"));
GCODES_ITEM(MSG_UBL_2_SMART_FILLIN, PSTR("G29 P3 T0"));
SUBMENU(MSG_UBL_3_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
GCODES_ITEM(MSG_UBL_4_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
SUBMENU(MSG_UBL_5_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
GCODES_ITEM(MSG_UBL_6_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
ACTION_ITEM(MSG_UBL_7_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
END_MENU();
}
#if ENABLED(G26_MESH_VALIDATION)
/**
* UBL Step-By-Step submenu
*
* << Unified Bed Leveling
* 1 Build Cold Mesh
* 2 Smart Fill-in
* - 3 Validate Mesh >>
* 4 Fine Tune All
* - 5 Validate Mesh >>
* 6 Fine Tune All
* 7 Save Bed Mesh
*/
void _lcd_ubl_step_by_step() {
START_MENU();
BACK_ITEM(MSG_UBL_LEVEL_BED);
GCODES_ITEM(MSG_UBL_1_BUILD_COLD_MESH, PSTR("G29NP1"));
GCODES_ITEM(MSG_UBL_2_SMART_FILLIN, PSTR("G29P3T0"));
SUBMENU(MSG_UBL_3_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
GCODES_ITEM(MSG_UBL_4_FINE_TUNE_ALL, PSTR("G29P4RT"));
SUBMENU(MSG_UBL_5_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
GCODES_ITEM(MSG_UBL_6_FINE_TUNE_ALL, PSTR("G29P4RT"));
ACTION_ITEM(MSG_UBL_7_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
END_MENU();
}
#endif
#if ENABLED(UBL_MESH_WIZARD)
/**
* UBL Mesh Wizard - One-click mesh creation with or without a probe
*/
void _lcd_ubl_mesh_wizard() {
char ubl_lcd_gcode[30];
#if HAS_HEATED_BED && HAS_HOTEND
sprintf_P(ubl_lcd_gcode, PSTR("M1004B%iH%iS%i"), custom_bed_temp, custom_hotend_temp, ubl_storage_slot);
#elif HAS_HOTEND
sprintf_P(ubl_lcd_gcode, PSTR("M1004H%iS%i"), custom_hotend_temp, ubl_storage_slot);
#else
sprintf_P(ubl_lcd_gcode, PSTR("M1004S%i"), ubl_storage_slot);
#endif
queue.inject(ubl_lcd_gcode);
ui.return_to_status();
}
void _menu_ubl_mesh_wizard() {
const int16_t total_slots = settings.calc_num_meshes();
START_MENU();
BACK_ITEM(MSG_UBL_LEVEL_BED);
#if HAS_HOTEND
EDIT_ITEM(int3, MSG_UBL_HOTEND_TEMP_CUSTOM, &custom_hotend_temp, HEATER_0_MINTEMP + 20, thermalManager.hotend_max_target(0));
#endif
#if HAS_HEATED_BED
EDIT_ITEM(int3, MSG_UBL_BED_TEMP_CUSTOM, &custom_bed_temp, BED_MINTEMP + 20, BED_MAX_TARGET);
#endif
EDIT_ITEM(int3, MSG_UBL_STORAGE_SLOT, &ubl_storage_slot, 0, total_slots);
ACTION_ITEM(MSG_UBL_MESH_WIZARD, _lcd_ubl_mesh_wizard);
#if ENABLED(G26_MESH_VALIDATION)
SUBMENU(MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
#endif
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
END_MENU();
}
#endif
/**
* UBL System submenu
@@ -599,24 +659,28 @@ void _lcd_ubl_step_by_step() {
* - UBL Tools >>
* - Output UBL Info >>
*/
void _lcd_ubl_level_bed() {
START_MENU();
BACK_ITEM(MSG_MOTION);
if (planner.leveling_active)
GCODES_ITEM(MSG_UBL_DEACTIVATE_MESH, PSTR("G29 D"));
GCODES_ITEM(MSG_UBL_DEACTIVATE_MESH, PSTR("G29D"));
else
GCODES_ITEM(MSG_UBL_ACTIVATE_MESH, PSTR("G29 A"));
SUBMENU(MSG_UBL_STEP_BY_STEP_MENU, _lcd_ubl_step_by_step);
ACTION_ITEM(MSG_UBL_MESH_EDIT, _lcd_ubl_output_map_lcd_cmd);
SUBMENU(MSG_UBL_STORAGE_MESH_MENU, _lcd_ubl_storage_mesh);
SUBMENU(MSG_UBL_OUTPUT_MAP, _lcd_ubl_output_map);
SUBMENU(MSG_UBL_TOOLS, _menu_ubl_tools);
GCODES_ITEM(MSG_UBL_INFO_UBL, PSTR("G29 W"));
GCODES_ITEM(MSG_UBL_ACTIVATE_MESH, PSTR("G29A"));
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
editable.decimal = planner.z_fade_height;
EDIT_ITEM_FAST(float3, MSG_Z_FADE_HEIGHT, &editable.decimal, 0, 100, []{ set_z_fade_height(editable.decimal); });
#endif
#if ENABLED(G26_MESH_VALIDATION)
SUBMENU(MSG_UBL_STEP_BY_STEP_MENU, _lcd_ubl_step_by_step);
#endif
#if ENABLED(UBL_MESH_WIZARD)
SUBMENU(MSG_UBL_MESH_WIZARD, _menu_ubl_mesh_wizard);
#endif
ACTION_ITEM(MSG_UBL_MESH_EDIT, _ubl_goto_map_screen);
SUBMENU(MSG_UBL_STORAGE_MESH_MENU, _lcd_ubl_storage_mesh);
SUBMENU(MSG_UBL_OUTPUT_MAP, _lcd_ubl_output_map);
SUBMENU(MSG_UBL_TOOLS, _menu_ubl_tools);
GCODES_ITEM(MSG_UBL_INFO_UBL, PSTR("G29W"));
END_MENU();
}