Browse Source

Followup for BTN_ENC_EN

Scott Lahteine 4 years ago
parent
commit
c4f3f67537
1 changed files with 10 additions and 5 deletions
  1. 10
    5
      Marlin/src/lcd/marlinui.cpp

+ 10
- 5
Marlin/src/lcd/marlinui.cpp View File

@@ -808,6 +808,14 @@ millis_t next_lcd_update_ms;
808 808
   millis_t MarlinUI::return_to_status_ms = 0;
809 809
 #endif
810 810
 
811
+inline bool can_encode() {
812
+  #if BUTTON_EXISTS(ENC_EN)
813
+    return !BUTTON_PRESSED(ENC_EN);  // Update position only when ENC_EN is HIGH
814
+  #else
815
+    return true;
816
+  #endif
817
+}
818
+
811 819
 void MarlinUI::update() {
812 820
 
813 821
   static uint16_t max_display_update_time = 0;
@@ -961,9 +969,7 @@ void MarlinUI::update() {
961 969
 
962 970
           #endif // ENCODER_RATE_MULTIPLIER
963 971
 
964
-          // Update position only when ENC_EN is HIGH
965
-          if (TERN1(BTN_ENC_EN, !BUTTON_PRESSED(ENC_EN)))
966
-            encoderPosition += (encoderDiff * encoderMultiplier) / epps;
972
+          if (can_encode()) encoderPosition += (encoderDiff * encoderMultiplier) / epps;
967 973
 
968 974
           encoderDiff = 0;
969 975
         }
@@ -1182,8 +1188,7 @@ void MarlinUI::update() {
1182 1188
             if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
1183 1189
           #endif
1184 1190
           #if BUTTON_EXISTS(ENC)
1185
-            // Update button only when ENC_EN is HIGH
1186
-            if (TERN1(BTN_ENC_EN, !BUTTON_PRESSED(ENC_EN)) && BUTTON_PRESSED(ENC)) newbutton |= EN_C;
1191
+            if (can_encode() && BUTTON_PRESSED(ENC)) newbutton |= EN_C;
1187 1192
           #endif
1188 1193
           #if BUTTON_EXISTS(BACK)
1189 1194
             if (BUTTON_PRESSED(BACK)) newbutton |= EN_D;

Loading…
Cancel
Save