M220: add support for feedrate override percentage.

Similar to M221 which sets a variable flow rate percentage, add
support for M220 which sets a percentage modifier for the
feedrate, F.

It seems a little disturbing that the flow rate modifies the next
G1 command and does not touch the buffered commands, but this
seems like the only reasonable thing to do since the M221 setting
could be embedded in the source gcode for some use cases.  Perhaps
an "immediate" setting using P1 could be considered later if
needed.
This commit is contained in:
Phil Hord 2016-07-01 15:37:16 -04:00 committed by Markus Hitter
parent 6679dd6562
commit 5f6371c53d
3 changed files with 18 additions and 0 deletions

9
dda.c
View File

@ -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.

1
dda.h
View File

@ -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;

View File

@ -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)