Browse Source

Add support for BACK button (RADDS) (#9835)

Scott Lahteine 7 years ago
parent
commit
35ec67885a
No account linked to committer's email address
3 changed files with 31 additions and 13 deletions
  1. 11
    4
      Marlin/src/lcd/ultralcd.cpp
  2. 19
    7
      Marlin/src/lcd/ultralcd.h
  3. 1
    2
      Marlin/src/lcd/ultralcd_impl_HD44780.h

+ 11
- 4
Marlin/src/lcd/ultralcd.cpp View File

@@ -4862,11 +4862,9 @@ void lcd_init() {
4862 4862
     #if BUTTON_EXISTS(EN1)
4863 4863
       SET_INPUT_PULLUP(BTN_EN1);
4864 4864
     #endif
4865
-
4866 4865
     #if BUTTON_EXISTS(EN2)
4867 4866
       SET_INPUT_PULLUP(BTN_EN2);
4868 4867
     #endif
4869
-
4870 4868
     #if BUTTON_EXISTS(ENC)
4871 4869
       SET_INPUT_PULLUP(BTN_ENC);
4872 4870
     #endif
@@ -5011,6 +5009,14 @@ void lcd_update() {
5011 5009
       }
5012 5010
     }
5013 5011
     else wait_for_unclick = false;
5012
+
5013
+    #if BUTTON_EXISTS(BACK)
5014
+      if (LCD_BACK_CLICKED) {
5015
+        lcd_quick_feedback();
5016
+        lcd_goto_previous_menu();
5017
+      }
5018
+    #endif
5019
+
5014 5020
   #endif
5015 5021
 
5016 5022
   #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
@@ -5374,14 +5380,15 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
5374 5380
         #if BUTTON_EXISTS(EN1)
5375 5381
           if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
5376 5382
         #endif
5377
-
5378 5383
         #if BUTTON_EXISTS(EN2)
5379 5384
           if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
5380 5385
         #endif
5381
-
5382 5386
         #if BUTTON_EXISTS(ENC)
5383 5387
           if (BUTTON_PRESSED(ENC)) newbutton |= EN_C;
5384 5388
         #endif
5389
+        #if BUTTON_EXISTS(BACK)
5390
+          if (BUTTON_PRESSED(BACK)) newbutton |= EN_D;
5391
+        #endif
5385 5392
 
5386 5393
         //
5387 5394
         // Directional buttons

+ 19
- 7
Marlin/src/lcd/ultralcd.h View File

@@ -44,9 +44,6 @@
44 44
     constexpr bool lcd_external_control = false;
45 45
   #endif
46 46
 
47
-  #define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
48
-  #define BUTTON_PRESSED(BN) !READ(BTN_## BN)
49
-
50 47
   extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
51 48
 
52 49
   #if ENABLED(LCD_BED_LEVELING)
@@ -96,6 +93,8 @@
96 93
   #endif
97 94
 
98 95
   #define LCD_UPDATE_INTERVAL 100
96
+  #define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
97
+  #define BUTTON_PRESSED(BN) !READ(BTN_## BN)
99 98
 
100 99
   #if ENABLED(ULTIPANEL)
101 100
 
@@ -107,15 +106,24 @@
107 106
 
108 107
     void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder=0);
109 108
 
109
+    // Encoder click is directly connected
110
+
110 111
     #define BLEN_A 0
111 112
     #define BLEN_B 1
112
-    // Encoder click is directly connected
113
+
114
+    #define EN_A (_BV(BLEN_A))
115
+    #define EN_B (_BV(BLEN_B))
116
+
113 117
     #if BUTTON_EXISTS(ENC)
114 118
       #define BLEN_C 2
119
+      #define EN_C (_BV(BLEN_C))
120
+    #endif
121
+
122
+    #if BUTTON_EXISTS(BACK)
123
+      #define BLEN_D 3
124
+      #define EN_D BIT(BLEN_D)
125
+      #define LCD_BACK_CLICKED (buttons & EN_D)
115 126
     #endif
116
-    #define EN_A (_BV(BLEN_A))
117
-    #define EN_B (_BV(BLEN_B))
118
-    #define EN_C (_BV(BLEN_C))
119 127
 
120 128
     extern volatile uint8_t buttons;  // The last-checked buttons in a bit array.
121 129
     void lcd_buttons_update();
@@ -213,9 +221,13 @@
213 221
                                             )
214 222
 
215 223
   #elif ENABLED(NEWPANEL)
224
+
216 225
     #define LCD_CLICKED (buttons & EN_C)
226
+
217 227
   #else
228
+
218 229
     #define LCD_CLICKED false
230
+
219 231
   #endif
220 232
 
221 233
   #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)

+ 1
- 2
Marlin/src/lcd/ultralcd_impl_HD44780.h View File

@@ -78,13 +78,12 @@ extern volatile uint8_t buttons;  //an extended version of the last checked butt
78 78
     #define B_DW (BUTTON_DOWN<<B_I2C_BTN_OFFSET)
79 79
     #define B_RI (BUTTON_RIGHT<<B_I2C_BTN_OFFSET)
80 80
 
81
+    #undef LCD_CLICKED
81 82
     #if BUTTON_EXISTS(ENC)
82 83
       // the pause/stop/restart button is connected to BTN_ENC when used
83 84
       #define B_ST (EN_C)                            // Map the pause/stop/resume button into its normalized functional name
84
-      #undef LCD_CLICKED
85 85
       #define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
86 86
     #else
87
-      #undef LCD_CLICKED
88 87
       #define LCD_CLICKED (buttons&(B_MI|B_RI))
89 88
     #endif
90 89
 

Loading…
Cancel
Save