Procházet zdrojové kódy

Followup for BTN_ENC_EN

Scott Lahteine před 4 roky
rodič
revize
c4f3f67537
1 změnil soubory, kde provedl 10 přidání a 5 odebrání
  1. 10
    5
      Marlin/src/lcd/marlinui.cpp

+ 10
- 5
Marlin/src/lcd/marlinui.cpp Zobrazit soubor

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…
Zrušit
Uložit