From 5aa9c41ab1aa128edf54d618047b323fb9176aec Mon Sep 17 00:00:00 2001 From: Erik van der Zalm Date: Fri, 24 Feb 2012 20:42:07 +0100 Subject: [PATCH] Changed comment mode for detection. Added M221 extuder multiply factor. --- Marlin/Marlin.pde | 27 +++++++++++++++++++-------- Marlin/planner.cpp | 8 +++++--- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 49753fb45..51829a496 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -98,7 +98,8 @@ // M204 - Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) im mm/sec^2 also sets minimum segment time in ms (B20000) to prevent buffer underruns and M20 minimum feedrate // M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk // M206 - set additional homeing offset -// M220 - set speed factor override percentage S:factor in percent +// M220 S- set speed factor override percentage +// M221 S- set extrude factor override percentage // M240 - Trigger a camera to take a photograph // M301 - Set PID parameters P I and D // M302 - Allow cold extrudes @@ -126,6 +127,8 @@ bool axis_relative_modes[] = AXIS_RELATIVE_MODES; volatile int feedmultiply=100; //100->1 200->2 int saved_feedmultiply; volatile bool feedmultiplychanged=false; +volatile int extrudemultiply=100; //100->1 200->2 +volatile bool extrudemultiplychanged=false; float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 }; float add_homeing[3]={0,0,0}; uint8_t active_extruder = 0; @@ -332,9 +335,13 @@ void get_command() serial_char = MYSERIAL.read(); if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1) ) { - if(!serial_count) return; //if empty line + if(!serial_count) { //if empty line + comment_mode = false; //for new command + return; + } cmdbuffer[bufindw][serial_count] = 0; //terminate string if(!comment_mode){ + comment_mode = false; //for new command fromsd[bufindw] = false; if(strstr(cmdbuffer[bufindw], "N") != NULL) { @@ -411,9 +418,7 @@ void get_command() } bufindw = (bufindw + 1)%BUFSIZE; buflen += 1; - } - comment_mode = false; //for new command serial_count = 0; //clear buffer } else @@ -447,10 +452,9 @@ void get_command() card.checkautostart(true); } - if(serial_char=='\n') - comment_mode = false; //for new command if(!serial_count) { + comment_mode = false; //for new command return; //if empty line } cmdbuffer[bufindw][serial_count] = 0; //terminate string @@ -459,6 +463,7 @@ void get_command() buflen += 1; bufindw = (bufindw + 1)%BUFSIZE; } + comment_mode = false; //for new command serial_count = 0; //clear buffer } else @@ -1100,8 +1105,14 @@ void process_commands() } } break; - - + case 221: // M221 S- set extrude factor override percentage + { + if(code_seen('S')) + { + extrudemultiply = code_value() ; + extrudemultiplychanged=true; + } + break; #ifdef PIDTEMP case 301: // M301 diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 468d9fcac..c4b998322 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -81,6 +81,8 @@ long position[4]; //rescaled from extern when axis_steps_per_unit are changed static float previous_speed[4]; // Speed of previous path line segment static float previous_nominal_speed; // Nominal speed of previous path line segment +extern volatile int extrudemultiply; // Sets extrude multiply factor (in percent) + #ifdef AUTOTEMP float autotemp_max=250; float autotemp_min=210; @@ -474,8 +476,6 @@ void plan_buffer_line(float &x, float &y, float &z, float &e, float feed_rate, u target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); - - #ifdef PREVENT_DANGEROUS_EXTRUDE if(target[E_AXIS]!=position[E_AXIS]) if(degHotend(active_extruder)steps_y = labs(target[Y_AXIS]-position[Y_AXIS]); block->steps_z = labs(target[Z_AXIS]-position[Z_AXIS]); block->steps_e = labs(target[E_AXIS]-position[E_AXIS]); + block->steps_e *= extrudemultiply; + block-?steps_e /= 100; block->step_event_count = max(block->steps_x, max(block->steps_y, max(block->steps_z, block->steps_e))); // Bail if this is a zero-length block @@ -531,7 +533,7 @@ void plan_buffer_line(float &x, float &y, float &z, float &e, float feed_rate, u delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS]; delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS]; delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS]; - delta_mm[E_AXIS] = (target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS]; + delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*extrudemultiply/100.0; if ( block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0 ) { block->millimeters = abs(delta_mm[E_AXIS]); } else {