fix homing, speeds and backoffs
[clinton/Smoothieware.git] / src / modules / tools / endstops / Endstops.h
index 844d3b0..c7f23d4 100644 (file)
@@ -5,13 +5,13 @@
       You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
 */
 
-#ifndef ENDSTOPS_MODULE_H
-#define ENDSTOPS_MODULE_H
+#pragma once
 
 #include "libs/Module.h"
 #include "libs/Pin.h"
 
 #include <bitset>
+#include <array>
 
 class StepperMotor;
 class Gcode;
@@ -21,30 +21,24 @@ class Endstops : public Module{
         Endstops();
         void on_module_loaded();
         void on_gcode_received(void* argument);
-        void on_config_reload(void* argument);
-        void acceleration_tick(void);
 
     private:
-        void home(char axes_to_move);
-        void do_homing_cartesian(char axes_to_move);
-        void do_homing_corexy(char axes_to_move);
-        bool wait_for_homed(char axes_to_move);
-        bool wait_for_homed_corexy(int axis);
-        void corexy_home(int home_axis, bool dirx, bool diry, float fast_rate, float slow_rate, unsigned int retract_steps);
-        void back_off_home(char axes_to_move);
-        void move_to_origin(char);
+        void load_config();
+        void home(std::bitset<3> a);
+        void back_off_home(std::bitset<3> axis);
+        void move_to_origin();
         void on_get_public_data(void* argument);
         void on_set_public_data(void* argument);
         void on_idle(void *argument);
         bool debounced_get(int pin);
         void process_home_command(Gcode* gcode);
+        void set_homing_offset(Gcode* gcode);
+        uint32_t read_endstops(uint32_t dummy);
 
         float homing_position[3];
         float home_offset[3];
-        uint8_t homing_order;
-        std::bitset<3> home_direction;
-        std::bitset<3> limit_enable;
         float saved_position[3]{0}; // save G28 (in grbl mode)
+        float alpha_max, beta_max, gamma_max;
 
         unsigned int  debounce_count;
         float  retract_mm[3];
@@ -52,16 +46,20 @@ class Endstops : public Module{
         float  fast_rates[3];
         float  slow_rates[3];
         Pin    pins[6];
-        volatile float feed_rate[3];
+        std::array<uint16_t, 3> debounce;
+
+        std::bitset<3> home_direction;
+        std::bitset<3> limit_enable;
+        std::bitset<3> axis_to_home;
+
         struct {
+            uint8_t homing_order:6;
+            uint8_t bounce_cnt:4;
+            volatile char status:3;
             bool is_corexy:1;
             bool is_delta:1;
             bool is_rdelta:1;
             bool is_scara:1;
             bool move_to_origin_after_home:1;
-            uint8_t bounce_cnt:4;
-            volatile char status:3;
         };
 };
-
-#endif