fix things that -std=gnu++0x was complaining about, whitespace changes
[clinton/Smoothieware.git] / src / libs / StepperMotor.cpp
index 4d82f71..8a93c9b 100644 (file)
@@ -18,6 +18,8 @@ StepperMotor::StepperMotor(){
     this->direction_bit = 0;
     this->remove_from_active_list_next_reset = false;
     this->is_move_finished = false;
+    this->signal_step = false;
+    this->step_signal_hook = new Hook(); 
 }
 
 StepperMotor::StepperMotor(Pin* step, Pin* dir, Pin* en) : step_pin(step), dir_pin(dir), en_pin(en) {
@@ -30,6 +32,8 @@ StepperMotor::StepperMotor(Pin* step, Pin* dir, Pin* en) : step_pin(step), dir_p
     this->direction_bit = 0;
     this->remove_from_active_list_next_reset = false;
     this->is_move_finished = false;
+    this->signal_step = false;
+    this->step_signal_hook = new Hook(); 
 }
 
 // Called a great many times per second, to step if we have to now
@@ -52,6 +56,11 @@ void StepperMotor::tick(){
         // we have moved a step 9t
         this->stepped++;
 
+        // Do we need to signal this step
+        if( this->stepped == this->signal_step_number && this->signal_step ){
+            this->step_signal_hook->call();
+        }
+
         // is this move finished ? 11t
         if( this->stepped == this->steps_to_move ){ 
             this->is_move_finished = true; 
@@ -106,6 +115,9 @@ void StepperMotor::move( bool direction, unsigned int steps ){
     this->fx_counter = 0;      // Bresenheim counter
     this->stepped = 0;
 
+    // Do not signal steps until we get instructed to
+    this->signal_step = false;
+
     // Starting now we are moving
     if( steps > 0 ){ 
         this->moving = true;