♻️ Refactor axis counts and loops
This commit is contained in:
committed by
Scott Lahteine
parent
f7d28ce1d6
commit
26a244325b
@ -194,7 +194,7 @@ typedef struct SettingsDataStruct {
|
||||
//
|
||||
// DISTINCT_E_FACTORS
|
||||
//
|
||||
uint8_t esteppers; // XYZE_N - XYZ
|
||||
uint8_t esteppers; // DISTINCT_AXES - LINEAR_AXES
|
||||
|
||||
planner_settings_t planner_settings;
|
||||
|
||||
@ -385,7 +385,7 @@ typedef struct SettingsDataStruct {
|
||||
// HAS_MOTOR_CURRENT_PWM
|
||||
//
|
||||
#ifndef MOTOR_CURRENT_COUNT
|
||||
#define MOTOR_CURRENT_COUNT 3
|
||||
#define MOTOR_CURRENT_COUNT LINEAR_AXES
|
||||
#endif
|
||||
uint32_t motor_current_setting[MOTOR_CURRENT_COUNT]; // M907 X Z E
|
||||
|
||||
@ -516,7 +516,7 @@ void MarlinSettings::postprocess() {
|
||||
#endif
|
||||
|
||||
// Software endstops depend on home_offset
|
||||
LOOP_XYZ(i) {
|
||||
LOOP_LINEAR_AXES(i) {
|
||||
update_workspace_offset((AxisEnum)i);
|
||||
update_software_endstops((AxisEnum)i);
|
||||
}
|
||||
@ -637,9 +637,8 @@ void MarlinSettings::postprocess() {
|
||||
|
||||
working_crc = 0; // clear before first "real data"
|
||||
|
||||
const uint8_t esteppers = COUNT(planner.settings.axis_steps_per_mm) - LINEAR_AXES;
|
||||
_FIELD_TEST(esteppers);
|
||||
|
||||
const uint8_t esteppers = COUNT(planner.settings.axis_steps_per_mm) - XYZ;
|
||||
EEPROM_WRITE(esteppers);
|
||||
|
||||
//
|
||||
@ -1513,16 +1512,16 @@ void MarlinSettings::postprocess() {
|
||||
{
|
||||
// Get only the number of E stepper parameters previously stored
|
||||
// Any steppers added later are set to their defaults
|
||||
uint32_t tmp1[XYZ + esteppers];
|
||||
float tmp2[XYZ + esteppers];
|
||||
feedRate_t tmp3[XYZ + esteppers];
|
||||
uint32_t tmp1[LINEAR_AXES + esteppers];
|
||||
float tmp2[LINEAR_AXES + esteppers];
|
||||
feedRate_t tmp3[LINEAR_AXES + esteppers];
|
||||
EEPROM_READ((uint8_t *)tmp1, sizeof(tmp1)); // max_acceleration_mm_per_s2
|
||||
EEPROM_READ(planner.settings.min_segment_time_us);
|
||||
EEPROM_READ((uint8_t *)tmp2, sizeof(tmp2)); // axis_steps_per_mm
|
||||
EEPROM_READ((uint8_t *)tmp3, sizeof(tmp3)); // max_feedrate_mm_s
|
||||
|
||||
if (!validating) LOOP_XYZE_N(i) {
|
||||
const bool in = (i < esteppers + XYZ);
|
||||
if (!validating) LOOP_DISTINCT_AXES(i) {
|
||||
const bool in = (i < esteppers + LINEAR_AXES);
|
||||
planner.settings.max_acceleration_mm_per_s2[i] = in ? tmp1[i] : pgm_read_dword(&_DMA[ALIM(i, _DMA)]);
|
||||
planner.settings.axis_steps_per_mm[i] = in ? tmp2[i] : pgm_read_float(&_DASU[ALIM(i, _DASU)]);
|
||||
planner.settings.max_feedrate_mm_s[i] = in ? tmp3[i] : pgm_read_float(&_DMF[ALIM(i, _DMF)]);
|
||||
@ -1540,7 +1539,7 @@ void MarlinSettings::postprocess() {
|
||||
EEPROM_READ(dummyf);
|
||||
#endif
|
||||
#else
|
||||
for (uint8_t q = XYZE; q--;) EEPROM_READ(dummyf);
|
||||
for (uint8_t q = LOGICAL_AXES; q--;) EEPROM_READ(dummyf);
|
||||
#endif
|
||||
|
||||
EEPROM_READ(TERN(CLASSIC_JERK, dummyf, planner.junction_deviation_mm));
|
||||
@ -2582,7 +2581,7 @@ void MarlinSettings::postprocess() {
|
||||
* M502 - Reset Configuration
|
||||
*/
|
||||
void MarlinSettings::reset() {
|
||||
LOOP_XYZE_N(i) {
|
||||
LOOP_DISTINCT_AXES(i) {
|
||||
planner.settings.max_acceleration_mm_per_s2[i] = pgm_read_dword(&_DMA[ALIM(i, _DMA)]);
|
||||
planner.settings.axis_steps_per_mm[i] = pgm_read_float(&_DASU[ALIM(i, _DASU)]);
|
||||
planner.settings.max_feedrate_mm_s[i] = pgm_read_float(&_DMF[ALIM(i, _DMF)]);
|
||||
@ -2706,7 +2705,7 @@ void MarlinSettings::reset() {
|
||||
constexpr float dpo[] = NOZZLE_TO_PROBE_OFFSET;
|
||||
static_assert(COUNT(dpo) == 3, "NOZZLE_TO_PROBE_OFFSET must contain offsets for X, Y, and Z.");
|
||||
#if HAS_PROBE_XY_OFFSET
|
||||
LOOP_XYZ(a) probe.offset[a] = dpo[a];
|
||||
LOOP_LINEAR_AXES(a) probe.offset[a] = dpo[a];
|
||||
#else
|
||||
probe.offset.set(0, 0, dpo[Z_AXIS]);
|
||||
#endif
|
||||
@ -3856,7 +3855,7 @@ void MarlinSettings::reset() {
|
||||
);
|
||||
#elif HAS_MOTOR_CURRENT_SPI
|
||||
SERIAL_ECHOPGM(" M907"); // SPI-based has 5 values:
|
||||
LOOP_XYZE(q) { // X Y Z E (map to X Y Z E0 by default)
|
||||
LOOP_LOGICAL_AXES(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]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user