Merge upstream changes from Marlin 2.1.1
This commit is contained in:
@@ -33,24 +33,42 @@
|
||||
|
||||
#define _AXIS(A) (A##_AXIS)
|
||||
|
||||
#define _XSTOP_ 0x01
|
||||
#define _YSTOP_ 0x02
|
||||
#define _ZSTOP_ 0x03
|
||||
#define _ISTOP_ 0x04
|
||||
#define _JSTOP_ 0x05
|
||||
#define _KSTOP_ 0x06
|
||||
#define _USTOP_ 0x07
|
||||
#define _VSTOP_ 0x08
|
||||
#define _WSTOP_ 0x09
|
||||
#define _XMIN_ 0x11
|
||||
#define _YMIN_ 0x12
|
||||
#define _ZMIN_ 0x13
|
||||
#define _IMIN_ 0x14
|
||||
#define _JMIN_ 0x15
|
||||
#define _KMIN_ 0x16
|
||||
#define _UMIN_ 0x17
|
||||
#define _VMIN_ 0x18
|
||||
#define _WMIN_ 0x19
|
||||
#define _XMAX_ 0x21
|
||||
#define _YMAX_ 0x22
|
||||
#define _ZMAX_ 0x23
|
||||
#define _IMAX_ 0x24
|
||||
#define _JMAX_ 0x25
|
||||
#define _KMAX_ 0x26
|
||||
#define _UMAX_ 0x27
|
||||
#define _VMAX_ 0x28
|
||||
#define _WMAX_ 0x29
|
||||
#define _XDIAG_ 0x31
|
||||
#define _YDIAG_ 0x32
|
||||
#define _ZDIAG_ 0x33
|
||||
#define _IDIAG_ 0x34
|
||||
#define _JDIAG_ 0x35
|
||||
#define _KDIAG_ 0x36
|
||||
#define _UDIAG_ 0x37
|
||||
#define _VDIAG_ 0x38
|
||||
#define _WDIAG_ 0x39
|
||||
#define _E0DIAG_ 0xE0
|
||||
#define _E1DIAG_ 0xE1
|
||||
#define _E2DIAG_ 0xE2
|
||||
@@ -64,11 +82,11 @@
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
#define NO_INLINE __attribute__((noinline))
|
||||
#define _UNUSED __attribute__((unused))
|
||||
#define _O0 __attribute__((optimize("O0")))
|
||||
#define _Os __attribute__((optimize("Os")))
|
||||
#define _O1 __attribute__((optimize("O1")))
|
||||
#define _O2 __attribute__((optimize("O2")))
|
||||
#define _O3 __attribute__((optimize("O3")))
|
||||
#define __O0 __attribute__((optimize("O0")))
|
||||
#define __Os __attribute__((optimize("Os")))
|
||||
#define __O1 __attribute__((optimize("O1")))
|
||||
#define __O2 __attribute__((optimize("O2")))
|
||||
#define __O3 __attribute__((optimize("O3")))
|
||||
|
||||
#define IS_CONSTEXPR(...) __builtin_constant_p(__VA_ARGS__) // Only valid solution with C++14. Should use std::is_constant_evaluated() in C++20 instead
|
||||
|
||||
@@ -125,13 +143,13 @@
|
||||
#ifdef __cplusplus
|
||||
|
||||
// C++11 solution that is standards compliant.
|
||||
template <class V, class N> static inline constexpr void NOLESS(V& v, const N n) {
|
||||
template <class V, class N> static constexpr void NOLESS(V& v, const N n) {
|
||||
if (n > v) v = n;
|
||||
}
|
||||
template <class V, class N> static inline constexpr void NOMORE(V& v, const N n) {
|
||||
template <class V, class N> static constexpr void NOMORE(V& v, const N n) {
|
||||
if (n < v) v = n;
|
||||
}
|
||||
template <class V, class N1, class N2> static inline constexpr void LIMIT(V& v, const N1 n1, const N2 n2) {
|
||||
template <class V, class N1, class N2> static constexpr void LIMIT(V& v, const N1 n1, const N2 n2) {
|
||||
if (n1 > v) v = n1;
|
||||
else if (n2 < v) v = n2;
|
||||
}
|
||||
@@ -160,7 +178,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
// Macros to chain up to 14 conditions
|
||||
// Macros to chain up to 40 conditions
|
||||
#define _DO_1(W,C,A) (_##W##_1(A))
|
||||
#define _DO_2(W,C,A,B) (_##W##_1(A) C _##W##_1(B))
|
||||
#define _DO_3(W,C,A,V...) (_##W##_1(A) C _DO_2(W,C,V))
|
||||
@@ -176,6 +194,31 @@
|
||||
#define _DO_13(W,C,A,V...) (_##W##_1(A) C _DO_12(W,C,V))
|
||||
#define _DO_14(W,C,A,V...) (_##W##_1(A) C _DO_13(W,C,V))
|
||||
#define _DO_15(W,C,A,V...) (_##W##_1(A) C _DO_14(W,C,V))
|
||||
#define _DO_16(W,C,A,V...) (_##W##_1(A) C _DO_15(W,C,V))
|
||||
#define _DO_17(W,C,A,V...) (_##W##_1(A) C _DO_16(W,C,V))
|
||||
#define _DO_18(W,C,A,V...) (_##W##_1(A) C _DO_17(W,C,V))
|
||||
#define _DO_19(W,C,A,V...) (_##W##_1(A) C _DO_18(W,C,V))
|
||||
#define _DO_20(W,C,A,V...) (_##W##_1(A) C _DO_19(W,C,V))
|
||||
#define _DO_21(W,C,A,V...) (_##W##_1(A) C _DO_20(W,C,V))
|
||||
#define _DO_22(W,C,A,V...) (_##W##_1(A) C _DO_21(W,C,V))
|
||||
#define _DO_23(W,C,A,V...) (_##W##_1(A) C _DO_22(W,C,V))
|
||||
#define _DO_24(W,C,A,V...) (_##W##_1(A) C _DO_23(W,C,V))
|
||||
#define _DO_25(W,C,A,V...) (_##W##_1(A) C _DO_24(W,C,V))
|
||||
#define _DO_26(W,C,A,V...) (_##W##_1(A) C _DO_25(W,C,V))
|
||||
#define _DO_27(W,C,A,V...) (_##W##_1(A) C _DO_26(W,C,V))
|
||||
#define _DO_28(W,C,A,V...) (_##W##_1(A) C _DO_27(W,C,V))
|
||||
#define _DO_29(W,C,A,V...) (_##W##_1(A) C _DO_28(W,C,V))
|
||||
#define _DO_30(W,C,A,V...) (_##W##_1(A) C _DO_29(W,C,V))
|
||||
#define _DO_31(W,C,A,V...) (_##W##_1(A) C _DO_30(W,C,V))
|
||||
#define _DO_32(W,C,A,V...) (_##W##_1(A) C _DO_31(W,C,V))
|
||||
#define _DO_33(W,C,A,V...) (_##W##_1(A) C _DO_32(W,C,V))
|
||||
#define _DO_34(W,C,A,V...) (_##W##_1(A) C _DO_33(W,C,V))
|
||||
#define _DO_35(W,C,A,V...) (_##W##_1(A) C _DO_34(W,C,V))
|
||||
#define _DO_36(W,C,A,V...) (_##W##_1(A) C _DO_35(W,C,V))
|
||||
#define _DO_37(W,C,A,V...) (_##W##_1(A) C _DO_36(W,C,V))
|
||||
#define _DO_38(W,C,A,V...) (_##W##_1(A) C _DO_37(W,C,V))
|
||||
#define _DO_39(W,C,A,V...) (_##W##_1(A) C _DO_38(W,C,V))
|
||||
#define _DO_40(W,C,A,V...) (_##W##_1(A) C _DO_39(W,C,V))
|
||||
#define __DO_N(W,C,N,V...) _DO_##N(W,C,V)
|
||||
#define _DO_N(W,C,N,V...) __DO_N(W,C,N,V)
|
||||
#define DO(W,C,V...) (_DO_N(W,C,NUM_ARGS(V),V))
|
||||
@@ -204,6 +247,8 @@
|
||||
#define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
|
||||
#define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B.
|
||||
|
||||
#define _OPTITEM(A...) A,
|
||||
#define OPTITEM(O,A...) TERN_(O,DEFER4(_OPTITEM)(A))
|
||||
#define _OPTARG(A...) , A
|
||||
#define OPTARG(O,A...) TERN_(O,DEFER4(_OPTARG)(A))
|
||||
#define _OPTCODE(A) A;
|
||||
@@ -245,12 +290,17 @@
|
||||
#define NUMERIC_SIGNED(a) (NUMERIC(a) || (a) == '-' || (a) == '+')
|
||||
#define DECIMAL_SIGNED(a) (DECIMAL(a) || (a) == '-' || (a) == '+')
|
||||
#define COUNT(a) (sizeof(a)/sizeof(*a))
|
||||
#define ZERO(a) memset(a,0,sizeof(a))
|
||||
#define ZERO(a) memset((void*)a,0,sizeof(a))
|
||||
#define COPY(a,b) do{ \
|
||||
static_assert(sizeof(a[0]) == sizeof(b[0]), "COPY: '" STRINGIFY(a) "' and '" STRINGIFY(b) "' types (sizes) don't match!"); \
|
||||
memcpy(&a[0],&b[0],_MIN(sizeof(a),sizeof(b))); \
|
||||
}while(0)
|
||||
|
||||
#define CODE_16( A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N; O; P
|
||||
#define CODE_15( A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N; O
|
||||
#define CODE_14( A,B,C,D,E,F,G,H,I,J,K,L,M,N,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N
|
||||
#define CODE_13( A,B,C,D,E,F,G,H,I,J,K,L,M,...) A; B; C; D; E; F; G; H; I; J; K; L; M
|
||||
#define CODE_12( A,B,C,D,E,F,G,H,I,J,K,L,...) A; B; C; D; E; F; G; H; I; J; K; L
|
||||
#define CODE_11( A,B,C,D,E,F,G,H,I,J,K,...) A; B; C; D; E; F; G; H; I; J; K
|
||||
#define CODE_10( A,B,C,D,E,F,G,H,I,J,...) A; B; C; D; E; F; G; H; I; J
|
||||
#define CODE_9( A,B,C,D,E,F,G,H,I,...) A; B; C; D; E; F; G; H; I
|
||||
@@ -312,7 +362,7 @@
|
||||
|
||||
#define _LIST_N(N,V...) LIST_##N(V)
|
||||
#define LIST_N(N,V...) _LIST_N(N,V)
|
||||
#define LIST_N_1(N,K) _LIST_N(N,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K)
|
||||
#define LIST_N_1(N,K) _LIST_N(N,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K)
|
||||
#define ARRAY_N(N,V...) { _LIST_N(N,V) }
|
||||
#define ARRAY_N_1(N,K) { LIST_N_1(N,K) }
|
||||
|
||||
@@ -330,7 +380,7 @@
|
||||
|
||||
#undef ABS
|
||||
#ifdef __cplusplus
|
||||
template <class T> static inline constexpr const T ABS(const T v) { return v >= 0 ? v : -v; }
|
||||
template <class T> static constexpr const T ABS(const T v) { return v >= 0 ? v : -v; }
|
||||
#else
|
||||
#define ABS(a) ({__typeof__(a) _a = (a); _a >= 0 ? _a : -_a;})
|
||||
#endif
|
||||
@@ -373,14 +423,14 @@
|
||||
extern "C++" {
|
||||
|
||||
// C++11 solution that is standards compliant. Return type is deduced automatically
|
||||
template <class L, class R> static inline constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
|
||||
template <class L, class R> static constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
|
||||
return lhs < rhs ? lhs : rhs;
|
||||
}
|
||||
template <class L, class R> static inline constexpr auto _MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
|
||||
template <class L, class R> static constexpr auto _MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
|
||||
return lhs > rhs ? lhs : rhs;
|
||||
}
|
||||
template<class T, class ... Ts> static inline constexpr const T _MIN(T V, Ts... Vs) { return _MIN(V, _MIN(Vs...)); }
|
||||
template<class T, class ... Ts> static inline constexpr const T _MAX(T V, Ts... Vs) { return _MAX(V, _MAX(Vs...)); }
|
||||
template<class T, class ... Ts> static constexpr const T _MIN(T V, Ts... Vs) { return _MIN(V, _MIN(Vs...)); }
|
||||
template<class T, class ... Ts> static constexpr const T _MAX(T V, Ts... Vs) { return _MAX(V, _MAX(Vs...)); }
|
||||
|
||||
}
|
||||
|
||||
@@ -594,8 +644,8 @@
|
||||
#define IS_PROBE(V...) SECOND(V, 0) // Get the second item passed, or 0
|
||||
#define PROBE() ~, 1 // Second item will be 1 if this is passed
|
||||
#define _NOT_0 PROBE()
|
||||
#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'.
|
||||
#define _BOOL(x) NOT(NOT(x)) // NOT('0') gets '0'. Anything else gets '1'.
|
||||
#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'.
|
||||
#define _BOOL(x) NOT(NOT(x)) // _BOOL('0') gets '0'. Anything else gets '1'.
|
||||
|
||||
#define IF_ELSE(TF) _IF_ELSE(_BOOL(TF))
|
||||
#define _IF_ELSE(TF) _CAT(_IF_, TF)
|
||||
@@ -609,7 +659,6 @@
|
||||
#define HAS_ARGS(V...) _BOOL(FIRST(_END_OF_ARGUMENTS_ V)())
|
||||
#define _END_OF_ARGUMENTS_() 0
|
||||
|
||||
|
||||
// Simple Inline IF Macros, friendly to use in other macro definitions
|
||||
#define IF(O, A, B) ((O) ? (A) : (B))
|
||||
#define IF_0(O, A) IF(O, A, 0)
|
||||
@@ -662,13 +711,27 @@
|
||||
#define RREPEAT2_S(S,N,OP,V...) EVAL1024(_RREPEAT2(S,SUB##S(N),OP,V))
|
||||
#define RREPEAT2(N,OP,V...) RREPEAT2_S(0,N,OP,V)
|
||||
|
||||
// See https://github.com/swansontec/map-macro
|
||||
#define MAP_OUT
|
||||
#define MAP_END(...)
|
||||
#define MAP_GET_END() 0, MAP_END
|
||||
#define MAP_NEXT0(test, next, ...) next MAP_OUT
|
||||
#define MAP_NEXT1(test, next) MAP_NEXT0 (test, next, 0)
|
||||
#define MAP_NEXT(test, next) MAP_NEXT1 (MAP_GET_END test, next)
|
||||
#define MAP0(f, x, peek, ...) f(x) MAP_NEXT (peek, MAP1) (f, peek, __VA_ARGS__)
|
||||
#define MAP1(f, x, peek, ...) f(x) MAP_NEXT (peek, MAP0) (f, peek, __VA_ARGS__)
|
||||
#define MAP(f, ...) EVAL512 (MAP1 (f, __VA_ARGS__, (), 0))
|
||||
// Call OP(A) with each item as an argument
|
||||
#define _MAP(_MAP_OP,A,V...) \
|
||||
_MAP_OP(A) \
|
||||
IF_ELSE(HAS_ARGS(V)) \
|
||||
( DEFER2(__MAP)()(_MAP_OP,V) ) \
|
||||
( /* Do nothing */ )
|
||||
#define __MAP() _MAP
|
||||
|
||||
#define MAP(OP,V...) EVAL(_MAP(OP,V))
|
||||
|
||||
// Emit a list of OP(A) with the given items
|
||||
#define _MAPLIST(_MAP_OP,A,V...) \
|
||||
_MAP_OP(A) \
|
||||
IF_ELSE(HAS_ARGS(V)) \
|
||||
( , DEFER2(__MAPLIST)()(_MAP_OP,V) ) \
|
||||
( /* Do nothing */ )
|
||||
#define __MAPLIST() _MAPLIST
|
||||
|
||||
#define MAPLIST(OP,V...) EVAL(_MAPLIST(OP,V))
|
||||
|
||||
// Temperature Sensor Config
|
||||
#define _HAS_E_TEMP(N) || (TEMP_SENSOR_##N != 0)
|
||||
#define HAS_E_TEMP_SENSOR (0 REPEAT(EXTRUDERS, _HAS_E_TEMP))
|
||||
#define TEMP_SENSOR_IS_MAX_TC(T) (TEMP_SENSOR_##T == -5 || TEMP_SENSOR_##T == -3 || TEMP_SENSOR_##T == -2)
|
||||
|
Reference in New Issue
Block a user