Skip to content

Commit

Permalink
🎨 Misc. types cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Feb 24, 2023
1 parent 5a8dc2e commit 9b36dca
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 131 deletions.
42 changes: 21 additions & 21 deletions Marlin/src/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct IF<true, L, R> { typedef L type; };
#define NUM_AXIS_LIST_1(V) LIST_N_1(NUM_AXES, V)
#define NUM_AXIS_ARRAY(V...) { NUM_AXIS_LIST(V) }
#define NUM_AXIS_ARRAY_1(V) { NUM_AXIS_LIST_1(V) }
#define NUM_AXIS_ARGS(T...) NUM_AXIS_LIST(T x, T y, T z, T i, T j, T k, T u, T v, T w)
#define NUM_AXIS_ARGS(T) NUM_AXIS_LIST(T x, T y, T z, T i, T j, T k, T u, T v, T w)
#define NUM_AXIS_ELEM(O) NUM_AXIS_LIST(O.x, O.y, O.z, O.i, O.j, O.k, O.u, O.v, O.w)
#define NUM_AXIS_DEFS(T,V) NUM_AXIS_LIST(T x=V, T y=V, T z=V, T i=V, T j=V, T k=V, T u=V, T v=V, T w=V)
#define MAIN_AXIS_NAMES NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W)
Expand All @@ -57,7 +57,7 @@ struct IF<true, L, R> { typedef L type; };
#define LOGICAL_AXIS_LIST_1(V) NUM_AXIS_LIST_1(V) LIST_ITEM_E(V)
#define LOGICAL_AXIS_ARRAY(E,V...) { LOGICAL_AXIS_LIST(E,V) }
#define LOGICAL_AXIS_ARRAY_1(V) { LOGICAL_AXIS_LIST_1(V) }
#define LOGICAL_AXIS_ARGS(T...) LOGICAL_AXIS_LIST(T e, T x, T y, T z, T i, T j, T k, T u, T v, T w)
#define LOGICAL_AXIS_ARGS(T) LOGICAL_AXIS_LIST(T e, T x, T y, T z, T i, T j, T k, T u, T v, T w)
#define LOGICAL_AXIS_ELEM(O) LOGICAL_AXIS_LIST(O.e, O.x, O.y, O.z, O.i, O.j, O.k, O.u, O.v, O.w)
#define LOGICAL_AXIS_DECL(T,V) LOGICAL_AXIS_LIST(T e=V, T x=V, T y=V, T z=V, T i=V, T j=V, T k=V, T u=V, T v=V, T w=V)
#define LOGICAL_AXIS_NAMES LOGICAL_AXIS_LIST(E, X, Y, Z, I, J, K, U, V, W)
Expand Down Expand Up @@ -96,14 +96,14 @@ struct Flags {
bits_t b;
typename IF<(N>8), N16, N8>::type flag;
};
void reset() { b = 0; }
void set(const int n, const bool onoff) { onoff ? set(n) : clear(n); }
void set(const int n) { b |= (bits_t)_BV(n); }
void clear(const int n) { b &= ~(bits_t)_BV(n); }
bool test(const int n) const { return TEST(b, n); }
bool operator[](const int n) { return test(n); }
bool operator[](const int n) const { return test(n); }
int size() const { return sizeof(b); }
void reset() { b = 0; }
void set(const int n, const bool onoff) { onoff ? set(n) : clear(n); }
void set(const int n) { b |= (bits_t)_BV(n); }
void clear(const int n) { b &= ~(bits_t)_BV(n); }
bool test(const int n) const { return TEST(b, n); }
bool operator[](const int n) { return test(n); }
bool operator[](const int n) const { return test(n); }
int size() const { return sizeof(b); }
};

// Specialization for a single bool flag
Expand All @@ -129,14 +129,14 @@ typedef struct AxisFlags {
struct Flags<LOGICAL_AXES> flags;
struct { bool LOGICAL_AXIS_LIST(e:1, x:1, y:1, z:1, i:1, j:1, k:1, u:1, v:1, w:1); };
};
void reset() { flags.reset(); }
void set(const int n) { flags.set(n); }
void set(const int n, const bool onoff) { flags.set(n, onoff); }
void clear(const int n) { flags.clear(n); }
bool test(const int n) const { return flags.test(n); }
bool operator[](const int n) { return flags[n]; }
bool operator[](const int n) const { return flags[n]; }
int size() const { return sizeof(flags); }
void reset() { flags.reset(); }
void set(const int n) { flags.set(n); }
void set(const int n, const bool onoff) { flags.set(n, onoff); }
void clear(const int n) { flags.clear(n); }
bool test(const int n) const { return flags.test(n); }
bool operator[](const int n) { return flags[n]; }
bool operator[](const int n) const { return flags[n]; }
int size() const { return sizeof(flags); }
} axis_flags_t;

//
Expand Down Expand Up @@ -188,9 +188,9 @@ typedef IF<(NUM_AXIS_ENUMS > 8), uint16_t, uint8_t>::type axis_bits_t;
// Loop over axes
//
#define LOOP_ABC(VAR) LOOP_S_LE_N(VAR, A_AXIS, C_AXIS)
#define LOOP_NUM_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, NUM_AXES)
#define LOOP_LOGICAL_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, LOGICAL_AXES)
#define LOOP_DISTINCT_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, DISTINCT_AXES)
#define LOOP_NUM_AXES(VAR) LOOP_S_L_N(VAR, 0, NUM_AXES)
#define LOOP_LOGICAL_AXES(VAR) LOOP_S_L_N(VAR, 0, LOGICAL_AXES)
#define LOOP_DISTINCT_AXES(VAR) LOOP_S_L_N(VAR, 0, DISTINCT_AXES)
#define LOOP_DISTINCT_E(VAR) LOOP_L_N(VAR, DISTINCT_E)

//
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
NUM_AXIS_LIST(
TERN0(X_SENSORLESS, tmc_enable_stallguard(stepperX)),
TERN0(Y_SENSORLESS, tmc_enable_stallguard(stepperY)),
false, false, false, false
false, false, false, false, false, false, false
)
, TERN0(X2_SENSORLESS, tmc_enable_stallguard(stepperX2))
, TERN0(Y2_SENSORLESS, tmc_enable_stallguard(stepperY2))
Expand Down
4 changes: 1 addition & 3 deletions Marlin/src/gcode/geometry/M206_M428.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
/**
* M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y
*
* *** @thinkyhead: I recommend deprecating M206 for SCARA in favor of M665.
* *** M206 for SCARA will remain enabled in 1.1.x for compatibility.
* *** In the 2.0 release, it will simply be disabled by default.
* *** TODO: Deprecate M206 for SCARA in favor of M665.
*/
void GcodeSuite::M206() {
if (!parser.seen_any()) return M206_report();
Expand Down
66 changes: 35 additions & 31 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -758,39 +758,32 @@
#define HAS_X_AXIS 1
#if NUM_AXES >= XY
#define HAS_Y_AXIS 1
#if NUM_AXES >= XYZ
#define HAS_Z_AXIS 1
#ifdef Z4_DRIVER_TYPE
#define NUM_Z_STEPPERS 4
#elif defined(Z3_DRIVER_TYPE)
#define NUM_Z_STEPPERS 3
#elif defined(Z2_DRIVER_TYPE)
#define NUM_Z_STEPPERS 2
#else
#define NUM_Z_STEPPERS 1
#endif
#if NUM_AXES >= 4
#define HAS_I_AXIS 1
#if NUM_AXES >= 5
#define HAS_J_AXIS 1
#if NUM_AXES >= 6
#define HAS_K_AXIS 1
#if NUM_AXES >= 7
#define HAS_U_AXIS 1
#if NUM_AXES >= 8
#define HAS_V_AXIS 1
#if NUM_AXES >= 9
#define HAS_W_AXIS 1
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#if NUM_AXES >= XYZ
#define HAS_Z_AXIS 1
#endif
#if NUM_AXES >= 4
#define HAS_I_AXIS 1
#endif
#if NUM_AXES >= 5
#define HAS_J_AXIS 1
#endif
#if NUM_AXES >= 6
#define HAS_K_AXIS 1
#endif
#if NUM_AXES >= 7
#define HAS_U_AXIS 1
#endif
#if NUM_AXES >= 8
#define HAS_V_AXIS 1
#endif
#if NUM_AXES >= 9
#define HAS_W_AXIS 1
#endif
#endif

#if !HAS_Y_AXIS
#undef AVOID_OBSTACLES
#undef ENDSTOPPULLUP_YMIN
#undef ENDSTOPPULLUP_YMAX
#undef Y_MIN_ENDSTOP_INVERTING
Expand All @@ -807,7 +800,17 @@
#undef MAX_SOFTWARE_ENDSTOP_Y
#endif

#if !HAS_Z_AXIS
#if HAS_Z_AXIS
#ifdef Z4_DRIVER_TYPE
#define NUM_Z_STEPPERS 4
#elif defined(Z3_DRIVER_TYPE)
#define NUM_Z_STEPPERS 3
#elif defined(Z2_DRIVER_TYPE)
#define NUM_Z_STEPPERS 2
#else
#define NUM_Z_STEPPERS 1
#endif
#else
#undef ENDSTOPPULLUP_ZMIN
#undef ENDSTOPPULLUP_ZMAX
#undef Z_MIN_ENDSTOP_INVERTING
Expand All @@ -822,6 +825,7 @@
#undef Z_MIN_POS
#undef Z_MAX_POS
#undef MANUAL_Z_HOME_POS
#undef Z_SAFE_HOMING
#undef MIN_SOFTWARE_ENDSTOP_Z
#undef MAX_SOFTWARE_ENDSTOP_Z
#endif
Expand Down
110 changes: 52 additions & 58 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,59 +88,100 @@

// Some options are disallowed without required axes
#if !HAS_Y_AXIS
#undef SAFE_BED_LEVELING_START_Y
#undef ARC_SUPPORT
#undef CALIBRATION_MEASURE_YMAX
#undef CALIBRATION_MEASURE_YMIN
#undef DISABLE_INACTIVE_Y
#undef HOME_Y_BEFORE_X
#undef INPUT_SHAPING_Y
#undef SHAPING_FREQ_Y
#undef QUICK_HOME
#undef SAFE_BED_LEVELING_START_Y
#undef SHAPING_BUFFER_Y
#undef SHAPING_FREQ_Y
#undef STEALTHCHOP_Y
#endif

#if !HAS_Z_AXIS
#undef CALIBRATION_MEASURE_ZMAX
#undef CALIBRATION_MEASURE_ZMIN
#undef CNC_WORKSPACE_PLANES
#undef DISABLE_INACTIVE_Z
#undef ENABLE_LEVELING_FADE_HEIGHT
#undef HOME_Z_FIRST
#undef HOMING_Z_WITH_PROBE
#undef NUM_Z_STEPPERS
#undef SAFE_BED_LEVELING_START_Z
#undef STEALTHCHOP_Z
#undef Z_IDLE_HEIGHT
#undef Z_PROBE_SLED
#undef Z_SAFE_HOMING
#endif

#if !HAS_I_AXIS
#undef CALIBRATION_MEASURE_IMAX
#undef CALIBRATION_MEASURE_IMIN
#undef DISABLE_INACTIVE_I
#undef SAFE_BED_LEVELING_START_I
#undef STEALTHCHOP_I
#endif

#if !HAS_J_AXIS
#undef CALIBRATION_MEASURE_JMAX
#undef CALIBRATION_MEASURE_JMIN
#undef DISABLE_INACTIVE_J
#undef SAFE_BED_LEVELING_START_J
#undef STEALTHCHOP_J
#endif

#if !HAS_K_AXIS
#undef CALIBRATION_MEASURE_KMAX
#undef CALIBRATION_MEASURE_KMIN
#undef DISABLE_INACTIVE_K
#undef SAFE_BED_LEVELING_START_K
#undef STEALTHCHOP_K
#endif

#if !HAS_U_AXIS
#undef CALIBRATION_MEASURE_UMAX
#undef CALIBRATION_MEASURE_UMIN
#undef DISABLE_INACTIVE_U
#undef SAFE_BED_LEVELING_START_U
#undef STEALTHCHOP_U
#endif

#if !HAS_V_AXIS
#undef CALIBRATION_MEASURE_VMAX
#undef CALIBRATION_MEASURE_VMIN
#undef DISABLE_INACTIVE_V
#undef SAFE_BED_LEVELING_START_V
#undef STEALTHCHOP_V
#endif

#if !HAS_W_AXIS
#undef CALIBRATION_MEASURE_WMAX
#undef CALIBRATION_MEASURE_WMIN
#undef DISABLE_INACTIVE_W
#undef SAFE_BED_LEVELING_START_W
#undef STEALTHCHOP_W
#endif

// Disallowed with no extruders
#if !HAS_EXTRUDERS
#define NO_VOLUMETRICS
#undef FWRETRACT
#undef PIDTEMP
#undef AUTOTEMP
#undef PID_EXTRUSION_SCALING
#undef LIN_ADVANCE
#undef ADVANCED_PAUSE_FEATURE
#undef FILAMENT_LOAD_UNLOAD_GCODES
#undef AUTOTEMP
#undef EXTRUDER_RUNOUT_PREVENT
#undef THERMAL_PROTECTION_PERIOD
#undef WATCH_TEMP_PERIOD
#undef SHOW_TEMP_ADC_VALUES
#undef FILAMENT_LOAD_UNLOAD_GCODES
#undef FWRETRACT
#undef LCD_SHOW_E_TOTAL
#undef LIN_ADVANCE
#undef MANUAL_E_MOVES_RELATIVE
#undef PID_EXTRUSION_SCALING
#undef PIDTEMP
#undef SHOW_TEMP_ADC_VALUES
#undef STEALTHCHOP_E
#undef THERMAL_PROTECTION_PERIOD
#undef WATCH_TEMP_PERIOD
#endif

#if HOTENDS <= 7
Expand Down Expand Up @@ -1051,53 +1092,6 @@
#endif
#endif

// Remove unused STEALTHCHOP flags
#if NUM_AXES < 9
#undef STEALTHCHOP_W
#undef CALIBRATION_MEASURE_WMIN
#undef CALIBRATION_MEASURE_WMAX
#if NUM_AXES < 8
#undef STEALTHCHOP_V
#undef CALIBRATION_MEASURE_VMIN
#undef CALIBRATION_MEASURE_VMAX
#if NUM_AXES < 7
#undef STEALTHCHOP_U
#undef CALIBRATION_MEASURE_UMIN
#undef CALIBRATION_MEASURE_UMAX
#if NUM_AXES < 6
#undef STEALTHCHOP_K
#undef CALIBRATION_MEASURE_KMIN
#undef CALIBRATION_MEASURE_KMAX
#if NUM_AXES < 5
#undef STEALTHCHOP_J
#undef CALIBRATION_MEASURE_JMIN
#undef CALIBRATION_MEASURE_JMAX
#if NUM_AXES < 4
#undef STEALTHCHOP_I
#undef CALIBRATION_MEASURE_IMIN
#undef CALIBRATION_MEASURE_IMAX
#if NUM_AXES < 3
#undef STEALTHCHOP_Z
#undef Z_IDLE_HEIGHT
#undef Z_PROBE_SLED
#undef Z_SAFE_HOMING
#undef HOME_Z_FIRST
#undef HOMING_Z_WITH_PROBE
#undef ENABLE_LEVELING_FADE_HEIGHT
#undef NUM_Z_STEPPERS
#undef CNC_WORKSPACE_PLANES
#if NUM_AXES < 2
#undef STEALTHCHOP_Y
#undef QUICK_HOME
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif

#if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \
|| defined(SAFE_BED_LEVELING_START_I) || defined(SAFE_BED_LEVELING_START_J) || defined(SAFE_BED_LEVELING_START_K) \
|| defined(SAFE_BED_LEVELING_START_U) || defined(SAFE_BED_LEVELING_START_V) || defined(SAFE_BED_LEVELING_START_W)
Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/lcd/dogm/status_screen_DOGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,9 @@ void MarlinUI::draw_status_screen() {

const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive());

static u8g_uint_t progress_bar_solid_width = 0;
#if HAS_PRINT_PROGRESS
static u8g_uint_t progress_bar_solid_width = 0;
#endif

// At the first page, generate new display values
if (first_page) {
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
#if HAS_Y_AXIS
WRITE(Y_DIR_PIN, HIGH);
#endif
#if HAS_Y_AXIS
#if HAS_Z_AXIS
WRITE(Z_DIR_PIN, HIGH);
#endif
#if HAS_EXTRUDERS
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ void Planner::check_axes_activity() {
thermalManager.setTargetHotend(t, active_extruder);
}

#endif
#endif // AUTOTEMP

#if DISABLED(NO_VOLUMETRICS)

Expand Down
Loading

0 comments on commit 9b36dca

Please sign in to comment.