Skip to content

Commit 15ce5d0

Browse files
committed
🔨🩹 Misc. code corrections, notes
1 parent d2b47c3 commit 15ce5d0

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

Marlin/src/gcode/feature/digipot/M907-M910.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,25 @@ void GcodeSuite::M907() {
5151
if (!parser.seen("BS" STR_AXES_LOGICAL))
5252
return M907_report();
5353

54-
if (parser.seenval('S')) for (uint8_t i = 0; i < MOTOR_CURRENT_COUNT; ++i) stepper.set_digipot_current(i, parser.value_int());
55-
LOOP_LOGICAL_AXES(i) if (parser.seenval(IAXIS_CHAR(i))) stepper.set_digipot_current(i, parser.value_int()); // X Y Z (I J K U V W) E (map to drivers according to DIGIPOT_CHANNELS. Default with NUM_AXES 3: map X Y Z E to X Y Z E0)
56-
// Additional extruders use B,C.
57-
// TODO: Change these parameters because 'E' is used and D should be reserved for debugging. B<index>?
54+
// S<current> - Set current in mA for all axes
55+
if (parser.seenval('S'))
56+
for (uint8_t i = 0; i < MOTOR_CURRENT_COUNT; ++i)
57+
stepper.set_digipot_current(i, parser.value_int());
58+
59+
// X Y Z (I J K U V W) E (map to drivers according to DIGIPOT_CHANNELS.
60+
// Default with NUM_AXES 3: map X Y Z E to X Y Z E0)
61+
LOOP_LOGICAL_AXES(i)
62+
if (parser.seenval(IAXIS_CHAR(i)))
63+
stepper.set_digipot_current(i, parser.value_int());
64+
65+
/**
66+
* Additional extruders use B,C in this legacy protocol
67+
* TODO: Update to allow for an index with X, Y, Z, E axis to isolate a single stepper
68+
* and use configured axis names instead of IJKUVW. i.e., Match the behavior of
69+
* other G-codes that set stepper-specific parameters. If necessary deprecate G-codes.
70+
* Bonus Points: Standardize a method that all G-codes can use to refer to one or
71+
* more steppers/drivers and apply to various G-codes.
72+
*/
5873
#if E_STEPPERS >= 2
5974
if (parser.seenval('B')) stepper.set_digipot_current(E_AXIS + 1, parser.value_int());
6075
#if E_STEPPERS >= 3
@@ -72,14 +87,12 @@ void GcodeSuite::M907() {
7287

7388
if (!parser.seen("S"
7489
#if HAS_X_Y_XY_I_J_K_U_V_W
75-
"XY" SECONDARY_AXIS_GANG("I", "J", "K", "U", "V", "W")
90+
NUM_AXIS_GANG("X", "Y",, "I", "J", "K", "U", "V", "W")
7691
#endif
7792
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
7893
"Z"
7994
#endif
80-
#if HAS_MOTOR_CURRENT_PWM_E
81-
"E"
82-
#endif
95+
TERN_(HAS_MOTOR_CURRENT_PWM_E, "E")
8396
)) return M907_report();
8497

8598
if (parser.seenval('S')) for (uint8_t a = 0; a < MOTOR_CURRENT_COUNT; ++a) stepper.set_digipot_current(a, parser.value_int());

Marlin/src/inc/Conditionals-6-type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#endif
3939

4040
// If an axis's Homing Current differs from standard current...
41-
#define HAS_HOME_CURRENT(N) (N##_CURRENT_HOME > 0 && N##_CURRENT_HOME != N##_CURRENT)
41+
#define HAS_HOME_CURRENT(N) TERN0(EDITABLE_HOMING_CURRENT, N##_IS_TRINAMIC && N##_HOME_DIR != 0) || (N##_CURRENT_HOME > 0 && N##_CURRENT_HOME != N##_CURRENT)
4242
#if HAS_HOME_CURRENT(X)
4343
#define X_HAS_HOME_CURRENT 1
4444
#endif

Marlin/src/inc/SanityCheck.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,7 +1890,7 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
18901890
/**
18911891
* ULTIPANEL encoder
18921892
*/
1893-
#if IS_ULTIPANEL && NONE(IS_NEWPANEL, SR_LCD_2W_NL) && !PIN_EXISTS(SHIFT_CLK)
1893+
#if IS_ULTIPANEL && NONE(HAS_ROTARY_ENCODER, SR_LCD_2W_NL, SR_LCD_3W_NL) && !PIN_EXISTS(SHIFT_CLK)
18941894
#error "ULTIPANEL controllers require some kind of encoder."
18951895
#endif
18961896

@@ -4041,11 +4041,11 @@ static_assert(_PLUS_TEST(3), "DEFAULT_MAX_ACCELERATION values must be positive."
40414041
#elif _PIN_CONFLICT(CONTROLLERFAN)
40424042
#error "SPINDLE_LASER_PWM_PIN conflicts with CONTROLLERFAN_PIN."
40434043
#elif _PIN_CONFLICT(MOTOR_CURRENT_PWM_XY)
4044-
#error "SPINDLE_LASER_PWM_PIN conflicts with MOTOR_CURRENT_PWM_XY."
4044+
#error "SPINDLE_LASER_PWM_PIN conflicts with MOTOR_CURRENT_PWM_XY_PIN."
40454045
#elif _PIN_CONFLICT(MOTOR_CURRENT_PWM_Z)
4046-
#error "SPINDLE_LASER_PWM_PIN conflicts with MOTOR_CURRENT_PWM_Z."
4046+
#error "SPINDLE_LASER_PWM_PIN conflicts with MOTOR_CURRENT_PWM_Z_PIN."
40474047
#elif _PIN_CONFLICT(MOTOR_CURRENT_PWM_E)
4048-
#error "SPINDLE_LASER_PWM_PIN conflicts with MOTOR_CURRENT_PWM_E."
4048+
#error "SPINDLE_LASER_PWM_PIN conflicts with MOTOR_CURRENT_PWM_E_PIN."
40494049
#endif
40504050
#endif
40514051
#undef _PIN_CONFLICT

Marlin/src/module/stepper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3673,7 +3673,7 @@ void Stepper::report_positions() {
36733673
#if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM
36743674

36753675
void Stepper::set_digipot_current(const uint8_t driver, const int16_t current) {
3676-
if (WITHIN(driver, 0, MOTOR_CURRENT_COUNT - 1))
3676+
if (WITHIN(driver, 0, COUNT(motor_current_setting) - 1))
36773677
motor_current_setting[driver] = current; // update motor_current_setting
36783678

36793679
if (!initialized) return;

0 commit comments

Comments
 (0)