Browse Source

🎨 Fix comments, formatting

FB4S_WIFI
Scott Lahteine 2 years ago
committed by Scott Lahteine
parent
commit
da6c16a9cd
  1. 5
      Marlin/src/core/macros.h
  2. 4
      Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h
  3. 11
      Marlin/src/lcd/marlinui.cpp
  4. 54
      Marlin/src/module/planner.cpp
  5. 12
      Marlin/src/module/stepper/trinamic.cpp

5
Marlin/src/core/macros.h

@ -644,8 +644,8 @@
#define IS_PROBE(V...) SECOND(V, 0) // Get the second item passed, or 0
#define PROBE() ~, 1 // Second item will be 1 if this is passed
#define _NOT_0 PROBE()
#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'.
#define _BOOL(x) NOT(NOT(x)) // NOT('0') gets '0'. Anything else gets '1'.
#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'.
#define _BOOL(x) NOT(NOT(x)) // _BOOL('0') gets '0'. Anything else gets '1'.
#define IF_ELSE(TF) _IF_ELSE(_BOOL(TF))
#define _IF_ELSE(TF) _CAT(_IF_, TF)
@ -659,7 +659,6 @@
#define HAS_ARGS(V...) _BOOL(FIRST(_END_OF_ARGUMENTS_ V)())
#define _END_OF_ARGUMENTS_() 0
// Simple Inline IF Macros, friendly to use in other macro definitions
#define IF(O, A, B) ((O) ? (A) : (B))
#define IF_0(O, A) IF(O, A, 0)

4
Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h

@ -240,8 +240,8 @@
#define IS_PROBE(V...) SECOND(V, 0) // Get the second item passed, or 0
#define PROBE() ~, 1 // Second item will be 1 if this is passed
#define _NOT_0 PROBE()
#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'.
#define _BOOL(x) NOT(NOT(x)) // NOT('0') gets '0'. Anything else gets '1'.
#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'.
#define _BOOL(x) NOT(NOT(x)) // _BOOL('0') gets '0'. Anything else gets '1'.
#define _DO_1(W,C,A) (_##W##_1(A))
#define _DO_2(W,C,A,B) (_##W##_1(A) C _##W##_1(B))

11
Marlin/src/lcd/marlinui.cpp

@ -489,13 +489,10 @@ void MarlinUI::init() {
ui.manual_move.menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
ui.encoderPosition = dir;
switch (axis) {
case X_AXIS: { void lcd_move_x(); lcd_move_x(); } break;
#if HAS_Y_AXIS
case Y_AXIS: { void lcd_move_y(); lcd_move_y(); } break;
#endif
#if HAS_Z_AXIS
case Z_AXIS: { void lcd_move_z(); lcd_move_z(); } break;
#endif
case X_AXIS:
TERN_(HAS_Y_AXIS, case Y_AXIS:)
TERN_(HAS_Z_AXIS, case Z_AXIS:)
lcd_move_axis(axis);
default: break;
}
}

54
Marlin/src/module/planner.cpp

@ -2049,9 +2049,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
#endif
#elif ENABLED(MARKFORGED_XY)
steps_dist_mm.a = (da - db) * mm_per_step[A_AXIS];
steps_dist_mm.b = db * mm_per_step[B_AXIS];
steps_dist_mm.b = db * mm_per_step[B_AXIS];
#elif ENABLED(MARKFORGED_YX)
steps_dist_mm.a = da * mm_per_step[A_AXIS];
steps_dist_mm.a = da * mm_per_step[A_AXIS];
steps_dist_mm.b = (db - da) * mm_per_step[B_AXIS];
#else
XYZ_CODE(
@ -2097,12 +2097,21 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
block->millimeters = millimeters;
else {
/**
* Distance for interpretation of feedrate in accordance with LinuxCNC (the successor of NIST
* RS274NGC interpreter - version 3) and its default CANON_XYZ feed reference mode.
* Assume that X, Y, Z are the primary linear axes and U, V, W are secondary linear axes and A, B, C are
* rotational axes. Then dX, dY, dZ are the displacements of the primary linear axes and dU, dV, dW are the displacements of linear axes and
* dA, dB, dC are the displacements of rotational axes.
* The time it takes to execute move command with feedrate F is t = D/F, where D is the total distance, calculated as follows:
* Distance for interpretation of feedrate in accordance with LinuxCNC (the successor of
* NIST RS274NGC interpreter - version 3) and its default CANON_XYZ feed reference mode.
*
* Assume:
* - X, Y, Z are the primary linear axes;
* - U, V, W are secondary linear axes;
* - A, B, C are rotational axes.
*
* Then:
* - dX, dY, dZ are the displacements of the primary linear axes;
* - dU, dV, dW are the displacements of linear axes;
* - dA, dB, dC are the displacements of rotational axes.
*
* The time it takes to execute move command with feedrate F is t = D/F,
* where D is the total distance, calculated as follows:
* D^2 = dX^2 + dY^2 + dZ^2
* if D^2 == 0 (none of XYZ move but any secondary linear axes move, whether other axes are moved or not):
* D^2 = dU^2 + dV^2 + dW^2
@ -2111,8 +2120,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
*/
float distance_sqr = (
#if ENABLED(ARTICULATED_ROBOT_ARM)
// For articulated robots, interpreting feedrate like LinuxCNC would require inverse kinematics. As a workaround, pretend that motors sit on n mutually orthogonal
// axes and assume that we could think of distance as magnitude of an n-vector in an n-dimensional Euclidian space.
// For articulated robots, interpreting feedrate like LinuxCNC would require inverse kinematics. As a workaround,
// assume that motors sit on a mutually-orthogonal axes and we can think of distance as magnitude of an n-vector
// in an n-dimensional Euclidian space.
NUM_AXIS_GANG(
sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z),
+ sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k),
@ -2120,8 +2130,8 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
);
#elif ENABLED(FOAMCUTTER_XYUV)
#if HAS_J_AXIS
// Special 5 axis kinematics. Return the largest distance move from either X/Y or I/J plane
_MAX(sq(steps_dist_mm.x) + sq(steps_dist_mm.y), sq(steps_dist_mm.i) + sq(steps_dist_mm.j))
// Special 5 axis kinematics. Return the largest distance move from either X/Y or I/J plane
_MAX(sq(steps_dist_mm.x) + sq(steps_dist_mm.y), sq(steps_dist_mm.i) + sq(steps_dist_mm.j))
#else // Foamcutter with only two axes (XY)
sq(steps_dist_mm.x) + sq(steps_dist_mm.y)
#endif
@ -2132,7 +2142,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
#elif CORE_IS_YZ
XYZ_GANG(sq(steps_dist_mm.x), + sq(steps_dist_mm.head.y), + sq(steps_dist_mm.head.z))
#else
XYZ_GANG(sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z))
XYZ_GANG(sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z))
#endif
);
@ -2165,9 +2175,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
/**
* At this point at least one of the axes has more steps than
* MIN_STEPS_PER_SEGMENT, ensuring the segment won't get dropped as
* zero-length. It's important to not apply corrections
* to blocks that would get dropped!
* MIN_STEPS_PER_SEGMENT, ensuring the segment won't get dropped
* as zero-length. It's important to not apply corrections to blocks
* that would get dropped!
*
* A correction function is permitted to add steps to an axis, it
* should *never* remove steps!
@ -2203,15 +2213,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
#if ENABLED(AUTO_POWER_CONTROL)
if (NUM_AXIS_GANG(
block->steps.x,
|| block->steps.y,
|| block->steps.z,
|| block->steps.i,
|| block->steps.j,
|| block->steps.k,
|| block->steps.u,
|| block->steps.v,
|| block->steps.w
block->steps.x, || block->steps.y, || block->steps.z,
|| block->steps.i, || block->steps.j, || block->steps.k,
|| block->steps.u, || block->steps.v, || block->steps.w
)) powerManager.power_on();
#endif

12
Marlin/src/module/stepper/trinamic.cpp

@ -1030,10 +1030,8 @@ void reset_trinamic_drivers() {
// Using a fixed-length character array for the port name allows this to be constexpr compatible.
struct SanityHwSerialDetails { const char port[20]; uint32_t address; };
#define TMC_HW_DETAIL_ARGS(A) TERN(A##_HAS_HW_SERIAL, STRINGIFY(A##_HARDWARE_SERIAL), ""), TERN0(A##_HAS_HW_SERIAL, A##_SLAVE_ADDRESS)
#define TMC_HW_DETAIL(A) { TMC_HW_DETAIL_ARGS(A) },
constexpr SanityHwSerialDetails sanity_tmc_hw_details[] = {
MAP(TMC_HW_DETAIL, ALL_AXIS_NAMES)
};
#define TMC_HW_DETAIL(A) { TMC_HW_DETAIL_ARGS(A) }
constexpr SanityHwSerialDetails sanity_tmc_hw_details[] = { MAPLIST(TMC_HW_DETAIL, ALL_AXIS_NAMES) };
// constexpr compatible string comparison
constexpr bool str_eq_ce(const char * a, const char * b) {
@ -1057,10 +1055,8 @@ void reset_trinamic_drivers() {
#if ANY_AXIS_HAS(SW_SERIAL)
struct SanitySwSerialDetails { int32_t txpin; int32_t rxpin; uint32_t address; };
#define TMC_SW_DETAIL_ARGS(A) TERN(A##_HAS_SW_SERIAL, A##_SERIAL_TX_PIN, -1), TERN(A##_HAS_SW_SERIAL, A##_SERIAL_RX_PIN, -1), TERN0(A##_HAS_SW_SERIAL, A##_SLAVE_ADDRESS)
#define TMC_SW_DETAIL(A) TMC_SW_DETAIL_ARGS(A),
constexpr SanitySwSerialDetails sanity_tmc_sw_details[] = {
MAP(TMC_SW_DETAIL, ALL_AXIS_NAMES)
};
#define TMC_SW_DETAIL(A) { TMC_SW_DETAIL_ARGS(A) }
constexpr SanitySwSerialDetails sanity_tmc_sw_details[] = { MAPLIST(TMC_SW_DETAIL, ALL_AXIS_NAMES) };
constexpr bool sc_sw_done(size_t start, size_t end) { return start == end; }
constexpr bool sc_sw_skip(int32_t txpin) { return txpin < 0; }

Loading…
Cancel
Save