|
@@ -1723,17 +1723,17 @@ void lcd_init() {
|
1723
|
1723
|
lcd_implementation_init();
|
1724
|
1724
|
|
1725
|
1725
|
#if ENABLED(NEWPANEL)
|
1726
|
|
- #if BTN_EN1 > 0
|
|
1726
|
+ #if BUTTON_EXISTS(EN1)
|
1727
|
1727
|
SET_INPUT(BTN_EN1);
|
1728
|
1728
|
WRITE(BTN_EN1, HIGH);
|
1729
|
1729
|
#endif
|
1730
|
1730
|
|
1731
|
|
- #if BTN_EN2 > 0
|
|
1731
|
+ #if BUTTON_EXISTS(EN2)
|
1732
|
1732
|
SET_INPUT(BTN_EN2);
|
1733
|
1733
|
WRITE(BTN_EN2, HIGH);
|
1734
|
1734
|
#endif
|
1735
|
1735
|
|
1736
|
|
- #if BTN_ENC > 0
|
|
1736
|
+ #if BUTTON_EXISTS(ENC)
|
1737
|
1737
|
SET_INPUT(BTN_ENC);
|
1738
|
1738
|
WRITE(BTN_ENC, HIGH);
|
1739
|
1739
|
#endif
|
|
@@ -2055,6 +2055,19 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
|
2055
|
2055
|
#define encrot3 1
|
2056
|
2056
|
#endif
|
2057
|
2057
|
|
|
2058
|
+ #define GET_BUTTON_STATES(DST) \
|
|
2059
|
+ uint8_t new_##DST = 0; \
|
|
2060
|
+ WRITE(SHIFT_LD, LOW); \
|
|
2061
|
+ WRITE(SHIFT_LD, HIGH); \
|
|
2062
|
+ for (int8_t i = 0; i < 8; i++) { \
|
|
2063
|
+ new_##DST >>= 1; \
|
|
2064
|
+ if (READ(SHIFT_OUT)) SBI(new_##DST, 7); \
|
|
2065
|
+ WRITE(SHIFT_CLK, HIGH); \
|
|
2066
|
+ WRITE(SHIFT_CLK, LOW); \
|
|
2067
|
+ } \
|
|
2068
|
+ DST = ~new_##DST; //invert it, because a pressed switch produces a logical 0
|
|
2069
|
+
|
|
2070
|
+
|
2058
|
2071
|
/**
|
2059
|
2072
|
* Read encoder buttons from the hardware registers
|
2060
|
2073
|
* Warning: This function is called from interrupt context!
|
|
@@ -2062,67 +2075,47 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
|
2062
|
2075
|
void lcd_buttons_update() {
|
2063
|
2076
|
#if ENABLED(NEWPANEL)
|
2064
|
2077
|
uint8_t newbutton = 0;
|
2065
|
|
- #if BTN_EN1 > 0
|
2066
|
|
- if (READ(BTN_EN1) == 0) newbutton |= EN_A;
|
|
2078
|
+ #if BUTTON_EXISTS(EN1)
|
|
2079
|
+ if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
|
2067
|
2080
|
#endif
|
2068
|
|
- #if BTN_EN2 > 0
|
2069
|
|
- if (READ(BTN_EN2) == 0) newbutton |= EN_B;
|
|
2081
|
+ #if BUTTON_EXISTS(EN2)
|
|
2082
|
+ if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
|
2070
|
2083
|
#endif
|
2071
|
|
- #if ENABLED(RIGIDBOT_PANEL) || BTN_ENC > 0
|
|
2084
|
+ #if ENABLED(RIGIDBOT_PANEL) || BUTTON_EXISTS(ENC)
|
2072
|
2085
|
millis_t now = millis();
|
2073
|
2086
|
#endif
|
2074
|
2087
|
#if ENABLED(RIGIDBOT_PANEL)
|
2075
|
2088
|
if (now > next_button_update_ms) {
|
2076
|
|
- if (READ(BTN_UP) == 0) {
|
|
2089
|
+ if (BUTTON_PRESSED(UP)) {
|
2077
|
2090
|
encoderDiff = -1 * (ENCODER_STEPS_PER_MENU_ITEM);
|
2078
|
2091
|
next_button_update_ms = now + 300;
|
2079
|
2092
|
}
|
2080
|
|
- else if (READ(BTN_DWN) == 0) {
|
|
2093
|
+ else if (BUTTON_PRESSED(DWN)) {
|
2081
|
2094
|
encoderDiff = ENCODER_STEPS_PER_MENU_ITEM;
|
2082
|
2095
|
next_button_update_ms = now + 300;
|
2083
|
2096
|
}
|
2084
|
|
- else if (READ(BTN_LFT) == 0) {
|
|
2097
|
+ else if (BUTTON_PRESSED(LFT)) {
|
2085
|
2098
|
encoderDiff = -1 * (ENCODER_PULSES_PER_STEP);
|
2086
|
2099
|
next_button_update_ms = now + 300;
|
2087
|
2100
|
}
|
2088
|
|
- else if (READ(BTN_RT) == 0) {
|
|
2101
|
+ else if (BUTTON_PRESSED(RT)) {
|
2089
|
2102
|
encoderDiff = ENCODER_PULSES_PER_STEP;
|
2090
|
2103
|
next_button_update_ms = now + 300;
|
2091
|
2104
|
}
|
2092
|
2105
|
}
|
2093
|
2106
|
#endif
|
2094
|
|
- #if BTN_ENC > 0
|
2095
|
|
- if (now > next_button_update_ms && READ(BTN_ENC) == 0) newbutton |= EN_C;
|
|
2107
|
+ #if BUTTON_EXISTS(ENC)
|
|
2108
|
+ if (now > next_button_update_ms && BUTTON_PRESSED(ENC)) newbutton |= EN_C;
|
2096
|
2109
|
#endif
|
2097
|
2110
|
buttons = newbutton;
|
2098
|
2111
|
#if ENABLED(LCD_HAS_SLOW_BUTTONS)
|
2099
|
2112
|
buttons |= slow_buttons;
|
2100
|
2113
|
#endif
|
2101
|
2114
|
#if ENABLED(REPRAPWORLD_KEYPAD)
|
2102
|
|
- // for the reprapworld_keypad
|
2103
|
|
- uint8_t newbutton_reprapworld_keypad = 0;
|
2104
|
|
- WRITE(SHIFT_LD, LOW);
|
2105
|
|
- WRITE(SHIFT_LD, HIGH);
|
2106
|
|
- for (int8_t i = 0; i < 8; i++) {
|
2107
|
|
- newbutton_reprapworld_keypad >>= 1;
|
2108
|
|
- if (READ(SHIFT_OUT)) SBI(newbutton_reprapworld_keypad, 7);
|
2109
|
|
- WRITE(SHIFT_CLK, HIGH);
|
2110
|
|
- WRITE(SHIFT_CLK, LOW);
|
2111
|
|
- }
|
2112
|
|
- buttons_reprapworld_keypad = ~newbutton_reprapworld_keypad; //invert it, because a pressed switch produces a logical 0
|
|
2115
|
+ GET_BUTTON_STATES(buttons_reprapworld_keypad);
|
2113
|
2116
|
#endif
|
2114
|
|
- #else //read it from the shift register
|
2115
|
|
- uint8_t newbutton = 0;
|
2116
|
|
- WRITE(SHIFT_LD, LOW);
|
2117
|
|
- WRITE(SHIFT_LD, HIGH);
|
2118
|
|
- unsigned char tmp_buttons = 0;
|
2119
|
|
- for (int8_t i = 0; i < 8; i++) {
|
2120
|
|
- newbutton >>= 1;
|
2121
|
|
- if (READ(SHIFT_OUT)) SBI(newbutton, 7);
|
2122
|
|
- WRITE(SHIFT_CLK, HIGH);
|
2123
|
|
- WRITE(SHIFT_CLK, LOW);
|
2124
|
|
- }
|
2125
|
|
- buttons = ~newbutton; //invert it, because a pressed switch produces a logical 0
|
|
2117
|
+ #else
|
|
2118
|
+ GET_BUTTON_STATES(buttons);
|
2126
|
2119
|
#endif //!NEWPANEL
|
2127
|
2120
|
|
2128
|
2121
|
#if ENABLED(REVERSE_MENU_DIRECTION)
|