|
187 | 187 | #else |
188 | 188 | #define _I_MS3 |
189 | 189 | #endif |
| 190 | + #if PIN_EXISTS(I_ENABLE) |
| 191 | + #define _I_ENABLE_PIN I_ENABLE_PIN, |
| 192 | + #else |
| 193 | + #define _I_ENABLE_PIN |
| 194 | + #endif |
190 | 195 |
|
191 | | - #define _I_PINS I_STEP_PIN, I_DIR_PIN, I_ENABLE_PIN, _I_MIN _I_MAX _I_MS1 _I_MS2 _I_MS3 _I_CS |
| 196 | + #define _I_PINS I_STEP_PIN, I_DIR_PIN, _I_ENABLE_PIN _I_MIN _I_MAX _I_MS1 _I_MS2 _I_MS3 _I_CS |
192 | 197 |
|
193 | 198 | #else |
194 | 199 |
|
|
228 | 233 | #else |
229 | 234 | #define _J_MS3 |
230 | 235 | #endif |
| 236 | + #if PIN_EXISTS(J_ENABLE) |
| 237 | + #define _J_ENABLE_PIN J_ENABLE_PIN, |
| 238 | + #else |
| 239 | + #define _J_ENABLE_PIN |
| 240 | + #endif |
231 | 241 |
|
232 | | - #define _J_PINS J_STEP_PIN, J_DIR_PIN, J_ENABLE_PIN, _J_MIN _J_MAX _J_MS1 _J_MS2 _J_MS3 _J_CS |
| 242 | + #define _J_PINS J_STEP_PIN, J_DIR_PIN, _J_ENABLE_PIN _J_MIN _J_MAX _J_MS1 _J_MS2 _J_MS3 _J_CS |
233 | 243 |
|
234 | 244 | #else |
235 | 245 |
|
|
269 | 279 | #else |
270 | 280 | #define _K_MS3 |
271 | 281 | #endif |
| 282 | + #if PIN_EXISTS(K_ENABLE) |
| 283 | + #define _K_ENABLE_PIN K_ENABLE_PIN, |
| 284 | + #else |
| 285 | + #define _K_ENABLE_PIN |
| 286 | + #endif |
272 | 287 |
|
273 | | - #define _K_PINS K_STEP_PIN, K_DIR_PIN, K_ENABLE_PIN, _K_MIN _K_MAX _K_MS1 _K_MS2 _K_MS3 _K_CS |
| 288 | + #define _K_PINS K_STEP_PIN, K_DIR_PIN, _K_ENABLE_PIN _K_MIN _K_MAX _K_MS1 _K_MS2 _K_MS3 _K_CS |
274 | 289 |
|
275 | 290 | #else |
276 | 291 |
|
|
577 | 592 | #define _H6_PINS |
578 | 593 | #define _H7_PINS |
579 | 594 |
|
| 595 | +#define DIO_PIN(P) TERN(TARGET_LPC1768, P, analogInputToDigitalPin(P)) |
| 596 | + |
580 | 597 | #if HAS_HOTEND |
581 | 598 | #undef _H0_PINS |
582 | | - #define _H0_PINS HEATER_0_PIN, E0_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_0_PIN), |
| 599 | + #define _H0_PINS HEATER_0_PIN, E0_AUTO_FAN_PIN, DIO_PIN(TEMP_0_PIN), |
583 | 600 | #if HAS_MULTI_HOTEND |
584 | 601 | #undef _H1_PINS |
585 | | - #define _H1_PINS HEATER_1_PIN, E1_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_1_PIN), |
| 602 | + #define _H1_PINS HEATER_1_PIN, E1_AUTO_FAN_PIN, DIO_PIN(TEMP_1_PIN), |
586 | 603 | #if HOTENDS > 2 |
587 | 604 | #undef _H2_PINS |
588 | | - #define _H2_PINS HEATER_2_PIN, E2_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_2_PIN), |
| 605 | + #define _H2_PINS HEATER_2_PIN, E2_AUTO_FAN_PIN, DIO_PIN(TEMP_2_PIN), |
589 | 606 | #if HOTENDS > 3 |
590 | 607 | #undef _H3_PINS |
591 | | - #define _H3_PINS HEATER_3_PIN, E3_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_3_PIN), |
| 608 | + #define _H3_PINS HEATER_3_PIN, E3_AUTO_FAN_PIN, DIO_PIN(TEMP_3_PIN), |
592 | 609 | #if HOTENDS > 4 |
593 | 610 | #undef _H4_PINS |
594 | | - #define _H4_PINS HEATER_4_PIN, E4_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_4_PIN), |
| 611 | + #define _H4_PINS HEATER_4_PIN, E4_AUTO_FAN_PIN, DIO_PIN(TEMP_4_PIN), |
595 | 612 | #if HOTENDS > 5 |
596 | 613 | #undef _H5_PINS |
597 | | - #define _H5_PINS HEATER_5_PIN, E5_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_5_PIN), |
| 614 | + #define _H5_PINS HEATER_5_PIN, E5_AUTO_FAN_PIN, DIO_PIN(TEMP_5_PIN), |
598 | 615 | #if HOTENDS > 6 |
599 | 616 | #undef _H6_PINS |
600 | | - #define _H6_PINS HEATER_6_PIN, E6_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_6_PIN), |
| 617 | + #define _H6_PINS HEATER_6_PIN, E6_AUTO_FAN_PIN, DIO_PIN(TEMP_6_PIN), |
601 | 618 | #if HOTENDS > 7 |
602 | 619 | #undef _H7_PINS |
603 | | - #define _H7_PINS HEATER_7_PIN, E7_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_7_PIN), |
| 620 | + #define _H7_PINS HEATER_7_PIN, E7_AUTO_FAN_PIN, DIO_PIN(TEMP_7_PIN), |
604 | 621 | #endif // HOTENDS > 7 |
605 | 622 | #endif // HOTENDS > 6 |
606 | 623 | #endif // HOTENDS > 5 |
|
809 | 826 | #endif |
810 | 827 |
|
811 | 828 | #if TEMP_SENSOR_BED && PINS_EXIST(TEMP_BED, HEATER_BED) |
812 | | - #define _BED_PINS HEATER_BED_PIN, analogInputToDigitalPin(TEMP_BED_PIN), |
| 829 | + #define _BED_PINS HEATER_BED_PIN, DIO_PIN(TEMP_BED_PIN), |
813 | 830 | #else |
814 | 831 | #define _BED_PINS |
815 | 832 | #endif |
816 | 833 |
|
817 | 834 | #if TEMP_SENSOR_CHAMBER && PIN_EXISTS(TEMP_CHAMBER) |
818 | | - #define _CHAMBER_TEMP analogInputToDigitalPin(TEMP_CHAMBER_PIN), |
| 835 | + #define _CHAMBER_TEMP DIO_PIN(TEMP_CHAMBER_PIN), |
819 | 836 | #else |
820 | 837 | #define _CHAMBER_TEMP |
821 | 838 | #endif |
|
831 | 848 | #endif |
832 | 849 |
|
833 | 850 | #if TEMP_SENSOR_COOLER && PIN_EXISTS(TEMP_COOLER) |
834 | | - #define _COOLER_TEMP analogInputToDigitalPin(TEMP_COOLER_PIN), |
| 851 | + #define _COOLER_TEMP DIO_PIN(TEMP_COOLER_PIN), |
835 | 852 | #else |
836 | 853 | #define _COOLER_TEMP |
837 | 854 | #endif |
838 | | - |
839 | 855 | #if TEMP_SENSOR_COOLER && PIN_EXISTS(COOLER) |
840 | 856 | #define _COOLER COOLER_PIN, |
841 | 857 | #else |
842 | 858 | #define _COOLER |
843 | 859 | #endif |
844 | | - |
845 | 860 | #if TEMP_SENSOR_COOLER && PINS_EXIST(TEMP_COOLER, COOLER_AUTO_FAN) |
846 | 861 | #define _COOLER_FAN COOLER_AUTO_FAN_PIN, |
847 | 862 | #else |
|
852 | 867 | #define HAL_SENSITIVE_PINS |
853 | 868 | #endif |
854 | 869 |
|
855 | | -#define SENSITIVE_PINS { \ |
| 870 | +#ifdef RUNTIME_ONLY_ANALOG_TO_DIGITAL |
| 871 | + #define _SP_END |
| 872 | +#else |
| 873 | + #define _SP_END -2 |
| 874 | + |
| 875 | + // Move a regular pin in front to the end |
| 876 | + template<pin_t F, pin_t ...D> |
| 877 | + struct OnlyPins : OnlyPins<D..., F> { }; |
| 878 | + |
| 879 | + // Remove a -1 from the front |
| 880 | + template<pin_t ...D> |
| 881 | + struct OnlyPins<-1, D...> : OnlyPins<D...> { }; |
| 882 | + |
| 883 | + // Remove -2 from the front, emit the rest, cease propagation |
| 884 | + template<pin_t ...D> |
| 885 | + struct OnlyPins<_SP_END, D...> { static constexpr pin_t table[sizeof...(D)] PROGMEM = { D... }; }; |
| 886 | +#endif |
| 887 | + |
| 888 | +#define SENSITIVE_PINS \ |
856 | 889 | _X_PINS _Y_PINS _Z_PINS _I_PINS _J_PINS _K_PINS \ |
857 | 890 | _X2_PINS _Y2_PINS _Z2_PINS _Z3_PINS _Z4_PINS _Z_PROBE \ |
858 | 891 | _E0_PINS _E1_PINS _E2_PINS _E3_PINS _E4_PINS _E5_PINS _E6_PINS _E7_PINS \ |
859 | 892 | _H0_PINS _H1_PINS _H2_PINS _H3_PINS _H4_PINS _H5_PINS _H6_PINS _H7_PINS \ |
860 | 893 | _PS_ON _FAN0 _FAN1 _FAN2 _FAN3 _FAN4 _FAN5 _FAN6 _FAN7 _FANC \ |
861 | | - _BED_PINS _COOLER _CHAMBER_TEMP _CHAMBER_HEATER _CHAMBER_FAN HAL_SENSITIVE_PINS \ |
862 | | -} |
| 894 | + _BED_PINS _CHAMBER_TEMP _CHAMBER_HEATER _CHAMBER_FAN \ |
| 895 | + _COOLER_TEMP _COOLER _COOLER_FAN HAL_SENSITIVE_PINS \ |
| 896 | + _SP_END |
0 commit comments