Better and correct fix for Kill hanging on E moving
[clinton/Smoothieware.git] / src / libs / StepperMotor.h
index a9747f1..17ec0eb 100644 (file)
@@ -16,15 +16,17 @@ class StepperMotor  : public Module {
         ~StepperMotor();
 
         // called from step ticker ISR
-        inline void step() { step_pin.set(1); current_position_steps += (direction?-1:1); }
+        inline bool step() { step_pin.set(1); current_position_steps += (direction?-1:1); return moving; }
         // called from unstep ISR
         inline void unstep() { step_pin.set(0); }
         // called from step ticker ISR
         inline void set_direction(bool f) { dir_pin.set(f); direction= f; }
 
-        inline void enable(bool state) { en_pin.set(!state); };
-        inline bool is_enabled() const { return !en_pin.get(); };
-        inline bool is_moving() const { return moving; };
+        void enable(bool state) { en_pin.set(!state); };
+        bool is_enabled() const { return !en_pin.get(); };
+        bool is_moving() const { return moving; };
+        void start_moving() { moving= true; }
+        void stop_moving() { moving= false; }
 
         void manual_step(bool dir);
 
@@ -34,18 +36,21 @@ class StepperMotor  : public Module {
         float get_steps_per_mm()  const { return steps_per_mm; }
         void change_steps_per_mm(float);
         void change_last_milestone(float);
+        void set_last_milestones(float, int32_t);
+        void update_last_milestones(float mm, int32_t steps);
         float get_last_milestone(void) const { return last_milestone_mm; }
+        int32_t get_last_milestone_steps(void) const { return last_milestone_steps; }
         float get_current_position(void) const { return (float)current_position_steps/steps_per_mm; }
         uint32_t get_current_step(void) const { return current_position_steps; }
         float get_max_rate(void) const { return max_rate; }
         void set_max_rate(float mr) { max_rate= mr; }
+        void set_acceleration(float a) { acceleration= a; }
+        float get_acceleration() const { return acceleration; }
+        bool is_selected() const { return selected; }
+        void set_selected(bool b) { selected= b; }
 
-        int  steps_to_target(float);
+        int32_t steps_to_target(float);
 
-        friend class StepTicker;
-        friend class Stepper;
-        friend class Planner;
-        friend class Robot;
 
     private:
         void on_halt(void *argument);
@@ -60,7 +65,7 @@ class StepperMotor  : public Module {
         float steps_per_second;
         float steps_per_mm;
         float max_rate; // this is not really rate it is in mm/sec, misnamed used in Robot and Extruder
-        static float default_minimum_actuator_rate;
+        float acceleration;
 
         volatile int32_t current_position_steps;
         int32_t last_milestone_steps;
@@ -69,6 +74,7 @@ class StepperMotor  : public Module {
         volatile struct {
             volatile bool direction:1;
             volatile bool moving:1;
+            bool selected:1;
         };
 };