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
     #if BUTTON_EXISTS(EN1)
4862
     #if BUTTON_EXISTS(EN1)
4863
       SET_INPUT_PULLUP(BTN_EN1);
4863
       SET_INPUT_PULLUP(BTN_EN1);
4864
     #endif
4864
     #endif
4865
-
4866
     #if BUTTON_EXISTS(EN2)
4865
     #if BUTTON_EXISTS(EN2)
4867
       SET_INPUT_PULLUP(BTN_EN2);
4866
       SET_INPUT_PULLUP(BTN_EN2);
4868
     #endif
4867
     #endif
4869
-
4870
     #if BUTTON_EXISTS(ENC)
4868
     #if BUTTON_EXISTS(ENC)
4871
       SET_INPUT_PULLUP(BTN_ENC);
4869
       SET_INPUT_PULLUP(BTN_ENC);
4872
     #endif
4870
     #endif
5011
       }
5009
       }
5012
     }
5010
     }
5013
     else wait_for_unclick = false;
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
   #endif
5020
   #endif
5015
 
5021
 
5016
   #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
5022
   #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
5374
         #if BUTTON_EXISTS(EN1)
5380
         #if BUTTON_EXISTS(EN1)
5375
           if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
5381
           if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
5376
         #endif
5382
         #endif
5377
-
5378
         #if BUTTON_EXISTS(EN2)
5383
         #if BUTTON_EXISTS(EN2)
5379
           if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
5384
           if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
5380
         #endif
5385
         #endif
5381
-
5382
         #if BUTTON_EXISTS(ENC)
5386
         #if BUTTON_EXISTS(ENC)
5383
           if (BUTTON_PRESSED(ENC)) newbutton |= EN_C;
5387
           if (BUTTON_PRESSED(ENC)) newbutton |= EN_C;
5384
         #endif
5388
         #endif
5389
+        #if BUTTON_EXISTS(BACK)
5390
+          if (BUTTON_PRESSED(BACK)) newbutton |= EN_D;
5391
+        #endif
5385
 
5392
 
5386
         //
5393
         //
5387
         // Directional buttons
5394
         // Directional buttons

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

44
     constexpr bool lcd_external_control = false;
44
     constexpr bool lcd_external_control = false;
45
   #endif
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
   extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
47
   extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
51
 
48
 
52
   #if ENABLED(LCD_BED_LEVELING)
49
   #if ENABLED(LCD_BED_LEVELING)
96
   #endif
93
   #endif
97
 
94
 
98
   #define LCD_UPDATE_INTERVAL 100
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
   #if ENABLED(ULTIPANEL)
99
   #if ENABLED(ULTIPANEL)
101
 
100
 
107
 
106
 
108
     void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder=0);
107
     void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder=0);
109
 
108
 
109
+    // Encoder click is directly connected
110
+
110
     #define BLEN_A 0
111
     #define BLEN_A 0
111
     #define BLEN_B 1
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
     #if BUTTON_EXISTS(ENC)
117
     #if BUTTON_EXISTS(ENC)
114
       #define BLEN_C 2
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
     #endif
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
     extern volatile uint8_t buttons;  // The last-checked buttons in a bit array.
128
     extern volatile uint8_t buttons;  // The last-checked buttons in a bit array.
121
     void lcd_buttons_update();
129
     void lcd_buttons_update();
213
                                             )
221
                                             )
214
 
222
 
215
   #elif ENABLED(NEWPANEL)
223
   #elif ENABLED(NEWPANEL)
224
+
216
     #define LCD_CLICKED (buttons & EN_C)
225
     #define LCD_CLICKED (buttons & EN_C)
226
+
217
   #else
227
   #else
228
+
218
     #define LCD_CLICKED false
229
     #define LCD_CLICKED false
230
+
219
   #endif
231
   #endif
220
 
232
 
221
   #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
233
   #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)

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

78
     #define B_DW (BUTTON_DOWN<<B_I2C_BTN_OFFSET)
78
     #define B_DW (BUTTON_DOWN<<B_I2C_BTN_OFFSET)
79
     #define B_RI (BUTTON_RIGHT<<B_I2C_BTN_OFFSET)
79
     #define B_RI (BUTTON_RIGHT<<B_I2C_BTN_OFFSET)
80
 
80
 
81
+    #undef LCD_CLICKED
81
     #if BUTTON_EXISTS(ENC)
82
     #if BUTTON_EXISTS(ENC)
82
       // the pause/stop/restart button is connected to BTN_ENC when used
83
       // the pause/stop/restart button is connected to BTN_ENC when used
83
       #define B_ST (EN_C)                            // Map the pause/stop/resume button into its normalized functional name
84
       #define B_ST (EN_C)                            // Map the pause/stop/resume button into its normalized functional name
84
-      #undef LCD_CLICKED
85
       #define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
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
     #else
86
     #else
87
-      #undef LCD_CLICKED
88
       #define LCD_CLICKED (buttons&(B_MI|B_RI))
87
       #define LCD_CLICKED (buttons&(B_MI|B_RI))
89
     #endif
88
     #endif
90
 
89
 

Loading…
Cancel
Save