Browse Source

Use handle_reprapworld_keypad for keypad handling

Scott Lahteine 8 years ago
parent
commit
2b5d424394
1 changed files with 35 additions and 30 deletions
  1. 35
    30
      Marlin/ultralcd.cpp

+ 35
- 30
Marlin/ultralcd.cpp View File

@@ -2502,6 +2502,39 @@ void kill_screen(const char* lcd_msg) {
2502 2502
     void reprapworld_keypad_move_y_down()  { _reprapworld_keypad_move(Y_AXIS,  1); }
2503 2503
     void reprapworld_keypad_move_home()    { enqueue_and_echo_commands_P(PSTR("G28")); } // move all axes home and wait
2504 2504
     void reprapworld_keypad_move_menu()    { lcd_goto_screen(lcd_move_menu); }
2505
+
2506
+    inline void handle_reprapworld_keypad() {
2507
+
2508
+      static uint8_t keypad_debounce = 0;
2509
+
2510
+      if (!REPRAPWORLD_KEYPAD_PRESSED) {
2511
+        if (keypad_debounce > 0) keypad_debounce--;
2512
+      }
2513
+      else if (!keypad_debounce) {
2514
+        keypad_debounce = 2;
2515
+
2516
+        if (REPRAPWORLD_KEYPAD_MOVE_MENU)       reprapworld_keypad_move_menu();
2517
+
2518
+        #if DISABLED(DELTA) && Z_HOME_DIR == -1
2519
+          if (REPRAPWORLD_KEYPAD_MOVE_Z_UP)     reprapworld_keypad_move_z_up();
2520
+        #endif
2521
+
2522
+        if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) {
2523
+          #if ENABLED(DELTA) || Z_HOME_DIR != -1
2524
+            if (REPRAPWORLD_KEYPAD_MOVE_Z_UP)   reprapworld_keypad_move_z_up();
2525
+          #endif
2526
+          if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN)   reprapworld_keypad_move_z_down();
2527
+          if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT)   reprapworld_keypad_move_x_left();
2528
+          if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT)  reprapworld_keypad_move_x_right();
2529
+          if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN)   reprapworld_keypad_move_y_down();
2530
+          if (REPRAPWORLD_KEYPAD_MOVE_Y_UP)     reprapworld_keypad_move_y_up();
2531
+        }
2532
+        else {
2533
+          if (REPRAPWORLD_KEYPAD_MOVE_HOME)     reprapworld_keypad_move_home();
2534
+        }
2535
+      }
2536
+    }
2537
+
2505 2538
   #endif // REPRAPWORLD_KEYPAD
2506 2539
 
2507 2540
   /**
@@ -2773,36 +2806,8 @@ void lcd_update() {
2773 2806
       #endif
2774 2807
 
2775 2808
       #if ENABLED(REPRAPWORLD_KEYPAD)
2776
-
2777
-        static uint8_t keypad_debounce = 0;
2778
-
2779
-        if (!REPRAPWORLD_KEYPAD_PRESSED) {
2780
-          if (keypad_debounce > 0) keypad_debounce--;
2781
-        }
2782
-        else if (!keypad_debounce) {
2783
-          keypad_debounce = 2;
2784
-
2785
-          if (REPRAPWORLD_KEYPAD_MOVE_MENU)       reprapworld_keypad_move_menu();
2786
-
2787
-          #if DISABLED(DELTA) && Z_HOME_DIR == -1
2788
-            if (REPRAPWORLD_KEYPAD_MOVE_Z_UP)     reprapworld_keypad_move_z_up();
2789
-          #endif
2790
-
2791
-          if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) {
2792
-            #if ENABLED(DELTA) || Z_HOME_DIR != -1
2793
-              if (REPRAPWORLD_KEYPAD_MOVE_Z_UP)   reprapworld_keypad_move_z_up();
2794
-            #endif
2795
-            if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN)   reprapworld_keypad_move_z_down();
2796
-            if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT)   reprapworld_keypad_move_x_left();
2797
-            if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT)  reprapworld_keypad_move_x_right();
2798
-            if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN)   reprapworld_keypad_move_y_down();
2799
-            if (REPRAPWORLD_KEYPAD_MOVE_Y_UP)     reprapworld_keypad_move_y_up();
2800
-          }
2801
-          else {
2802
-            if (REPRAPWORLD_KEYPAD_MOVE_HOME)     reprapworld_keypad_move_home();
2803
-          }
2804
-        }
2805
-      #endif // REPRAPWORLD_KEYPAD
2809
+        handle_reprapworld_keypad();
2810
+      #endif
2806 2811
 
2807 2812
       bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
2808 2813
       if (encoderPastThreshold || lcd_clicked) {

Loading…
Cancel
Save