瀏覽代碼

Proper pullup/pulldown configurability (#20242)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
Kurt Haenen 4 年之前
父節點
當前提交
ca83e1a26f
No account linked to committer's email address

+ 25
- 9
Marlin/Configuration.h 查看文件

@@ -1176,25 +1176,41 @@
1176 1176
   #define NUM_RUNOUT_SENSORS   1          // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.
1177 1177
 
1178 1178
   #define FIL_RUNOUT_STATE     LOW        // Pin state indicating that filament is NOT present.
1179
-  #define FIL_RUNOUT_PULL                 // Use internal pullup / pulldown for filament runout pins.
1179
+  #define FIL_RUNOUT_PULLUP               // Use internal pullup for filament runout pins.
1180
+  //#define FIL_RUNOUT_PULLDOWN           // Use internal pulldown for filament runout pins.
1180 1181
 
1181 1182
   // Override individually if the runout sensors vary
1182 1183
   //#define FIL_RUNOUT1_STATE LOW
1183
-  //#define FIL_RUNOUT1_PULL
1184
+  //#define FIL_RUNOUT1_PULLUP
1185
+  //#define FIL_RUNOUT1_PULLDOWN
1186
+
1184 1187
   //#define FIL_RUNOUT2_STATE LOW
1185
-  //#define FIL_RUNOUT2_PULL
1188
+  //#define FIL_RUNOUT2_PULLUP
1189
+  //#define FIL_RUNOUT2_PULLDOWN
1190
+
1186 1191
   //#define FIL_RUNOUT3_STATE LOW
1187
-  //#define FIL_RUNOUT3_PULL
1192
+  //#define FIL_RUNOUT3_PULLUP
1193
+  //#define FIL_RUNOUT3_PULLDOWN
1194
+
1188 1195
   //#define FIL_RUNOUT4_STATE LOW
1189
-  //#define FIL_RUNOUT4_PULL
1196
+  //#define FIL_RUNOUT4_PULLUP
1197
+  //#define FIL_RUNOUT4_PULLDOWN
1198
+
1190 1199
   //#define FIL_RUNOUT5_STATE LOW
1191
-  //#define FIL_RUNOUT5_PULL
1200
+  //#define FIL_RUNOUT5_PULLUP
1201
+  //#define FIL_RUNOUT5_PULLDOWN
1202
+
1192 1203
   //#define FIL_RUNOUT6_STATE LOW
1193
-  //#define FIL_RUNOUT6_PULL
1204
+  //#define FIL_RUNOUT6_PULLUP
1205
+  //#define FIL_RUNOUT6_PULLDOWN
1206
+
1194 1207
   //#define FIL_RUNOUT7_STATE LOW
1195
-  //#define FIL_RUNOUT7_PULL
1208
+  //#define FIL_RUNOUT7_PULLUP
1209
+  //#define FIL_RUNOUT7_PULLDOWN
1210
+
1196 1211
   //#define FIL_RUNOUT8_STATE LOW
1197
-  //#define FIL_RUNOUT8_PULL
1212
+  //#define FIL_RUNOUT8_PULLUP
1213
+  //#define FIL_RUNOUT8_PULLDOWN
1198 1214
 
1199 1215
   // Set one or more commands to execute on filament runout.
1200 1216
   // (After 'M412 H' Marlin will ask the host to handle the process.)

+ 2
- 1
Marlin/Configuration_adv.h 查看文件

@@ -1217,7 +1217,8 @@
1217 1217
     //#define POWER_LOSS_ZRAISE       2 // (mm) Z axis raise on resume (on power loss with UPS)
1218 1218
     //#define POWER_LOSS_PIN         44 // Pin to detect power loss. Set to -1 to disable default pin on boards without module.
1219 1219
     //#define POWER_LOSS_STATE     HIGH // State of pin indicating power loss
1220
-    //#define POWER_LOSS_PULL           // Set pullup / pulldown as appropriate
1220
+    //#define POWER_LOSS_PULLUP         // Set pullup / pulldown as appropriate for your sensor
1221
+    //#define POWER_LOSS_PULLDOWN
1221 1222
     //#define POWER_LOSS_PURGE_LEN   20 // (mm) Length of filament to purge on resume
1222 1223
     //#define POWER_LOSS_RETRACT_LEN 10 // (mm) Length of filament to retract on fail. Requires backup power.
1223 1224
 

+ 4
- 6
Marlin/src/feature/powerloss.h 查看文件

@@ -120,12 +120,10 @@ class PrintJobRecovery {
120 120
 
121 121
     static inline void setup() {
122 122
       #if PIN_EXISTS(POWER_LOSS)
123
-        #if ENABLED(POWER_LOSS_PULL)
124
-          #if POWER_LOSS_STATE == LOW
125
-            SET_INPUT_PULLUP(POWER_LOSS_PIN);
126
-          #else
127
-            SET_INPUT_PULLDOWN(POWER_LOSS_PIN);
128
-          #endif
123
+        #if ENABLED(POWER_LOSS_PULLUP)
124
+          SET_INPUT_PULLUP(POWER_LOSS_PIN);
125
+        #elif ENABLED(POWER_LOSS_PULLDOWN)
126
+          SET_INPUT_PULLDOWN(POWER_LOSS_PIN);
129 127
         #else
130 128
           SET_INPUT(POWER_LOSS_PIN);
131 129
         #endif

+ 2
- 2
Marlin/src/feature/runout.h 查看文件

@@ -149,8 +149,8 @@ class FilamentSensorBase {
149 149
 
150 150
   public:
151 151
     static inline void setup() {
152
-      #define _INIT_RUNOUT_PIN(P,S,U) do{ if (DISABLED(U)) SET_INPUT(P); else if (S) SET_INPUT_PULLUP(P); else SET_INPUT_PULLDOWN(P); }while(0)
153
-      #define  INIT_RUNOUT_PIN(N) _INIT_RUNOUT_PIN(FIL_RUNOUT##N##_PIN, FIL_RUNOUT##N##_STATE, FIL_RUNOUT##N##_PULL)
152
+      #define _INIT_RUNOUT_PIN(P,S,U,D) do{ if (ENABLED(U)) SET_INPUT_PULLUP(P); else if (ENABLED(D)) SET_INPUT_PULLDOWN(P); else SET_INPUT(P); }while(0)
153
+      #define  INIT_RUNOUT_PIN(N) _INIT_RUNOUT_PIN(FIL_RUNOUT##N##_PIN, FIL_RUNOUT##N##_STATE, FIL_RUNOUT##N##_PULLUP, FIL_RUNOUT##N##_PULLDOWN)
154 154
       #if NUM_RUNOUT_SENSORS >= 1
155 155
         INIT_RUNOUT_PIN(1);
156 156
       #endif

+ 40
- 16
Marlin/src/inc/Conditionals_LCD.h 查看文件

@@ -708,64 +708,88 @@
708 708
     #ifndef FIL_RUNOUT1_STATE
709 709
       #define FIL_RUNOUT1_STATE FIL_RUNOUT_STATE
710 710
     #endif
711
-    #ifndef FIL_RUNOUT1_PULL
712
-      #define FIL_RUNOUT1_PULL FIL_RUNOUT_PULL
711
+    #ifndef FIL_RUNOUT1_PULLUP
712
+      #define FIL_RUNOUT1_PULLUP FIL_RUNOUT_PULLUP
713
+    #endif
714
+    #ifndef FIL_RUNOUT1_PULLDOWN
715
+      #define FIL_RUNOUT1_PULLDOWN FIL_RUNOUT_PULLDOWN
713 716
     #endif
714 717
   #endif
715 718
   #if NUM_RUNOUT_SENSORS >= 2
716 719
     #ifndef FIL_RUNOUT2_STATE
717 720
       #define FIL_RUNOUT2_STATE FIL_RUNOUT_STATE
718 721
     #endif
719
-    #ifndef FIL_RUNOUT2_PULL
720
-      #define FIL_RUNOUT2_PULL FIL_RUNOUT_PULL
722
+    #ifndef FIL_RUNOUT2_PULLUP
723
+      #define FIL_RUNOUT2_PULLUP FIL_RUNOUT_PULLUP
724
+    #endif
725
+    #ifndef FIL_RUNOUT2_PULLDOWN
726
+      #define FIL_RUNOUT2_PULLDOWN FIL_RUNOUT_PULLDOWN
721 727
     #endif
722 728
   #endif
723 729
   #if NUM_RUNOUT_SENSORS >= 3
724 730
     #ifndef FIL_RUNOUT3_STATE
725 731
       #define FIL_RUNOUT3_STATE FIL_RUNOUT_STATE
726 732
     #endif
727
-    #ifndef FIL_RUNOUT3_PULL
728
-      #define FIL_RUNOUT3_PULL FIL_RUNOUT_PULL
733
+    #ifndef FIL_RUNOUT3_PULLUP
734
+      #define FIL_RUNOUT3_PULLUP FIL_RUNOUT_PULLUP
735
+    #endif
736
+    #ifndef FIL_RUNOUT3_PULLDOWN
737
+      #define FIL_RUNOUT3_PULLDOWN FIL_RUNOUT_PULLDOWN
729 738
     #endif
730 739
   #endif
731 740
   #if NUM_RUNOUT_SENSORS >= 4
732 741
     #ifndef FIL_RUNOUT4_STATE
733 742
       #define FIL_RUNOUT4_STATE FIL_RUNOUT_STATE
734 743
     #endif
735
-    #ifndef FIL_RUNOUT4_PULL
736
-      #define FIL_RUNOUT4_PULL FIL_RUNOUT_PULL
744
+    #ifndef FIL_RUNOUT4_PULLUP
745
+      #define FIL_RUNOUT4_PULLUP FIL_RUNOUT_PULLUP
746
+    #endif
747
+    #ifndef FIL_RUNOUT4_PULLDOWN
748
+      #define FIL_RUNOUT4_PULLDOWN FIL_RUNOUT_PULLDOWN
737 749
     #endif
738 750
   #endif
739 751
   #if NUM_RUNOUT_SENSORS >= 5
740 752
     #ifndef FIL_RUNOUT5_STATE
741 753
       #define FIL_RUNOUT5_STATE FIL_RUNOUT_STATE
742 754
     #endif
743
-    #ifndef FIL_RUNOUT5_PULL
744
-      #define FIL_RUNOUT5_PULL FIL_RUNOUT_PULL
755
+    #ifndef FIL_RUNOUT5_PULLUP
756
+      #define FIL_RUNOUT5_PULLUP FIL_RUNOUT_PULLUP
757
+    #endif
758
+    #ifndef FIL_RUNOUT5_PULLDOWN
759
+      #define FIL_RUNOUT5_PULLDOWN FIL_RUNOUT_PULLDOWN
745 760
     #endif
746 761
   #endif
747 762
   #if NUM_RUNOUT_SENSORS >= 6
748 763
     #ifndef FIL_RUNOUT6_STATE
749 764
       #define FIL_RUNOUT6_STATE FIL_RUNOUT_STATE
750 765
     #endif
751
-    #ifndef FIL_RUNOUT6_PULL
752
-      #define FIL_RUNOUT6_PULL FIL_RUNOUT_PULL
766
+    #ifndef FIL_RUNOUT6_PULLUP
767
+      #define FIL_RUNOUT6_PULLUP FIL_RUNOUT_PULLUP
768
+    #endif
769
+    #ifndef FIL_RUNOUT6_PULLDOWN
770
+      #define FIL_RUNOUT6_PULLDOWN FIL_RUNOUT_PULLDOWN
753 771
     #endif
754 772
   #endif
755 773
   #if NUM_RUNOUT_SENSORS >= 7
756 774
     #ifndef FIL_RUNOUT7_STATE
757 775
       #define FIL_RUNOUT7_STATE FIL_RUNOUT_STATE
758 776
     #endif
759
-    #ifndef FIL_RUNOUT7_PULL
760
-      #define FIL_RUNOUT7_PULL FIL_RUNOUT_PULL
777
+    #ifndef FIL_RUNOUT7_PULLUP
778
+      #define FIL_RUNOUT7_PULLUP FIL_RUNOUT_PULLUP
779
+    #endif
780
+    #ifndef FIL_RUNOUT7_PULLDOWN
781
+      #define FIL_RUNOUT7_PULLDOWN FIL_RUNOUT_PULLDOWN
761 782
     #endif
762 783
   #endif
763 784
   #if NUM_RUNOUT_SENSORS >= 8
764 785
     #ifndef FIL_RUNOUT8_STATE
765 786
       #define FIL_RUNOUT8_STATE FIL_RUNOUT_STATE
766 787
     #endif
767
-    #ifndef FIL_RUNOUT8_PULL
768
-      #define FIL_RUNOUT8_PULL FIL_RUNOUT_PULL
788
+    #ifndef FIL_RUNOUT8_PULLUP
789
+      #define FIL_RUNOUT8_PULLUP FIL_RUNOUT_PULLUP
790
+    #endif
791
+    #ifndef FIL_RUNOUT8_PULLDOWN
792
+      #define FIL_RUNOUT8_PULLDOWN FIL_RUNOUT_PULLDOWN
769 793
     #endif
770 794
   #endif
771 795
 #endif // FILAMENT_RUNOUT_SENSOR

+ 25
- 1
Marlin/src/inc/SanityCheck.h 查看文件

@@ -111,7 +111,7 @@
111 111
 #elif defined(FILAMENT_SENSOR)
112 112
   #error "FILAMENT_SENSOR is now FILAMENT_WIDTH_SENSOR."
113 113
 #elif defined(ENDSTOPPULLUP_FIL_RUNOUT)
114
-  #error "ENDSTOPPULLUP_FIL_RUNOUT is now FIL_RUNOUT_PULL."
114
+  #error "ENDSTOPPULLUP_FIL_RUNOUT is now FIL_RUNOUT_PULLUP."
115 115
 #elif defined(DISABLE_MAX_ENDSTOPS) || defined(DISABLE_MIN_ENDSTOPS)
116 116
   #error "DISABLE_MAX_ENDSTOPS and DISABLE_MIN_ENDSTOPS deprecated. Use individual USE_*_PLUG options instead."
117 117
 #elif defined(LANGUAGE_INCLUDE)
@@ -525,6 +525,8 @@
525 525
   #error "EVENT_GCODE_SD_STOP is now EVENT_GCODE_SD_ABORT."
526 526
 #elif defined(GRAPHICAL_TFT_ROTATE_180)
527 527
   #error "GRAPHICAL_TFT_ROTATE_180 is now TFT_ROTATION set to TFT_ROTATE_180."
528
+#elif defined(POWER_LOSS_PULL)
529
+  #error "POWER_LOSS_PULL is now specifically POWER_LOSS_PULL(UP|DOWN)."
528 530
 #elif defined(FIL_RUNOUT_INVERTING)
529 531
   #if FIL_RUNOUT_INVERTING
530 532
     #error "FIL_RUNOUT_INVERTING true is now FIL_RUNOUT_STATE HIGH."
@@ -653,6 +655,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
653 655
 
654 656
 #if BOTH(ENDSTOPPULLUPS, ENDSTOPPULLDOWNS)
655 657
   #error "Enable only one of ENDSTOPPULLUPS or ENDSTOPPULLDOWNS."
658
+#elif BOTH(FIL_RUNOUT_PULLUP, FIL_RUNOUT_PULLDOWN)
659
+  #error "Enable only one of FIL_RUNOUT_PULLUP or FIL_RUNOUT_PULLDOWN."
656 660
 #elif BOTH(ENDSTOPPULLUP_XMAX, ENDSTOPPULLDOWN_XMAX)
657 661
   #error "Enable only one of ENDSTOPPULLUP_X_MAX or ENDSTOPPULLDOWN_X_MAX."
658 662
 #elif BOTH(ENDSTOPPULLUP_YMAX, ENDSTOPPULLDOWN_YMAX)
@@ -823,6 +827,22 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
823 827
     #error "FIL_RUNOUT7_PIN is required with NUM_RUNOUT_SENSORS >= 7."
824 828
   #elif NUM_RUNOUT_SENSORS >= 8 && !PIN_EXISTS(FIL_RUNOUT8)
825 829
     #error "FIL_RUNOUT8_PIN is required with NUM_RUNOUT_SENSORS >= 8."
830
+  #elif BOTH(FIL_RUNOUT1_PULLUP, FIL_RUNOUT1_PULLDOWN)
831
+    #error "You can't enable FIL_RUNOUT1_PULLUP and FIL_RUNOUT1_PULLDOWN at the same time."
832
+  #elif BOTH(FIL_RUNOUT2_PULLUP, FIL_RUNOUT2_PULLDOWN)
833
+    #error "You can't enable FIL_RUNOUT2_PULLUP and FIL_RUNOUT2_PULLDOWN at the same time."
834
+  #elif BOTH(FIL_RUNOUT3_PULLUP, FIL_RUNOUT3_PULLDOWN)
835
+    #error "You can't enable FIL_RUNOUT3_PULLUP and FIL_RUNOUT3_PULLDOWN at the same time."
836
+  #elif BOTH(FIL_RUNOUT4_PULLUP, FIL_RUNOUT4_PULLDOWN)
837
+    #error "You can't enable FIL_RUNOUT4_PULLUP and FIL_RUNOUT4_PULLDOWN at the same time."
838
+  #elif BOTH(FIL_RUNOUT5_PULLUP, FIL_RUNOUT5_PULLDOWN)
839
+    #error "You can't enable FIL_RUNOUT5_PULLUP and FIL_RUNOUT5_PULLDOWN at the same time."
840
+  #elif BOTH(FIL_RUNOUT6_PULLUP, FIL_RUNOUT6_PULLDOWN)
841
+    #error "You can't enable FIL_RUNOUT6_PULLUP and FIL_RUNOUT6_PULLDOWN at the same time."
842
+  #elif BOTH(FIL_RUNOUT7_PULLUP, FIL_RUNOUT7_PULLDOWN)
843
+    #error "You can't enable FIL_RUNOUT7_PULLUP and FIL_RUNOUT7_PULLDOWN at the same time."
844
+  #elif BOTH(FIL_RUNOUT8_PULLUP, FIL_RUNOUT8_PULLDOWN)
845
+    #error "You can't enable FIL_RUNOUT8_PULLUP and FIL_RUNOUT8_PULLDOWN at the same time."
826 846
   #elif FILAMENT_RUNOUT_DISTANCE_MM < 0
827 847
     #error "FILAMENT_RUNOUT_DISTANCE_MM must be greater than or equal to zero."
828 848
   #elif DISABLED(ADVANCED_PAUSE_FEATURE)
@@ -2824,6 +2844,10 @@ static_assert(   _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
2824 2844
   #error "BACKUP_POWER_SUPPLY requires a POWER_LOSS_PIN."
2825 2845
 #endif
2826 2846
 
2847
+#if BOTH(POWER_LOSS_PULLUP, POWER_LOSS_PULLDOWN)
2848
+  #error "You can't enable POWER_LOSS_PULLUP and POWER_LOSS_PULLDOWN at the same time."
2849
+#endif
2850
+
2827 2851
 #if ENABLED(Z_STEPPER_AUTO_ALIGN)
2828 2852
   #if NUM_Z_STEPPER_DRIVERS <= 1
2829 2853
     #error "Z_STEPPER_AUTO_ALIGN requires NUM_Z_STEPPER_DRIVERS greater than 1."

+ 1
- 1
Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp 查看文件

@@ -77,7 +77,7 @@ namespace Anycubic {
77 77
 
78 78
     // Filament runout is handled by Marlin settings in Configuration.h
79 79
     // opt_set    FIL_RUNOUT_STATE HIGH  // Pin state indicating that filament is NOT present.
80
-    // opt_enable FIL_RUNOUT_PULL
80
+    // opt_enable FIL_RUNOUT_PULLUP
81 81
 
82 82
     TFTSer.begin(115200);
83 83
 

+ 2
- 2
buildroot/tests/BIGTREE_GTR_V1_0-tests 查看文件

@@ -34,9 +34,9 @@ opt_set FIL_RUNOUT6_PIN 8
34 34
 opt_set FIL_RUNOUT7_PIN 9
35 35
 opt_set FIL_RUNOUT8_PIN 10
36 36
 opt_set FIL_RUNOUT4_STATE HIGH
37
-opt_enable FIL_RUNOUT4_PULL
37
+opt_enable FIL_RUNOUT4_PULLUP
38 38
 opt_set FIL_RUNOUT8_STATE HIGH
39
-opt_enable FIL_RUNOUT8_PULL
39
+opt_enable FIL_RUNOUT8_PULLUP
40 40
 exec_test $1 $2 "BigTreeTech GTR 8 Extruders with Auto-Fan, Mixed TMC Drivers, and Runout Sensors with distinct states" "$3"
41 41
 
42 42
 restore_configs

+ 1
- 1
buildroot/tests/mega2560-tests 查看文件

@@ -91,7 +91,7 @@ opt_enable ZONESTAR_LCD Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_
91 91
            AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL \
92 92
            NO_VOLUMETRICS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES AUTOTEMP G38_PROBE_TARGET JOYSTICK \
93 93
            DIRECT_STEPPING DETECT_BROKEN_ENDSTOP \
94
-           FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE Z_SAFE_HOMING FIL_RUNOUT3_PULL
94
+           FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE Z_SAFE_HOMING FIL_RUNOUT3_PULLUP
95 95
 opt_set NUM_RUNOUT_SENSORS 5
96 96
 opt_set FIL_RUNOUT2_PIN 44
97 97
 opt_set FIL_RUNOUT3_PIN 45

Loading…
取消
儲存