*/
#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;
#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();
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;
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