Merge remote-tracking branch 'upstream/edge' into upstream-master
[clinton/Smoothieware.git] / src / modules / tools / switch / Switch.cpp
index 3a15cfd..17455e4 100644 (file)
@@ -64,6 +64,7 @@ void Switch::on_halt(void *arg)
             case HWPWM: this->pwm_pin->write(0); break;
             case NONE: break;
         }
+        this->switch_state= this->failsafe;
     }
 }
 
@@ -302,15 +303,12 @@ void Switch::on_get_public_data(void *argument)
     if(!pdr->second_element_is(this->name_checksum)) return; // likely fan, but could be anything
 
     // ok this is targeted at us, so send back the requested data
-    // caller has provided the location to write the state
+    // caller has provided the location to write the state to
     struct pad_switch *pad= static_cast<struct pad_switch *>(pdr->get_data_ptr());
     pad->name = this->name_checksum;
     pad->state = this->switch_state;
     pad->value = this->switch_value;
-
-    pdr->set_data_ptr(&pad);
     pdr->set_taken();
-    pdr->clear_returned_data();
 }
 
 void Switch::on_set_public_data(void *argument)