@@ -1614,6 +1614,7 @@ void Planner::finish_and_disable() {
1614
1614
float Planner::get_axis_position_mm (const AxisEnum axis) {
1615
1615
float axis_steps;
1616
1616
#if IS_CORE
1617
+
1617
1618
// Requesting one of the "core" axes?
1618
1619
if (axis == CORE_AXIS_1 || axis == CORE_AXIS_2) {
1619
1620
@@ -1631,9 +1632,30 @@ float Planner::get_axis_position_mm(const AxisEnum axis) {
1631
1632
}
1632
1633
else
1633
1634
axis_steps = stepper.position (axis);
1635
+
1636
+ #elif ENABLED(MARKFORGED_XY)
1637
+
1638
+ // Requesting one of the joined axes?
1639
+ if (axis == CORE_AXIS_1 || axis == CORE_AXIS_2) {
1640
+ // Protect the access to the position.
1641
+ const bool was_enabled = stepper.suspend ();
1642
+
1643
+ const int32_t p1 = stepper.position (CORE_AXIS_1),
1644
+ p2 = stepper.position (CORE_AXIS_2);
1645
+
1646
+ if (was_enabled) stepper.wake_up ();
1647
+
1648
+ axis_steps = ((axis == CORE_AXIS_1) ? p1 - p2 : p2);
1649
+ }
1650
+ else
1651
+ axis_steps = stepper.position (axis);
1652
+
1634
1653
#else
1654
+
1635
1655
axis_steps = stepper.position (axis);
1656
+
1636
1657
#endif
1658
+
1637
1659
return axis_steps * steps_to_mm[axis];
1638
1660
}
1639
1661
@@ -1808,6 +1830,12 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
1808
1830
if (dc < 0 ) SBI (dm, Z_HEAD); // ...and Z
1809
1831
if (db + dc < 0 ) SBI (dm, B_AXIS); // Motor B direction
1810
1832
if (CORESIGN (db - dc) < 0 ) SBI (dm, C_AXIS); // Motor C direction
1833
+ #elif ENABLED(MARKFORGED_XY)
1834
+ if (da < 0 ) SBI (dm, X_HEAD); // Save the real Extruder (head) direction in X Axis
1835
+ if (db < 0 ) SBI (dm, Y_HEAD); // ...and Y
1836
+ if (dc < 0 ) SBI (dm, Z_AXIS);
1837
+ if (da + db < 0 ) SBI (dm, A_AXIS); // Motor A direction
1838
+ if (db < 0 ) SBI (dm, B_AXIS); // Motor B direction
1811
1839
#else
1812
1840
if (da < 0 ) SBI (dm, X_AXIS);
1813
1841
if (db < 0 ) SBI (dm, Y_AXIS);
@@ -1843,6 +1871,8 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
1843
1871
block->steps .set (ABS (da + dc), ABS (db), ABS (da - dc));
1844
1872
#elif CORE_IS_YZ
1845
1873
block->steps .set (ABS (da), ABS (db + dc), ABS (db - dc));
1874
+ #elif ENABLED(MARKFORGED_XY)
1875
+ block->steps .set (ABS (da + db), ABS (db), ABS (dc));
1846
1876
#elif IS_SCARA
1847
1877
block->steps .set (ABS (da), ABS (db), ABS (dc));
1848
1878
#else
@@ -1859,7 +1889,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
1859
1889
* Having the real displacement of the head, we can calculate the total movement length and apply the desired speed.
1860
1890
*/
1861
1891
struct DistanceMM : abce_float_t {
1862
- TERN_ (IS_CORE, xyz_pos_t head);
1892
+ #if EITHER(IS_CORE, MARKFORGED_XY)
1893
+ xyz_pos_t head;
1894
+ #endif
1863
1895
} steps_dist_mm;
1864
1896
#if IS_CORE
1865
1897
#if CORE_IS_XY
@@ -1881,6 +1913,12 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
1881
1913
steps_dist_mm.b = (db + dc) * steps_to_mm[B_AXIS];
1882
1914
steps_dist_mm.c = CORESIGN (db - dc) * steps_to_mm[C_AXIS];
1883
1915
#endif
1916
+ #elif ENABLED(MARKFORGED_XY)
1917
+ steps_dist_mm.head .x = da * steps_to_mm[A_AXIS];
1918
+ steps_dist_mm.head .y = db * steps_to_mm[B_AXIS];
1919
+ steps_dist_mm.z = dc * steps_to_mm[Z_AXIS];
1920
+ steps_dist_mm.a = (da - db) * steps_to_mm[A_AXIS];
1921
+ steps_dist_mm.b = db * steps_to_mm[B_AXIS];
1884
1922
#else
1885
1923
steps_dist_mm.a = da * steps_to_mm[A_AXIS];
1886
1924
steps_dist_mm.b = db * steps_to_mm[B_AXIS];
@@ -1907,7 +1945,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
1907
1945
block->millimeters = millimeters;
1908
1946
else
1909
1947
block->millimeters = SQRT (
1910
- #if CORE_IS_XY
1948
+ #if EITHER( CORE_IS_XY, MARKFORGED_XY)
1911
1949
sq (steps_dist_mm.head .x ) + sq (steps_dist_mm.head .y ) + sq (steps_dist_mm.z )
1912
1950
#elif CORE_IS_XZ
1913
1951
sq (steps_dist_mm.head .x ) + sq (steps_dist_mm.y ) + sq (steps_dist_mm.head .z )
@@ -1964,7 +2002,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
1964
2002
#endif
1965
2003
1966
2004
// Enable active axes
1967
- #if CORE_IS_XY
2005
+ #if EITHER( CORE_IS_XY, MARKFORGED_XY)
1968
2006
if (block->steps .a || block->steps .b ) {
1969
2007
ENABLE_AXIS_X ();
1970
2008
ENABLE_AXIS_Y ();
@@ -2325,9 +2363,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2325
2363
* On CoreXY the length of the vector [A,B] is SQRT(2) times the length of the head movement vector [X,Y].
2326
2364
* So taking Z and E into account, we cannot scale to a unit vector with "inverse_millimeters".
2327
2365
* => normalize the complete junction vector.
2328
- * Elsewise, when needed JD factors in the E component
2366
+ * Elsewise, when needed JD will factor- in the E component
2329
2367
*/
2330
- if (ENABLED (IS_CORE) || esteps > 0 )
2368
+ if (EITHER (IS_CORE, MARKFORGED_XY ) || esteps > 0 )
2331
2369
normalize_junction_vector (unit_vec); // Normalize with XYZE components
2332
2370
else
2333
2371
unit_vec *= inverse_millimeters; // Use pre-calculated (1 / SQRT(x^2 + y^2 + z^2))
0 commit comments