moving all modules to use Actuator instead of StepperMotor ( but still instantiate...
authorArthur Wolf <wolf.arthur@gmail.com>
Sat, 6 Jul 2013 15:24:55 +0000 (17:24 +0200)
committerArthur Wolf <wolf.arthur@gmail.com>
Sat, 6 Jul 2013 15:24:55 +0000 (17:24 +0200)
src/libs/StepTicker.cpp
src/libs/StepTicker.h
src/libs/actuators/Actuator.h
src/libs/actuators/StepperMotor.h
src/modules/robot/Robot.h
src/modules/robot/Stepper.h
src/modules/tools/endstops/Endstops.cpp
src/modules/tools/endstops/Endstops.h
src/modules/tools/extruder/Extruder.cpp
src/modules/tools/extruder/Extruder.h
src/modules/tools/touchprobe/Touchprobe.h

index b003b80..9db2f5d 100644 (file)
@@ -71,7 +71,7 @@ void StepTicker::set_reset_delay( double seconds ){
 }
 
 // Add a stepper motor object to our list of steppers we must take care of
-StepperMotor* StepTicker::add_stepper_motor(StepperMotor* stepper_motor){
+Actuator* StepTicker::add_stepper_motor(Actuator* stepper_motor){
     this->stepper_motors.push_back(stepper_motor);
     stepper_motor->step_ticker = this;
     this->has_axes = true;
@@ -222,7 +222,7 @@ extern "C" void TIMER0_IRQHandler (void){
 
 
 // We make a list of steppers that want to be called so that we don't call them for nothing
-void StepTicker::add_motor_to_active_list(StepperMotor* motor)
+void StepTicker::add_motor_to_active_list(Actuator* motor)
 {
     uint32_t bm;
     int i;
@@ -250,7 +250,7 @@ void StepTicker::add_motor_to_active_list(StepperMotor* motor)
 }
 
 // Remove a stepper from the list of active motors
-void StepTicker::remove_motor_from_active_list(StepperMotor* motor)
+void StepTicker::remove_motor_from_active_list(Actuator* motor)
 {
     uint32_t bm; int i;
     for (i = 0, bm = 1; i < 12; i++, bm <<= 1)
index ffc3993..06615f4 100644 (file)
@@ -15,7 +15,7 @@ using namespace std;
 #include "libs/nuts_bolts.h"
 #include "libs/Module.h"
 #include "libs/Kernel.h"
-#include "libs/actuators/StepperMotor.h"
+#include "libs/actuators/Actuator.h"
 
 class StepTicker{
     public:
@@ -23,14 +23,14 @@ class StepTicker{
         void set_frequency( double frequency );
         void tick();
         void signal_moves_finished();
-        StepperMotor* add_stepper_motor(StepperMotor* stepper_motor);
+        Actuator* add_stepper_motor(Actuator* stepper_motor);
         void set_reset_delay( double seconds );
         void reset_tick();
-        void add_motor_to_active_list(StepperMotor* motor);
-        void remove_motor_from_active_list(StepperMotor* motor);
+        void add_motor_to_active_list(Actuator* motor);
+        void remove_motor_from_active_list(Actuator* motor);
 
         double frequency;
-        vector<StepperMotor*> stepper_motors;
+        vector<Actuator*> stepper_motors;
         uint32_t delay;
         uint32_t period;
         uint32_t debug;
@@ -40,7 +40,7 @@ class StepTicker{
         bool moves_finished;
         bool reset_step_pins;
 
-        StepperMotor* active_motors[12];
+        Actuator* active_motors[12];
         uint32_t active_motor_bm;
 
 };
index 69a758b..b202c3b 100644 (file)
@@ -9,23 +9,26 @@
 #define ACTUATOR_H
 
 #include "libs/Hook.h"
+#include "libs/StepTicker.h"
 
 /* Actuator is the base class for all actuator-type things ( StepperMotors, ServoMotors etc ). */
 
+class StepTicker;
+
 class Actuator {
     public:
         Actuator(){};
 
         /* Functions all actuators must have are still to be defined, but here are a few bellow for a start */
-        void tick();
-        void step();
-        void move_finished();
-        void move( bool direction, unsigned int steps );
-        void signal_move_finished();
-        void set_speed( double speed );
-        void update_exit_tick();
-        void pause();
-        void unpause();
+        void tick(){};
+        void step(){};
+        void move_finished(){};
+        void move( bool direction, unsigned int steps ){};
+        void signal_move_finished(){};
+        void set_speed( double speed ){};
+        void update_exit_tick(){};
+        void pause(){};
+        void unpause(){};
 
         template<typename t> void attach( t *optr, uint32_t ( t::*fptr )( uint32_t ) ){
             Hook* hook = new Hook();
@@ -45,7 +48,26 @@ class Actuator {
         bool signal_step;
         uint32_t signal_step_number;
 
+        double steps_per_second;
+
+        volatile bool moving;
+        bool paused;
+
+        uint32_t steps_to_move;
+        StepTicker* step_ticker;
+        Pin* step_pin;
+        Pin* dir_pin;
+        Pin* en_pin;
+
+
+       uint32_t stepped;
+        uint32_t fx_counter;
+        uint32_t fx_ticks_per_step;
+
+        bool remove_from_active_list_next_reset;
 
+        bool is_move_finished; // Whether the move just finished
 
 
 };
index ec3c61f..57f1b44 100644 (file)
@@ -28,25 +28,12 @@ class StepperMotor : public Actuator {
         void update_exit_tick();
         void pause();
         void unpause();
-
-
         StepTicker* step_ticker;
         Pin* step_pin;
         Pin* dir_pin;
         Pin* en_pin;
 
-        double steps_per_second;
-
-        volatile bool moving;
-        bool paused;
-
-        uint32_t steps_to_move;
-        uint32_t stepped;
-        uint32_t fx_counter;
-        uint32_t fx_ticks_per_step;
-
-        bool remove_from_active_list_next_reset;
-
         bool is_move_finished; // Whether the move just finished
 };
 
index 0b99c22..84e2e6d 100644 (file)
@@ -16,7 +16,7 @@ using std::string;
 #include "arm_solutions/BaseSolution.h"
 #include "Planner.h"
 #include "libs/Pin.h"
-#include "libs/actuators/StepperMotor.h"
+#include "libs/actuators/Actuator.h"
 #include "RobotPublicAccess.h"
 
 #define default_seek_rate_checksum             CHECKSUM("default_seek_rate")
@@ -120,9 +120,9 @@ class Robot : public Module {
         Pin gamma_dir_pin;
         Pin gamma_en_pin;
 
-        StepperMotor* alpha_stepper_motor;
-        StepperMotor* beta_stepper_motor;
-        StepperMotor* gamma_stepper_motor;
+        Actuator* alpha_stepper_motor;
+        Actuator* beta_stepper_motor;
+        Actuator* gamma_stepper_motor;
 
         double seconds_per_minute;                            // for realtime speed change
 };
index 15a2a03..c1d99c7 100644 (file)
@@ -9,6 +9,7 @@
 #define STEPPER_H
 #include "libs/Module.h"
 #include "libs/Kernel.h"
+#include "libs/actuators/Actuator.h"
 #include "Planner.h"
 #include "Block.h"
 
@@ -72,7 +73,7 @@ class Stepper : public Module {
         bool enable_pins_status;
         Hook* acceleration_tick_hook;
 
-        StepperMotor* main_stepper;
+        Actuator* main_stepper;
 
 };
 
index 855683f..a3980b2 100644 (file)
@@ -12,7 +12,7 @@
 #include "Endstops.h"
 #include "libs/nuts_bolts.h"
 #include "libs/Pin.h"
-#include "libs/actuators/StepperMotor.h"
+#include "libs/actuators/Actuator.h"
 #include "wait_api.h" // mbed.h lib
 
 Endstops::Endstops(){
index 1eef705..c0dd944 100644 (file)
@@ -11,7 +11,7 @@
 #include "libs/Module.h"
 #include "libs/Kernel.h"
 #include "modules/communication/utils/Gcode.h"
-#include "libs/actuators/StepperMotor.h"
+#include "libs/actuators/Actuator.h"
 #include "libs/Pin.h"
 
 #define ALPHA_AXIS 0
@@ -70,7 +70,7 @@ class Endstops : public Module{
         void on_gcode_received(void* argument);
         void on_config_reload(void* argument);
 
-        StepperMotor* steppers[3];
+        Actuator* steppers[3];
         Pin           pins[6];
         double  slow_rates[3];
         double  fast_rates[3];
index 67113fe..e0c7324 100644 (file)
@@ -10,6 +10,7 @@
 #include "modules/robot/Conveyor.h"
 #include "modules/robot/Block.h"
 #include "modules/tools/extruder/Extruder.h"
+#include "libs/actuators/StepperMotor.h"
 #include <mri.h>
 
 /* The extruder module controls a filament extruder for 3D printing: http://en.wikipedia.org/wiki/Fused_deposition_modeling
index fd72488..8359e63 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "libs/Module.h"
 #include "libs/Kernel.h"
+#include "libs/actuators/Actuator.h"
 #include "modules/robot/Block.h"
 
 #define microseconds_per_step_pulse_checksum CHECKSUM("microseconds_per_step_pulse")
@@ -74,7 +75,7 @@ class Extruder : public Module{
 
         bool paused;
 
-        StepperMotor* stepper_motor;
+        Actuator* stepper_motor;
 
 };
 
index 313b77f..8a45737 100644 (file)
@@ -13,7 +13,7 @@
 #include "modules/robot/Conveyor.h"
 #include "libs/Kernel.h"
 #include "modules/communication/utils/Gcode.h"
-#include "libs/actuators/StepperMotor.h"
+#include "libs/actuators/Actuator.h"
 
 #include "libs/Pin.h"
 
@@ -32,7 +32,7 @@ class Touchprobe: public Module {
 
         FILE*          logfile;
         string         filename;
-        StepperMotor*  steppers[3];
+        Actuator*  steppers[3];
         Pin            pin;
         unsigned int   debounce_count;