From 9b010e65eeee5479423d7356c74b3e338d89e6af Mon Sep 17 00:00:00 2001 From: wurstnase Date: Fri, 24 Jun 2016 20:04:24 +0200 Subject: [PATCH] Introduce M221 aka flow-control. Now it is possible to control the extruders flow. M221 S100 = 100% of the extruders steps M221 S90 = 90% of the extruders steps M221 is also used in other firmwares for this. Also a lot of hosts, like Octoprint and Pronterface using this M-Code for this behaviour. --- dda.c | 7 +++++++ dda.h | 1 + gcode_process.c | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/dda.c b/dda.c index ec16d12..0884263 100644 --- a/dda.c +++ b/dda.c @@ -110,6 +110,8 @@ void dda_init(void) { // set up default feedrate if (startpoint.F == 0) startpoint.F = next_target.target.F = SEARCH_FEEDRATE_Z; + if (startpoint.e_multiplier == 0) + startpoint.e_multiplier = next_target.target.e_multiplier = 100; } /*! Distribute a new startpoint to DDA's internal structures without any movement. @@ -216,6 +218,11 @@ void dda_create(DDA *dda, TARGET *target) { // type, but are subject to other special handling. steps[E] = um_to_steps(target->axis[E], E); + // Apply extrusion multiplier. + steps[E] *= target->e_multiplier; + steps[E] += 50; + steps[E] /= 100; + if ( ! target->e_relative) { int32_t delta_steps; diff --git a/dda.h b/dda.h index 10a5ea3..4eaef1a 100644 --- a/dda.h +++ b/dda.h @@ -41,6 +41,7 @@ typedef struct { axes_int32_t axis; uint32_t F; + uint8_t e_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 79493e9..b87f2d5 100644 --- a/gcode_process.c +++ b/gcode_process.c @@ -793,6 +793,13 @@ void process_gcode_command() { #endif break; + case 221: + //? --- M221: Control the extruders flow --- + if ( ! next_target.seen_S) + break; + next_target.target.e_multiplier = next_target.S; + break; + #ifdef DEBUG case 240: //? --- M240: echo off ---