🎨 Macros for optional arguments (#21969)

This commit is contained in:
Scott Lahteine
2021-05-23 21:33:22 -05:00
committed by Scott Lahteine
parent 61f2bb1228
commit e75c3b6c54
28 changed files with 120 additions and 351 deletions

View File

@ -758,13 +758,9 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) {
// Tell ui.update() to start a move to current_position after a short delay.
//
void ManualMove::soon(const AxisEnum move_axis
#if MULTI_E_MANUAL
, const int8_t eindex/*=-1*/
#endif
OPTARG(MULTI_E_MANUAL, const int8_t eindex/*=active_extruder*/)
) {
#if MULTI_E_MANUAL
if (move_axis == E_AXIS) e_index = eindex >= 0 ? eindex : active_extruder;
#endif
TERN_(MULTI_E_MANUAL, if (move_axis == E_AXIS) e_index = eindex);
start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
axis = move_axis;
//SERIAL_ECHOLNPAIR("Post Move with Axis ", AS_CHAR(axis_codes[axis]), " soon.");

View File

@ -182,11 +182,7 @@
static bool constexpr processing = false;
#endif
static void task();
static void soon(const AxisEnum axis
#if MULTI_E_MANUAL
, const int8_t eindex=-1
#endif
);
static void soon(const AxisEnum axis OPTARG(MULTI_E_MANUAL, const int8_t eindex=active_extruder));
};
#endif

View File

@ -94,17 +94,13 @@ void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); }
#if E_MANUAL
static void lcd_move_e(TERN_(MULTI_E_MANUAL, const int8_t eindex=-1)) {
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.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
#if MULTI_E_MANUAL
, eindex
#endif
);
ui.manual_move.soon(E_AXIS OPTARG(MULTI_E_MANUAL, eindex));
ui.refresh(LCDVIEW_REDRAW_NOW);
}
ui.encoderPosition = 0;
@ -139,7 +135,7 @@ void _goto_manual_move(const_float_t 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) {
@ -188,7 +184,7 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int
#if E_MANUAL
inline void _goto_menu_move_distance_e() {
ui.goto_screen([]{ _menu_move_distance(E_AXIS, []{ lcd_move_e(TERN_(MULTI_E_MANUAL, active_extruder)); }, -1); });
ui.goto_screen([]{ _menu_move_distance(E_AXIS, []{ lcd_move_e(); }); });
}
inline void _menu_move_distance_e_maybe() {

View File

@ -724,11 +724,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
drawMessage(msg);
#endif
ui.manual_move.soon(axis
#if MULTI_E_MANUAL
, motionAxisState.e_selection
#endif
);
ui.manual_move.soon(axis OPTARG(MULTI_E_MANUAL, motionAxisState.e_selection));
}
drawAxisValue(axis);

View File

@ -709,11 +709,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
drawMessage(msg);
#endif
ui.manual_move.soon(axis
#if MULTI_E_MANUAL
, motionAxisState.e_selection
#endif
);
ui.manual_move.soon(axis OPTARG(MULTI_E_MANUAL, motionAxisState.e_selection));
}
drawAxisValue(axis);

View File

@ -711,11 +711,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
drawMessage(msg);
#endif
ui.manual_move.soon(axis
#if MULTI_E_MANUAL
, motionAxisState.e_selection
#endif
);
ui.manual_move.soon(axis OPTARG(MULTI_E_MANUAL, motionAxisState.e_selection));
}
drawAxisValue(axis);