diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 7f1888c658196..2b115fd1c28db 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -177,64 +177,6 @@ typedef ab_float_t ab_pos_t; typedef abc_float_t abc_pos_t; typedef abce_float_t abce_pos_t; -#if LINEAR_AXES >= 4 - template struct XYZOnlyval; - template struct XYZEOnlyval; - - typedef struct XYZOnlyval xyzOnly_bool_t; - typedef struct XYZEOnlyval xyzeOnly_bool_t; - - typedef struct XYZOnlyval xyzOnly_char_t; - typedef struct XYZEOnlyval xyzeOnly_char_t; - - typedef struct XYZOnlyval xyzOnly_uchar_t; - typedef struct XYZEOnlyval xyzeOnly_uchar_t; - - typedef struct XYZOnlyval xyzOnly_int8_t; - typedef struct XYZEOnlyval xyzeOnly_int8_t; - - typedef struct XYZOnlyval xyzOnly_uint8_t; - typedef struct XYZEOnlyval xyzeOnly_uint8_t; - - typedef struct XYZOnlyval xyzOnly_int_t; - typedef struct XYZEOnlyval xyzeOnly_int_t; - - typedef struct XYZOnlyval xyzOnly_uint_t; - typedef struct XYZEOnlyval xyzeOnly_uint_t; - - typedef struct XYZOnlyval xyzOnly_long_t; - typedef struct XYZEOnlyval xyzeOnly_long_t; - - typedef struct XYZOnlyval xyzOnly_ulong_t; - typedef struct XYZEOnlyval xyzeOnly_ulong_t; - - typedef struct XYZOnlyval xyzOnly_vlong_t; - typedef struct XYZEOnlyval xyzeOnly_vlong_t; - - typedef struct XYZOnlyval xyzOnly_float_t; - typedef struct XYZEOnlyval xyzeOnly_float_t; - - typedef struct XYZOnlyval xyzOnly_feedrate_t; - typedef struct XYZEOnlyval xyzeOnly_feedrate_t; - - typedef xyzOnly_uint8_t xyzOnly_byte_t; - typedef xyzeOnly_uint8_t xyzeOnly_byte_t; - - typedef xyzOnly_long_t abcOnly_long_t; - typedef xyzeOnly_long_t abceOnly_long_t; - typedef xyzOnly_ulong_t abcOnly_ulong_t; - typedef xyzeOnly_ulong_t abceOnly_ulong_t; - - typedef xyzOnly_float_t xyzOnly_pos_t; - typedef xyzeOnly_float_t xyzeOnly_pos_t; - - typedef xyzOnly_float_t abcOnly_float_t; - typedef xyzeOnly_float_t abceOnly_float_t; - - typedef abcOnly_float_t abcOnly_pos_t; - typedef abceOnly_float_t abceOnly_pos_t; -#endif - // External conversion methods void toLogical(xy_pos_t &raw); void toLogical(xyz_pos_t &raw); @@ -243,13 +185,6 @@ void toNative(xy_pos_t &raw); void toNative(xyz_pos_t &raw); void toNative(xyze_pos_t &raw); -#if LINEAR_AXES >= 4 - void toLogical(xyzOnly_pos_t &raw); - void toLogical(xyzeOnly_pos_t &raw); - void toNative(xyzOnly_pos_t &raw); - void toNative(xyzeOnly_pos_t &raw); -#endif - // // XY coordinates, counters, etc. // @@ -1235,221 +1170,6 @@ struct XYZEval { #endif // LINEAR_AXES <= 3 -#if LINEAR_AXES >= 4 - -template -struct XYZOnlyval { - union { - struct { T x, y, z; }; - struct { T a, b, c; }; - T pos[3]; - }; - FI void set(const T px) { x = px; } - FI void set(const T px, const T py) { x = px; y = py; } - FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } - FI void set(const XYval pxy, const T pz) { x = pxy.x; y = pxy.y; z = pz; } - FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; } - FI void set(const T (&arr)[XYZ]) { x = arr[0]; y = arr[1]; z = arr[2]; } - FI void set(const T (&arr)[XYZE]) { x = arr[0]; y = arr[1]; z = arr[2]; } - #if XYZE_N > XYZE - FI void set(const T (&arr)[XYZE_N]) { x = arr[0]; y = arr[1]; z = arr[2]; } - #endif - FI void reset() { x = y = z = 0; } - FI T magnitude() const { return (T)sqrtf(x*x + y*y + z*z); } - FI operator T* () { return pos; } - FI operator bool() { return z || x || y; } - FI XYZOnlyval copy() const { XYZOnlyval o = *this; return o; } - FI XYZOnlyval ABS() const { return { T(_ABS(x)), T(_ABS(y)), T(_ABS(z)) }; } - FI XYZOnlyval asInt() { return { int16_t(x), int16_t(y), int16_t(z) }; } - FI XYZOnlyval asInt() const { return { int16_t(x), int16_t(y), int16_t(z) }; } - FI XYZOnlyval asLong() { return { int32_t(x), int32_t(y), int32_t(z) }; } - FI XYZOnlyval asLong() const { return { int32_t(x), int32_t(y), int32_t(z) }; } - FI XYZOnlyval ROUNDL() { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)) }; } - FI XYZOnlyval ROUNDL() const { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)) }; } - FI XYZOnlyval asFloat() { return { float(x), float(y), float(z) }; } - FI XYZOnlyval asFloat() const { return { float(x), float(y), float(z) }; } - FI XYZOnlyval reciprocal() const { return { _RECIP(x), _RECIP(y), _RECIP(z) }; } - FI XYZOnlyval asLogical() const { XYZval o = asFloat(); toLogical(o); return o; } - FI XYZOnlyval asNative() const { XYZval o = asFloat(); toNative(o); return o; } - FI operator XYval&() { return *(XYval*)this; } - FI operator const XYval&() const { return *(const XYval*)this; } - FI operator XYZEOnlyval() const { return { x, y, z }; } - FI T& operator[](const int i) { return pos[i]; } - FI const T& operator[](const int i) const { return pos[i]; } - FI XYZOnlyval& operator= (const T v) { set(v, v, v ); return *this; } - FI XYZOnlyval& operator= (const XYval &rs) { set(rs.x, rs.y ); return *this; } - FI XYZOnlyval& operator= (const XYZEOnlyval &rs) { set(rs.x, rs.y, rs.z); return *this; } - FI XYZOnlyval operator+ (const XYval &rs) const { XYZOnlyval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } - FI XYZOnlyval operator+ (const XYval &rs) { XYZOnlyval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } - FI XYZOnlyval operator- (const XYval &rs) const { XYZOnlyval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } - FI XYZOnlyval operator- (const XYval &rs) { XYZOnlyval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } - FI XYZOnlyval operator* (const XYval &rs) const { XYZOnlyval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } - FI XYZOnlyval operator* (const XYval &rs) { XYZOnlyval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } - FI XYZOnlyval operator/ (const XYval &rs) const { XYZOnlyval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYZOnlyval operator/ (const XYval &rs) { XYZOnlyval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYZOnlyval operator+ (const XYZOnlyval &rs) const { XYZOnlyval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; } - FI XYZOnlyval operator+ (const XYZOnlyval &rs) { XYZOnlyval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; } - FI XYZOnlyval operator- (const XYZOnlyval &rs) const { XYZOnlyval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; } - FI XYZOnlyval operator- (const XYZOnlyval &rs) { XYZOnlyval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; } - FI XYZOnlyval operator* (const XYZOnlyval &rs) const { XYZOnlyval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; } - FI XYZOnlyval operator* (const XYZOnlyval &rs) { XYZOnlyval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; } - FI XYZOnlyval operator/ (const XYZOnlyval &rs) const { XYZOnlyval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; } - FI XYZOnlyval operator/ (const XYZOnlyval &rs) { XYZOnlyval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; } - FI XYZOnlyval operator+ (const XYZEOnlyval &rs) const { XYZOnlyval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; } - FI XYZOnlyval operator+ (const XYZEOnlyval &rs) { XYZOnlyval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; } - FI XYZOnlyval operator- (const XYZEOnlyval &rs) const { XYZOnlyval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; } - FI XYZOnlyval operator- (const XYZEOnlyval &rs) { XYZOnlyval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; } - FI XYZOnlyval operator* (const XYZEOnlyval &rs) const { XYZOnlyval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; } - FI XYZOnlyval operator* (const XYZEOnlyval &rs) { XYZOnlyval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; } - FI XYZOnlyval operator/ (const XYZEOnlyval &rs) const { XYZOnlyval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; } - FI XYZOnlyval operator/ (const XYZEOnlyval &rs) { XYZOnlyval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; } - FI XYZOnlyval operator* (const float &v) const { XYZOnlyval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; return ls; } - FI XYZOnlyval operator* (const float &v) { XYZOnlyval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; return ls; } - FI XYZOnlyval operator* (const int &v) const { XYZOnlyval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; return ls; } - FI XYZOnlyval operator* (const int &v) { XYZOnlyval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; return ls; } - FI XYZOnlyval operator/ (const float &v) const { XYZOnlyval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; return ls; } - FI XYZOnlyval operator/ (const float &v) { XYZOnlyval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; return ls; } - FI XYZOnlyval operator/ (const int &v) const { XYZOnlyval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; return ls; } - FI XYZOnlyval operator/ (const int &v) { XYZOnlyval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; return ls; } - FI XYZOnlyval operator>>(const int &v) const { XYZOnlyval ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); return ls; } - FI XYZOnlyval operator>>(const int &v) { XYZOnlyval ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); return ls; } - FI XYZOnlyval operator<<(const int &v) const { XYZOnlyval ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); return ls; } - FI XYZOnlyval operator<<(const int &v) { XYZOnlyval ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); return ls; } - FI XYZOnlyval& operator+=(const XYval &rs) { x += rs.x; y += rs.y; return *this; } - FI XYZOnlyval& operator-=(const XYval &rs) { x -= rs.x; y -= rs.y; return *this; } - FI XYZOnlyval& operator*=(const XYval &rs) { x *= rs.x; y *= rs.y; return *this; } - FI XYZOnlyval& operator/=(const XYval &rs) { x /= rs.x; y /= rs.y; return *this; } - FI XYZOnlyval& operator+=(const XYZOnlyval &rs) { x += rs.x; y += rs.y; z += rs.z; return *this; } - FI XYZOnlyval& operator-=(const XYZOnlyval &rs) { x -= rs.x; y -= rs.y; z -= rs.z; return *this; } - FI XYZOnlyval& operator*=(const XYZOnlyval &rs) { x *= rs.x; y *= rs.y; z *= rs.z; return *this; } - FI XYZOnlyval& operator/=(const XYZOnlyval &rs) { x /= rs.x; y /= rs.y; z /= rs.z; return *this; } - FI XYZOnlyval& operator+=(const XYZEOnlyval &rs) { x += rs.x; y += rs.y; z += rs.z; return *this; } - FI XYZOnlyval& operator-=(const XYZEOnlyval &rs) { x -= rs.x; y -= rs.y; z -= rs.z; return *this; } - FI XYZOnlyval& operator*=(const XYZEOnlyval &rs) { x *= rs.x; y *= rs.y; z *= rs.z; return *this; } - FI XYZOnlyval& operator/=(const XYZEOnlyval &rs) { x /= rs.x; y /= rs.y; z /= rs.z; return *this; } - FI XYZOnlyval& operator*=(const float &v) { x *= v; y *= v; z *= v; return *this; } - FI XYZOnlyval& operator*=(const int &v) { x *= v; y *= v; z *= v; return *this; } - FI XYZOnlyval& operator>>=(const int &v) { _RS(x); _RS(y); _RS(z); return *this; } - FI XYZOnlyval& operator<<=(const int &v) { _LS(x); _LS(y); _LS(z); return *this; } - FI bool operator==(const XYZEOnlyval &rs) { return x == rs.x && y == rs.y && z == rs.z; } - FI bool operator!=(const XYZEOnlyval &rs) { return !operator==(rs); } - FI bool operator==(const XYZEOnlyval &rs) const { return x == rs.x && y == rs.y && z == rs.z; } - FI bool operator!=(const XYZEOnlyval &rs) const { return !operator==(rs); } - FI XYZOnlyval operator-() { XYZOnlyval o = *this; o.x = -x; o.y = -y; o.z = -z; return o; } - FI const XYZOnlyval operator-() const { XYZOnlyval o = *this; o.x = -x; o.y = -y; o.z = -z; return o; } -}; - - -template -struct XYZEOnlyval { - union { - struct{ T x, y, z, e; }; - struct{ T a, b, c; }; - T pos[4]; - }; - FI void reset() { x = y = z = e = 0; } - FI T magnitude() const { return (T)sqrtf(x*x + y*y + z*z + e*e); } - FI operator T* () { return pos; } - FI operator bool() { return e || z || x || y; } - FI void set(const T px) { x = px; } - FI void set(const T px, const T py) { x = px; y = py; } - FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } - FI void set(const T px, const T py, const T pz, const T pe) { x = px; y = py; z = pz; e = pe; } - FI void set(const XYval pxy) { x = pxy.x; y = pxy.y; } - FI void set(const XYval pxy, const T pz) { x = pxy.x; y = pxy.y; z = pz; } - FI void set(const XYZval pxyz) { x = pxyz.x; y = pxyz.y; z = pxyz.z; } - FI void set(const XYval pxy, const T pz, const T pe) { x = pxy.x; y = pxy.y; z = pz; e = pe; } - FI void set(const XYval pxy, const XYval pze) { x = pxy.x; y = pxy.y; z = pze.z; e = pze.e; } - FI void set(const XYZval pxyz, const T pe) { x = pxyz.x; y = pxyz.y; z = pxyz.z; e = pe; } - FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; } - FI void set(const T (&arr)[XYZ]) { x = arr[0]; y = arr[1]; z = arr[2]; } - FI void set(const T (&arr)[XYZE]) { x = arr[0]; y = arr[1]; z = arr[2]; e = arr[3]; } - #if XYZE_N > XYZE - FI void set(const T (&arr)[XYZE_N]) { x = arr[0]; y = arr[1]; z = arr[2]; e = arr[3]; } - #endif - FI XYZEOnlyval copy() const { return *this; } - FI XYZEOnlyval ABS() const { return { T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(e)) }; } - FI XYZEOnlyval asInt() { return { int16_t(x), int16_t(y), int16_t(z), int16_t(e) }; } - FI XYZEOnlyval asInt() const { return { int16_t(x), int16_t(y), int16_t(z), int16_t(e) }; } - FI XYZEOnlyval asLong() { return { int32_t(x), int32_t(y), int32_t(z), int32_t(e) }; } - FI XYZEOnlyval asLong() const { return { int32_t(x), int32_t(y), int32_t(z), int32_t(e) }; } - FI XYZEOnlyval ROUNDL() { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(e)) }; } - FI XYZEOnlyval ROUNDL() const { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(e)) }; } - FI XYZEOnlyval asFloat() { return { float(x), float(y), float(z), float(e) }; } - FI XYZEOnlyval asFloat() const { return { float(x), float(y), float(z), float(e) }; } - FI XYZEOnlyval reciprocal() const { return { _RECIP(x), _RECIP(y), _RECIP(z), _RECIP(e) }; } - FI XYZEOnlyval asLogical() const { XYZEOnlyval o = asFloat(); toLogical(o); return o; } - FI XYZEOnlyval asNative() const { XYZEOnlyval o = asFloat(); toNative(o); return o; } - FI operator XYval&() { return *(XYval*)this; } - FI operator const XYval&() const { return *(const XYval*)this; } - FI operator XYZval&() { return *(XYZOnlyval*)this; } - FI operator const XYZval&() const { return *(const XYZval*)this; } - FI T& operator[](const int i) { return pos[i]; } - FI const T& operator[](const int i) const { return pos[i]; } - FI XYZEOnlyval& operator= (const T v) { set(v, v, v, v); return *this; } - FI XYZEOnlyval& operator= (const XYval &rs) { set(rs.x, rs.y); return *this; } - FI XYZEOnlyval& operator= (const XYZval &rs) { set(rs.x, rs.y, rs.z); return *this; } - FI XYZEOnlyval operator+ (const XYval &rs) const { XYZEOnlyval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } - FI XYZEOnlyval operator+ (const XYval &rs) { XYZEOnlyval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } - FI XYZEOnlyval operator- (const XYval &rs) const { XYZEOnlyval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } - FI XYZEOnlyval operator- (const XYval &rs) { XYZEOnlyval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } - FI XYZEOnlyval operator* (const XYval &rs) const { XYZEOnlyval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } - FI XYZEOnlyval operator* (const XYval &rs) { XYZEOnlyval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } - FI XYZEOnlyval operator/ (const XYval &rs) const { XYZEOnlyval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYZEOnlyval operator/ (const XYval &rs) { XYZEOnlyval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYZEOnlyval operator+ (const XYZOnlyval &rs) const { XYZEOnlyval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; } - FI XYZEOnlyval operator+ (const XYZOnlyval &rs) { XYZEOnlyval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; } - FI XYZEOnlyval operator- (const XYZOnlyval &rs) const { XYZEOnlyval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; } - FI XYZEOnlyval operator- (const XYZOnlyval &rs) { XYZEOnlyval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; } - FI XYZEOnlyval operator* (const XYZOnlyval &rs) const { XYZEOnlyval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; } - FI XYZEOnlyval operator* (const XYZOnlyval &rs) { XYZEOnlyval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; } - FI XYZEOnlyval operator/ (const XYZOnlyval &rs) const { XYZEOnlyval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; } - FI XYZEOnlyval operator/ (const XYZOnlyval &rs) { XYZEOnlyval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; } - FI XYZEOnlyval operator+ (const XYZEOnlyval &rs) const { XYZEOnlyval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; ls.e += rs.e; return ls; } - FI XYZEOnlyval operator+ (const XYZEOnlyval &rs) { XYZEOnlyval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; ls.e += rs.e; return ls; } - FI XYZEOnlyval operator- (const XYZEOnlyval &rs) const { XYZEOnlyval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; ls.e -= rs.e; return ls; } - FI XYZEOnlyval operator- (const XYZEOnlyval &rs) { XYZEOnlyval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; ls.e -= rs.e; return ls; } - FI XYZEOnlyval operator* (const XYZEOnlyval &rs) const { XYZEOnlyval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; ls.e *= rs.e; return ls; } - FI XYZEOnlyval operator* (const XYZEOnlyval &rs) { XYZEOnlyval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; ls.e *= rs.e; return ls; } - FI XYZEOnlyval operator/ (const XYZEOnlyval &rs) const { XYZEOnlyval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; ls.e /= rs.e; return ls; } - FI XYZEOnlyval operator/ (const XYZEOnlyval &rs) { XYZEOnlyval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; ls.e /= rs.e; return ls; } - FI XYZEOnlyval operator* (const float &v) const { XYZEOnlyval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; } - FI XYZEOnlyval operator* (const float &v) { XYZEOnlyval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; } - FI XYZEOnlyval operator* (const int &v) const { XYZEOnlyval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; } - FI XYZEOnlyval operator* (const int &v) { XYZEOnlyval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; } - FI XYZEOnlyval operator/ (const float &v) const { XYZEOnlyval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; } - FI XYZEOnlyval operator/ (const float &v) { XYZEOnlyval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; } - FI XYZEOnlyval operator/ (const int &v) const { XYZEOnlyval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; } - FI XYZEOnlyval operator/ (const int &v) { XYZEOnlyval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; } - FI XYZEOnlyval operator>>(const int &v) const { XYZEOnlyval ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); _RS(ls.e); return ls; } - FI XYZEOnlyval operator>>(const int &v) { XYZEOnlyval ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); _RS(ls.e); return ls; } - FI XYZEOnlyval operator<<(const int &v) const { XYZEOnlyval ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); _LS(ls.e); return ls; } - FI XYZEOnlyval operator<<(const int &v) { XYZEOnlyval ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); _LS(ls.e); return ls; } - FI XYZEOnlyval& operator+=(const XYval &rs) { x += rs.x; y += rs.y; return *this; } - FI XYZEOnlyval& operator-=(const XYval &rs) { x -= rs.x; y -= rs.y; return *this; } - FI XYZEOnlyval& operator*=(const XYval &rs) { x *= rs.x; y *= rs.y; return *this; } - FI XYZEOnlyval& operator/=(const XYval &rs) { x /= rs.x; y /= rs.y; return *this; } - FI XYZEOnlyval& operator+=(const XYZOnlyval &rs) { x += rs.x; y += rs.y; z += rs.z; return *this; } - FI XYZEOnlyval& operator-=(const XYZOnlyval &rs) { x -= rs.x; y -= rs.y; z -= rs.z; return *this; } - FI XYZEOnlyval& operator*=(const XYZOnlyval &rs) { x *= rs.x; y *= rs.y; z *= rs.z; return *this; } - FI XYZEOnlyval& operator/=(const XYZOnlyval &rs) { x /= rs.x; y /= rs.y; z /= rs.z; return *this; } - FI XYZEOnlyval& operator+=(const XYZEOnlyval &rs) { x += rs.x; y += rs.y; z += rs.z; e += rs.e; return *this; } - FI XYZEOnlyval& operator-=(const XYZEOnlyval &rs) { x -= rs.x; y -= rs.y; z -= rs.z; e -= rs.e; return *this; } - FI XYZEOnlyval& operator*=(const XYZEOnlyval &rs) { x *= rs.x; y *= rs.y; z *= rs.z; e *= rs.e; return *this; } - FI XYZEOnlyval& operator/=(const XYZEOnlyval &rs) { x /= rs.x; y /= rs.y; z /= rs.z; e /= rs.e; return *this; } - FI XYZEOnlyval& operator*=(const T &v) { x *= v; y *= v; z *= v; e *= v; return *this; } - FI XYZEOnlyval& operator>>=(const int &v) { _RS(x); _RS(y); _RS(z); _RS(e); return *this; } - FI XYZEOnlyval& operator<<=(const int &v) { _LS(x); _LS(y); _LS(z); _LS(e); return *this; } - FI bool operator==(const XYZOnlyval &rs) { return x == rs.x && y == rs.y && z == rs.z; } - FI bool operator!=(const XYZOnlyval &rs) { return !operator==(rs); } - FI bool operator==(const XYZOnlyval &rs) const { return x == rs.x && y == rs.y && z == rs.z; } - FI bool operator!=(const XYZOnlyval &rs) const { return !operator==(rs); } - FI XYZEOnlyval operator-() { return { -x, -y, -z, -e }; } - FI const XYZEOnlyval operator-() const { return { -x, -y, -z, -e }; } -}; - -#endif // LINEAR_AXES >= 4 - #undef _RECIP #undef _ABS #undef _LS diff --git a/Marlin/src/gcode/config/M92.cpp b/Marlin/src/gcode/config/M92.cpp index eface57082155..f84c4d131d3c1 100644 --- a/Marlin/src/gcode/config/M92.cpp +++ b/Marlin/src/gcode/config/M92.cpp @@ -70,7 +70,7 @@ void GcodeSuite::M92() { // No arguments? Show M92 report. if (!parser.seen("E" - GANG_N(LINEAR_AXES, "X", "Y", "Z", AXIS4_STR AXIS5_STR AXIS6_STR) + GANG_N(LINEAR_AXES, "X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR) TERN_(MAGIC_NUMBERS_GCODE, "HL") )) return report_M92(true, target_extruder); diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index 1e66e6da8a659..d121533c77c1c 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -33,7 +33,7 @@ * M17: Enable stepper motors */ void GcodeSuite::M17() { - if (parser.seen(GANG_N(LINEAR_AXES, "X", "Y", "Z", AXIS4_STR AXIS5_STR AXIS6_STR) "E")) { + if (parser.seen(GANG_N(LINEAR_AXES, "X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR) "E")) { if (parser.seen('X')) ENABLE_AXIS_X(); if (parser.seen('Y')) ENABLE_AXIS_Y(); if (parser.seen('Z')) ENABLE_AXIS_Z(); @@ -63,7 +63,7 @@ void GcodeSuite::M18_M84() { stepper_inactive_time = parser.value_millis_from_seconds(); } else { - if (parser.seen(GANG_N(LINEAR_AXES, "X", "Y", "Z", AXIS4_STR AXIS5_STR AXIS6_STR) "E")) { + if (parser.seen(GANG_N(LINEAR_AXES, "X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR) "E")) { planner.synchronize(); if (parser.seen('X')) DISABLE_AXIS_X(); if (parser.seen('Y')) DISABLE_AXIS_Y(); diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 880aa76f5a52f..317e998b035fa 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1174,8 +1174,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS + ENABLED(COREYZ) \ + ENABLED(COREYX) \ + ENABLED(COREZX) \ - + ENABLED(COREZY) - #error "Please enable only one of DELTA, MORGAN_SCARA, COREXY, COREYX, COREXZ, COREZX, COREYZ, or COREZY." + + ENABLED(COREZY) \ + + ENABLED(ASYNC_SECONDARY_AXES) \ + + ENABLED(FOAMCUTTER_XYUV) + #error "Please enable only one of DELTA, MORGAN_SCARA, COREXY, COREYX, COREXZ, COREZX, COREYZ, COREZY, ASYNC_SECONDARY_AXES or FOAMCUTTER_XYUV." #endif /** @@ -1199,6 +1201,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif +/** + * Delta requirements + */ +#if ENABLED(FOAMCUTTER_XYUV) && LINEAR_AXES < 5 + #error "FOAMCUTTER_XYUV requires LINEAR_AXES >= 5." +#endif /** * Junction deviation is incompatible with kinematic systems. */ @@ -1948,7 +1956,15 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #define _PLUG_UNUSED_TEST(A,P) (DISABLED(USE_##P##MIN_PLUG, USE_##P##MAX_PLUG) \ && !(ENABLED(A##_DUAL_ENDSTOPS) && WITHIN(A##2_USE_ENDSTOP, _##P##MAX_, _##P##MIN_)) \ && !(ENABLED(A##_MULTI_ENDSTOPS) && WITHIN(A##2_USE_ENDSTOP, _##P##MAX_, _##P##MIN_)) ) -#define _AXIS_PLUG_UNUSED_TEST(A) (_PLUG_UNUSED_TEST(A,X) && _PLUG_UNUSED_TEST(A,Y) && _PLUG_UNUSED_TEST(A,Z)) +#if LINEAR_AXES == 6 + #define _AXIS_PLUG_UNUSED_TEST(A) (_PLUG_UNUSED_TEST(A,X) && _PLUG_UNUSED_TEST(A,Y) && _PLUG_UNUSED_TEST(A,Z) && _PLUG_UNUSED_TEST(A,I) && _PLUG_UNUSED_TEST(A,J) && _PLUG_UNUSED_TEST(A,K)) +#elif LINEAR_AXES == 5 + #define _AXIS_PLUG_UNUSED_TEST(A) (_PLUG_UNUSED_TEST(A,X) && _PLUG_UNUSED_TEST(A,Y) && _PLUG_UNUSED_TEST(A,Z) && _PLUG_UNUSED_TEST(A,I) && _PLUG_UNUSED_TEST(A,J)) +#elif LINEAR_AXES == 4 + #define _AXIS_PLUG_UNUSED_TEST(A) (_PLUG_UNUSED_TEST(A,X) && _PLUG_UNUSED_TEST(A,Y) && _PLUG_UNUSED_TEST(A,Z) && _PLUG_UNUSED_TEST(A,I)) +#else + #define _AXIS_PLUG_UNUSED_TEST(A) (_PLUG_UNUSED_TEST(A,X) && _PLUG_UNUSED_TEST(A,Y) && _PLUG_UNUSED_TEST(A,Z)) +#endif // At least 3 endstop plugs must be used #if _AXIS_PLUG_UNUSED_TEST(X) @@ -1960,6 +1976,21 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #if _AXIS_PLUG_UNUSED_TEST(Z) #error "You must enable USE_ZMIN_PLUG or USE_ZMAX_PLUG." #endif +#if LINEAR_AXES >= 4 + #if _AXIS_PLUG_UNUSED_TEST(I) + #error "You must enable USE_IMIN_PLUG or USE_IMAX_PLUG." + #endif +#endif +#if LINEAR_AXES >= 5 + #if _AXIS_PLUG_UNUSED_TEST(J) + #error "You must enable USE_JMIN_PLUG or USE_JMAX_PLUG." + #endif +#endif +#if LINEAR_AXES >= 6 + #if _AXIS_PLUG_UNUSED_TEST(K) + #error "You must enable USE_KMIN_PLUG or USE_KMAX_PLUG." + #endif +#endif // Delta and Cartesian use 3 homing endstops #if !IS_SCARA diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 585a5565da1bf..bb3b991ea47b6 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -54,7 +54,11 @@ Endstops endstops; bool Endstops::enabled, Endstops::enabled_globally; // Initialized by settings.load() -volatile axis_bits_t Endstops::hit_state; //TODO (DerAndere): volatile hitbits_t Endstops::hit_state; +#if LINEAR_AXES >= 4 + volatile uint16_t Endstops::hit_state; //TODO (DerAndere): volatile hitbits_t Endstops::hit_state; +#else + volatile uint8_t Endstops::hit_state; //TODO (DerAndere): volatile hitbits_t Endstops::hit_state; +#endif Endstops::esbits_t Endstops::live_state = 0; @@ -408,8 +412,12 @@ void Endstops::resync() { #endif void Endstops::event_handler() { - static hitbits_t prev_hit_state; // = 0 - if (hit_state == prev_hit_state) return; + #if LINEAR_AXES >= 4 + static uint16_t prev_hit_state; // = 0 + #else + static uint8_t prev_hit_state; // = 0 + #endif + if (hit_state == prev_hit_state) return; prev_hit_state = hit_state; if (hit_state) { #if HAS_SPI_LCD diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index 807f8f4a9cf57..28fe79cb77550 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -44,8 +44,11 @@ enum EndstopEnum : char { class Endstops { public: - typedef IF<(LINEAR_AXES >= 4 || ENABLED(HAS_EXTRA_ENDSTOPS)), uint16_t, uint8_t>::type esbits_t; - typedef IF<(LINEAR_AXES >= 4), uint16_t, uint8_t>::type hitbits_t; + #if LINEAR_AXES >=4 || ENABLED(HAS_EXTRA_ENDSTOPS) + typedef uint16_t esbits_t; + #else + typedef uint8_t esbits_t; + #endif #if HAS_EXTRA_ENDSTOPS TERN_(X_DUAL_ENDSTOPS, static float x2_endstop_adj); @@ -62,7 +65,11 @@ class Endstops { private: static bool enabled, enabled_globally; static esbits_t live_state; - static volatile axis_bits_t hit_state; // Use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT index + #if LINEAR_AXES >= 4 + static volatile uint16_t hit_state; // Use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT index + #else + static volatile uint8_t hit_state; // Use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT index + #endif #if ENDSTOP_NOISE_THRESHOLD static esbits_t validated_live_state; @@ -101,7 +108,11 @@ class Endstops { /** * Get Endstop hit state. */ - FORCE_INLINE static hitbits_t trigger_state() { return hit_state; } + #if LINEAR_AXES > 3 + FORCE_INLINE static uint16_t trigger_state() { return hit_state; } + #else + FORCE_INLINE static uint8_t trigger_state() { return hit_state; } + #endif /** * Get current endstops state diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index e9428de3089a2..e6b9434563763 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -514,36 +514,39 @@ void do_blocking_move_to( } void do_blocking_move_to(const xy_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) { - do_blocking_move_to(raw.x, raw.y, current_position.z, fr_mm_s); + do_blocking_move_to(LIST_N(LINEAR_AXES, raw.x, raw.y, current_position.z, current_position.i, current_position.j, current_position.k), fr_mm_s); } void do_blocking_move_to(const xyz_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) { do_blocking_move_to(LIST_N(LINEAR_AXES, raw.x, raw.y, raw.z, raw.i, raw.j, raw.k), fr_mm_s); } -void do_blocking_move_to(const xyze_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) { - do_blocking_move_to(LIST_N(LINEAR_AXES, raw.x, raw.y, raw.z, raw.i, raw.j, raw.k), fr_mm_s); -} - -#if LINEAR_AXES >= 4 - void do_blocking_move_to(const xyzOnly_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) { - do_blocking_move_to(raw.x, raw.y, raw.z, current_position.i, fr_mm_s); - } -// #if LINEAR_AXES >= 5 -// void do_blocking_move_to(const xyziOnly_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) { -// do_blocking_move_to(raw.x, raw.y, raw.z, raw.i, current_position.j, fr_mm_s); -// } -// #if LINEAR_AXES >= 6 -// void do_blocking_move_to(const xyzijOnly_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) { -// do_blocking_move_to(raw.x, raw.y, raw.z, raw.i, raw.j, current_position.k, fr_mm_s); -// } -// #endif -// #endif -#endif - +//void do_blocking_move_to(const xyze_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) { +// do_blocking_move_to(LIST_N(LINEAR_AXES, raw.x, raw.y, raw.z, raw.i, raw.j, raw.k), fr_mm_s); +//} +//#if LINEAR_AXES >= 4 +// void do_blocking_move_to(const xyzOnly_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) { +// do_blocking_move_to(raw.x, raw.y, raw.z, current_position.i, fr_mm_s); +// } +//#endif +//#if LINEAR_AXES >= 5 +// void do_blocking_move_to(const xyziOnly_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) { +// do_blocking_move_to(raw.x, raw.y, raw.z, raw.i, current_position.j, fr_mm_s); +// } +//#endif +//#if LINEAR_AXES >= 6 +// void do_blocking_move_to(const xyzijOnly_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) { +// do_blocking_move_to(raw.x, raw.y, raw.z, raw.i, raw.j, current_position.k, fr_mm_s); +// } +//#endif +// void do_blocking_move_to_x(const float &rx, const feedRate_t &fr_mm_s/*=0.0*/) { - do_blocking_move_to(rx, current_position.y, current_position.z, fr_mm_s); + do_blocking_move_to( + LIST_N(LINEAR_AXES, rx, current_position.y, current_position.z, current_position.i, current_position.j, current_position.k), + fr_mm_s); } void do_blocking_move_to_y(const float &ry, const feedRate_t &fr_mm_s/*=0.0*/) { - do_blocking_move_to(current_position.x, ry, current_position.z, fr_mm_s); + do_blocking_move_to( + LIST_N(LINEAR_AXES, current_position.x, ry, current_position.z, current_position.i, current_position.j, current_position.k), + fr_mm_s); } void do_blocking_move_to_z(const float &rz, const feedRate_t &fr_mm_s/*=0.0*/) { do_blocking_move_to_xy_z(current_position, rz, fr_mm_s); @@ -560,7 +563,7 @@ void do_blocking_move_to_z(const float &rz, const feedRate_t &fr_mm_s/*=0.0*/) { #if LINEAR_AXES >= 5 void do_blocking_move_to_j(const float &rj, const feedRate_t &fr_mm_s/*=0.0*/) { - do_blocking_move_to_xyzi_j(current_position, ri, fr_mm_s); + do_blocking_move_to_xyzi_j(current_position, rj, fr_mm_s); } void do_blocking_move_to_xyzi_j(const xyze_pos_t &raw, const float &j, const feedRate_t &fr_mm_s/*=0.0f*/) { do_blocking_move_to(raw.x, raw.y, raw.z, raw.i, j, fr_mm_s); @@ -587,7 +590,10 @@ void do_blocking_move_to_xy(const xy_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0 } void do_blocking_move_to_xy_z(const xy_pos_t &raw, const float &z, const feedRate_t &fr_mm_s/*=0.0f*/) { - do_blocking_move_to(raw.x, raw.y, z, fr_mm_s); + do_blocking_move_to( + LIST_N(LINEAR_AXES, raw.x, raw.y, z, current_position.i, current_position.j, current_position.k), + fr_mm_s + ); } void do_z_clearance(const float &zclear, const bool z_known/*=true*/, const bool raise_on_unknown/*=true*/, const bool lower_allowed/*=false*/) { diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 211fee74674a1..8e43832e40556 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -218,36 +218,21 @@ void do_blocking_move_to( ); void do_blocking_move_to(const xy_pos_t &raw, const feedRate_t &fr_mm_s=0.0f); void do_blocking_move_to(const xyz_pos_t &raw, const feedRate_t &fr_mm_s=0.0f); -void do_blocking_move_to(const xyze_pos_t &raw, const feedRate_t &fr_mm_s=0.0f); -#if LINEAR_AXES >= 4 - void do_blocking_move_to(const xyzeOnly_pos_t &raw, const feedRate_t &fr_mm_s=0.0f); - /* - #if LINEAR_AXES >= 5 - void do_blocking_move_to(const xyzieOnly_pos_t &raw, const feedRate_t &fr_mm_s=0.0f); - #if LINEAR_AXES >= 6 - void do_blocking_move_to(const xyzieOnly_pos_t &raw, const feedRate_t &fr_mm_s=0.0f); - #endif - #endif - */ -#endif + void do_blocking_move_to_x(const float &rx, const feedRate_t &fr_mm_s=0.0f); void do_blocking_move_to_y(const float &ry, const feedRate_t &fr_mm_s=0.0f); void do_blocking_move_to_z(const float &rz, const feedRate_t &fr_mm_s=0.0f); #if LINEAR_AXES >= 4 void do_blocking_move_to_i(const float &ri, const feedRate_t &fr_mm_s=0.0f); void do_blocking_move_to_xyz_i(const xyze_pos_t &raw, const float &i, const feedRate_t &fr_mm_s=0.0f); - /* - FORCE_INLINE void do_blocking_move_to_xyz_i(const xyz_pos_t &raw, const float &i, const feedRate_t &fr_mm_s=0.0f) { do_blocking_move_to_xyz_i(xyzOnly_pos_t(raw), i, fr_mm_s); } - FORCE_INLINE void do_blocking_move_to_xyz_i(const xyze_pos_t &raw, const float &i, const feedRate_t &fr_mm_s=0.0f) { do_blocking_move_to_xyz_i(xyzOnly_pos_t(raw), i, fr_mm_s); } - */ #endif #if LINEAR_AXES >= 5 void do_blocking_move_to_j(const float &rj, const feedRate_t &fr_mm_s=0.0f); - void do_blocking_move_to_xyz_j(const xyze_pos_t &raw, const float &j, const feedRate_t &fr_mm_s=0.0f); + void do_blocking_move_to_xyzi_j(const xyze_pos_t &raw, const float &j, const feedRate_t &fr_mm_s=0.0f); #endif #if LINEAR_AXES >= 6 void do_blocking_move_to_k(const float &rk, const feedRate_t &fr_mm_s=0.0f); - void do_blocking_move_to_xyz_k(const xyze_pos_t &raw, const float &k, const feedRate_t &fr_mm_s=0.0f); + void do_blocking_move_to_xyzij_k(const xyze_pos_t &raw, const float &k, const feedRate_t &fr_mm_s=0.0f); #endif void do_blocking_move_to_xy(const float &rx, const float &ry, const feedRate_t &fr_mm_s=0.0f); void do_blocking_move_to_xy(const xy_pos_t &raw, const feedRate_t &fr_mm_s=0.0f); diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 6c35fdc84d46c..7b0396e008056 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1750,15 +1750,19 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif , feedRate_t fr_mm_s, const uint8_t extruder, const float &millimeters/*=0.0*/ ) { - const int32_t LIST_N(LINEAR_AXES, - da = target.a - position.a, - db = target.b - position.b, - dc = target.c - position.c, - di = target.i - position.i, - dj = target.j - position.j, - dk = target.k - position.k - ); - + const int32_t da = target.a - position.a, + db = target.b - position.b, + dc = target.c - position.c; + #if LINEAR_AXES >= 4 + const int32_t di = target.i - position.i; + #endif + #if LINEAR_AXES >= 5 + const int32_t dj = target.j - position.j; + #endif + #if LINEAR_AXES >= 6 + const int32_t dk = target.k - position.k; + #endif + #if EXTRUDERS int32_t de = target.e - position.e; #else @@ -1811,7 +1815,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif // PREVENT_COLD_EXTRUSION || PREVENT_LENGTHY_EXTRUDE // Compute direction bit-mask for this block - axis_bits_t dm = 0; + uint8_t dm = 0; #if CORE_IS_XY if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis if (db < 0) SBI(dm, Y_HEAD); // ...and Y @@ -1834,7 +1838,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (da < 0) SBI(dm, X_AXIS); if (db < 0) SBI(dm, Y_AXIS); if (dc < 0) SBI(dm, Z_AXIS); - #if LINEAR_AXES >= 4 + #if LINEAR_AXES >= 4 if (di < 0) SBI(dm, I_AXIS); #endif #if LINEAR_AXES >= 5 @@ -1927,18 +1931,30 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif #endif - steps_dist_mm.e = TERN0(HAS_EXTRUDERS, esteps_float * steps_to_mm[E_AXIS_N(extruder)]); + #if EXTRUDERS + steps_dist_mm.e = esteps_float * steps_to_mm[E_AXIS_N(extruder)]; + #else + steps_dist_mm.e = 0.0f; + #endif + TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator += steps_dist_mm.e); - if (GANG_N(LINEAR_AXES, - block->steps.a < MIN_STEPS_PER_SEGMENT, - && block->steps.b < MIN_STEPS_PER_SEGMENT, - && block->steps.c < MIN_STEPS_PER_SEGMENT, - && block->steps.i < MIN_STEPS_PER_SEGMENT, - && block->steps.j < MIN_STEPS_PER_SEGMENT, - && block->steps.k < MIN_STEPS_PER_SEGMENT - )) { - block->millimeters = TERN0(HAS_EXTRUDERS, ABS(steps_dist_mm.e)); + if (block->steps.a < MIN_STEPS_PER_SEGMENT && block->steps.b < MIN_STEPS_PER_SEGMENT && block->steps.c < MIN_STEPS_PER_SEGMENT + #if LINEAR_AXES >= 4 + && block->steps.i < MIN_STEPS_PER_SEGMENT + #endif + #if LINEAR_AXES >= 5 + && block->steps.j < MIN_STEPS_PER_SEGMENT + #endif + #if LINEAR_AXES >= 6 + && block->steps.k < MIN_STEPS_PER_SEGMENT + #endif + ) { + block->millimeters = (0 + #if EXTRUDERS + + ABS(steps_dist_mm.e) + #endif + ); } else { if (millimeters) @@ -1946,24 +1962,29 @@ bool Planner::_populate_block(block_t * const block, bool split_move, else { block->millimeters = SQRT( #if CORE_IS_XY - GANG_N(LINEAR_AXES, - sq(steps_dist_mm.head.x), - + sq(steps_dist_mm.head.y), - + sq(steps_dist_mm.z), - + sq(steps_dist_mm.i), - + sq(steps_dist_mm.j), + sq(steps_dist_mm.head.x) + sq(steps_dist_mm.head.y) + sq(steps_dist_mm.z) + #if LINEAR_AXES >= 4 + + sq(steps_dist_mm.i) + #endif + #if LINEAR_AXES >= 5 + + sq(steps_dist_mm.j) + #endif + #if LINEAR_AXES >= 6 + sq(steps_dist_mm.k) - ) + #endif #elif CORE_IS_XZ - GANG_N(LINEAR_AXES, - sq(steps_dist_mm.head.x), - + sq(steps_dist_mm.y), - + sq(steps_dist_mm.head.z), - + sq(steps_dist_mm.i), - + sq(steps_dist_mm.j), + sq(steps_dist_mm.head.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.head.z) + #if LINEAR_AXES >= 4 + + sq(steps_dist_mm.i) + #endif + #if LINEAR_AXES >= 5 + + sq(steps_dist_mm.j) + #endif + #if LINEAR_AXES >= 6 + sq(steps_dist_mm.k) - ) + #endif + #elif CORE_IS_YZ sq(steps_dist_mm.x) + sq(steps_dist_mm.head.y) + sq(steps_dist_mm.head.z) @@ -1972,42 +1993,44 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // XYZ vector magnitude. If one of the secondary axes IJK moves further // than the XYZ vector magnitude, take the largest single-axis move, instead. #if LINEAR_AXES == 6 - _MAX( - sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.z), - _MAX(sq(steps_dist_mm.i), sq(steps_dist_mm.j), sq(steps_dist_mm.k)) - ) + sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.z) + > _MAX(sq(steps_dist_mm.i), sq(steps_dist_mm.j), sq(steps_dist_mm.k)) + ? sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.z) + : _MAX(sq(steps_dist_mm.i), sq(steps_dist_mm.j), sq(steps_dist_mm.k)) #elif LINEAR_AXES == 5 - _MAX( - sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.z), - _MAX(sq(steps_dist_mm.i), sq(steps_dist_mm.j)) - ) + sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.z) + > _MAX(sq(steps_dist_mm.i), sq(steps_dist_mm.j)) + ? sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.z) + : _MAX(sq(steps_dist_mm.i), sq(steps_dist_mm.j)) #elif LINEAR_AXES == 4 - sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.z) + sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.z) > sq(steps_dist_mm.i) ? sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.z) : sq(steps_dist_mm.i) #else - sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.z) + sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.z) #endif #elif defined(FOAMCUTTER_XYUV) // return the largest distance move from either X/Y or I/J plane // largest distance from either X/Y or I/J plane - #if LINEAR_AXES >= 6 - _MAX(sq(steps_dist_mm.x) + sq(steps_dist_mm.y), sq(steps_dist_mm.i) + sq(steps_dist_mm.j)) - #else - sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + #if LINEAR_AXES >= 5 + sq(steps_dist_mm.x) + sq(steps_dist_mm.y) > sq(steps_dist_mm.i) + sq(steps_dist_mm.j) + ? sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + : sq(steps_dist_mm.i) + sq(steps_dist_mm.j) #endif #else - GANG_N(LINEAR_AXES, - sq(steps_dist_mm.x), - + sq(steps_dist_mm.y), - + sq(steps_dist_mm.z), - + sq(steps_dist_mm.i), - + sq(steps_dist_mm.j), + sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.z) + #if LINEAR_AXES >= 4 + + sq(steps_dist_mm.i) + #endif + #if LINEAR_AXES >= 5 + + sq(steps_dist_mm.j) + #endif + #if LINEAR_AXES >= 6 + sq(steps_dist_mm.k) - ) + #endif #endif ); } @@ -2055,14 +2078,19 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif #if ENABLED(AUTO_POWER_CONTROL) - if (GANG_N(LINEAR_AXES, - block->steps.x, - || block->steps.y, - || block->steps.z, - || block->steps.i, - || block->steps.j, - || block->steps.k) - ) powerManager.power_on(); + if (block->steps.x || block->steps.y || block->steps.z + #if LINEAR_AXES >= 4 + || block->steps.i + #endif + #if LINEAR_AXES >= 5 + || block->steps.j + #endif + #if LINEAR_AXES >= 6 + || block->steps.k + #endif + ) { + powerManager.power_on(); + } #endif // Enable active axes @@ -2096,7 +2124,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (block->steps.j) ENABLE_AXIS_J(); #endif #if LINEAR_AXES >= 6 - if (block->steps.k) ENABLE_AXIS_K(); + if (block->steps.k) ENABLE_AXIS_K(); #endif #if DISABLED(Z_LATE_ENABLE) if (block->steps.z) ENABLE_AXIS_Z(); @@ -2288,14 +2316,17 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Compute and limit the acceleration rate for the trapezoid generator. const float steps_per_mm = block->step_event_count * inverse_millimeters; uint32_t accel; - if (GANG_N(LINEAR_AXES, - !block->steps.a, - && !block->steps.b, - && !block->steps.c, - && !block->steps.i, - && !block->steps.j, - && !block->steps.k) - ) { + if (!block->steps.a && !block->steps.b && !block->steps.c + #if LINEAR_AXES >= 4 + && !block->steps.i + #endif + #if LINEAR_AXES >= 5 + && !block->steps.j + #endif + #if LINEAR_AXES >= 6 + && !block->steps.k + #endif + ) { // convert to: acceleration steps/sec^2 accel = CEIL(settings.retract_acceleration * steps_per_mm); TERN_(LIN_ADVANCE, block->use_advance_lead = false); @@ -2457,14 +2488,18 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (moves_queued && !UNEAR_ZERO(previous_nominal_speed_sqr)) { // Compute cosine of angle between previous and current path. (prev_unit_vec is negative) // NOTE: Max junction velocity is computed without sin() or acos() by trig half angle identity. - float junction_cos_theta = GANG_N(LINEAR_AXES, - (-prev_unit_vec.x * unit_vec.x), - + (-prev_unit_vec.y * unit_vec.y), - + (-prev_unit_vec.z * unit_vec.z), - + (-prev_unit_vec.i * unit_vec.i), - + (-prev_unit_vec.j * unit_vec.j), - + (-prev_unit_vec.k * unit_vec.k)) - + (-prev_unit_vec.e * unit_vec.e); + float junction_cos_theta = (-prev_unit_vec.x * unit_vec.x) + (-prev_unit_vec.y * unit_vec.y) + + (-prev_unit_vec.z * unit_vec.z) + #if LINEAR_AXES >= 4 + + (-prev_unit_vec.i * unit_vec.i) + #endif + #if LINEAR_AXES >= 5 + + (-prev_unit_vec.j * unit_vec.j) + #endif + #if LINEAR_AXES >= 6 + + (-prev_unit_vec.k * unit_vec.k) + #endif + + (-prev_unit_vec.e * unit_vec.e); // NOTE: Computed without any expensive trig, sin() or acos(), by trig half angle identity of cos(theta). if (junction_cos_theta > 0.999999f) { @@ -2770,9 +2805,17 @@ void Planner::buffer_sync_block() { * * Return 'false' if no segment was queued due to cleaning, cold extrusion, full queue, etc. */ -bool Planner::buffer_segment( - LIST_N(LINEAR_AXES, const float &a, const float &b, const float &c, const float &i, const float &j, const float &k) - , const float &e +bool Planner::buffer_segment(const float &a, const float &b, const float &c + #if LINEAR_AXES >= 4 + , const float &i + #endif + #if LINEAR_AXES >= 5 + , const float &j + #endif + #if LINEAR_AXES >= 6 + , const float &k + #endif + , const float &e #if HAS_DIST_MM_ARG , const xyze_float_t &cart_dist_mm #endif @@ -2793,14 +2836,14 @@ bool Planner::buffer_segment( // The target position of the tool in absolute steps // Calculate target position in absolute steps const abce_long_t target = { - LIST_N(LINEAR_AXES, + LIST_N(LINEAR_AXES, int32_t(LROUND(a * settings.axis_steps_per_mm[A_AXIS])), int32_t(LROUND(b * settings.axis_steps_per_mm[B_AXIS])), int32_t(LROUND(c * settings.axis_steps_per_mm[C_AXIS])), int32_t(LROUND(i * settings.axis_steps_per_mm[I_AXIS])), // FIXME (DerAndere): Multiplication by 4.0 is a work-around for issue with wrong internal steps per mm int32_t(LROUND(j * settings.axis_steps_per_mm[J_AXIS])), int32_t(LROUND(k * settings.axis_steps_per_mm[K_AXIS])) - ), + ), int32_t(LROUND(e * settings.axis_steps_per_mm[E_AXIS_N(extruder)])) }; @@ -2865,13 +2908,13 @@ bool Planner::buffer_segment( // Queue the movement. Return 'false' if the move was not queued. if (!_buffer_steps(target - #if HAS_POSITION_FLOAT - , target_float - #endif - #if HAS_DIST_MM_ARG - , cart_dist_mm - #endif - , fr_mm_s, extruder, millimeters) + #if HAS_POSITION_FLOAT + , target_float + #endif + #if HAS_DIST_MM_ARG + , cart_dist_mm + #endif + , fr_mm_s, extruder, millimeters) ) return false; stepper.wake_up(); @@ -2889,9 +2932,17 @@ bool Planner::buffer_segment( * millimeters - the length of the movement, if known * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) */ -bool Planner::buffer_line( - LIST_N(LINEAR_AXES, const float &rx, const float &ry, const float &rz, const float &ri, const float &rj, const float &rk) - , const float &e, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters +bool Planner::buffer_line(const float &rx, const float &ry, const float &rz + #if LINEAR_AXES >= 4 + , const float &ri + #endif + #if LINEAR_AXES >= 5 + , const float &rj + #endif + #if LINEAR_AXES >= 6 + , const float &rk + #endif + , const float &e, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters #if ENABLED(SCARA_FEEDRATE_SCALING) , const float &inv_duration #endif @@ -3012,10 +3063,17 @@ bool Planner::buffer_line( * The provided ABC position is in machine units. */ -void Planner::set_machine_position_mm( - LIST_N(LINEAR_AXES, const float &a, const float &b, const float &c, const float &i, const float &j, const float &k), - const float &e -) { +void Planner::set_machine_position_mm(const float &a, const float &b, const float &c + #if LINEAR_AXES >= 4 + , const float &i + #endif + #if LINEAR_AXES >= 5 + , const float &j + #endif + #if LINEAR_AXES >= 6 + , const float &k + #endif + , const float &e) { TERN_(DISTINCT_E_FACTORS, last_extruder = active_extruder); TERN_(HAS_POSITION_FLOAT, position_float.set(LIST_N(LINEAR_AXES, a, b, c, i, j, k), e)); position.set( @@ -3038,12 +3096,21 @@ void Planner::set_machine_position_mm( stepper.set_position(position); } -void Planner::set_position_mm( - LIST_N(LINEAR_AXES, const float &rx, const float &ry, const float &rz, const float &ri, const float &rj, const float &rk), - const float &e -) { +void Planner::set_position_mm(const float &rx, const float &ry, const float &rz + #if LINEAR_AXES >= 4 + , const float &ri + #endif + #if LINEAR_AXES >= 5 + , const float &rj + #endif + #if LINEAR_AXES >= 6 + , const float &rk + #endif + , const float &e) { xyze_pos_t machine = { LIST_N(LINEAR_AXES, rx, ry, rz, ri, rj, rk), e }; - TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine, true)); + #if HAS_POSITION_MODIFIERS + apply_modifiers(machine, true); + #endif #if IS_KINEMATIC position_cart.set(rx, ry, rz, e); inverse_kinematics(machine); @@ -3135,8 +3202,14 @@ void Planner::set_max_feedrate(const uint8_t axis, float targetValue) { limit_and_warn(targetValue, axis, PSTR("Feedrate"), max_fr_edit_scaled); #endif #if LINEAR_AXES >= 4 - // FIXME (DerAndere): Work-around for issue with internal feedrate for I_AXIS - settings.max_feedrate_mm_s[axis] = targetValue * (axis == 3 ? 4.0f : 1.0f); + // FIXME (DerAndere):!!! Work-around for issue with internal feedrate for I_AXIS + + if (axis == 3) { + settings.max_feedrate_mm_s[axis] = targetValue * 4.0; + } + else { + settings.max_feedrate_mm_s[axis] = targetValue; + } #else settings.max_feedrate_mm_s[axis] = targetValue; #endif diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 79579d6592438..7bae397e2f1a3 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -723,9 +723,17 @@ class Planner { * extruder - target extruder * millimeters - the length of the movement, if known */ - static bool buffer_segment( - LIST_N(LINEAR_AXES, const float &a, const float &b, const float &c, const float &i, const float &j, const float &k), - const float &e + static bool buffer_segment(const float &a, const float &b, const float &c + #if LINEAR_AXES >= 4 + , const float &i + #endif + #if LINEAR_AXES >= 5 + , const float &j + #endif + #if LINEAR_AXES >= 6 + , const float &k + #endif + , const float &e #if HAS_DIST_MM_ARG , const xyze_float_t &cart_dist_mm #endif @@ -760,10 +768,17 @@ class Planner { * millimeters - the length of the movement, if known * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) */ - static bool buffer_line( - LIST_N(LINEAR_AXES, const float &rx, const float &ry, const float &rz, const float &ri, const float &rj, const float &rk) - , const float &e - , const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters=0.0 + static bool buffer_line(const float &rx, const float &ry, const float &rz + #if LINEAR_AXES >= 4 + , const float &ri + #endif + #if LINEAR_AXES >= 5 + , const float &rj + #endif + #if LINEAR_AXES >= 6 + , const float &rk + #endif + , const float &e, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters=0.0 #if ENABLED(SCARA_FEEDRATE_SCALING) , const float &inv_duration=0.0 #endif @@ -800,11 +815,19 @@ class Planner { * * Clears previous speed values. */ - static void set_position_mm( - LIST_N(LINEAR_AXES, const float &rx, const float &ry, const float &rz, const float &ri, const float &rj, const float &rk), - const float &e + static void set_position_mm(const float &rx, const float &ry, const float &rz + #if LINEAR_AXES >= 4 + , const float &ri + #endif + #if LINEAR_AXES >= 5 + , const float &rj + #endif + #if LINEAR_AXES > 5 + , const float &rk + #endif + , const float &e ); - FORCE_INLINE static void set_position_mm(const xyze_pos_t &cart) { + FORCE_INLINE static void set_position_mm(const xyze_pos_t &cart) { set_position_mm(LIST_N(LINEAR_AXES, cart.x, cart.y, cart.z, cart.i, cart.j, cart.k), cart.e); } static void set_e_position_mm(const float &e); @@ -815,9 +838,17 @@ class Planner { * The supplied position is in machine space, and no additional * conversions are applied. */ - static void set_machine_position_mm( - LIST_N(LINEAR_AXES, const float &a, const float &b, const float &c, const float &i, const float &j, const float &k), - const float &e + static void set_machine_position_mm(const float &a, const float &b, const float &c + #if LINEAR_AXES >= 4 + , const float &i + #endif + #if LINEAR_AXES >= 5 + , const float &j + #endif + #if LINEAR_AXES >= 6 + , const float &k + #endif + , const float &e ); FORCE_INLINE static void set_machine_position_mm(const abce_pos_t &abce) { set_machine_position_mm( diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 73829490ae836..b4424525d5cd2 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -37,7 +37,7 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V89" +#define EEPROM_VERSION "V90" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -2493,7 +2493,7 @@ void MarlinSettings::postprocess() { void MarlinSettings::reset() { LOOP_NUM_AXIS_N(i) { planner.settings.max_acceleration_mm_per_s2[i] = pgm_read_dword(&_DMA[ALIM(i, _DMA)]); - // FIXME (DerAndere): Work around issue where actual internally-used steps_per_mm for I_AXIS are only 1/4 of STEPS_PER_UNIT + // FIXME (DerAndere):!!! Work around issue where actual internally-used steps_per_mm for I_AXIS are only 1/4 of STEPS_PER_UNIT planner.settings.axis_steps_per_mm[i] = pgm_read_float(&_DASU[ALIM(i, _DASU)]); if (LINEAR_AXES >= 4 && i == 3) planner.settings.axis_steps_per_mm[i] *= 4.0f; planner.settings.max_feedrate_mm_s[i] = pgm_read_float(&_DMF[ALIM(i, _DMF)]);