Fix build issues with REPRAPWORLD_KEYPAD (#17038)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
		| @@ -391,7 +391,7 @@ bool MarlinUI::get_blink() { | ||||
|  | ||||
|     void _reprapworld_keypad_move(const AxisEnum axis, const int16_t dir) { | ||||
|       move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP; | ||||
|       encoderPosition = dir; | ||||
|       ui.encoderPosition = dir; | ||||
|       switch (axis) { | ||||
|         case X_AXIS: lcd_move_x(); break; | ||||
|         case Y_AXIS: lcd_move_y(); break; | ||||
| @@ -1149,27 +1149,6 @@ void MarlinUI::update() { | ||||
|  | ||||
| #if HAS_ENCODER_ACTION | ||||
|  | ||||
|   #if DISABLED(ADC_KEYPAD) && (ENABLED(REPRAPWORLD_KEYPAD) || !HAS_DIGITAL_BUTTONS) | ||||
|  | ||||
|     /** | ||||
|      * Setup Rotary Encoder Bit Values (for two pin encoders to indicate movement) | ||||
|      * These values are independent of which pins are used for EN_A and EN_B indications | ||||
|      * The rotary encoder part is also independent to the chipset used for the LCD | ||||
|      */ | ||||
|     #define GET_SHIFT_BUTTON_STATES(DST) \ | ||||
|       uint8_t new_##DST = 0; \ | ||||
|       WRITE(SHIFT_LD, LOW); \ | ||||
|       WRITE(SHIFT_LD, HIGH); \ | ||||
|       for (int8_t i = 0; i < 8; i++) { \ | ||||
|         new_##DST >>= 1; \ | ||||
|         if (READ(SHIFT_OUT)) SBI(new_##DST, 7); \ | ||||
|         WRITE(SHIFT_CLK, HIGH); \ | ||||
|         WRITE(SHIFT_CLK, LOW); \ | ||||
|       } \ | ||||
|       DST = ~new_##DST; //invert it, because a pressed switch produces a logical 0 | ||||
|  | ||||
|   #endif | ||||
|  | ||||
|   /** | ||||
|    * Read encoder buttons from the hardware registers | ||||
|    * Warning: This function is called from interrupt context! | ||||
| @@ -1266,16 +1245,26 @@ void MarlinUI::update() { | ||||
|         } | ||||
|       #endif | ||||
|  | ||||
|       #if HAS_SHIFT_ENCODER | ||||
|  | ||||
|         GET_SHIFT_BUTTON_STATES(( | ||||
|           #if ENABLED(REPRAPWORLD_KEYPAD) | ||||
|             keypad_buttons | ||||
|           #else | ||||
|             buttons | ||||
|           #endif | ||||
|         )); | ||||
|  | ||||
|       #if HAS_SHIFT_ENCODER       | ||||
|         /** | ||||
|          * Set up Rotary Encoder bit values (for two pin encoders to indicate movement). | ||||
|          * These values are independent of which pins are used for EN_A / EN_B indications. | ||||
|          * The rotary encoder part is also independent of the LCD chipset. | ||||
|          */ | ||||
|         uint8_t val = 0; | ||||
|         WRITE(SHIFT_LD, LOW); | ||||
|         WRITE(SHIFT_LD, HIGH); | ||||
|         LOOP_L_N(i, 8) { | ||||
|           val >>= 1; | ||||
|           if (READ(SHIFT_OUT)) SBI(val, 7); | ||||
|           WRITE(SHIFT_CLK, HIGH); | ||||
|           WRITE(SHIFT_CLK, LOW); | ||||
|         } | ||||
|         #if ENABLED(REPRAPWORLD_KEYPAD) | ||||
|           keypad_buttons = ~val; | ||||
|         #else | ||||
|           buttons = ~val; | ||||
|         #endif | ||||
|       #endif | ||||
|  | ||||
|     } // next_button_update_ms | ||||
|   | ||||
| @@ -647,7 +647,7 @@ | ||||
|           #define NEOPIXEL_PIN    25 | ||||
|         #endif | ||||
|  | ||||
|     #endif | ||||
|       #endif | ||||
|  | ||||
|     #elif ENABLED(MINIPANEL) | ||||
|  | ||||
| @@ -685,14 +685,7 @@ | ||||
|       #define BEEPER_PIN        33 | ||||
|  | ||||
|       // Buttons are directly attached to AUX-2 | ||||
|       #if ENABLED(REPRAPWORLD_KEYPAD) | ||||
|         #define SHIFT_OUT       40 | ||||
|         #define SHIFT_CLK       44 | ||||
|         #define SHIFT_LD        42 | ||||
|         #define BTN_EN1         64 | ||||
|         #define BTN_EN2         59 | ||||
|         #define BTN_ENC         63 | ||||
|       #elif ENABLED(PANEL_ONE) | ||||
|       #if ENABLED(PANEL_ONE) | ||||
|         #define BTN_EN1         59   // AUX2 PIN 3 | ||||
|         #define BTN_EN2         63   // AUX2 PIN 4 | ||||
|         #define BTN_ENC         49   // AUX3 PIN 7 | ||||
| @@ -711,3 +704,18 @@ | ||||
|   #endif // NEWPANEL | ||||
|  | ||||
| #endif // HAS_SPI_LCD | ||||
|  | ||||
| #if ENABLED(REPRAPWORLD_KEYPAD) | ||||
|   #define SHIFT_OUT        40 | ||||
|   #define SHIFT_CLK        44 | ||||
|   #define SHIFT_LD         42 | ||||
|   #ifndef BTN_EN1 | ||||
|     #define BTN_EN1        64 | ||||
|   #endif | ||||
|   #ifndef BTN_EN2 | ||||
|     #define BTN_EN2        59 | ||||
|   #endif | ||||
|   #ifndef BTN_ENC | ||||
|     #define BTN_ENC        63 | ||||
|   #endif | ||||
| #endif | ||||
|   | ||||
		Reference in New Issue
	
	Block a user