24 #ifndef _NUTS_BOLTS_H_
25 #define _NUTS_BOLTS_H_
38 #define SOME_LARGE_VALUE 1.0E+38f
40 #define M_PI 3.14159265358979323846f
43 #define TOLERANCE_EQUAL 0.0001f
45 #define RADDEG 0.01745329251994329577f
46 #define DEGRAD 57.29577951308232087680f
47 #define SQRT3 1.73205080756887729353f
48 #define SIN120 0.86602540378443864676f
50 #define TAN60 1.73205080756887729353f
52 #define TAN30 0.57735026918962576451f
53 #define TAN30_2 0.28867513459481288225f
55 #define ABORTED (sys.abort || sys.cancel)
58 #define CAPS(c) ((c >= 'a' && c <= 'z') ? (c & 0x5F) : c)
59 #define LCAPS(c) ((c >= 'A' && c <= 'Z') ? (c | 0x20) : c)
61 #if !(defined(STM32F103xB) || defined(STM32F303xC))
63 #define UNUSED(x) (void)(x)
67 #if defined(__MSP430F5529__) || defined(__MSP432P401R__) || defined(__MSP432E401Y__) || defined(PART_TM4C123GH6PM) || defined(PART_TM4C1294NCPDT)
68 #define isnanf(x) __isnanf(x)
69 #define isinff(x) __isinff(x)
76 #define X_AXIS_BIT bit(X_AXIS)
77 #define Y_AXIS_BIT bit(Y_AXIS)
78 #define Z_AXIS_BIT bit(Z_AXIS)
81 #define A_AXIS_BIT bit(A_AXIS)
85 #define B_AXIS_BIT bit(B_AXIS)
89 #define C_AXIS_BIT bit(C_AXIS)
93 #define U_AXIS_BIT bit(U_AXIS)
97 #define V_AXIS_BIT bit(V_AXIS)
101 #define AXES_BITMASK (X_AXIS_BIT|Y_AXIS_BIT|Z_AXIS_BIT)
103 #define AXES_BITMASK (X_AXIS_BIT|Y_AXIS_BIT|Z_AXIS_BIT|A_AXIS_BIT)
105 #define AXES_BITMASK (X_AXIS_BIT|Y_AXIS_BIT|Z_AXIS_BIT|A_AXIS_BIT|B_AXIS_BIT)
107 #define AXES_BITMASK (X_AXIS_BIT|Y_AXIS_BIT|Z_AXIS_BIT|A_AXIS_BIT|B_AXIS_BIT|C_AXIS_BIT)
109 #define AXES_BITMASK (X_AXIS_BIT|Y_AXIS_BIT|Z_AXIS_BIT|A_AXIS_BIT|B_AXIS_BIT|C_AXIS_BIT|U_AXIS_BIT)
111 #define AXES_BITMASK (X_AXIS_BIT|Y_AXIS_BIT|Z_AXIS_BIT|A_AXIS_BIT|B_AXIS_BIT|C_AXIS_BIT|U_AXIS_BIT|V_AXIS_BIT)
116 #elif defined(U_AXIS)
118 #elif defined(C_AXIS)
120 #elif defined(B_AXIS)
122 #elif defined(A_AXIS)
154 #pragma pack(push, 1)
178 #define MM_PER_INCH (25.40f)
179 #define INCH_PER_MM (0.0393701f)
181 #define MAX_INT_DIGITS 9
182 #define STRLEN_COORDVALUE (MAX_INT_DIGITS + N_DECIMAL_COORDVALUE_INCH + 1)
186 #define max(a,b) (((a) > (b)) ? (a) : (b))
189 #define min(a,b) (((a) < (b)) ? (a) : (b))
192 #define constrain(val, min, max) ((val) < (min) ? (min) : ((val) > (max) ? (max) : (val)))
194 #define clear_vector(a) memset(a, 0, sizeof(a))
195 #define isequal_position_vector(a, b) !memcmp(a, b, sizeof(coord_data_t))
196 #define is0_position_vector(a) !memcmp(a, &((coord_data_t){0}), sizeof(coord_data_t))
200 #define bit(n) (1UL << (n))
202 #define bit_true(x, mask) (x) |= (mask)
203 #define bit_false(x, mask) (x) &= ~(mask)
204 #define BIT_SET(x, bit, v) { if (v) { x |= (bit); } else { x &= ~(bit); } }
206 #define bit_istrue(x, mask) ((x & (mask)) != 0)
207 #define bit_isfalse(x, mask) ((x & (mask)) == 0)
210 char *
uitoa (uint32_t n);
213 char *
ftoa (
float n, uint8_t decimal_places);
219 bool isintf (
float value);
221 status_code_t
read_uint (
char *line, uint_fast8_t *char_counter, uint32_t *uint_ptr);
226 bool read_float (
char *line, uint_fast8_t *char_counter,
float *float_ptr);
float convert_delta_vector_to_unit_vector(float *vector)
Definition: nuts_bolts.c:332
struct tm * get_datetime(const char *s)
Definition: nuts_bolts.c:354
char * strcaps(char *s)
Definition: nuts_bolts.c:428
bool isintf(float value)
Definition: nuts_bolts.c:307
bool read_float(char *line, uint_fast8_t *char_counter, float *float_ptr)
Definition: nuts_bolts.c:242
char const *const axis_letter[]
Definition: nuts_bolts.c:62
uint8_t calc_checksum(uint8_t *data, uint32_t size)
Definition: nuts_bolts.c:415
status_code_t read_uint(char *line, uint_fast8_t *char_counter, uint32_t *uint_ptr)
Definition: nuts_bolts.c:184
char * ftoa(float n, uint8_t decimal_places)
Definition: nuts_bolts.c:115
char * uitoa(uint32_t n)
Definition: nuts_bolts.c:96
delaymode_t
Definition: nuts_bolts.h:172
@ DelayMode_SysSuspend
Definition: nuts_bolts.h:174
@ DelayMode_Dwell
Definition: nuts_bolts.h:173
bool delay_sec(float seconds, delaymode_t mode)
Definition: nuts_bolts.c:313
char * trim_float(char *s)
Definition: nuts_bolts.c:170
void dummy_handler(void)
Definition: nuts_bolts.c:444
Home switches struct, consists of two packed axes_signals_t structs.
Definition: nuts_bolts.h:165
axes_signals_t a
Primary home switches status, optional. Limit signals are used for homing if not available.
Definition: nuts_bolts.h:166
axes_signals_t b
Secondary home switch(es) status, required for auto squaring enabled axes if primary switches are ava...
Definition: nuts_bolts.h:167
Limit switches struct, consists of four packed axes_signals_t structs in 32 bits.
Definition: nuts_bolts.h:157
axes_signals_t min
Min limit switches status, required.
Definition: nuts_bolts.h:158
axes_signals_t min2
Secondary min limit switch(es) status, required for auto squaring enabled axes.
Definition: nuts_bolts.h:160
axes_signals_t max2
Secondary max limit switches status, optional (of no practical use?).
Definition: nuts_bolts.h:161
axes_signals_t max
Max limit switches status, optional.
Definition: nuts_bolts.h:159
Definition: nuts_bolts.h:130
uint8_t u
Definition: nuts_bolts.h:141
uint8_t x
Definition: nuts_bolts.h:135
uint8_t y
Definition: nuts_bolts.h:136
uint8_t c
Definition: nuts_bolts.h:140
uint8_t b
Definition: nuts_bolts.h:139
uint8_t v
Definition: nuts_bolts.h:142
uint8_t bits
Definition: nuts_bolts.h:132
uint8_t value
Definition: nuts_bolts.h:133
uint8_t mask
Definition: nuts_bolts.h:131
uint8_t z
Definition: nuts_bolts.h:137
uint8_t a
Definition: nuts_bolts.h:138
Definition: nuts_bolts.h:146
float y
Definition: nuts_bolts.h:150
float x
Definition: nuts_bolts.h:149