From e612a49d14fdd1a49d4edba1d967dd8e082ea17b Mon Sep 17 00:00:00 2001 From: classicrocker883 Date: Thu, 29 Aug 2024 14:27:04 -0400 Subject: [PATCH 1/6] remove extras --- Marlin/src/inc/Conditionals_axes.h | 211 ++++------------------------- 1 file changed, 29 insertions(+), 182 deletions(-) diff --git a/Marlin/src/inc/Conditionals_axes.h b/Marlin/src/inc/Conditionals_axes.h index 5a79d2f3eb97..c46499b9d825 100644 --- a/Marlin/src/inc/Conditionals_axes.h +++ b/Marlin/src/inc/Conditionals_axes.h @@ -46,6 +46,26 @@ #else #undef EXTRUDERS #define EXTRUDERS 0 + #undef TEMP_SENSOR_0 + #undef TEMP_SENSOR_1 + #undef TEMP_SENSOR_2 + #undef TEMP_SENSOR_3 + #undef TEMP_SENSOR_4 + #undef TEMP_SENSOR_5 + #undef TEMP_SENSOR_6 + #undef TEMP_SENSOR_7 + #undef SINGLENOZZLE + #undef SWITCHING_EXTRUDER + #undef MECHANICAL_SWITCHING_EXTRUDER + #undef SWITCHING_NOZZLE + #undef MECHANICAL_SWITCHING_NOZZLE + #undef MIXING_EXTRUDER + #undef HOTEND_IDLE_TIMEOUT + #undef DISABLE_E + #undef PREVENT_LENGTHY_EXTRUDE + #undef FILAMENT_RUNOUT_SENSOR + #undef FILAMENT_RUNOUT_DISTANCE_MM + #undef DISABLE_OTHER_EXTRUDERS #endif #define E_OPTARG(N) OPTARG(HAS_MULTI_EXTRUDER, N) @@ -162,6 +182,11 @@ #ifndef HOTEND_OVERSHOOT #define HOTEND_OVERSHOOT 15 #endif +#else + #undef MPCTEMP + #undef PIDTEMP + #undef PREVENT_COLD_EXTRUSION + #undef THERMAL_PROTECTION_HOTENDS #endif // More than one hotend... @@ -177,6 +202,10 @@ #ifndef HOTEND_OFFSET_Z #define HOTEND_OFFSET_Z { 0 } // Z offsets for each extruder #endif +#else + #undef HOTEND_OFFSET_X + #undef HOTEND_OFFSET_Y + #undef HOTEND_OFFSET_Z #endif /** @@ -514,185 +543,3 @@ #define ARRAY_BY_EXTRUDERS1(v1) ARRAY_N_1(EXTRUDERS, v1) #define ARRAY_BY_HOTENDS(V...) ARRAY_N(HOTENDS, V) #define ARRAY_BY_HOTENDS1(v1) ARRAY_N_1(HOTENDS, v1) - -/** - * Extruders have some combination of stepper motors and hotends - * so we separate these concepts into the defines: - * - * EXTRUDERS - Number of Selectable Tools - * HOTENDS - Number of hotends, whether connected or separate - * E_STEPPERS - Number of actual E stepper motors - * E_MANUAL - Number of E steppers for LCD move options - * - * These defines must be simple constants for use in REPEAT, etc. - */ -#if EXTRUDERS - #define HAS_EXTRUDERS 1 - #if EXTRUDERS > 1 - #define HAS_MULTI_EXTRUDER 1 - #endif - #define E_AXIS_N(E) AxisEnum(E_AXIS + E_INDEX_N(E)) -#else - #undef EXTRUDERS - #define EXTRUDERS 0 - #undef TEMP_SENSOR_0 - #undef TEMP_SENSOR_1 - #undef TEMP_SENSOR_2 - #undef TEMP_SENSOR_3 - #undef TEMP_SENSOR_4 - #undef TEMP_SENSOR_5 - #undef TEMP_SENSOR_6 - #undef TEMP_SENSOR_7 - #undef SINGLENOZZLE - #undef SWITCHING_EXTRUDER - #undef MECHANICAL_SWITCHING_EXTRUDER - #undef SWITCHING_NOZZLE - #undef MECHANICAL_SWITCHING_NOZZLE - #undef MIXING_EXTRUDER - #undef HOTEND_IDLE_TIMEOUT - #undef DISABLE_E - #undef PREVENT_LENGTHY_EXTRUDE - #undef FILAMENT_RUNOUT_SENSOR - #undef FILAMENT_RUNOUT_DISTANCE_MM - #undef DISABLE_OTHER_EXTRUDERS -#endif - -#define E_OPTARG(N) OPTARG(HAS_MULTI_EXTRUDER, N) -#define E_TERN_(N) TERN_(HAS_MULTI_EXTRUDER, N) -#define E_TERN0(N) TERN0(HAS_MULTI_EXTRUDER, N) - -#if ANY(SWITCHING_EXTRUDER, MECHANICAL_SWITCHING_EXTRUDER) - #define HAS_SWITCHING_EXTRUDER 1 -#endif -#if ANY(SWITCHING_NOZZLE, MECHANICAL_SWITCHING_NOZZLE) - #define HAS_SWITCHING_NOZZLE 1 -#endif - -/** - * Multi-Material-Unit supported models - */ -#ifdef MMU_MODEL - #define HAS_MMU 1 - #define SINGLENOZZLE - - #define _PRUSA_MMU1 1 - #define _PRUSA_MMU2 2 - #define _PRUSA_MMU2S 3 - #define _PRUSA_MMU3 4 - #define _EXTENDABLE_EMU_MMU2 12 - #define _EXTENDABLE_EMU_MMU2S 13 - #define _EXTENDABLE_EMU_MMU3 14 - #define _MMU CAT(_,MMU_MODEL) - - #if _MMU == _PRUSA_MMU1 - #define HAS_PRUSA_MMU1 1 - #elif _MMU % 10 == _PRUSA_MMU2 - #define HAS_PRUSA_MMU2 1 - #elif _MMU % 10 == _PRUSA_MMU2S - #define HAS_PRUSA_MMU2 1 - #define HAS_PRUSA_MMU2S 1 - #elif _MMU % 10 == _PRUSA_MMU3 - #define HAS_PRUSA_MMU3 1 - #endif - #if _MMU == _EXTENDABLE_EMU_MMU2 || _MMU == _EXTENDABLE_EMU_MMU2S - #define HAS_EXTENDABLE_MMU 1 - #endif - - #undef _MMU - #undef _PRUSA_MMU1 - #undef _PRUSA_MMU2 - #undef _PRUSA_MMU2S - #undef _PRUSA_MMU3 - #undef _EXTENDABLE_EMU_MMU2 - #undef _EXTENDABLE_EMU_MMU2S - #undef _EXTENDABLE_EMU_MMU3 -#endif - -#if ENABLED(E_DUAL_STEPPER_DRIVERS) // E0/E1 steppers act in tandem as E0 - - #define E_STEPPERS 2 - #define E_MANUAL 1 - -#elif HAS_SWITCHING_EXTRUDER // One stepper for every two EXTRUDERS - - #if EXTRUDERS > 4 - #define E_STEPPERS 3 - #elif EXTRUDERS > 2 - #define E_STEPPERS 2 - #else - #define E_STEPPERS 1 - #endif - -#elif ENABLED(MIXING_EXTRUDER) // Multiple feeds are mixed proportionally - - #define E_STEPPERS MIXING_STEPPERS - #define E_MANUAL 1 - #if MIXING_STEPPERS == 2 - #define HAS_DUAL_MIXING 1 - #endif - #ifndef MIXING_VIRTUAL_TOOLS - #define MIXING_VIRTUAL_TOOLS 1 - #endif - -#elif ENABLED(SWITCHING_TOOLHEAD) // Toolchanger - - #define E_STEPPERS EXTRUDERS - #define E_MANUAL EXTRUDERS - -#elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU3 // Průša Multi-Material Unit v2/v3 - - #define E_STEPPERS 1 - #define E_MANUAL 1 - -#endif - -// Default E steppers / manual motion is one per extruder -#ifndef E_STEPPERS - #define E_STEPPERS EXTRUDERS -#endif -#ifndef E_MANUAL - #define E_MANUAL EXTRUDERS -#endif - -// Number of hotends... -#if ANY(SINGLENOZZLE, MIXING_EXTRUDER) // Only one for singlenozzle or mixing extruder - #define HOTENDS 1 -#elif HAS_SWITCHING_EXTRUDER && !HAS_SWITCHING_NOZZLE // One for each pair of abstract "extruders" - #define HOTENDS E_STEPPERS -#elif TEMP_SENSOR_0 - #define HOTENDS EXTRUDERS // One per extruder if at least one heater exists -#else - #define HOTENDS 0 // A machine with no hotends at all can still extrude -#endif - -// At least one hotend... -#if HOTENDS - #define HAS_HOTEND 1 - #ifndef HOTEND_OVERSHOOT - #define HOTEND_OVERSHOOT 15 - #endif -#else - #undef MPCTEMP - #undef PIDTEMP - #undef PREVENT_COLD_EXTRUSION - #undef THERMAL_PROTECTION_HOTENDS -#endif - -// More than one hotend... -#if HOTENDS > 1 - #define HAS_MULTI_HOTEND 1 - #define HAS_HOTEND_OFFSET 1 - #ifndef HOTEND_OFFSET_X - #define HOTEND_OFFSET_X { 0 } // X offsets for each extruder - #endif - #ifndef HOTEND_OFFSET_Y - #define HOTEND_OFFSET_Y { 0 } // Y offsets for each extruder - #endif - #ifndef HOTEND_OFFSET_Z - #define HOTEND_OFFSET_Z { 0 } // Z offsets for each extruder - #endif -#else - #undef HOTEND_OFFSET_X - #undef HOTEND_OFFSET_Y - #undef HOTEND_OFFSET_Z -#endif From 5111c31790bb58c78c7f856b17c48ed0af13f281 Mon Sep 17 00:00:00 2001 From: classicrocker883 Date: Sun, 1 Sep 2024 02:30:13 -0400 Subject: [PATCH 2/6] remove double nested UBL --- Marlin/src/module/settings.cpp | 133 ++++++++++++++------------------- 1 file changed, 58 insertions(+), 75 deletions(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 52057ceab51e..84d3ac4a3e13 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3120,96 +3120,79 @@ void MarlinSettings::postprocess() { } void MarlinSettings::store_mesh(const int8_t slot) { + const int16_t a = calc_num_meshes(); + if (!WITHIN(slot, 0, a - 1)) { + ubl_invalid_slot(a); + DEBUG_ECHOLNPGM("E2END=", persistentStore.capacity() - 1, " meshes_end=", meshes_end, " slot=", slot); + DEBUG_EOL(); + return; + } - #if ENABLED(AUTO_BED_LEVELING_UBL) - const int16_t a = calc_num_meshes(); - if (!WITHIN(slot, 0, a - 1)) { - ubl_invalid_slot(a); - DEBUG_ECHOLNPGM("E2END=", persistentStore.capacity() - 1, " meshes_end=", meshes_end, " slot=", slot); - DEBUG_EOL(); - return; - } - - int pos = mesh_slot_offset(slot); - uint16_t crc = 0; - - #if ENABLED(OPTIMIZED_MESH_STORAGE) - int16_t z_mesh_store[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; - bedlevel.set_store_from_mesh(bedlevel.z_values, z_mesh_store); - uint8_t * const src = (uint8_t*)&z_mesh_store; - #else - uint8_t * const src = (uint8_t*)&bedlevel.z_values; - #endif - - // Write crc to MAT along with other data, or just tack on to the beginning or end - persistentStore.access_start(); - const bool status = persistentStore.write_data(pos, src, MESH_STORE_SIZE, &crc); - persistentStore.access_finish(); - - if (status) SERIAL_ECHOLNPGM("?Unable to save mesh data."); - else DEBUG_ECHOLNPGM("Mesh saved in slot ", slot); + int pos = mesh_slot_offset(slot); + uint16_t crc = 0; + #if ENABLED(OPTIMIZED_MESH_STORAGE) + int16_t z_mesh_store[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; + bedlevel.set_store_from_mesh(bedlevel.z_values, z_mesh_store); + uint8_t * const src = (uint8_t*)&z_mesh_store; #else + uint8_t * const src = (uint8_t*)&bedlevel.z_values; + #endif - // Other mesh types + // Write crc to MAT along with other data, or just tack on to the beginning or end + persistentStore.access_start(); + const bool status = persistentStore.write_data(pos, src, MESH_STORE_SIZE, &crc); + persistentStore.access_finish(); - #endif + if (status) SERIAL_ECHOLNPGM("?Unable to save mesh data."); + else DEBUG_ECHOLNPGM("Mesh saved in slot ", slot); } void MarlinSettings::load_mesh(const int8_t slot, void * const into/*=nullptr*/) { + const int16_t a = settings.calc_num_meshes(); - #if ENABLED(AUTO_BED_LEVELING_UBL) - - const int16_t a = settings.calc_num_meshes(); - - if (!WITHIN(slot, 0, a - 1)) { - ubl_invalid_slot(a); - return; - } - - int pos = mesh_slot_offset(slot); - uint16_t crc = 0; - #if ENABLED(OPTIMIZED_MESH_STORAGE) - int16_t z_mesh_store[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; - uint8_t * const dest = (uint8_t*)&z_mesh_store; - #else - uint8_t * const dest = into ? (uint8_t*)into : (uint8_t*)&bedlevel.z_values; - #endif - - persistentStore.access_start(); - uint16_t status = persistentStore.read_data(pos, dest, MESH_STORE_SIZE, &crc); - persistentStore.access_finish(); - - #if ENABLED(OPTIMIZED_MESH_STORAGE) - if (into) { - float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; - bedlevel.set_mesh_from_store(z_mesh_store, z_values); - memcpy(into, z_values, sizeof(z_values)); - } - else - bedlevel.set_mesh_from_store(z_mesh_store, bedlevel.z_values); - #endif + if (!WITHIN(slot, 0, a - 1)) { + ubl_invalid_slot(a); + return; + } - #if ENABLED(DWIN_LCD_PROUI) - status = !bedLevelTools.meshValidate(); - if (status) { - bedlevel.invalidate(); - LCD_MESSAGE(MSG_UBL_MESH_INVALID); - } - else - ui.status_printf(0, GET_TEXT_F(MSG_MESH_LOADED), bedlevel.storage_slot); - #endif + int pos = mesh_slot_offset(slot); + uint16_t crc = 0; + #if ENABLED(OPTIMIZED_MESH_STORAGE) + int16_t z_mesh_store[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; + uint8_t * const dest = (uint8_t*)&z_mesh_store; + #else + uint8_t * const dest = into ? (uint8_t*)into : (uint8_t*)&bedlevel.z_values; + #endif - if (status) SERIAL_ECHOLNPGM("?Unable to load mesh data."); - else DEBUG_ECHOLNPGM("Mesh loaded from slot ", slot); + persistentStore.access_start(); + uint16_t status = persistentStore.read_data(pos, dest, MESH_STORE_SIZE, &crc); + persistentStore.access_finish(); - EEPROM_FINISH(); + #if ENABLED(OPTIMIZED_MESH_STORAGE) + if (into) { + float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; + bedlevel.set_mesh_from_store(z_mesh_store, z_values); + memcpy(into, z_values, sizeof(z_values)); + } + else + bedlevel.set_mesh_from_store(z_mesh_store, bedlevel.z_values); + #endif - #else + #if ENABLED(DWIN_LCD_PROUI) + status = !bedLevelTools.meshValidate(); + if (status) { + bedlevel.invalidate(); + LCD_MESSAGE(MSG_UBL_MESH_INVALID); + } + else + ui.status_printf(0, GET_TEXT_F(MSG_MESH_LOADED), bedlevel.storage_slot); + #endif - // Other mesh types + if (status) SERIAL_ECHOLNPGM("?Unable to load mesh data."); + else DEBUG_ECHOLNPGM("Mesh loaded from slot ", slot); - #endif + EEPROM_FINISH(); } //void MarlinSettings::delete_mesh() { return; } From ef05e0e50fa4c446e21e6af33aedeb636929d482 Mon Sep 17 00:00:00 2001 From: classicrocker883 Date: Tue, 15 Oct 2024 09:56:21 -0400 Subject: [PATCH 3/6] add vector --- Marlin/tests/core/test_macros.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/tests/core/test_macros.cpp b/Marlin/tests/core/test_macros.cpp index bb269dec2b40..efe450f42e27 100644 --- a/Marlin/tests/core/test_macros.cpp +++ b/Marlin/tests/core/test_macros.cpp @@ -22,6 +22,7 @@ #include "../test/unit_tests.h" #include +#include // These represent enabled and disabled configuration options for testing. // They will be used by multiple tests. From dc61964f40ae5bd6eef26ae88dde7af5d71ed964 Mon Sep 17 00:00:00 2001 From: classicrocker883 Date: Tue, 15 Oct 2024 10:09:05 -0400 Subject: [PATCH 4/6] include array --- Marlin/tests/core/test_macros.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/tests/core/test_macros.cpp b/Marlin/tests/core/test_macros.cpp index efe450f42e27..35a7c92537b6 100644 --- a/Marlin/tests/core/test_macros.cpp +++ b/Marlin/tests/core/test_macros.cpp @@ -23,6 +23,7 @@ #include "../test/unit_tests.h" #include #include +#include // These represent enabled and disabled configuration options for testing. // They will be used by multiple tests. From fdb3f00de53216ac4fbc7afbdb346204ffd6f61d Mon Sep 17 00:00:00 2001 From: classicrocker883 Date: Sun, 20 Oct 2024 02:36:16 -0400 Subject: [PATCH 5/6] revert array --- Marlin/tests/core/test_macros.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/tests/core/test_macros.cpp b/Marlin/tests/core/test_macros.cpp index 35a7c92537b6..efe450f42e27 100644 --- a/Marlin/tests/core/test_macros.cpp +++ b/Marlin/tests/core/test_macros.cpp @@ -23,7 +23,6 @@ #include "../test/unit_tests.h" #include #include -#include // These represent enabled and disabled configuration options for testing. // They will be used by multiple tests. From ec3828dd040dcd87125a62bd393692ef070e1d9c Mon Sep 17 00:00:00 2001 From: Andrew <18502096+classicrocker883@users.noreply.github.com> Date: Wed, 13 Nov 2024 04:37:53 -0500 Subject: [PATCH 6/6] revert test_macros.cpp --- Marlin/tests/core/test_macros.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/tests/core/test_macros.cpp b/Marlin/tests/core/test_macros.cpp index efe450f42e27..bb269dec2b40 100644 --- a/Marlin/tests/core/test_macros.cpp +++ b/Marlin/tests/core/test_macros.cpp @@ -22,7 +22,6 @@ #include "../test/unit_tests.h" #include -#include // These represent enabled and disabled configuration options for testing. // They will be used by multiple tests.