Merge pull request #3744 from thinkyhead/rc_bezier_curves

Add BEZIER_CURVE_SUPPORT — G5 command
This commit is contained in:
Scott Lahteine
2016-05-17 13:57:38 -07:00
21 changed files with 362 additions and 34 deletions

View File

@@ -45,6 +45,10 @@
#include "mesh_bed_leveling.h"
#endif
#if ENABLED(BEZIER_CURVE_SUPPORT)
#include "planner_bezier.h"
#endif
#include "ultralcd.h"
#include "planner.h"
#include "stepper.h"
@@ -102,6 +106,7 @@
* G2 - CW ARC
* G3 - CCW ARC
* G4 - Dwell S<seconds> or P<milliseconds>
* G5 - Cubic B-spline with
* G10 - retract filament according to settings of M207
* G11 - retract recover filament according to settings of M208
* G28 - Home one or more axes
@@ -510,6 +515,10 @@ void process_next_command();
void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise);
#endif
#if ENABLED(BEZIER_CURVE_SUPPORT)
void plan_cubic_move(const float offset[4]);
#endif
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); }
@@ -2510,6 +2519,43 @@ inline void gcode_G4() {
while (PENDING(millis(), codenum)) idle();
}
#if ENABLED(BEZIER_CURVE_SUPPORT)
/**
* Parameters interpreted according to:
* http://linuxcnc.org/docs/2.6/html/gcode/gcode.html#sec:G5-Cubic-Spline
* However I, J omission is not supported at this point; all
* parameters can be omitted and default to zero.
*/
/**
* G5: Cubic B-spline
*/
inline void gcode_G5() {
if (IsRunning()) {
#ifdef SF_ARC_FIX
bool relative_mode_backup = relative_mode;
relative_mode = true;
#endif
gcode_get_destination();
#ifdef SF_ARC_FIX
relative_mode = relative_mode_backup;
#endif
float offset[] = {
code_seen('I') ? code_value() : 0.0,
code_seen('J') ? code_value() : 0.0,
code_seen('P') ? code_value() : 0.0,
code_seen('Q') ? code_value() : 0.0
};
plan_cubic_move(offset);
}
}
#endif // BEZIER_CURVE_SUPPORT
#if ENABLED(FWRETRACT)
/**
@@ -6498,10 +6544,12 @@ void process_next_command() {
// G2, G3
#if ENABLED(ARC_SUPPORT) && DISABLED(SCARA)
case 2: // G2 - CW ARC
case 3: // G3 - CCW ARC
gcode_G2_G3(codenum == 2);
break;
#endif
// G4 Dwell
@@ -6509,6 +6557,15 @@ void process_next_command() {
gcode_G4();
break;
#if ENABLED(BEZIER_CURVE_SUPPORT)
// G5
case 5: // G5 - Cubic B_spline
gcode_G5();
break;
#endif // BEZIER_CURVE_SUPPORT
#if ENABLED(FWRETRACT)
case 10: // G10: retract
@@ -6516,7 +6573,7 @@ void process_next_command() {
gcode_G10_G11(codenum == 10);
break;
#endif //FWRETRACT
#endif // FWRETRACT
case 28: // G28: Home all axes, one at a time
gcode_G28();
@@ -7588,6 +7645,19 @@ void prepare_move() {
}
#endif
#if ENABLED(BEZIER_CURVE_SUPPORT)
void plan_cubic_move(const float offset[4]) {
cubic_b_spline(current_position, destination, offset, feedrate * feedrate_multiplier / 60 / 100.0, active_extruder);
// As far as the parser is concerned, the position is now == target. In reality the
// motion control system might still be processing the action and the real tool position
// in any intermediate location.
set_current_to_destination();
}
#endif // BEZIER_CURVE_SUPPORT
#if HAS_CONTROLLERFAN
void controllerFan() {