diff --git a/dda.c b/dda.c index 435fcdb..d3d5e56 100644 --- a/dda.c +++ b/dda.c @@ -112,6 +112,8 @@ void dda_init(void) { startpoint.F = next_target.target.F = SEARCH_FEEDRATE_Z; if (startpoint.e_multiplier == 0) startpoint.e_multiplier = next_target.target.e_multiplier = 256; + if (startpoint.f_multiplier == 0) + startpoint.f_multiplier = next_target.target.f_multiplier = 256; } /*! Distribute a new startpoint to DDA's internal structures without any movement. @@ -177,6 +179,13 @@ void dda_create(DDA *dda, const TARGET *target) { dda->endpoint.axis[X], dda->endpoint.axis[Y], dda->endpoint.axis[Z], dda->endpoint.F); + // Apply feedrate multiplier. + if (dda->endpoint.f_multiplier != 256) { + dda->endpoint.F *= dda->endpoint.f_multiplier; + dda->endpoint.F += 128; + dda->endpoint.F /= 256; + } + #ifdef LOOKAHEAD // Set the start and stop speeds to zero for now = full stops between // moves. Also fallback if lookahead calculations fail to finish in time. diff --git a/dda.h b/dda.h index b4b2cdc..47e2907 100644 --- a/dda.h +++ b/dda.h @@ -42,6 +42,7 @@ typedef struct { uint32_t F; uint16_t e_multiplier; + uint16_t f_multiplier; uint8_t e_relative :1; ///< bool: e axis relative? Overrides all_relative } TARGET; diff --git a/gcode_process.c b/gcode_process.c index 1cb50be..21f8f1e 100644 --- a/gcode_process.c +++ b/gcode_process.c @@ -793,6 +793,14 @@ void process_gcode_command() { #endif break; + case 220: + //? --- M220: Set speed factor override percentage --- + if ( ! next_target.seen_S) + break; + // Scale 100% = 256 + next_target.target.f_multiplier = (next_target.S * 64 + 12) / 25; + break; + case 221: //? --- M221: Control the extruders flow --- if ( ! next_target.seen_S)