Merge branch 'edge' into accel
[clinton/Smoothieware.git] / src / modules / tools / endstops / Endstops.h
1 /*
2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
3 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
6 */
7
8 #ifndef ENDSTOPS_MODULE_H
9 #define ENDSTOPS_MODULE_H
10
11 #include "libs/Module.h"
12 #include "libs/Kernel.h"
13 #include "modules/communication/utils/Gcode.h"
14 #include "libs/StepperMotor.h"
15 #include "libs/Pin.h"
16
17 #define ALPHA_AXIS 0
18 #define BETA_AXIS 1
19 #define GAMMA_AXIS 2
20
21 #define NOT_HOMING 0
22 #define MOVING_TO_ORIGIN_FAST 1
23 #define MOVING_BACK 2
24 #define MOVING_TO_ORIGIN_SLOW 3
25
26 #define endstops_module_enable_checksum CHECKSUM("endstops_enable")
27
28 #define alpha_min_endstop_checksum CHECKSUM("alpha_min_endstop")
29 #define beta_min_endstop_checksum CHECKSUM("beta_min_endstop")
30 #define gamma_min_endstop_checksum CHECKSUM("gamma_min_endstop")
31
32 #define alpha_max_endstop_checksum CHECKSUM("alpha_max_endstop")
33 #define beta_max_endstop_checksum CHECKSUM("beta_max_endstop")
34 #define gamma_max_endstop_checksum CHECKSUM("gamma_max_endstop")
35
36 #define alpha_fast_homing_rate_checksum CHECKSUM("alpha_fast_homing_rate")
37 #define beta_fast_homing_rate_checksum CHECKSUM("beta_fast_homing_rate")
38 #define gamma_fast_homing_rate_checksum CHECKSUM("gamma_fast_homing_rate")
39
40 #define alpha_slow_homing_rate_checksum CHECKSUM("alpha_slow_homing_rate")
41 #define beta_slow_homing_rate_checksum CHECKSUM("beta_slow_homing_rate")
42 #define gamma_slow_homing_rate_checksum CHECKSUM("gamma_slow_homing_rate")
43
44 #define alpha_homing_retract_checksum CHECKSUM("alpha_homing_retract")
45 #define beta_homing_retract_checksum CHECKSUM("beta_homing_retract")
46 #define gamma_homing_retract_checksum CHECKSUM("gamma_homing_retract")
47 #define endstop_debounce_count_checksum CHECKSUM("endstop_debounce_count")
48
49 #define alpha_homing_direction_checksum CHECKSUM("alpha_homing_direction")
50 #define beta_homing_direction_checksum CHECKSUM("beta_homing_direction")
51 #define gamma_homing_direction_checksum CHECKSUM("gamma_homing_direction")
52
53 #define alpha_min_checksum CHECKSUM("alpha_min")
54 #define beta_min_checksum CHECKSUM("beta_min")
55 #define gamma_min_checksum CHECKSUM("gamma_min")
56
57 #define alpha_max_checksum CHECKSUM("alpha_max")
58 #define beta_max_checksum CHECKSUM("beta_max")
59 #define gamma_max_checksum CHECKSUM("gamma_max")
60
61
62 class Endstops : public Module{
63 private:
64 void wait_for_homed(char axes_to_move);
65
66 public:
67 Endstops();
68 void on_module_loaded();
69 void on_gcode_received(void* argument);
70 void on_config_reload(void* argument);
71
72 StepperMotor* steppers[3];
73 Pin pins[6];
74 double slow_rates[3];
75 double fast_rates[3];
76 unsigned int retract_steps[3];
77 unsigned int debounce_count;
78 int direction[3];
79 double homing_position[3];
80 char status;
81 };
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99 #endif