}
} else if( ( gcode->m == this->set_m_code || gcode->m == this->set_and_wait_m_code ) && gcode->has_letter('S')) {
- // this only gets handled if it is not controlled by the tool manager or is active in the toolmanager
- this->active = true;
-
- // this is safe as old configs as well as single extruder configs the toolmanager will not be running so will return false
- // this will also ignore anything that the tool manager is not controlling and return false, otherwise it returns the active tool
- void *returned_data;
- bool ok = PublicData::get_value( tool_manager_checksum, is_active_tool_checksum, this->name_checksum, &returned_data );
- if (ok) {
- uint16_t active_tool_name = *static_cast<uint16_t *>(returned_data);
- this->active = (active_tool_name == this->name_checksum);
- }
-
- if(this->active) {
+ int tool = gcode->has_letter('T') ? gcode->get_value('T') : -1;
+ // default on when no T, for unmanaged tools (e.g. heatbed)
+ bool am_tool = (tool == -1) ? true : false;
+
+ if (tool == -1) {
+ // this is safe as old configs as well as single extruder configs the toolmanager will not be running so will return false
+ // this will also ignore anything that the tool manager is not controlling and return false, otherwise it returns the active tool
+ void *returned_data;
+ bool ok = PublicData::get_value( tool_manager_checksum, is_active_tool_checksum, this->name_checksum, &returned_data );
+ if (ok) {
+ uint16_t active_tool_name = *static_cast<uint16_t *>(returned_data);
+ am_tool = (active_tool_name == this->name_checksum);
+ }
+ } else {
+ // FIXME
+ // this is wrong because we can't get the names of any
+ // inactive tools to check that we are associated with
+ // one. Just assume one temperature control per
+ // tool...
+ am_tool = (tool == this->pool_index);
+ }
+
+ if(am_tool) {
// required so temp change happens in order
- THEKERNEL->conveyor->wait_for_idle();
+ // Allow set without wait to be processed immediately
+ if( gcode->m == this->set_and_wait_m_code ) {
+ THEKERNEL->conveyor->wait_for_idle();
+ }
float v = gcode->get_value('S');
{
Gcode *gcode = static_cast<Gcode*>(argument);
- if( gcode->has_letter('T') ) {
+ if( gcode->has_letter('T') && !gcode->has_m) {
int new_tool = gcode->get_value('T');
+ char buff[32]; // should be big enough for any status
+ int n = snprintf(buff, sizeof(buff), "T%d,T%d switching ", this->active_tool, new_tool);
+ gcode->txt_after_ok.append(buff, n);
if(new_tool >= (int)this->tools.size() || new_tool < 0) {
// invalid tool
char buf[32]; // should be big enough for any status