Browse Source

Wrangle encoder bits, LCD_CLICKED

Scott Lahteine 8 years ago
parent
commit
03fdb26cd2
4 changed files with 30 additions and 91 deletions
  1. 0
    9
      Marlin/pins_RAMBO.h
  2. 18
    31
      Marlin/ultralcd.h
  3. 1
    12
      Marlin/ultralcd_impl_DOGM.h
  4. 11
    39
      Marlin/ultralcd_impl_HD44780.h

+ 0
- 9
Marlin/pins_RAMBO.h View File

@@ -150,15 +150,6 @@
150 150
     #define LCD_PINS_D6 27
151 151
     #define LCD_PINS_D7 29
152 152
 
153
-    //bits in the shift register that carry the buttons for:
154
-    // left up center down right red
155
-    #define BL_LE 7
156
-    #define BL_UP 6
157
-    #define BL_MI 5
158
-    #define BL_DW 4
159
-    #define BL_RI 3
160
-    #define BL_ST 2
161
-
162 153
   #endif // !NEWPANEL
163 154
 
164 155
 #endif // ULTRA_LCD

+ 18
- 31
Marlin/ultralcd.h View File

@@ -58,7 +58,6 @@
58 58
     void bootscreen();
59 59
   #endif
60 60
 
61
-
62 61
   #define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x))
63 62
   #define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x))
64 63
 
@@ -93,7 +92,20 @@
93 92
 
94 93
   bool lcd_blink();
95 94
 
96
-  #if ENABLED(REPRAPWORLD_KEYPAD)
95
+  #if ENABLED(ULTIPANEL)
96
+    #define BLEN_A 0
97
+    #define BLEN_B 1
98
+    // Encoder click is directly connected
99
+    #if BUTTON_EXISTS(ENC)
100
+      #define BLEN_C 2
101
+      #define EN_C (_BV(BLEN_C))
102
+    #endif
103
+    #define EN_A (_BV(BLEN_A))
104
+    #define EN_B (_BV(BLEN_B))
105
+    #define EN_C (_BV(BLEN_C))
106
+  #endif
107
+
108
+  #if ENABLED(REPRAPWORLD_KEYPAD) // is also ULTIPANEL and NEWPANEL
97 109
 
98 110
     #define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values
99 111
 
@@ -135,35 +147,10 @@
135 147
                                               EN_REPRAPWORLD_KEYPAD_LEFT) \
136 148
                                             )
137 149
 
138
-  #endif // REPRAPWORLD_KEYPAD
139
-
140
-  #if ENABLED(NEWPANEL)
141
-
142
-    #define EN_C (_BV(BLEN_C))
143
-    #define EN_B (_BV(BLEN_B))
144
-    #define EN_A (_BV(BLEN_A))
145
-
146
-    #if ENABLED(REPRAPWORLD_KEYPAD)
147
-      #define LCD_CLICKED ((buttons&EN_C) || (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F1))
148
-    #else
149
-      #define LCD_CLICKED (buttons&EN_C)
150
-    #endif
151
-
152
-  #else //!NEWPANEL
153
-
154
-    //atomic, do not change
155
-    #define B_LE (_BV(BL_LE))
156
-    #define B_UP (_BV(BL_UP))
157
-    #define B_MI (_BV(BL_MI))
158
-    #define B_DW (_BV(BL_DW))
159
-    #define B_RI (_BV(BL_RI))
160
-    #define B_ST (_BV(BL_ST))
161
-    #define EN_B (_BV(BLEN_B))
162
-    #define EN_A (_BV(BLEN_A))
163
-
164
-    #define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
165
-
166
-  #endif //!NEWPANEL
150
+    #define LCD_CLICKED ((buttons & EN_C) || (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F1))
151
+  #elif ENABLED(NEWPANEL)
152
+    #define LCD_CLICKED (buttons & EN_C)
153
+  #endif
167 154
 
168 155
 #else //no LCD
169 156
   FORCE_INLINE void lcd_update() {}

+ 1
- 12
Marlin/ultralcd_impl_DOGM.h View File

@@ -42,20 +42,9 @@
42 42
  * Implementation of the LCD display routines for a DOGM128 graphic display.
43 43
  * These are common LCD 128x64 pixel graphic displays.
44 44
  */
45
-
46
-#if ENABLED(ULTIPANEL)
47
-  #define BLEN_A 0
48
-  #define BLEN_B 1
49
-  #define BLEN_C 2
50
-  #define EN_A (_BV(BLEN_A))
51
-  #define EN_B (_BV(BLEN_B))
52
-  #define EN_C (_BV(BLEN_C))
53
-  #define LCD_CLICKED (buttons&EN_C)
54
-#endif
55
-
56
-#include "dogm_bitmaps.h"
57 45
 #include "ultralcd.h"
58 46
 #include "ultralcd_st7920_u8glib_rrd.h"
47
+#include "dogm_bitmaps.h"
59 48
 #include "duration_t.h"
60 49
 
61 50
 #include <U8glib.h>

+ 11
- 39
Marlin/ultralcd_impl_HD44780.h View File

@@ -39,18 +39,6 @@ extern volatile uint8_t buttons;  //an extended version of the last checked butt
39 39
 // via a shift/i2c register.
40 40
 
41 41
 #if ENABLED(ULTIPANEL)
42
-  // All UltiPanels might have an encoder - so this is always be mapped onto first two bits
43
-  #define BLEN_B 1
44
-  #define BLEN_A 0
45
-
46
-  #define EN_B (_BV(BLEN_B)) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
47
-  #define EN_A (_BV(BLEN_A))
48
-
49
-  #if BUTTON_EXISTS(ENC)
50
-    // encoder click is directly connected
51
-    #define BLEN_C 2
52
-    #define EN_C (_BV(BLEN_C))
53
-  #endif
54 42
 
55 43
   //
56 44
   // Setup other button mappings of each panel
@@ -80,51 +68,35 @@ extern volatile uint8_t buttons;  //an extended version of the last checked butt
80 68
 
81 69
   #elif ENABLED(LCD_I2C_PANELOLU2)
82 70
 
83
-    #if BUTTON_EXISTS(ENC)
84
-
85
-      #undef LCD_CLICKED
86
-      #define LCD_CLICKED (buttons&EN_C)
87
-
88
-    #else // Read through I2C if not directly connected to a pin
71
+    #if !BUTTON_EXISTS(ENC) // Use I2C if not directly connected to a pin
89 72
 
90 73
       #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
91 74
 
92 75
       #define B_MI (PANELOLU2_ENCODER_C<<B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
93 76
 
94 77
       #undef LCD_CLICKED
95
-      #define LCD_CLICKED (buttons&B_MI)
78
+      #define LCD_CLICKED (buttons & B_MI)
96 79
 
97 80
       // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
98 81
       #define LCD_HAS_SLOW_BUTTONS
99 82
 
100 83
     #endif
101 84
 
102
-  #elif ENABLED(REPRAPWORLD_KEYPAD)
103
-
104
-    // REPRAPWORLD_KEYPAD defined in ultralcd.h
105
-
106
-  #elif ENABLED(NEWPANEL)
107
-    #define LCD_CLICKED (buttons&EN_C)
108
-
109
-  #else // old style ULTIPANEL
110
-    //bits in the shift register that carry the buttons for:
111
-    // left up center down right red(stop)
112
-    #define BL_LE 7
113
-    #define BL_UP 6
114
-    #define BL_MI 5
115
-    #define BL_DW 4
116
-    #define BL_RI 3
117
-    #define BL_ST 2
118
-
119
-    //automatic, do not change
85
+  #elif DISABLED(NEWPANEL) // old style ULTIPANEL
86
+    // Shift register bits correspond to buttons:
87
+    #define BL_LE 7   // Left
88
+    #define BL_UP 6   // Up
89
+    #define BL_MI 5   // Middle
90
+    #define BL_DW 4   // Down
91
+    #define BL_RI 3   // Right
92
+    #define BL_ST 2   // Red Button
120 93
     #define B_LE (_BV(BL_LE))
121 94
     #define B_UP (_BV(BL_UP))
122 95
     #define B_MI (_BV(BL_MI))
123 96
     #define B_DW (_BV(BL_DW))
124 97
     #define B_RI (_BV(BL_RI))
125 98
     #define B_ST (_BV(BL_ST))
126
-
127
-    #define LCD_CLICKED (buttons&(B_MI|B_ST))
99
+    #define LCD_CLICKED ((buttons & B_MI) || (buttons & B_ST))
128 100
   #endif
129 101
 
130 102
 #endif //ULTIPANEL

Loading…
Cancel
Save