Skip to content

Commit

Permalink
adjust style
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jan 23, 2024
1 parent c53fd59 commit c18c6de
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 93 deletions.
36 changes: 26 additions & 10 deletions Marlin/src/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -939,9 +939,7 @@ class AxisBits {
el bits;
// Axes x, y, z ... e0, e1, e2 ... hx, hy, hz
struct {
#if NUM_AXES
bool NUM_AXIS_LIST(x:1, y:1, z:1, i:1, j:1, k:1, u:1, v:1, w:1);
#endif
bool NUM_AXIS_LIST(x:1, y:1, z:1, i:1, j:1, k:1, u:1, v:1, w:1);
#define _EN_ITEM(N) bool e##N:1;
REPEAT(EXTRUDERS,_EN_ITEM)
#undef _EN_ITEM
Expand All @@ -951,19 +949,17 @@ class AxisBits {
};
// Axes X, Y, Z ... E0, E1, E2 ... HX, HY, HZ
struct {
#if NUM_AXES
bool NUM_AXIS_LIST(X:1, Y:1, Z:1, I:1, J:1, K:1, U:1, V:1, W:1);
#endif
bool NUM_AXIS_LIST(X:1, Y:1, Z:1, I:1, J:1, K:1, U:1, V:1, W:1);
#define _EN_ITEM(N) bool E##N:1;
REPEAT(EXTRUDERS,_EN_ITEM)
#undef _EN_ITEM
#if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX)
bool HX:1, HY:1, HZ:1;
#endif
};
// Joints ja, jb, jc, e ... ha, hb, hc
// a, b, c, e ... ha, hb, hc
struct {
bool LOGICAL_AXIS_LIST(e:1, ja:1, jb:1, jc:1, ji:1, jj:1, jk:1, ju:1, jv:1, jw:1);
bool LOGICAL_AXIS_LIST(e:1, a:1, b:1, c:1, _i:1, _j:1, _k:1, _u:1, _v:1, _w:1);
#if EXTRUDERS > 1
#define _EN_ITEM(N) bool _e##N:1;
REPEAT_S(1,EXTRUDERS,_EN_ITEM)
Expand All @@ -973,9 +969,9 @@ class AxisBits {
bool ha:1, hb:1, hc:1;
#endif
};
// Joints JA, JB, JC, E ... HA, HB, HC
// A, B, C, E ... HA, HB, HC
struct {
bool LOGICAL_AXIS_LIST(E:1, JA:1, JB:1, JC:1, JI:1, JJ:1, JK:1, JU:1, JV:1, JW:1);
bool LOGICAL_AXIS_LIST(E:1, A:1, B:1, C:1, _I:1, _J:1, _K:1, _U:1, _V:1, _W:1);
#if EXTRUDERS > 1
#define _EN_ITEM(N) bool _E##N:1;
REPEAT_S(1,EXTRUDERS,_EN_ITEM)
Expand All @@ -985,6 +981,26 @@ class AxisBits {
bool HA:1, HB:1, HC:1;
#endif
};
// Joints ja, jb, jc ... je0, je1, je2 ... jha, jhb, jhc
struct {
bool NUM_AXIS_LIST(ja:1, jb:1, jc:1, ji:1, jj:1, jk:1, ju:1, jv:1, jw:1);
#define _EN_ITEM(N) bool je##N:1;
REPEAT(EXTRUDERS,_EN_ITEM)
#undef _EN_ITEM
#if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX)
bool jha:1, jhb:1, jhc:1;
#endif
};
// Joints JA, JB, JC ... JE0, JE1, JE2 ... JHA, JHB, JHC
struct {
bool NUM_AXIS_LIST(JA:1, JB:1, JC:1, JI:1, JJ:1, JK:1, JU:1, JV:1, JW:1);
#define _EN_ITEM(N) bool JE##N:1;
REPEAT(EXTRUDERS,_EN_ITEM)
#undef _EN_ITEM
#if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX)
bool JHA:1, JHB:1, JHC:1;
#endif
};
};

AxisBits() { reset(); }
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/geometry/G92.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void GcodeSuite::G92() {
break;
#endif

#if ENABLED(POWER_LOSS_RECOVERY) || HAS_ROTATIONAL_AXES
#if ANY(POWER_LOSS_RECOVERY, HAS_ROTATIONAL_AXES)
case 9: // G92.9 - Set Current Position directly (like Marlin 1.0)
LOOP_LOGICAL_AXES(i) {
if (parser.seenval(AXIS_CHAR(i))) {
Expand Down
39 changes: 18 additions & 21 deletions Marlin/src/gcode/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,17 @@ class GCodeParser {
// Bool is true with no value or non-zero
static bool value_bool() { return !has_value() || !!value_byte(); }

#if HAS_ROTATIONAL_AXES
static constexpr bool axis_is_rotational(const AxisEnum axis) {
return (false
|| TERN0(AXIS4_ROTATES, axis == I_AXIS)
|| TERN0(AXIS5_ROTATES, axis == J_AXIS)
|| TERN0(AXIS6_ROTATES, axis == K_AXIS)
|| TERN0(AXIS7_ROTATES, axis == U_AXIS)
|| TERN0(AXIS8_ROTATES, axis == V_AXIS)
|| TERN0(AXIS9_ROTATES, axis == W_AXIS)
);
}
#endif
static constexpr bool axis_is_rotational(const AxisEnum axis) {
return (false
|| TERN0(AXIS4_ROTATES, axis == I_AXIS)
|| TERN0(AXIS5_ROTATES, axis == J_AXIS)
|| TERN0(AXIS6_ROTATES, axis == K_AXIS)
|| TERN0(AXIS7_ROTATES, axis == U_AXIS)
|| TERN0(AXIS8_ROTATES, axis == V_AXIS)
|| TERN0(AXIS9_ROTATES, axis == W_AXIS)
);
}

// Units modes: Inches, Fahrenheit, Kelvin

#if ENABLED(INCH_MODE_SUPPORT)
Expand All @@ -319,9 +318,7 @@ class GCodeParser {
}

static float axis_unit_factor(const AxisEnum axis) {
#if HAS_ROTATIONAL_AXES
if (axis_is_rotational(axis)) return 1.0f;
#endif
if (axis_is_rotational(axis)) return 1.0f;
#if HAS_EXTRUDERS
if (axis >= E_AXIS && volumetric_enabled) return volumetric_unit_factor;
#endif
Expand All @@ -334,12 +331,12 @@ class GCodeParser {

#else

static float mm_to_linear_unit(const_float_t mm) { return mm; }
static float mm_to_volumetric_unit(const_float_t mm) { return mm; }
static constexpr float mm_to_linear_unit(const_float_t mm) { return mm; }
static constexpr float mm_to_volumetric_unit(const_float_t mm) { return mm; }

static float linear_value_to_mm(const_float_t v) { return v; }
static float axis_value_to_mm(const AxisEnum, const float v) { return v; }
static float per_axis_value(const AxisEnum, const float v) { return v; }
static constexpr float linear_value_to_mm(const_float_t v) { return v; }
static constexpr float axis_value_to_mm(const AxisEnum, const float v) { return v; }
static constexpr float per_axis_value(const AxisEnum, const float v) { return v; }

#endif

Expand Down Expand Up @@ -409,7 +406,7 @@ class GCodeParser {

#else // !TEMPERATURE_UNITS_SUPPORT

static float to_temp_units(int16_t c) { return (float)c; }
static constexpr float to_temp_units(int16_t c) { return (float)c; }

static celsius_t value_celsius() { return value_int(); }
static celsius_t value_celsius_diff() { return value_int(); }
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -3276,7 +3276,7 @@
#endif

// Add commands that need sub-codes to this list
#if ANY(G38_PROBE_TARGET, CNC_COORDINATE_SYSTEMS, POWER_LOSS_RECOVERY) || HAS_ROTATIONAL_AXES
#if ANY(G38_PROBE_TARGET, CNC_COORDINATE_SYSTEMS, POWER_LOSS_RECOVERY, HAS_ROTATIONAL_AXES)
#define USE_GCODE_SUBCODES 1
#endif

Expand Down
91 changes: 42 additions & 49 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "../inc/MarlinConfig.h"

#include "../MarlinCore.h" // for printingIsPaused
#include "../gcode/parser.h" // for axis_is_rotational, using_inch_units

#if LED_POWEROFF_TIMEOUT > 0 || ALL(HAS_WIRED_LCD, PRINTER_EVENT_LEDS) || (HAS_BACKLIGHT_TIMEOUT && defined(NEOPIXEL_BKGD_INDEX_FIRST))
#include "../feature/leds/leds.h"
Expand Down Expand Up @@ -61,10 +62,6 @@ MarlinUI ui;
#include "../module/printcounter.h"
#endif

#if ENABLED(INCH_MODE_SUPPORT) && HAS_ROTATIONAL_AXES
#include "../gcode/parser.h"
#endif

#if LCD_HAS_WAIT_FOR_MOVE
bool MarlinUI::wait_for_move; // = false
#endif
Expand Down Expand Up @@ -851,62 +848,58 @@ void MarlinUI::init() {
if (processing) return; // Prevent re-entry from idle() calls

// Add a manual move to the queue?
if (axis != NO_AXIS_ENUM && ELAPSED(millis(), start_time) && !planner.is_full()) {

const feedRate_t fr_mm_s = (axis < LOGICAL_AXES) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S;

/**
* For a rotational axis apply the "inch" to "mm" conversion factor. This mimics behaviour of the G-code G1
* (see get_distance_from_command function). For moves involving only rotational axes, the planner will
* convert back to the feedrate in degrees per time unit.
*/
feedRate_t fr = fr_mm_s;
#if ENABLED(INCH_MODE_SUPPORT) && HAS_ROTATIONAL_AXES
if (parser.axis_is_rotational(axis) && parser.using_inch_units()) fr = IN_TO_MM(fr);
#endif
if (axis == NO_AXIS_ENUM || PENDING(millis(), start_time) || planner.is_full()) return;

#if IS_KINEMATIC
const feedRate_t fr_mm_s = (axis < LOGICAL_AXES) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S;

#if HAS_MULTI_EXTRUDER
REMEMBER(ae, active_extruder);
#if MULTI_E_MANUAL
if (axis == E_AXIS) active_extruder = e_index;
#endif
/**
* For a rotational axis apply the "inch" to "mm" conversion factor. This mimics behaviour of the G-code G1
* (see get_destination_from_command). For moves involving only rotational axes, the planner will convert
* back to the feedrate in degrees-per-time unit.
*/
const feedRate_t fr = parser.axis_is_rotational(axis) && parser.using_inch_units() ? IN_TO_MM(fr_mm_s) : fr_mm_s;

#if IS_KINEMATIC

#if HAS_MULTI_EXTRUDER
REMEMBER(ae, active_extruder);
#if MULTI_E_MANUAL
if (axis == E_AXIS) active_extruder = e_index;
#endif
#endif

// Apply a linear offset to a single axis
if (axis == ALL_AXES_ENUM)
destination = all_axes_destination;
else if (axis <= LOGICAL_AXES) {
destination = current_position;
destination[axis] += offset;
}
// Apply a linear offset to a single axis
if (axis == ALL_AXES_ENUM)
destination = all_axes_destination;
else if (axis <= LOGICAL_AXES) {
destination = current_position;
destination[axis] += offset;
}

// Reset for the next move
offset = 0;
axis = NO_AXIS_ENUM;
// Reset for the next move
offset = 0;
axis = NO_AXIS_ENUM;

// DELTA and SCARA machines use segmented moves, which could fill the planner during the call to
// move_to_destination. This will cause idle() to be called, which can then call this function while the
// previous invocation is being blocked. Modifications to offset shouldn't be made while
// processing is true or the planner will get out of sync.
processing = true;
prepare_internal_move_to_destination(fr); // will set current_position from destination
processing = false;
// DELTA and SCARA machines use segmented moves, which could fill the planner during the call to
// move_to_destination. This will cause idle() to be called, which can then call this function while the
// previous invocation is being blocked. Modifications to offset shouldn't be made while
// processing is true or the planner will get out of sync.
processing = true;
prepare_internal_move_to_destination(fr); // will set current_position from destination
processing = false;

#else
#else

// For Cartesian / Core motion simply move to the current_position
planner.buffer_line(current_position, fr,
TERN_(MULTI_E_MANUAL, axis == E_AXIS ? e_index :) active_extruder
);
// For Cartesian / Core motion simply move to the current_position
planner.buffer_line(current_position, fr,
TERN_(MULTI_E_MANUAL, axis == E_AXIS ? e_index :) active_extruder
);

//SERIAL_ECHOLNPGM("Add planner.move with Axis ", C(AXIS_CHAR(axis)), " at FR ", fr_mm_s);
//SERIAL_ECHOLNPGM("Add planner.move with Axis ", C(AXIS_CHAR(axis)), " at FR ", fr_mm_s);

axis = NO_AXIS_ENUM;
axis = NO_AXIS_ENUM;

#endif
}
#endif
}

//
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void lcd_move_axis(const AxisEnum axis) {
if (ui.should_draw()) {
MenuEditItemBase::itemIndex = axis;
const float pos = ui.manual_move.axis_value(axis);
if (parser.using_inch_units && TERN1(HAS_ROTATIONAL_AXES, !parser.axis_is_rotational(axis))) {
if (parser.using_inch_units && !parser.axis_is_rotational(axis)) {
const float imp_pos = parser.per_axis_value(axis, pos);
MenuEditItemBase::draw_edit_screen(GET_TEXT_F(MSG_MOVE_N), ftostr63(imp_pos));
}
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ float get_move_distance(const xyze_pos_t &diff OPTARG(HAS_ROTATIONAL_AXES, bool
distance_sqr = ROTATIONAL_AXIS_GANG(sq(diff.i), + sq(diff.j), + sq(diff.k), + sq(diff.u), + sq(diff.v), + sq(diff.w));
}
if (!UNEAR_ZERO(distance_sqr)) {
//Move involves rotational axes, not just the extruder
// Move involves rotational axes, not just the extruder
is_cartesian_move = false;
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2309,8 +2309,8 @@ bool Planner::_populate_block(
float inverse_secs = inverse_millimeters * (
#if ALL(HAS_ROTATIONAL_AXES, INCH_MODE_SUPPORT)
/**
* Work around for the premature feedrate conversion from
* inches/s to mm/s by the get_distance_from_command function.
* Workaround for premature feedrate conversion
* from in/s to mm/s by get_distance_from_command.
*/
cartesian_move ? fr_mm_s : LINEAR_UNIT(fr_mm_s)
#else
Expand Down
10 changes: 3 additions & 7 deletions Marlin/src/module/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2597,20 +2597,16 @@ hal_timer_t Stepper::block_phase_isr() {

AxisBits didmove;
NUM_AXIS_CODE(
if (X_MOVE_TEST) didmove.ja = true,
if (Y_MOVE_TEST) didmove.jb = true,
if (Z_MOVE_TEST) didmove.jc = true,
if (X_MOVE_TEST) didmove.ja = true,
if (Y_MOVE_TEST) didmove.jb = true,
if (Z_MOVE_TEST) didmove.jc = true,
if (!!current_block->steps._i) didmove.ji = true,
if (!!current_block->steps._j) didmove.jj = true,
if (!!current_block->steps._k) didmove.jk = true,
if (!!current_block->steps._u) didmove.ju = true,
if (!!current_block->steps._v) didmove.jv = true,
if (!!current_block->steps._w) didmove.jw = true
);
//if (current_block->steps.e) didmove.e = true;
//if (current_block->steps.a) didmove.x = true;
//if (current_block->steps.b) didmove.y = true;
//if (current_block->steps.c) didmove.z = true;
axis_did_move = didmove;

// No acceleration / deceleration time elapsed so far
Expand Down

0 comments on commit c18c6de

Please sign in to comment.