From 06ac1f3bcfa4d4b44fa1127829a489cd738b040a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 4 Jun 2016 01:09:59 -0700 Subject: [PATCH] Reduce Reprapworld Keypad move code size --- Marlin/ultralcd.cpp | 48 ++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index fbdcb8a40c..baf04a14f5 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -2310,42 +2310,24 @@ void kill_screen(const char* lcd_msg) { * */ #if ENABLED(REPRAPWORLD_KEYPAD) - static void reprapworld_keypad_move_z_up() { - encoderPosition = 1; + static void _reprapworld_keypad_move(AxisEnum axis, int dir) { move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP; - lcd_move_z(); - } - static void reprapworld_keypad_move_z_down() { - encoderPosition = -1; - move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP; - lcd_move_z(); - } - static void reprapworld_keypad_move_x_left() { - encoderPosition = -1; - move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP; - lcd_move_x(); - } - static void reprapworld_keypad_move_x_right() { - encoderPosition = 1; - move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP; - lcd_move_x(); - } - static void reprapworld_keypad_move_y_down() { - encoderPosition = 1; - move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP; - lcd_move_y(); - } - static void reprapworld_keypad_move_y_up() { - encoderPosition = -1; - move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP; - lcd_move_y(); - } - static void reprapworld_keypad_move_home() { - enqueue_and_echo_commands_P(PSTR("G28")); // move all axes home + encoderPosition = dir; + switch (axis) { + case X_AXIS: lcd_move_x(); break; + case Y_AXIS: lcd_move_y(); break; + case Z_AXIS: lcd_move_z(); + } } + static void reprapworld_keypad_move_z_up() { _reprapworld_keypad_move(Z_AXIS, 1); } + static void reprapworld_keypad_move_z_down() { _reprapworld_keypad_move(Z_AXIS, -1); } + static void reprapworld_keypad_move_x_left() { _reprapworld_keypad_move(X_AXIS, -1); } + static void reprapworld_keypad_move_x_right() { _reprapworld_keypad_move(X_AXIS, 1); } + static void reprapworld_keypad_move_y_up() { _reprapworld_keypad_move(Y_AXIS, -1); } + static void reprapworld_keypad_move_y_down() { _reprapworld_keypad_move(Y_AXIS, 1); } + static void reprapworld_keypad_move_home() { enqueue_and_echo_commands_P(PSTR("G28")); } // move all axes home and wait #endif // REPRAPWORLD_KEYPAD - /** * * Audio feedback for controller clicks @@ -2657,7 +2639,7 @@ void lcd_update() { return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS; lcdDrawUpdate = LCDVIEW_REDRAW_NOW; } - #endif //ULTIPANEL + #endif // ULTIPANEL // We arrive here every ~100ms when idling often enough. // Instead of tracking the changes simply redraw the Info Screen ~1 time a second.