🧑‍💻 Extend LCD string substitution (#24278)

This commit is contained in:
Scott Lahteine
2022-06-04 00:15:23 -05:00
parent fcef8d946c
commit 1e127a93c4
83 changed files with 1062 additions and 1281 deletions

View File

@@ -68,9 +68,10 @@ typedef struct {
menuPosition screen_history[6];
uint8_t screen_history_depth = 0;
int8_t MenuItemBase::itemIndex; // Index number for draw and action
FSTR_P MenuItemBase::itemString; // A string for substitution
chimera_t editable; // Value Editing
int8_t MenuItemBase::itemIndex; // Index number for draw and action
FSTR_P MenuItemBase::itemStringF; // A string for substitution
const char *MenuItemBase::itemStringC;
chimera_t editable; // Value Editing
// Menu Edit Items
FSTR_P MenuEditItemBase::editLabel;

View File

@@ -53,15 +53,17 @@ class MenuItemBase {
// 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 FSTR_P itemString;
// Optional pointers for use in display or by the action
static FSTR_P itemStringF;
static const char* itemStringC;
// Store the index of the item ahead of use by indexed items
FORCE_INLINE static void init(const int8_t ind=0, FSTR_P const fstr=nullptr) { itemIndex = ind; itemString = fstr; }
// Store an index and string for later substitution
FORCE_INLINE static void init(const int8_t ind=0, FSTR_P const fstr=nullptr) { itemIndex = ind; itemStringF = fstr; itemStringC = nullptr; }
FORCE_INLINE static void init(const int8_t ind, const char * const cstr) { itemIndex = ind; itemStringC = cstr; itemStringF = nullptr; }
// Implementation-specific:
// Draw an item either selected (pre_char) or not (space) with post_char
// Menus may set up itemIndex, itemString and pass them to string-building or string-emitting functions
// Menus may set up itemIndex, itemStringC/F and pass them to string-building or string-emitting functions
static void _draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char pre_char, const char post_char);
// Draw an item either selected ('>') or not (space) with post_char
@@ -90,8 +92,8 @@ class MenuItem_back : public MenuItemBase {
// YESNO_ITEM(LABEL,FY,FN,...)
class MenuItem_confirm : public MenuItemBase {
public:
FORCE_INLINE static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, ...) {
_draw(sel, row, fstr, '>', LCD_STR_ARROW_RIGHT[0]);
FORCE_INLINE static void draw(const bool sel, const uint8_t row, FSTR_P const ftpl, ...) {
_draw(sel, row, ftpl, '>', LCD_STR_ARROW_RIGHT[0]);
}
// Implemented for HD44780 and DOGM
// Draw the prompt, buttons, and state
@@ -170,10 +172,10 @@ class MenuEditItemBase : public MenuItemBase {
public:
// Implementation-specific:
// Draw the current item at specified row with edit data
static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char * const inStr, const bool pgm=false);
static void draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char * const inStr, const bool pgm=false);
static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, FSTR_P const inStr) {
draw(sel, row, fstr, FTOP(inStr), true);
static void draw(const bool sel, const uint8_t row, FSTR_P const ftpl, FSTR_P const fstr) {
draw(sel, row, ftpl, FTOP(fstr), true);
}
// Implementation-specific:

View File

@@ -68,8 +68,10 @@ void menu_backlash();
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, []{ 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));
LOOP_LOGICAL_AXES(a)
EDIT_ITEM_N(uint8, a, MSG_DAC_PERCENT_N, &driverPercent[a], 0, 100, []{ stepper_dac.set_current_percents(driverPercent); });
ACTION_ITEM(MSG_DAC_EEPROM_WRITE, stepper_dac.commit_eeprom);
END_MENU();
}
@@ -427,11 +429,11 @@ void menu_backlash();
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));
LOOP_NUM_AXES(a)
EDIT_ITEM_FAST_N(float5, a, MSG_VMAX_N, &planner.settings.max_feedrate_mm_s[a], 1, max_fr_edit_scaled[a]);
#if E_STEPPERS
EDIT_ITEM_FAST(float5, MSG_VMAX_E, &planner.settings.max_feedrate_mm_s[E_AXIS_N(active_extruder)], 1, max_fr_edit_scaled.e);
EDIT_ITEM_FAST_N(float5, E_AXIS, MSG_VMAX_N, &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)
@@ -514,11 +516,9 @@ void menu_backlash();
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
EDIT_ITEM(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.001f, TERN(LIN_ADVANCE, 0.3f, 0.5f)
OPTARG(LIN_ADVANCE, planner.recalculate_max_e_jerk)
);
#endif
constexpr xyze_float_t max_jerk_edit =
@@ -532,20 +532,13 @@ void menu_backlash();
{ 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)])
#if ENABLED(DELTA)
#define EDIT_JERK_C() EDIT_JERK(C)
#else
#define EDIT_JERK_C() EDIT_ITEM_FAST(float52sign, MSG_VC_JERK, &planner.max_jerk.c, 0.1f, max_jerk_edit.c)
#endif
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
LOOP_LOGICAL_AXES(a) {
if (a == C_AXIS || TERN0(HAS_EXTRUDERS, a == E_AXIS))
EDIT_ITEM_FAST_N(float52sign, a, MSG_VN_JERK, &planner.max_jerk[a], 0.1f, max_jerk_edit[a]);
else
EDIT_ITEM_FAST_N(float3, a, MSG_VN_JERK, &planner.max_jerk[a], 1.0f, max_jerk_edit[a]);
}
END_MENU();
}
@@ -582,11 +575,8 @@ void menu_advanced_steps_per_mm() {
START_MENU();
BACK_ITEM(MSG_ADVANCED_SETTINGS);
#define EDIT_QSTEPS(Q) EDIT_ITEM_FAST(float61, MSG_##Q##_STEPS, &planner.settings.axis_steps_per_mm[_AXIS(Q)], 5, 9999, []{ planner.refresh_positioning(); })
LINEAR_AXIS_CODE(
EDIT_QSTEPS(A), EDIT_QSTEPS(B), EDIT_QSTEPS(C),
EDIT_QSTEPS(I), EDIT_QSTEPS(J), EDIT_QSTEPS(K)
);
LOOP_NUM_AXES(a)
EDIT_ITEM_FAST_N(float61, a, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[a], 5, 9999, []{ planner.refresh_positioning(); });
#if ENABLED(DISTINCT_E_FACTORS)
LOOP_L_N(n, E_STEPPERS)
@@ -598,7 +588,7 @@ void menu_advanced_steps_per_mm() {
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(float61, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); });
EDIT_ITEM_FAST_N(float61, E_AXIS, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); });
#endif
END_MENU();
@@ -624,7 +614,7 @@ void menu_advanced_settings() {
#endif
// M203 / M205 - Feedrate items
SUBMENU(MSG_VELOCITY, menu_advanced_velocity);
SUBMENU(MSG_MAX_SPEED, menu_advanced_velocity);
// M201 - Acceleration items
SUBMENU(MSG_ACCELERATION, menu_advanced_acceleration);

View File

@@ -47,7 +47,7 @@ void menu_backlash() {
#define EDIT_BACKLASH_DISTANCE(N) do { \
editable.decimal = backlash.get_distance_mm(_AXIS(N)); \
EDIT_ITEM_FAST(float43, MSG_BACKLASH_##N, &editable.decimal, 0.0f, 9.9f, []{ backlash.set_distance_mm(_AXIS(N), editable.decimal); }); \
EDIT_ITEM_FAST_N(float43, _AXIS(N), MSG_BACKLASH_N, &editable.decimal, 0.0f, 9.9f, []{ backlash.set_distance_mm(_AXIS(N), editable.decimal); }); \
} while (0);
if (_CAN_CALI(A)) EDIT_BACKLASH_DISTANCE(A);

View File

@@ -572,7 +572,7 @@ void menu_configuration() {
// Preheat configurations
#if HAS_PREHEAT && 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);
SUBMENU_N_f(m, ui.get_preheat_label(m), MSG_PREHEAT_M_SETTINGS, _menu_configuration_preheat_settings);
#endif
#if ENABLED(SOUND_MENU_ITEM)

View File

@@ -95,7 +95,7 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
BACK_ITEM(MSG_BACK);
#if HAS_PREHEAT
LOOP_L_N(m, PREHEAT_COUNT)
ACTION_ITEM_N_S(m, ui.get_preheat_label(m), MSG_PREHEAT_M, _change_filament_with_preset);
ACTION_ITEM_N_f(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),
@@ -132,18 +132,18 @@ void menu_change_filament() {
// Change filament
#if E_STEPPERS == 1
FSTR_P const msg = GET_TEXT_F(MSG_FILAMENTCHANGE);
FSTR_P const fmsg = GET_TEXT_F(MSG_FILAMENTCHANGE);
if (thermalManager.targetTooColdToExtrude(active_extruder))
SUBMENU_F(msg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, 0); });
SUBMENU_F(fmsg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, 0); });
else
GCODES_ITEM_F(msg, F("M600 B0"));
GCODES_ITEM_F(fmsg, F("M600 B0"));
#else
FSTR_P const msg = GET_TEXT_F(MSG_FILAMENTCHANGE_E);
FSTR_P const fmsg = GET_TEXT_F(MSG_FILAMENTCHANGE_E);
LOOP_L_N(s, E_STEPPERS) {
if (thermalManager.targetTooColdToExtrude(s))
SUBMENU_N_F(s, msg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, MenuItemBase::itemIndex); });
SUBMENU_N_F(s, fmsg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, MenuItemBase::itemIndex); });
else {
ACTION_ITEM_N_F(s, msg, []{
ACTION_ITEM_N_F(s, fmsg, []{
PGM_P const cmdpstr = PSTR("M600 B0 T%i");
char cmd[strlen_P(cmdpstr) + 3 + 1];
sprintf_P(cmd, cmdpstr, int(MenuItemBase::itemIndex));
@@ -271,10 +271,10 @@ void menu_pause_option() {
//
// ADVANCED_PAUSE_FEATURE message screens
//
// Warning: msg must have three null bytes to delimit lines!
// Warning: fmsg must have three null bytes to delimit lines!
//
void _lcd_pause_message(FSTR_P const msg) {
PGM_P const msg1 = FTOP(msg);
void _lcd_pause_message(FSTR_P const fmsg) {
PGM_P const msg1 = FTOP(fmsg);
PGM_P const msg2 = msg1 + strlen_P(msg1) + 1;
PGM_P const msg3 = msg2 + strlen_P(msg2) + 1;
const bool has2 = msg2[0], has3 = msg3[0],

View File

@@ -268,7 +268,7 @@ class MenuItem_bool : public MenuEditItemBase {
#define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER)
#endif
#define _MENU_INNER_P(TYPE, USE_MULTIPLIER, FLABEL, V...) do { \
#define _MENU_INNER_F(TYPE, USE_MULTIPLIER, FLABEL, V...) do { \
FSTR_P const flabel = FLABEL; \
if (encoderLine == _thisItemNr && ui.use_click()) { \
_MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER); \
@@ -280,30 +280,41 @@ class MenuItem_bool : public MenuEditItemBase {
(encoderLine == _thisItemNr, _lcdLineNr, flabel, ##V); \
}while(0)
// Item with optional data
#define _MENU_ITEM_F(TYPE, V...) do { \
if (_menuLineNr == _thisItemNr) { \
_skipStatic = false; \
_MENU_INNER_P(TYPE, ##V); \
_MENU_INNER_F(TYPE, ##V); \
} \
NEXT_ITEM(); \
}while(0)
// Indexed items set a global index value and optional data
// Item with index value, C-string, and optional data
#define _MENU_ITEM_N_S_F(TYPE, N, S, V...) do{ \
if (_menuLineNr == _thisItemNr) { \
_skipStatic = false; \
MenuItemBase::init(N, S); \
_MENU_INNER_P(TYPE, ##V); \
_MENU_INNER_F(TYPE, ##V); \
} \
NEXT_ITEM(); \
}while(0)
// Indexed items set a global index value
// Item with index value and F-string
#define _MENU_ITEM_N_f_F(TYPE, N, f, V...) do{ \
if (_menuLineNr == _thisItemNr) { \
_skipStatic = false; \
MenuItemBase::init(N, f); \
_MENU_INNER_F(TYPE, ##V); \
} \
NEXT_ITEM(); \
}while(0)
// Item with index value
#define _MENU_ITEM_N_F(TYPE, N, V...) do{ \
if (_menuLineNr == _thisItemNr) { \
_skipStatic = false; \
MenuItemBase::itemIndex = N; \
_MENU_INNER_P(TYPE, ##V); \
MenuItemBase::init(N); \
_MENU_INNER_F(TYPE, ##V); \
} \
NEXT_ITEM(); \
}while(0)
@@ -312,8 +323,18 @@ class MenuItem_bool : public MenuEditItemBase {
#define _MENU_ITEM_S_F(TYPE, S, V...) do{ \
if (_menuLineNr == _thisItemNr) { \
_skipStatic = false; \
MenuItemBase::itemString = S; \
_MENU_INNER_P(TYPE, ##V); \
MenuItemBase::init(0, S); \
_MENU_INNER_F(TYPE, ##V); \
} \
NEXT_ITEM(); \
}while(0)
// Items with a unique F-string
#define _MENU_ITEM_f_F(TYPE, f, V...) do{ \
if (_menuLineNr == _thisItemNr) { \
_skipStatic = false; \
MenuItemBase::init(0, f); \
_MENU_INNER_F(TYPE, ##V); \
} \
NEXT_ITEM(); \
}while(0)
@@ -361,15 +382,24 @@ class MenuItem_bool : public MenuEditItemBase {
#define STATIC_ITEM(LABEL, V...) STATIC_ITEM_F(GET_TEXT_F(LABEL), ##V)
#define STATIC_ITEM_N(LABEL, N, V...) STATIC_ITEM_N_F(GET_TEXT_F(LABEL), N, ##V)
// Menu item with index and composed C-string substitution
#define MENU_ITEM_N_S_F(TYPE, N, S, FLABEL, V...) _MENU_ITEM_N_S_F(TYPE, N, S, false, FLABEL, ##V)
#define MENU_ITEM_N_S(TYPE, N, S, LABEL, V...) MENU_ITEM_N_S_F(TYPE, N, S, GET_TEXT_F(LABEL), ##V)
// Menu item with composed C-string substitution
#define MENU_ITEM_S_F(TYPE, S, FLABEL, V...) _MENU_ITEM_S_F(TYPE, S, false, FLABEL, ##V)
#define MENU_ITEM_S(TYPE, S, LABEL, V...) MENU_ITEM_S_F(TYPE, S, GET_TEXT_F(LABEL), ##V)
// Menu item substitution, indexed
#define MENU_ITEM_N_F(TYPE, N, FLABEL, V...) _MENU_ITEM_N_F(TYPE, N, false, FLABEL, ##V)
#define MENU_ITEM_N(TYPE, N, LABEL, V...) MENU_ITEM_N_F(TYPE, N, GET_TEXT_F(LABEL), ##V)
// Basic menu items, no substitution
#define MENU_ITEM_F(TYPE, FLABEL, V...) _MENU_ITEM_F(TYPE, false, FLABEL, ##V)
#define MENU_ITEM(TYPE, LABEL, V...) MENU_ITEM_F(TYPE, GET_TEXT_F(LABEL), ##V)
// Predefined menu item types //
#define BACK_ITEM_F(FLABEL) MENU_ITEM_F(back, FLABEL)
#define BACK_ITEM(LABEL) MENU_ITEM(back, LABEL)
@@ -418,6 +448,38 @@ class MenuItem_bool : public MenuEditItemBase {
#define EDIT_ITEM_FAST_F(TYPE, FLABEL, V...) _MENU_ITEM_F(TYPE, true, FLABEL, ##V)
#define EDIT_ITEM_FAST(TYPE, LABEL, V...) EDIT_ITEM_FAST_F(TYPE, GET_TEXT_F(LABEL), ##V)
// F-string substitution instead of C-string //
#define MENU_ITEM_N_f_F(TYPE, N, f, FLABEL, V...) _MENU_ITEM_N_f_F(TYPE, N, f, false, FLABEL, ##V)
#define MENU_ITEM_N_f(TYPE, N, f, LABEL, V...) MENU_ITEM_N_f_F(TYPE, N, f, GET_TEXT_F(LABEL), ##V)
#define MENU_ITEM_f_F(TYPE, f, FLABEL, V...) _MENU_ITEM_f_F(TYPE, f, false, FLABEL, ##V)
#define MENU_ITEM_f(TYPE, f, LABEL, V...) MENU_ITEM_f_F(TYPE, f, GET_TEXT_F(LABEL), ##V)
#define ACTION_ITEM_N_f_F(N, f, FLABEL, ACTION) MENU_ITEM_N_f_F(function, N, f, FLABEL, ACTION)
#define ACTION_ITEM_N_f(N, f, LABEL, ACTION) ACTION_ITEM_N_f_F(N, f, GET_TEXT_F(LABEL), ACTION)
#define ACTION_ITEM_f_F(f, FLABEL, ACTION) MENU_ITEM_f_F(function, f, FLABEL, ACTION)
#define ACTION_ITEM_f(f, LABEL, ACTION) ACTION_ITEM_f_F(f, GET_TEXT_F(LABEL), ACTION)
#define GCODES_ITEM_N_f_F(N, f, FLABEL, GCODES) MENU_ITEM_N_f_F(gcode, N, f, FLABEL, GCODES)
#define GCODES_ITEM_N_f(N, f, LABEL, GCODES) GCODES_ITEM_N_f_F(N, f, GET_TEXT_F(LABEL), GCODES)
#define GCODES_ITEM_f_F(f, FLABEL, GCODES) MENU_ITEM_f_F(gcode, f, FLABEL, GCODES)
#define GCODES_ITEM_f(f, LABEL, GCODES) GCODES_ITEM_f_F(f, GET_TEXT_F(LABEL), GCODES)
#define SUBMENU_N_f_F(N, f, FLABEL, DEST) MENU_ITEM_N_f_F(submenu, N, f, FLABEL, DEST)
#define SUBMENU_N_f(N, f, LABEL, DEST) SUBMENU_N_f_F(N, f, GET_TEXT_F(LABEL), DEST)
#define SUBMENU_f_F(f, FLABEL, DEST) MENU_ITEM_f_F(submenu, f, FLABEL, DEST)
#define SUBMENU_f(f, LABEL, DEST) SUBMENU_f_F(f, GET_TEXT_F(LABEL), DEST)
#define EDIT_ITEM_N_f_F(TYPE, N, f, FLABEL, V...) MENU_ITEM_N_f_F(TYPE, N, f, FLABEL, ##V)
#define EDIT_ITEM_N_f(TYPE, N, f, LABEL, V...) EDIT_ITEM_N_f_F(TYPE, N, f, GET_TEXT_F(LABEL), ##V)
#define EDIT_ITEM_f_F(TYPE, f, FLABEL, V...) MENU_ITEM_f_F(TYPE, f, FLABEL, ##V)
#define EDIT_ITEM_f(TYPE, f, LABEL, V...) EDIT_ITEM_f_F(TYPE, f, GET_TEXT_F(LABEL), ##V)
#define EDIT_ITEM_FAST_N_f_F(TYPE, N, f, FLABEL, V...) _MENU_ITEM_N_f_F(TYPE, N, f, true, FLABEL, ##V)
#define EDIT_ITEM_FAST_N_f(TYPE, N, f, LABEL, V...) EDIT_ITEM_FAST_N_f_F(TYPE, N, f, true, GET_TEXT_F(LABEL), ##V)
#define EDIT_ITEM_FAST_f_F(TYPE, f, FLABEL, V...) _MENU_ITEM_f_F(TYPE, f, true, FLABEL, ##V)
#define EDIT_ITEM_FAST_f(TYPE, f, LABEL, V...) EDIT_ITEM_FAST_f_F(TYPE, f, GET_TEXT_F(LABEL), ##V)
#define _CONFIRM_ITEM_INNER_F(FLABEL, V...) do { \
if (encoderLine == _thisItemNr && ui.use_click()) { \
ui.push_current_screen(); \

View File

@@ -57,6 +57,8 @@
// "Motion" > "Move Axis" submenu
//
// TODO: Use substitution here with MSG_MOVE_N
static void _lcd_move_xyz(FSTR_P const name, const AxisEnum axis) {
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
if (ui.encoderPosition && !ui.manual_move.processing) {
@@ -187,22 +189,8 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int
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 && (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_F(FPSTR(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();
#else
SUBMENU_F(FPSTR(tmp), []{ _goto_manual_move(float(FINE_MANUAL_MOVE)); });
#endif
}
if (axis == Z_AXIS && (FINE_MANUAL_MOVE) > 0.0f && (FINE_MANUAL_MOVE) < 0.1f)
SUBMENU_f(F(STRINGIFY(FINE_MANUAL_MOVE)), MSG_MOVE_N_MM, []{ _goto_manual_move(float(FINE_MANUAL_MOVE)); });
}
END_MENU();
}

View File

@@ -68,21 +68,8 @@ void probe_offset_wizard_menu() {
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_F(FPSTR(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_F(tmp, []{ _goto_manual_move_z(float(FINE_MANUAL_MOVE)); });
#endif
}
if ((FINE_MANUAL_MOVE) > 0.0f && (FINE_MANUAL_MOVE) < 0.1f)
SUBMENU_f(F(STRINGIFY(FINE_MANUAL_MOVE)), MSG_MOVE_N_MM, []{ _goto_manual_move_z(float(FINE_MANUAL_MOVE)); });
ACTION_ITEM(MSG_BUTTON_DONE, []{
set_offset_and_go_back(calculated_z_offset);

View File

@@ -88,14 +88,14 @@ void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t i
// 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); }); \
ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_both(M, MenuItemBase::itemIndex); }); \
ACTION_ITEM_N_f(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); })
#define PREHEAT_ITEMS(M,E) ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_end(M, MenuItemBase::itemIndex); })
#endif
@@ -112,16 +112,16 @@ void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t i
#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);
ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, []{ _preheat_both(editable.int8, 0); });
ACTION_ITEM_f(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);
ACTION_ITEM_f(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, []() {
ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M_ALL, []() {
const celsius_t t = ui.material_preset[editable.int8].hotend_temp;
HOTEND_LOOP() thermalManager.setTargetHotend(t, e);
TERN(HAS_HEATED_BED, _preheat_bed(editable.int8), ui.return_to_status());
@@ -130,7 +130,7 @@ void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t i
#endif
#if HAS_HEATED_BED
ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M_BEDONLY, []{ _preheat_bed(editable.int8); });
ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M_BEDONLY, []{ _preheat_bed(editable.int8); });
#endif
END_MENU();
@@ -269,9 +269,9 @@ void menu_temperature() {
LOOP_L_N(m, PREHEAT_COUNT) {
editable.int8 = m;
#if HAS_MULTI_HOTEND || HAS_HEATED_BED
SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m);
SUBMENU_f(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);
ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
#endif
}
#endif
@@ -296,9 +296,9 @@ void menu_temperature() {
LOOP_L_N(m, PREHEAT_COUNT) {
editable.int8 = m;
#if HAS_MULTI_HOTEND || HAS_HEATED_BED
SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m);
SUBMENU_f(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);
ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
#endif
}

View File

@@ -50,6 +50,8 @@
#include "../dogm/marlinui_DOGM.h"
#endif
// TODO: Replace fmsg with MSG_BABYSTEP_N and index substitution
void _lcd_babystep(const AxisEnum axis, FSTR_P const fmsg) {
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
if (ui.encoderPosition) {
@@ -223,13 +225,13 @@ void menu_tune() {
//
#if ENABLED(BABYSTEPPING)
#if ENABLED(BABYSTEP_XY)
SUBMENU(MSG_BABYSTEP_X, []{ _lcd_babystep_go(_lcd_babystep_x); });
SUBMENU(MSG_BABYSTEP_Y, []{ _lcd_babystep_go(_lcd_babystep_y); });
SUBMENU_N(X_AXIS, MSG_BABYSTEP_N, []{ _lcd_babystep_go(_lcd_babystep_x); });
SUBMENU_N(Y_AXIS, MSG_BABYSTEP_N, []{ _lcd_babystep_go(_lcd_babystep_y); });
#endif
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
#else
SUBMENU(MSG_BABYSTEP_Z, lcd_babystep_z);
SUBMENU_N(Z_AXIS, MSG_BABYSTEP_N, lcd_babystep_z);
#endif
#endif

View File

@@ -211,10 +211,10 @@ void _lcd_ubl_edit_mesh() {
#if HAS_PREHEAT
#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, F("G28\nG26CPI" STRINGIFY(M)));
GCODES_ITEM_N_f(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, F("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, F("G28\nG26CPB0I" STRINGIFY(M)));
GCODES_ITEM_N_f(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, F("G28\nG26CPB0I" STRINGIFY(M)));
#endif
REPEAT(PREHEAT_COUNT, VALIDATE_MESH_GCODE_ITEM)
#endif
@@ -317,7 +317,7 @@ void _lcd_ubl_build_mesh() {
#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, \
#define BUILD_MESH_GCODE_ITEM(M) GCODES_ITEM_f(ui.get_preheat_label(M), MSG_UBL_BUILD_MESH_M, \
F( \
"G28\n" \
PREHEAT_BED_GCODE(M) \

View File

@@ -100,19 +100,10 @@ void xatc_wizard_menu() {
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_F(FPSTR(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_F(FPSTR(tmp), []{ _goto_manual_move_z(float(FINE_MANUAL_MOVE)); });
#endif
SUBMENU_f(F(STRINGIFY(FINE_MANUAL_MOVE)), MSG_MOVE_N_MM, []{ _goto_manual_move_z(float(FINE_MANUAL_MOVE)); });
}
ACTION_ITEM(MSG_BUTTON_DONE, xatc_wizard_set_offset_and_go_to_next_point);