Browse Source

setTargetedHotend => get_target_extruder_from_command

pull/1/head
Scott Lahteine 9 years ago
parent
commit
39ee9c526b
  1. 59
      Marlin/Marlin_main.cpp

59
Marlin/Marlin_main.cpp

@ -496,8 +496,6 @@ void process_next_command();
void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise);
bool setTargetedHotend(int code);
void serial_echopair_P(const char* s_P, int v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
void serial_echopair_P(const char* s_P, long v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
void serial_echopair_P(const char* s_P, float v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
@ -1161,6 +1159,30 @@ bool code_seen(char code) {
return (seen_pointer != NULL); // Return TRUE if the code-letter was found
}
/**
* Set target_extruder from the T parameter or the active_extruder
*
* Returns TRUE if the target is invalid
*/
bool get_target_extruder_from_command(int code) {
if (code_seen('T')) {
short t = code_value_short();
if (t >= EXTRUDERS) {
SERIAL_ECHO_START;
SERIAL_CHAR('M');
SERIAL_ECHO(code);
SERIAL_ECHOPAIR(" " MSG_INVALID_EXTRUDER " ", t);
SERIAL_EOL;
return true;
}
target_extruder = t;
}
else
target_extruder = active_extruder;
return false;
}
#define DEFINE_PGM_READ_ANY(type, reader) \
static inline type pgm_read_any(const type *p) \
{ return pgm_read_##reader##_near(p); }
@ -4233,7 +4255,7 @@ inline void gcode_M77() {
* M104: Set hot end temperature
*/
inline void gcode_M104() {
if (setTargetedHotend(104)) return;
if (get_target_extruder_from_command(104)) return;
if (DEBUGGING(DRYRUN)) return;
if (code_seen('S')) {
@ -4341,7 +4363,7 @@ inline void gcode_M104() {
* M105: Read hot end and bed temperature
*/
inline void gcode_M105() {
if (setTargetedHotend(105)) return;
if (get_target_extruder_from_command(105)) return;
#if HAS_TEMP_HOTEND || HAS_TEMP_BED
SERIAL_PROTOCOLPGM(MSG_OK);
@ -4385,7 +4407,7 @@ inline void gcode_M105() {
*/
inline void gcode_M109() {
if (setTargetedHotend(109)) return;
if (get_target_extruder_from_command(109)) return;
if (DEBUGGING(DRYRUN)) return;
bool no_wait_for_cooling = code_seen('S');
@ -5052,7 +5074,7 @@ inline void gcode_M121() { enable_endstops_globally(false); }
*/
inline void gcode_M200() {
if (setTargetedHotend(200)) return;
if (get_target_extruder_from_command(200)) return;
if (code_seen('D')) {
float diameter = code_value();
@ -5304,7 +5326,7 @@ inline void gcode_M206() {
* Z<zoffset> - Available with DUAL_X_CARRIAGE
*/
inline void gcode_M218() {
if (setTargetedHotend(218)) return;
if (get_target_extruder_from_command(218)) return;
if (code_seen('X')) extruder_offset[X_AXIS][target_extruder] = code_value();
if (code_seen('Y')) extruder_offset[Y_AXIS][target_extruder] = code_value();
@ -5343,7 +5365,7 @@ inline void gcode_M220() {
inline void gcode_M221() {
if (code_seen('S')) {
int sval = code_value();
if (setTargetedHotend(221)) return;
if (get_target_extruder_from_command(221)) return;
extruder_multiplier[target_extruder] = sval;
}
}
@ -8006,27 +8028,6 @@ void Stop() {
}
}
/**
* Set target_extruder from the T parameter or the active_extruder
*
* Returns TRUE if the target is invalid
*/
bool setTargetedHotend(int code) {
target_extruder = active_extruder;
if (code_seen('T')) {
target_extruder = code_value_short();
if (target_extruder >= EXTRUDERS) {
SERIAL_ECHO_START;
SERIAL_CHAR('M');
SERIAL_ECHO(code);
SERIAL_ECHOPGM(" " MSG_INVALID_EXTRUDER " ");
SERIAL_ECHOLN((int)target_extruder);
return true;
}
}
return false;
}
float calculate_volumetric_multiplier(float diameter) {
if (!volumetric_enabled || diameter == 0) return 1.0;
float d2 = diameter * 0.5;

Loading…
Cancel
Save