Allow both encoder and ADC keypad (#13355)

This commit is contained in:
7eggert 2019-03-12 00:10:56 +01:00 committed by Scott Lahteine
parent 31ff7da7ac
commit 10c8c034bd
4 changed files with 16 additions and 11 deletions

View File

@ -194,7 +194,8 @@
#define DECREMENT_(n) DEC_ ##n
#define DECREMENT(n) DECREMENT_(n)
#define PIN_EXISTS(PN) (defined(PN ##_PIN) && PN ##_PIN >= 0)
#define PIN_EXISTS(PN) (defined(PN ##_PIN) && PN ##_PIN >= 0)
#define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
#define MMM_TO_MMS(MM_M) ((MM_M)/60.0f)
#define MMS_TO_MMM(MM_S) ((MM_S)*60.0f)

View File

@ -320,12 +320,6 @@
#define HAS_LCD_MENU (ENABLED(ULTIPANEL) && DISABLED(NO_LCD_MENUS))
#define HAS_ADC_BUTTONS ENABLED(ADC_KEYPAD)
#define HAS_DIGITAL_BUTTONS (!HAS_ADC_BUTTONS && ENABLED(NEWPANEL))
#define HAS_SHIFT_ENCODER (!HAS_ADC_BUTTONS && (ENABLED(REPRAPWORLD_KEYPAD) || (HAS_SPI_LCD && DISABLED(NEWPANEL))))
#define HAS_ENCODER_WHEEL (!HAS_ADC_BUTTONS && ENABLED(NEWPANEL))
// I2C buttons must be read in the main thread
#define HAS_SLOW_BUTTONS (ENABLED(LCD_I2C_VIKI) || ENABLED(LCD_I2C_PANELOLU2))
#if HAS_GRAPHICAL_LCD
/**

View File

@ -1073,15 +1073,15 @@ void MarlinUI::update() {
| slow_buttons
#endif
;
#elif HAS_ADC_BUTTONS
buttons = 0;
#endif
#if HAS_ADC_BUTTONS
if (keypad_buttons == 0) {
const uint8_t b = get_ADC_keyValue();
if (WITHIN(b, 1, 8)) keypad_buttons = _BV(b - 1);
}
#endif
#if HAS_SHIFT_ENCODER

View File

@ -27,8 +27,19 @@
#include "../libs/buzzer.h"
#endif
#define HAS_DIGITAL_BUTTONS (!HAS_ADC_BUTTONS && ENABLED(NEWPANEL) \
|| (BUTTON_EXISTS(EN1) && BUTTON_EXISTS(EN2)) \
|| BUTTON_EXISTS(ENC) || BUTTON_EXISTS(BACK) \
|| BUTTON_EXISTS(UP) || BUTTON_EXISTS(DWN) \
|| BUTTON_EXISTS(LFT) || BUTTON_EXISTS(RT))
#define HAS_SHIFT_ENCODER (!HAS_ADC_BUTTONS && (ENABLED(REPRAPWORLD_KEYPAD) || (HAS_SPI_LCD && DISABLED(NEWPANEL))))
#define HAS_ENCODER_WHEEL ((!HAS_ADC_BUTTONS && ENABLED(NEWPANEL)) || (BUTTON_EXISTS(EN1) && BUTTON_EXISTS(EN2)) )
#define HAS_ENCODER_ACTION (HAS_LCD_MENU || ENABLED(ULTIPANEL_FEEDMULTIPLY))
// I2C buttons must be read in the main thread
#define HAS_SLOW_BUTTONS (ENABLED(LCD_I2C_VIKI) || ENABLED(LCD_I2C_PANELOLU2))
#if HAS_SPI_LCD
#include "../Marlin.h"
@ -133,7 +144,6 @@
#define EN_A _BV(BLEN_A)
#define EN_B _BV(BLEN_B)
#define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
#define BUTTON_PRESSED(BN) !READ(BTN_## BN)
#if BUTTON_EXISTS(ENC)