Update Marlin/Marlin.pde
Added function 'setTargetedHotend' that turns into a function an operation repeated 3 times through the M-codes processing. This modification saves a few bytes that can be used to add support for new commands.
This commit is contained in:
		@@ -202,6 +202,7 @@ bool Stopped=false;
 | 
				
			|||||||
//===========================================================================
 | 
					//===========================================================================
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void get_arc_coordinates();
 | 
					void get_arc_coordinates();
 | 
				
			||||||
 | 
					bool setTargetedHotend(int code);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void serial_echopair_P(const char *s_P, float v)
 | 
					void serial_echopair_P(const char *s_P, float v)
 | 
				
			||||||
    { serialprintPGM(s_P); SERIAL_ECHO(v); }
 | 
					    { serialprintPGM(s_P); SERIAL_ECHO(v); }
 | 
				
			||||||
@@ -957,16 +958,9 @@ void process_commands()
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
     break;
 | 
					     break;
 | 
				
			||||||
    case 104: // M104
 | 
					    case 104: // M104
 | 
				
			||||||
      tmp_extruder = active_extruder;
 | 
					      if(setTargetedHotend(104)){
 | 
				
			||||||
      if(code_seen('T')) {
 | 
					 | 
				
			||||||
        tmp_extruder = code_value();
 | 
					 | 
				
			||||||
        if(tmp_extruder >= EXTRUDERS) {
 | 
					 | 
				
			||||||
          SERIAL_ECHO_START;
 | 
					 | 
				
			||||||
          SERIAL_ECHO(MSG_M104_INVALID_EXTRUDER);
 | 
					 | 
				
			||||||
          SERIAL_ECHOLN(tmp_extruder);
 | 
					 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
 | 
					      if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
 | 
				
			||||||
      setWatch();
 | 
					      setWatch();
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
@@ -974,16 +968,9 @@ void process_commands()
 | 
				
			|||||||
      if (code_seen('S')) setTargetBed(code_value());
 | 
					      if (code_seen('S')) setTargetBed(code_value());
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    case 105 : // M105
 | 
					    case 105 : // M105
 | 
				
			||||||
      tmp_extruder = active_extruder;
 | 
					      if(setTargetedHotend(105)){
 | 
				
			||||||
      if(code_seen('T')) {
 | 
					 | 
				
			||||||
        tmp_extruder = code_value();
 | 
					 | 
				
			||||||
        if(tmp_extruder >= EXTRUDERS) {
 | 
					 | 
				
			||||||
          SERIAL_ECHO_START;
 | 
					 | 
				
			||||||
          SERIAL_ECHO(MSG_M105_INVALID_EXTRUDER);
 | 
					 | 
				
			||||||
          SERIAL_ECHOLN(tmp_extruder);
 | 
					 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      #if (TEMP_0_PIN > -1)
 | 
					      #if (TEMP_0_PIN > -1)
 | 
				
			||||||
        SERIAL_PROTOCOLPGM("ok T:");
 | 
					        SERIAL_PROTOCOLPGM("ok T:");
 | 
				
			||||||
        SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1); 
 | 
					        SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1); 
 | 
				
			||||||
@@ -1008,16 +995,9 @@ void process_commands()
 | 
				
			|||||||
      break;
 | 
					      break;
 | 
				
			||||||
    case 109: 
 | 
					    case 109: 
 | 
				
			||||||
    {// M109 - Wait for extruder heater to reach target.
 | 
					    {// M109 - Wait for extruder heater to reach target.
 | 
				
			||||||
      tmp_extruder = active_extruder;
 | 
					      if(setTargetedHotend(109)){
 | 
				
			||||||
      if(code_seen('T')) {
 | 
					 | 
				
			||||||
        tmp_extruder = code_value();
 | 
					 | 
				
			||||||
        if(tmp_extruder >= EXTRUDERS) {
 | 
					 | 
				
			||||||
          SERIAL_ECHO_START;
 | 
					 | 
				
			||||||
          SERIAL_ECHO(MSG_M109_INVALID_EXTRUDER);
 | 
					 | 
				
			||||||
          SERIAL_ECHOLN(tmp_extruder);
 | 
					 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      LCD_MESSAGEPGM(MSG_HEATING);   
 | 
					      LCD_MESSAGEPGM(MSG_HEATING);   
 | 
				
			||||||
      #ifdef AUTOTEMP
 | 
					      #ifdef AUTOTEMP
 | 
				
			||||||
        autotemp_enabled=false;
 | 
					        autotemp_enabled=false;
 | 
				
			||||||
@@ -1829,4 +1809,28 @@ void setPwmFrequency(uint8_t pin, int val)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif //FAST_PWM_FAN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool setTargetedHotend(int code){
 | 
				
			||||||
 | 
					  tmp_extruder = active_extruder;
 | 
				
			||||||
 | 
					  if(code_seen('T')) {
 | 
				
			||||||
 | 
					    tmp_extruder = code_value();
 | 
				
			||||||
 | 
					    if(tmp_extruder >= EXTRUDERS) {
 | 
				
			||||||
 | 
					      SERIAL_ECHO_START;
 | 
				
			||||||
 | 
					      switch(code){
 | 
				
			||||||
 | 
					        case 104:
 | 
				
			||||||
 | 
					          SERIAL_ECHO(MSG_M104_INVALID_EXTRUDER);
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        case 105:
 | 
				
			||||||
 | 
					          SERIAL_ECHO(MSG_M105_INVALID_EXTRUDER);
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        case 109:
 | 
				
			||||||
 | 
					          SERIAL_ECHO(MSG_M109_INVALID_EXTRUDER);
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      SERIAL_ECHOLN(tmp_extruder);
 | 
				
			||||||
 | 
					      return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user