Stepper: pick up M84 (disable steppers)
authorMichael Moon <triffid.hunter@gmail.com>
Sat, 28 Apr 2012 15:26:04 +0000 (01:26 +1000)
committerMichael Moon <triffid.hunter@gmail.com>
Sat, 28 Apr 2012 15:26:30 +0000 (01:26 +1000)
src/modules/robot/Stepper.cpp

index 3f3d2a0..adac0a2 100644 (file)
@@ -28,6 +28,7 @@ void Stepper::on_module_loaded(){
     stepper = this;
     this->register_for_event(ON_BLOCK_BEGIN);
     this->register_for_event(ON_BLOCK_END);
+    this->register_for_event(ON_GCODE_EXECUTE);
     this->register_for_event(ON_PLAY);
     this->register_for_event(ON_PAUSE);
  
@@ -84,6 +85,19 @@ void Stepper::on_play(void* argument){
     this->paused = false;
 }
 
+void Stepper::on_gcode_execute(void* argument){
+    Gcode* gcode = static_cast<Gcode*>(argument);
+
+    if( gcode->has_letter('M')){
+        int code = (int) gcode->get_value('M');
+        if( code == 84 ){
+            this->alpha_en_pin->set(0);
+            this->beta_en_pin->set(0);
+            this->gamma_en_pin->set(0);
+        }
+    }
+}
+
 // A new block is popped from the queue
 void Stepper::on_block_begin(void* argument){
     Block* block  = static_cast<Block*>(argument);