From 5dc96c7324e230664ed181a5539dc5c19d09224a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 10 Oct 2020 12:27:46 -0500 Subject: [PATCH] Use MOTOR_CURRENT_COUNT --- Marlin/src/module/settings.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 00782bff2b..51fc40860b 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -365,11 +365,10 @@ typedef struct SettingsDataStruct { // // HAS_MOTOR_CURRENT_PWM // - #if HAS_MOTOR_CURRENT_SPI - uint32_t motor_current_setting[COUNT(stepper.motor_current_setting)]; - #else - uint32_t motor_current_setting[3]; // M907 X Z E + #ifndef MOTOR_CURRENT_COUNT + #define MOTOR_CURRENT_COUNT 3 #endif + uint32_t motor_current_setting[MOTOR_CURRENT_COUNT]; // M907 X Z E // // CNC_COORDINATE_SYSTEMS @@ -1284,7 +1283,7 @@ void MarlinSettings::postprocess() { #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM EEPROM_WRITE(stepper.motor_current_setting); #else - const uint32_t no_current[3] = { 0 }; + const uint32_t no_current[MOTOR_CURRENT_COUNT] = { 0 }; EEPROM_WRITE(no_current); #endif } @@ -2115,11 +2114,11 @@ void MarlinSettings::postprocess() { // { _FIELD_TEST(motor_current_setting); - #if HAS_MOTOR_CURRENT_SPI - uint32_t motor_current_setting[] = DIGIPOT_MOTOR_CURRENT; - #else - uint32_t motor_current_setting[3]; - #endif + uint32_t motor_current_setting[MOTOR_CURRENT_COUNT] + #if HAS_MOTOR_CURRENT_SPI + = DIGIPOT_MOTOR_CURRENT + #endif + ; DEBUG_ECHOLNPGM("DIGIPOTS Loading"); EEPROM_READ(motor_current_setting); DEBUG_ECHOLNPGM("DIGIPOTS Loaded"); @@ -2801,8 +2800,8 @@ void MarlinSettings::reset() { // #if HAS_MOTOR_CURRENT_PWM - constexpr uint32_t tmp_motor_current_setting[3] = PWM_MOTOR_CURRENT; - LOOP_L_N(q, 3) + constexpr uint32_t tmp_motor_current_setting[MOTOR_CURRENT_COUNT] = PWM_MOTOR_CURRENT; + LOOP_L_N(q, MOTOR_CURRENT_COUNT) stepper.set_digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q])); #endif @@ -3738,7 +3737,7 @@ void MarlinSettings::reset() { ); #elif HAS_MOTOR_CURRENT_SPI SERIAL_ECHOPGM(" M907"); - LOOP_L_N(q, COUNT(stepper.motor_current_setting)) { + LOOP_L_N(q, MOTOR_CURRENT_COUNT) { SERIAL_CHAR(' '); SERIAL_CHAR(axis_codes[q]); SERIAL_ECHO(stepper.motor_current_setting[q]);