|
21 | 21 | */
|
22 | 22 | #pragma once
|
23 | 23 |
|
24 |
| -#include <math.h> |
25 |
| -#include <stddef.h> |
26 |
| - |
27 | 24 | #include "../inc/MarlinConfigPre.h"
|
28 | 25 |
|
29 |
| -// |
30 |
| -// Conditional type assignment magic. For example... |
31 |
| -// |
32 |
| -// typename IF<(MYOPT==12), int, float>::type myvar; |
33 |
| -// |
34 |
| -template <bool, class L, class R> struct IF { typedef R type; }; |
35 |
| -template <class L, class R> struct IF<true, L, R> { typedef L type; }; |
36 |
| - |
37 | 26 | #define ALL_AXIS_NAMES X, X2, Y, Y2, Z, Z2, Z3, Z4, I, J, K, U, V, W, E0, E1, E2, E3, E4, E5, E6, E7
|
38 | 27 |
|
39 | 28 | #define NUM_AXIS_GANG(V...) GANG_N(NUM_AXES, V)
|
@@ -84,59 +73,6 @@ template <class L, class R> struct IF<true, L, R> { typedef L type; };
|
84 | 73 |
|
85 | 74 | #define AXIS_COLLISION(L) (AXIS4_NAME == L || AXIS5_NAME == L || AXIS6_NAME == L || AXIS7_NAME == L || AXIS8_NAME == L || AXIS9_NAME == L)
|
86 | 75 |
|
87 |
| -// Helpers |
88 |
| -#define _RECIP(N) ((N) ? 1.0f / static_cast<float>(N) : 0.0f) |
89 |
| -#define _ABS(N) ((N) < 0 ? -(N) : (N)) |
90 |
| -#define _LS(N) (N = (T)(uint32_t(N) << p)) |
91 |
| -#define _RS(N) (N = (T)(uint32_t(N) >> p)) |
92 |
| -#define FI FORCE_INLINE |
93 |
| - |
94 |
| -// Define types based on largest bit width stored value required |
95 |
| -#define bits_t(W) typename IF<((W)> 16), uint32_t, typename IF<((W)> 8), uint16_t, uint8_t>::type>::type |
96 |
| -#define uvalue_t(V) typename IF<((V)>65535), uint32_t, typename IF<((V)>255), uint16_t, uint8_t>::type>::type |
97 |
| -#define value_t(V) typename IF<((V)>32767), int32_t, typename IF<((V)>127), int16_t, int8_t>::type>::type |
98 |
| - |
99 |
| -// General Flags for some number of states |
100 |
| -template<size_t N> |
101 |
| -struct Flags { |
102 |
| - typedef value_t(N) flagbits_t; |
103 |
| - typedef struct { bool b0:1, b1:1, b2:1, b3:1, b4:1, b5:1, b6:1, b7:1; } N8; |
104 |
| - typedef struct { bool b0:1, b1:1, b2:1, b3:1, b4:1, b5:1, b6:1, b7:1, b8:1, b9:1, b10:1, b11:1, b12:1, b13:1, b14:1, b15:1; } N16; |
105 |
| - typedef struct { bool b0:1, b1:1, b2:1, b3:1, b4:1, b5:1, b6:1, b7:1, b8:1, b9:1, b10:1, b11:1, b12:1, b13:1, b14:1, b15:1, |
106 |
| - b16:1, b17:1, b18:1, b19:1, b20:1, b21:1, b22:1, b23:1, b24:1, b25:1, b26:1, b27:1, b28:1, b29:1, b30:1, b31:1; } N32; |
107 |
| - union { |
108 |
| - flagbits_t b; |
109 |
| - typename IF<(N>16), N32, typename IF<(N>8), N16, N8>::type>::type flag; |
110 |
| - }; |
111 |
| - FI void reset() { b = 0; } |
112 |
| - FI void set(const int n, const bool onoff) { onoff ? set(n) : clear(n); } |
113 |
| - FI void set(const int n) { b |= (flagbits_t)_BV(n); } |
114 |
| - FI void clear(const int n) { b &= ~(flagbits_t)_BV(n); } |
115 |
| - FI bool test(const int n) const { return TEST(b, n); } |
116 |
| - FI bool operator[](const int n) { return test(n); } |
117 |
| - FI bool operator[](const int n) const { return test(n); } |
118 |
| - FI int size() const { return sizeof(b); } |
119 |
| - FI operator bool() const { return b; } |
120 |
| -}; |
121 |
| - |
122 |
| -// Specialization for a single bool flag |
123 |
| -template<> |
124 |
| -struct Flags<1> { |
125 |
| - bool b; |
126 |
| - FI void reset() { b = false; } |
127 |
| - FI void set(const int n, const bool onoff) { onoff ? set(n) : clear(n); } |
128 |
| - FI void set(const int) { b = true; } |
129 |
| - FI void clear(const int) { b = false; } |
130 |
| - FI bool test(const int) const { return b; } |
131 |
| - FI bool& operator[](const int) { return b; } |
132 |
| - FI bool operator[](const int) const { return b; } |
133 |
| - FI int size() const { return sizeof(b); } |
134 |
| - FI operator bool() const { return b; } |
135 |
| -}; |
136 |
| - |
137 |
| -typedef Flags<8> flags_8_t; |
138 |
| -typedef Flags<16> flags_16_t; |
139 |
| - |
140 | 76 | // Flags for some axis states, with per-axis aliases xyzijkuvwe
|
141 | 77 | typedef struct AxisFlags {
|
142 | 78 | union {
|
@@ -208,34 +144,6 @@ typedef bits_t(NUM_AXIS_ENUMS) axis_bits_t;
|
208 | 144 | #define LOOP_DISTINCT_AXES(VAR) LOOP_S_L_N(VAR, 0, DISTINCT_AXES)
|
209 | 145 | #define LOOP_DISTINCT_E(VAR) LOOP_L_N(VAR, DISTINCT_E)
|
210 | 146 |
|
211 |
| -// |
212 |
| -// feedRate_t is just a humble float |
213 |
| -// |
214 |
| -typedef float feedRate_t; |
215 |
| - |
216 |
| -// |
217 |
| -// celsius_t is the native unit of temperature. Signed to handle a disconnected thermistor value (-14). |
218 |
| -// For more resolition (e.g., for a chocolate printer) this may later be changed to Celsius x 100 |
219 |
| -// |
220 |
| -typedef uint16_t raw_adc_t; |
221 |
| -typedef int16_t celsius_t; |
222 |
| -typedef float celsius_float_t; |
223 |
| - |
224 |
| -// |
225 |
| -// On AVR pointers are only 2 bytes so use 'const float &' for 'const float' |
226 |
| -// |
227 |
| -#ifdef __AVR__ |
228 |
| - typedef const float & const_float_t; |
229 |
| -#else |
230 |
| - typedef const float const_float_t; |
231 |
| -#endif |
232 |
| -typedef const_float_t const_feedRate_t; |
233 |
| -typedef const_float_t const_celsius_float_t; |
234 |
| - |
235 |
| -// Conversion macros |
236 |
| -#define MMM_TO_MMS(MM_M) feedRate_t(static_cast<float>(MM_M) / 60.0f) |
237 |
| -#define MMS_TO_MMM(MM_S) (static_cast<float>(MM_S) * 60.0f) |
238 |
| - |
239 | 147 | //
|
240 | 148 | // Coordinates structures for XY, XYZ, XYZE...
|
241 | 149 | //
|
@@ -321,6 +229,13 @@ void toNative(xy_pos_t &lpos);
|
321 | 229 | void toNative(xyz_pos_t &lpos);
|
322 | 230 | void toNative(xyze_pos_t &lpos);
|
323 | 231 |
|
| 232 | +// Helpers for axis types below |
| 233 | +#define _RECIP(N) ((N) ? 1.0f / static_cast<float>(N) : 0.0f) |
| 234 | +#define _ABS(N) ((N) < 0 ? -(N) : (N)) |
| 235 | +#define _LS(N) (N = (T)(uint32_t(N) << p)) |
| 236 | +#define _RS(N) (N = (T)(uint32_t(N) >> p)) |
| 237 | +#define FI FORCE_INLINE |
| 238 | + |
324 | 239 | //
|
325 | 240 | // Paired XY coordinates, counters, flags, etc.
|
326 | 241 | //
|
|
0 commit comments