Browse Source

🎨 Fix comments, formatting

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

3
Marlin/src/core/macros.h

@ -645,7 +645,7 @@
#define PROBE() ~, 1 // Second item will be 1 if this is passed #define PROBE() ~, 1 // Second item will be 1 if this is passed
#define _NOT_0 PROBE() #define _NOT_0 PROBE()
#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'. #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 _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) _IF_ELSE(_BOOL(TF))
#define _IF_ELSE(TF) _CAT(_IF_, TF) #define _IF_ELSE(TF) _CAT(_IF_, TF)
@ -659,7 +659,6 @@
#define HAS_ARGS(V...) _BOOL(FIRST(_END_OF_ARGUMENTS_ V)()) #define HAS_ARGS(V...) _BOOL(FIRST(_END_OF_ARGUMENTS_ V)())
#define _END_OF_ARGUMENTS_() 0 #define _END_OF_ARGUMENTS_() 0
// Simple Inline IF Macros, friendly to use in other macro definitions // Simple Inline IF Macros, friendly to use in other macro definitions
#define IF(O, A, B) ((O) ? (A) : (B)) #define IF(O, A, B) ((O) ? (A) : (B))
#define IF_0(O, A) IF(O, A, 0) #define IF_0(O, A) IF(O, A, 0)

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

@ -241,7 +241,7 @@
#define PROBE() ~, 1 // Second item will be 1 if this is passed #define PROBE() ~, 1 // Second item will be 1 if this is passed
#define _NOT_0 PROBE() #define _NOT_0 PROBE()
#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'. #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 _BOOL(x) NOT(NOT(x)) // _BOOL('0') gets '0'. Anything else gets '1'.
#define _DO_1(W,C,A) (_##W##_1(A)) #define _DO_1(W,C,A) (_##W##_1(A))
#define _DO_2(W,C,A,B) (_##W##_1(A) C _##W##_1(B)) #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.manual_move.menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
ui.encoderPosition = dir; ui.encoderPosition = dir;
switch (axis) { switch (axis) {
case X_AXIS: { void lcd_move_x(); lcd_move_x(); } break; case X_AXIS:
#if HAS_Y_AXIS TERN_(HAS_Y_AXIS, case Y_AXIS:)
case Y_AXIS: { void lcd_move_y(); lcd_move_y(); } break; TERN_(HAS_Z_AXIS, case Z_AXIS:)
#endif lcd_move_axis(axis);
#if HAS_Z_AXIS
case Z_AXIS: { void lcd_move_z(); lcd_move_z(); } break;
#endif
default: break; default: break;
} }
} }

44
Marlin/src/module/planner.cpp

@ -2097,12 +2097,21 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
block->millimeters = millimeters; block->millimeters = millimeters;
else { else {
/** /**
* Distance for interpretation of feedrate in accordance with LinuxCNC (the successor of NIST * Distance for interpretation of feedrate in accordance with LinuxCNC (the successor of
* RS274NGC interpreter - version 3) and its default CANON_XYZ feed reference mode. * 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 * Assume:
* dA, dB, dC are the displacements of rotational axes. * - X, Y, Z are the primary linear 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: * - 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 * 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): * 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 * 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 = ( float distance_sqr = (
#if ENABLED(ARTICULATED_ROBOT_ARM) #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 // For articulated robots, interpreting feedrate like LinuxCNC would require inverse kinematics. As a workaround,
// axes and assume that we could think of distance as magnitude of an n-vector in an n-dimensional Euclidian space. // 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( NUM_AXIS_GANG(
sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z), 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), + sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k),
@ -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 * 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 * MIN_STEPS_PER_SEGMENT, ensuring the segment won't get dropped
* zero-length. It's important to not apply corrections * as zero-length. It's important to not apply corrections to blocks
* to blocks that would get dropped! * that would get dropped!
* *
* A correction function is permitted to add steps to an axis, it * A correction function is permitted to add steps to an axis, it
* should *never* remove steps! * 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 ENABLED(AUTO_POWER_CONTROL)
if (NUM_AXIS_GANG( if (NUM_AXIS_GANG(
block->steps.x, block->steps.x, || block->steps.y, || block->steps.z,
|| block->steps.y, || block->steps.i, || block->steps.j, || block->steps.k,
|| block->steps.z, || block->steps.u, || block->steps.v, || block->steps.w
|| block->steps.i,
|| block->steps.j,
|| block->steps.k,
|| block->steps.u,
|| block->steps.v,
|| block->steps.w
)) powerManager.power_on(); )) powerManager.power_on();
#endif #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. // 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; }; 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_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) }, #define TMC_HW_DETAIL(A) { TMC_HW_DETAIL_ARGS(A) }
constexpr SanityHwSerialDetails sanity_tmc_hw_details[] = { constexpr SanityHwSerialDetails sanity_tmc_hw_details[] = { MAPLIST(TMC_HW_DETAIL, ALL_AXIS_NAMES) };
MAP(TMC_HW_DETAIL, ALL_AXIS_NAMES)
};
// constexpr compatible string comparison // constexpr compatible string comparison
constexpr bool str_eq_ce(const char * a, const char * b) { 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) #if ANY_AXIS_HAS(SW_SERIAL)
struct SanitySwSerialDetails { int32_t txpin; int32_t rxpin; uint32_t address; }; 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_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), #define TMC_SW_DETAIL(A) { TMC_SW_DETAIL_ARGS(A) }
constexpr SanitySwSerialDetails sanity_tmc_sw_details[] = { constexpr SanitySwSerialDetails sanity_tmc_sw_details[] = { MAPLIST(TMC_SW_DETAIL, ALL_AXIS_NAMES) };
MAP(TMC_SW_DETAIL, ALL_AXIS_NAMES)
};
constexpr bool sc_sw_done(size_t start, size_t end) { return start == end; } 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; } constexpr bool sc_sw_skip(int32_t txpin) { return txpin < 0; }

Loading…
Cancel
Save