Stepticker now inherits Actuator
authorArthur Wolf <wolf.arthur@gmail.com>
Sat, 6 Jul 2013 13:10:54 +0000 (15:10 +0200)
committerArthur Wolf <wolf.arthur@gmail.com>
Sat, 6 Jul 2013 13:10:54 +0000 (15:10 +0200)
src/libs/actuators/StepperMotor.cpp
src/libs/actuators/StepperMotor.h

index b06647c..2ebdc52 100644 (file)
@@ -6,25 +6,13 @@
 */
 #include "mri.h"
 #include "libs/Kernel.h"
-#include "StepperMotor.h"
+#include "libs/actuators/StepperMotor.h"
+#include "libs/actuators/Actuator.h"
 #include "MRI_Hooks.h"
 
 // A StepperMotor represents an actual stepper motor. It is used to generate steps that move the actual motor at a given speed
 // TODO : Abstract this into Actuator
 
-StepperMotor::StepperMotor(){
-    this->moving = false;
-    this->paused = false;
-    this->fx_counter = 0;
-    this->stepped = 0;
-    this->fx_ticks_per_step = 0;
-    this->steps_to_move = 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) {
     this->moving = false;
     this->paused = false;
index bdaf2fb..ec3c61f 100644 (file)
 
 #include "libs/Kernel.h"
 #include "libs/Hook.h"
+#include "libs/actuators/Actuator.h"
 
 class StepTicker;
 
-class StepperMotor {
+class StepperMotor : public Actuator {
     public:
-        StepperMotor();
+        //StepperMotor();
         StepperMotor(Pin* step, Pin* dir, Pin* en);
+
         void tick();
         void step();
         void move_finished();
@@ -28,25 +30,6 @@ class StepperMotor {
         void unpause();
 
 
-
-        template<typename T> void attach( T *optr, uint32_t ( T::*fptr )( uint32_t ) ){
-            Hook* hook = new Hook();
-            hook->attach(optr, fptr);
-            this->end_hook = hook;
-        }
-
-        template<typename T> void attach_signal_step(uint32_t step, T *optr, uint32_t ( T::*fptr )( uint32_t ) ){
-            this->step_signal_hook->attach(optr, fptr);
-            this->signal_step_number = step;
-            this->signal_step = true;
-        }
-
-        Hook* end_hook;
-        Hook* step_signal_hook;
-
-        bool signal_step;
-        uint32_t signal_step_number;
-
         StepTicker* step_ticker;
         Pin* step_pin;
         Pin* dir_pin;
@@ -57,15 +40,11 @@ class StepperMotor {
         volatile bool moving;
         bool paused;
 
-        //bool direction_bit;
-        //bool step_bit;
-
         uint32_t steps_to_move;
         uint32_t stepped;
         uint32_t fx_counter;
         uint32_t fx_ticks_per_step;
 
-        //bool exit_tick;
         bool remove_from_active_list_next_reset;
 
         bool is_move_finished; // Whether the move just finished