gnea\grbl-Mega  1.0f
Source Code Documentation ( Internal Workings )
nuts_bolts.h
Go to the documentation of this file.
1 /*
2  nuts_bolts.h - Header file for shared definitions, variables, and functions
3  Part of Grbl
4 
5  Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
6  Copyright (c) 2009-2011 Simen Svale Skogsrud
7 
8  Grbl is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  Grbl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Grbl. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #ifndef nuts_bolts_h
23 #define nuts_bolts_h
24 
25 #define false 0
26 #define true 1
27 
28 #define SOME_LARGE_VALUE 1.0E+38
29 #define N_AXIS 3
31 #define X_AXIS 0
32 #define Y_AXIS 1
33 #define Z_AXIS 2
34 // #define A_AXIS 3
36 //
38 #ifdef COREXY
39  #define A_MOTOR X_AXIS
40  #define B_MOTOR Y_AXIS
41 #endif
42 #define MM_PER_INCH (25.40)
44 #define INCH_PER_MM (0.0393701)
45 #define TICKS_PER_MICROSECOND (F_CPU/1000000)
46 
47 #define DELAY_MODE_DWELL 0
48 #define DELAY_MODE_SYS_SUSPEND 1
49 #define clear_vector(a) memset(a, 0, sizeof(a))
51 #define clear_vector_float(a) memset(a, 0.0, sizeof(float)*N_AXIS)
52 // #define clear_vector_long(a) memset(a, 0.0, sizeof(long)*N_AXIS)
53 #define max(a,b) (((a) > (b)) ? (a) : (b))
54 #define min(a,b) (((a) < (b)) ? (a) : (b))
55 #define isequal_position_vector(a,b) !(memcmp(a, b, sizeof(float)*N_AXIS))
56 #define bit(n) (1 << n)
58 #define bit_true(x,mask) (x) |= (mask)
59 #define bit_false(x,mask) (x) &= ~(mask)
60 #define bit_istrue(x,mask) ((x & mask) != 0)
61 #define bit_isfalse(x,mask) ((x & mask) == 0)
62 // is the indexer pointing to the current character of the line, while float_ptr is
64 // a pointer to the result variable. Returns true when it succeeds
65 uint8_t read_float(char *line, uint8_t *char_counter, float *float_ptr);
67 void delay_sec(float seconds, uint8_t mode);
69 void delay_ms(uint16_t ms);
71 void delay_us(uint32_t us);
73 float hypot_f(float x, float y);
74 
75 float convert_delta_vector_to_unit_vector(float *vector);
76 float limit_value_by_axis_maximum(float *max_value, float *unit_vec);
77 
78 #endif
float limit_value_by_axis_maximum(float *max_value, float *unit_vec)
Definition: nuts_bolts.c:176
uint8_t read_float(char *line, uint8_t *char_counter, float *float_ptr)
Read a floating point value from a string. Line points to the input buffer, char_counter.
Definition: nuts_bolts.c:35
void delay_us(uint32_t us)
Delays variable-defined microseconds. Compiler compatibility fix for _delay_us(). ...
Definition: nuts_bolts.c:137
float convert_delta_vector_to_unit_vector(float *vector)
Definition: nuts_bolts.c:160
float hypot_f(float x, float y)
Computes hypotenuse, avoiding avr-gcc's bloated version and the extra error checking.
Definition: nuts_bolts.c:157
void delay_sec(float seconds, uint8_t mode)
Non-blocking delay function used for general operation and suspend features.
Definition: nuts_bolts.c:111
void delay_ms(uint16_t ms)
Delays variable-defined milliseconds. Compiler compatibility fix for _delay_ms(). ...
Definition: nuts_bolts.c:129