revert to pre-actuator state
authorLogxen <logxen@hotmail.com>
Thu, 18 Jul 2013 19:10:41 +0000 (12:10 -0700)
committerLogxen <logxen@hotmail.com>
Thu, 18 Jul 2013 19:10:41 +0000 (12:10 -0700)
13 files changed:
src/libs/StepTicker.cpp
src/libs/StepTicker.h
src/libs/StepperMotor.cpp [moved from src/libs/actuators/StepperMotor.cpp with 93% similarity]
src/libs/StepperMotor.h [moved from src/libs/actuators/StepperMotor.h with 62% similarity]
src/libs/actuators/Actuator.h [deleted file]
src/modules/robot/Robot.cpp
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 9db2f5d..b003b80 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
-Actuator* StepTicker::add_stepper_motor(Actuator* stepper_motor){
+StepperMotor* StepTicker::add_stepper_motor(StepperMotor* 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(Actuator* motor)
+void StepTicker::add_motor_to_active_list(StepperMotor* motor)
 {
     uint32_t bm;
     int i;
@@ -250,7 +250,7 @@ void StepTicker::add_motor_to_active_list(Actuator* motor)
 }
 
 // Remove a stepper from the list of active motors
-void StepTicker::remove_motor_from_active_list(Actuator* motor)
+void StepTicker::remove_motor_from_active_list(StepperMotor* motor)
 {
     uint32_t bm; int i;
     for (i = 0, bm = 1; i < 12; i++, bm <<= 1)
index 06615f4..65d2d33 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/Actuator.h"
+#include "libs/StepperMotor.h"
 
 class StepTicker{
     public:
@@ -23,14 +23,14 @@ class StepTicker{
         void set_frequency( double frequency );
         void tick();
         void signal_moves_finished();
-        Actuator* add_stepper_motor(Actuator* stepper_motor);
+        StepperMotor* add_stepper_motor(StepperMotor* stepper_motor);
         void set_reset_delay( double seconds );
         void reset_tick();
-        void add_motor_to_active_list(Actuator* motor);
-        void remove_motor_from_active_list(Actuator* motor);
+        void add_motor_to_active_list(StepperMotor* motor);
+        void remove_motor_from_active_list(StepperMotor* motor);
 
         double frequency;
-        vector<Actuator*> stepper_motors;
+        vector<StepperMotor*> stepper_motors;
         uint32_t delay;
         uint32_t period;
         uint32_t debug;
@@ -40,7 +40,7 @@ class StepTicker{
         bool moves_finished;
         bool reset_step_pins;
 
-        Actuator* active_motors[12];
+        StepperMotor* active_motors[12];
         uint32_t active_motor_bm;
 
 };
similarity index 93%
rename from src/libs/actuators/StepperMotor.cpp
rename to src/libs/StepperMotor.cpp
index 2ebdc52..b06647c 100644 (file)
@@ -6,13 +6,25 @@
 */
 #include "mri.h"
 #include "libs/Kernel.h"
-#include "libs/actuators/StepperMotor.h"
-#include "libs/actuators/Actuator.h"
+#include "StepperMotor.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;
similarity index 62%
rename from src/libs/actuators/StepperMotor.h
rename to src/libs/StepperMotor.h
index 7bc225a..bdaf2fb 100644 (file)
 
 #include "libs/Kernel.h"
 #include "libs/Hook.h"
-#include "libs/actuators/Actuator.h"
 
 class StepTicker;
 
-class StepperMotor : public Actuator {
+class StepperMotor {
     public:
-        //StepperMotor();
+        StepperMotor();
         StepperMotor(Pin* step, Pin* dir, Pin* en);
-
         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();
+            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;
         Pin* en_pin;
 
+        double steps_per_second;
+
+        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
 };
 
diff --git a/src/libs/actuators/Actuator.h b/src/libs/actuators/Actuator.h
deleted file mode 100644 (file)
index 1d6a980..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-      This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
-      Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
-      Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-      You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef ACTUATOR_H
-#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(){};
-        virtual ~Actuator(){};
-
-        /* Functions all actuators must have are still to be defined, but here are a few bellow for a start */
-        virtual void tick()=0;
-        virtual void step()=0;
-        virtual void move( bool direction, unsigned int steps )=0;
-        virtual void signal_move_finished()=0;
-        virtual void set_speed( double speed )=0;
-        virtual void update_exit_tick()=0;
-        virtual void pause()=0;
-        virtual void unpause()=0;
-
-        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;
-
-        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
-
-
-};
-
-
-
-#endif
index 46b649e..0fee853 100644 (file)
@@ -15,7 +15,7 @@ using std::string;
 #include "Robot.h"
 #include "libs/nuts_bolts.h"
 #include "libs/Pin.h"
-#include "libs/actuators/StepperMotor.h"
+#include "libs/StepperMotor.h"
 #include "../communication/utils/Gcode.h"
 #include "PublicDataRequest.h"
 #include "arm_solutions/BaseSolution.h"
index 84e2e6d..8a1c060 100644 (file)
@@ -16,7 +16,7 @@ using std::string;
 #include "arm_solutions/BaseSolution.h"
 #include "Planner.h"
 #include "libs/Pin.h"
-#include "libs/actuators/Actuator.h"
+#include "libs/StepperMotor.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;
 
-        Actuator* alpha_stepper_motor;
-        Actuator* beta_stepper_motor;
-        Actuator* gamma_stepper_motor;
+        StepperMotor* alpha_stepper_motor;
+        StepperMotor* beta_stepper_motor;
+        StepperMotor* gamma_stepper_motor;
 
         double seconds_per_minute;                            // for realtime speed change
 };
index c1d99c7..15a2a03 100644 (file)
@@ -9,7 +9,6 @@
 #define STEPPER_H
 #include "libs/Module.h"
 #include "libs/Kernel.h"
-#include "libs/actuators/Actuator.h"
 #include "Planner.h"
 #include "Block.h"
 
@@ -73,7 +72,7 @@ class Stepper : public Module {
         bool enable_pins_status;
         Hook* acceleration_tick_hook;
 
-        Actuator* main_stepper;
+        StepperMotor* main_stepper;
 
 };
 
index a3980b2..8aea221 100644 (file)
@@ -12,7 +12,7 @@
 #include "Endstops.h"
 #include "libs/nuts_bolts.h"
 #include "libs/Pin.h"
-#include "libs/actuators/Actuator.h"
+#include "libs/StepperMotor.h"
 #include "wait_api.h" // mbed.h lib
 
 Endstops::Endstops(){
index c0dd944..9f95d70 100644 (file)
@@ -11,7 +11,7 @@
 #include "libs/Module.h"
 #include "libs/Kernel.h"
 #include "modules/communication/utils/Gcode.h"
-#include "libs/actuators/Actuator.h"
+#include "libs/StepperMotor.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);
 
-        Actuator* steppers[3];
+        StepperMotor* steppers[3];
         Pin           pins[6];
         double  slow_rates[3];
         double  fast_rates[3];
index e0c7324..67113fe 100644 (file)
@@ -10,7 +10,6 @@
 #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 8359e63..fd72488 100644 (file)
@@ -12,7 +12,6 @@
 
 #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")
@@ -75,7 +74,7 @@ class Extruder : public Module{
 
         bool paused;
 
-        Actuator* stepper_motor;
+        StepperMotor* stepper_motor;
 
 };
 
index 8a45737..aa0c721 100644 (file)
@@ -13,8 +13,7 @@
 #include "modules/robot/Conveyor.h"
 #include "libs/Kernel.h"
 #include "modules/communication/utils/Gcode.h"
-#include "libs/actuators/Actuator.h"
-
+#include "libs/StepperMotor.h"
 #include "libs/Pin.h"
 
 #define touchprobe_enable_checksum           CHECKSUM("touchprobe_enable")
@@ -32,7 +31,7 @@ class Touchprobe: public Module {
 
         FILE*          logfile;
         string         filename;
-        Actuator*  steppers[3];
+        StepperMotor*  steppers[3];
         Pin            pin;
         unsigned int   debounce_count;