Commit | Line | Data |
---|---|---|
88443c6b JM |
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 ZPROBE_H_ | |
9 | #define ZPROBE_H_ | |
10 | ||
11 | #include "Module.h" | |
12 | #include "Pin.h" | |
13 | ||
ce9d2bda JM |
14 | #include <vector> |
15 | ||
f6efadb0 JM |
16 | // defined here as they are used in multiple files |
17 | #define zprobe_checksum CHECKSUM("zprobe") | |
18 | #define leveling_strategy_checksum CHECKSUM("leveling-strategy") | |
ce9d2bda | 19 | |
88443c6b | 20 | class StepperMotor; |
fc7b9a7b | 21 | class Gcode; |
681a62d7 | 22 | class StreamOutput; |
ce9d2bda | 23 | class LevelingStrategy; |
88443c6b JM |
24 | |
25 | class ZProbe: public Module | |
26 | { | |
27 | ||
28 | public: | |
66e6f86c | 29 | ZProbe() : running(false){}; |
31c6c2c2 | 30 | virtual ~ZProbe() {}; |
66e6f86c | 31 | |
88443c6b | 32 | void on_module_loaded(); |
88443c6b | 33 | void on_gcode_received(void *argument); |
a157d099 | 34 | void acceleration_tick(void); |
88443c6b | 35 | |
fa7bcf7e | 36 | bool wait_for_probe(int& steps); |
93f20a8c JM |
37 | bool run_probe(int& steps, float feedrate, float max_dist= -1, bool reverse= false); |
38 | bool run_probe(int& steps, bool fast= false) { return run_probe(steps, fast ? this->fast_feedrate : this->slow_feedrate); } | |
39 | bool return_probe(int steps, bool reverse= false); | |
97832d6d | 40 | bool doProbeAt(int &steps, float x, float y); |
0e44e7d7 | 41 | float probeDistance(float x, float y); |
ce9d2bda | 42 | |
037c350d | 43 | void coordinated_move(float x, float y, float z, float feedrate, bool relative=false); |
681a62d7 | 44 | void home(); |
ce9d2bda | 45 | |
2f809c40 | 46 | bool getProbeStatus() { return this->pin.get(); } |
119114b4 JM |
47 | float getSlowFeedrate() const { return slow_feedrate; } |
48 | float getFastFeedrate() const { return fast_feedrate; } | |
49 | float getProbeHeight() const { return probe_height; } | |
50 | float getMaxZ() const { return max_z; } | |
57e927fa | 51 | float zsteps_to_mm(float steps); |
ce9d2bda JM |
52 | |
53 | private: | |
66e6f86c | 54 | void on_config_reload(void *argument); |
fa7bcf7e | 55 | void accelerate(int c); |
a2f1ce04 | 56 | void probe_XYZ(Gcode *gc, int axis); |
778093ce | 57 | uint32_t read_probe(uint32_t dummy); |
fa7bcf7e | 58 | volatile float current_feedrate; |
ce9d2bda JM |
59 | float slow_feedrate; |
60 | float fast_feedrate; | |
b469231e | 61 | float return_feedrate; |
ce9d2bda | 62 | float probe_height; |
f3b66360 | 63 | float max_z; |
778093ce JM |
64 | |
65 | Pin pin; | |
66 | std::vector<LevelingStrategy*> strategies; | |
67 | uint8_t debounce_count; | |
68 | ||
fa7bcf7e JM |
69 | volatile struct { |
70 | volatile bool running:1; | |
ce9d2bda | 71 | bool is_delta:1; |
d8198a57 | 72 | bool is_rdelta:1; |
778093ce | 73 | bool probing:1; |
93f20a8c | 74 | bool reverse_z:1; |
778093ce | 75 | volatile bool probe_detected:1; |
7d6fe308 | 76 | }; |
88443c6b JM |
77 | }; |
78 | ||
79 | #endif /* ZPROBE_H_ */ |