Browse Source

Merge pull request #3428 from thinkyhead/rc_consolidate_reprap_keypad

Consolidate REPRAPWORLD_KEYPAD, disallow moves for unhomed Delta/SCARA
Scott Lahteine 8 years ago
parent
commit
047c412df6
3 changed files with 58 additions and 55 deletions
  1. 17
    8
      Marlin/ultralcd.cpp
  2. 39
    22
      Marlin/ultralcd.h
  3. 2
    25
      Marlin/ultralcd_implementation_hitachi_HD44780.h

+ 17
- 8
Marlin/ultralcd.cpp View File

@@ -1842,7 +1842,7 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01);
1842 1842
     lcd_move_y();
1843 1843
   }
1844 1844
   static void reprapworld_keypad_move_home() {
1845
-    enqueue_and_echo_commands_P((PSTR("G28"))); // move all axis home
1845
+    enqueue_and_echo_commands_P(PSTR("G28")); // move all axes home
1846 1846
   }
1847 1847
 #endif // REPRAPWORLD_KEYPAD
1848 1848
 
@@ -2091,13 +2091,22 @@ void lcd_update() {
2091 2091
     #if ENABLED(ULTIPANEL)
2092 2092
 
2093 2093
       #if ENABLED(REPRAPWORLD_KEYPAD)
2094
-        if (REPRAPWORLD_KEYPAD_MOVE_Z_UP)     reprapworld_keypad_move_z_up();
2095
-        if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN)   reprapworld_keypad_move_z_down();
2096
-        if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT)   reprapworld_keypad_move_x_left();
2097
-        if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT)  reprapworld_keypad_move_x_right();
2098
-        if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN)   reprapworld_keypad_move_y_down();
2099
-        if (REPRAPWORLD_KEYPAD_MOVE_Y_UP)     reprapworld_keypad_move_y_up();
2100
-        if (REPRAPWORLD_KEYPAD_MOVE_HOME)     reprapworld_keypad_move_home();
2094
+
2095
+        #if ENABLED(DELTA) || ENABLED(SCARA)
2096
+          #define _KEYPAD_MOVE_ALLOWED (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
2097
+        #else
2098
+          #define _KEYPAD_MOVE_ALLOWED true
2099
+        #endif
2100
+
2101
+        if (REPRAPWORLD_KEYPAD_MOVE_HOME)       reprapworld_keypad_move_home();
2102
+        if (_KEYPAD_MOVE_ALLOWED) {
2103
+          if (REPRAPWORLD_KEYPAD_MOVE_Z_UP)     reprapworld_keypad_move_z_up();
2104
+          if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN)   reprapworld_keypad_move_z_down();
2105
+          if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT)   reprapworld_keypad_move_x_left();
2106
+          if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT)  reprapworld_keypad_move_x_right();
2107
+          if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN)   reprapworld_keypad_move_y_down();
2108
+          if (REPRAPWORLD_KEYPAD_MOVE_Y_UP)     reprapworld_keypad_move_y_up();
2109
+        }
2101 2110
       #endif
2102 2111
 
2103 2112
       bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);

+ 39
- 22
Marlin/ultralcd.h View File

@@ -65,9 +65,6 @@
65 65
   #if ENABLED(ULTIPANEL)
66 66
     void lcd_buttons_update();
67 67
     extern volatile uint8_t buttons;  //the last checked buttons in a bit array.
68
-    #if ENABLED(REPRAPWORLD_KEYPAD)
69
-      extern volatile uint8_t buttons_reprapworld_keypad; // to store the keypad shift register values
70
-    #endif
71 68
   #else
72 69
     FORCE_INLINE void lcd_buttons_update() {}
73 70
   #endif
@@ -89,33 +86,52 @@
89 86
   void lcd_ignore_click(bool b=true);
90 87
   bool lcd_blink();
91 88
 
89
+  #if ENABLED(ULTIPANEL) && ENABLED(REPRAPWORLD_KEYPAD)
90
+
91
+    #define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values
92
+
93
+    #define BLEN_REPRAPWORLD_KEYPAD_F3     0
94
+    #define BLEN_REPRAPWORLD_KEYPAD_F2     1
95
+    #define BLEN_REPRAPWORLD_KEYPAD_F1     2
96
+    #define BLEN_REPRAPWORLD_KEYPAD_DOWN   3
97
+    #define BLEN_REPRAPWORLD_KEYPAD_RIGHT  4
98
+    #define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5
99
+    #define BLEN_REPRAPWORLD_KEYPAD_UP     6
100
+    #define BLEN_REPRAPWORLD_KEYPAD_LEFT   7
101
+
102
+    #define EN_REPRAPWORLD_KEYPAD_F3      (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F3))
103
+    #define EN_REPRAPWORLD_KEYPAD_F2      (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F2))
104
+    #define EN_REPRAPWORLD_KEYPAD_F1      (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F1))
105
+    #define EN_REPRAPWORLD_KEYPAD_DOWN    (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_DOWN))
106
+    #define EN_REPRAPWORLD_KEYPAD_RIGHT   (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_RIGHT))
107
+    #define EN_REPRAPWORLD_KEYPAD_MIDDLE  (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
108
+    #define EN_REPRAPWORLD_KEYPAD_UP      (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_UP))
109
+    #define EN_REPRAPWORLD_KEYPAD_LEFT    (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_LEFT))
110
+
111
+    #define REPRAPWORLD_KEYPAD_MOVE_Z_DOWN  (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F3)
112
+    #define REPRAPWORLD_KEYPAD_MOVE_Z_UP    (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F2)
113
+    #define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN  (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN)
114
+    #define REPRAPWORLD_KEYPAD_MOVE_X_RIGHT (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT)
115
+    #define REPRAPWORLD_KEYPAD_MOVE_HOME    (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_MIDDLE)
116
+    #define REPRAPWORLD_KEYPAD_MOVE_Y_UP    (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP)
117
+    #define REPRAPWORLD_KEYPAD_MOVE_X_LEFT  (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT)
118
+
119
+  #endif //ULTIPANEL && REPRAPWORLD_KEYPAD
120
+
92 121
   #if ENABLED(NEWPANEL)
122
+
93 123
     #define EN_C (_BV(BLEN_C))
94 124
     #define EN_B (_BV(BLEN_B))
95 125
     #define EN_A (_BV(BLEN_A))
96 126
 
97 127
     #if ENABLED(REPRAPWORLD_KEYPAD)
98
-      #define EN_REPRAPWORLD_KEYPAD_F3 (_BV(BLEN_REPRAPWORLD_KEYPAD_F3))
99
-      #define EN_REPRAPWORLD_KEYPAD_F2 (_BV(BLEN_REPRAPWORLD_KEYPAD_F2))
100
-      #define EN_REPRAPWORLD_KEYPAD_F1 (_BV(BLEN_REPRAPWORLD_KEYPAD_F1))
101
-      #define EN_REPRAPWORLD_KEYPAD_UP (_BV(BLEN_REPRAPWORLD_KEYPAD_UP))
102
-      #define EN_REPRAPWORLD_KEYPAD_RIGHT (_BV(BLEN_REPRAPWORLD_KEYPAD_RIGHT))
103
-      #define EN_REPRAPWORLD_KEYPAD_MIDDLE (_BV(BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
104
-      #define EN_REPRAPWORLD_KEYPAD_DOWN (_BV(BLEN_REPRAPWORLD_KEYPAD_DOWN))
105
-      #define EN_REPRAPWORLD_KEYPAD_LEFT (_BV(BLEN_REPRAPWORLD_KEYPAD_LEFT))
106
-
107 128
       #define LCD_CLICKED ((buttons&EN_C) || (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F1))
108
-      #define REPRAPWORLD_KEYPAD_MOVE_Z_UP (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F2)
109
-      #define REPRAPWORLD_KEYPAD_MOVE_Z_DOWN (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F3)
110
-      #define REPRAPWORLD_KEYPAD_MOVE_X_LEFT (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_LEFT)
111
-      #define REPRAPWORLD_KEYPAD_MOVE_X_RIGHT (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_RIGHT)
112
-      #define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_DOWN)
113
-      #define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_UP)
114
-      #define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_MIDDLE)
115 129
     #else
116 130
       #define LCD_CLICKED (buttons&EN_C)
117
-    #endif //REPRAPWORLD_KEYPAD
118
-  #else
131
+    #endif
132
+
133
+  #else //!NEWPANEL
134
+
119 135
     //atomic, do not change
120 136
     #define B_LE (_BV(BL_LE))
121 137
     #define B_UP (_BV(BL_UP))
@@ -127,7 +143,8 @@
127 143
     #define EN_A (_BV(BLEN_A))
128 144
 
129 145
     #define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
130
-  #endif//NEWPANEL
146
+
147
+  #endif //!NEWPANEL
131 148
 
132 149
 #else //no LCD
133 150
   FORCE_INLINE void lcd_update() {}

+ 2
- 25
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

@@ -98,31 +98,8 @@ extern volatile uint8_t buttons;  //an extended version of the last checked butt
98 98
     #endif
99 99
 
100 100
   #elif ENABLED(REPRAPWORLD_KEYPAD)
101
-    // define register bit values, don't change it
102
-    #define BLEN_REPRAPWORLD_KEYPAD_F3 0
103
-    #define BLEN_REPRAPWORLD_KEYPAD_F2 1
104
-    #define BLEN_REPRAPWORLD_KEYPAD_F1 2
105
-    #define BLEN_REPRAPWORLD_KEYPAD_UP 6
106
-    #define BLEN_REPRAPWORLD_KEYPAD_RIGHT 4
107
-    #define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5
108
-    #define BLEN_REPRAPWORLD_KEYPAD_DOWN 3
109
-    #define BLEN_REPRAPWORLD_KEYPAD_LEFT 7
110
-
111
-    #define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values
112
-
113
-    #define EN_REPRAPWORLD_KEYPAD_F3 (_BV(BLEN_REPRAPWORLD_KEYPAD_F3+REPRAPWORLD_BTN_OFFSET))
114
-    #define EN_REPRAPWORLD_KEYPAD_F2 (_BV(BLEN_REPRAPWORLD_KEYPAD_F2+REPRAPWORLD_BTN_OFFSET))
115
-    #define EN_REPRAPWORLD_KEYPAD_F1 (_BV(BLEN_REPRAPWORLD_KEYPAD_F1+REPRAPWORLD_BTN_OFFSET))
116
-    #define EN_REPRAPWORLD_KEYPAD_UP (_BV(BLEN_REPRAPWORLD_KEYPAD_UP+REPRAPWORLD_BTN_OFFSET))
117
-    #define EN_REPRAPWORLD_KEYPAD_RIGHT (_BV(BLEN_REPRAPWORLD_KEYPAD_RIGHT+REPRAPWORLD_BTN_OFFSET))
118
-    #define EN_REPRAPWORLD_KEYPAD_MIDDLE (_BV(BLEN_REPRAPWORLD_KEYPAD_MIDDLE+REPRAPWORLD_BTN_OFFSET))
119
-    #define EN_REPRAPWORLD_KEYPAD_DOWN (_BV(BLEN_REPRAPWORLD_KEYPAD_DOWN+REPRAPWORLD_BTN_OFFSET))
120
-    #define EN_REPRAPWORLD_KEYPAD_LEFT (_BV(BLEN_REPRAPWORLD_KEYPAD_LEFT+REPRAPWORLD_BTN_OFFSET))
121
-
122
-    //#define LCD_CLICKED ((buttons&EN_C) || (buttons&EN_REPRAPWORLD_KEYPAD_F1))
123
-    //#define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons&EN_REPRAPWORLD_KEYPAD_DOWN)
124
-    //#define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons&EN_REPRAPWORLD_KEYPAD_UP)
125
-    //#define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons&EN_REPRAPWORLD_KEYPAD_MIDDLE)
101
+
102
+    // REPRAPWORLD_KEYPAD defined in ultralcd.h
126 103
 
127 104
   #elif ENABLED(NEWPANEL)
128 105
     #define LCD_CLICKED (buttons&EN_C)

Loading…
Cancel
Save