|
@@ -458,7 +458,7 @@ volatile bool wait_for_heatup = true;
|
458
|
458
|
volatile bool wait_for_user = false;
|
459
|
459
|
#endif
|
460
|
460
|
|
461
|
|
-const char axis_codes[XYZE] = {'X', 'Y', 'Z', 'E'};
|
|
461
|
+const char axis_codes[XYZE] = { 'X', 'Y', 'Z', 'E' };
|
462
|
462
|
|
463
|
463
|
// Number of characters read in the current line of serial input
|
464
|
464
|
static int serial_count = 0;
|
|
@@ -1394,7 +1394,7 @@ bool get_target_extruder_from_command(int code) {
|
1394
|
1394
|
*
|
1395
|
1395
|
* Callers must sync the planner position after calling this!
|
1396
|
1396
|
*/
|
1397
|
|
-static void set_axis_is_at_home(AxisEnum axis) {
|
|
1397
|
+static void set_axis_is_at_home(const AxisEnum axis) {
|
1398
|
1398
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
1399
|
1399
|
if (DEBUGGING(LEVELING)) {
|
1400
|
1400
|
SERIAL_ECHOPAIR(">>> set_axis_is_at_home(", axis_codes[axis]);
|
|
@@ -1496,7 +1496,7 @@ static void set_axis_is_at_home(AxisEnum axis) {
|
1496
|
1496
|
/**
|
1497
|
1497
|
* Some planner shorthand inline functions
|
1498
|
1498
|
*/
|
1499
|
|
-inline float get_homing_bump_feedrate(AxisEnum axis) {
|
|
1499
|
+inline float get_homing_bump_feedrate(const AxisEnum axis) {
|
1500
|
1500
|
int constexpr homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
|
1501
|
1501
|
int hbd = homing_bump_divisor[axis];
|
1502
|
1502
|
if (hbd < 1) {
|
|
@@ -1507,20 +1507,19 @@ inline float get_homing_bump_feedrate(AxisEnum axis) {
|
1507
|
1507
|
return homing_feedrate_mm_s[axis] / hbd;
|
1508
|
1508
|
}
|
1509
|
1509
|
|
1510
|
|
-//
|
1511
|
|
-// line_to_current_position
|
1512
|
|
-// Move the planner to the current position from wherever it last moved
|
1513
|
|
-// (or from wherever it has been told it is located).
|
1514
|
|
-//
|
|
1510
|
+/**
|
|
1511
|
+ * Move the planner to the current position from wherever it last moved
|
|
1512
|
+ * (or from wherever it has been told it is located).
|
|
1513
|
+ */
|
1515
|
1514
|
inline void line_to_current_position() {
|
1516
|
1515
|
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate_mm_s, active_extruder);
|
1517
|
1516
|
}
|
1518
|
1517
|
|
1519
|
|
-//
|
1520
|
|
-// line_to_destination
|
1521
|
|
-// Move the planner, not necessarily synced with current_position
|
1522
|
|
-//
|
1523
|
|
-inline void line_to_destination(float fr_mm_s) {
|
|
1518
|
+/**
|
|
1519
|
+ * Move the planner to the position stored in the destination array, which is
|
|
1520
|
+ * used by G0/G1/G2/G3/G5 and many other functions to set a destination.
|
|
1521
|
+ */
|
|
1522
|
+inline void line_to_destination(const float fr_mm_s) {
|
1524
|
1523
|
planner.buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], fr_mm_s, active_extruder);
|
1525
|
1524
|
}
|
1526
|
1525
|
inline void line_to_destination() { line_to_destination(feedrate_mm_s); }
|
|
@@ -2751,7 +2750,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
2751
|
2750
|
/**
|
2752
|
2751
|
* Home an individual linear axis
|
2753
|
2752
|
*/
|
2754
|
|
-static void do_homing_move(const AxisEnum axis, float distance, float fr_mm_s=0.0) {
|
|
2753
|
+static void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm_s=0.0) {
|
2755
|
2754
|
|
2756
|
2755
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2757
|
2756
|
if (DEBUGGING(LEVELING)) {
|
|
@@ -4907,7 +4906,7 @@ void home_all_axes() { gcode_G28(true); }
|
4907
|
4906
|
if ( NEAR(current_position[X_AXIS], xProbe - (X_PROBE_OFFSET_FROM_EXTRUDER))
|
4908
|
4907
|
&& NEAR(current_position[Y_AXIS], yProbe - (Y_PROBE_OFFSET_FROM_EXTRUDER))
|
4909
|
4908
|
) {
|
4910
|
|
- float simple_z = current_position[Z_AXIS] - measured_z;
|
|
4909
|
+ const float simple_z = current_position[Z_AXIS] - measured_z;
|
4911
|
4910
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
4912
|
4911
|
if (DEBUGGING(LEVELING)) {
|
4913
|
4912
|
SERIAL_ECHOPAIR("Z from Probe:", simple_z);
|
|
@@ -7667,45 +7666,32 @@ void report_current_position() {
|
7667
|
7666
|
|
7668
|
7667
|
#ifdef M114_DETAIL
|
7669
|
7668
|
|
7670
|
|
- static const char axis_char[XYZE] = {'X','Y','Z','E'};
|
7671
|
|
-
|
7672
|
|
- void report_xyze(const float pos[XYZE], uint8_t n = 4, uint8_t precision = 3) {
|
|
7669
|
+ void report_xyze(const float pos[XYZE], const uint8_t n = 4, const uint8_t precision = 3) {
|
7673
|
7670
|
char str[12];
|
7674
|
|
- for(uint8_t i=0; i<n; i++) {
|
|
7671
|
+ for (uint8_t i = 0; i < n; i++) {
|
7675
|
7672
|
SERIAL_CHAR(' ');
|
7676
|
|
- SERIAL_CHAR(axis_char[i]);
|
|
7673
|
+ SERIAL_CHAR(axis_codes[i]);
|
7677
|
7674
|
SERIAL_CHAR(':');
|
7678
|
|
- SERIAL_PROTOCOL(dtostrf(pos[i],8,precision,str));
|
|
7675
|
+ SERIAL_PROTOCOL(dtostrf(pos[i], 8, precision, str));
|
7679
|
7676
|
}
|
7680
|
7677
|
SERIAL_EOL;
|
7681
|
7678
|
}
|
7682
|
7679
|
|
7683
|
|
- inline void report_xyz(const float pos[XYZ]) {
|
7684
|
|
- report_xyze(pos,3);
|
7685
|
|
- }
|
|
7680
|
+ inline void report_xyz(const float pos[XYZ]) { report_xyze(pos, 3); }
|
7686
|
7681
|
|
7687
|
7682
|
void report_current_position_detail() {
|
7688
|
7683
|
|
7689
|
7684
|
stepper.synchronize();
|
7690
|
7685
|
|
7691
|
|
- SERIAL_EOL;
|
7692
|
|
- SERIAL_PROTOCOLPGM("Logical:");
|
|
7686
|
+ SERIAL_PROTOCOLPGM("\nLogical:");
|
7693
|
7687
|
report_xyze(current_position);
|
7694
|
7688
|
|
7695
|
7689
|
SERIAL_PROTOCOLPGM("Raw: ");
|
7696
|
|
- const float raw[XYZ] = {
|
7697
|
|
- RAW_X_POSITION(current_position[X_AXIS]),
|
7698
|
|
- RAW_Y_POSITION(current_position[Y_AXIS]),
|
7699
|
|
- RAW_Z_POSITION(current_position[Z_AXIS])
|
7700
|
|
- };
|
|
7690
|
+ const float raw[XYZ] = { RAW_X_POSITION(current_position[X_AXIS]), RAW_Y_POSITION(current_position[Y_AXIS]), RAW_Z_POSITION(current_position[Z_AXIS]) };
|
7701
|
7691
|
report_xyz(raw);
|
7702
|
7692
|
|
7703
|
7693
|
SERIAL_PROTOCOLPGM("Leveled:");
|
7704
|
|
- float leveled[XYZ] = {
|
7705
|
|
- current_position[X_AXIS],
|
7706
|
|
- current_position[Y_AXIS],
|
7707
|
|
- current_position[Z_AXIS]
|
7708
|
|
- };
|
|
7694
|
+ float leveled[XYZ] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
|
7709
|
7695
|
planner.apply_leveling(leveled);
|
7710
|
7696
|
report_xyz(leveled);
|
7711
|
7697
|
|
|
@@ -7725,13 +7711,8 @@ void report_current_position() {
|
7725
|
7711
|
#endif
|
7726
|
7712
|
|
7727
|
7713
|
SERIAL_PROTOCOLPGM("Stepper:");
|
7728
|
|
- const float step_count[XYZE] = {
|
7729
|
|
- (float)stepper.position(X_AXIS),
|
7730
|
|
- (float)stepper.position(Y_AXIS),
|
7731
|
|
- (float)stepper.position(Z_AXIS),
|
7732
|
|
- (float)stepper.position(E_AXIS)
|
7733
|
|
- };
|
7734
|
|
- report_xyze(step_count,4,0);
|
|
7714
|
+ const float step_count[XYZE] = { stepper.position(X_AXIS), stepper.position(Y_AXIS), stepper.position(Z_AXIS), stepper.position(E_AXIS) };
|
|
7715
|
+ report_xyze(step_count, 4, 0);
|
7735
|
7716
|
|
7736
|
7717
|
#if IS_SCARA
|
7737
|
7718
|
const float deg[XYZ] = {
|
|
@@ -7739,17 +7720,12 @@ void report_current_position() {
|
7739
|
7720
|
stepper.get_axis_position_degrees(B_AXIS)
|
7740
|
7721
|
};
|
7741
|
7722
|
SERIAL_PROTOCOLPGM("Degrees:");
|
7742
|
|
- report_xyze(deg,2);
|
|
7723
|
+ report_xyze(deg, 2);
|
7743
|
7724
|
#endif
|
7744
|
7725
|
|
7745
|
7726
|
SERIAL_PROTOCOLPGM("FromStp:");
|
7746
|
7727
|
get_cartesian_from_steppers(); // writes cartes[XYZ] (with forward kinematics)
|
7747
|
|
- const float from_steppers[XYZE] = {
|
7748
|
|
- cartes[X_AXIS],
|
7749
|
|
- cartes[Y_AXIS],
|
7750
|
|
- cartes[Z_AXIS],
|
7751
|
|
- stepper.get_axis_position_mm(E_AXIS)
|
7752
|
|
- };
|
|
7728
|
+ const float from_steppers[XYZE] = { cartes[X_AXIS], cartes[Y_AXIS], cartes[Z_AXIS], stepper.get_axis_position_mm(E_AXIS) };
|
7753
|
7729
|
report_xyze(from_steppers);
|
7754
|
7730
|
|
7755
|
7731
|
const float diff[XYZE] = {
|
|
@@ -7764,12 +7740,12 @@ void report_current_position() {
|
7764
|
7740
|
#endif // M114_DETAIL
|
7765
|
7741
|
|
7766
|
7742
|
/**
|
7767
|
|
- * M114: Output current position to serial port
|
|
7743
|
+ * M114: Report current position to host
|
7768
|
7744
|
*/
|
7769
|
7745
|
inline void gcode_M114() {
|
7770
|
7746
|
|
7771
|
7747
|
#ifdef M114_DETAIL
|
7772
|
|
- if ( parser.seen('D') ) {
|
|
7748
|
+ if (parser.seen('D')) {
|
7773
|
7749
|
report_current_position_detail();
|
7774
|
7750
|
return;
|
7775
|
7751
|
}
|
|
@@ -7777,7 +7753,7 @@ inline void gcode_M114() {
|
7777
|
7753
|
|
7778
|
7754
|
stepper.synchronize();
|
7779
|
7755
|
report_current_position();
|
7780
|
|
- }
|
|
7756
|
+}
|
7781
|
7757
|
|
7782
|
7758
|
/**
|
7783
|
7759
|
* M115: Capabilities string
|
|
@@ -7859,9 +7835,7 @@ inline void gcode_M115() {
|
7859
|
7835
|
/**
|
7860
|
7836
|
* M117: Set LCD Status Message
|
7861
|
7837
|
*/
|
7862
|
|
-inline void gcode_M117() {
|
7863
|
|
- lcd_setstatus(parser.string_arg);
|
7864
|
|
-}
|
|
7838
|
+inline void gcode_M117() { lcd_setstatus(parser.string_arg); }
|
7865
|
7839
|
|
7866
|
7840
|
/**
|
7867
|
7841
|
* M119: Output endstop states to serial output
|
|
@@ -12749,7 +12723,7 @@ void setup() {
|
12749
|
12723
|
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
12750
|
12724
|
setup_endstop_interrupts();
|
12751
|
12725
|
#endif
|
12752
|
|
-
|
|
12726
|
+
|
12753
|
12727
|
#if ENABLED(SWITCHING_EXTRUDER)
|
12754
|
12728
|
move_extruder_servo(0); // Initialize extruder servo
|
12755
|
12729
|
#endif
|