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
   millis_t MarlinUI::return_to_status_ms = 0;
808
   millis_t MarlinUI::return_to_status_ms = 0;
809
 #endif
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
 void MarlinUI::update() {
819
 void MarlinUI::update() {
812
 
820
 
813
   static uint16_t max_display_update_time = 0;
821
   static uint16_t max_display_update_time = 0;
961
 
969
 
962
           #endif // ENCODER_RATE_MULTIPLIER
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
           encoderDiff = 0;
974
           encoderDiff = 0;
969
         }
975
         }
1182
             if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
1188
             if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
1183
           #endif
1189
           #endif
1184
           #if BUTTON_EXISTS(ENC)
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
           #endif
1192
           #endif
1188
           #if BUTTON_EXISTS(BACK)
1193
           #if BUTTON_EXISTS(BACK)
1189
             if (BUTTON_PRESSED(BACK)) newbutton |= EN_D;
1194
             if (BUTTON_PRESSED(BACK)) newbutton |= EN_D;

Loading…
Cancel
Save