|
@@ -154,6 +154,8 @@
|
154
|
154
|
// M302 - Allow cold extrudes, or set the minimum extrude S<temperature>.
|
155
|
155
|
// M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
|
156
|
156
|
// M304 - Set bed PID parameters P I and D
|
|
157
|
+// M380 - Activate solenoid on active extruder
|
|
158
|
+// M381 - Disable all solenoids
|
157
|
159
|
// M400 - Finish all moves
|
158
|
160
|
// M401 - Lower z-probe if present
|
159
|
161
|
// M402 - Raise z-probe if present
|
|
@@ -529,32 +531,28 @@ void setup_homepin(void)
|
529
|
531
|
void setup_photpin()
|
530
|
532
|
{
|
531
|
533
|
#if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
|
532
|
|
- SET_OUTPUT(PHOTOGRAPH_PIN);
|
533
|
|
- WRITE(PHOTOGRAPH_PIN, LOW);
|
|
534
|
+ OUT_WRITE(PHOTOGRAPH_PIN, LOW);
|
534
|
535
|
#endif
|
535
|
536
|
}
|
536
|
537
|
|
537
|
538
|
void setup_powerhold()
|
538
|
539
|
{
|
539
|
540
|
#if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
|
540
|
|
- SET_OUTPUT(SUICIDE_PIN);
|
541
|
|
- WRITE(SUICIDE_PIN, HIGH);
|
|
541
|
+ OUT_WRITE(SUICIDE_PIN, HIGH);
|
542
|
542
|
#endif
|
543
|
543
|
#if defined(PS_ON_PIN) && PS_ON_PIN > -1
|
544
|
|
- SET_OUTPUT(PS_ON_PIN);
|
545
|
|
- #if defined(PS_DEFAULT_OFF)
|
546
|
|
- WRITE(PS_ON_PIN, PS_ON_ASLEEP);
|
547
|
|
- #else
|
548
|
|
- WRITE(PS_ON_PIN, PS_ON_AWAKE);
|
549
|
|
- #endif
|
|
544
|
+ #if defined(PS_DEFAULT_OFF)
|
|
545
|
+ OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
|
|
546
|
+ #else
|
|
547
|
+ OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE);
|
|
548
|
+ #endif
|
550
|
549
|
#endif
|
551
|
550
|
}
|
552
|
551
|
|
553
|
552
|
void suicide()
|
554
|
553
|
{
|
555
|
554
|
#if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
|
556
|
|
- SET_OUTPUT(SUICIDE_PIN);
|
557
|
|
- WRITE(SUICIDE_PIN, LOW);
|
|
555
|
+ OUT_WRITE(SUICIDE_PIN, LOW);
|
558
|
556
|
#endif
|
559
|
557
|
}
|
560
|
558
|
|
|
@@ -1200,22 +1198,24 @@ static void retract_z_probe() {
|
1200
|
1198
|
#endif
|
1201
|
1199
|
}
|
1202
|
1200
|
|
|
1201
|
+enum ProbeAction { ProbeStay, ProbeEngage, ProbeRetract, ProbeEngageRetract };
|
|
1202
|
+
|
1203
|
1203
|
/// Probe bed height at position (x,y), returns the measured z value
|
1204
|
|
-static float probe_pt(float x, float y, float z_before, int retract_action=0) {
|
|
1204
|
+static float probe_pt(float x, float y, float z_before, ProbeAction retract_action=ProbeEngageRetract) {
|
1205
|
1205
|
// move to right place
|
1206
|
1206
|
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before);
|
1207
|
1207
|
do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
|
1208
|
1208
|
|
1209
|
|
-#ifndef Z_PROBE_SLED
|
1210
|
|
- if ((retract_action==0) || (retract_action==1))
|
1211
|
|
- engage_z_probe(); // Engage Z Servo endstop if available
|
1212
|
|
-#endif // Z_PROBE_SLED
|
|
1209
|
+ #ifndef Z_PROBE_SLED
|
|
1210
|
+ if (retract_action & ProbeEngage) engage_z_probe();
|
|
1211
|
+ #endif
|
|
1212
|
+
|
1213
|
1213
|
run_z_probe();
|
1214
|
1214
|
float measured_z = current_position[Z_AXIS];
|
1215
|
|
-#ifndef Z_PROBE_SLED
|
1216
|
|
- if ((retract_action==0) || (retract_action==3))
|
1217
|
|
- retract_z_probe();
|
1218
|
|
-#endif // Z_PROBE_SLED
|
|
1215
|
+
|
|
1216
|
+ #ifndef Z_PROBE_SLED
|
|
1217
|
+ if (retract_action & ProbeRetract) retract_z_probe();
|
|
1218
|
+ #endif
|
1219
|
1219
|
|
1220
|
1220
|
SERIAL_PROTOCOLPGM(MSG_BED);
|
1221
|
1221
|
SERIAL_PROTOCOLPGM(" x: ");
|
|
@@ -1376,6 +1376,11 @@ void refresh_cmd_timeout(void)
|
1376
|
1376
|
#endif //FWRETRACT
|
1377
|
1377
|
|
1378
|
1378
|
#ifdef Z_PROBE_SLED
|
|
1379
|
+
|
|
1380
|
+ #ifndef SLED_DOCKING_OFFSET
|
|
1381
|
+ #define SLED_DOCKING_OFFSET 0
|
|
1382
|
+ #endif
|
|
1383
|
+
|
1379
|
1384
|
//
|
1380
|
1385
|
// Method to dock/undock a sled designed by Charles Bell.
|
1381
|
1386
|
//
|
|
@@ -1430,10 +1435,10 @@ void process_commands()
|
1430
|
1435
|
if(autoretract_enabled)
|
1431
|
1436
|
if( !(code_seen('X') || code_seen('Y') || code_seen('Z')) && code_seen('E')) {
|
1432
|
1437
|
float echange=destination[E_AXIS]-current_position[E_AXIS];
|
1433
|
|
- if((echange<-MIN_RETRACT && !retracted) || (echange>MIN_RETRACT && retracted)) { //move appears to be an attempt to retract or recover
|
|
1438
|
+ if((echange<-MIN_RETRACT && !retracted[active_extruder]) || (echange>MIN_RETRACT && retracted[active_extruder])) { //move appears to be an attempt to retract or recover
|
1434
|
1439
|
current_position[E_AXIS] = destination[E_AXIS]; //hide the slicer-generated retract/recover from calculations
|
1435
|
1440
|
plan_set_e_position(current_position[E_AXIS]); //AND from the planner
|
1436
|
|
- retract(!retracted);
|
|
1441
|
+ retract(!retracted[active_extruder]);
|
1437
|
1442
|
return;
|
1438
|
1443
|
}
|
1439
|
1444
|
}
|
|
@@ -1662,10 +1667,10 @@ void process_commands()
|
1662
|
1667
|
// Let's see if X and Y are homed and probe is inside bed area.
|
1663
|
1668
|
if(code_seen(axis_codes[Z_AXIS])) {
|
1664
|
1669
|
if ( (axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]) \
|
1665
|
|
- && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER >= X_MIN_POS) \
|
1666
|
|
- && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER <= X_MAX_POS) \
|
1667
|
|
- && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER >= Y_MIN_POS) \
|
1668
|
|
- && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) {
|
|
1670
|
+ && (current_position[X_AXIS] >= X_MIN_POS - X_PROBE_OFFSET_FROM_EXTRUDER) \
|
|
1671
|
+ && (current_position[X_AXIS] <= X_MAX_POS - X_PROBE_OFFSET_FROM_EXTRUDER) \
|
|
1672
|
+ && (current_position[Y_AXIS] >= Y_MIN_POS - Y_PROBE_OFFSET_FROM_EXTRUDER) \
|
|
1673
|
+ && (current_position[Y_AXIS] <= Y_MAX_POS - Y_PROBE_OFFSET_FROM_EXTRUDER)) {
|
1669
|
1674
|
|
1670
|
1675
|
current_position[Z_AXIS] = 0;
|
1671
|
1676
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
@@ -1719,193 +1724,327 @@ void process_commands()
|
1719
|
1724
|
break;
|
1720
|
1725
|
|
1721
|
1726
|
#ifdef ENABLE_AUTO_BED_LEVELING
|
|
1727
|
+
|
|
1728
|
+ #if Z_MIN_PIN == -1
|
|
1729
|
+ #error "You must have a Z_MIN endstop in order to enable Auto Bed Leveling!!! Z_MIN_PIN must point to a valid hardware pin."
|
|
1730
|
+ #endif
|
|
1731
|
+
|
|
1732
|
+ /**
|
|
1733
|
+ * Enhanced G29 Auto Bed Leveling Probe Routine
|
|
1734
|
+ *
|
|
1735
|
+ * Parameters With AUTO_BED_LEVELING_GRID:
|
|
1736
|
+ *
|
|
1737
|
+ * P Set the size of the grid that will be probed (P x P points).
|
|
1738
|
+ * Example: "G29 P4"
|
|
1739
|
+ *
|
|
1740
|
+ * V Set the verbose level (0-4). Example: "G29 V3"
|
|
1741
|
+ *
|
|
1742
|
+ * T Generate a Bed Topology Report. Example: "G29 P5 T" for a detailed report.
|
|
1743
|
+ * This is useful for manual bed leveling and finding flaws in the bed (to
|
|
1744
|
+ * assist with part placement).
|
|
1745
|
+ *
|
|
1746
|
+ * F Set the Front limit of the probing grid
|
|
1747
|
+ * B Set the Back limit of the probing grid
|
|
1748
|
+ * L Set the Left limit of the probing grid
|
|
1749
|
+ * R Set the Right limit of the probing grid
|
|
1750
|
+ *
|
|
1751
|
+ * Global Parameters:
|
|
1752
|
+ *
|
|
1753
|
+ * E/e By default G29 engages / disengages the probe for each point.
|
|
1754
|
+ * Include "E" to engage and disengage the probe just once.
|
|
1755
|
+ * There's no extra effect if you have a fixed probe.
|
|
1756
|
+ * Usage: "G29 E" or "G29 e"
|
|
1757
|
+ *
|
|
1758
|
+ */
|
|
1759
|
+
|
1722
|
1760
|
case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points.
|
1723
|
|
- // Override probing area by providing [F]ront [B]ack [L]eft [R]ight Grid[P]oints values
|
1724
|
|
- {
|
1725
|
|
- #if Z_MIN_PIN == -1
|
1726
|
|
- #error "You must have a Z_MIN endstop in order to enable Auto Bed Leveling feature!!! Z_MIN_PIN must point to a valid hardware pin."
|
1727
|
|
- #endif
|
|
1761
|
+ {
|
|
1762
|
+ // Use one of these defines to specify the origin
|
|
1763
|
+ // for a topographical map to be printed for your bed.
|
|
1764
|
+ #define ORIGIN_BACK_LEFT 1
|
|
1765
|
+ #define ORIGIN_FRONT_RIGHT 2
|
|
1766
|
+ #define ORIGIN_BACK_RIGHT 3
|
|
1767
|
+ #define ORIGIN_FRONT_LEFT 4
|
|
1768
|
+ #define TOPO_ORIGIN ORIGIN_FRONT_LEFT
|
|
1769
|
+
|
|
1770
|
+ // Prevent user from running a G29 without first homing in X and Y
|
|
1771
|
+ if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS])) {
|
|
1772
|
+ LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
|
|
1773
|
+ SERIAL_ECHO_START;
|
|
1774
|
+ SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
|
|
1775
|
+ break; // abort G29, since we don't know where we are
|
|
1776
|
+ }
|
1728
|
1777
|
|
1729
|
|
- // Prevent user from running a G29 without first homing in X and Y
|
1730
|
|
- if (! (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) )
|
1731
|
|
- {
|
1732
|
|
- LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
|
1733
|
|
- SERIAL_ECHO_START;
|
1734
|
|
- SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
|
1735
|
|
- break; // abort G29, since we don't know where we are
|
1736
|
|
- }
|
|
1778
|
+ bool enhanced_g29 = code_seen('E') || code_seen('e');
|
1737
|
1779
|
|
1738
|
|
-#ifdef Z_PROBE_SLED
|
1739
|
|
- dock_sled(false);
|
1740
|
|
-#endif // Z_PROBE_SLED
|
1741
|
|
- st_synchronize();
|
1742
|
|
- // make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
|
1743
|
|
- //vector_3 corrected_position = plan_get_position_mm();
|
1744
|
|
- //corrected_position.debug("position before G29");
|
1745
|
|
- plan_bed_level_matrix.set_to_identity();
|
1746
|
|
- vector_3 uncorrected_position = plan_get_position();
|
1747
|
|
- //uncorrected_position.debug("position durring G29");
|
1748
|
|
- current_position[X_AXIS] = uncorrected_position.x;
|
1749
|
|
- current_position[Y_AXIS] = uncorrected_position.y;
|
1750
|
|
- current_position[Z_AXIS] = uncorrected_position.z;
|
1751
|
|
- plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1752
|
|
- setup_for_endstop_move();
|
|
1780
|
+ #ifdef AUTO_BED_LEVELING_GRID
|
1753
|
1781
|
|
1754
|
|
- feedrate = homing_feedrate[Z_AXIS];
|
1755
|
|
-#ifdef AUTO_BED_LEVELING_GRID
|
1756
|
|
- // probe at the points of a lattice grid
|
1757
|
|
- int left_probe_bed_position=LEFT_PROBE_BED_POSITION;
|
1758
|
|
- int right_probe_bed_position=RIGHT_PROBE_BED_POSITION;
|
1759
|
|
- int back_probe_bed_position=BACK_PROBE_BED_POSITION;
|
1760
|
|
- int front_probe_bed_position=FRONT_PROBE_BED_POSITION;
|
1761
|
|
- int auto_bed_leveling_grid_points=AUTO_BED_LEVELING_GRID_POINTS;
|
1762
|
|
- if (code_seen('L')) left_probe_bed_position=(int)code_value();
|
1763
|
|
- if (code_seen('R')) right_probe_bed_position=(int)code_value();
|
1764
|
|
- if (code_seen('B')) back_probe_bed_position=(int)code_value();
|
1765
|
|
- if (code_seen('F')) front_probe_bed_position=(int)code_value();
|
1766
|
|
- if (code_seen('P')) auto_bed_leveling_grid_points=(int)code_value();
|
|
1782
|
+ // Example Syntax: G29 N4 V2 E T
|
|
1783
|
+ int verbose_level = 1;
|
1767
|
1784
|
|
1768
|
|
- int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points-1);
|
1769
|
|
- int yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points-1);
|
|
1785
|
+ bool topo_flag = code_seen('T') || code_seen('t');
|
1770
|
1786
|
|
|
1787
|
+ if (code_seen('V') || code_seen('v')) {
|
|
1788
|
+ verbose_level = code_value();
|
|
1789
|
+ if (verbose_level < 0 || verbose_level > 4) {
|
|
1790
|
+ SERIAL_PROTOCOLPGM("?(V)erbose Level is implausible (0-4).\n");
|
|
1791
|
+ break;
|
|
1792
|
+ }
|
|
1793
|
+ if (verbose_level > 0) {
|
|
1794
|
+ SERIAL_PROTOCOLPGM("G29 Enhanced Auto Bed Leveling Code V1.25:\n");
|
|
1795
|
+ SERIAL_PROTOCOLPGM("Full support at: http://3dprintboard.com/forum.php\n");
|
|
1796
|
+ if (verbose_level > 2) topo_flag = true;
|
|
1797
|
+ }
|
|
1798
|
+ }
|
1771
|
1799
|
|
1772
|
|
- // solve the plane equation ax + by + d = z
|
1773
|
|
- // A is the matrix with rows [x y 1] for all the probed points
|
1774
|
|
- // B is the vector of the Z positions
|
1775
|
|
- // the normal vector to the plane is formed by the coefficients of the plane equation in the standard form, which is Vx*x+Vy*y+Vz*z+d = 0
|
1776
|
|
- // so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
|
|
1800
|
+ int auto_bed_leveling_grid_points = code_seen('P') ? code_value_long() : AUTO_BED_LEVELING_GRID_POINTS;
|
|
1801
|
+ if (auto_bed_leveling_grid_points < 2 || auto_bed_leveling_grid_points > AUTO_BED_LEVELING_GRID_POINTS) {
|
|
1802
|
+ SERIAL_PROTOCOLPGM("?Number of probed (P)oints is implausible (2 minimum).\n");
|
|
1803
|
+ break;
|
|
1804
|
+ }
|
1777
|
1805
|
|
1778
|
|
- // "A" matrix of the linear system of equations
|
1779
|
|
- double eqnAMatrix[auto_bed_leveling_grid_points*auto_bed_leveling_grid_points*3];
|
|
1806
|
+ // Define the possible boundaries for probing based on the set limits.
|
|
1807
|
+ // Code above (in G28) might have these limits wrong, or I am wrong here.
|
|
1808
|
+ #define MIN_PROBE_EDGE 10 // Edges of the probe square can be no less
|
|
1809
|
+ const int min_probe_x = max(X_MIN_POS, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER),
|
|
1810
|
+ max_probe_x = min(X_MAX_POS, X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER),
|
|
1811
|
+ min_probe_y = max(Y_MIN_POS, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER),
|
|
1812
|
+ max_probe_y = min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER);
|
|
1813
|
+
|
|
1814
|
+ int left_probe_bed_position = code_seen('L') ? code_value_long() : LEFT_PROBE_BED_POSITION,
|
|
1815
|
+ right_probe_bed_position = code_seen('R') ? code_value_long() : RIGHT_PROBE_BED_POSITION,
|
|
1816
|
+ front_probe_bed_position = code_seen('F') ? code_value_long() : FRONT_PROBE_BED_POSITION,
|
|
1817
|
+ back_probe_bed_position = code_seen('B') ? code_value_long() : BACK_PROBE_BED_POSITION;
|
|
1818
|
+
|
|
1819
|
+ bool left_out_l = left_probe_bed_position < min_probe_x,
|
|
1820
|
+ left_out_r = left_probe_bed_position > right_probe_bed_position - MIN_PROBE_EDGE,
|
|
1821
|
+ left_out = left_out_l || left_out_r,
|
|
1822
|
+ right_out_r = right_probe_bed_position > max_probe_x,
|
|
1823
|
+ right_out_l =right_probe_bed_position < left_probe_bed_position + MIN_PROBE_EDGE,
|
|
1824
|
+ right_out = right_out_l || right_out_r,
|
|
1825
|
+ front_out_f = front_probe_bed_position < min_probe_y,
|
|
1826
|
+ front_out_b = front_probe_bed_position > back_probe_bed_position - MIN_PROBE_EDGE,
|
|
1827
|
+ front_out = front_out_f || front_out_b,
|
|
1828
|
+ back_out_b = back_probe_bed_position > max_probe_y,
|
|
1829
|
+ back_out_f = back_probe_bed_position < front_probe_bed_position + MIN_PROBE_EDGE,
|
|
1830
|
+ back_out = back_out_f || back_out_b;
|
|
1831
|
+
|
|
1832
|
+ if (left_out || right_out || front_out || back_out) {
|
|
1833
|
+ if (left_out) {
|
|
1834
|
+ SERIAL_PROTOCOLPGM("?Probe (L)eft position out of range.\n");
|
|
1835
|
+ left_probe_bed_position = left_out_l ? min_probe_x : right_probe_bed_position - MIN_PROBE_EDGE;
|
|
1836
|
+ }
|
|
1837
|
+ if (right_out) {
|
|
1838
|
+ SERIAL_PROTOCOLPGM("?Probe (R)ight position out of range.\n");
|
|
1839
|
+ right_probe_bed_position = right_out_r ? max_probe_x : left_probe_bed_position + MIN_PROBE_EDGE;
|
|
1840
|
+ }
|
|
1841
|
+ if (front_out) {
|
|
1842
|
+ SERIAL_PROTOCOLPGM("?Probe (F)ront position out of range.\n");
|
|
1843
|
+ front_probe_bed_position = front_out_f ? min_probe_y : back_probe_bed_position - MIN_PROBE_EDGE;
|
|
1844
|
+ }
|
|
1845
|
+ if (back_out) {
|
|
1846
|
+ SERIAL_PROTOCOLPGM("?Probe (B)ack position out of range.\n");
|
|
1847
|
+ back_probe_bed_position = back_out_b ? max_probe_y : front_probe_bed_position + MIN_PROBE_EDGE;
|
|
1848
|
+ }
|
|
1849
|
+ break;
|
|
1850
|
+ }
|
1780
|
1851
|
|
1781
|
|
- // "B" vector of Z points
|
1782
|
|
- double eqnBVector[auto_bed_leveling_grid_points*auto_bed_leveling_grid_points];
|
|
1852
|
+ #endif
|
1783
|
1853
|
|
|
1854
|
+ #ifdef Z_PROBE_SLED
|
|
1855
|
+ dock_sled(false); // engage (un-dock) the probe
|
|
1856
|
+ #endif
|
1784
|
1857
|
|
|
1858
|
+ st_synchronize();
|
|
1859
|
+ // make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
|
|
1860
|
+ //vector_3 corrected_position = plan_get_position_mm();
|
|
1861
|
+ //corrected_position.debug("position before G29");
|
|
1862
|
+ plan_bed_level_matrix.set_to_identity();
|
|
1863
|
+ vector_3 uncorrected_position = plan_get_position();
|
|
1864
|
+ //uncorrected_position.debug("position durring G29");
|
|
1865
|
+ current_position[X_AXIS] = uncorrected_position.x;
|
|
1866
|
+ current_position[Y_AXIS] = uncorrected_position.y;
|
|
1867
|
+ current_position[Z_AXIS] = uncorrected_position.z;
|
|
1868
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
1869
|
+ setup_for_endstop_move();
|
1785
|
1870
|
|
1786
|
|
- int probePointCounter = 0;
|
1787
|
|
- bool zig = true;
|
|
1871
|
+ feedrate = homing_feedrate[Z_AXIS];
|
1788
|
1872
|
|
1789
|
|
- for (int yProbe=front_probe_bed_position; yProbe <= back_probe_bed_position; yProbe += yGridSpacing)
|
|
1873
|
+ #ifdef AUTO_BED_LEVELING_GRID
|
|
1874
|
+ // probe at the points of a lattice grid
|
1790
|
1875
|
|
1791
|
|
- {
|
1792
|
|
- int xProbe, xInc;
|
1793
|
|
- if (zig)
|
1794
|
|
- {
|
1795
|
|
- xProbe = left_probe_bed_position;
|
1796
|
|
- //xEnd = right_probe_bed_position;
|
1797
|
|
- xInc = xGridSpacing;
|
1798
|
|
- zig = false;
|
1799
|
|
- } else // zag
|
1800
|
|
- {
|
1801
|
|
- xProbe = right_probe_bed_position;
|
1802
|
|
- //xEnd = left_probe_bed_position;
|
1803
|
|
- xInc = -xGridSpacing;
|
1804
|
|
- zig = true;
|
1805
|
|
- }
|
|
1876
|
+ int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points - 1);
|
|
1877
|
+ int yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points - 1);
|
1806
|
1878
|
|
1807
|
|
- for (int xCount=0; xCount < auto_bed_leveling_grid_points; xCount++)
|
1808
|
|
- {
|
1809
|
|
- float z_before;
|
1810
|
|
- if (probePointCounter == 0)
|
1811
|
|
- {
|
1812
|
|
- // raise before probing
|
1813
|
|
- z_before = Z_RAISE_BEFORE_PROBING;
|
1814
|
|
- } else
|
1815
|
|
- {
|
1816
|
|
- // raise extruder
|
1817
|
|
- z_before = current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS;
|
1818
|
|
- }
|
1819
|
|
-
|
1820
|
|
- float measured_z;
|
1821
|
|
- //Enhanced G29 - Do not retract servo between probes
|
1822
|
|
- if (code_seen('E') || code_seen('e') )
|
1823
|
|
- {
|
1824
|
|
- if ((yProbe==FRONT_PROBE_BED_POSITION) && (xCount==0))
|
1825
|
|
- {
|
1826
|
|
- measured_z = probe_pt(xProbe, yProbe, z_before,1);
|
1827
|
|
- } else if ((yProbe==FRONT_PROBE_BED_POSITION + (yGridSpacing * (AUTO_BED_LEVELING_GRID_POINTS-1))) && (xCount == AUTO_BED_LEVELING_GRID_POINTS-1))
|
1828
|
|
- {
|
1829
|
|
- measured_z = probe_pt(xProbe, yProbe, z_before,3);
|
1830
|
|
- } else {
|
1831
|
|
- measured_z = probe_pt(xProbe, yProbe, z_before,2);
|
1832
|
|
- }
|
1833
|
|
- } else {
|
1834
|
|
- measured_z = probe_pt(xProbe, yProbe, z_before);
|
1835
|
|
- }
|
1836
|
|
-
|
1837
|
|
- eqnBVector[probePointCounter] = measured_z;
|
1838
|
|
-
|
1839
|
|
- eqnAMatrix[probePointCounter + 0*auto_bed_leveling_grid_points*auto_bed_leveling_grid_points] = xProbe;
|
1840
|
|
- eqnAMatrix[probePointCounter + 1*auto_bed_leveling_grid_points*auto_bed_leveling_grid_points] = yProbe;
|
1841
|
|
- eqnAMatrix[probePointCounter + 2*auto_bed_leveling_grid_points*auto_bed_leveling_grid_points] = 1;
|
1842
|
|
- probePointCounter++;
|
1843
|
|
- xProbe += xInc;
|
1844
|
|
- }
|
|
1879
|
+ // solve the plane equation ax + by + d = z
|
|
1880
|
+ // A is the matrix with rows [x y 1] for all the probed points
|
|
1881
|
+ // B is the vector of the Z positions
|
|
1882
|
+ // the normal vector to the plane is formed by the coefficients of the plane equation in the standard form, which is Vx*x+Vy*y+Vz*z+d = 0
|
|
1883
|
+ // so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
|
|
1884
|
+
|
|
1885
|
+ int abl2 = auto_bed_leveling_grid_points * auto_bed_leveling_grid_points;
|
|
1886
|
+
|
|
1887
|
+ double eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations
|
|
1888
|
+ eqnBVector[abl2], // "B" vector of Z points
|
|
1889
|
+ mean = 0.0;
|
|
1890
|
+
|
|
1891
|
+ int probePointCounter = 0;
|
|
1892
|
+ bool zig = true;
|
|
1893
|
+
|
|
1894
|
+ for (int yProbe = front_probe_bed_position; yProbe <= back_probe_bed_position; yProbe += yGridSpacing) {
|
|
1895
|
+ int xProbe, xInc;
|
|
1896
|
+
|
|
1897
|
+ if (zig)
|
|
1898
|
+ xProbe = left_probe_bed_position, xInc = xGridSpacing;
|
|
1899
|
+ else
|
|
1900
|
+ xProbe = right_probe_bed_position, xInc = -xGridSpacing;
|
|
1901
|
+
|
|
1902
|
+ // If topo_flag is set then don't zig-zag. Just scan in one direction.
|
|
1903
|
+ // This gets the probe points in more readable order.
|
|
1904
|
+ if (!topo_flag) zig = !zig;
|
|
1905
|
+
|
|
1906
|
+ for (int xCount = 0; xCount < auto_bed_leveling_grid_points; xCount++) {
|
|
1907
|
+ // raise extruder
|
|
1908
|
+ float z_before = probePointCounter == 0 ? Z_RAISE_BEFORE_PROBING : current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS,
|
|
1909
|
+ measured_z;
|
|
1910
|
+
|
|
1911
|
+ // Enhanced G29 - Do not retract servo between probes
|
|
1912
|
+ ProbeAction act;
|
|
1913
|
+ if (enhanced_g29) {
|
|
1914
|
+ if (yProbe == front_probe_bed_position && xCount == 0)
|
|
1915
|
+ act = ProbeEngage;
|
|
1916
|
+ else if (yProbe == front_probe_bed_position + (yGridSpacing * (auto_bed_leveling_grid_points - 1)) && xCount == auto_bed_leveling_grid_points - 1)
|
|
1917
|
+ act = ProbeRetract;
|
|
1918
|
+ else
|
|
1919
|
+ act = ProbeStay;
|
1845
|
1920
|
}
|
1846
|
|
- clean_up_after_endstop_move();
|
|
1921
|
+ else
|
|
1922
|
+ act = ProbeEngageRetract;
|
1847
|
1923
|
|
1848
|
|
- // solve lsq problem
|
1849
|
|
- double *plane_equation_coefficients = qr_solve(auto_bed_leveling_grid_points*auto_bed_leveling_grid_points, 3, eqnAMatrix, eqnBVector);
|
|
1924
|
+ measured_z = probe_pt(xProbe, yProbe, z_before, act);
|
1850
|
1925
|
|
1851
|
|
- SERIAL_PROTOCOLPGM("Eqn coefficients: a: ");
|
1852
|
|
- SERIAL_PROTOCOL(plane_equation_coefficients[0]);
|
1853
|
|
- SERIAL_PROTOCOLPGM(" b: ");
|
1854
|
|
- SERIAL_PROTOCOL(plane_equation_coefficients[1]);
|
1855
|
|
- SERIAL_PROTOCOLPGM(" d: ");
|
1856
|
|
- SERIAL_PROTOCOLLN(plane_equation_coefficients[2]);
|
|
1926
|
+ mean += measured_z;
|
1857
|
1927
|
|
|
1928
|
+ eqnBVector[probePointCounter] = measured_z;
|
|
1929
|
+ eqnAMatrix[probePointCounter + 0 * abl2] = xProbe;
|
|
1930
|
+ eqnAMatrix[probePointCounter + 1 * abl2] = yProbe;
|
|
1931
|
+ eqnAMatrix[probePointCounter + 2 * abl2] = 1;
|
1858
|
1932
|
|
1859
|
|
- set_bed_level_equation_lsq(plane_equation_coefficients);
|
|
1933
|
+ probePointCounter++;
|
|
1934
|
+ xProbe += xInc;
|
1860
|
1935
|
|
1861
|
|
- free(plane_equation_coefficients);
|
|
1936
|
+ } //xProbe
|
1862
|
1937
|
|
1863
|
|
-#else // AUTO_BED_LEVELING_GRID not defined
|
|
1938
|
+ } //yProbe
|
1864
|
1939
|
|
1865
|
|
- // Probe at 3 arbitrary points
|
1866
|
|
- // Enhanced G29
|
1867
|
|
-
|
1868
|
|
- float z_at_pt_1, z_at_pt_2, z_at_pt_3;
|
1869
|
|
-
|
1870
|
|
- if (code_seen('E') || code_seen('e')) {
|
1871
|
|
- // probe 1
|
1872
|
|
- z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING,1);
|
1873
|
|
- // probe 2
|
1874
|
|
- z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS,2);
|
1875
|
|
- // probe 3
|
1876
|
|
- z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS,3);
|
1877
|
|
- }
|
1878
|
|
- else {
|
1879
|
|
- // probe 1
|
1880
|
|
- z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING);
|
1881
|
|
- // probe 2
|
1882
|
|
- z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
1883
|
|
- // probe 3
|
1884
|
|
- z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
1885
|
|
- }
|
1886
|
|
- clean_up_after_endstop_move();
|
1887
|
|
- set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
|
|
1940
|
+ clean_up_after_endstop_move();
|
1888
|
1941
|
|
|
1942
|
+ // solve lsq problem
|
|
1943
|
+ double *plane_equation_coefficients = qr_solve(abl2, 3, eqnAMatrix, eqnBVector);
|
|
1944
|
+
|
|
1945
|
+ mean /= abl2;
|
|
1946
|
+
|
|
1947
|
+ if (verbose_level) {
|
|
1948
|
+ SERIAL_PROTOCOLPGM("Eqn coefficients: a: ");
|
|
1949
|
+ SERIAL_PROTOCOL(plane_equation_coefficients[0]);
|
|
1950
|
+ SERIAL_PROTOCOLPGM(" b: ");
|
|
1951
|
+ SERIAL_PROTOCOL(plane_equation_coefficients[1]);
|
|
1952
|
+ SERIAL_PROTOCOLPGM(" d: ");
|
|
1953
|
+ SERIAL_PROTOCOLLN(plane_equation_coefficients[2]);
|
|
1954
|
+ if (verbose_level > 2) {
|
|
1955
|
+ SERIAL_PROTOCOLPGM("Mean of sampled points: ");
|
|
1956
|
+ SERIAL_PROTOCOL_F(mean, 6);
|
|
1957
|
+ SERIAL_PROTOCOLPGM(" \n");
|
|
1958
|
+ }
|
|
1959
|
+ }
|
1889
|
1960
|
|
1890
|
|
-#endif // AUTO_BED_LEVELING_GRID
|
1891
|
|
- st_synchronize();
|
|
1961
|
+ if (topo_flag) {
|
1892
|
1962
|
|
1893
|
|
- // The following code correct the Z height difference from z-probe position and hotend tip position.
|
1894
|
|
- // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
|
1895
|
|
- // When the bed is uneven, this height must be corrected.
|
1896
|
|
- real_z = float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS]; //get the real Z (since the auto bed leveling is already correcting the plane)
|
1897
|
|
- x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
|
1898
|
|
- y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
|
1899
|
|
- z_tmp = current_position[Z_AXIS];
|
|
1963
|
+ int xx, yy;
|
1900
|
1964
|
|
1901
|
|
- apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); //Apply the correction sending the probe offset
|
1902
|
|
- current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS]; //The difference is added to current position and sent to planner.
|
1903
|
|
- plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1904
|
|
-#ifdef Z_PROBE_SLED
|
1905
|
|
- dock_sled(true, -SLED_DOCKING_OFFSET); // correct for over travel.
|
1906
|
|
-#endif // Z_PROBE_SLED
|
|
1965
|
+ SERIAL_PROTOCOLPGM(" \nBed Height Topography: \n");
|
|
1966
|
+ #if TOPO_ORIGIN == ORIGIN_FRONT_LEFT
|
|
1967
|
+ for (yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--)
|
|
1968
|
+ #else
|
|
1969
|
+ for (yy = 0; yy < auto_bed_leveling_grid_points; yy++)
|
|
1970
|
+ #endif
|
|
1971
|
+ {
|
|
1972
|
+ #if TOPO_ORIGIN == ORIGIN_BACK_RIGHT
|
|
1973
|
+ for (xx = auto_bed_leveling_grid_points - 1; xx >= 0; xx--)
|
|
1974
|
+ #else
|
|
1975
|
+ for (xx = 0; xx < auto_bed_leveling_grid_points; xx++)
|
|
1976
|
+ #endif
|
|
1977
|
+ {
|
|
1978
|
+ int ind =
|
|
1979
|
+ #if TOPO_ORIGIN == ORIGIN_BACK_RIGHT || TOPO_ORIGIN == ORIGIN_FRONT_LEFT
|
|
1980
|
+ yy * auto_bed_leveling_grid_points + xx
|
|
1981
|
+ #elif TOPO_ORIGIN == ORIGIN_BACK_LEFT
|
|
1982
|
+ xx * auto_bed_leveling_grid_points + yy
|
|
1983
|
+ #elif TOPO_ORIGIN == ORIGIN_FRONT_RIGHT
|
|
1984
|
+ abl2 - xx * auto_bed_leveling_grid_points - yy - 1
|
|
1985
|
+ #endif
|
|
1986
|
+ ;
|
|
1987
|
+ float diff = eqnBVector[ind] - mean;
|
|
1988
|
+ if (diff >= 0.0)
|
|
1989
|
+ SERIAL_PROTOCOLPGM(" +"); // Watch column alignment in Pronterface
|
|
1990
|
+ else
|
|
1991
|
+ SERIAL_PROTOCOLPGM(" -");
|
|
1992
|
+ SERIAL_PROTOCOL_F(diff, 5);
|
|
1993
|
+ } // xx
|
|
1994
|
+ SERIAL_PROTOCOLPGM("\n");
|
|
1995
|
+ } // yy
|
|
1996
|
+ SERIAL_PROTOCOLPGM("\n");
|
|
1997
|
+
|
|
1998
|
+ } //topo_flag
|
|
1999
|
+
|
|
2000
|
+
|
|
2001
|
+ set_bed_level_equation_lsq(plane_equation_coefficients);
|
|
2002
|
+ free(plane_equation_coefficients);
|
|
2003
|
+
|
|
2004
|
+ #else // !AUTO_BED_LEVELING_GRID
|
|
2005
|
+
|
|
2006
|
+ // Probe at 3 arbitrary points
|
|
2007
|
+ float z_at_pt_1, z_at_pt_2, z_at_pt_3;
|
|
2008
|
+
|
|
2009
|
+ if (enhanced_g29) {
|
|
2010
|
+ // Basic Enhanced G29
|
|
2011
|
+ z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING, ProbeEngage);
|
|
2012
|
+ z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, ProbeStay);
|
|
2013
|
+ z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, ProbeRetract);
|
1907
|
2014
|
}
|
1908
|
|
- break;
|
|
2015
|
+ else {
|
|
2016
|
+ z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING);
|
|
2017
|
+ z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
|
2018
|
+ z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
|
2019
|
+ }
|
|
2020
|
+ clean_up_after_endstop_move();
|
|
2021
|
+ set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
|
|
2022
|
+
|
|
2023
|
+ #endif // !AUTO_BED_LEVELING_GRID
|
|
2024
|
+
|
|
2025
|
+ st_synchronize();
|
|
2026
|
+
|
|
2027
|
+ if (verbose_level > 0)
|
|
2028
|
+ plan_bed_level_matrix.debug(" \n\nBed Level Correction Matrix:");
|
|
2029
|
+
|
|
2030
|
+ // The following code correct the Z height difference from z-probe position and hotend tip position.
|
|
2031
|
+ // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
|
|
2032
|
+ // When the bed is uneven, this height must be corrected.
|
|
2033
|
+ real_z = float(st_get_position(Z_AXIS)) / axis_steps_per_unit[Z_AXIS]; //get the real Z (since the auto bed leveling is already correcting the plane)
|
|
2034
|
+ x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
|
|
2035
|
+ y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
|
|
2036
|
+ z_tmp = current_position[Z_AXIS];
|
|
2037
|
+
|
|
2038
|
+ apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); //Apply the correction sending the probe offset
|
|
2039
|
+ current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS]; //The difference is added to current position and sent to planner.
|
|
2040
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
2041
|
+
|
|
2042
|
+ #ifdef Z_PROBE_SLED
|
|
2043
|
+ dock_sled(true, -SLED_DOCKING_OFFSET); // dock the probe, correcting for over-travel
|
|
2044
|
+ #endif
|
|
2045
|
+ }
|
|
2046
|
+ break;
|
|
2047
|
+
|
1909
|
2048
|
#ifndef Z_PROBE_SLED
|
1910
|
2049
|
case 30: // G30 Single Z Probe
|
1911
|
2050
|
{
|
|
@@ -2038,6 +2177,7 @@ void process_commands()
|
2038
|
2177
|
enable_e0();
|
2039
|
2178
|
enable_e1();
|
2040
|
2179
|
enable_e2();
|
|
2180
|
+ enable_e3();
|
2041
|
2181
|
break;
|
2042
|
2182
|
|
2043
|
2183
|
#ifdef SDSUPPORT
|
|
@@ -2723,15 +2863,13 @@ Sigma_Exit:
|
2723
|
2863
|
|
2724
|
2864
|
#if defined(PS_ON_PIN) && PS_ON_PIN > -1
|
2725
|
2865
|
case 80: // M80 - Turn on Power Supply
|
2726
|
|
- SET_OUTPUT(PS_ON_PIN); //GND
|
2727
|
|
- WRITE(PS_ON_PIN, PS_ON_AWAKE);
|
|
2866
|
+ OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); // GND
|
2728
|
2867
|
|
2729
|
2868
|
// If you have a switch on suicide pin, this is useful
|
2730
|
2869
|
// if you want to start another print with suicide feature after
|
2731
|
2870
|
// a print without suicide...
|
2732
|
2871
|
#if defined SUICIDE_PIN && SUICIDE_PIN > -1
|
2733
|
|
- SET_OUTPUT(SUICIDE_PIN);
|
2734
|
|
- WRITE(SUICIDE_PIN, HIGH);
|
|
2872
|
+ OUT_WRITE(SUICIDE_PIN, HIGH);
|
2735
|
2873
|
#endif
|
2736
|
2874
|
|
2737
|
2875
|
#ifdef ULTIPANEL
|
|
@@ -2748,6 +2886,7 @@ Sigma_Exit:
|
2748
|
2886
|
disable_e0();
|
2749
|
2887
|
disable_e1();
|
2750
|
2888
|
disable_e2();
|
|
2889
|
+ disable_e3();
|
2751
|
2890
|
finishAndDisableSteppers();
|
2752
|
2891
|
fanSpeed = 0;
|
2753
|
2892
|
delay(1000); // Wait a little before to switch off
|
|
@@ -2755,8 +2894,7 @@ Sigma_Exit:
|
2755
|
2894
|
st_synchronize();
|
2756
|
2895
|
suicide();
|
2757
|
2896
|
#elif defined(PS_ON_PIN) && PS_ON_PIN > -1
|
2758
|
|
- SET_OUTPUT(PS_ON_PIN);
|
2759
|
|
- WRITE(PS_ON_PIN, PS_ON_ASLEEP);
|
|
2897
|
+ OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
|
2760
|
2898
|
#endif
|
2761
|
2899
|
#ifdef ULTIPANEL
|
2762
|
2900
|
powersupply = false;
|
|
@@ -2785,6 +2923,7 @@ Sigma_Exit:
|
2785
|
2923
|
disable_e0();
|
2786
|
2924
|
disable_e1();
|
2787
|
2925
|
disable_e2();
|
|
2926
|
+ disable_e3();
|
2788
|
2927
|
finishAndDisableSteppers();
|
2789
|
2928
|
}
|
2790
|
2929
|
else
|
|
@@ -2798,6 +2937,7 @@ Sigma_Exit:
|
2798
|
2937
|
disable_e0();
|
2799
|
2938
|
disable_e1();
|
2800
|
2939
|
disable_e2();
|
|
2940
|
+ disable_e3();
|
2801
|
2941
|
}
|
2802
|
2942
|
#endif
|
2803
|
2943
|
}
|
|
@@ -3118,7 +3258,7 @@ Sigma_Exit:
|
3118
|
3258
|
SERIAL_ECHO(extruder_offset[Z_AXIS][tmp_extruder]);
|
3119
|
3259
|
#endif
|
3120
|
3260
|
}
|
3121
|
|
- SERIAL_ECHOLN("");
|
|
3261
|
+ SERIAL_EOL;
|
3122
|
3262
|
}break;
|
3123
|
3263
|
#endif
|
3124
|
3264
|
case 220: // M220 S<factor in percent>- set speed factor override percentage
|
|
@@ -3337,8 +3477,7 @@ Sigma_Exit:
|
3337
|
3477
|
{
|
3338
|
3478
|
#ifdef CHDK
|
3339
|
3479
|
|
3340
|
|
- SET_OUTPUT(CHDK);
|
3341
|
|
- WRITE(CHDK, HIGH);
|
|
3480
|
+ OUT_WRITE(CHDK, HIGH);
|
3342
|
3481
|
chdkHigh = millis();
|
3343
|
3482
|
chdkActive = true;
|
3344
|
3483
|
|
|
@@ -3497,6 +3636,17 @@ Sigma_Exit:
|
3497
|
3636
|
}
|
3498
|
3637
|
break;
|
3499
|
3638
|
#endif
|
|
3639
|
+
|
|
3640
|
+#ifdef EXT_SOLENOID
|
|
3641
|
+ case 380:
|
|
3642
|
+ enable_solenoid_on_active_extruder();
|
|
3643
|
+ break;
|
|
3644
|
+
|
|
3645
|
+ case 381:
|
|
3646
|
+ disable_all_solenoids();
|
|
3647
|
+ break;
|
|
3648
|
+#endif //EXT_SOLENOID
|
|
3649
|
+
|
3500
|
3650
|
case 400: // M400 finish all moves
|
3501
|
3651
|
{
|
3502
|
3652
|
st_synchronize();
|
|
@@ -3726,6 +3876,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
3726
|
3876
|
disable_e0();
|
3727
|
3877
|
disable_e1();
|
3728
|
3878
|
disable_e2();
|
|
3879
|
+ disable_e3();
|
3729
|
3880
|
delay(100);
|
3730
|
3881
|
LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE);
|
3731
|
3882
|
uint8_t cnt=0;
|
|
@@ -3737,9 +3888,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
3737
|
3888
|
if(cnt==0)
|
3738
|
3889
|
{
|
3739
|
3890
|
#if BEEPER > 0
|
3740
|
|
- SET_OUTPUT(BEEPER);
|
3741
|
|
-
|
3742
|
|
- WRITE(BEEPER,HIGH);
|
|
3891
|
+ OUT_WRITE(BEEPER,HIGH);
|
3743
|
3892
|
delay(3);
|
3744
|
3893
|
WRITE(BEEPER,LOW);
|
3745
|
3894
|
delay(3);
|
|
@@ -4000,6 +4149,13 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
4000
|
4149
|
prepare_move();
|
4001
|
4150
|
}
|
4002
|
4151
|
}
|
|
4152
|
+
|
|
4153
|
+#ifdef EXT_SOLENOID
|
|
4154
|
+ st_synchronize();
|
|
4155
|
+ disable_all_solenoids();
|
|
4156
|
+ enable_solenoid_on_active_extruder();
|
|
4157
|
+#endif //EXT_SOLENOID
|
|
4158
|
+
|
4003
|
4159
|
#endif
|
4004
|
4160
|
SERIAL_ECHO_START;
|
4005
|
4161
|
SERIAL_ECHO(MSG_ACTIVE_EXTRUDER);
|
|
@@ -4469,6 +4625,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
|
4469
|
4625
|
disable_e0();
|
4470
|
4626
|
disable_e1();
|
4471
|
4627
|
disable_e2();
|
|
4628
|
+ disable_e3();
|
4472
|
4629
|
}
|
4473
|
4630
|
}
|
4474
|
4631
|
}
|
|
@@ -4574,6 +4731,7 @@ void kill()
|
4574
|
4731
|
disable_e0();
|
4575
|
4732
|
disable_e1();
|
4576
|
4733
|
disable_e2();
|
|
4734
|
+ disable_e3();
|
4577
|
4735
|
|
4578
|
4736
|
#if defined(PS_ON_PIN) && PS_ON_PIN > -1
|
4579
|
4737
|
pinMode(PS_ON_PIN,INPUT);
|
|
@@ -4707,7 +4865,6 @@ bool setTargetedHotend(int code){
|
4707
|
4865
|
return false;
|
4708
|
4866
|
}
|
4709
|
4867
|
|
4710
|
|
-
|
4711
|
4868
|
float calculate_volumetric_multiplier(float diameter) {
|
4712
|
4869
|
if (!volumetric_enabled || diameter == 0) return 1.0;
|
4713
|
4870
|
float d2 = diameter * 0.5;
|
|
@@ -4718,3 +4875,43 @@ void calculate_volumetric_multipliers() {
|
4718
|
4875
|
for (int i=0; i<EXTRUDERS; i++)
|
4719
|
4876
|
volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
|
4720
|
4877
|
}
|
|
4878
|
+
|
|
4879
|
+#ifdef EXT_SOLENOID
|
|
4880
|
+
|
|
4881
|
+void enable_solenoid(uint8_t num) {
|
|
4882
|
+ switch(num) {
|
|
4883
|
+ case 0:
|
|
4884
|
+ OUT_WRITE(SOL0_PIN, HIGH);
|
|
4885
|
+ break;
|
|
4886
|
+ #if defined(SOL1_PIN) && SOL1_PIN > -1
|
|
4887
|
+ case 1:
|
|
4888
|
+ OUT_WRITE(SOL1_PIN, HIGH);
|
|
4889
|
+ break;
|
|
4890
|
+ #endif
|
|
4891
|
+ #if defined(SOL2_PIN) && SOL2_PIN > -1
|
|
4892
|
+ case 2:
|
|
4893
|
+ OUT_WRITE(SOL2_PIN, HIGH);
|
|
4894
|
+ break;
|
|
4895
|
+ #endif
|
|
4896
|
+ #if defined(SOL3_PIN) && SOL3_PIN > -1
|
|
4897
|
+ case 3:
|
|
4898
|
+ OUT_WRITE(SOL3_PIN, HIGH);
|
|
4899
|
+ break;
|
|
4900
|
+ #endif
|
|
4901
|
+ default:
|
|
4902
|
+ SERIAL_ECHO_START;
|
|
4903
|
+ SERIAL_ECHOLNPGM(MSG_INVALID_SOLENOID);
|
|
4904
|
+ break;
|
|
4905
|
+ }
|
|
4906
|
+}
|
|
4907
|
+
|
|
4908
|
+void enable_solenoid_on_active_extruder() { enable_solenoid(active_extruder); }
|
|
4909
|
+
|
|
4910
|
+void disable_all_solenoids() {
|
|
4911
|
+ OUT_WRITE(SOL0_PIN, LOW);
|
|
4912
|
+ OUT_WRITE(SOL1_PIN, LOW);
|
|
4913
|
+ OUT_WRITE(SOL2_PIN, LOW);
|
|
4914
|
+ OUT_WRITE(SOL3_PIN, LOW);
|
|
4915
|
+}
|
|
4916
|
+
|
|
4917
|
+#endif //EXT_SOLENOID
|