Initilize invert_probe in the constructor
[clinton/Smoothieware.git] / src / modules / tools / zprobe / ZProbe.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 ZPROBE_H_
9 #define ZPROBE_H_
10
11 #include "Module.h"
12 #include "Pin.h"
13
14 #include <vector>
15
16 // defined here as they are used in multiple files
17 #define zprobe_checksum CHECKSUM("zprobe")
18 #define leveling_strategy_checksum CHECKSUM("leveling-strategy")
19
20 class StepperMotor;
21 class Gcode;
22 class StreamOutput;
23 class LevelingStrategy;
24
25 class ZProbe: public Module
26 {
27
28 public:
29 ZProbe() : invert_override(false),invert_probe(false) {};
30 virtual ~ZProbe() {};
31
32 void on_module_loaded();
33 void on_gcode_received(void *argument);
34
35 bool run_probe(float& mm, float feedrate, float max_dist= -1, bool reverse= false);
36 bool run_probe_return(float& mm, float feedrate, float max_dist= -1, bool reverse= false);
37 bool doProbeAt(float &mm, float x, float y);
38
39 void coordinated_move(float x, float y, float z, float feedrate, bool relative=false);
40 void home();
41
42 bool getProbeStatus() { return this->pin.get(); }
43 float getSlowFeedrate() const { return slow_feedrate; }
44 float getFastFeedrate() const { return fast_feedrate; }
45 float getProbeHeight() const { return probe_height; }
46 float getMaxZ() const { return max_z; }
47
48 private:
49 void config_load();
50 void probe_XYZ(Gcode *gc, float x, float y, float z);
51 uint32_t read_probe(uint32_t dummy);
52
53 float slow_feedrate;
54 float fast_feedrate;
55 float return_feedrate;
56 float probe_height;
57 float max_z;
58 float dwell_before_probing;
59
60 Pin pin;
61 std::vector<LevelingStrategy*> strategies;
62 uint16_t debounce_ms, debounce;
63
64 volatile struct {
65 bool is_delta:1;
66 bool is_rdelta:1;
67 bool probing:1;
68 bool reverse_z:1;
69 bool invert_override:1;
70 bool invert_probe:1;
71 volatile bool probe_detected:1;
72 };
73 };
74
75 #endif /* ZPROBE_H_ */