From 32ca42ead33cd628d0962dd95f406738218eff5d Mon Sep 17 00:00:00 2001 From: Sten Uusvali <31988255+nuevocampo@users.noreply.github.com> Date: Sat, 17 Oct 2020 14:11:22 -0700 Subject: [PATCH] Fix M503 output for M907 motor current (#19777) Co-authored-by: Scott Lahteine --- Marlin/src/module/settings.cpp | 22 +++++++++++++-------- Marlin/src/module/stepper.cpp | 2 +- Marlin/src/pins/rambo/pins_RAMBO.h | 2 +- Marlin/src/pins/rambo/pins_SCOOVO_X9H.h | 2 +- Marlin/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h | 2 +- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index eac2af38c..f5a954f5d 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3719,19 +3719,25 @@ void MarlinSettings::reset() { CONFIG_ECHO_HEADING("Stepper motor currents:"); CONFIG_ECHO_START(); #if HAS_MOTOR_CURRENT_PWM - SERIAL_ECHOLNPAIR_P( - PSTR(" M907 X"), stepper.motor_current_setting[0] - , SP_Z_STR, stepper.motor_current_setting[1] - , SP_E_STR, stepper.motor_current_setting[2] + SERIAL_ECHOLNPAIR_P( // PWM-based has 3 values: + PSTR(" M907 X"), stepper.motor_current_setting[0] // X and Y + , SP_Z_STR, stepper.motor_current_setting[1] // Z + , SP_E_STR, stepper.motor_current_setting[2] // E ); #elif HAS_MOTOR_CURRENT_SPI - SERIAL_ECHOPGM(" M907"); - LOOP_L_N(q, MOTOR_CURRENT_COUNT) { - SERIAL_CHAR(' '); - SERIAL_CHAR(axis_codes[q]); + SERIAL_ECHOPGM(" M907"); // SPI-based has 5 values: + LOOP_XYZE(q) { // X Y Z E (map to X Y Z E0 by default) + SERIAL_CHAR(' ', axis_codes[q]); SERIAL_ECHO(stepper.motor_current_setting[q]); } + SERIAL_CHAR(' ', 'B'); // B (maps to E1 by default) + SERIAL_ECHOLN(stepper.motor_current_setting[4]); #endif + #elif HAS_MOTOR_CURRENT_I2C // i2c-based has any number of values + // Values sent over i2c are not stored. + // Indexes map directly to drivers, not axes. + #elif HAS_MOTOR_CURRENT_DAC // DAC-based has 4 values, for X Y Z E + // Values sent over i2c are not stored. Uses indirect mapping. #endif /** diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 7b3e13eff..0a83a90ba 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2962,7 +2962,7 @@ void Stepper::report_positions() { #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM void Stepper::set_digipot_current(const uint8_t driver, const int16_t current) { - if (WITHIN(driver, 0, COUNT(motor_current_setting) - 1)) + if (WITHIN(driver, 0, MOTOR_CURRENT_COUNT - 1)) motor_current_setting[driver] = current; // update motor_current_setting if (!initialized) return; diff --git a/Marlin/src/pins/rambo/pins_RAMBO.h b/Marlin/src/pins/rambo/pins_RAMBO.h index 0254edea2..62e7565c1 100644 --- a/Marlin/src/pins/rambo/pins_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_RAMBO.h @@ -112,7 +112,7 @@ #define E1_MS2_PIN 64 #define DIGIPOTSS_PIN 38 -#define DIGIPOT_CHANNELS { 4,5,3,0,1 } // X Y Z E0 E1 digipot channels to stepper driver mapping +#define DIGIPOT_CHANNELS { 4, 5, 3, 0, 1 } // X Y Z E0 E1 digipot channels to stepper driver mapping #ifndef DIGIPOT_MOTOR_CURRENT #define DIGIPOT_MOTOR_CURRENT { 135,135,135,135,135 } // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) #endif diff --git a/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h b/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h index 4af38e1de..5680b00df 100644 --- a/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h +++ b/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h @@ -92,7 +92,7 @@ #define E1_MS2_PIN 64 #define DIGIPOTSS_PIN 38 -#define DIGIPOT_CHANNELS {4,5,3,0,1} // X Y Z E0 E1 digipot channels to stepper driver mapping +#define DIGIPOT_CHANNELS { 4, 5, 3, 0, 1 } // X Y Z E0 E1 digipot channels to stepper driver mapping // // Temperature Sensors diff --git a/Marlin/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h b/Marlin/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h index 967fec7b4..f120e9c44 100644 --- a/Marlin/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h +++ b/Marlin/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h @@ -85,7 +85,7 @@ // Steppers // #define DIGIPOTSS_PIN 22 -#define DIGIPOT_CHANNELS { 4, 5, 3, 0, 1 } +#define DIGIPOT_CHANNELS { 4, 5, 3, 0, 1 } // // Temperature Sensors