Robot: static Pins
authorMichael Moon <triffid.hunter@gmail.com>
Sat, 9 Feb 2013 13:44:05 +0000 (00:44 +1100)
committerMichael Moon <triffid.hunter@gmail.com>
Sat, 9 Feb 2013 13:44:05 +0000 (00:44 +1100)
src/modules/robot/Robot.cpp
src/modules/robot/Robot.h
src/modules/robot/Stepper.cpp

index 48bf866..b579124 100644 (file)
@@ -40,9 +40,9 @@ void Robot::on_module_loaded() {
     this->on_config_reload(this);
 
     // Make our 3 StepperMotors
-    this->alpha_stepper_motor  = this->kernel->step_ticker->add_stepper_motor( new StepperMotor(this->alpha_step_pin,this->alpha_dir_pin,this->alpha_en_pin) );
-    this->beta_stepper_motor   = this->kernel->step_ticker->add_stepper_motor( new StepperMotor(this->beta_step_pin, this->beta_dir_pin, this->beta_en_pin ) );
-    this->gamma_stepper_motor  = this->kernel->step_ticker->add_stepper_motor( new StepperMotor(this->gamma_step_pin,this->gamma_dir_pin,this->gamma_en_pin) );
+    this->alpha_stepper_motor  = this->kernel->step_ticker->add_stepper_motor( new StepperMotor(&alpha_step_pin,&alpha_dir_pin,&alpha_en_pin) );
+    this->beta_stepper_motor   = this->kernel->step_ticker->add_stepper_motor( new StepperMotor(&beta_step_pin, &beta_dir_pin, &beta_en_pin ) );
+    this->gamma_stepper_motor  = this->kernel->step_ticker->add_stepper_motor( new StepperMotor(&gamma_step_pin,&gamma_dir_pin,&gamma_en_pin) );
 
 }
 
@@ -58,15 +58,15 @@ void Robot::on_config_reload(void* argument){
     this->max_speeds[X_AXIS]  = this->kernel->config->value(x_axis_max_speed_checksum    )->by_default(60000  )->as_number();
     this->max_speeds[Y_AXIS]  = this->kernel->config->value(y_axis_max_speed_checksum    )->by_default(60000  )->as_number();
     this->max_speeds[Z_AXIS]  = this->kernel->config->value(z_axis_max_speed_checksum    )->by_default(300    )->as_number();
-    this->alpha_step_pin      = this->kernel->config->value(alpha_step_pin_checksum      )->by_default("2.0"  )->as_pin()->as_output();
-    this->beta_step_pin       = this->kernel->config->value(beta_step_pin_checksum       )->by_default("2.1"  )->as_pin()->as_output();
-    this->gamma_step_pin      = this->kernel->config->value(gamma_step_pin_checksum      )->by_default("2.2"  )->as_pin()->as_output();
-    this->alpha_dir_pin       = this->kernel->config->value(alpha_dir_pin_checksum       )->by_default("0.5"  )->as_pin()->as_output();
-    this->beta_dir_pin        = this->kernel->config->value(beta_dir_pin_checksum        )->by_default("0.11" )->as_pin()->as_output();
-    this->gamma_dir_pin       = this->kernel->config->value(gamma_dir_pin_checksum       )->by_default("0.20" )->as_pin()->as_output();
-    this->alpha_en_pin        = this->kernel->config->value(alpha_en_pin_checksum        )->by_default("0.4"  )->as_pin()->as_output()->as_open_drain();
-    this->beta_en_pin         = this->kernel->config->value(beta_en_pin_checksum         )->by_default("0.10" )->as_pin()->as_output()->as_open_drain();
-    this->gamma_en_pin        = this->kernel->config->value(gamma_en_pin_checksum        )->by_default("0.19" )->as_pin()->as_output()->as_open_drain();
+    this->alpha_step_pin.from_string( this->kernel->config->value(alpha_step_pin_checksum )->by_default("2.0"  )->as_string())->as_output();
+    this->alpha_dir_pin.from_string(  this->kernel->config->value(alpha_dir_pin_checksum  )->by_default("0.5"  )->as_string())->as_output();
+    this->alpha_en_pin.from_string(   this->kernel->config->value(alpha_en_pin_checksum   )->by_default("0.4"  )->as_string())->as_output()->as_open_drain();
+    this->beta_step_pin.from_string(  this->kernel->config->value(beta_step_pin_checksum  )->by_default("2.1"  )->as_string())->as_output();
+    this->gamma_step_pin.from_string( this->kernel->config->value(gamma_step_pin_checksum )->by_default("2.2"  )->as_string())->as_output();
+    this->gamma_dir_pin.from_string(  this->kernel->config->value(gamma_dir_pin_checksum  )->by_default("0.20" )->as_string())->as_output();
+    this->gamma_en_pin.from_string(   this->kernel->config->value(gamma_en_pin_checksum   )->by_default("0.19" )->as_string())->as_output()->as_open_drain();
+    this->beta_dir_pin.from_string(   this->kernel->config->value(beta_dir_pin_checksum   )->by_default("0.11" )->as_string())->as_output();
+    this->beta_en_pin.from_string(    this->kernel->config->value(beta_en_pin_checksum    )->by_default("0.10" )->as_string())->as_output()->as_open_drain();
 
 }
 
index 2172922..2f86af5 100644 (file)
@@ -93,15 +93,15 @@ class Robot : public Module {
 
     // Used by Stepper
     public:
-        Pin* alpha_step_pin;
-        Pin* beta_step_pin;
-        Pin* gamma_step_pin;
-        Pin* alpha_dir_pin;
-        Pin* beta_dir_pin;
-        Pin* gamma_dir_pin;
-        Pin* alpha_en_pin;
-        Pin* beta_en_pin;
-        Pin* gamma_en_pin;
+        Pin alpha_step_pin;
+        Pin alpha_dir_pin;
+        Pin alpha_en_pin;
+        Pin beta_step_pin;
+        Pin beta_dir_pin;
+        Pin beta_en_pin;
+        Pin gamma_step_pin;
+        Pin gamma_dir_pin;
+        Pin gamma_en_pin;
 
         StepperMotor* alpha_stepper_motor;
         StepperMotor* beta_stepper_motor;
index aaa3f92..56176b7 100644 (file)
@@ -95,16 +95,16 @@ void Stepper::on_gcode_execute(void* argument){
 }
 
 void Stepper::turn_enable_pins_on(){
-    this->kernel->robot->alpha_en_pin->set(0);
-    this->kernel->robot->beta_en_pin->set(0);
-    this->kernel->robot->gamma_en_pin->set(0);
+    this->kernel->robot->alpha_en_pin.set(0);
+    this->kernel->robot->beta_en_pin.set(0);
+    this->kernel->robot->gamma_en_pin.set(0);
     this->enable_pins_status = true;
 }
 
 void Stepper::turn_enable_pins_off(){
-    this->kernel->robot->alpha_en_pin->set(1);
-    this->kernel->robot->beta_en_pin->set(1);
-    this->kernel->robot->gamma_en_pin->set(1);
+    this->kernel->robot->alpha_en_pin.set(1);
+    this->kernel->robot->beta_en_pin.set(1);
+    this->kernel->robot->gamma_en_pin.set(1);
     this->enable_pins_status = false;
 }