c0dd944e2dc8873e89bd8706bfba6b9242a87467
[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/actuators/Actuator.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 #define home_to_max_checksum CHECKSUM("home_to_max")
53 #define home_to_min_checksum CHECKSUM("home_to_min")
54 #define alpha_min_checksum CHECKSUM("alpha_min")
55 #define beta_min_checksum CHECKSUM("beta_min")
56 #define gamma_min_checksum CHECKSUM("gamma_min")
57
58 #define alpha_max_checksum CHECKSUM("alpha_max")
59 #define beta_max_checksum CHECKSUM("beta_max")
60 #define gamma_max_checksum CHECKSUM("gamma_max")
61
62
63 class Endstops : public Module{
64 private:
65 void wait_for_homed(char axes_to_move);
66
67 public:
68 Endstops();
69 void on_module_loaded();
70 void on_gcode_received(void* argument);
71 void on_config_reload(void* argument);
72
73 Actuator* steppers[3];
74 Pin pins[6];
75 double slow_rates[3];
76 double fast_rates[3];
77 unsigned int retract_steps[3];
78 unsigned int debounce_count;
79 bool home_direction[3];
80 double homing_position[3];
81 char status;
82 };
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100 #endif