From ebb75a529b8f9d3b53dac12ffc6301d515a1cdaa Mon Sep 17 00:00:00 2001 From: ekef <62036680+ekef@users.noreply.github.com> Date: Sun, 16 May 2021 02:22:30 +0300 Subject: [PATCH 01/61] Fix MKS Robin E3 BLTOUCH and Fan PWM timer conflicts (#21889) --- Marlin/src/HAL/STM32F1/timers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/HAL/STM32F1/timers.h b/Marlin/src/HAL/STM32F1/timers.h index 63ddfb9e60c3..38a0fc7fa1e9 100644 --- a/Marlin/src/HAL/STM32F1/timers.h +++ b/Marlin/src/HAL/STM32F1/timers.h @@ -80,7 +80,7 @@ typedef uint16_t hal_timer_t; //#define TEMP_TIMER_NUM 4 // 2->4, Timer 2 for Stepper Current PWM #endif -#if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_E3_DIP, BTT_SKR_MINI_E3_V1_2, MKS_ROBIN_LITE) +#if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_E3_DIP, BTT_SKR_MINI_E3_V1_2, MKS_ROBIN_LITE, MKS_ROBIN_E3D, MKS_ROBIN_E3) // SKR Mini E3 boards use PA8 as FAN_PIN, so TIMER 1 is used for Fan PWM. #ifdef STM32_HIGH_DENSITY #define SERVO0_TIMER_NUM 8 // tone.cpp uses Timer 4 From 9c61e6f1c0b1cb003f440fb4410faaa371764a1e Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 17 May 2021 01:06:01 +0000 Subject: [PATCH 02/61] [cron] Bump distribution date (2021-05-17) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 90bd9f080ff5..8fff7dcc1773 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-05-16" + #define STRING_DISTRIBUTION_DATE "2021-05-17" #endif /** From c3a65eef7a4e62ee3db0ff672ccb94acfc896a34 Mon Sep 17 00:00:00 2001 From: ellensp Date: Tue, 18 May 2021 11:22:33 +1200 Subject: [PATCH 03/61] Fix envs using mks_encrypt.py (#21933) Fix #21928 --- buildroot/share/PlatformIO/scripts/mks_encrypt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/share/PlatformIO/scripts/mks_encrypt.py b/buildroot/share/PlatformIO/scripts/mks_encrypt.py index 78d7cf349db9..0c622704e75c 100644 --- a/buildroot/share/PlatformIO/scripts/mks_encrypt.py +++ b/buildroot/share/PlatformIO/scripts/mks_encrypt.py @@ -17,7 +17,7 @@ # Encrypt ${PROGNAME}.bin and save it as build.firmware def encrypt(source, target, env): - marlin.encrypt_mks(source, target, env, "build.firmware") + marlin.encrypt_mks(source, target, env, board.get("build.firmware")) marlin.add_post_action(encrypt); From 4d7feea72e1164da2bb0941e978e63a42bcabcf0 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 18 May 2021 01:09:42 +0000 Subject: [PATCH 04/61] [cron] Bump distribution date (2021-05-18) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 8fff7dcc1773..708f130e4007 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-05-17" + #define STRING_DISTRIBUTION_DATE "2021-05-18" #endif /** From 1e189506effcf6be1e681cedb396b0574a9f109e Mon Sep 17 00:00:00 2001 From: ellensp Date: Tue, 18 May 2021 14:16:47 +1200 Subject: [PATCH 05/61] Fix EEPROM_CHITCHAT (#21934) Fix #21929 --- Marlin/src/module/settings.cpp | 35 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 9d65bbb7449a..2b20bba4fbee 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -584,7 +584,11 @@ void MarlinSettings::postprocess() { "ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE is insufficient to capture all EEPROM data."); #endif -#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) +// +// This file simply uses the DEBUG_ECHO macros to implement EEPROM_CHITCHAT. +// For deeper debugging of EEPROM issues enable DEBUG_EEPROM_READWRITE. +// +#define DEBUG_OUT EITHER(EEPROM_CHITCHAT, DEBUG_LEVELING_FEATURE) #include "../core/debug_out.h" #if ENABLED(EEPROM_SETTINGS) @@ -1450,8 +1454,7 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(final_crc); // Report storage size - DEBUG_ECHO_START(); - DEBUG_ECHOLNPAIR("Settings Stored (", eeprom_size, " bytes; crc ", (uint32_t)final_crc, ")"); + DEBUG_ECHO_MSG("Settings Stored (", eeprom_size, " bytes; crc ", (uint32_t)final_crc, ")"); eeprom_error |= size_error(eeprom_size); } @@ -1490,8 +1493,7 @@ void MarlinSettings::postprocess() { stored_ver[0] = '?'; stored_ver[1] = '\0'; } - DEBUG_ECHO_START(); - DEBUG_ECHOLNPAIR("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")"); + DEBUG_ECHO_MSG("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")"); IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_version()); eeprom_error = true; } @@ -2186,9 +2188,13 @@ void MarlinSettings::postprocess() { = DIGIPOT_MOTOR_CURRENT #endif ; - DEBUG_ECHOLNPGM("DIGIPOTS Loading"); + #if HAS_MOTOR_CURRENT_SPI + DEBUG_ECHO_MSG("DIGIPOTS Loading"); + #endif EEPROM_READ(motor_current_setting); - DEBUG_ECHOLNPGM("DIGIPOTS Loaded"); + #if HAS_MOTOR_CURRENT_SPI + DEBUG_ECHO_MSG("DIGIPOTS Loaded"); + #endif #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM if (!validating) COPY(stepper.motor_current_setting, motor_current_setting); @@ -2357,14 +2363,12 @@ void MarlinSettings::postprocess() { // eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET)); if (eeprom_error) { - DEBUG_ECHO_START(); - DEBUG_ECHOLNPAIR("Index: ", eeprom_index - (EEPROM_OFFSET), " Size: ", datasize()); + DEBUG_ECHO_MSG("Index: ", eeprom_index - (EEPROM_OFFSET), " Size: ", datasize()); IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_index()); } else if (working_crc != stored_crc) { eeprom_error = true; - DEBUG_ERROR_START(); - DEBUG_ECHOLNPAIR("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!"); + DEBUG_ERROR_MSG("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!"); IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_crc()); } else if (!validating) { @@ -2454,13 +2458,8 @@ void MarlinSettings::postprocess() { #if ENABLED(AUTO_BED_LEVELING_UBL) inline void ubl_invalid_slot(const int s) { - #if BOTH(EEPROM_CHITCHAT, DEBUG_OUT) - DEBUG_ECHOLNPGM("?Invalid slot."); - DEBUG_ECHO(s); - DEBUG_ECHOLNPGM(" mesh slots available."); - #else - UNUSED(s); - #endif + DEBUG_ECHOLNPAIR("?Invalid slot.\n", s, " mesh slots available."); + UNUSED(s); } const uint16_t MarlinSettings::meshes_end = persistentStore.capacity() - 129; // 128 (+1 because of the change to capacity rather than last valid address) From ad8c16177e825c20c8868ac2d440762451d29c60 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 17 May 2021 21:17:22 -0500 Subject: [PATCH 06/61] Use defined strings --- Marlin/src/lcd/extui/mks_ui/wifi_module.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp index be693a748fc9..a9ad9c189c4a 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp @@ -621,9 +621,9 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { if (tmpStr == 0) { gCfgItems.fileSysType = FILE_SYS_SD; - send_to_wifi((uint8_t *)"Begin file list\r\n", strlen("Begin file list\r\n")); + send_to_wifi((uint8_t *)(STR_BEGIN_FILE_LIST "\r\n"), strlen(STR_BEGIN_FILE_LIST "\r\n")); get_file_list((char *)"0:/"); - send_to_wifi((uint8_t *)"End file list\r\n", strlen("End file list\r\n")); + send_to_wifi((uint8_t *)(STR_END_FILE_LIST "\r\n"), strlen(STR_END_FILE_LIST "\r\n")); SEND_OK_TO_WIFI; break; } @@ -634,7 +634,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { char *path = (char *)tempBuf; if (strlen((char *)&tmpStr[index]) < 80) { - send_to_wifi((uint8_t *)"Begin file list\r\n", strlen("Begin file list\r\n")); + send_to_wifi((uint8_t *)(STR_BEGIN_FILE_LIST "\r\n"), strlen(STR_BEGIN_FILE_LIST "\r\n")); if (strncmp((char *)&tmpStr[index], "1:", 2) == 0) gCfgItems.fileSysType = FILE_SYS_SD; @@ -643,7 +643,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { strcpy((char *)path, (char *)&tmpStr[index]); get_file_list(path); - send_to_wifi((uint8_t *)"End file list\r\n", strlen("End file list\r\n")); + send_to_wifi((uint8_t *)(STR_END_FILE_LIST "\r\n"), strlen(STR_END_FILE_LIST "\r\n")); } SEND_OK_TO_WIFI; } From 90f46d12268ad96659380a15304a3eb7132ae615 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 19 May 2021 01:05:23 +0000 Subject: [PATCH 07/61] [cron] Bump distribution date (2021-05-19) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 708f130e4007..2d6d17e6fa35 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-05-18" + #define STRING_DISTRIBUTION_DATE "2021-05-19" #endif /** From 419d67237cc7afecd42ad4d8083b8008350c4ce0 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 20 May 2021 01:03:10 +0000 Subject: [PATCH 08/61] [cron] Bump distribution date (2021-05-20) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 2d6d17e6fa35..4bb0f19a8a37 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-05-19" + #define STRING_DISTRIBUTION_DATE "2021-05-20" #endif /** From 50355f46074fe0b1f64bd8700086f30b90cc7c8f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 19 May 2021 22:02:28 -0500 Subject: [PATCH 09/61] Fix 'G29 K' value --- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 6f1425b60c5c..b5773b0d4604 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -581,7 +581,7 @@ void unified_bed_leveling::G29() { // use cases for the users. So we can wait and see what to do with it. // - if (parser.seen_test('K')) // Kompare Current Mesh Data to Specified Stored Mesh + if (parser.seen('K')) // Kompare Current Mesh Data to Specified Stored Mesh g29_compare_current_mesh_to_stored_mesh(); #endif // UBL_DEVEL_DEBUGGING From abbe3f0dc7aa23bae4aa26f6d6b09a4a0665a1a0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 18 May 2021 22:46:59 -0500 Subject: [PATCH 10/61] =?UTF-8?q?=F0=9F=8E=A8=20Misc=20cleanup=20and=20fix?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/debug_section.h | 2 +- Marlin/src/core/language.h | 16 +++---- Marlin/src/core/serial.cpp | 2 +- Marlin/src/core/serial.h | 10 ++-- Marlin/src/core/types.h | 20 ++++---- Marlin/src/gcode/calibrate/G425.cpp | 36 +++++++-------- Marlin/src/gcode/config/M200-M205.cpp | 32 +++++-------- Marlin/src/gcode/config/M92.cpp | 9 ++-- Marlin/src/gcode/control/M17_M18_M84.cpp | 16 +++---- Marlin/src/gcode/control/M211.cpp | 4 +- .../src/gcode/feature/trinamic/M911-M914.cpp | 46 ++++++++----------- Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/gcode/host/M114.cpp | 22 ++++----- Marlin/src/gcode/motion/G0_G1.cpp | 2 +- Marlin/src/gcode/motion/G2_G3.cpp | 8 ++-- Marlin/src/gcode/parser.cpp | 2 +- Marlin/src/gcode/parser.h | 2 +- Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/inc/SanityCheck.h | 2 +- Marlin/src/lcd/extui/dgus/dgus_extui.cpp | 1 + Marlin/src/lcd/extui/ui_api.cpp | 12 ++--- Marlin/src/lcd/menu/menu_mmu2.cpp | 3 +- Marlin/src/module/endstops.cpp | 4 +- Marlin/src/module/motion.cpp | 20 ++++---- Marlin/src/module/settings.cpp | 4 +- Marlin/src/module/stepper/trinamic.cpp | 2 +- 26 files changed, 125 insertions(+), 156 deletions(-) diff --git a/Marlin/src/core/debug_section.h b/Marlin/src/core/debug_section.h index 2862d35af132..ef1511e6f082 100644 --- a/Marlin/src/core/debug_section.h +++ b/Marlin/src/core/debug_section.h @@ -44,6 +44,6 @@ class SectionLog { SERIAL_ECHOPGM_P(the_msg); } SERIAL_CHAR(' '); - print_xyz(current_position); + print_pos(current_position); } }; diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index de29535f8795..cabdde983b51 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -277,14 +277,6 @@ #define STR_REMINDER_SAVE_SETTINGS "Remember to save!" #define STR_PASSWORD_SET "Password is " -// LCD Menu Messages - -#define LANGUAGE_DATA_INCL_(M) STRINGIFY_(fontdata/langdata_##M.h) -#define LANGUAGE_DATA_INCL(M) LANGUAGE_DATA_INCL_(M) - -#define LANGUAGE_INCL_(M) STRINGIFY_(../lcd/language/language_##M.h) -#define LANGUAGE_INCL(M) LANGUAGE_INCL_(M) - #define STR_X "X" #define STR_Y "Y" #define STR_Z "Z" @@ -386,6 +378,14 @@ #define LCD_STR_E6 "E" LCD_STR_N6 #define LCD_STR_E7 "E" LCD_STR_N7 +// Include localized LCD Menu Messages + +#define LANGUAGE_DATA_INCL_(M) STRINGIFY_(fontdata/langdata_##M.h) +#define LANGUAGE_DATA_INCL(M) LANGUAGE_DATA_INCL_(M) + +#define LANGUAGE_INCL_(M) STRINGIFY_(../lcd/language/language_##M.h) +#define LANGUAGE_INCL(M) LANGUAGE_INCL_(M) + // Use superscripts, if possible. Evaluated at point of use. #define SUPERSCRIPT_TWO TERN(NOT_EXTENDED_ISO10646_1_5X7, "^2", "²") #define SUPERSCRIPT_THREE TERN(NOT_EXTENDED_ISO10646_1_5X7, "^3", "³") diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 28442594ce55..b4184fcd623b 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -101,7 +101,7 @@ void print_bin(uint16_t val) { } } -void print_xyz(const_float_t x, const_float_t y, const_float_t z, PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) { +void print_pos(const_float_t x, const_float_t y, const_float_t z, PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) { if (prefix) serialprintPGM(prefix); SERIAL_ECHOPAIR_P(SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z); if (suffix) serialprintPGM(suffix); else SERIAL_EOL(); diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 5c08be5c92ca..74b96dbb6476 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -310,11 +310,11 @@ void serialprint_truefalse(const bool tf); void serial_spaces(uint8_t count); void print_bin(const uint16_t val); -void print_xyz(const_float_t x, const_float_t y, const_float_t z, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr); +void print_pos(const_float_t x, const_float_t y, const_float_t z, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr); -inline void print_xyz(const xyz_pos_t &xyz, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr) { - print_xyz(xyz.x, xyz.y, xyz.z, prefix, suffix); +inline void print_pos(const xyz_pos_t &xyz, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr) { + print_pos(xyz.x, xyz.y, xyz.z, prefix, suffix); } -#define SERIAL_POS(SUFFIX,VAR) do { print_xyz(VAR, PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n")); }while(0) -#define SERIAL_XYZ(PREFIX,V...) do { print_xyz(V, PSTR(PREFIX), nullptr); }while(0) +#define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n")); }while(0) +#define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, PSTR(PREFIX), nullptr); }while(0) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 79a79b739b8c..4011473aa07a 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -29,6 +29,16 @@ class __FlashStringHelper; typedef const __FlashStringHelper *progmem_str; +// +// Conditional type assignment magic. For example... +// +// typename IF<(MYOPT==12), int, float>::type myvar; +// +template +struct IF { typedef R type; }; +template +struct IF { typedef L type; }; + // // Enumerated axis indices // @@ -57,16 +67,6 @@ enum AxisEnum : uint8_t { #define LOOP_ABCE(VAR) LOOP_S_LE_N(VAR, A_AXIS, E_AXIS) #define LOOP_ABCE_N(VAR) LOOP_S_L_N(VAR, A_AXIS, XYZE_N) -// -// Conditional type assignment magic. For example... -// -// typename IF<(MYOPT==12), int, float>::type myvar; -// -template -struct IF { typedef R type; }; -template -struct IF { typedef L type; }; - // // feedRate_t is just a humble float // diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index 0918bc9d4fec..2fb450226797 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -194,16 +194,20 @@ float measuring_movement(const AxisEnum axis, const int dir, const bool stop_sta inline float measure(const AxisEnum axis, const int dir, const bool stop_state, float * const backlash_ptr, const float uncertainty) { const bool fast = uncertainty == CALIBRATION_MEASUREMENT_UNKNOWN; - // Save position - destination = current_position; - const float start_pos = destination[axis]; + // Save the current position of the specified axis + const float start_pos = current_position[axis]; + + // Take a measurement. Only the specified axis will be affected. const float measured_pos = measuring_movement(axis, dir, stop_state, fast); + // Measure backlash if (backlash_ptr && !fast) { const float release_pos = measuring_movement(axis, -dir, !stop_state, fast); *backlash_ptr = ABS(release_pos - measured_pos); } - // Return to starting position + + // Move back to the starting position + destination = current_position; destination[axis] = start_pos; do_blocking_move_to(destination, MMM_TO_MMS(CALIBRATION_FEEDRATE_TRAVEL)); return measured_pos; @@ -235,12 +239,12 @@ inline void probe_side(measurements_t &m, const float uncertainty, const side_t } #endif #if AXIS_CAN_CALIBRATE(X) + case RIGHT: dir = -1; case LEFT: axis = X_AXIS; break; - case RIGHT: axis = X_AXIS; dir = -1; break; #endif #if AXIS_CAN_CALIBRATE(Y) + case BACK: dir = -1; case FRONT: axis = Y_AXIS; break; - case BACK: axis = Y_AXIS; dir = -1; break; #endif default: return; } @@ -303,16 +307,8 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { // The difference between the known and the measured location // of the calibration object is the positional error - m.pos_error.x = (0 - #if HAS_X_CENTER - + true_center.x - m.obj_center.x - #endif - ); - m.pos_error.y = (0 - #if HAS_Y_CENTER - + true_center.y - m.obj_center.y - #endif - ); + m.pos_error.x = TERN0(HAS_X_CENTER, true_center.x - m.obj_center.x); + m.pos_error.y = TERN0(HAS_Y_CENTER, true_center.y - m.obj_center.y); m.pos_error.z = true_center.z - m.obj_center.z; } @@ -589,12 +585,12 @@ void GcodeSuite::G425() { SET_SOFT_ENDSTOP_LOOSE(true); measurements_t m; - float uncertainty = parser.seenval('U') ? parser.value_float() : CALIBRATION_MEASUREMENT_UNCERTAIN; + const float uncertainty = parser.floatval('U', CALIBRATION_MEASUREMENT_UNCERTAIN); - if (parser.seen('B')) + if (parser.seen_test('B')) calibrate_backlash(m, uncertainty); - else if (parser.seen('T')) - calibrate_toolhead(m, uncertainty, parser.has_value() ? parser.value_int() : active_extruder); + else if (parser.seen_test('T')) + calibrate_toolhead(m, uncertainty, parser.intval('T', active_extruder)); #if ENABLED(CALIBRATION_REPORTING) else if (parser.seen('V')) { probe_sides(m, uncertainty); diff --git a/Marlin/src/gcode/config/M200-M205.cpp b/Marlin/src/gcode/config/M200-M205.cpp index cb17fc45a6e8..55cfc1bf46d5 100644 --- a/Marlin/src/gcode/config/M200-M205.cpp +++ b/Marlin/src/gcode/config/M200-M205.cpp @@ -87,7 +87,7 @@ void GcodeSuite::M201() { #endif LOOP_XYZE(i) { - if (parser.seen(axis_codes[i])) { + if (parser.seenval(axis_codes[i])) { const uint8_t a = (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i); planner.set_max_acceleration(a, parser.value_axis_units((AxisEnum)a)); } @@ -105,7 +105,7 @@ void GcodeSuite::M203() { if (target_extruder < 0) return; LOOP_XYZE(i) - if (parser.seen(axis_codes[i])) { + if (parser.seenval(axis_codes[i])) { const uint8_t a = (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i); planner.set_max_feedrate(a, parser.value_axis_units((AxisEnum)a)); } @@ -147,24 +147,14 @@ void GcodeSuite::M204() { * J = Junction Deviation (mm) (If not using CLASSIC_JERK) */ void GcodeSuite::M205() { - #if HAS_JUNCTION_DEVIATION - #define J_PARAM "J" - #else - #define J_PARAM - #endif - #if HAS_CLASSIC_JERK - #define XYZE_PARAM "XYZE" - #else - #define XYZE_PARAM - #endif - if (!parser.seen("BST" J_PARAM XYZE_PARAM)) return; + if (!parser.seen("BST" TERN_(HAS_JUNCTION_DEVIATION, "J") TERN_(HAS_CLASSIC_JERK, "XYZE"))) return; //planner.synchronize(); - if (parser.seen('B')) planner.settings.min_segment_time_us = parser.value_ulong(); - if (parser.seen('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units(); - if (parser.seen('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units(); + if (parser.seenval('B')) planner.settings.min_segment_time_us = parser.value_ulong(); + if (parser.seenval('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units(); + if (parser.seenval('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units(); #if HAS_JUNCTION_DEVIATION - if (parser.seen('J')) { + if (parser.seenval('J')) { const float junc_dev = parser.value_linear_units(); if (WITHIN(junc_dev, 0.01f, 0.3f)) { planner.junction_deviation_mm = junc_dev; @@ -175,9 +165,9 @@ void GcodeSuite::M205() { } #endif #if HAS_CLASSIC_JERK - if (parser.seen('X')) planner.set_max_jerk(X_AXIS, parser.value_linear_units()); - if (parser.seen('Y')) planner.set_max_jerk(Y_AXIS, parser.value_linear_units()); - if (parser.seen('Z')) { + if (parser.seenval('X')) planner.set_max_jerk(X_AXIS, parser.value_linear_units()); + if (parser.seenval('Y')) planner.set_max_jerk(Y_AXIS, parser.value_linear_units()); + if (parser.seenval('Z')) { planner.set_max_jerk(Z_AXIS, parser.value_linear_units()); #if HAS_MESH && DISABLED(LIMITED_JERK_EDITING) if (planner.max_jerk.z <= 0.1f) @@ -185,7 +175,7 @@ void GcodeSuite::M205() { #endif } #if HAS_CLASSIC_E_JERK - if (parser.seen('E')) planner.set_max_jerk(E_AXIS, parser.value_linear_units()); + if (parser.seenval('E')) planner.set_max_jerk(E_AXIS, parser.value_linear_units()); #endif #endif } diff --git a/Marlin/src/gcode/config/M92.cpp b/Marlin/src/gcode/config/M92.cpp index bdb95db8d6d9..e83f5b314f4d 100644 --- a/Marlin/src/gcode/config/M92.cpp +++ b/Marlin/src/gcode/config/M92.cpp @@ -42,7 +42,7 @@ void report_M92(const bool echo=true, const int8_t e=-1) { } #endif - UNUSED_E(e); + UNUSED(e); } /** @@ -64,11 +64,8 @@ void GcodeSuite::M92() { if (target_extruder < 0) return; // No arguments? Show M92 report. - if (!parser.seen("XYZE" - #if ENABLED(MAGIC_NUMBERS_GCODE) - "HL" - #endif - )) return report_M92(true, target_extruder); + if (!parser.seen("XYZE" TERN_(MAGIC_NUMBERS_GCODE, "HL"))) + return report_M92(true, target_extruder); LOOP_XYZE(i) { if (parser.seenval(axis_codes[i])) { diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index b35b4653319c..f02508a90171 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -34,10 +34,10 @@ */ void GcodeSuite::M17() { if (parser.seen("XYZE")) { - if (parser.seen('X')) ENABLE_AXIS_X(); - if (parser.seen('Y')) ENABLE_AXIS_Y(); - if (parser.seen('Z')) ENABLE_AXIS_Z(); - if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen('E'))) enable_e_steppers(); + if (parser.seen_test('X')) ENABLE_AXIS_X(); + if (parser.seen_test('Y')) ENABLE_AXIS_Y(); + if (parser.seen_test('Z')) ENABLE_AXIS_Z(); + if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen_test('E'))) enable_e_steppers(); } else { LCD_MESSAGEPGM(MSG_NO_MOVE); @@ -56,10 +56,10 @@ void GcodeSuite::M18_M84() { else { if (parser.seen("XYZE")) { planner.synchronize(); - if (parser.seen('X')) DISABLE_AXIS_X(); - if (parser.seen('Y')) DISABLE_AXIS_Y(); - if (parser.seen('Z')) DISABLE_AXIS_Z(); - if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen('E'))) disable_e_steppers(); + if (parser.seen_test('X')) DISABLE_AXIS_X(); + if (parser.seen_test('Y')) DISABLE_AXIS_Y(); + if (parser.seen_test('Z')) DISABLE_AXIS_Z(); + if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen_test('E'))) disable_e_steppers(); } else planner.finish_and_disable(); diff --git a/Marlin/src/gcode/control/M211.cpp b/Marlin/src/gcode/control/M211.cpp index 2049f1eb6955..2ba777ba650e 100644 --- a/Marlin/src/gcode/control/M211.cpp +++ b/Marlin/src/gcode/control/M211.cpp @@ -39,8 +39,8 @@ void GcodeSuite::M211() { SERIAL_ECHOPGM(STR_SOFT_ENDSTOPS); if (parser.seen('S')) soft_endstop._enabled = parser.value_bool(); serialprint_onoff(soft_endstop._enabled); - print_xyz(l_soft_min, PSTR(STR_SOFT_MIN), PSTR(" ")); - print_xyz(l_soft_max, PSTR(STR_SOFT_MAX)); + print_pos(l_soft_min, PSTR(STR_SOFT_MIN), PSTR(" ")); + print_pos(l_soft_max, PSTR(STR_SOFT_MAX)); } #endif diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index 8c840db5bf9c..0c5fff7025b9 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -35,10 +35,19 @@ #define M91x_USE(ST) (AXIS_DRIVER_TYPE(ST, TMC2130) || AXIS_DRIVER_TYPE(ST, TMC2160) || AXIS_DRIVER_TYPE(ST, TMC2208) || AXIS_DRIVER_TYPE(ST, TMC2209) || AXIS_DRIVER_TYPE(ST, TMC2660) || AXIS_DRIVER_TYPE(ST, TMC5130) || AXIS_DRIVER_TYPE(ST, TMC5160)) #define M91x_USE_E(N) (E_STEPPERS > N && M91x_USE(E##N)) - #define M91x_SOME_X (M91x_USE(X) || M91x_USE(X2)) - #define M91x_SOME_Y (M91x_USE(Y) || M91x_USE(Y2)) - #define M91x_SOME_Z (M91x_USE(Z) || M91x_USE(Z2) || M91x_USE(Z3) || M91x_USE(Z4)) - #define M91x_SOME_E (M91x_USE_E(0) || M91x_USE_E(1) || M91x_USE_E(2) || M91x_USE_E(3) || M91x_USE_E(4) || M91x_USE_E(5) || M91x_USE_E(6) || M91x_USE_E(7)) + #if M91x_USE(X) || M91x_USE(X2) + #define M91x_SOME_X 1 + #endif + #if M91x_USE(Y) || M91x_USE(Y2) + #define M91x_SOME_Y 1 + #endif + #if M91x_USE(Z) || M91x_USE(Z2) || M91x_USE(Z3) || M91x_USE(Z4) + #define M91x_SOME_Z 1 + #endif + + #if M91x_USE_E(0) || M91x_USE_E(1) || M91x_USE_E(2) || M91x_USE_E(3) || M91x_USE_E(4) || M91x_USE_E(5) || M91x_USE_E(6) || M91x_USE_E(7) + #define M91x_SOME_E 1 + #endif #if !M91x_SOME_X && !M91x_SOME_Y && !M91x_SOME_Z && !M91x_SOME_E #error "MONITOR_DRIVER_STATUS requires at least one TMC2130, 2160, 2208, 2209, 2660, 5130, or 5160." @@ -112,31 +121,12 @@ * M912 E1 ; clear E1 only */ void GcodeSuite::M912() { - #if M91x_SOME_X - const bool hasX = parser.seen(axis_codes.x); - #else - constexpr bool hasX = false; - #endif - - #if M91x_SOME_Y - const bool hasY = parser.seen(axis_codes.y); - #else - constexpr bool hasY = false; - #endif - - #if M91x_SOME_Z - const bool hasZ = parser.seen(axis_codes.z); - #else - constexpr bool hasZ = false; - #endif - - #if M91x_SOME_E - const bool hasE = parser.seen(axis_codes.e); - #else - constexpr bool hasE = false; - #endif + const bool hasX = TERN0(M91x_SOME_X, parser.seen(axis_codes.x)), + hasY = TERN0(M91x_SOME_Y, parser.seen(axis_codes.y)), + hasZ = TERN0(M91x_SOME_Z, parser.seen(axis_codes.z)), + hasE = TERN0(M91x_SOME_E, parser.seen(axis_codes.e)); - const bool hasNone = !hasX && !hasY && !hasZ && !hasE; + const bool hasNone = !hasE && !hasX && !hasY && !hasZ; #if M91x_SOME_X const int8_t xval = int8_t(parser.byteval(axis_codes.x, 0xFF)); diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 0ca6c82c2ae2..34a719c4669f 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -140,7 +140,7 @@ int8_t GcodeSuite::get_target_e_stepper_from_command() { * - Set the feedrate, if included */ void GcodeSuite::get_destination_from_command() { - xyze_bool_t seen = { false, false, false, false }; + xyze_bool_t seen{false}; #if ENABLED(CANCEL_OBJECTS) const bool &skip_move = cancelable.skipping; diff --git a/Marlin/src/gcode/host/M114.cpp b/Marlin/src/gcode/host/M114.cpp index e5dc90fb302b..27b193851d27 100644 --- a/Marlin/src/gcode/host/M114.cpp +++ b/Marlin/src/gcode/host/M114.cpp @@ -34,7 +34,7 @@ #include "../../core/debug_out.h" #endif - void report_xyze(const xyze_pos_t &pos, const uint8_t n=XYZE, const uint8_t precision=3) { + void report_all_axis_pos(const xyze_pos_t &pos, const uint8_t n=XYZE, const uint8_t precision=3) { char str[12]; LOOP_L_N(a, n) { SERIAL_CHAR(' ', axis_codes[a], ':'); @@ -43,9 +43,9 @@ } SERIAL_EOL(); } - inline void report_xyz(const xyze_pos_t &pos) { report_xyze(pos, XYZ); } + inline void report_linear_axis_pos(const xyze_pos_t &pos) { report_all_axis_pos(pos, XYZ); } - void report_xyz(const xyz_pos_t &pos, const uint8_t precision=3) { + void report_linear_axis_pos(const xyz_pos_t &pos, const uint8_t precision=3) { char str[12]; LOOP_XYZ(a) { SERIAL_CHAR(' ', XYZ_CHAR(a), ':'); @@ -57,11 +57,11 @@ void report_current_position_detail() { // Position as sent by G-code SERIAL_ECHOPGM("\nLogical:"); - report_xyz(current_position.asLogical()); + report_linear_axis_pos(current_position.asLogical()); // Cartesian position in native machine space SERIAL_ECHOPGM("Raw: "); - report_xyz(current_position); + report_linear_axis_pos(current_position); xyze_pos_t leveled = current_position; @@ -69,20 +69,20 @@ // Current position with leveling applied SERIAL_ECHOPGM("Leveled:"); planner.apply_leveling(leveled); - report_xyz(leveled); + report_linear_axis_pos(leveled); // Test planner un-leveling. This should match the Raw result. SERIAL_ECHOPGM("UnLevel:"); xyze_pos_t unleveled = leveled; planner.unapply_leveling(unleveled); - report_xyz(unleveled); + report_linear_axis_pos(unleveled); #endif #if IS_KINEMATIC // Kinematics applied to the leveled position SERIAL_ECHOPGM(TERN(IS_SCARA, "ScaraK: ", "DeltaK: ")); inverse_kinematics(leveled); // writes delta[] - report_xyz(delta); + report_linear_axis_pos(delta); #endif planner.synchronize(); @@ -165,17 +165,17 @@ planner.get_axis_position_degrees(B_AXIS) }; SERIAL_ECHOPGM("Degrees:"); - report_xyze(deg, 2); + report_all_axis_pos(deg, 2); #endif SERIAL_ECHOPGM("FromStp:"); get_cartesian_from_steppers(); // writes 'cartes' (with forward kinematics) xyze_pos_t from_steppers = { cartes.x, cartes.y, cartes.z, planner.get_axis_position_mm(E_AXIS) }; - report_xyze(from_steppers); + report_all_axis_pos(from_steppers); const xyze_float_t diff = from_steppers - leveled; SERIAL_ECHOPGM("Diff: "); - report_xyze(diff); + report_all_axis_pos(diff); TERN_(FULL_REPORT_TO_HOST_FEATURE, report_current_grblstate_moving()); } diff --git a/Marlin/src/gcode/motion/G0_G1.cpp b/Marlin/src/gcode/motion/G0_G1.cpp index 089e00ab9516..73c5b1171422 100644 --- a/Marlin/src/gcode/motion/G0_G1.cpp +++ b/Marlin/src/gcode/motion/G0_G1.cpp @@ -83,7 +83,7 @@ void GcodeSuite::G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move/*=false*/)) { if (MIN_AUTORETRACT <= MAX_AUTORETRACT) { // When M209 Autoretract is enabled, convert E-only moves to firmware retract/recover moves - if (fwretract.autoretract_enabled && parser.seen('E') && !(parser.seen('X') || parser.seen('Y') || parser.seen('Z'))) { + if (fwretract.autoretract_enabled && parser.seen('E') && !parser.seen("XYZ")) { const float echange = destination.e - current_position.e; // Is this a retract or recover move? if (WITHIN(ABS(echange), MIN_AUTORETRACT, MAX_AUTORETRACT) && fwretract.retracted[active_extruder] == (echange > 0.0)) { diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index 5a8324362a26..41ff7e976595 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -291,12 +291,12 @@ void plan_arc( * Mixing IJ/JK/KI with R will throw an error. * * - R specifies the radius. X or Y (Y or Z / Z or X) is required. - * Omitting both XY/YZ/ZX will throw an error. - * XY/YZ/ZX must differ from the current XY/YZ/ZX. - * Mixing R with IJ/JK/KI will throw an error. + * Omitting both XY/YZ/ZX will throw an error. + * XY/YZ/ZX must differ from the current XY/YZ/ZX. + * Mixing R with IJ/JK/KI will throw an error. * * - P specifies the number of full circles to do - * before the specified arc move. + * before the specified arc move. * * Examples: * diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index bfa4346f0316..514d6b7a5daf 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -222,7 +222,7 @@ void GCodeParser::parse(char *p) { #if ENABLED(GCODE_MOTION_MODES) if (letter == 'G' - && (codenum <= TERN(ARC_SUPPORT, 3, 1) || codenum == 5 || TERN0(G38_PROBE_TARGET, codenum == 38)) + && (codenum <= TERN(ARC_SUPPORT, 3, 1) || TERN0(BEZIER_CURVE_SUPPORT, codenum == 5) || TERN0(G38_PROBE_TARGET, codenum == 38)) ) { motion_mode_codenum = codenum; TERN_(USE_GCODE_SUBCODES, motion_mode_subcode = subcode); diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 3aec17554b5f..4270e04c9f09 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -226,7 +226,7 @@ class GCodeParser { // Seen any axis parameter static inline bool seen_axis() { - return seen_test('X') || seen_test('Y') || seen_test('Z') || seen_test('E'); + return seen("XYZE"); } #if ENABLED(GCODE_QUOTED_STRINGS) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 6de9c40ac7ad..46c1e590205c 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -125,7 +125,7 @@ #if EITHER(IS_CORE, MARKFORGED_XY) #define CAN_CALIBRATE(A,B) (_AXIS(A) == B) #else - #define CAN_CALIBRATE(A,B) 1 + #define CAN_CALIBRATE(A,B) true #endif #endif #define AXIS_CAN_CALIBRATE(A) CAN_CALIBRATE(A,NORMAL_AXIS) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 2131fcd678c5..1f0b301f0a93 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3247,7 +3247,7 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) /** * Sanity check for MIXING_EXTRUDER & DISTINCT_E_FACTORS these are not compatible */ -#if ENABLED(MIXING_EXTRUDER) && ENABLED(DISTINCT_E_FACTORS) +#if BOTH(MIXING_EXTRUDER, DISTINCT_E_FACTORS) #error "MIXING_EXTRUDER can't be used with DISTINCT_E_FACTORS. But you may use SINGLENOZZLE with DISTINCT_E_FACTORS." #endif diff --git a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp index b3892941756e..55546caaf157 100644 --- a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp +++ b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp @@ -147,6 +147,7 @@ namespace ExtUI { case PID_DONE: ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_AUTOTUNE_DONE)); break; + case PID_STARTED: break; } ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN); } diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index faa23665bbea..fff31f099bf7 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -569,7 +569,7 @@ namespace ExtUI { } float getAxisSteps_per_mm(const extruder_t extruder) { - UNUSED_E(extruder); + UNUSED(extruder); return planner.settings.axis_steps_per_mm[E_AXIS_N(extruder - E0)]; } @@ -579,7 +579,7 @@ namespace ExtUI { } void setAxisSteps_per_mm(const_float_t value, const extruder_t extruder) { - UNUSED_E(extruder); + UNUSED(extruder); planner.settings.axis_steps_per_mm[E_AXIS_N(extruder - E0)] = value; planner.refresh_positioning(); } @@ -589,7 +589,7 @@ namespace ExtUI { } feedRate_t getAxisMaxFeedrate_mm_s(const extruder_t extruder) { - UNUSED_E(extruder); + UNUSED(extruder); return planner.settings.max_feedrate_mm_s[E_AXIS_N(extruder - E0)]; } @@ -598,7 +598,7 @@ namespace ExtUI { } void setAxisMaxFeedrate_mm_s(const feedRate_t value, const extruder_t extruder) { - UNUSED_E(extruder); + UNUSED(extruder); planner.set_max_feedrate(E_AXIS_N(extruder - E0), value); } @@ -607,7 +607,7 @@ namespace ExtUI { } float getAxisMaxAcceleration_mm_s2(const extruder_t extruder) { - UNUSED_E(extruder); + UNUSED(extruder); return planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(extruder - E0)]; } @@ -616,7 +616,7 @@ namespace ExtUI { } void setAxisMaxAcceleration_mm_s2(const_float_t value, const extruder_t extruder) { - UNUSED_E(extruder); + UNUSED(extruder); planner.set_max_acceleration(E_AXIS_N(extruder - E0), value); } diff --git a/Marlin/src/lcd/menu/menu_mmu2.cpp b/Marlin/src/lcd/menu/menu_mmu2.cpp index af3d9232b255..425a8ca75135 100644 --- a/Marlin/src/lcd/menu/menu_mmu2.cpp +++ b/Marlin/src/lcd/menu/menu_mmu2.cpp @@ -37,8 +37,7 @@ inline void action_mmu2_load_filament_to_nozzle(const uint8_t tool) { ui.reset_status(); ui.return_to_status(); ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(tool + 1)); - if (mmu2.load_filament_to_nozzle(tool)) - ui.reset_status(); + if (mmu2.load_filament_to_nozzle(tool)) ui.reset_status(); ui.return_to_status(); } diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index d7f728ad4b85..2ac20c92ef6c 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -508,7 +508,7 @@ void Endstops::update() { #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX))) #define COPY_LIVE_STATE(SRC_BIT, DST_BIT) SET_BIT_TO(live_state, DST_BIT, TEST(live_state, SRC_BIT)) - #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) + #if BOTH(G38_PROBE_TARGET, HAS_Z_MIN_PROBE_PIN) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) // If G38 command is active check Z_MIN_PROBE for ALL movement if (G38_move) UPDATE_ENDSTOP_BIT(Z, MIN_PROBE); #endif @@ -747,7 +747,7 @@ void Endstops::update() { #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_DUAL_ENDSTOP(Z, MINMAX) #endif - #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) + #if BOTH(G38_PROBE_TARGET, HAS_Z_MIN_PROBE_PIN) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) #if ENABLED(G38_PROBE_AWAY) #define _G38_OPEN_STATE (G38_move >= 4) #else diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 171d9520cb7b..97be6226ba46 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -83,13 +83,13 @@ bool relative_mode; // = false; * Used by 'line_to_current_position' to do a move after changing it. * Used by 'sync_plan_position' to update 'planner.position'. */ -xyze_pos_t current_position = { X_HOME_POS, Y_HOME_POS, - #ifdef Z_IDLE_HEIGHT - Z_IDLE_HEIGHT - #else - Z_HOME_POS - #endif -}; +#ifdef Z_IDLE_HEIGHT + #define Z_INIT_POS Z_IDLE_HEIGHT +#else + #define Z_INIT_POS Z_HOME_POS +#endif + +xyze_pos_t current_position = { X_HOME_POS, Y_HOME_POS, Z_INIT_POS }; /** * Cartesian Destination @@ -204,11 +204,7 @@ void report_real_position() { get_cartesian_from_steppers(); xyze_pos_t npos = cartes; npos.e = planner.get_axis_position_mm(E_AXIS); - - #if HAS_POSITION_MODIFIERS - planner.unapply_modifiers(npos, true); - #endif - + TERN_(HAS_POSITION_MODIFIERS, planner.unapply_modifiers(npos, true)); report_logical_position(npos); report_more_positions(); } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 2b20bba4fbee..0ef382a71c40 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -2584,8 +2584,8 @@ void MarlinSettings::postprocess() { void MarlinSettings::reset() { LOOP_XYZE_N(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)]); + 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)]); } planner.settings.min_segment_time_us = DEFAULT_MINSEGMENTTIME; diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index de3d45e4b654..8c943048ba96 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -62,7 +62,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; #define _TMC_UART_DEFINE(SWHW, IC, ST, AI) TMC_UART_##SWHW##_DEFINE(IC, ST, TMC_##ST##_LABEL, AI) #define TMC_UART_DEFINE(SWHW, ST, AI) _TMC_UART_DEFINE(SWHW, ST##_DRIVER_TYPE, ST, AI##_AXIS) -#if DISTINCT_E > 1 +#if ENABLED(DISTINCT_E_FACTORS) #define TMC_SPI_DEFINE_E(AI) TMC_SPI_DEFINE(E##AI, E##AI) #define TMC_UART_DEFINE_E(SWHW, AI) TMC_UART_DEFINE(SWHW, E##AI, E##AI) #else From a6e5492b088add3589aeac168136369f21614e60 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 18 May 2021 22:51:19 -0500 Subject: [PATCH 11/61] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20axis=20co?= =?UTF-8?q?unts=20and=20loops?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/types.h | 38 +++++++++---------- Marlin/src/core/utility.cpp | 4 +- Marlin/src/feature/backlash.cpp | 2 +- Marlin/src/feature/dac/dac_mcp4728.cpp | 4 +- Marlin/src/feature/dac/stepper_dac.cpp | 2 +- Marlin/src/feature/encoder_i2c.cpp | 22 +++++------ Marlin/src/feature/joystick.cpp | 2 +- Marlin/src/feature/powerloss.cpp | 8 ++-- Marlin/src/gcode/calibrate/G28.cpp | 2 +- Marlin/src/gcode/calibrate/G33.cpp | 10 ++--- Marlin/src/gcode/calibrate/M425.cpp | 12 +++--- Marlin/src/gcode/calibrate/M666.cpp | 6 +-- Marlin/src/gcode/calibrate/M852.cpp | 2 +- Marlin/src/gcode/config/M200-M205.cpp | 4 +- Marlin/src/gcode/config/M92.cpp | 2 +- Marlin/src/gcode/control/M350_M351.cpp | 8 ++-- Marlin/src/gcode/control/M605.cpp | 2 +- Marlin/src/gcode/feature/L6470/M906.cpp | 2 +- .../src/gcode/feature/digipot/M907-M910.cpp | 6 +-- Marlin/src/gcode/feature/pause/G61.cpp | 6 +-- Marlin/src/gcode/feature/trinamic/M122.cpp | 6 +-- Marlin/src/gcode/feature/trinamic/M569.cpp | 2 +- Marlin/src/gcode/feature/trinamic/M906.cpp | 2 +- .../src/gcode/feature/trinamic/M911-M914.cpp | 4 +- Marlin/src/gcode/gcode.cpp | 4 +- Marlin/src/gcode/geometry/G53-G59.cpp | 2 +- Marlin/src/gcode/geometry/G92.cpp | 6 +-- Marlin/src/gcode/geometry/M206_M428.cpp | 8 ++-- Marlin/src/gcode/host/M114.cpp | 6 +-- Marlin/src/gcode/motion/M290.cpp | 4 +- Marlin/src/gcode/probe/G38.cpp | 6 +-- Marlin/src/inc/Conditionals_LCD.h | 30 +++++++++++---- Marlin/src/inc/SanityCheck.h | 24 ++++++------ Marlin/src/lcd/marlinui.cpp | 12 +++--- Marlin/src/lcd/menu/menu_advanced.cpp | 2 +- Marlin/src/lcd/menu/menu_bed_leveling.cpp | 2 +- Marlin/src/lcd/menu/menu_ubl.cpp | 2 +- Marlin/src/libs/L64XX/L64XX_Marlin.cpp | 2 +- Marlin/src/module/motion.cpp | 10 ++--- Marlin/src/module/planner.cpp | 14 +++---- Marlin/src/module/planner.h | 18 ++++----- Marlin/src/module/scara.cpp | 2 +- Marlin/src/module/settings.cpp | 27 +++++++------ Marlin/src/module/stepper.h | 2 +- Marlin/src/module/tool_change.cpp | 2 +- 45 files changed, 178 insertions(+), 165 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 4011473aa07a..98e2bedb001f 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -47,25 +47,23 @@ struct IF { typedef L type; }; // - X_HEAD, Y_HEAD, and Z_HEAD should be used for Steppers on Core kinematics // enum AxisEnum : uint8_t { - X_AXIS = 0, A_AXIS = 0, - Y_AXIS = 1, B_AXIS = 1, - Z_AXIS = 2, C_AXIS = 2, - E_AXIS = 3, - X_HEAD = 4, Y_HEAD = 5, Z_HEAD = 6, - E0_AXIS = 3, + X_AXIS = 0, A_AXIS = X_AXIS, + Y_AXIS = 1, B_AXIS = Y_AXIS, + Z_AXIS = 2, C_AXIS = Z_AXIS, + E_AXIS, + X_HEAD, Y_HEAD, Z_HEAD, + E0_AXIS = E_AXIS, E1_AXIS, E2_AXIS, E3_AXIS, E4_AXIS, E5_AXIS, E6_AXIS, E7_AXIS, - ALL_AXES = 0xFE, NO_AXIS = 0xFF + ALL_AXES_MASK = 0xFE, NO_AXIS_MASK = 0xFF }; // -// Loop over XYZE axes +// Loop over axes // -#define LOOP_XYZ(VAR) LOOP_S_LE_N(VAR, X_AXIS, Z_AXIS) -#define LOOP_XYZE(VAR) LOOP_S_LE_N(VAR, X_AXIS, E_AXIS) -#define LOOP_XYZE_N(VAR) LOOP_S_L_N(VAR, X_AXIS, XYZE_N) #define LOOP_ABC(VAR) LOOP_S_LE_N(VAR, A_AXIS, C_AXIS) -#define LOOP_ABCE(VAR) LOOP_S_LE_N(VAR, A_AXIS, E_AXIS) -#define LOOP_ABCE_N(VAR) LOOP_S_L_N(VAR, A_AXIS, XYZE_N) +#define LOOP_LINEAR_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, LINEAR_AXES) +#define LOOP_LOGICAL_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, LOGICAL_AXES) +#define LOOP_DISTINCT_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, DISTINCT_AXES) // // feedRate_t is just a humble float @@ -201,8 +199,8 @@ struct XYval { FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; } FI void set(const T (&arr)[XYZ]) { x = arr[0]; y = arr[1]; } FI void set(const T (&arr)[XYZE]) { x = arr[0]; y = arr[1]; } - #if XYZE_N > XYZE - FI void set(const T (&arr)[XYZE_N]) { x = arr[0]; y = arr[1]; } + #if DISTINCT_AXES > LOGICAL_AXES + FI void set(const T (&arr)[DISTINCT_AXES]) { x = arr[0]; y = arr[1]; } #endif FI void reset() { x = y = 0; } FI T magnitude() const { return (T)sqrtf(x*x + y*y); } @@ -312,8 +310,8 @@ struct XYZval { FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; } FI void set(const T (&arr)[XYZ]) { x = arr[0]; y = arr[1]; z = arr[2]; } FI void set(const T (&arr)[XYZE]) { x = arr[0]; y = arr[1]; z = arr[2]; } - #if XYZE_N > XYZE - FI void set(const T (&arr)[XYZE_N]) { x = arr[0]; y = arr[1]; z = arr[2]; } + #if DISTINCT_AXES > XYZE + FI void set(const T (&arr)[DISTINCT_AXES]) { x = arr[0]; y = arr[1]; z = arr[2]; } #endif FI void reset() { x = y = z = 0; } FI T magnitude() const { return (T)sqrtf(x*x + y*y + z*z); } @@ -427,8 +425,8 @@ struct XYZEval { FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; } FI void set(const T (&arr)[XYZ]) { x = arr[0]; y = arr[1]; z = arr[2]; } FI void set(const T (&arr)[XYZE]) { x = arr[0]; y = arr[1]; z = arr[2]; e = arr[3]; } - #if XYZE_N > XYZE - FI void set(const T (&arr)[XYZE_N]) { x = arr[0]; y = arr[1]; z = arr[2]; e = arr[3]; } + #if DISTINCT_AXES > XYZE + FI void set(const T (&arr)[DISTINCT_AXES]) { x = arr[0]; y = arr[1]; z = arr[2]; e = arr[3]; } #endif FI XYZEval copy() const { return *this; } FI XYZEval ABS() const { return { T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(e)) }; } @@ -518,4 +516,4 @@ struct XYZEval { #undef FI const xyze_char_t axis_codes { 'X', 'Y', 'Z', 'E' }; -#define XYZ_CHAR(A) ((char)('X' + A)) +#define AXIS_CHAR(A) ((char)('X' + A)) diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 3d7897f95a0a..f4cdef43c808 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -123,9 +123,9 @@ void safe_delay(millis_t ms) { #endif #if ABL_PLANAR SERIAL_ECHOPGM("ABL Adjustment X"); - LOOP_XYZ(a) { + LOOP_LINEAR_AXES(a) { const float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]; - SERIAL_CHAR(' ', XYZ_CHAR(a)); + SERIAL_CHAR(' ', AXIS_CHAR(a)); if (v > 0) SERIAL_CHAR('+'); SERIAL_DECIMAL(v); } diff --git a/Marlin/src/feature/backlash.cpp b/Marlin/src/feature/backlash.cpp index 610cfcb56551..5ab95d157775 100644 --- a/Marlin/src/feature/backlash.cpp +++ b/Marlin/src/feature/backlash.cpp @@ -104,7 +104,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const const float f_corr = float(correction) / 255.0f; - LOOP_XYZ(axis) { + LOOP_LINEAR_AXES(axis) { if (distance_mm[axis]) { const bool reversing = TEST(dm,axis); diff --git a/Marlin/src/feature/dac/dac_mcp4728.cpp b/Marlin/src/feature/dac/dac_mcp4728.cpp index 2b57037d9984..ddbaced08640 100644 --- a/Marlin/src/feature/dac/dac_mcp4728.cpp +++ b/Marlin/src/feature/dac/dac_mcp4728.cpp @@ -73,7 +73,7 @@ uint8_t MCP4728::analogWrite(const uint8_t channel, const uint16_t value) { uint8_t MCP4728::eepromWrite() { Wire.beginTransmission(I2C_ADDRESS(DAC_DEV_ADDRESS)); Wire.write(SEQWRITE); - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { Wire.write(DAC_STEPPER_VREF << 7 | DAC_STEPPER_GAIN << 4 | highByte(dac_values[i])); Wire.write(lowByte(dac_values[i])); } @@ -135,7 +135,7 @@ void MCP4728::setDrvPct(xyze_uint_t &pct) { */ uint8_t MCP4728::fastWrite() { Wire.beginTransmission(I2C_ADDRESS(DAC_DEV_ADDRESS)); - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { Wire.write(highByte(dac_values[i])); Wire.write(lowByte(dac_values[i])); } diff --git a/Marlin/src/feature/dac/stepper_dac.cpp b/Marlin/src/feature/dac/stepper_dac.cpp index 5170a3551108..bb7954cfe05f 100644 --- a/Marlin/src/feature/dac/stepper_dac.cpp +++ b/Marlin/src/feature/dac/stepper_dac.cpp @@ -77,7 +77,7 @@ static float dac_amps(int8_t n) { return mcp4728.getValue(dac_order[n]) * 0.125 uint8_t StepperDAC::get_current_percent(const AxisEnum axis) { return mcp4728.getDrvPct(dac_order[axis]); } void StepperDAC::set_current_percents(xyze_uint8_t &pct) { - LOOP_XYZE(i) dac_channel_pct[i] = pct[dac_order[i]]; + LOOP_LOGICAL_AXES(i) dac_channel_pct[i] = pct[dac_order[i]]; mcp4728.setDrvPct(dac_channel_pct); } diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index b3265b2c5946..d6c88613fd81 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -337,7 +337,7 @@ bool I2CPositionEncoder::test_axis() { ec = false; xyze_pos_t startCoord, endCoord; - LOOP_XYZ(a) { + LOOP_LINEAR_AXES(a) { startCoord[a] = planner.get_axis_position_mm((AxisEnum)a); endCoord[a] = planner.get_axis_position_mm((AxisEnum)a); } @@ -392,7 +392,7 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) { travelDistance = endDistance - startDistance; xyze_pos_t startCoord, endCoord; - LOOP_XYZ(a) { + LOOP_LINEAR_AXES(a) { startCoord[a] = planner.get_axis_position_mm((AxisEnum)a); endCoord[a] = planner.get_axis_position_mm((AxisEnum)a); } @@ -822,7 +822,7 @@ void I2CPositionEncodersMgr::M860() { const bool hasU = parser.seen_test('U'), hasO = parser.seen_test('O'); if (I2CPE_idx == 0xFF) { - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { if (!I2CPE_anyaxis || parser.seen_test(axis_codes[i])) { const uint8_t idx = idx_from_axis(AxisEnum(i)); if ((int8_t)idx >= 0) report_position(idx, hasU, hasO); @@ -849,7 +849,7 @@ void I2CPositionEncodersMgr::M861() { if (parse()) return; if (I2CPE_idx == 0xFF) { - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { const uint8_t idx = idx_from_axis(AxisEnum(i)); if ((int8_t)idx >= 0) report_status(idx); @@ -877,7 +877,7 @@ void I2CPositionEncodersMgr::M862() { if (parse()) return; if (I2CPE_idx == 0xFF) { - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { const uint8_t idx = idx_from_axis(AxisEnum(i)); if ((int8_t)idx >= 0) test_axis(idx); @@ -908,7 +908,7 @@ void I2CPositionEncodersMgr::M863() { const uint8_t iterations = constrain(parser.byteval('P', 1), 1, 10); if (I2CPE_idx == 0xFF) { - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { const uint8_t idx = idx_from_axis(AxisEnum(i)); if ((int8_t)idx >= 0) calibrate_steps_mm(idx, iterations); @@ -984,7 +984,7 @@ void I2CPositionEncodersMgr::M865() { if (parse()) return; if (!I2CPE_addr) { - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { const uint8_t idx = idx_from_axis(AxisEnum(i)); if ((int8_t)idx >= 0) report_module_firmware(encoders[idx].get_address()); @@ -1015,7 +1015,7 @@ void I2CPositionEncodersMgr::M866() { const bool hasR = parser.seen_test('R'); if (I2CPE_idx == 0xFF) { - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { const uint8_t idx = idx_from_axis(AxisEnum(i)); if ((int8_t)idx >= 0) { @@ -1053,7 +1053,7 @@ void I2CPositionEncodersMgr::M867() { const int8_t onoff = parser.seenval('S') ? parser.value_int() : -1; if (I2CPE_idx == 0xFF) { - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { const uint8_t idx = idx_from_axis(AxisEnum(i)); if ((int8_t)idx >= 0) { @@ -1089,7 +1089,7 @@ void I2CPositionEncodersMgr::M868() { const float newThreshold = parser.seenval('T') ? parser.value_float() : -9999; if (I2CPE_idx == 0xFF) { - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { const uint8_t idx = idx_from_axis(AxisEnum(i)); if ((int8_t)idx >= 0) { @@ -1123,7 +1123,7 @@ void I2CPositionEncodersMgr::M869() { if (parse()) return; if (I2CPE_idx == 0xFF) { - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { const uint8_t idx = idx_from_axis(AxisEnum(i)); if ((int8_t)idx >= 0) report_error(idx); diff --git a/Marlin/src/feature/joystick.cpp b/Marlin/src/feature/joystick.cpp index 2cc61ec5a375..d8e6cef3b6d3 100644 --- a/Marlin/src/feature/joystick.cpp +++ b/Marlin/src/feature/joystick.cpp @@ -163,7 +163,7 @@ Joystick joystick; // norm_jog values of [-1 .. 1] maps linearly to [-feedrate .. feedrate] xyz_float_t move_dist{0}; float hypot2 = 0; - LOOP_XYZ(i) if (norm_jog[i]) { + LOOP_LINEAR_AXES(i) if (norm_jog[i]) { move_dist[i] = seg_time * norm_jog[i] * TERN(EXTENSIBLE_UI, manual_feedrate_mm_s, planner.settings.max_feedrate_mm_s)[i]; hypot2 += sq(move_dist[i]); } diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 3764af13d028..db78e7331bbb 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -549,7 +549,7 @@ void PrintJobRecovery::resume() { TERN_(HAS_HOME_OFFSET, home_offset = info.home_offset); TERN_(HAS_POSITION_SHIFT, position_shift = info.position_shift); #if HAS_HOME_OFFSET || HAS_POSITION_SHIFT - LOOP_XYZ(i) update_workspace_offset((AxisEnum)i); + LOOP_LINEAR_AXES(i) update_workspace_offset((AxisEnum)i); #endif // Relative axis modes @@ -581,7 +581,7 @@ void PrintJobRecovery::resume() { if (info.valid_head) { if (info.valid_head == info.valid_foot) { DEBUG_ECHOPGM("current_position: "); - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { if (i) DEBUG_CHAR(','); DEBUG_DECIMAL(info.current_position[i]); } @@ -599,7 +599,7 @@ void PrintJobRecovery::resume() { #if HAS_HOME_OFFSET DEBUG_ECHOPGM("home_offset: "); - LOOP_XYZ(i) { + LOOP_LINEAR_AXES(i) { if (i) DEBUG_CHAR(','); DEBUG_DECIMAL(info.home_offset[i]); } @@ -608,7 +608,7 @@ void PrintJobRecovery::resume() { #if HAS_POSITION_SHIFT DEBUG_ECHOPGM("position_shift: "); - LOOP_XYZ(i) { + LOOP_LINEAR_AXES(i) { if (i) DEBUG_CHAR(','); DEBUG_DECIMAL(info.position_shift[i]); } diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 92bbb8e6c5b3..23eafe4bb64e 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -220,7 +220,7 @@ void GcodeSuite::G28() { #if ENABLED(MARLIN_DEV_MODE) if (parser.seen_test('S')) { - LOOP_XYZ(a) set_axis_is_at_home((AxisEnum)a); + LOOP_LINEAR_AXES(a) set_axis_is_at_home((AxisEnum)a); sync_plan_position(); SERIAL_ECHOLNPGM("Simulated Homing"); report_current_position(); diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index a8de51933503..14ac53aeba8c 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -347,7 +347,7 @@ static float auto_tune_a() { abc_float_t delta_e = { 0.0f }, delta_t = { 0.0f }; delta_t.reset(); - LOOP_XYZ(axis) { + LOOP_LINEAR_AXES(axis) { delta_t[axis] = diff; calc_kinematics_diff_probe_points(z_pt, delta_e, delta_r, delta_t); delta_t[axis] = 0; @@ -525,7 +525,7 @@ void GcodeSuite::G33() { case 1: test_precision = 0.0f; // forced end - LOOP_XYZ(axis) e_delta[axis] = +Z4(CEN); + LOOP_LINEAR_AXES(axis) e_delta[axis] = +Z4(CEN); break; case 2: @@ -573,14 +573,14 @@ void GcodeSuite::G33() { // Normalize angles to least-squares if (_angle_results) { float a_sum = 0.0f; - LOOP_XYZ(axis) a_sum += delta_tower_angle_trim[axis]; - LOOP_XYZ(axis) delta_tower_angle_trim[axis] -= a_sum / 3.0f; + LOOP_LINEAR_AXES(axis) a_sum += delta_tower_angle_trim[axis]; + LOOP_LINEAR_AXES(axis) delta_tower_angle_trim[axis] -= a_sum / 3.0f; } // adjust delta_height and endstops by the max amount const float z_temp = _MAX(delta_endstop_adj.a, delta_endstop_adj.b, delta_endstop_adj.c); delta_height -= z_temp; - LOOP_XYZ(axis) delta_endstop_adj[axis] -= z_temp; + LOOP_LINEAR_AXES(axis) delta_endstop_adj[axis] -= z_temp; } recalc_delta_settings(); NOMORE(zero_std_dev_min, zero_std_dev); diff --git a/Marlin/src/gcode/calibrate/M425.cpp b/Marlin/src/gcode/calibrate/M425.cpp index 40441ac08d16..432144f491c0 100644 --- a/Marlin/src/gcode/calibrate/M425.cpp +++ b/Marlin/src/gcode/calibrate/M425.cpp @@ -55,8 +55,8 @@ void GcodeSuite::M425() { } }; - LOOP_XYZ(a) { - if (axis_can_calibrate(a) && parser.seen(XYZ_CHAR(a))) { + LOOP_LINEAR_AXES(a) { + if (axis_can_calibrate(a) && parser.seen(AXIS_CHAR(a))) { planner.synchronize(); backlash.distance_mm[a] = parser.has_value() ? parser.value_linear_units() : backlash.get_measurement(AxisEnum(a)); noArgs = false; @@ -83,8 +83,8 @@ void GcodeSuite::M425() { SERIAL_ECHOLNPGM("active:"); SERIAL_ECHOLNPAIR(" Correction Amount/Fade-out: F", backlash.get_correction(), " (F1.0 = full, F0.0 = none)"); SERIAL_ECHOPGM(" Backlash Distance (mm): "); - LOOP_XYZ(a) if (axis_can_calibrate(a)) { - SERIAL_CHAR(' ', XYZ_CHAR(a)); + LOOP_LINEAR_AXES(a) if (axis_can_calibrate(a)) { + SERIAL_CHAR(' ', AXIS_CHAR(a)); SERIAL_ECHO(backlash.distance_mm[a]); SERIAL_EOL(); } @@ -96,8 +96,8 @@ void GcodeSuite::M425() { #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) SERIAL_ECHOPGM(" Average measured backlash (mm):"); if (backlash.has_any_measurement()) { - LOOP_XYZ(a) if (axis_can_calibrate(a) && backlash.has_measurement(AxisEnum(a))) { - SERIAL_CHAR(' ', XYZ_CHAR(a)); + LOOP_LINEAR_AXES(a) if (axis_can_calibrate(a) && backlash.has_measurement(AxisEnum(a))) { + SERIAL_CHAR(' ', AXIS_CHAR(a)); SERIAL_ECHO(backlash.get_measurement(AxisEnum(a))); } } diff --git a/Marlin/src/gcode/calibrate/M666.cpp b/Marlin/src/gcode/calibrate/M666.cpp index 75becf13f369..a3a48cd3fc1f 100644 --- a/Marlin/src/gcode/calibrate/M666.cpp +++ b/Marlin/src/gcode/calibrate/M666.cpp @@ -39,11 +39,11 @@ */ void GcodeSuite::M666() { DEBUG_SECTION(log_M666, "M666", DEBUGGING(LEVELING)); - LOOP_XYZ(i) { - if (parser.seen(XYZ_CHAR(i))) { + LOOP_LINEAR_AXES(i) { + if (parser.seen(AXIS_CHAR(i))) { const float v = parser.value_linear_units(); if (v * Z_HOME_DIR <= 0) delta_endstop_adj[i] = v; - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", AS_CHAR(XYZ_CHAR(i)), "] = ", delta_endstop_adj[i]); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", AS_CHAR(AXIS_CHAR(i)), "] = ", delta_endstop_adj[i]); } } } diff --git a/Marlin/src/gcode/calibrate/M852.cpp b/Marlin/src/gcode/calibrate/M852.cpp index e52f03b86c4e..a038dc59fdf6 100644 --- a/Marlin/src/gcode/calibrate/M852.cpp +++ b/Marlin/src/gcode/calibrate/M852.cpp @@ -86,7 +86,7 @@ void GcodeSuite::M852() { // When skew is changed the current position changes if (setval) { - set_current_from_steppers_for_axis(ALL_AXES); + set_current_from_steppers_for_axis(ALL_AXES_MASK); sync_plan_position(); report_current_position(); } diff --git a/Marlin/src/gcode/config/M200-M205.cpp b/Marlin/src/gcode/config/M200-M205.cpp index 55cfc1bf46d5..06751f41c499 100644 --- a/Marlin/src/gcode/config/M200-M205.cpp +++ b/Marlin/src/gcode/config/M200-M205.cpp @@ -86,7 +86,7 @@ void GcodeSuite::M201() { if (parser.seenval('G')) planner.xy_freq_min_speed_factor = constrain(parser.value_float(), 1, 100) / 100; #endif - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { if (parser.seenval(axis_codes[i])) { const uint8_t a = (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i); planner.set_max_acceleration(a, parser.value_axis_units((AxisEnum)a)); @@ -104,7 +104,7 @@ void GcodeSuite::M203() { const int8_t target_extruder = get_target_extruder_from_command(); if (target_extruder < 0) return; - LOOP_XYZE(i) + LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) { const uint8_t a = (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i); planner.set_max_feedrate(a, parser.value_axis_units((AxisEnum)a)); diff --git a/Marlin/src/gcode/config/M92.cpp b/Marlin/src/gcode/config/M92.cpp index e83f5b314f4d..06c47b825334 100644 --- a/Marlin/src/gcode/config/M92.cpp +++ b/Marlin/src/gcode/config/M92.cpp @@ -67,7 +67,7 @@ void GcodeSuite::M92() { if (!parser.seen("XYZE" TERN_(MAGIC_NUMBERS_GCODE, "HL"))) return report_M92(true, target_extruder); - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { if (parser.seenval(axis_codes[i])) { if (i == E_AXIS) { const float value = parser.value_per_axis_units((AxisEnum)(E_AXIS_N(target_extruder))); diff --git a/Marlin/src/gcode/control/M350_M351.cpp b/Marlin/src/gcode/control/M350_M351.cpp index 463bd2ad5815..a92238e4bbf2 100644 --- a/Marlin/src/gcode/control/M350_M351.cpp +++ b/Marlin/src/gcode/control/M350_M351.cpp @@ -34,7 +34,7 @@ */ void GcodeSuite::M350() { if (parser.seen('S')) LOOP_LE_N(i, 4) stepper.microstep_mode(i, parser.value_byte()); - LOOP_XYZE(i) if (parser.seen(axis_codes[i])) stepper.microstep_mode(i, parser.value_byte()); + LOOP_LOGICAL_AXES(i) if (parser.seen(axis_codes[i])) stepper.microstep_mode(i, parser.value_byte()); if (parser.seen('B')) stepper.microstep_mode(4, parser.value_byte()); stepper.microstep_readings(); } @@ -46,15 +46,15 @@ void GcodeSuite::M350() { void GcodeSuite::M351() { if (parser.seenval('S')) switch (parser.value_byte()) { case 1: - LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, parser.value_byte(), -1, -1); + LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, parser.value_byte(), -1, -1); if (parser.seenval('B')) stepper.microstep_ms(4, parser.value_byte(), -1, -1); break; case 2: - LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, -1, parser.value_byte(), -1); + LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, -1, parser.value_byte(), -1); if (parser.seenval('B')) stepper.microstep_ms(4, -1, parser.value_byte(), -1); break; case 3: - LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, -1, -1, parser.value_byte()); + LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, -1, -1, parser.value_byte()); if (parser.seenval('B')) stepper.microstep_ms(4, -1, -1, parser.value_byte()); break; } diff --git a/Marlin/src/gcode/control/M605.cpp b/Marlin/src/gcode/control/M605.cpp index e0c79f0e54e2..ac84ac621796 100644 --- a/Marlin/src/gcode/control/M605.cpp +++ b/Marlin/src/gcode/control/M605.cpp @@ -141,7 +141,7 @@ HOTEND_LOOP() { DEBUG_ECHOPAIR_P(SP_T_STR, e); - LOOP_XYZ(a) DEBUG_ECHOPAIR(" hotend_offset[", e, "].", AS_CHAR(XYZ_CHAR(a) | 0x20), "=", hotend_offset[e][a]); + LOOP_LINEAR_AXES(a) DEBUG_ECHOPAIR(" hotend_offset[", e, "].", AS_CHAR(AXIS_CHAR(a) | 0x20), "=", hotend_offset[e][a]); DEBUG_EOL(); } DEBUG_EOL(); diff --git a/Marlin/src/gcode/feature/L6470/M906.cpp b/Marlin/src/gcode/feature/L6470/M906.cpp index 3638fae45b5c..87614e9c73de 100644 --- a/Marlin/src/gcode/feature/L6470/M906.cpp +++ b/Marlin/src/gcode/feature/L6470/M906.cpp @@ -234,7 +234,7 @@ void GcodeSuite::M906() { const uint8_t index = parser.byteval('I'); #endif - LOOP_XYZE(i) if (uint16_t value = parser.intval(axis_codes[i])) { + LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(axis_codes[i])) { report_current = false; diff --git a/Marlin/src/gcode/feature/digipot/M907-M910.cpp b/Marlin/src/gcode/feature/digipot/M907-M910.cpp index e46366620798..ee9801eda910 100644 --- a/Marlin/src/gcode/feature/digipot/M907-M910.cpp +++ b/Marlin/src/gcode/feature/digipot/M907-M910.cpp @@ -44,7 +44,7 @@ void GcodeSuite::M907() { #if HAS_MOTOR_CURRENT_SPI - LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper.set_digipot_current(i, parser.value_int()); + LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.set_digipot_current(i, parser.value_int()); if (parser.seenval('B')) stepper.set_digipot_current(4, parser.value_int()); if (parser.seenval('S')) LOOP_LE_N(i, 4) stepper.set_digipot_current(i, parser.value_int()); @@ -64,7 +64,7 @@ void GcodeSuite::M907() { #if HAS_MOTOR_CURRENT_I2C // this one uses actual amps in floating point - LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) digipot_i2c.set_current(i, parser.value_float()); + LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) digipot_i2c.set_current(i, parser.value_float()); // Additional extruders use B,C,D for channels 4,5,6. // TODO: Change these parameters because 'E' is used. B? for (uint8_t i = E_AXIS + 1; i < DIGIPOT_I2C_NUM_CHANNELS; i++) @@ -76,7 +76,7 @@ void GcodeSuite::M907() { const float dac_percent = parser.value_float(); LOOP_LE_N(i, 4) stepper_dac.set_current_percent(i, dac_percent); } - LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper_dac.set_current_percent(i, parser.value_float()); + LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper_dac.set_current_percent(i, parser.value_float()); #endif } diff --git a/Marlin/src/gcode/feature/pause/G61.cpp b/Marlin/src/gcode/feature/pause/G61.cpp index bb1146490209..a6d7cb3094c4 100644 --- a/Marlin/src/gcode/feature/pause/G61.cpp +++ b/Marlin/src/gcode/feature/pause/G61.cpp @@ -71,11 +71,11 @@ void GcodeSuite::G61(void) { else { if (parser.seen("XYZ")) { DEBUG_ECHOPAIR(STR_RESTORING_POS " S", slot); - LOOP_XYZ(i) { - destination[i] = parser.seen(XYZ_CHAR(i)) + LOOP_LINEAR_AXES(i) { + destination[i] = parser.seen(AXIS_CHAR(i)) ? stored_position[slot][i] + parser.value_axis_units((AxisEnum)i) : current_position[i]; - DEBUG_CHAR(' ', XYZ_CHAR(i)); + DEBUG_CHAR(' ', AXIS_CHAR(i)); DEBUG_ECHO_F(destination[i]); } DEBUG_EOL(); diff --git a/Marlin/src/gcode/feature/trinamic/M122.cpp b/Marlin/src/gcode/feature/trinamic/M122.cpp index c338e48df418..054d145c8c23 100644 --- a/Marlin/src/gcode/feature/trinamic/M122.cpp +++ b/Marlin/src/gcode/feature/trinamic/M122.cpp @@ -32,12 +32,12 @@ * M122: Debug TMC drivers */ void GcodeSuite::M122() { - xyze_bool_t print_axis = ARRAY_N_1(XYZE, false); + xyze_bool_t print_axis = ARRAY_N_1(LOGICAL_AXES, false); bool print_all = true; - LOOP_XYZE(i) if (parser.seen(axis_codes[i])) { print_axis[i] = true; print_all = false; } + LOOP_LOGICAL_AXES(i) if (parser.seen(axis_codes[i])) { print_axis[i] = true; print_all = false; } - if (print_all) LOOP_XYZE(i) print_axis[i] = true; + if (print_all) LOOP_LOGICAL_AXES(i) print_axis[i] = true; if (parser.boolval('I')) restore_stepper_drivers(); diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp index a92812004fb8..8f1c0ed81923 100644 --- a/Marlin/src/gcode/feature/trinamic/M569.cpp +++ b/Marlin/src/gcode/feature/trinamic/M569.cpp @@ -50,7 +50,7 @@ static void set_stealth_status(const bool enable, const int8_t target_extruder) const uint8_t index = parser.byteval('I'); #endif - LOOP_XYZE(i) if (parser.seen(axis_codes[i])) { + LOOP_LOGICAL_AXES(i) if (parser.seen(axis_codes[i])) { switch (i) { case X_AXIS: #if AXIS_HAS_STEALTHCHOP(X) diff --git a/Marlin/src/gcode/feature/trinamic/M906.cpp b/Marlin/src/gcode/feature/trinamic/M906.cpp index e834ebd67d95..86e0cd29871e 100644 --- a/Marlin/src/gcode/feature/trinamic/M906.cpp +++ b/Marlin/src/gcode/feature/trinamic/M906.cpp @@ -52,7 +52,7 @@ void GcodeSuite::M906() { const uint8_t index = parser.byteval('I'); #endif - LOOP_XYZE(i) if (uint16_t value = parser.intval(axis_codes[i])) { + LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(axis_codes[i])) { report = false; switch (i) { case X_AXIS: diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index 0c5fff7025b9..c4b4a8772e95 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -209,7 +209,7 @@ #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) const uint8_t index = parser.byteval('I'); #endif - LOOP_XYZE(i) if (int32_t value = parser.longval(axis_codes[i])) { + LOOP_LOGICAL_AXES(i) if (int32_t value = parser.longval(axis_codes[i])) { report = false; switch (i) { case X_AXIS: @@ -338,7 +338,7 @@ bool report = true; const uint8_t index = parser.byteval('I'); - LOOP_XYZ(i) if (parser.seen(XYZ_CHAR(i))) { + LOOP_LINEAR_AXES(i) if (parser.seen(AXIS_CHAR(i))) { const int16_t value = parser.value_int(); report = false; switch (i) { diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 34a719c4669f..33877cd61c5f 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -149,8 +149,8 @@ void GcodeSuite::get_destination_from_command() { #endif // Get new XYZ position, whether absolute or relative - LOOP_XYZ(i) { - if ( (seen[i] = parser.seenval(XYZ_CHAR(i))) ) { + LOOP_LINEAR_AXES(i) { + if ( (seen[i] = parser.seenval(AXIS_CHAR(i))) ) { const float v = parser.value_axis_units((AxisEnum)i); if (skip_move) destination[i] = current_position[i]; diff --git a/Marlin/src/gcode/geometry/G53-G59.cpp b/Marlin/src/gcode/geometry/G53-G59.cpp index 05bc522768a2..a5a9f70a8b61 100644 --- a/Marlin/src/gcode/geometry/G53-G59.cpp +++ b/Marlin/src/gcode/geometry/G53-G59.cpp @@ -39,7 +39,7 @@ bool GcodeSuite::select_coordinate_system(const int8_t _new) { xyz_float_t new_offset{0}; if (WITHIN(_new, 0, MAX_COORDINATE_SYSTEMS - 1)) new_offset = coordinate_system[_new]; - LOOP_XYZ(i) { + LOOP_LINEAR_AXES(i) { if (position_shift[i] != new_offset[i]) { position_shift[i] = new_offset[i]; update_workspace_offset((AxisEnum)i); diff --git a/Marlin/src/gcode/geometry/G92.cpp b/Marlin/src/gcode/geometry/G92.cpp index 30620be6f958..a9970b1e9c09 100644 --- a/Marlin/src/gcode/geometry/G92.cpp +++ b/Marlin/src/gcode/geometry/G92.cpp @@ -61,7 +61,7 @@ void GcodeSuite::G92() { #if ENABLED(CNC_COORDINATE_SYSTEMS) && !IS_SCARA case 1: // G92.1 - Zero the Workspace Offset - LOOP_XYZ(i) if (position_shift[i]) { + LOOP_LINEAR_AXES(i) if (position_shift[i]) { position_shift[i] = 0; update_workspace_offset((AxisEnum)i); } @@ -70,7 +70,7 @@ void GcodeSuite::G92() { #if ENABLED(POWER_LOSS_RECOVERY) case 9: // G92.9 - Set Current Position directly (like Marlin 1.0) - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { if (parser.seenval(axis_codes[i])) { if (i == E_AXIS) sync_E = true; else sync_XYZE = true; current_position[i] = parser.value_axis_units((AxisEnum)i); @@ -80,7 +80,7 @@ void GcodeSuite::G92() { #endif case 0: - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { if (parser.seenval(axis_codes[i])) { const float l = parser.value_axis_units((AxisEnum)i), // Given axis coordinate value, converted to millimeters v = i == E_AXIS ? l : LOGICAL_TO_NATIVE(l, i), // Axis position in NATIVE space (applying the existing offset) diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index ac2420fcc3e3..e65540eb8c31 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -42,8 +42,8 @@ void M206_report() { * *** In the 2.0 release, it will simply be disabled by default. */ void GcodeSuite::M206() { - LOOP_XYZ(i) - if (parser.seen(XYZ_CHAR(i))) + LOOP_LINEAR_AXES(i) + if (parser.seen(AXIS_CHAR(i))) set_home_offset((AxisEnum)i, parser.value_linear_units()); #if ENABLED(MORGAN_SCARA) @@ -72,7 +72,7 @@ void GcodeSuite::M428() { if (homing_needed_error()) return; xyz_float_t diff; - LOOP_XYZ(i) { + LOOP_LINEAR_AXES(i) { diff[i] = base_home_pos((AxisEnum)i) - current_position[i]; if (!WITHIN(diff[i], -20, 20) && home_dir((AxisEnum)i) > 0) diff[i] = -current_position[i]; @@ -84,7 +84,7 @@ void GcodeSuite::M428() { } } - LOOP_XYZ(i) set_home_offset((AxisEnum)i, diff[i]); + LOOP_LINEAR_AXES(i) set_home_offset((AxisEnum)i, diff[i]); report_current_position(); LCD_MESSAGEPGM(MSG_HOME_OFFSETS_APPLIED); BUZZ(100, 659); diff --git a/Marlin/src/gcode/host/M114.cpp b/Marlin/src/gcode/host/M114.cpp index 27b193851d27..2d43d33aa122 100644 --- a/Marlin/src/gcode/host/M114.cpp +++ b/Marlin/src/gcode/host/M114.cpp @@ -47,8 +47,8 @@ void report_linear_axis_pos(const xyz_pos_t &pos, const uint8_t precision=3) { char str[12]; - LOOP_XYZ(a) { - SERIAL_CHAR(' ', XYZ_CHAR(a), ':'); + LOOP_LINEAR_AXES(a) { + SERIAL_CHAR(' ', AXIS_CHAR(a), ':'); SERIAL_ECHO(dtostrf(pos[a], 1, precision, str)); } SERIAL_EOL(); @@ -153,7 +153,7 @@ #endif // HAS_L64XX SERIAL_ECHOPGM("Stepper:"); - LOOP_XYZE(i) { + LOOP_LOGICAL_AXES(i) { SERIAL_CHAR(' ', axis_codes[i], ':'); SERIAL_ECHO(stepper.position((AxisEnum)i)); } diff --git a/Marlin/src/gcode/motion/M290.cpp b/Marlin/src/gcode/motion/M290.cpp index 7e5a0177835f..0a858090f955 100644 --- a/Marlin/src/gcode/motion/M290.cpp +++ b/Marlin/src/gcode/motion/M290.cpp @@ -69,8 +69,8 @@ */ void GcodeSuite::M290() { #if ENABLED(BABYSTEP_XY) - LOOP_XYZ(a) - if (parser.seenval(XYZ_CHAR(a)) || (a == Z_AXIS && parser.seenval('S'))) { + LOOP_LINEAR_AXES(a) + if (parser.seenval(AXIS_CHAR(a)) || (a == Z_AXIS && parser.seenval('S'))) { const float offs = constrain(parser.value_axis_units((AxisEnum)a), -2, 2); babystep.add_mm((AxisEnum)a, offs); #if ENABLED(BABYSTEP_ZPROBE_OFFSET) diff --git a/Marlin/src/gcode/probe/G38.cpp b/Marlin/src/gcode/probe/G38.cpp index b06cd47359c7..606776f40299 100644 --- a/Marlin/src/gcode/probe/G38.cpp +++ b/Marlin/src/gcode/probe/G38.cpp @@ -38,7 +38,7 @@ inline void G38_single_probe(const uint8_t move_value) { planner.synchronize(); G38_move = 0; endstops.hit_on_purpose(); - set_current_from_steppers_for_axis(ALL_AXES); + set_current_from_steppers_for_axis(ALL_AXES_MASK); sync_plan_position(); } @@ -49,7 +49,7 @@ inline bool G38_run_probe() { #if MULTIPLE_PROBING > 1 // Get direction of move and retract xyz_float_t retract_mm; - LOOP_XYZ(i) { + LOOP_LINEAR_AXES(i) { const float dist = destination[i] - current_position[i]; retract_mm[i] = ABS(dist) < G38_MINIMUM_MOVE ? 0 : home_bump_mm((AxisEnum)i) * (dist > 0 ? -1 : 1); } @@ -119,7 +119,7 @@ void GcodeSuite::G38(const int8_t subcode) { ; // If any axis has enough movement, do the move - LOOP_XYZ(i) + LOOP_LINEAR_AXES(i) if (ABS(destination[i] - current_position[i]) >= G38_MINIMUM_MOVE) { if (!parser.seenval('F')) feedrate_mm_s = homing_feedrate((AxisEnum)i); // If G38.2 fails throw an error diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 000aa6034728..ccfe30947c80 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -651,22 +651,38 @@ #endif /** - * DISTINCT_E_FACTORS affects how some E factors are accessed + * Number of Linear Axes (e.g., XYZ) + * All the logical axes except for the tool (E) axis + */ +#ifndef LINEAR_AXES + #define LINEAR_AXES XYZ +#endif + +/** + * Number of Logical Axes (e.g., XYZE) + * All the logical axes that can be commanded directly by G-code. + * Delta maps stepper-specific values to ABC steppers. + */ +#if EXTRUDERS + #define LOGICAL_AXES INCREMENT(LINEAR_AXES) +#else + #define LOGICAL_AXES LINEAR_AXES +#endif + +/** + * DISTINCT_E_FACTORS affects whether Extruders use different settings */ #if ENABLED(DISTINCT_E_FACTORS) && E_STEPPERS > 1 #define DISTINCT_E E_STEPPERS - #define XYZE_N (XYZ + E_STEPPERS) + #define DISTINCT_AXES (LINEAR_AXES + E_STEPPERS) #define E_INDEX_N(E) (E) - #define E_AXIS_N(E) AxisEnum(E_AXIS + E) - #define UNUSED_E(E) NOOP #else #undef DISTINCT_E_FACTORS #define DISTINCT_E 1 - #define XYZE_N XYZE + #define DISTINCT_AXES LOGICAL_AXES #define E_INDEX_N(E) 0 - #define E_AXIS_N(E) E_AXIS - #define UNUSED_E(E) UNUSED(E) #endif +#define E_AXIS_N(E) AxisEnum(E_AXIS + E_INDEX_N(E)) /** * The BLTouch Probe emulates a servo probe diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 1f0b301f0a93..04f8a45c3b86 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2819,22 +2819,22 @@ constexpr float sanity_arr_1[] = DEFAULT_AXIS_STEPS_PER_UNIT, #define _EXTRA_NOTE "" #endif -static_assert(COUNT(sanity_arr_1) >= XYZE, "DEFAULT_AXIS_STEPS_PER_UNIT requires X, Y, Z and E elements."); -static_assert(COUNT(sanity_arr_1) <= XYZE_N, "DEFAULT_AXIS_STEPS_PER_UNIT has too many elements." _EXTRA_NOTE); +static_assert(COUNT(sanity_arr_1) >= LOGICAL_AXES, "DEFAULT_AXIS_STEPS_PER_UNIT requires X, Y, Z and E elements."); +static_assert(COUNT(sanity_arr_1) <= DISTINCT_AXES, "DEFAULT_AXIS_STEPS_PER_UNIT has too many elements." _EXTRA_NOTE); static_assert( _ARR_TEST(1,0) && _ARR_TEST(1,1) && _ARR_TEST(1,2) && _ARR_TEST(1,3) && _ARR_TEST(1,4) && _ARR_TEST(1,5) && _ARR_TEST(1,6) && _ARR_TEST(1,7) && _ARR_TEST(1,8), "DEFAULT_AXIS_STEPS_PER_UNIT values must be positive."); -static_assert(COUNT(sanity_arr_2) >= XYZE, "DEFAULT_MAX_FEEDRATE requires X, Y, Z and E elements."); -static_assert(COUNT(sanity_arr_2) <= XYZE_N, "DEFAULT_MAX_FEEDRATE has too many elements." _EXTRA_NOTE); +static_assert(COUNT(sanity_arr_2) >= LOGICAL_AXES, "DEFAULT_MAX_FEEDRATE requires X, Y, Z and E elements."); +static_assert(COUNT(sanity_arr_2) <= DISTINCT_AXES, "DEFAULT_MAX_FEEDRATE has too many elements." _EXTRA_NOTE); static_assert( _ARR_TEST(2,0) && _ARR_TEST(2,1) && _ARR_TEST(2,2) && _ARR_TEST(2,3) && _ARR_TEST(2,4) && _ARR_TEST(2,5) && _ARR_TEST(2,6) && _ARR_TEST(2,7) && _ARR_TEST(2,8), "DEFAULT_MAX_FEEDRATE values must be positive."); -static_assert(COUNT(sanity_arr_3) >= XYZE, "DEFAULT_MAX_ACCELERATION requires X, Y, Z and E elements."); -static_assert(COUNT(sanity_arr_3) <= XYZE_N, "DEFAULT_MAX_ACCELERATION has too many elements." _EXTRA_NOTE); +static_assert(COUNT(sanity_arr_3) >= LOGICAL_AXES, "DEFAULT_MAX_ACCELERATION requires X, Y, Z and E elements."); +static_assert(COUNT(sanity_arr_3) <= DISTINCT_AXES, "DEFAULT_MAX_ACCELERATION has too many elements." _EXTRA_NOTE); static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) && _ARR_TEST(3,3) && _ARR_TEST(3,4) && _ARR_TEST(3,5) && _ARR_TEST(3,6) && _ARR_TEST(3,7) && _ARR_TEST(3,8), @@ -2843,8 +2843,8 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #if ENABLED(LIMITED_MAX_ACCEL_EDITING) #ifdef MAX_ACCEL_EDIT_VALUES constexpr float sanity_arr_4[] = MAX_ACCEL_EDIT_VALUES; - static_assert(COUNT(sanity_arr_4) >= XYZE, "MAX_ACCEL_EDIT_VALUES requires X, Y, Z and E elements."); - static_assert(COUNT(sanity_arr_4) <= XYZE, "MAX_ACCEL_EDIT_VALUES has too many elements. X, Y, Z and E elements only."); + static_assert(COUNT(sanity_arr_4) >= LOGICAL_AXES, "MAX_ACCEL_EDIT_VALUES requires X, Y, Z and E elements."); + static_assert(COUNT(sanity_arr_4) <= LOGICAL_AXES, "MAX_ACCEL_EDIT_VALUES has too many elements. X, Y, Z and E elements only."); static_assert( _ARR_TEST(4,0) && _ARR_TEST(4,1) && _ARR_TEST(4,2) && _ARR_TEST(4,3) && _ARR_TEST(4,4) && _ARR_TEST(4,5) && _ARR_TEST(4,6) && _ARR_TEST(4,7) && _ARR_TEST(4,8), @@ -2855,8 +2855,8 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #if ENABLED(LIMITED_MAX_FR_EDITING) #ifdef MAX_FEEDRATE_EDIT_VALUES constexpr float sanity_arr_5[] = MAX_FEEDRATE_EDIT_VALUES; - static_assert(COUNT(sanity_arr_5) >= XYZE, "MAX_FEEDRATE_EDIT_VALUES requires X, Y, Z and E elements."); - static_assert(COUNT(sanity_arr_5) <= XYZE, "MAX_FEEDRATE_EDIT_VALUES has too many elements. X, Y, Z and E elements only."); + static_assert(COUNT(sanity_arr_5) >= LOGICAL_AXES, "MAX_FEEDRATE_EDIT_VALUES requires X, Y, Z and E elements."); + static_assert(COUNT(sanity_arr_5) <= LOGICAL_AXES, "MAX_FEEDRATE_EDIT_VALUES has too many elements. X, Y, Z and E elements only."); static_assert( _ARR_TEST(5,0) && _ARR_TEST(5,1) && _ARR_TEST(5,2) && _ARR_TEST(5,3) && _ARR_TEST(5,4) && _ARR_TEST(5,5) && _ARR_TEST(5,6) && _ARR_TEST(5,7) && _ARR_TEST(5,8), @@ -2867,8 +2867,8 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #if ENABLED(LIMITED_JERK_EDITING) #ifdef MAX_JERK_EDIT_VALUES constexpr float sanity_arr_6[] = MAX_JERK_EDIT_VALUES; - static_assert(COUNT(sanity_arr_6) >= XYZE, "MAX_JERK_EDIT_VALUES requires X, Y, Z and E elements."); - static_assert(COUNT(sanity_arr_6) <= XYZE, "MAX_JERK_EDIT_VALUES has too many elements. X, Y, Z and E elements only."); + static_assert(COUNT(sanity_arr_6) >= LOGICAL_AXES, "MAX_JERK_EDIT_VALUES requires X, Y, Z and E elements."); + static_assert(COUNT(sanity_arr_6) <= LOGICAL_AXES, "MAX_JERK_EDIT_VALUES has too many elements. X, Y, Z and E elements only."); static_assert( _ARR_TEST(6,0) && _ARR_TEST(6,1) && _ARR_TEST(6,2) && _ARR_TEST(6,3) && _ARR_TEST(6,4) && _ARR_TEST(6,5) && _ARR_TEST(6,6) && _ARR_TEST(6,7) && _ARR_TEST(6,8), diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 4c33b924c424..acc3b63ac053 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -684,7 +684,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { #if ENABLED(MULTI_MANUAL) int8_t ManualMove::e_index = 0; #endif - AxisEnum ManualMove::axis = NO_AXIS; + AxisEnum ManualMove::axis = NO_AXIS_MASK; /** * If a manual move has been posted and its time has arrived, and if the planner @@ -695,7 +695,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { * * To post a manual move: * - Update current_position to the new place you want to go. - * - Set manual_move.axis to an axis like X_AXIS. Use ALL_AXES for diagonal moves. + * - Set manual_move.axis to an axis like X_AXIS. Use ALL_AXES_MASK for diagonal moves. * - Set manual_move.start_time to a point in the future (in ms) when the move should be done. * * For kinematic machines: @@ -710,7 +710,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { if (processing) return; // Prevent re-entry from idle() calls // Add a manual move to the queue? - if (axis != NO_AXIS && ELAPSED(millis(), start_time) && !planner.is_full()) { + if (axis != NO_AXIS_MASK && ELAPSED(millis(), start_time) && !planner.is_full()) { const feedRate_t fr_mm_s = (axis <= E_AXIS) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; @@ -722,7 +722,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { #endif // Apply a linear offset to a single axis - if (axis == ALL_AXES) + if (axis == ALL_AXES_MASK) destination = all_axes_destination; else if (axis <= XYZE) { destination = current_position; @@ -731,7 +731,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { // Reset for the next move offset = 0; - axis = NO_AXIS; + axis = NO_AXIS_MASK; // DELTA and SCARA machines use segmented moves, which could fill the planner during the call to // move_to_destination. This will cause idle() to be called, which can then call this function while the @@ -748,7 +748,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { //SERIAL_ECHOLNPAIR("Add planner.move with Axis ", AS_CHAR(axis_codes[axis]), " at FR ", fr_mm_s); - axis = NO_AXIS; + axis = NO_AXIS_MASK; #endif } diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 044797b74946..e751b534466f 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -64,7 +64,7 @@ void menu_backlash(); void menu_dac() { static xyze_uint8_t driverPercent; - LOOP_XYZE(i) driverPercent[i] = stepper_dac.get_current_percent((AxisEnum)i); + LOOP_LOGICAL_AXES(i) driverPercent[i] = stepper_dac.get_current_percent((AxisEnum)i); START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); #define EDIT_DAC_PERCENT(A) EDIT_ITEM(uint8, MSG_DAC_PERCENT_##A, &driverPercent[_AXIS(A)], 0, 100, []{ stepper_dac.set_current_percents(driverPercent); }) diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index 8e9707de5bee..70de53dab593 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -206,7 +206,7 @@ #if ENABLED(MESH_EDIT_MENU) inline void refresh_planner() { - set_current_from_steppers_for_axis(ALL_AXES); + set_current_from_steppers_for_axis(ALL_AXES_MASK); sync_plan_position(); } diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index 1171837a57b3..f923f98c7828 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -430,7 +430,7 @@ void ubl_map_move_to_xy() { // Use the built-in manual move handler to move to the mesh point. ui.manual_move.set_destination(xy); - ui.manual_move.soon(ALL_AXES); + ui.manual_move.soon(ALL_AXES_MASK); } inline int32_t grid_index(const uint8_t x, const uint8_t y) { diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp index 8f71d52ec8ec..45c947e7904e 100644 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp +++ b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp @@ -395,7 +395,7 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in } uint8_t found_displacement = false; - LOOP_XYZE(i) if (uint16_t _displacement = parser.intval(axis_codes[i])) { + LOOP_LOGICAL_AXES(i) if (uint16_t _displacement = parser.intval(axis_codes[i])) { found_displacement = true; displacement = _displacement; uint8_t axis_offset = parser.byteval('J'); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 97be6226ba46..427aea80b15e 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -124,7 +124,7 @@ xyze_pos_t destination; // {0} "Offsets for the first hotend must be 0.0." ); // Transpose from [XYZ][HOTENDS] to [HOTENDS][XYZ] - HOTEND_LOOP() LOOP_XYZ(a) hotend_offset[e][a] = tmp[a][e]; + HOTEND_LOOP() LOOP_LINEAR_AXES(a) hotend_offset[e][a] = tmp[a][e]; #if ENABLED(DUAL_X_CARRIAGE) hotend_offset[1].x = _MAX(X2_HOME_POS, X2_MAX_POS); #endif @@ -282,7 +282,7 @@ void report_current_position_projected() { void quickstop_stepper() { planner.quick_stop(); planner.synchronize(); - set_current_from_steppers_for_axis(ALL_AXES); + set_current_from_steppers_for_axis(ALL_AXES_MASK); sync_plan_position(); } @@ -360,7 +360,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) { planner.unapply_modifiers(pos, true); #endif - if (axis == ALL_AXES) + if (axis == ALL_AXES_MASK) current_position = pos; else current_position[axis] = pos[axis]; @@ -681,7 +681,7 @@ void restore_feedrate_and_scaling() { #endif if (DEBUGGING(LEVELING)) - SERIAL_ECHOLNPAIR("Axis ", AS_CHAR(XYZ_CHAR(axis)), " min:", soft_endstop.min[axis], " max:", soft_endstop.max[axis]); + SERIAL_ECHOLNPAIR("Axis ", AS_CHAR(AXIS_CHAR(axis)), " min:", soft_endstop.min[axis], " max:", soft_endstop.max[axis]); } /** @@ -1951,7 +1951,7 @@ void set_axis_is_at_home(const AxisEnum axis) { #if HAS_WORKSPACE_OFFSET void update_workspace_offset(const AxisEnum axis) { workspace_offset[axis] = home_offset[axis] + position_shift[axis]; - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Axis ", AS_CHAR(XYZ_CHAR(axis)), " home_offset = ", home_offset[axis], " position_shift = ", position_shift[axis]); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Axis ", AS_CHAR(AXIS_CHAR(axis)), " home_offset = ", home_offset[axis], " position_shift = ", position_shift[axis]); } #endif diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index f11f2738676d..dde6e89a1f48 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -136,9 +136,9 @@ planner_settings_t Planner::settings; // Initialized by settings.load( laser_state_t Planner::laser_inline; // Current state for blocks #endif -uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N]; // (steps/s^2) Derived from mm_per_s2 +uint32_t Planner::max_acceleration_steps_per_s2[DISTINCT_AXES]; // (steps/s^2) Derived from mm_per_s2 -float Planner::steps_to_mm[XYZE_N]; // (mm) Millimeters per step +float Planner::steps_to_mm[DISTINCT_AXES]; // (mm) Millimeters per step #if HAS_JUNCTION_DEVIATION float Planner::junction_deviation_mm; // (mm) M205 J @@ -2201,7 +2201,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, float speed_factor = 1.0f; // factor <1 decreases speed // Linear axes first with less logic - LOOP_XYZ(i) { + LOOP_LINEAR_AXES(i) { current_speed[i] = steps_dist_mm[i] * inverse_secs; const feedRate_t cs = ABS(current_speed[i]), max_fr = settings.max_feedrate_mm_s[i]; @@ -2593,7 +2593,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, const float extra_xyjerk = (de <= 0) ? TRAVEL_EXTRA_XYJERK : 0; uint8_t limited = 0; - TERN(HAS_LINEAR_E_JERK, LOOP_XYZ, LOOP_XYZE)(i) { + TERN(HAS_LINEAR_E_JERK, LOOP_LINEAR_AXES, LOOP_LOGICAL_AXES)(i) { const float jerk = ABS(current_speed[i]), // cs : Starting from zero, change in speed for this axis maxj = (max_jerk[i] + (i == X_AXIS || i == Y_AXIS ? extra_xyjerk : 0.0f)); // mj : The max jerk setting for this axis if (jerk > maxj) { // cs > mj : New current speed too fast? @@ -2631,7 +2631,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, vmax_junction = previous_nominal_speed; // Now limit the jerk in all axes. - TERN(HAS_LINEAR_E_JERK, LOOP_XYZ, LOOP_XYZE)(axis) { + TERN(HAS_LINEAR_E_JERK, LOOP_LINEAR_AXES, LOOP_LOGICAL_AXES)(axis) { // Limit an axis. We have to differentiate: coasting, reversal of an axis, full stop. float v_exit = previous_speed[axis] * smaller_speed_factor, v_entry = current_speed[axis]; @@ -3033,7 +3033,7 @@ void Planner::reset_acceleration_rates() { #define AXIS_CONDITION true #endif uint32_t highest_rate = 1; - LOOP_XYZE_N(i) { + LOOP_DISTINCT_AXES(i) { max_acceleration_steps_per_s2[i] = settings.max_acceleration_mm_per_s2[i] * settings.axis_steps_per_mm[i]; if (AXIS_CONDITION) NOLESS(highest_rate, max_acceleration_steps_per_s2[i]); } @@ -3046,7 +3046,7 @@ void Planner::reset_acceleration_rates() { * Must be called whenever settings.axis_steps_per_mm changes! */ void Planner::refresh_positioning() { - LOOP_XYZE_N(i) steps_to_mm[i] = 1.0f / settings.axis_steps_per_mm[i]; + LOOP_DISTINCT_AXES(i) steps_to_mm[i] = 1.0f / settings.axis_steps_per_mm[i]; set_position_mm(current_position); reset_acceleration_rates(); } diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 30eeb758a477..db83792b452f 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -268,10 +268,10 @@ typedef struct block_t { #endif typedef struct { - uint32_t max_acceleration_mm_per_s2[XYZE_N], // (mm/s^2) M201 XYZE + uint32_t max_acceleration_mm_per_s2[DISTINCT_AXES], // (mm/s^2) M201 XYZE min_segment_time_us; // (µs) M205 B - float axis_steps_per_mm[XYZE_N]; // (steps) M92 XYZE - Steps per millimeter - feedRate_t max_feedrate_mm_s[XYZE_N]; // (mm/s) M203 XYZE - Max speeds + float axis_steps_per_mm[DISTINCT_AXES]; // (steps) M92 XYZE - Steps per millimeter + feedRate_t max_feedrate_mm_s[DISTINCT_AXES]; // (mm/s) M203 XYZE - Max speeds float acceleration, // (mm/s^2) M204 S - Normal acceleration. DEFAULT ACCELERATION for all printing moves. retract_acceleration, // (mm/s^2) M204 R - Retract acceleration. Filament pull-back and push-forward while standing still in the other axes travel_acceleration; // (mm/s^2) M204 T - Travel acceleration. DEFAULT ACCELERATION for all NON printing moves. @@ -360,13 +360,13 @@ class Planner { static laser_state_t laser_inline; #endif - static uint32_t max_acceleration_steps_per_s2[XYZE_N]; // (steps/s^2) Derived from mm_per_s2 - static float steps_to_mm[XYZE_N]; // Millimeters per step + static uint32_t max_acceleration_steps_per_s2[DISTINCT_AXES]; // (steps/s^2) Derived from mm_per_s2 + static float steps_to_mm[DISTINCT_AXES]; // Millimeters per step #if HAS_JUNCTION_DEVIATION - static float junction_deviation_mm; // (mm) M205 J + static float junction_deviation_mm; // (mm) M205 J #if HAS_LINEAR_E_JERK - static float max_e_jerk[DISTINCT_E]; // Calculated from junction_deviation_mm + static float max_e_jerk[DISTINCT_E]; // Calculated from junction_deviation_mm #endif #endif @@ -1014,13 +1014,13 @@ class Planner { FORCE_INLINE static void normalize_junction_vector(xyze_float_t &vector) { float magnitude_sq = 0; - LOOP_XYZE(idx) if (vector[idx]) magnitude_sq += sq(vector[idx]); + LOOP_LOGICAL_AXES(idx) if (vector[idx]) magnitude_sq += sq(vector[idx]); vector *= RSQRT(magnitude_sq); } FORCE_INLINE static float limit_value_by_axis_maximum(const_float_t max_value, xyze_float_t &unit_vec) { float limit_value = max_value; - LOOP_XYZE(idx) { + LOOP_LOGICAL_AXES(idx) { if (unit_vec[idx]) { if (limit_value * ABS(unit_vec[idx]) > settings.max_acceleration_mm_per_s2[idx]) limit_value = ABS(settings.max_acceleration_mm_per_s2[idx] / unit_vec[idx]); diff --git a/Marlin/src/module/scara.cpp b/Marlin/src/module/scara.cpp index e058804c904d..b0544c7791ac 100644 --- a/Marlin/src/module/scara.cpp +++ b/Marlin/src/module/scara.cpp @@ -254,7 +254,7 @@ float segments_per_second = TERN(AXEL_TPARA, TPARA_SEGMENTS_PER_SECOND, SCARA_SE // Do this here all at once for Delta, because // XYZ isn't ABC. Applying this per-tower would // give the impression that they are the same. - LOOP_XYZ(i) set_axis_is_at_home((AxisEnum)i); + LOOP_LINEAR_AXES(i) set_axis_is_at_home((AxisEnum)i); sync_plan_position(); } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 0ef382a71c40..56e3c86fd4a3 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -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]); } diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 5ddd762aa9ed..020f72e9e685 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -250,7 +250,7 @@ class Stepper { #ifndef PWM_MOTOR_CURRENT #define PWM_MOTOR_CURRENT DEFAULT_PWM_MOTOR_CURRENT #endif - #define MOTOR_CURRENT_COUNT XYZ + #define MOTOR_CURRENT_COUNT LINEAR_AXES #elif HAS_MOTOR_CURRENT_SPI static constexpr uint32_t digipot_count[] = DIGIPOT_MOTOR_CURRENT; #define MOTOR_CURRENT_COUNT COUNT(Stepper::digipot_count) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 559caa7f9803..03e85fdd8436 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1181,7 +1181,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { sync_plan_position(); #if ENABLED(DELTA) - //LOOP_XYZ(i) update_software_endstops(i); // or modify the constrain function + //LOOP_LINEAR_AXES(i) update_software_endstops(i); // or modify the constrain function const bool safe_to_move = current_position.z < delta_clip_start_height - 1; #else constexpr bool safe_to_move = true; From 926a7f27c66e777b5a838a87ee8931d35095fd03 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 18 May 2021 22:52:10 -0500 Subject: [PATCH 12/61] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Simplify=20TMC=20uti?= =?UTF-8?q?lities=20for=20more=20axes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 2 +- Marlin/src/feature/tmc_util.cpp | 6 +++--- Marlin/src/feature/tmc_util.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 5cd0269bac2c..5ef575a30f6a 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1488,7 +1488,7 @@ void setup() { #endif #if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF) - SETUP_RUN(test_tmc_connection(true, true, true, true)); + SETUP_RUN(test_tmc_connection()); #endif #if HAS_DRIVER_SAFE_POWER_PROTECT diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index a4f71414a6b6..9c4fbf08dfc8 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -211,7 +211,7 @@ SERIAL_PRINTLN(data.drv_status, HEX); if (data.is_ot) SERIAL_ECHOLNPGM("overtemperature"); if (data.is_s2g) SERIAL_ECHOLNPGM("coil short circuit"); - TERN_(TMC_DEBUG, tmc_report_all(true, true, true, true)); + TERN_(TMC_DEBUG, tmc_report_all()); kill(PSTR("Driver error")); } #endif @@ -889,7 +889,7 @@ * M122 report functions */ - void tmc_report_all(bool print_x, const bool print_y, const bool print_z, const bool print_e) { + void tmc_report_all(const bool print_x/*=true*/, const bool print_y/*=true*/, const bool print_z/*=true*/, const bool print_e/*=true*/) { #define TMC_REPORT(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); tmc_debug_loop(ITEM, print_x, print_y, print_z, print_e); }while(0) #define DRV_REPORT(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); drv_status_loop(ITEM, print_x, print_y, print_z, print_e); }while(0) TMC_REPORT("\t", TMC_CODES); @@ -1214,7 +1214,7 @@ static bool test_connection(TMC &st) { return test_result; } -void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z, const bool test_e) { +void test_tmc_connection(const bool test_x/*=true*/, const bool test_y/*=true*/, const bool test_z/*=true*/, const bool test_e/*=true*/) { uint8_t axis_connection = 0; if (test_x) { diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index 1767313ba26f..a0e07ab8a8c6 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -341,13 +341,13 @@ void tmc_print_current(TMC &st) { #endif void monitor_tmc_drivers(); -void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z, const bool test_e); +void test_tmc_connection(const bool test_x=true, const bool test_y=true, const bool test_z=true, const bool test_e=true); #if ENABLED(TMC_DEBUG) #if ENABLED(MONITOR_DRIVER_STATUS) void tmc_set_report_interval(const uint16_t update_interval); #endif - void tmc_report_all(const bool print_x, const bool print_y, const bool print_z, const bool print_e); + void tmc_report_all(const bool print_x=true, const bool print_y=true, const bool print_z=true, const bool print_e=true); void tmc_get_registers(const bool print_x, const bool print_y, const bool print_z, const bool print_e); #endif From 18b1ccda276d0474fa3d71912cd0921857ac5cf8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 18 May 2021 22:52:41 -0500 Subject: [PATCH 13/61] =?UTF-8?q?=E2=9C=85=20Fix=20tests=20for=20EXTRUDERS?= =?UTF-8?q?=200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/tests/mega2560 | 10 ++++++++-- buildroot/tests/rambo | 10 +++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 7bbf29e630f3..8e63c6e7b1b2 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -171,7 +171,10 @@ exec_test $1 $2 "Azteeg X3 | Mixing Extruder (x5) | Gradient Mix | Greek" "$3" # Test Laser features with 12864 LCD # restore_configs -opt_set MOTHERBOARD BOARD_RAMPS_14_EFB LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 EXTRUDERS 0 TEMP_SENSOR_1 0 SERIAL_PORT_2 2 +opt_set MOTHERBOARD BOARD_RAMPS_14_EFB LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 EXTRUDERS 0 TEMP_SENSOR_1 0 SERIAL_PORT_2 2 \ + DEFAULT_AXIS_STEPS_PER_UNIT '{ 80, 80, 400 }' \ + DEFAULT_MAX_FEEDRATE '{ 300, 300, 5 }' \ + DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT \ LASER_FEATURE AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_COOLANT_FLOW_METER MEATPACK_ON_SERIAL_PORT_1 @@ -181,7 +184,10 @@ exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air As # Test Laser features with 44780 LCD # restore_configs -opt_set MOTHERBOARD BOARD_RAMPS_14_EFB LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 EXTRUDERS 0 TEMP_SENSOR_1 0 +opt_set MOTHERBOARD BOARD_RAMPS_14_EFB LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 EXTRUDERS 0 TEMP_SENSOR_1 0 \ + DEFAULT_AXIS_STEPS_PER_UNIT '{ 80, 80, 400 }' \ + DEFAULT_MAX_FEEDRATE '{ 300, 300, 5 }' \ + DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT \ LASER_FEATURE AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_COOLANT_FLOW_METER diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index 87772a988bb2..9869b96b3478 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -45,6 +45,10 @@ restore_configs opt_set MOTHERBOARD BOARD_RAMBO \ EXTRUDERS 0 TEMP_SENSOR_0 999 DUMMY_THERMISTOR_999_VALUE 170 Z_HOME_DIR 1 \ DIGIPOT_MOTOR_CURRENT '{ 120, 120, 120, 120, 120 }' \ + DEFAULT_AXIS_STEPS_PER_UNIT '{ 80, 80, 4000 }' \ + DEFAULT_MAX_FEEDRATE '{ 300, 300, 5 }' \ + DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \ + AXIS_RELATIVE_MODES '{ false, false, false }' \ LEVEL_CORNERS_LEVELING_ORDER '{ LF, RF }' opt_enable USE_XMAX_PLUG USE_YMAX_PLUG USE_ZMAX_PLUG \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER REVERSE_ENCODER_DIRECTION SDSUPPORT EEPROM_SETTINGS \ @@ -58,7 +62,11 @@ exec_test $1 $2 "Rambo CNC Configuration" "$3" # Rambo heated bed only # restore_configs -opt_set MOTHERBOARD BOARD_RAMBO EXTRUDERS 0 TEMP_SENSOR_BED 1 +opt_set MOTHERBOARD BOARD_RAMBO EXTRUDERS 0 TEMP_SENSOR_BED 1 \ + DEFAULT_AXIS_STEPS_PER_UNIT '{ 80, 80, 4000 }' \ + DEFAULT_MAX_FEEDRATE '{ 300, 300, 5 }' \ + DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \ + AXIS_RELATIVE_MODES '{ false, false, false }' opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER exec_test $1 $2 "Rambo heated bed only" "$3" From 02f904dbf9df999264099a26c563b07b1d163df4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 18 May 2021 22:53:52 -0500 Subject: [PATCH 14/61] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Minimize=20endstop?= =?UTF-8?q?=20bits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/endstops.cpp | 17 ++++--- Marlin/src/module/endstops.h | 87 ++++++++++++++++++++++------------ Marlin/src/module/stepper.cpp | 8 ++-- 3 files changed, 68 insertions(+), 44 deletions(-) diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 2ac20c92ef6c..d0befe71fb58 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -56,12 +56,12 @@ Endstops endstops; // private: bool Endstops::enabled, Endstops::enabled_globally; // Initialized by settings.load() -volatile uint8_t Endstops::hit_state; -Endstops::esbits_t Endstops::live_state = 0; +volatile Endstops::endstop_mask_t Endstops::hit_state; +Endstops::endstop_mask_t Endstops::live_state = 0; #if ENDSTOP_NOISE_THRESHOLD - Endstops::esbits_t Endstops::validated_live_state; + Endstops::endstop_mask_t Endstops::validated_live_state; uint8_t Endstops::endstop_poll_count; #endif @@ -356,7 +356,7 @@ void Endstops::resync() { #endif void Endstops::event_handler() { - static uint8_t prev_hit_state; // = 0 + static endstop_mask_t prev_hit_state; // = 0 if (hit_state == prev_hit_state) return; prev_hit_state = hit_state; if (hit_state) { @@ -364,15 +364,14 @@ void Endstops::event_handler() { char chrX = ' ', chrY = ' ', chrZ = ' ', chrP = ' '; #define _SET_STOP_CHAR(A,C) (chr## A = C) #else - #define _SET_STOP_CHAR(A,C) ; + #define _SET_STOP_CHAR(A,C) NOOP #endif #define _ENDSTOP_HIT_ECHO(A,C) do{ \ - SERIAL_ECHOPAIR(" " STRINGIFY(A) ":", planner.triggered_position_mm(_AXIS(A))); \ - _SET_STOP_CHAR(A,C); }while(0) + SERIAL_ECHOPAIR(" " STRINGIFY(A) ":", planner.triggered_position_mm(_AXIS(A))); _SET_STOP_CHAR(A,C); }while(0) #define _ENDSTOP_HIT_TEST(A,C) \ - if (TEST(hit_state, A ##_MIN) || TEST(hit_state, A ##_MAX)) \ + if (TERN0(HAS_##A##_MIN, TEST(hit_state, A##_MIN)) || TERN0(HAS_##A##_MAX, TEST(hit_state, A##_MAX))) \ _ENDSTOP_HIT_ECHO(A,C) #define ENDSTOP_HIT_TEST_X() _ENDSTOP_HIT_TEST(X,'X') @@ -659,7 +658,7 @@ void Endstops::update() { * still exist. The only way to reduce them further is to increase the number of samples. * To reduce the chance to 1% (1/128th) requires 7 samples (adding 7ms of delay). */ - static esbits_t old_live_state; + static endstop_mask_t old_live_state; if (old_live_state != live_state) { endstop_poll_count = ENDSTOP_NOISE_THRESHOLD; old_live_state = live_state; diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index 13e814aa1f93..7d18aaf850f2 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -28,50 +28,75 @@ #include "../inc/MarlinConfig.h" #include +#define __ES_ITEM(N) N, +#define _ES_ITEM(K,N) TERN_(K,DEFER4(__ES_ITEM)(N)) + enum EndstopEnum : char { - X_MIN, Y_MIN, Z_MIN, Z_MIN_PROBE, - X_MAX, Y_MAX, Z_MAX, - X2_MIN, X2_MAX, - Y2_MIN, Y2_MAX, - Z2_MIN, Z2_MAX, - Z3_MIN, Z3_MAX, - Z4_MIN, Z4_MAX + _ES_ITEM(HAS_X_MIN, X_MIN) + _ES_ITEM(HAS_X_MAX, X_MAX) + _ES_ITEM(HAS_Y_MIN, Y_MIN) + _ES_ITEM(HAS_Y_MAX, Y_MAX) + _ES_ITEM(HAS_Z_MIN, Z_MIN) + _ES_ITEM(HAS_Z_MAX, Z_MAX) + #if ENABLED(X_DUAL_ENDSTOPS) + _ES_ITEM(HAS_X_MIN, X2_MIN) + _ES_ITEM(HAS_X_MAX, X2_MAX) + #endif + #if ENABLED(Y_DUAL_ENDSTOPS) + _ES_ITEM(HAS_Y_MIN, Y2_MIN) + _ES_ITEM(HAS_Y_MAX, Y2_MAX) + #endif + #if ENABLED(Z_MULTI_ENDSTOPS) + _ES_ITEM(HAS_Z_MIN, Z2_MIN) + _ES_ITEM(HAS_Z_MAX, Z2_MAX) + #if NUM_Z_STEPPER_DRIVERS >= 3 + _ES_ITEM(HAS_Z_MIN, Z3_MIN) + _ES_ITEM(HAS_Z_MAX, Z3_MAX) + #endif + #if NUM_Z_STEPPER_DRIVERS >= 4 + _ES_ITEM(HAS_Z_MIN, Z4_MIN) + _ES_ITEM(HAS_Z_MAX, Z4_MAX) + #endif + #endif + _ES_ITEM(HAS_Z_MIN_PROBE_PIN, Z_MIN_PROBE) + NUM_ENDSTOP_STATES }; #define X_ENDSTOP (x_home_dir(active_extruder) < 0 ? X_MIN : X_MAX) #define Y_ENDSTOP (Y_HOME_DIR < 0 ? Y_MIN : Y_MAX) #define Z_ENDSTOP (Z_HOME_DIR < 0 ? TERN(HOMING_Z_WITH_PROBE, Z_MIN, Z_MIN_PROBE) : Z_MAX) +#undef __ES_ITEM +#undef _ES_ITEM + class Endstops { public: - #if HAS_EXTRA_ENDSTOPS - typedef uint16_t esbits_t; - #if ENABLED(X_DUAL_ENDSTOPS) - static float x2_endstop_adj; - #endif - #if ENABLED(Y_DUAL_ENDSTOPS) - static float y2_endstop_adj; - #endif - #if ENABLED(Z_MULTI_ENDSTOPS) - static float z2_endstop_adj; - #endif - #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 - static float z3_endstop_adj; - #endif - #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 - static float z4_endstop_adj; - #endif - #else - typedef uint8_t esbits_t; + + typedef IF<(NUM_ENDSTOP_STATES > 8), uint16_t, uint8_t>::type endstop_mask_t; + + #if ENABLED(X_DUAL_ENDSTOPS) + static float x2_endstop_adj; + #endif + #if ENABLED(Y_DUAL_ENDSTOPS) + static float y2_endstop_adj; + #endif + #if ENABLED(Z_MULTI_ENDSTOPS) + static float z2_endstop_adj; + #endif + #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 + static float z3_endstop_adj; + #endif + #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 + static float z4_endstop_adj; #endif private: static bool enabled, enabled_globally; - static esbits_t live_state; - static volatile uint8_t hit_state; // Use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT index + static endstop_mask_t live_state; + static volatile endstop_mask_t hit_state; // Use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT index #if ENDSTOP_NOISE_THRESHOLD - static esbits_t validated_live_state; + static endstop_mask_t validated_live_state; static uint8_t endstop_poll_count; // Countdown from threshold for polling #endif @@ -107,12 +132,12 @@ class Endstops { /** * Get Endstop hit state. */ - FORCE_INLINE static uint8_t trigger_state() { return hit_state; } + FORCE_INLINE static endstop_mask_t trigger_state() { return hit_state; } /** * Get current endstops state */ - FORCE_INLINE static esbits_t state() { + FORCE_INLINE static endstop_mask_t state() { return #if ENDSTOP_NOISE_THRESHOLD validated_live_state diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index ff2be0c3565d..e8f578ae91f5 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -260,12 +260,12 @@ xyze_int8_t Stepper::count_direction{0}; #define DUAL_ENDSTOP_APPLY_STEP(A,V) \ if (separate_multi_axis) { \ if (A##_HOME_DIR < 0) { \ - if (!(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \ - if (!(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \ + if (TERN0(HAS_##A##_MIN, !(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor)) A##_STEP_WRITE(V); \ + if (TERN0(HAS_##A##2_MIN, !(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor)) A##2_STEP_WRITE(V); \ } \ else { \ - if (!(TEST(endstops.state(), A##_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \ - if (!(TEST(endstops.state(), A##2_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \ + if (TERN0(HAS_##A##_MAX, !(TEST(endstops.state(), A##_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##_motor)) A##_STEP_WRITE(V); \ + if (TERN0(HAS_##A##2_MAX, !(TEST(endstops.state(), A##2_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##2_motor)) A##2_STEP_WRITE(V); \ } \ } \ else { \ From 458677c63a3f9ae32c988e2ab10d8f3a0935bf50 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 18 May 2021 22:56:05 -0500 Subject: [PATCH 15/61] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20axis=20ho?= =?UTF-8?q?ming/trusted=20state=20bits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/motion.cpp | 20 +++++++++++--------- Marlin/src/module/motion.h | 21 +++++++++++---------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 427aea80b15e..52d9dec9044e 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1181,18 +1181,20 @@ void prepare_line_to_destination() { #if HAS_ENDSTOPS - uint8_t axis_homed, axis_trusted; // = 0 - - uint8_t axes_should_home(uint8_t axis_bits/*=0x07*/) { - #define SHOULD_HOME(A) TERN(HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(A) - // Clear test bits that are trusted - if (TEST(axis_bits, X_AXIS) && SHOULD_HOME(X_AXIS)) CBI(axis_bits, X_AXIS); - if (TEST(axis_bits, Y_AXIS) && SHOULD_HOME(Y_AXIS)) CBI(axis_bits, Y_AXIS); - if (TEST(axis_bits, Z_AXIS) && SHOULD_HOME(Z_AXIS)) CBI(axis_bits, Z_AXIS); + linear_axis_bits_t axis_homed, axis_trusted; // = 0 + + linear_axis_bits_t axes_should_home(linear_axis_bits_t axis_bits/*=linear_bits*/) { + auto set_should = [](linear_axis_bits_t &b, AxisEnum a) { + if (TEST(b, a) && TERN(HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(a)) + CBI(b, a); + }; + set_should(axis_bits, X_AXIS); // Clear test bits that are trusted + set_should(axis_bits, Y_AXIS); + set_should(axis_bits, Z_AXIS); return axis_bits; } - bool homing_needed_error(uint8_t axis_bits/*=0x07*/) { + bool homing_needed_error(linear_axis_bits_t axis_bits/*=linear_bits*/) { if ((axis_bits = axes_should_home(axis_bits))) { PGM_P home_first = GET_TEXT(MSG_HOME_FIRST); char msg[strlen_P(home_first)+1]; diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index e01978c8526e..15713e6d4dd9 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -326,7 +326,8 @@ void do_z_clearance(const_float_t zclear, const bool lower_allowed=false); /** * Homing and Trusted Axes */ -constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS); +typedef IF<(LINEAR_AXES>8), uint16_t, uint8_t>::type linear_axis_bits_t; +constexpr linear_axis_bits_t linear_bits = _BV(LINEAR_AXES) - 1; void set_axis_is_at_home(const AxisEnum axis); @@ -340,23 +341,23 @@ void set_axis_is_at_home(const AxisEnum axis); * Flags that the position is trusted in each linear axis. Set when homed. * Cleared whenever a stepper powers off, potentially losing its position. */ - extern uint8_t axis_homed, axis_trusted; + extern linear_axis_bits_t axis_homed, axis_trusted; void homeaxis(const AxisEnum axis); void set_axis_never_homed(const AxisEnum axis); - uint8_t axes_should_home(uint8_t axis_bits=0x07); - bool homing_needed_error(uint8_t axis_bits=0x07); + linear_axis_bits_t axes_should_home(linear_axis_bits_t axis_bits=linear_bits); + bool homing_needed_error(linear_axis_bits_t axis_bits=linear_bits); FORCE_INLINE void set_axis_unhomed(const AxisEnum axis) { CBI(axis_homed, axis); } FORCE_INLINE void set_axis_untrusted(const AxisEnum axis) { CBI(axis_trusted, axis); } FORCE_INLINE void set_all_unhomed() { axis_homed = axis_trusted = 0; } FORCE_INLINE void set_axis_homed(const AxisEnum axis) { SBI(axis_homed, axis); } FORCE_INLINE void set_axis_trusted(const AxisEnum axis) { SBI(axis_trusted, axis); } - FORCE_INLINE void set_all_homed() { axis_homed = axis_trusted = xyz_bits; } + FORCE_INLINE void set_all_homed() { axis_homed = axis_trusted = linear_bits; } #else - constexpr uint8_t axis_homed = xyz_bits, axis_trusted = xyz_bits; // Zero-endstop machines are always homed and trusted + constexpr linear_axis_bits_t axis_homed = linear_bits, axis_trusted = linear_bits; // Zero-endstop machines are always homed and trusted FORCE_INLINE void homeaxis(const AxisEnum axis) {} FORCE_INLINE void set_axis_never_homed(const AxisEnum) {} - FORCE_INLINE uint8_t axes_should_home(uint8_t=0x07) { return false; } - FORCE_INLINE bool homing_needed_error(uint8_t=0x07) { return false; } + FORCE_INLINE linear_axis_bits_t axes_should_home(linear_axis_bits_t=linear_bits) { return false; } + FORCE_INLINE bool homing_needed_error(linear_axis_bits_t=linear_bits) { return false; } FORCE_INLINE void set_axis_unhomed(const AxisEnum axis) {} FORCE_INLINE void set_axis_untrusted(const AxisEnum axis) {} FORCE_INLINE void set_all_unhomed() {} @@ -369,9 +370,9 @@ FORCE_INLINE bool axis_was_homed(const AxisEnum axis) { return TEST(axis_h FORCE_INLINE bool axis_is_trusted(const AxisEnum axis) { return TEST(axis_trusted, axis); } FORCE_INLINE bool axis_should_home(const AxisEnum axis) { return (axes_should_home() & _BV(axis)) != 0; } FORCE_INLINE bool no_axes_homed() { return !axis_homed; } -FORCE_INLINE bool all_axes_homed() { return xyz_bits == (axis_homed & xyz_bits); } +FORCE_INLINE bool all_axes_homed() { return linear_bits == (axis_homed & linear_bits); } FORCE_INLINE bool homing_needed() { return !all_axes_homed(); } -FORCE_INLINE bool all_axes_trusted() { return xyz_bits == (axis_trusted & xyz_bits); } +FORCE_INLINE bool all_axes_trusted() { return linear_bits == (axis_trusted & linear_bits); } #if ENABLED(NO_MOTION_BEFORE_HOMING) #define MOTION_CONDITIONS (IsRunning() && !homing_needed_error()) From 0dae140080c611089f8cb7e937c9f48516eb944d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 18 May 2021 23:30:49 -0500 Subject: [PATCH 16/61] =?UTF-8?q?=F0=9F=90=9B=20Fix=20DELTA=20with=20SENSO?= =?UTF-8?q?RLESS=5FPROBING?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_LCD.h | 2 +- Marlin/src/module/probe.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index ccfe30947c80..de97712a085d 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -818,7 +818,7 @@ #if DISABLED(NOZZLE_AS_PROBE) #define HAS_PROBE_XY_OFFSET 1 #endif - #if DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #if DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && !BOTH(DELTA, SENSORLESS_PROBING) #define HAS_CUSTOM_PROBE_PIN 1 #endif #if Z_HOME_DIR < 0 && (!HAS_CUSTOM_PROBE_PIN || ENABLED(USE_PROBE_FOR_Z_HOMING)) diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index be991c1d5261..655b8cc2495e 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -507,7 +507,7 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { // Check to see if the probe was triggered const bool probe_triggered = #if BOTH(DELTA, SENSORLESS_PROBING) - endstops.trigger_state() & (_BV(X_MIN) | _BV(Y_MIN) | _BV(Z_MIN)) + endstops.trigger_state() & (_BV(X_MAX) | _BV(Y_MAX) | _BV(Z_MAX)) #else TEST(endstops.trigger_state(), TERN(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, Z_MIN, Z_MIN_PROBE)) #endif From 49771c4a9ed2afa1e572f82a24b5edb3de120f78 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 19 May 2021 00:21:34 -0500 Subject: [PATCH 17/61] =?UTF-8?q?=F0=9F=8E=A8=20Flags=20for=20homing=20dir?= =?UTF-8?q?ections?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/LPC1768/inc/SanityCheck.h | 2 +- Marlin/src/feature/powerloss.cpp | 2 +- Marlin/src/gcode/calibrate/G28.cpp | 2 +- Marlin/src/inc/Conditionals_LCD.h | 21 ++++++++- Marlin/src/inc/Conditionals_adv.h | 6 +++ Marlin/src/inc/Conditionals_post.h | 16 +++---- Marlin/src/inc/SanityCheck.h | 46 +++++++++---------- .../screens/move_axis_screen.cpp | 2 +- Marlin/src/lcd/marlinui.cpp | 4 +- Marlin/src/module/endstops.cpp | 22 ++++----- Marlin/src/module/endstops.h | 6 +-- Marlin/src/module/motion.cpp | 10 ++-- Marlin/src/module/motion.h | 4 +- Marlin/src/module/scara.cpp | 6 +-- Marlin/src/module/stepper.cpp | 6 +-- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h | 6 +-- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 6 +-- Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h | 6 +-- Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h | 6 +-- Marlin/src/pins/pins_postprocess.h | 32 ++++++------- Marlin/src/pins/rambo/pins_EINSY_RETRO.h | 4 +- Marlin/src/pins/sam/pins_ARCHIM2.h | 4 +- Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h | 2 +- Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h | 6 +-- .../src/pins/stm32f4/pins_BTT_OCTOPUS_V1_0.h | 6 +-- .../pins/stm32f4/pins_BTT_SKR_PRO_common.h | 6 +-- .../pins/stm32f4/pins_BTT_SKR_V2_0_common.h | 6 +-- 27 files changed, 131 insertions(+), 114 deletions(-) diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index a6286ba6f404..46a876a836ca 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -144,7 +144,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #error "Serial port pins (2) conflict with Z4 pins!" #elif ANY_RX(2, X_DIR_PIN, Y_DIR_PIN) #error "Serial port pins (2) conflict with other pins!" - #elif Y_HOME_DIR < 0 && IS_TX2(Y_STOP_PIN) + #elif Y_HOME_TO_MIN && IS_TX2(Y_STOP_PIN) #error "Serial port pins (2) conflict with Y endstop pin!" #elif HAS_CUSTOM_PROBE_PIN && IS_TX2(Z_MIN_PROBE_PIN) #error "Serial port pins (2) conflict with probe pin!" diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index db78e7331bbb..a7474794de3b 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -375,7 +375,7 @@ void PrintJobRecovery::resume() { gcode.process_subcommands_now_P(PSTR("G92.9E0")); // Reset E to 0 - #if Z_HOME_DIR > 0 + #if Z_HOME_TO_MAX float z_now = z_raised; diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 23eafe4bb64e..aacfcfa42f5a 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -73,7 +73,7 @@ current_position.set(0.0, 0.0); sync_plan_position(); - const int x_axis_home_dir = x_home_dir(active_extruder); + const int x_axis_home_dir = TOOL_X_HOME_DIR(active_extruder); const float mlx = max_length(X_AXIS), mly = max_length(Y_AXIS), diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index de97712a085d..545ee403a182 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -814,6 +814,23 @@ #endif #endif // FILAMENT_RUNOUT_SENSOR +// Homing to Min or Max +#if X_HOME_DIR > 0 + #define X_HOME_TO_MAX 1 +#elif X_HOME_DIR < 0 + #define X_HOME_TO_MIN 1 +#endif +#if Y_HOME_DIR > 0 + #define Y_HOME_TO_MAX 1 +#elif Y_HOME_DIR < 0 + #define Y_HOME_TO_MIN 1 +#endif +#if Z_HOME_DIR > 0 + #define Z_HOME_TO_MAX 1 +#elif Z_HOME_DIR < 0 + #define Z_HOME_TO_MIN 1 +#endif + #if HAS_BED_PROBE #if DISABLED(NOZZLE_AS_PROBE) #define HAS_PROBE_XY_OFFSET 1 @@ -821,7 +838,7 @@ #if DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && !BOTH(DELTA, SENSORLESS_PROBING) #define HAS_CUSTOM_PROBE_PIN 1 #endif - #if Z_HOME_DIR < 0 && (!HAS_CUSTOM_PROBE_PIN || ENABLED(USE_PROBE_FOR_Z_HOMING)) + #if Z_HOME_TO_MIN && (!HAS_CUSTOM_PROBE_PIN || ENABLED(USE_PROBE_FOR_Z_HOMING)) #define HOMING_Z_WITH_PROBE 1 #endif #ifndef Z_PROBE_LOW_POINT @@ -843,7 +860,7 @@ #undef USE_PROBE_FOR_Z_HOMING #endif -#if Z_HOME_DIR > 0 +#if Z_HOME_TO_MAX #define HOME_Z_FIRST // If homing away from BED do Z first #endif diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 44ea34a490d2..95a7ada83f78 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -391,6 +391,12 @@ #define POLL_JOG #endif +#if X2_HOME_DIR > 0 + #define X2_HOME_TO_MAX 1 +#elif X2_HOME_DIR < 0 + #define X2_HOME_TO_MIN 1 +#endif + #ifndef HOMING_BUMP_MM #define HOMING_BUMP_MM { 0, 0, 0 } #endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 46c1e590205c..d86b02bdc233 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -155,7 +155,7 @@ #ifdef MANUAL_X_HOME_POS #define X_HOME_POS MANUAL_X_HOME_POS #else - #define X_END_POS (X_HOME_DIR < 0 ? X_MIN_POS : X_MAX_POS) + #define X_END_POS TERN(X_HOME_TO_MIN, X_MIN_POS, X_MAX_POS) #if ENABLED(BED_CENTER_AT_0_0) #define X_HOME_POS TERN(DELTA, 0, X_END_POS) #else @@ -166,7 +166,7 @@ #ifdef MANUAL_Y_HOME_POS #define Y_HOME_POS MANUAL_Y_HOME_POS #else - #define Y_END_POS (Y_HOME_DIR < 0 ? Y_MIN_POS : Y_MAX_POS) + #define Y_END_POS TERN(Y_HOME_TO_MIN, Y_MIN_POS, Y_MAX_POS) #if ENABLED(BED_CENTER_AT_0_0) #define Y_HOME_POS TERN(DELTA, 0, Y_END_POS) #else @@ -177,7 +177,7 @@ #ifdef MANUAL_Z_HOME_POS #define Z_HOME_POS MANUAL_Z_HOME_POS #else - #define Z_HOME_POS (Z_HOME_DIR < 0 ? Z_MIN_POS : Z_MAX_POS) + #define Z_HOME_POS TERN(Z_HOME_TO_MIN, Z_MIN_POS, Z_MAX_POS) #endif /** @@ -798,7 +798,7 @@ * X_DUAL_ENDSTOPS endstop reassignment */ #if ENABLED(X_DUAL_ENDSTOPS) - #if X_HOME_DIR > 0 + #if X_HOME_TO_MAX #ifndef X2_MAX_ENDSTOP_INVERTING #if X2_USE_ENDSTOP == _XMIN_ #define X2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING @@ -921,7 +921,7 @@ * Y_DUAL_ENDSTOPS endstop reassignment */ #if ENABLED(Y_DUAL_ENDSTOPS) - #if Y_HOME_DIR > 0 + #if Y_HOME_TO_MAX #ifndef Y2_MAX_ENDSTOP_INVERTING #if Y2_USE_ENDSTOP == _XMIN_ #define Y2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING @@ -1045,7 +1045,7 @@ */ #if ENABLED(Z_MULTI_ENDSTOPS) - #if Z_HOME_DIR > 0 + #if Z_HOME_TO_MAX #ifndef Z2_MAX_ENDSTOP_INVERTING #if Z2_USE_ENDSTOP == _XMIN_ #define Z2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING @@ -1164,7 +1164,7 @@ #endif #if NUM_Z_STEPPER_DRIVERS >= 3 - #if Z_HOME_DIR > 0 + #if Z_HOME_TO_MAX #ifndef Z3_MAX_ENDSTOP_INVERTING #if Z3_USE_ENDSTOP == _XMIN_ #define Z3_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING @@ -1284,7 +1284,7 @@ #endif #if NUM_Z_STEPPER_DRIVERS >= 4 - #if Z_HOME_DIR > 0 + #if Z_HOME_TO_MAX #ifndef Z4_MAX_ENDSTOP_INVERTING #if Z4_USE_ENDSTOP == _XMIN_ #define Z4_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 04f8a45c3b86..b9eacd0a1a50 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1682,7 +1682,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal * Allen Key * Deploying the Allen Key probe uses big moves in z direction. Too dangerous for an unhomed z-axis. */ -#if BOTH(Z_PROBE_ALLEN_KEY, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && Z_HOME_DIR < 0 +#if ALL(Z_HOME_TO_MIN, Z_PROBE_ALLEN_KEY, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) #error "You can't home to a Z min endstop with a Z_PROBE_ALLEN_KEY." #endif @@ -1700,7 +1700,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "DUAL_X_CARRIAGE requires USE_XMAX_PLUG and an X Max Endstop." #elif !defined(X2_HOME_POS) || !defined(X2_MIN_POS) || !defined(X2_MAX_POS) #error "DUAL_X_CARRIAGE requires X2_HOME_POS, X2_MIN_POS, and X2_MAX_POS." - #elif X_HOME_DIR != -1 || X2_HOME_DIR != 1 + #elif X_HOME_TO_MAX || X2_HOME_TO_MIN #error "DUAL_X_CARRIAGE requires X_HOME_DIR -1 and X2_HOME_DIR 1." #endif #endif @@ -2089,25 +2089,25 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal // Delta and Cartesian use 3 homing endstops #if NONE(IS_SCARA, SPI_ENDSTOPS) - #if X_HOME_DIR < 0 && DISABLED(USE_XMIN_PLUG) + #if X_HOME_TO_MIN && DISABLED(USE_XMIN_PLUG) #error "Enable USE_XMIN_PLUG when homing X to MIN." - #elif X_HOME_DIR > 0 && DISABLED(USE_XMAX_PLUG) + #elif X_HOME_TO_MAX && DISABLED(USE_XMAX_PLUG) #error "Enable USE_XMAX_PLUG when homing X to MAX." - #elif Y_HOME_DIR < 0 && DISABLED(USE_YMIN_PLUG) + #elif Y_HOME_TO_MIN && DISABLED(USE_YMIN_PLUG) #error "Enable USE_YMIN_PLUG when homing Y to MIN." - #elif Y_HOME_DIR > 0 && DISABLED(USE_YMAX_PLUG) + #elif Y_HOME_TO_MAX && DISABLED(USE_YMAX_PLUG) #error "Enable USE_YMAX_PLUG when homing Y to MAX." #endif #endif // Z homing direction and plug usage flags - #if Z_HOME_DIR < 0 && NONE(USE_ZMIN_PLUG, HOMING_Z_WITH_PROBE) + #if Z_HOME_TO_MIN && NONE(USE_ZMIN_PLUG, HOMING_Z_WITH_PROBE) #error "Enable USE_ZMIN_PLUG when homing Z to MIN." - #elif Z_HOME_DIR > 0 && ENABLED(USE_PROBE_FOR_Z_HOMING) + #elif Z_HOME_TO_MAX && ENABLED(USE_PROBE_FOR_Z_HOMING) #error "Z_HOME_DIR must be -1 when homing Z with the probe." #elif BOTH(HOMING_Z_WITH_PROBE, Z_MULTI_ENDSTOPS) #error "Z_MULTI_ENDSTOPS is incompatible with USE_PROBE_FOR_Z_HOMING." - #elif Z_HOME_DIR > 0 && DISABLED(USE_ZMAX_PLUG) + #elif Z_HOME_TO_MAX && DISABLED(USE_ZMAX_PLUG) #error "Enable USE_ZMAX_PLUG when homing Z to MAX." #endif #endif @@ -2630,17 +2630,17 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #define Z_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(Z,TMC2209) #if NONE(SPI_ENDSTOPS, ONBOARD_ENDSTOPPULLUPS, ENDSTOPPULLUPS) - #if X_SENSORLESS && X_HOME_DIR < 0 && DISABLED(ENDSTOPPULLUP_XMIN) + #if X_SENSORLESS && X_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_XMIN) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_XMIN (or ENDSTOPPULLUPS) when homing to X_MIN." - #elif X_SENSORLESS && X_HOME_DIR > 0 && DISABLED(ENDSTOPPULLUP_XMAX) + #elif X_SENSORLESS && X_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_XMAX) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_XMAX (or ENDSTOPPULLUPS) when homing to X_MAX." - #elif Y_SENSORLESS && Y_HOME_DIR < 0 && DISABLED(ENDSTOPPULLUP_YMIN) + #elif Y_SENSORLESS && Y_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_YMIN) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_YMIN (or ENDSTOPPULLUPS) when homing to Y_MIN." - #elif Y_SENSORLESS && Y_HOME_DIR > 0 && DISABLED(ENDSTOPPULLUP_YMAX) + #elif Y_SENSORLESS && Y_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_YMAX) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_YMAX (or ENDSTOPPULLUPS) when homing to Y_MAX." - #elif Z_SENSORLESS && Z_HOME_DIR < 0 && DISABLED(ENDSTOPPULLUP_ZMIN) + #elif Z_SENSORLESS && Z_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_ZMIN) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_ZMIN (or ENDSTOPPULLUPS) when homing to Z_MIN." - #elif Z_SENSORLESS && Z_HOME_DIR > 0 && DISABLED(ENDSTOPPULLUP_ZMAX) + #elif Z_SENSORLESS && Z_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_ZMAX) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_ZMAX (or ENDSTOPPULLUPS) when homing to Z_MAX." #endif #endif @@ -2650,37 +2650,37 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #warning "SPI_ENDSTOPS may be unreliable with QUICK_HOME. Adjust back-offs for better results." #endif #else - #if X_SENSORLESS && X_HOME_DIR < 0 && X_MIN_ENDSTOP_INVERTING != X_ENDSTOP_INVERTING + #if X_SENSORLESS && X_HOME_TO_MIN && X_MIN_ENDSTOP_INVERTING != X_ENDSTOP_INVERTING #if X_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires X_MIN_ENDSTOP_INVERTING = true when homing to X_MIN." #else #error "SENSORLESS_HOMING requires X_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to X_MIN." #endif - #elif X_SENSORLESS && X_HOME_DIR > 0 && X_MAX_ENDSTOP_INVERTING != X_ENDSTOP_INVERTING + #elif X_SENSORLESS && X_HOME_TO_MAX && X_MAX_ENDSTOP_INVERTING != X_ENDSTOP_INVERTING #if X_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires X_MAX_ENDSTOP_INVERTING = true when homing to X_MAX." #else #error "SENSORLESS_HOMING requires X_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to X_MAX." #endif - #elif Y_SENSORLESS && Y_HOME_DIR < 0 && Y_MIN_ENDSTOP_INVERTING != Y_ENDSTOP_INVERTING + #elif Y_SENSORLESS && Y_HOME_TO_MIN && Y_MIN_ENDSTOP_INVERTING != Y_ENDSTOP_INVERTING #if Y_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires Y_MIN_ENDSTOP_INVERTING = true when homing to Y_MIN." #else #error "SENSORLESS_HOMING requires Y_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to Y_MIN." #endif - #elif Y_SENSORLESS && Y_HOME_DIR > 0 && Y_MAX_ENDSTOP_INVERTING != Y_ENDSTOP_INVERTING + #elif Y_SENSORLESS && Y_HOME_TO_MAX && Y_MAX_ENDSTOP_INVERTING != Y_ENDSTOP_INVERTING #if Y_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires Y_MAX_ENDSTOP_INVERTING = true when homing to Y_MAX." #else #error "SENSORLESS_HOMING requires Y_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to Y_MAX." #endif - #elif Z_SENSORLESS && Z_HOME_DIR < 0 && Z_MIN_ENDSTOP_INVERTING != Z_ENDSTOP_INVERTING + #elif Z_SENSORLESS && Z_HOME_TO_MIN && Z_MIN_ENDSTOP_INVERTING != Z_ENDSTOP_INVERTING #if Z_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires Z_MIN_ENDSTOP_INVERTING = true when homing to Z_MIN." #else #error "SENSORLESS_HOMING requires Z_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to Z_MIN." #endif - #elif Z_SENSORLESS && Z_HOME_DIR > 0 && Z_MAX_ENDSTOP_INVERTING != Z_ENDSTOP_INVERTING + #elif Z_SENSORLESS && Z_HOME_TO_MAX && Z_MAX_ENDSTOP_INVERTING != Z_ENDSTOP_INVERTING #if Z_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires Z_MAX_ENDSTOP_INVERTING = true when homing to Z_MAX." #else @@ -2918,9 +2918,9 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #error "POWER_LOSS_RECOVER_ZHOME cannot be used with Z_SAFE_HOMING." #elif BOTH(POWER_LOSS_PULLUP, POWER_LOSS_PULLDOWN) #error "You can't enable POWER_LOSS_PULLUP and POWER_LOSS_PULLDOWN at the same time." - #elif ENABLED(POWER_LOSS_RECOVER_ZHOME) && Z_HOME_DIR > 0 + #elif ENABLED(POWER_LOSS_RECOVER_ZHOME) && Z_HOME_TO_MAX #error "POWER_LOSS_RECOVER_ZHOME is not needed on a machine that homes to ZMAX." - #elif BOTH(IS_CARTESIAN, POWER_LOSS_RECOVER_ZHOME) && Z_HOME_DIR < 0 && !defined(POWER_LOSS_ZHOME_POS) + #elif BOTH(IS_CARTESIAN, POWER_LOSS_RECOVER_ZHOME) && Z_HOME_TO_MIN && !defined(POWER_LOSS_ZHOME_POS) #error "POWER_LOSS_RECOVER_ZHOME requires POWER_LOSS_ZHOME_POS for a Cartesian that homes to ZMIN." #endif #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/move_axis_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/move_axis_screen.cpp index 67ea002d348d..9406572c3330 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/move_axis_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens/move_axis_screen.cpp @@ -66,7 +66,7 @@ void MoveAxisScreen::onRedraw(draw_mode_t what) { w.adjuster( 14, GET_TEXT_F(MSG_AXIS_E4), mydata.e_rel[3], canMove(E3)); #endif #endif - #if Z_HOME_DIR < 0 + #if Z_HOME_TO_MIN w.button(24, GET_TEXT_F(MSG_MOVE_Z_TO_TOP), !axis_should_home(Z_AXIS)); #endif w.increments(); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index acc3b63ac053..1d312535c940 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -488,12 +488,12 @@ bool MarlinUI::get_blink() { if (RRK(EN_KEYPAD_MIDDLE)) goto_screen(menu_move); - #if DISABLED(DELTA) && Z_HOME_DIR < 0 + #if NONE(DELTA, Z_HOME_TO_MAX) if (RRK(EN_KEYPAD_F2)) _reprapworld_keypad_move(Z_AXIS, 1); #endif if (homed) { - #if ENABLED(DELTA) || Z_HOME_DIR != -1 + #if EITHER(DELTA, Z_HOME_TO_MAX) if (RRK(EN_KEYPAD_F2)) _reprapworld_keypad_move(Z_AXIS, 1); #endif if (RRK(EN_KEYPAD_F3)) _reprapworld_keypad_move(Z_AXIS, -1); diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index d0befe71fb58..7a452f1fdddd 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -513,14 +513,8 @@ void Endstops::update() { #endif // With Dual X, endstops are only checked in the homing direction for the active extruder - #if ENABLED(DUAL_X_CARRIAGE) - #define E0_ACTIVE stepper.last_moved_extruder == 0 - #define X_MIN_TEST() ((X_HOME_DIR < 0 && E0_ACTIVE) || (X2_HOME_DIR < 0 && !E0_ACTIVE)) - #define X_MAX_TEST() ((X_HOME_DIR > 0 && E0_ACTIVE) || (X2_HOME_DIR > 0 && !E0_ACTIVE)) - #else - #define X_MIN_TEST() true - #define X_MAX_TEST() true - #endif + #define X_MIN_TEST() TERN1(DUAL_X_CARRIAGE, TERN0(X_HOME_TO_MIN, stepper.last_moved_extruder == 0) || TERN0(X2_HOME_TO_MIN, stepper.last_moved_extruder != 0)) + #define X_MAX_TEST() TERN1(DUAL_X_CARRIAGE, TERN0(X_HOME_TO_MAX, stepper.last_moved_extruder == 0) || TERN0(X2_HOME_TO_MAX, stepper.last_moved_extruder != 0)) // Use HEAD for core axes, AXIS for others #if ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY) @@ -765,7 +759,7 @@ void Endstops::update() { if (stepper.axis_is_moving(X_AXIS)) { if (stepper.motor_direction(X_AXIS_HEAD)) { // -direction - #if HAS_X_MIN || (X_SPI_SENSORLESS && X_HOME_DIR < 0) + #if HAS_X_MIN || (X_SPI_SENSORLESS && X_HOME_TO_MIN) PROCESS_ENDSTOP_X(MIN); #if CORE_DIAG(XY, Y, MIN) PROCESS_CORE_ENDSTOP(Y,MIN,X,MIN); @@ -779,7 +773,7 @@ void Endstops::update() { #endif } else { // +direction - #if HAS_X_MAX || (X_SPI_SENSORLESS && X_HOME_DIR > 0) + #if HAS_X_MAX || (X_SPI_SENSORLESS && X_HOME_TO_MAX) PROCESS_ENDSTOP_X(MAX); #if CORE_DIAG(XY, Y, MIN) PROCESS_CORE_ENDSTOP(Y,MIN,X,MAX); @@ -796,7 +790,7 @@ void Endstops::update() { if (stepper.axis_is_moving(Y_AXIS)) { if (stepper.motor_direction(Y_AXIS_HEAD)) { // -direction - #if HAS_Y_MIN || (Y_SPI_SENSORLESS && Y_HOME_DIR < 0) + #if HAS_Y_MIN || (Y_SPI_SENSORLESS && Y_HOME_TO_MIN) PROCESS_ENDSTOP_Y(MIN); #if CORE_DIAG(XY, X, MIN) PROCESS_CORE_ENDSTOP(X,MIN,Y,MIN); @@ -810,7 +804,7 @@ void Endstops::update() { #endif } else { // +direction - #if HAS_Y_MAX || (Y_SPI_SENSORLESS && Y_HOME_DIR > 0) + #if HAS_Y_MAX || (Y_SPI_SENSORLESS && Y_HOME_TO_MAX) PROCESS_ENDSTOP_Y(MAX); #if CORE_DIAG(XY, X, MIN) PROCESS_CORE_ENDSTOP(X,MIN,Y,MAX); @@ -828,7 +822,7 @@ void Endstops::update() { if (stepper.axis_is_moving(Z_AXIS)) { if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up. - #if HAS_Z_MIN || (Z_SPI_SENSORLESS && Z_HOME_DIR < 0) + #if HAS_Z_MIN || (Z_SPI_SENSORLESS && Z_HOME_TO_MIN) if ( TERN1(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, z_probe_enabled) && TERN1(HAS_CUSTOM_PROBE_PIN, !z_probe_enabled) ) PROCESS_ENDSTOP_Z(MIN); @@ -849,7 +843,7 @@ void Endstops::update() { #endif } else { // Z +direction. Gantry up, bed down. - #if HAS_Z_MAX || (Z_SPI_SENSORLESS && Z_HOME_DIR > 0) + #if HAS_Z_MAX || (Z_SPI_SENSORLESS && Z_HOME_TO_MAX) #if ENABLED(Z_MULTI_ENDSTOPS) PROCESS_ENDSTOP_Z(MAX); #elif !HAS_CUSTOM_PROBE_PIN || Z_MAX_PIN != Z_MIN_PROBE_PIN // No probe or probe is Z_MIN || Probe is not Z_MAX diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index 7d18aaf850f2..acd241d43217 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -62,9 +62,9 @@ enum EndstopEnum : char { NUM_ENDSTOP_STATES }; -#define X_ENDSTOP (x_home_dir(active_extruder) < 0 ? X_MIN : X_MAX) -#define Y_ENDSTOP (Y_HOME_DIR < 0 ? Y_MIN : Y_MAX) -#define Z_ENDSTOP (Z_HOME_DIR < 0 ? TERN(HOMING_Z_WITH_PROBE, Z_MIN, Z_MIN_PROBE) : Z_MAX) +#define X_ENDSTOP TERN(X_HOME_TO_MAX, X_MAX, X_MIN) +#define Y_ENDSTOP TERN(Y_HOME_TO_MAX, Y_MAX, Y_MIN) +#define Z_ENDSTOP TERN(Z_HOME_TO_MAX, Z_MAX, TERN(HOMING_Z_WITH_PROBE, Z_MIN, Z_MIN_PROBE)) #undef __ES_ITEM #undef _ES_ITEM diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 52d9dec9044e..69aed1e1926f 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1378,7 +1378,7 @@ void prepare_line_to_destination() { // Only do some things when moving towards an endstop const int8_t axis_home_dir = TERN0(DUAL_X_CARRIAGE, axis == X_AXIS) - ? x_home_dir(active_extruder) : home_dir(axis); + ? TOOL_X_HOME_DIR(active_extruder) : home_dir(axis); const bool is_home_dir = (axis_home_dir > 0) == (distance > 0); #if ENABLED(SENSORLESS_HOMING) @@ -1562,8 +1562,8 @@ void prepare_line_to_destination() { #define _CAN_HOME(A) (axis == _AXIS(A) && ( \ ENABLED(A##_SPI_SENSORLESS) \ || (_AXIS(A) == Z_AXIS && ENABLED(HOMING_Z_WITH_PROBE)) \ - || (A##_MIN_PIN > -1 && A##_HOME_DIR < 0) \ - || (A##_MAX_PIN > -1 && A##_HOME_DIR > 0) \ + || TERN0(A##_HOME_TO_MIN, A##_MIN_PIN > -1) \ + || TERN0(A##_HOME_TO_MAX, A##_MAX_PIN > -1) \ )) if (!_CAN_HOME(X) && !_CAN_HOME(Y) && !_CAN_HOME(Z)) return; #endif @@ -1571,7 +1571,7 @@ void prepare_line_to_destination() { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> homeaxis(", AS_CHAR(axis_codes[axis]), ")"); const int axis_home_dir = TERN0(DUAL_X_CARRIAGE, axis == X_AXIS) - ? x_home_dir(active_extruder) : home_dir(axis); + ? TOOL_X_HOME_DIR(active_extruder) : home_dir(axis); // // Homing Z with a probe? Raise Z (maybe) and deploy the Z probe. @@ -1916,7 +1916,7 @@ void set_axis_is_at_home(const AxisEnum axis) { /** * Z Probe Z Homing? Account for the probe's Z offset. */ - #if HAS_BED_PROBE && Z_HOME_DIR < 0 + #if HAS_BED_PROBE && Z_HOME_TO_MIN if (axis == Z_AXIS) { #if HOMING_Z_WITH_PROBE diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 15713e6d4dd9..3c6f044b2193 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -517,7 +517,7 @@ FORCE_INLINE bool all_axes_trusted() { return linear_bits float x_home_pos(const uint8_t extruder); - FORCE_INLINE int x_home_dir(const uint8_t extruder) { return extruder ? X2_HOME_DIR : X_HOME_DIR; } + #define TOOL_X_HOME_DIR(T) ((T) ? X2_HOME_DIR : X_HOME_DIR) void set_duplication_enabled(const bool dupe, const int8_t tool_index=-1); void idex_set_mirrored_mode(const bool mirr); @@ -531,7 +531,7 @@ FORCE_INLINE bool all_axes_trusted() { return linear_bits FORCE_INLINE void set_duplication_enabled(const bool dupe) { extruder_duplication_enabled = dupe; } #endif - FORCE_INLINE int x_home_dir(const uint8_t) { return X_HOME_DIR; } + #define TOOL_X_HOME_DIR(T) X_HOME_DIR #endif diff --git a/Marlin/src/module/scara.cpp b/Marlin/src/module/scara.cpp index b0544c7791ac..07f714a997b9 100644 --- a/Marlin/src/module/scara.cpp +++ b/Marlin/src/module/scara.cpp @@ -221,10 +221,10 @@ float segments_per_second = TERN(AXEL_TPARA, TPARA_SEGMENTS_PER_SECOND, SCARA_SE TERN_(Z_SENSORLESS, sensorless_t stealth_states_z = start_sensorless_homing_per_axis(Z_AXIS)); #endif - // const int x_axis_home_dir = x_home_dir(active_extruder); + //const int x_axis_home_dir = TOOL_X_HOME_DIR(active_extruder); - // const xy_pos_t pos { max_length(X_AXIS) , max_length(Y_AXIS) }; - // const float mlz = max_length(X_AXIS), + //const xy_pos_t pos { max_length(X_AXIS) , max_length(Y_AXIS) }; + //const float mlz = max_length(X_AXIS), // Move all carriages together linearly until an endstop is hit. //do_blocking_move_to_xy_z(pos, mlz, homing_feedrate(Z_AXIS)); diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index e8f578ae91f5..2e2afaeb90b6 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -259,7 +259,7 @@ xyze_int8_t Stepper::count_direction{0}; #define DUAL_ENDSTOP_APPLY_STEP(A,V) \ if (separate_multi_axis) { \ - if (A##_HOME_DIR < 0) { \ + if (A##_HOME_TO_MIN) { \ if (TERN0(HAS_##A##_MIN, !(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor)) A##_STEP_WRITE(V); \ if (TERN0(HAS_##A##2_MIN, !(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor)) A##2_STEP_WRITE(V); \ } \ @@ -285,7 +285,7 @@ xyze_int8_t Stepper::count_direction{0}; #define TRIPLE_ENDSTOP_APPLY_STEP(A,V) \ if (separate_multi_axis) { \ - if (A##_HOME_DIR < 0) { \ + if (A##_HOME_TO_MIN) { \ if (!(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \ if (!(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \ if (!(TEST(endstops.state(), A##3_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \ @@ -316,7 +316,7 @@ xyze_int8_t Stepper::count_direction{0}; #define QUAD_ENDSTOP_APPLY_STEP(A,V) \ if (separate_multi_axis) { \ - if (A##_HOME_DIR < 0) { \ + if (A##_HOME_TO_MIN) { \ if (!(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \ if (!(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \ if (!(TEST(endstops.state(), A##3_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \ diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h index 625de0599632..b262212b7ea5 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -38,7 +38,7 @@ // #ifdef X_STALL_SENSITIVITY #define X_STOP_PIN X_DIAG_PIN - #if X_HOME_DIR < 0 + #if X_HOME_TO_MIN #define X_MAX_PIN P1_28 // X+ #else #define X_MIN_PIN P1_28 // X+ @@ -50,7 +50,7 @@ #ifdef Y_STALL_SENSITIVITY #define Y_STOP_PIN Y_DIAG_PIN - #if Y_HOME_DIR < 0 + #if Y_HOME_TO_MIN #define Y_MAX_PIN P1_26 // Y+ #else #define Y_MIN_PIN P1_26 // Y+ @@ -62,7 +62,7 @@ #ifdef Z_STALL_SENSITIVITY #define Z_STOP_PIN Z_DIAG_PIN - #if Z_HOME_DIR < 0 + #if Z_HOME_TO_MIN #define Z_MAX_PIN P1_24 // Z+ #else #define Z_MIN_PIN P1_24 // Z+ diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h index ba60db472e48..0508c5b5a99e 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -50,7 +50,7 @@ // #ifdef X_STALL_SENSITIVITY #define X_STOP_PIN X_DIAG_PIN - #if X_HOME_DIR < 0 + #if X_HOME_TO_MIN #define X_MAX_PIN P1_26 // E0DET #else #define X_MIN_PIN P1_26 // E0DET @@ -68,7 +68,7 @@ #ifdef Y_STALL_SENSITIVITY #define Y_STOP_PIN Y_DIAG_PIN - #if Y_HOME_DIR < 0 + #if Y_HOME_TO_MIN #define Y_MAX_PIN P1_25 // E1DET #else #define Y_MIN_PIN P1_25 // E1DET @@ -86,7 +86,7 @@ #ifdef Z_STALL_SENSITIVITY #define Z_STOP_PIN Z_DIAG_PIN - #if Z_HOME_DIR < 0 + #if Z_HOME_TO_MIN #define Z_MAX_PIN P1_00 // PWRDET #else #define Z_MIN_PIN P1_00 // PWRDET diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h index 40fac4e7fa38..f998ecde4e3e 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h @@ -50,7 +50,7 @@ // #ifdef X_STALL_SENSITIVITY #define X_STOP_PIN X_DIAG_PIN - #if X_HOME_DIR < 0 + #if X_HOME_TO_MIN #define X_MAX_PIN P1_28 // X+ #else #define X_MIN_PIN P1_28 // X+ @@ -62,7 +62,7 @@ #ifdef Y_STALL_SENSITIVITY #define Y_STOP_PIN Y_DIAG_PIN - #if Y_HOME_DIR < 0 + #if Y_HOME_TO_MIN #define Y_MAX_PIN P1_26 // Y+ #else #define Y_MIN_PIN P1_26 // Y+ @@ -74,7 +74,7 @@ #ifdef Z_STALL_SENSITIVITY #define Z_STOP_PIN Z_DIAG_PIN - #if Z_HOME_DIR < 0 + #if Z_HOME_TO_MIN #define Z_MAX_PIN P1_24 // Z+ #else #define Z_MIN_PIN P1_24 // Z+ diff --git a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h index a6160794039b..10571474982d 100644 --- a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h @@ -60,7 +60,7 @@ // #if X_STALL_SENSITIVITY #define X_STOP_PIN X_DIAG_PIN - #if X_HOME_DIR < 0 + #if X_HOME_TO_MIN #define X_MAX_PIN P1_28 // X+ #else #define X_MIN_PIN P1_28 // X+ @@ -72,7 +72,7 @@ #if Y_STALL_SENSITIVITY #define Y_STOP_PIN Y_DIAG_PIN - #if Y_HOME_DIR < 0 + #if Y_HOME_TO_MIN #define Y_MAX_PIN P1_26 // Y+ #else #define Y_MIN_PIN P1_26 // Y+ @@ -84,7 +84,7 @@ #if Z_STALL_SENSITIVITY #define Z_STOP_PIN Z_DIAG_PIN - #if Z_HOME_DIR < 0 + #if Z_HOME_TO_MIN #define Z_MAX_PIN P1_24 // Z+ #else #define Z_MIN_PIN P1_24 // Z+ diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index d71b79ca9544..37ebbd47addb 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -385,7 +385,7 @@ // Assign endstop pins for boards with only 3 connectors // #ifdef X_STOP_PIN - #if X_HOME_DIR < 0 + #if X_HOME_TO_MIN #define X_MIN_PIN X_STOP_PIN #ifndef X_MAX_PIN #define X_MAX_PIN -1 @@ -396,14 +396,14 @@ #define X_MIN_PIN -1 #endif #endif -#elif X_HOME_DIR < 0 +#elif X_HOME_TO_MIN #define X_STOP_PIN X_MIN_PIN #else #define X_STOP_PIN X_MAX_PIN #endif #ifdef Y_STOP_PIN - #if Y_HOME_DIR < 0 + #if Y_HOME_TO_MIN #define Y_MIN_PIN Y_STOP_PIN #ifndef Y_MAX_PIN #define Y_MAX_PIN -1 @@ -414,14 +414,14 @@ #define Y_MIN_PIN -1 #endif #endif -#elif Y_HOME_DIR < 0 +#elif Y_HOME_TO_MIN #define Y_STOP_PIN Y_MIN_PIN #else #define Y_STOP_PIN Y_MAX_PIN #endif #ifdef Z_STOP_PIN - #if Z_HOME_DIR < 0 + #if Z_HOME_TO_MIN #define Z_MIN_PIN Z_STOP_PIN #ifndef Z_MAX_PIN #define Z_MAX_PIN -1 @@ -432,7 +432,7 @@ #define Z_MIN_PIN -1 #endif #endif -#elif Z_HOME_DIR < 0 +#elif Z_HOME_TO_MIN #define Z_STOP_PIN Z_MIN_PIN #else #define Z_STOP_PIN Z_MAX_PIN @@ -489,34 +489,34 @@ #undef Z_MIN_PIN #define Z_MIN_PIN -1 #endif -#if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_DIR > 0 +#if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_TO_MAX #undef X2_MIN_PIN #endif -#if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_DIR < 0 +#if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_TO_MIN #undef X2_MAX_PIN #endif -#if DISABLED(Y_DUAL_ENDSTOPS) || Y_HOME_DIR > 0 +#if DISABLED(Y_DUAL_ENDSTOPS) || Y_HOME_TO_MAX #undef Y2_MIN_PIN #endif -#if DISABLED(Y_DUAL_ENDSTOPS) || Y_HOME_DIR < 0 +#if DISABLED(Y_DUAL_ENDSTOPS) || Y_HOME_TO_MIN #undef Y2_MAX_PIN #endif -#if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_DIR > 0 +#if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_TO_MAX #undef Z2_MIN_PIN #endif -#if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_DIR < 0 +#if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_TO_MIN #undef Z2_MAX_PIN #endif -#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 3 || Z_HOME_DIR > 0 +#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 3 || Z_HOME_TO_MAX #undef Z3_MIN_PIN #endif -#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 3 || Z_HOME_DIR < 0 +#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 3 || Z_HOME_TO_MIN #undef Z3_MAX_PIN #endif -#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 4 || Z_HOME_DIR > 0 +#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 4 || Z_HOME_TO_MAX #undef Z4_MIN_PIN #endif -#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 4 || Z_HOME_DIR < 0 +#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 4 || Z_HOME_TO_MIN #undef Z4_MAX_PIN #endif diff --git a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h index ee537495ea23..0c072745d57b 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h @@ -61,7 +61,7 @@ #else - #if X_HOME_DIR < 0 + #if X_HOME_TO_MIN #define X_MIN_PIN X_DIAG_PIN #define X_MAX_PIN 81 // X+ #else @@ -69,7 +69,7 @@ #define X_MAX_PIN X_DIAG_PIN #endif - #if Y_HOME_DIR < 0 + #if Y_HOME_TO_MIN #define Y_MIN_PIN Y_DIAG_PIN #define Y_MAX_PIN 57 // Y+ #else diff --git a/Marlin/src/pins/sam/pins_ARCHIM2.h b/Marlin/src/pins/sam/pins_ARCHIM2.h index 3776cf8bb548..ecff888ff05e 100644 --- a/Marlin/src/pins/sam/pins_ARCHIM2.h +++ b/Marlin/src/pins/sam/pins_ARCHIM2.h @@ -71,7 +71,7 @@ #define E0_DIAG_PIN 78 // PB23 #define E1_DIAG_PIN 25 // PD0 - #if X_HOME_DIR < 0 + #if X_HOME_TO_MIN #define X_MIN_PIN X_DIAG_PIN #define X_MAX_PIN 32 #else @@ -79,7 +79,7 @@ #define X_MAX_PIN X_DIAG_PIN #endif - #if Y_HOME_DIR < 0 + #if Y_HOME_TO_MIN #define Y_MIN_PIN Y_DIAG_PIN #define Y_MAX_PIN 15 #else diff --git a/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h b/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h index f80827851082..621b136e1728 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h @@ -55,7 +55,7 @@ #define X2_DIR_PIN FPC10_PIN // X2DIR #define X2_SERIAL_TX_PIN FPC12_PIN // X2UART #define X2_SERIAL_RX_PIN FPC12_PIN // X2UART - #if X_HOME_DIR < 0 + #if X_HOME_TO_MIN #define X_MAX_PIN FPC2_PIN // X2-STOP #else #define X_MIN_PIN FPC2_PIN // X2-STOP diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index 70d502f68a90..70ac9a13c31d 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -69,7 +69,7 @@ // #ifdef X_STALL_SENSITIVITY #define X_STOP_PIN X_DIAG_PIN - #if X_HOME_DIR < 0 + #if X_HOME_TO_MIN #define X_MAX_PIN E0_DIAG_PIN // X+ #else #define X_MIN_PIN E0_DIAG_PIN // X+ @@ -81,7 +81,7 @@ #ifdef Y_STALL_SENSITIVITY #define Y_STOP_PIN Y_DIAG_PIN - #if Y_HOME_DIR < 0 + #if Y_HOME_TO_MIN #define Y_MAX_PIN E1_DIAG_PIN // Y+ #else #define Y_MIN_PIN E1_DIAG_PIN // Y+ @@ -93,7 +93,7 @@ #ifdef Z_STALL_SENSITIVITY #define Z_STOP_PIN Z_DIAG_PIN - #if Z_HOME_DIR < 0 + #if Z_HOME_TO_MIN #define Z_MAX_PIN E2_DIAG_PIN // Z+ #else #define Z_MIN_PIN E2_DIAG_PIN // Z+ diff --git a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_0.h index 6de3c544d323..34fe1a824b3a 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_0.h @@ -71,7 +71,7 @@ // #ifdef X_STALL_SENSITIVITY #define X_STOP_PIN X_DIAG_PIN - #if X_HOME_DIR < 0 + #if X_HOME_TO_MIN #define X_MAX_PIN E0_DIAG_PIN // E0DET #else #define X_MIN_PIN E0_DIAG_PIN // E0DET @@ -89,7 +89,7 @@ #ifdef Y_STALL_SENSITIVITY #define Y_STOP_PIN Y_DIAG_PIN - #if Y_HOME_DIR < 0 + #if Y_HOME_TO_MIN #define Y_MAX_PIN E1_DIAG_PIN // E1DET #else #define Y_MIN_PIN E1_DIAG_PIN // E1DET @@ -107,7 +107,7 @@ #ifdef Z_STALL_SENSITIVITY #define Z_STOP_PIN Z_DIAG_PIN - #if Z_HOME_DIR < 0 + #if Z_HOME_TO_MIN #define Z_MAX_PIN E2_DIAG_PIN // PWRDET #else #define Z_MIN_PIN E2_DIAG_PIN // PWRDET diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h index 67907affa7f1..fe6d8740bd93 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -71,7 +71,7 @@ // #ifdef X_STALL_SENSITIVITY #define X_STOP_PIN X_DIAG_PIN - #if X_HOME_DIR < 0 + #if X_HOME_TO_MIN #define X_MAX_PIN PE15 // E0 #else #define X_MIN_PIN PE15 // E0 @@ -83,7 +83,7 @@ #ifdef Y_STALL_SENSITIVITY #define Y_STOP_PIN Y_DIAG_PIN - #if Y_HOME_DIR < 0 + #if Y_HOME_TO_MIN #define Y_MAX_PIN PE10 // E1 #else #define Y_MIN_PIN PE10 // E1 @@ -95,7 +95,7 @@ #ifdef Z_STALL_SENSITIVITY #define Z_STOP_PIN Z_DIAG_PIN - #if Z_HOME_DIR < 0 + #if Z_HOME_TO_MIN #define Z_MAX_PIN PG5 // E2 #else #define Z_MIN_PIN PG5 // E2 diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h index a69041e2d4f6..5e2f88190d73 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h @@ -72,7 +72,7 @@ // #ifdef X_STALL_SENSITIVITY #define X_STOP_PIN X_DIAG_PIN - #if X_HOME_DIR < 0 + #if X_HOME_TO_MIN #define X_MAX_PIN PC2 // E0DET #else #define X_MIN_PIN PC2 // E0DET @@ -90,7 +90,7 @@ #ifdef Y_STALL_SENSITIVITY #define Y_STOP_PIN Y_DIAG_PIN - #if Y_HOME_DIR < 0 + #if Y_HOME_TO_MIN #define Y_MAX_PIN PA0 // E1DET #else #define Y_MIN_PIN PA0 // E1DET @@ -108,7 +108,7 @@ #ifdef Z_STALL_SENSITIVITY #define Z_STOP_PIN Z_DIAG_PIN - #if Z_HOME_DIR < 0 + #if Z_HOME_TO_MIN #define Z_MAX_PIN PC15 // PWRDET #else #define Z_MIN_PIN PC15 // PWRDET From e018f041bad46d6fb03a6c53f99fb7c7c494b721 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 19 May 2021 23:07:09 -0500 Subject: [PATCH 18/61] =?UTF-8?q?=F0=9F=8E=A8=20Move=20switch=20sensor=20s?= =?UTF-8?q?trings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/language.h | 44 ++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index cabdde983b51..df6821cb1caf 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -140,25 +140,7 @@ #define STR_RESEND "Resend: " #define STR_UNKNOWN_COMMAND "Unknown command: \"" #define STR_ACTIVE_EXTRUDER "Active Extruder: " -#define STR_X_MIN "x_min" -#define STR_X_MAX "x_max" -#define STR_X2_MIN "x2_min" -#define STR_X2_MAX "x2_max" -#define STR_Y_MIN "y_min" -#define STR_Y_MAX "y_max" -#define STR_Y2_MIN "y2_min" -#define STR_Y2_MAX "y2_max" -#define STR_Z_MIN "z_min" -#define STR_Z_MAX "z_max" -#define STR_Z2_MIN "z2_min" -#define STR_Z2_MAX "z2_max" -#define STR_Z3_MIN "z3_min" -#define STR_Z3_MAX "z3_max" -#define STR_Z4_MIN "z4_min" -#define STR_Z4_MAX "z4_max" -#define STR_Z_PROBE "z_probe" -#define STR_PROBE_EN "probe_en" -#define STR_FILAMENT_RUNOUT_SENSOR "filament" + #define STR_PROBE_OFFSET "Probe Offset" #define STR_SKEW_MIN "min_skew_factor: " #define STR_SKEW_MAX "max_skew_factor: " @@ -277,6 +259,30 @@ #define STR_REMINDER_SAVE_SETTINGS "Remember to save!" #define STR_PASSWORD_SET "Password is " +// +// Endstop Names used by Endstops::report_states +// +#define STR_X_MIN "x_min" +#define STR_X_MAX "x_max" +#define STR_X2_MIN "x2_min" +#define STR_X2_MAX "x2_max" +#define STR_Y_MIN "y_min" +#define STR_Y_MAX "y_max" +#define STR_Y2_MIN "y2_min" +#define STR_Y2_MAX "y2_max" +#define STR_Z_MIN "z_min" +#define STR_Z_MAX "z_max" +#define STR_Z2_MIN "z2_min" +#define STR_Z2_MAX "z2_max" +#define STR_Z3_MIN "z3_min" +#define STR_Z3_MAX "z3_max" +#define STR_Z4_MIN "z4_min" +#define STR_Z4_MAX "z4_max" +#define STR_Z_PROBE "z_probe" +#define STR_PROBE_EN "probe_en" +#define STR_FILAMENT_RUNOUT_SENSOR "filament" + +// General axis names #define STR_X "X" #define STR_Y "Y" #define STR_Z "Z" From 29ad42e54e88b2117581987aecc811177285eea2 Mon Sep 17 00:00:00 2001 From: charlespick Date: Thu, 20 May 2021 04:06:26 -0700 Subject: [PATCH 19/61] =?UTF-8?q?=E2=9C=A8=20Independent=20baud=20rates=20?= =?UTF-8?q?(#21949)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 27 ++++++++++++++++----------- Marlin/Configuration_adv.h | 3 --- Marlin/src/MarlinCore.cpp | 10 ++++++++-- buildroot/tests/STM32F103RC_btt_USB | 2 +- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 78c2dc916014..dd6abd562999 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -104,12 +104,27 @@ */ #define SERIAL_PORT 0 +/** + * Serial Port Baud Rate + * This is the default communication speed for all serial ports. + * Set the baud rate defaults for additional serial ports below. + * + * 250000 works in most cases, but you might try a lower speed if + * you commonly experience drop-outs during host printing. + * You may try up to 1000000 to speed up SD file transfer. + * + * :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] + */ +#define BAUDRATE 250000 +//#define BAUD_RATE_GCODE // Enable G-code M575 to set the baud rate + /** * Select a secondary serial port on the board to use for communication with the host. * Currently Ethernet (-2) is only supported on Teensy 4.1 boards. * :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7] */ //#define SERIAL_PORT_2 -1 +//#define BAUDRATE_2 250000 // Enable to override BAUDRATE /** * Select a third serial port on the board to use for communication with the host. @@ -117,17 +132,7 @@ * :[-1, 0, 1, 2, 3, 4, 5, 6, 7] */ //#define SERIAL_PORT_3 1 - -/** - * This setting determines the communication speed of the printer. - * - * 250000 works in most cases, but you might try a lower speed if - * you commonly experience drop-outs during host printing. - * You may try up to 1000000 to speed up SD file transfer. - * - * :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] - */ -#define BAUDRATE 250000 +//#define BAUDRATE_3 250000 // Enable to override BAUDRATE // Enable the Bluetooth serial interface on AT90USB devices //#define BLUETOOTH diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 5335fa012a15..5db36d9cbbe7 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2114,9 +2114,6 @@ //#define SERIAL_XON_XOFF #endif -// Add M575 G-code to change the baud rate -//#define BAUD_RATE_GCODE - #if ENABLED(SDSUPPORT) // Enable this option to collect and display the maximum // RX queue usage after transferring a file to SD. diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 5ef575a30f6a..4fca64ba6b79 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1073,11 +1073,17 @@ void setup() { while (!MYSERIAL1.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } #if HAS_MULTI_SERIAL && !HAS_ETHERNET - MYSERIAL2.begin(BAUDRATE); + #ifndef BAUDRATE_2 + #define BAUDRATE_2 BAUDRATE + #endif + MYSERIAL2.begin(BAUDRATE_2); serial_connect_timeout = millis() + 1000UL; while (!MYSERIAL2.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } #ifdef SERIAL_PORT_3 - MYSERIAL3.begin(BAUDRATE); + #ifndef BAUDRATE_3 + #define BAUDRATE_3 BAUDRATE + #endif + MYSERIAL3.begin(BAUDRATE_3); serial_connect_timeout = millis() + 1000UL; while (!MYSERIAL3.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } #endif diff --git a/buildroot/tests/STM32F103RC_btt_USB b/buildroot/tests/STM32F103RC_btt_USB index 8381de0ea6e4..fb0f2f5bd2d9 100755 --- a/buildroot/tests/STM32F103RC_btt_USB +++ b/buildroot/tests/STM32F103RC_btt_USB @@ -10,7 +10,7 @@ set -e # Build with the default configurations # restore_configs -opt_set MOTHERBOARD BOARD_BTT_SKR_MINI_V1_1 SERIAL_PORT 1 SERIAL_PORT_2 -1 +opt_set MOTHERBOARD BOARD_BTT_SKR_MINI_V1_1 SERIAL_PORT 1 SERIAL_PORT_2 -1 BAUDRATE_2 115200 exec_test $1 $2 "BigTreeTech SKR Mini v1.1 - Basic Configuration" "$3" # clean up From 7da4ed7340044a2457846af9a1709232f7eb0037 Mon Sep 17 00:00:00 2001 From: Moonglow Date: Thu, 20 May 2021 14:09:10 +0300 Subject: [PATCH 20/61] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Toshiba=20FlashAir?= =?UTF-8?q?=20(SDCARD=5FCOMMANDS=5FSPLIT)=20(#21944)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/sd/Sd2Card.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Marlin/src/sd/Sd2Card.cpp b/Marlin/src/sd/Sd2Card.cpp index 3e714fe9fefe..a81932d49485 100644 --- a/Marlin/src/sd/Sd2Card.cpp +++ b/Marlin/src/sd/Sd2Card.cpp @@ -89,6 +89,11 @@ // Send command and return error code. Return zero for OK uint8_t DiskIODriver_SPI_SD::cardCommand(const uint8_t cmd, const uint32_t arg) { + + #if ENABLED(SDCARD_COMMANDS_SPLIT) + if (cmd != CMD12) chipDeselect(); + #endif + // Select card chipSelect(); From 781b34709bae404368b095ccc33d7ceeffc30adb Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn Date: Thu, 20 May 2021 13:35:38 +0200 Subject: [PATCH 21/61] =?UTF-8?q?=E2=9C=A8=20MEDIA=5FMENU=5FAT=5FTOP=20for?= =?UTF-8?q?=20MarlinUI=20(#21925)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 2 + Marlin/src/lcd/menu/menu_main.cpp | 101 +++++++++++------------------- buildroot/tests/mega2560 | 4 +- 3 files changed, 42 insertions(+), 65 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 5db36d9cbbe7..4511aa49c769 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1301,6 +1301,8 @@ //#define BROWSE_MEDIA_ON_INSERT // Open the file browser when media is inserted + //#define MEDIA_MENU_AT_TOP // Force the media menu to be listed on the top of the main menu + #define EVENT_GCODE_SD_ABORT "G28XY" // G-code to run on SD Abort Print (e.g., "G28XY" or "G27") #if ENABLED(PRINTER_EVENT_LEDS) diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 34d1d6c6f452..17c9b1fe6a44 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -254,6 +254,38 @@ void menu_main() { START_MENU(); BACK_ITEM(MSG_INFO_SCREEN); + #if ENABLED(SDSUPPORT) + + #if !defined(MEDIA_MENU_AT_TOP) && !HAS_ENCODER_WHEEL + #define MEDIA_MENU_AT_TOP + #endif + + auto sdcard_menu_items = [&]{ + #if ENABLED(MENU_ADDAUTOSTART) + ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files + #endif + + if (card_detected) { + if (!card_open) { + #if PIN_EXISTS(SD_DETECT) + GCODES_ITEM(MSG_CHANGE_MEDIA, PSTR("M21")); // M21 Change Media + #else // - or - + GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22")); // M22 Release Media + #endif + SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First) + } + } + else { + #if PIN_EXISTS(SD_DETECT) + ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media" + #else + GCODES_ITEM(MSG_ATTACH_MEDIA, PSTR("M21")); // M21 Attach Media + #endif + } + }; + + #endif + if (busy) { #if MACHINE_CAN_PAUSE ACTION_ITEM(MSG_PAUSE_PRINT, ui.pause_print); @@ -281,36 +313,9 @@ void menu_main() { } else { - #if !HAS_ENCODER_WHEEL && ENABLED(SDSUPPORT) - - // *** IF THIS SECTION IS CHANGED, REPRODUCE BELOW *** - - // - // Run Auto Files - // - #if ENABLED(MENU_ADDAUTOSTART) - ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); - #endif - - if (card_detected) { - if (!card_open) { - SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); - #if PIN_EXISTS(SD_DETECT) - GCODES_ITEM(MSG_CHANGE_MEDIA, PSTR("M21")); - #else - GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22")); - #endif - } - } - else { - #if PIN_EXISTS(SD_DETECT) - ACTION_ITEM(MSG_NO_MEDIA, nullptr); - #else - GCODES_ITEM(MSG_ATTACH_MEDIA, PSTR("M21")); - #endif - } - - #endif // !HAS_ENCODER_WHEEL && SDSUPPORT + #if BOTH(SDSUPPORT, MEDIA_MENU_AT_TOP) + sdcard_menu_items(); + #endif if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused())) ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print); @@ -387,39 +392,9 @@ void menu_main() { GCODES_ITEM(MSG_SWITCH_PS_ON, PSTR("M80")); #endif - #if BOTH(HAS_ENCODER_WHEEL, SDSUPPORT) - - if (!busy) { - - // *** IF THIS SECTION IS CHANGED, REPRODUCE ABOVE *** - - // - // Autostart - // - #if ENABLED(MENU_ADDAUTOSTART) - ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); - #endif - - if (card_detected) { - if (!card_open) { - #if PIN_EXISTS(SD_DETECT) - GCODES_ITEM(MSG_CHANGE_MEDIA, PSTR("M21")); - #else - GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22")); - #endif - SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); - } - } - else { - #if PIN_EXISTS(SD_DETECT) - ACTION_ITEM(MSG_NO_MEDIA, nullptr); - #else - GCODES_ITEM(MSG_ATTACH_MEDIA, PSTR("M21")); - #endif - } - } - - #endif // HAS_ENCODER_WHEEL && SDSUPPORT + #if ENABLED(SDSUPPORT) && DISABLED(MEDIA_MENU_AT_TOP) + sdcard_menu_items(); + #endif #if HAS_SERVICE_INTERVALS static auto _service_reset = [](const int index) { diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 8e63c6e7b1b2..fc445c0532dd 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -20,8 +20,8 @@ opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO LCD_LANGUAGE fr \ EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 5 TEMP_SENSOR_3 20 TEMP_SENSOR_4 1000 TEMP_SENSOR_BED 1 opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT SKEW_CORRECTION \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \ - SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT AUTO_REPORT_SD_STATUS SCROLL_LONG_FILENAMES CANCEL_OBJECTS SOUND_MENU_ITEM \ - EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN FREEZE_FEATURE \ + SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT AUTO_REPORT_SD_STATUS SCROLL_LONG_FILENAMES MEDIA_MENU_AT_TOP \ + EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN FREEZE_FEATURE CANCEL_OBJECTS SOUND_MENU_ITEM \ MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \ LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \ BABYSTEPPING BABYSTEP_XY NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL From 000388b1d9e38a2678e8235a5d4dc3163f853c02 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 20 May 2021 17:12:18 -0500 Subject: [PATCH 22/61] =?UTF-8?q?=F0=9F=8E=A8=20MULTI=5FMANUAL=20=3D>=20MU?= =?UTF-8?q?LTI=5FE=5FMANUAL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/marlinui.cpp | 6 +++--- Marlin/src/lcd/marlinui.h | 6 +++--- Marlin/src/lcd/menu/menu_motion.cpp | 12 ++++++------ Marlin/src/lcd/tft/ui_1024x600.cpp | 2 +- Marlin/src/lcd/tft/ui_320x240.cpp | 2 +- Marlin/src/lcd/tft/ui_480x320.cpp | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 1d312535c940..544cc5eb2c96 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -681,7 +681,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { xyze_pos_t ManualMove::all_axes_destination = { 0 }; bool ManualMove::processing = false; #endif - #if ENABLED(MULTI_MANUAL) + #if ENABLED(MULTI_E_MANUAL) int8_t ManualMove::e_index = 0; #endif AxisEnum ManualMove::axis = NO_AXIS_MASK; @@ -758,11 +758,11 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { // Tell ui.update() to start a move to current_position after a short delay. // void ManualMove::soon(const AxisEnum move_axis - #if MULTI_MANUAL + #if MULTI_E_MANUAL , const int8_t eindex/*=-1*/ #endif ) { - #if MULTI_MANUAL + #if MULTI_E_MANUAL if (move_axis == E_AXIS) e_index = eindex >= 0 ? eindex : active_extruder; #endif start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 085e2e0b7e3a..ba0221713b53 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -48,7 +48,7 @@ #endif #if E_MANUAL > 1 - #define MULTI_MANUAL 1 + #define MULTI_E_MANUAL 1 #endif #if HAS_DISPLAY @@ -129,7 +129,7 @@ class ManualMove { private: static AxisEnum axis; - #if MULTI_MANUAL + #if MULTI_E_MANUAL static int8_t e_index; #else static int8_t constexpr e_index = 0; @@ -183,7 +183,7 @@ #endif static void task(); static void soon(const AxisEnum axis - #if MULTI_MANUAL + #if MULTI_E_MANUAL , const int8_t eindex=-1 #endif ); diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 6bf6df1897e4..06d635ffc835 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -94,14 +94,14 @@ void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); } #if E_MANUAL - static void lcd_move_e(TERN_(MULTI_MANUAL, const int8_t eindex=-1)) { + static void lcd_move_e(TERN_(MULTI_E_MANUAL, const int8_t eindex=-1)) { if (ui.use_click()) return ui.goto_previous_screen_no_defer(); if (ui.encoderPosition) { if (!ui.manual_move.processing) { const float diff = float(int32_t(ui.encoderPosition)) * ui.manual_move.menu_scale; TERN(IS_KINEMATIC, ui.manual_move.offset, current_position.e) += diff; ui.manual_move.soon(E_AXIS - #if MULTI_MANUAL + #if MULTI_E_MANUAL , eindex #endif ); @@ -110,9 +110,9 @@ void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); } ui.encoderPosition = 0; } if (ui.should_draw()) { - TERN_(MULTI_MANUAL, MenuItemBase::init(eindex)); + TERN_(MULTI_E_MANUAL, MenuItemBase::init(eindex)); MenuEditItemBase::draw_edit_screen( - GET_TEXT(TERN(MULTI_MANUAL, MSG_MOVE_EN, MSG_MOVE_E)), + GET_TEXT(TERN(MULTI_E_MANUAL, MSG_MOVE_EN, MSG_MOVE_E)), ftostr41sign(current_position.e PLUS_TERN0(IS_KINEMATIC, ui.manual_move.offset) MINUS_TERN0(MANUAL_E_MOVES_RELATIVE, manual_move_e_origin) @@ -188,7 +188,7 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int #if E_MANUAL inline void _goto_menu_move_distance_e() { - ui.goto_screen([]{ _menu_move_distance(E_AXIS, []{ lcd_move_e(TERN_(MULTI_MANUAL, active_extruder)); }, -1); }); + ui.goto_screen([]{ _menu_move_distance(E_AXIS, []{ lcd_move_e(TERN_(MULTI_E_MANUAL, active_extruder)); }, -1); }); } inline void _menu_move_distance_e_maybe() { @@ -283,7 +283,7 @@ void menu_move() { SUBMENU_MOVE_E(E_MANUAL - 1); #endif - #elif MULTI_MANUAL + #elif MULTI_E_MANUAL // Independent extruders with one E-stepper per hotend LOOP_L_N(n, E_MANUAL) SUBMENU_MOVE_E(n); diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index 3b12ab2b60a9..87b016b1eca3 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -725,7 +725,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { #endif ui.manual_move.soon(axis - #if MULTI_MANUAL + #if MULTI_E_MANUAL , motionAxisState.e_selection #endif ); diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 31665fdc3309..89a127b01ed9 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -710,7 +710,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { #endif ui.manual_move.soon(axis - #if MULTI_MANUAL + #if MULTI_E_MANUAL , motionAxisState.e_selection #endif ); diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index a5539990d5e4..6923bdd71c0e 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -712,7 +712,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { #endif ui.manual_move.soon(axis - #if MULTI_MANUAL + #if MULTI_E_MANUAL , motionAxisState.e_selection #endif ); From 67f08ef07f6419b5cca78226de75f2b14bde6d0c Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 21 May 2021 01:07:03 +0000 Subject: [PATCH 23/61] [cron] Bump distribution date (2021-05-21) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 4bb0f19a8a37..0209b9377efc 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-05-20" + #define STRING_DISTRIBUTION_DATE "2021-05-21" #endif /** From 8f0f6c1ac117bff0b5f2c2140479b93ea9cd138b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 20 May 2021 21:47:05 -0500 Subject: [PATCH 24/61] =?UTF-8?q?=F0=9F=90=9B=20Fix=20compile=20with=20PRE?= =?UTF-8?q?VENT=5FCOLD=5FEXTRUSION=20off?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp | 11 ++++++++-- .../lcd/extui/dgus/mks/DGUSScreenHandler.cpp | 22 +++++++++++-------- .../lcd/extui/dgus/mks/DGUSScreenHandler.h | 4 +++- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp index 525b781599c8..3d68df7b7f02 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp @@ -691,7 +691,10 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_X_PARK_POS, &mks_park_pos.x, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Y_PARK_POS, &mks_park_pos.y, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Z_PARK_POS, &mks_park_pos.z, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_MIN_EX_T, &thermalManager.extrude_min_temp, ScreenHandler.HandleGetExMinTemp_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + + #if ENABLED(PREVENT_COLD_EXTRUSION) + VPHELPER(VP_MIN_EX_T, &thermalManager.extrude_min_temp, ScreenHandler.HandleGetExMinTemp_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + #endif #if ENABLED(SENSORLESS_HOMING) // TMC SENSORLESS Setting #if AXIS_HAS_STEALTHCHOP(X) @@ -743,7 +746,11 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_ZOffset_Distance,nullptr ,ScreenHandler.GetZoffsetDistance, nullptr), VPHELPER(VP_MESH_LEVEL_ADJUST, nullptr, ScreenHandler.MeshLevelDistanceConfig, nullptr), VPHELPER(VP_MESH_LEVEL_POINT,nullptr, ScreenHandler.MeshLevel,nullptr), - VPHELPER(VP_Min_EX_T_E, &thermalManager.extrude_min_temp, &ScreenHandler.GetMinExtrudeTemp, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + + #if ENABLED(PREVENT_COLD_EXTRUSION) + VPHELPER(VP_Min_EX_T_E, &thermalManager.extrude_min_temp, &ScreenHandler.GetMinExtrudeTemp, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + #endif + VPHELPER(VP_AutoTurnOffSw, nullptr, &ScreenHandler.GetTurnOffCtrl, nullptr), #if HOTENDS >= 1 diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index c0b3b60a16e7..6d12d529a943 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -342,7 +342,7 @@ void DGUSScreenHandler::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) { void DGUSScreenHandler::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("GetMinExtrudeTemp"); const uint16_t value = swap16(*(uint16_t *)val_ptr); - thermalManager.extrude_min_temp = value; + TERN_(PREVENT_COLD_EXTRUSION, thermalManager.extrude_min_temp = value); mks_min_extrusion_temp = value; settings.save(); } @@ -1083,11 +1083,13 @@ void DGUSScreenHandler::HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } -void DGUSScreenHandler::HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t value_ex_min_temp = swap16(*(uint16_t*)val_ptr); - thermalManager.extrude_min_temp = value_ex_min_temp; - skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel -} +#if ENABLED(PREVENT_COLD_EXTRUSION) + void DGUSScreenHandler::HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_ptr) { + const uint16_t value_ex_min_temp = swap16(*(uint16_t*)val_ptr); + thermalManager.extrude_min_temp = value_ex_min_temp; + skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel + } +#endif #if HAS_PID_HEATING void DGUSScreenHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) { @@ -1231,7 +1233,7 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ break; } - #if HAS_HOTEND + #if BOTH(HAS_HOTEND, PREVENT_COLD_EXTRUSION) if (hotend_too_cold) { if (thermalManager.targetTooColdToExtrude(hotend_too_cold - 1)) thermalManager.setTargetHotend(thermalManager.extrude_min_temp, hotend_too_cold - 1); sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); @@ -1428,8 +1430,10 @@ bool DGUSScreenHandler::loop() { #endif #endif - if (mks_min_extrusion_temp != 0) - thermalManager.extrude_min_temp = mks_min_extrusion_temp; + #if ENABLED(PREVENT_COLD_EXTRUSION) + if (mks_min_extrusion_temp != 0) + thermalManager.extrude_min_temp = mks_min_extrusion_temp; + #endif DGUS_ExtrudeLoadInit(); diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h index 6713debd83ae..4a67b4afda76 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h @@ -82,7 +82,9 @@ class DGUSScreenHandler { static void GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr); static void GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr); static void GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr); - static void HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_ptr); + #if ENABLED(PREVENT_COLD_EXTRUSION) + static void HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_ptr); + #endif static void DGUS_LanguageDisplay(uint8_t var); static void TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr); static void GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr); From 2db640ea801d40af05dc598d168380a48b1ec1c8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 21 May 2021 00:26:54 -0500 Subject: [PATCH 25/61] Add a test for SAVED_POSITIONS --- buildroot/tests/mega2560 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index fc445c0532dd..a3711ca0766e 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -16,7 +16,7 @@ set -e # Test a probeless build of AUTO_BED_LEVELING_UBL, with lots of extruders # use_example_configs AnimationExample -opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO LCD_LANGUAGE fr \ +opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO LCD_LANGUAGE fr SAVED_POSITIONS 4 \ EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 5 TEMP_SENSOR_3 20 TEMP_SENSOR_4 1000 TEMP_SENSOR_BED 1 opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT SKEW_CORRECTION \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \ From f4951ed56b3fe7b2f85c039677dc9a499d537e8f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 21 May 2021 08:25:54 -0500 Subject: [PATCH 26/61] =?UTF-8?q?=F0=9F=8E=A8=20Rename=20all/no=20axis=20e?= =?UTF-8?q?nums?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/types.h | 2 +- Marlin/src/gcode/calibrate/M852.cpp | 2 +- Marlin/src/gcode/probe/G38.cpp | 2 +- Marlin/src/lcd/marlinui.cpp | 12 ++++++------ Marlin/src/lcd/menu/menu_bed_leveling.cpp | 2 +- Marlin/src/lcd/menu/menu_ubl.cpp | 2 +- Marlin/src/module/motion.cpp | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 98e2bedb001f..b7ae85eb2ee1 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -54,7 +54,7 @@ enum AxisEnum : uint8_t { X_HEAD, Y_HEAD, Z_HEAD, E0_AXIS = E_AXIS, E1_AXIS, E2_AXIS, E3_AXIS, E4_AXIS, E5_AXIS, E6_AXIS, E7_AXIS, - ALL_AXES_MASK = 0xFE, NO_AXIS_MASK = 0xFF + ALL_AXES_ENUM = 0xFE, NO_AXIS_ENUM = 0xFF }; // diff --git a/Marlin/src/gcode/calibrate/M852.cpp b/Marlin/src/gcode/calibrate/M852.cpp index a038dc59fdf6..6f1e984bc30d 100644 --- a/Marlin/src/gcode/calibrate/M852.cpp +++ b/Marlin/src/gcode/calibrate/M852.cpp @@ -86,7 +86,7 @@ void GcodeSuite::M852() { // When skew is changed the current position changes if (setval) { - set_current_from_steppers_for_axis(ALL_AXES_MASK); + set_current_from_steppers_for_axis(ALL_AXES_ENUM); sync_plan_position(); report_current_position(); } diff --git a/Marlin/src/gcode/probe/G38.cpp b/Marlin/src/gcode/probe/G38.cpp index 606776f40299..6906805fca14 100644 --- a/Marlin/src/gcode/probe/G38.cpp +++ b/Marlin/src/gcode/probe/G38.cpp @@ -38,7 +38,7 @@ inline void G38_single_probe(const uint8_t move_value) { planner.synchronize(); G38_move = 0; endstops.hit_on_purpose(); - set_current_from_steppers_for_axis(ALL_AXES_MASK); + set_current_from_steppers_for_axis(ALL_AXES_ENUM); sync_plan_position(); } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 544cc5eb2c96..c99fa41657c5 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -684,7 +684,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { #if ENABLED(MULTI_E_MANUAL) int8_t ManualMove::e_index = 0; #endif - AxisEnum ManualMove::axis = NO_AXIS_MASK; + AxisEnum ManualMove::axis = NO_AXIS_ENUM; /** * If a manual move has been posted and its time has arrived, and if the planner @@ -695,7 +695,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { * * To post a manual move: * - Update current_position to the new place you want to go. - * - Set manual_move.axis to an axis like X_AXIS. Use ALL_AXES_MASK for diagonal moves. + * - Set manual_move.axis to an axis like X_AXIS. Use ALL_AXES_ENUM for diagonal moves. * - Set manual_move.start_time to a point in the future (in ms) when the move should be done. * * For kinematic machines: @@ -710,7 +710,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { if (processing) return; // Prevent re-entry from idle() calls // Add a manual move to the queue? - if (axis != NO_AXIS_MASK && ELAPSED(millis(), start_time) && !planner.is_full()) { + if (axis != NO_AXIS_ENUM && ELAPSED(millis(), start_time) && !planner.is_full()) { const feedRate_t fr_mm_s = (axis <= E_AXIS) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; @@ -722,7 +722,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { #endif // Apply a linear offset to a single axis - if (axis == ALL_AXES_MASK) + if (axis == ALL_AXES_ENUM) destination = all_axes_destination; else if (axis <= XYZE) { destination = current_position; @@ -731,7 +731,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { // Reset for the next move offset = 0; - axis = NO_AXIS_MASK; + axis = NO_AXIS_ENUM; // DELTA and SCARA machines use segmented moves, which could fill the planner during the call to // move_to_destination. This will cause idle() to be called, which can then call this function while the @@ -748,7 +748,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { //SERIAL_ECHOLNPAIR("Add planner.move with Axis ", AS_CHAR(axis_codes[axis]), " at FR ", fr_mm_s); - axis = NO_AXIS_MASK; + axis = NO_AXIS_ENUM; #endif } diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index 70de53dab593..62cf8cf1c16b 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -206,7 +206,7 @@ #if ENABLED(MESH_EDIT_MENU) inline void refresh_planner() { - set_current_from_steppers_for_axis(ALL_AXES_MASK); + set_current_from_steppers_for_axis(ALL_AXES_ENUM); sync_plan_position(); } diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index f923f98c7828..880b76ff7651 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -430,7 +430,7 @@ void ubl_map_move_to_xy() { // Use the built-in manual move handler to move to the mesh point. ui.manual_move.set_destination(xy); - ui.manual_move.soon(ALL_AXES_MASK); + ui.manual_move.soon(ALL_AXES_ENUM); } inline int32_t grid_index(const uint8_t x, const uint8_t y) { diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 69aed1e1926f..ec57b37a71de 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -282,7 +282,7 @@ void report_current_position_projected() { void quickstop_stepper() { planner.quick_stop(); planner.synchronize(); - set_current_from_steppers_for_axis(ALL_AXES_MASK); + set_current_from_steppers_for_axis(ALL_AXES_ENUM); sync_plan_position(); } @@ -360,7 +360,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) { planner.unapply_modifiers(pos, true); #endif - if (axis == ALL_AXES_MASK) + if (axis == ALL_AXES_ENUM) current_position = pos; else current_position[axis] = pos[axis]; From ad30909a2d45a37c3a689a7080ca346f3cb75c5f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 21 May 2021 08:24:38 -0500 Subject: [PATCH 27/61] =?UTF-8?q?=F0=9F=8E=A8=20Update=20a=20condition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/marlinui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index c99fa41657c5..14959851fa34 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -681,7 +681,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { xyze_pos_t ManualMove::all_axes_destination = { 0 }; bool ManualMove::processing = false; #endif - #if ENABLED(MULTI_E_MANUAL) + #if MULTI_E_MANUAL int8_t ManualMove::e_index = 0; #endif AxisEnum ManualMove::axis = NO_AXIS_ENUM; From 2de54dab84d82ef69fb9ac3bd9025444f4f84813 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 21 May 2021 08:23:09 -0500 Subject: [PATCH 28/61] =?UTF-8?q?=F0=9F=8E=A8=20Move=20HAS=5FEXTRUDERS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/powerloss.cpp | 2 +- Marlin/src/gcode/config/M221.cpp | 2 +- Marlin/src/gcode/gcode.cpp | 10 ++++++---- Marlin/src/gcode/gcode.h | 13 ++++++++----- Marlin/src/gcode/host/M360.cpp | 4 ++-- Marlin/src/gcode/temp/M104_M109.cpp | 2 +- Marlin/src/gcode/units/M82_M83.cpp | 6 ++++++ Marlin/src/inc/Conditionals_LCD.h | 11 +++++++---- Marlin/src/inc/Conditionals_adv.h | 2 +- Marlin/src/inc/SanityCheck.h | 2 +- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 2 +- .../src/lcd/extui/dgus/DGUSScreenHandler.cpp | 2 +- Marlin/src/lcd/menu/menu_info.cpp | 6 +++--- Marlin/src/lcd/menu/menu_tune.cpp | 2 +- Marlin/src/module/motion.cpp | 6 +++--- Marlin/src/module/motion.h | 2 +- Marlin/src/module/planner.cpp | 18 +++++++++--------- Marlin/src/module/planner.h | 4 ++-- Marlin/src/module/settings.cpp | 6 +++--- Marlin/src/module/tool_change.cpp | 2 +- Marlin/src/pins/ramps/pins_3DRAG.h | 2 +- Marlin/src/pins/sensitive_pins.h | 2 +- .../PlatformIO/scripts/common-dependencies.h | 4 ---- ini/features.ini | 2 +- platformio.ini | 1 + 25 files changed, 63 insertions(+), 52 deletions(-) diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index a7474794de3b..a512022320db 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -197,7 +197,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW #endif #endif - #if EXTRUDERS + #if HAS_EXTRUDERS HOTEND_LOOP() info.target_temperature[e] = thermalManager.degTargetHotend(e); #endif diff --git a/Marlin/src/gcode/config/M221.cpp b/Marlin/src/gcode/config/M221.cpp index 7ba22d1901d5..e380bfb1c7d0 100644 --- a/Marlin/src/gcode/config/M221.cpp +++ b/Marlin/src/gcode/config/M221.cpp @@ -23,7 +23,7 @@ #include "../gcode.h" #include "../../module/planner.h" -#if EXTRUDERS +#if HAS_EXTRUDERS /** * M221: Set extrusion percentage (M221 T0 S95) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 33877cd61c5f..30151b3bd0cb 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -520,7 +520,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 100: M100(); break; // M100: Free Memory Report #endif - #if EXTRUDERS + #if HAS_EXTRUDERS case 104: M104(); break; // M104: Set hot end temperature case 109: M109(); break; // M109: Wait for hotend temperature to reach target #endif @@ -596,8 +596,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { #endif case 81: M81(); break; // M81: Turn off Power, including Power Supply, if possible - case 82: M82(); break; // M82: Set E axis normal mode (same as other axes) - case 83: M83(); break; // M83: Set E axis relative mode + #if HAS_EXTRUDERS + case 82: M82(); break; // M82: Set E axis normal mode (same as other axes) + case 83: M83(); break; // M83: Set E axis relative mode + #endif case 18: case 84: M18_M84(); break; // M18/M84: Disable Steppers / Set Timeout case 85: M85(); break; // M85: Set inactivity stepper shutdown timeout case 92: M92(); break; // M92: Set the steps-per-unit for one or more axes @@ -674,7 +676,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 220: M220(); break; // M220: Set Feedrate Percentage: S ("FR" on your LCD) - #if EXTRUDERS + #if HAS_EXTRUDERS case 221: M221(); break; // M221: Set Flow Percentage #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index cdf04cd0f275..c32575e81ee4 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -633,10 +633,13 @@ class GcodeSuite { #if ENABLED(PSU_CONTROL) static void M80(); #endif - static void M81(); - static void M82(); - static void M83(); + + #if HAS_EXTRUDERS + static void M82(); + static void M83(); + #endif + static void M85(); static void M92(); @@ -644,7 +647,7 @@ class GcodeSuite { static void M100(); #endif - #if EXTRUDERS + #if HAS_EXTRUDERS static void M104(); static void M109(); #endif @@ -776,7 +779,7 @@ class GcodeSuite { static void M220(); - #if EXTRUDERS + #if HAS_EXTRUDERS static void M221(); #endif diff --git a/Marlin/src/gcode/host/M360.cpp b/Marlin/src/gcode/host/M360.cpp index f3c242526dd5..7a0b8e3ab0f7 100644 --- a/Marlin/src/gcode/host/M360.cpp +++ b/Marlin/src/gcode/host/M360.cpp @@ -28,7 +28,7 @@ #include "../../module/motion.h" #include "../../module/planner.h" -#if EXTRUDERS +#if HAS_EXTRUDERS #include "../../module/temperature.h" #endif @@ -171,7 +171,7 @@ void GcodeSuite::M360() { // Per-Extruder settings // config_line(PSTR("NumExtruder"), EXTRUDERS); - #if EXTRUDERS + #if HAS_EXTRUDERS LOOP_L_N(e, EXTRUDERS) { config_line_e(e, JERK_STR, TERN(HAS_LINEAR_E_JERK, planner.max_e_jerk[E_INDEX_N(e)], TERN(HAS_CLASSIC_JERK, planner.max_jerk.e, DEFAULT_EJERK))); config_line_e(e, PSTR("MaxSpeed"), planner.settings.max_feedrate_mm_s[E_AXIS_N(e)]); diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index e54f7841533e..eb350a577afc 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -28,7 +28,7 @@ #include "../../inc/MarlinConfigPre.h" -#if EXTRUDERS +#if HAS_EXTRUDERS #include "../gcode.h" #include "../../module/temperature.h" diff --git a/Marlin/src/gcode/units/M82_M83.cpp b/Marlin/src/gcode/units/M82_M83.cpp index d93f0ea5adf3..c1767e805739 100644 --- a/Marlin/src/gcode/units/M82_M83.cpp +++ b/Marlin/src/gcode/units/M82_M83.cpp @@ -20,6 +20,10 @@ * */ +#include "../../inc/MarlinConfigPre.h" + +#if HAS_EXTRUDERS + #include "../gcode.h" /** @@ -31,3 +35,5 @@ void GcodeSuite::M82() { set_e_absolute(); } * M83: Set E codes relative while in Absolute Coordinates (G90) mode */ void GcodeSuite::M83() { set_e_relative(); } + +#endif // HAS_EXTRUDERS diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 545ee403a182..8001674dc4d5 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -538,7 +538,12 @@ * E_MANUAL - Number of E steppers for LCD move options */ -#if EXTRUDERS == 0 +#if EXTRUDERS + #define HAS_EXTRUDERS 1 + #if EXTRUDERS > 1 + #define HAS_MULTI_EXTRUDER 1 + #endif +#else #undef EXTRUDERS #define EXTRUDERS 0 #undef SINGLENOZZLE @@ -546,8 +551,6 @@ #undef SWITCHING_NOZZLE #undef MIXING_EXTRUDER #undef HOTEND_IDLE_TIMEOUT -#elif EXTRUDERS > 1 - #define HAS_MULTI_EXTRUDER 1 #endif #if ENABLED(SWITCHING_EXTRUDER) // One stepper for every two EXTRUDERS @@ -663,7 +666,7 @@ * All the logical axes that can be commanded directly by G-code. * Delta maps stepper-specific values to ABC steppers. */ -#if EXTRUDERS +#if HAS_EXTRUDERS #define LOGICAL_AXES INCREMENT(LINEAR_AXES) #else #define LOGICAL_AXES LINEAR_AXES diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 95a7ada83f78..1d3253b1ccb2 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -75,7 +75,7 @@ #define SERVO_DELAY { 50 } #endif -#if EXTRUDERS == 0 +#if !HAS_EXTRUDERS #define NO_VOLUMETRICS #undef TEMP_SENSOR_0 #undef TEMP_SENSOR_1 diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index b9eacd0a1a50..23201bb38767 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1555,7 +1555,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #if ENABLED(G26_MESH_VALIDATION) - #if !EXTRUDERS + #if !HAS_EXTRUDERS #error "G26_MESH_VALIDATION requires at least one extruder." #elif !HAS_MESH #error "G26_MESH_VALIDATION requires MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, or AUTO_BED_LEVELING_UBL." diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 85430c18b05b..50c80c9fa074 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -954,7 +954,7 @@ void MarlinUI::draw_status_screen() { else #endif { - #if EXTRUDERS + #if HAS_EXTRUDERS c = 'E'; per = planner.flow_percentage[0]; #endif diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp index 5b3bb9e0f397..a1de499f463c 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp @@ -422,7 +422,7 @@ void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *va } void DGUSScreenHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr) { - #if EXTRUDERS + #if HAS_EXTRUDERS uint16_t newvalue = swap16(*(uint16_t*)val_ptr); uint8_t target_extruder; switch (var.VP) { diff --git a/Marlin/src/lcd/menu/menu_info.cpp b/Marlin/src/lcd/menu/menu_info.cpp index d00909c7b326..cecccd115d4d 100644 --- a/Marlin/src/lcd/menu/menu_info.cpp +++ b/Marlin/src/lcd/menu/menu_info.cpp @@ -100,7 +100,7 @@ void menu_info_thermistors() { START_SCREEN(); - #if EXTRUDERS + #if HAS_EXTRUDERS #define THERMISTOR_ID TEMP_SENSOR_0 #include "../thermistornames.h" STATIC_ITEM_P(PSTR(LCD_STR_E0 ": " THERMISTOR_NAME), SS_INVERT); @@ -171,7 +171,7 @@ void menu_info_thermistors() { PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_7_MAXTEMP), SS_LEFT); #endif - #if EXTRUDERS + #if HAS_EXTRUDERS STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); #endif @@ -278,7 +278,7 @@ void menu_info() { #else SUBMENU(MSG_INFO_PRINTER_MENU, menu_info_printer); // Printer Info > SUBMENU(MSG_INFO_BOARD_MENU, menu_info_board); // Board Info > - #if EXTRUDERS + #if HAS_EXTRUDERS SUBMENU(MSG_INFO_THERMISTOR_MENU, menu_info_thermistors); // Thermistors > #endif #endif diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index 1a972f63f295..3a0d0c81caf8 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -195,7 +195,7 @@ void menu_tune() { // // Flow: // - #if EXTRUDERS + #if HAS_EXTRUDERS EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); }); // Flow En: #if HAS_MULTI_EXTRUDER diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index ec57b37a71de..235a969f66e7 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -374,7 +374,7 @@ void line_to_current_position(const_feedRate_t fr_mm_s/*=feedrate_mm_s*/) { planner.buffer_line(current_position, fr_mm_s, active_extruder); } -#if EXTRUDERS +#if HAS_EXTRUDERS void unscaled_e_move(const_float_t length, const_feedRate_t fr_mm_s) { TERN_(HAS_FILAMENT_SENSOR, runout.reset()); current_position.e += length / planner.e_factor[active_extruder]; @@ -421,7 +421,7 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ const uint16_t old_pct = feedrate_percentage; feedrate_percentage = 100; - #if EXTRUDERS + #if HAS_EXTRUDERS const float old_fac = planner.e_factor[active_extruder]; planner.e_factor[active_extruder] = 1.0f; #endif @@ -433,7 +433,7 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ feedrate_mm_s = old_feedrate; feedrate_percentage = old_pct; - #if EXTRUDERS + #if HAS_EXTRUDERS planner.e_factor[active_extruder] = old_fac; #endif } diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 3c6f044b2193..a43af6446b2d 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -272,7 +272,7 @@ void sync_plan_position_e(); */ void line_to_current_position(const_feedRate_t fr_mm_s=feedrate_mm_s); -#if EXTRUDERS +#if HAS_EXTRUDERS void unscaled_e_move(const_float_t length, const_feedRate_t fr_mm_s); #endif diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index dde6e89a1f48..714be8019e20 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -164,7 +164,7 @@ float Planner::steps_to_mm[DISTINCT_AXES]; // (mm) Millimeters per step xyze_bool_t Planner::last_page_dir{0}; #endif -#if EXTRUDERS +#if HAS_EXTRUDERS int16_t Planner::flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100); // Extrusion factor for each extruder float Planner::e_factor[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(1.0f); // The flow percentage and volumetric multiplier combine to scale E movement #endif @@ -1836,7 +1836,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, db = target.b - position.b, dc = target.c - position.c; - #if EXTRUDERS + #if HAS_EXTRUDERS int32_t de = target.e - position.e; #else constexpr int32_t de = 0; @@ -1848,7 +1848,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, " A:", target.a, " (", da, " steps)" " B:", target.b, " (", db, " steps)" " C:", target.c, " (", dc, " steps)" - #if EXTRUDERS + #if HAS_EXTRUDERS " E:", target.e, " (", de, " steps)" #endif ); @@ -1921,7 +1921,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif if (de < 0) SBI(dm, E_AXIS); - #if EXTRUDERS + #if HAS_EXTRUDERS const float esteps_float = de * e_factor[extruder]; const uint32_t esteps = ABS(esteps_float) + 0.5f; #else @@ -2003,7 +2003,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, steps_dist_mm.c = dc * steps_to_mm[C_AXIS]; #endif - #if EXTRUDERS + #if HAS_EXTRUDERS steps_dist_mm.e = esteps_float * steps_to_mm[E_AXIS_N(extruder)]; #else steps_dist_mm.e = 0.0f; @@ -2013,7 +2013,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (block->steps.a < MIN_STEPS_PER_SEGMENT && block->steps.b < MIN_STEPS_PER_SEGMENT && block->steps.c < MIN_STEPS_PER_SEGMENT) { block->millimeters = (0 - #if EXTRUDERS + #if HAS_EXTRUDERS + ABS(steps_dist_mm.e) #endif ); @@ -2046,7 +2046,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, TERN_(BACKLASH_COMPENSATION, backlash.add_correction_steps(da, db, dc, dm, block)); } - #if EXTRUDERS + #if HAS_EXTRUDERS block->steps.e = esteps; #endif @@ -2107,7 +2107,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif // Enable extruder(s) - #if EXTRUDERS + #if HAS_EXTRUDERS if (esteps) { TERN_(AUTO_POWER_CONTROL, powerManager.power_on()); @@ -2209,7 +2209,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, } // Limit speed on extruders, if any - #if EXTRUDERS + #if HAS_EXTRUDERS { current_speed.e = steps_dist_mm.e * inverse_secs; #if HAS_MIXER_SYNC_CHANNEL diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index db83792b452f..2ec90e1fa239 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -337,7 +337,7 @@ class Planner { static xyze_bool_t last_page_dir; // Last page direction given #endif - #if EXTRUDERS + #if HAS_EXTRUDERS static int16_t flow_percentage[EXTRUDERS]; // Extrusion factor for each extruder static float e_factor[EXTRUDERS]; // The flow percentage and volumetric multiplier combine to scale E movement #endif @@ -494,7 +494,7 @@ class Planner { static inline void set_max_jerk(const AxisEnum, const_float_t ) {} #endif - #if EXTRUDERS + #if HAS_EXTRUDERS FORCE_INLINE static void refresh_e_factor(const uint8_t e) { e_factor[e] = flow_percentage[e] * 0.01f * TERN(NO_VOLUMETRICS, 1.0f, volumetric_multiplier[e]); } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 56e3c86fd4a3..eae4728793fe 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -402,7 +402,7 @@ typedef struct SettingsDataStruct { // // ADVANCED_PAUSE_FEATURE // - #if EXTRUDERS + #if HAS_EXTRUDERS fil_change_settings_t fc_settings[EXTRUDERS]; // M603 T U L #endif @@ -1321,7 +1321,7 @@ void MarlinSettings::postprocess() { // // Advanced Pause filament load & unload lengths // - #if EXTRUDERS + #if HAS_EXTRUDERS { #if DISABLED(ADVANCED_PAUSE_FEATURE) const fil_change_settings_t fc_settings[EXTRUDERS] = { 0, 0 }; @@ -2235,7 +2235,7 @@ void MarlinSettings::postprocess() { // // Advanced Pause filament load & unload lengths // - #if EXTRUDERS + #if HAS_EXTRUDERS { #if DISABLED(ADVANCED_PAUSE_FEATURE) fil_change_settings_t fc_settings[EXTRUDERS]; diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 03e85fdd8436..cc34acc14f12 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -822,7 +822,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. #endif // ELECTROMAGNETIC_SWITCHING_TOOLHEAD -#if EXTRUDERS +#if HAS_EXTRUDERS inline void invalid_extruder_error(const uint8_t e) { SERIAL_ECHO_START(); SERIAL_CHAR('T'); SERIAL_ECHO(e); diff --git a/Marlin/src/pins/ramps/pins_3DRAG.h b/Marlin/src/pins/ramps/pins_3DRAG.h index 6c7f7f4db63f..08354ce2ff4e 100644 --- a/Marlin/src/pins/ramps/pins_3DRAG.h +++ b/Marlin/src/pins/ramps/pins_3DRAG.h @@ -144,7 +144,7 @@ #undef SPINDLE_DIR_PIN #if HAS_CUTTER - #if !EXTRUDERS + #if !HAS_EXTRUDERS #undef E0_DIR_PIN #undef E0_ENABLE_PIN #undef E0_STEP_PIN diff --git a/Marlin/src/pins/sensitive_pins.h b/Marlin/src/pins/sensitive_pins.h index 1c811601ca7b..21ba87e8f6fb 100644 --- a/Marlin/src/pins/sensitive_pins.h +++ b/Marlin/src/pins/sensitive_pins.h @@ -353,7 +353,7 @@ #define _E6_PINS #define _E7_PINS -#if EXTRUDERS +#if HAS_EXTRUDERS #undef _E0_PINS #define _E0_PINS E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN, _E0_CS _E0_MS1 _E0_MS2 _E0_MS3 #endif diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.h b/buildroot/share/PlatformIO/scripts/common-dependencies.h index 18a7303be6ea..a88e7084670b 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.h +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.h @@ -49,10 +49,6 @@ #define HAS_GCODE_M876 #endif -#if EXTRUDERS - #define HAS_EXTRUDERS -#endif - #if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) #define HAS_SMART_EFF_MOD #endif diff --git a/ini/features.ini b/ini/features.ini index 6a2ccbedac97..2b69daa88aeb 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -198,7 +198,7 @@ MAGNETIC_PARKING_EXTRUDER = src_filter=+ SDSUPPORT = src_filter=+ + + + + + + HAS_MEDIA_SUBCALLS = src_filter=+ GCODE_REPEAT_MARKERS = src_filter=+ + -HAS_EXTRUDERS = src_filter=+ + +HAS_EXTRUDERS = src_filter=+ + + HAS_COOLER = src_filter=+ + AUTO_REPORT_TEMPERATURES = src_filter=+ INCH_MODE_SUPPORT = src_filter=+ diff --git a/platformio.ini b/platformio.ini index 4d69ca12dfd2..0516149da9a5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -222,6 +222,7 @@ default_src_filter = + - - + - - - + - - - - - - - From 7985f7f11679113de6d1d83f930e926a310b768d Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 22 May 2021 01:06:28 +0000 Subject: [PATCH 29/61] [cron] Bump distribution date (2021-05-22) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 0209b9377efc..e78166461b39 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-05-21" + #define STRING_DISTRIBUTION_DATE "2021-05-22" #endif /** From 4ea4fa78aa6fcafc6f270bb543c2f8dc8ae695cd Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 21 May 2021 22:45:54 -0500 Subject: [PATCH 30/61] =?UTF-8?q?=F0=9F=93=9D=20Document=20diveToFile,=20p?= =?UTF-8?q?rintListing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 2 +- Marlin/src/sd/cardreader.cpp | 102 +++++++++++++++++++---------------- Marlin/src/sd/cardreader.h | 21 ++++++-- 3 files changed, 73 insertions(+), 52 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 23201bb38767..897cb2824fc9 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2304,7 +2304,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal + (DISABLED(IS_LEGACY_TFT) && ENABLED(TFT_GENERIC)) \ + (ENABLED(IS_LEGACY_TFT) && COUNT_ENABLED(TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI)) \ + COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \ - + COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY,DGUS_LCD_UI_MKS) \ + + COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_MKS) \ + COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY, DWIN_CREALITY_LCD) \ + COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_GENERIC_12864_1_1) \ + COUNT_ENABLED(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004) \ diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 3f6b50dd4bda..405da103de73 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -261,7 +261,14 @@ void CardReader::selectByName(SdFile dir, const char * const match) { } // -// Recursive method to list all files within a folder +// Recursive method to print all files within a folder in flat +// DOS 8.3 format. This style of listing is the most compatible +// with legacy hosts. +// +// This method recurses to unlimited depth and lists every +// G-code file within the given parent. If the hierarchy is +// very deep this can blow up the stack, so a 'depth' parameter +// (as with printListingJSON) would be a good addition. // void CardReader::printListing(SdFile parent, const char * const prepend/*=nullptr*/) { dir_t p; @@ -288,17 +295,17 @@ void CardReader::printListing(SdFile parent, const char * const prepend/*=nullpt // Get a new directory object using the full path // and dive recursively into it. - SdFile child; - if (!child.open(&parent, dosFilename, O_READ)) + SdFile child; // child.close() in destructor + if (child.open(&parent, dosFilename, O_READ)) + printListing(child, path); + else { SERIAL_ECHO_MSG(STR_SD_CANT_OPEN_SUBDIR, dosFilename); - - printListing(child, path); - // close() is done automatically by destructor of SdFile + return; + } } else if (is_dir_or_gcode(p)) { - createFilename(filename, p); if (prepend) SERIAL_ECHO(prepend); - SERIAL_ECHO(filename); + SERIAL_ECHO(createFilename(filename, p)); SERIAL_CHAR(' '); SERIAL_ECHOLN(p.fileSize); } @@ -342,7 +349,7 @@ void CardReader::ls() { // Go to the next segment while (path[++i]) { } - // SERIAL_ECHOPGM("Looking for segment: "); SERIAL_ECHOLN(segment); + //SERIAL_ECHOLNPAIR("Looking for segment: ", segment); // Find the item, setting the long filename diveDir.rewind(); @@ -720,14 +727,14 @@ void CardReader::removeFile(const char * const name) { //abortFilePrintNow(); - SdFile *curDir; - const char * const fname = diveToFile(false, curDir, name); + SdFile *itsDirPtr; + const char * const fname = diveToFile(false, itsDirPtr, name); if (!fname) return; #if ENABLED(SDCARD_READONLY) SERIAL_ECHOLNPAIR("Deletion failed (read-only), File: ", fname, "."); #else - if (file.remove(curDir, fname)) { + if (file.remove(itsDirPtr, fname)) { SERIAL_ECHOLNPAIR("File deleted:", fname); sdpos = 0; TERN_(SDCARD_SORT_ALPHA, presort()); @@ -870,98 +877,101 @@ uint16_t CardReader::countFilesInWorkDir() { * - If update_cwd was 'true' the workDir now points to the file's directory. * * Returns a pointer to the last segment (filename) of the given DOS 8.3 path. + * On exit, inDirPtr contains an SdFile reference to the file's directory. * * A nullptr result indicates an unrecoverable error. + * + * NOTE: End the path with a slash to dive to a folder. In this case the + * returned filename will be blank (points to the end of the path). */ -const char* CardReader::diveToFile(const bool update_cwd, SdFile* &diveDir, const char * const path, const bool echo/*=false*/) { +const char* CardReader::diveToFile(const bool update_cwd, SdFile* &inDirPtr, const char * const path, const bool echo/*=false*/) { DEBUG_SECTION(est, "diveToFile", true); // Track both parent and subfolder static SdFile newDir1, newDir2; - SdFile *sub = &newDir1, *startDir; + SdFile *sub = &newDir1, *startDirPtr; // Parsing the path string - const char *item_name_adr = path; + const char *atom_ptr = path; DEBUG_ECHOLNPAIR(" path = '", path, "'"); if (path[0] == '/') { // Starting at the root directory? - diveDir = &root; - item_name_adr++; - DEBUG_ECHOLNPAIR(" CWD to root: ", hex_address((void*)diveDir)); + inDirPtr = &root; + atom_ptr++; + DEBUG_ECHOLNPAIR(" CWD to root: ", hex_address((void*)inDirPtr)); if (update_cwd) workDirDepth = 0; // The cwd can be updated for the benefit of sub-programs } else - diveDir = &workDir; // Dive from workDir (as set by the UI) + inDirPtr = &workDir; // Dive from workDir (as set by the UI) - startDir = diveDir; + startDirPtr = inDirPtr; - DEBUG_ECHOLNPAIR(" startDir = ", hex_address((void*)startDir)); + DEBUG_ECHOLNPAIR(" startDirPtr = ", hex_address((void*)startDirPtr)); - while (item_name_adr) { + while (atom_ptr) { // Find next subdirectory delimiter - char * const name_end = strchr(item_name_adr, '/'); + char * const name_end = strchr(atom_ptr, '/'); // Last atom in the path? Item found. - if (name_end <= item_name_adr) break; + if (name_end <= atom_ptr) break; - // Set subDirName - const uint8_t len = name_end - item_name_adr; + // Isolate the next subitem name + const uint8_t len = name_end - atom_ptr; char dosSubdirname[len + 1]; - strncpy(dosSubdirname, item_name_adr, len); + strncpy(dosSubdirname, atom_ptr, len); dosSubdirname[len] = 0; if (echo) SERIAL_ECHOLN(dosSubdirname); DEBUG_ECHOLNPAIR(" sub = ", hex_address((void*)sub)); - // Open diveDir (closing first) + // Open inDirPtr (closing first) sub->close(); - if (!sub->open(diveDir, dosSubdirname, O_READ)) { + if (!sub->open(inDirPtr, dosSubdirname, O_READ)) { openFailed(dosSubdirname); - item_name_adr = nullptr; + atom_ptr = nullptr; break; } - // Close diveDir if not at starting-point - if (diveDir != startDir) { - DEBUG_ECHOLNPAIR(" closing diveDir: ", hex_address((void*)diveDir)); - diveDir->close(); + // Close inDirPtr if not at starting-point + if (inDirPtr != startDirPtr) { + DEBUG_ECHOLNPAIR(" closing inDirPtr: ", hex_address((void*)inDirPtr)); + inDirPtr->close(); } - // diveDir now subDir - diveDir = sub; - DEBUG_ECHOLNPAIR(" diveDir = sub: ", hex_address((void*)diveDir)); + // inDirPtr now subDir + inDirPtr = sub; + DEBUG_ECHOLNPAIR(" inDirPtr = sub: ", hex_address((void*)inDirPtr)); // Update workDirParents and workDirDepth if (update_cwd) { DEBUG_ECHOLNPAIR(" update_cwd"); if (workDirDepth < MAX_DIR_DEPTH) - workDirParents[workDirDepth++] = *diveDir; + workDirParents[workDirDepth++] = *inDirPtr; } // Point sub at the other scratch object - sub = (diveDir != &newDir1) ? &newDir1 : &newDir2; + sub = (inDirPtr != &newDir1) ? &newDir1 : &newDir2; DEBUG_ECHOLNPAIR(" swapping sub = ", hex_address((void*)sub)); // Next path atom address - item_name_adr = name_end + 1; + atom_ptr = name_end + 1; } if (update_cwd) { - workDir = *diveDir; - DEBUG_ECHOLNPAIR(" final workDir = ", hex_address((void*)diveDir)); + workDir = *inDirPtr; + DEBUG_ECHOLNPAIR(" final workDir = ", hex_address((void*)inDirPtr)); flag.workDirIsRoot = (workDirDepth == 0); TERN_(SDCARD_SORT_ALPHA, presort()); } - DEBUG_ECHOLNPAIR(" returning string ", item_name_adr ?: "nullptr"); - return item_name_adr; + DEBUG_ECHOLNPAIR(" returning string ", atom_ptr ?: "nullptr"); + return atom_ptr; } void CardReader::cd(const char * relpath) { - SdFile newDir; - SdFile *parent = workDir.isOpen() ? &workDir : &root; + SdFile newDir, *parent = &getWorkDir(); if (newDir.open(parent, relpath, O_READ)) { workDir = newDir; diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 6f1633d30ebc..35d762742164 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -111,7 +111,6 @@ class CardReader { static void mount(); static void release(); static inline bool isMounted() { return flag.mounted; } - static void ls(); // Handle media insert/remove static void manage_media(); @@ -176,21 +175,32 @@ class CardReader { return 0; } - // Helper for open and remove - static const char* diveToFile(const bool update_cwd, SdFile* &curDir, const char * const path, const bool echo=false); + /** + * Dive down to a relative or absolute path. + * Relative paths apply to the workDir. + * + * update_cwd: Pass 'true' to update the workDir on success. + * inDirPtr: On exit your pointer points to the target SdFile. + * A nullptr indicates failure. + * path: Start with '/' for abs path. End with '/' to get a folder ref. + * echo: Set 'true' to print the path throughout the loop. + */ + static const char* diveToFile(const bool update_cwd, SdFile* &inDirPtr, const char * const path, const bool echo=false); #if ENABLED(SDCARD_SORT_ALPHA) static void presort(); static void getfilename_sorted(const uint16_t nr); #if ENABLED(SDSORT_GCODE) - FORCE_INLINE static void setSortOn(bool b) { sort_alpha = b; presort(); } - FORCE_INLINE static void setSortFolders(int i) { sort_folders = i; presort(); } + FORCE_INLINE static void setSortOn(bool b) { sort_alpha = b; presort(); } + FORCE_INLINE static void setSortFolders(int i) { sort_folders = i; presort(); } //FORCE_INLINE static void setSortReverse(bool b) { sort_reverse = b; } #endif #else FORCE_INLINE static void getfilename_sorted(const uint16_t nr) { selectFileByIndex(nr); } #endif + static void ls(); + #if ENABLED(POWER_LOSS_RECOVERY) static bool jobRecoverFileExists(); static void openJobRecoveryFile(const bool read); @@ -199,6 +209,7 @@ class CardReader { // Current Working Dir - Set by cd, cdup, cdroot, and diveToFile(true, ...) static inline char* getWorkDirName() { workDir.getDosName(filename); return filename; } + static inline SdFile& getWorkDir() { return workDir.isOpen() ? workDir : root; } // Print File stats static inline uint32_t getFileSize() { return filesize; } From 8af4d70922cede7b3e7a6720959c4e2c2d807012 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 21 May 2021 22:55:13 -0500 Subject: [PATCH 31/61] =?UTF-8?q?=F0=9F=8E=A8=20Shorten=20lcd=20relative?= =?UTF-8?q?=20paths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/extui/mks_ui/wifi_module.cpp | 3 ++- Marlin/src/lcd/menu/menu_delta_calibrate.cpp | 2 +- Marlin/src/lcd/menu/menu_main.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp index a9ad9c189c4a..52a877031f83 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp @@ -28,11 +28,12 @@ #include "wifi_upload.h" #include "SPI_TFT.h" +#include "../../marlinui.h" + #include "../../../MarlinCore.h" #include "../../../module/temperature.h" #include "../../../gcode/queue.h" #include "../../../gcode/gcode.h" -#include "../../../lcd/marlinui.h" #include "../../../sd/cardreader.h" #include "../../../module/planner.h" #include "../../../module/servo.h" diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index b857b62de536..195afecc1b74 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -37,7 +37,7 @@ #endif #if ENABLED(EXTENSIBLE_UI) - #include "../../lcd/extui/ui_api.h" + #include "../extui/ui_api.h" #endif void _man_probe_pt(const xy_pos_t &xy) { diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 17c9b1fe6a44..921c2435b58a 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -47,7 +47,7 @@ #endif #if ENABLED(MMU2_MENUS) - #include "../../lcd/menu/menu_mmu2.h" + #include "menu_mmu2.h" #endif #if ENABLED(PASSWORD_FEATURE) From 464a9f0ab6adf51bd988936cf6284488c4e797cd Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 21 May 2021 23:03:49 -0500 Subject: [PATCH 32/61] =?UTF-8?q?=F0=9F=93=9D=20Update=20ExtUI=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/extui/example/example.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Marlin/src/lcd/extui/example/example.cpp b/Marlin/src/lcd/extui/example/example.cpp index 959d75087250..0e7d71ff4da4 100644 --- a/Marlin/src/lcd/extui/example/example.cpp +++ b/Marlin/src/lcd/extui/example/example.cpp @@ -119,6 +119,12 @@ namespace ExtUI { #if HAS_PID_HEATING void onPidTuning(const result_t rst) { // Called for temperature PID tuning result + switch (rst) { + case PID_BAD_EXTRUDER_NUM: break; + case PID_TEMP_TOO_HIGH: break; + case PID_TUNING_TIMEOUT: break; + case PID_DONE: break; + } } #endif From 7c2834c33c488accb0a937e1bacf320889379e1d Mon Sep 17 00:00:00 2001 From: Alvaro Segura Del Barco Date: Sat, 22 May 2021 14:52:41 -0600 Subject: [PATCH 33/61] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Teensy=20PINS=5FDEBU?= =?UTF-8?q?G=20compile=20(#21958)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to 84a11cfedc --- Marlin/src/HAL/AVR/pinsDebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/HAL/AVR/pinsDebug.h b/Marlin/src/HAL/AVR/pinsDebug.h index 6bf9f33a0ce5..55fddb05b862 100644 --- a/Marlin/src/HAL/AVR/pinsDebug.h +++ b/Marlin/src/HAL/AVR/pinsDebug.h @@ -38,7 +38,7 @@ // portModeRegister takes a different argument #define digitalPinToTimer_DEBUG(p) digitalPinToTimer(p) #define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask(p) - #define digitalPinToPort_DEBUG(p) digitalPinToPort_Teensy(p) + #define digitalPinToPort_DEBUG(p) digitalPinToPort(p) #define GET_PINMODE(pin) (*portModeRegister(pin) & digitalPinToBitMask_DEBUG(pin)) #elif AVR_ATmega2560_FAMILY_PLUS_70 // So we can access/display all the pins on boards using more than 70 From 43b736906ae4895b9dca37784743b0b9ea3740a3 Mon Sep 17 00:00:00 2001 From: Danol Date: Sun, 23 May 2021 00:35:07 +0200 Subject: [PATCH 34/61] =?UTF-8?q?=F0=9F=90=9B=20Fix=20wrong=20Z=5FENDSTOP?= =?UTF-8?q?=20flag=20bit=20(#21963)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug introduced in #18424 --- Marlin/src/module/endstops.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index acd241d43217..c3819417e5d8 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -64,7 +64,7 @@ enum EndstopEnum : char { #define X_ENDSTOP TERN(X_HOME_TO_MAX, X_MAX, X_MIN) #define Y_ENDSTOP TERN(Y_HOME_TO_MAX, Y_MAX, Y_MIN) -#define Z_ENDSTOP TERN(Z_HOME_TO_MAX, Z_MAX, TERN(HOMING_Z_WITH_PROBE, Z_MIN, Z_MIN_PROBE)) +#define Z_ENDSTOP TERN(Z_HOME_TO_MAX, Z_MAX, TERN(HOMING_Z_WITH_PROBE, Z_MIN_PROBE, Z_MIN)) #undef __ES_ITEM #undef _ES_ITEM From 6689e5ed75b5a777273ae3e6a82617349a76e833 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 22 May 2021 17:41:29 -0500 Subject: [PATCH 35/61] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Selena=20Compact=20p?= =?UTF-8?q?robe=20pin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h b/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h index 29fe3b528c08..78cf7a84fc3a 100644 --- a/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h +++ b/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h @@ -44,7 +44,9 @@ #define Y_MAX_PIN -1 #define Z_MIN_PIN P1_27 #define Z_MAX_PIN -1 -#define Z_PROBE P1_22 +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN P1_22 +#endif // // Steppers @@ -95,22 +97,22 @@ // #if IS_RRD_FG_SC - #define LCD_PINS_RS P0_16 - #define LCD_PINS_ENABLE P0_18 - #define LCD_PINS_D4 P0_15 - #define LCD_PINS_D5 P1_00 - #define LCD_PINS_D6 P1_01 - #define LCD_PINS_D7 P1_04 - #define BEEPER_PIN P1_31 - - #define BTN_EN1 P3_25 - #define BTN_EN2 P3_26 - #define BTN_ENC P1_30 - - #define SD_DETECT_PIN -1 - - #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) - #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder - #endif + #define LCD_PINS_RS P0_16 + #define LCD_PINS_ENABLE P0_18 + #define LCD_PINS_D4 P0_15 + #define LCD_PINS_D5 P1_00 + #define LCD_PINS_D6 P1_01 + #define LCD_PINS_D7 P1_04 + #define BEEPER_PIN P1_31 + + #define BTN_EN1 P3_25 + #define BTN_EN2 P3_26 + #define BTN_ENC P1_30 + + #define SD_DETECT_PIN -1 + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif #endif // IS_RRD_FG_SC From aee971bcaf2d8b7157985f36f6705015ef334238 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 22 May 2021 17:02:21 -0500 Subject: [PATCH 36/61] =?UTF-8?q?=F0=9F=8E=A8=20Combine=20M104/M109=20and?= =?UTF-8?q?=20M140/M190=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/gcode.h | 10 ++-- Marlin/src/gcode/temp/M104_M109.cpp | 78 ++++------------------------- Marlin/src/gcode/temp/M140_M190.cpp | 57 +++++---------------- 3 files changed, 27 insertions(+), 118 deletions(-) diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index c32575e81ee4..6f8568730b49 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -648,8 +648,9 @@ class GcodeSuite { #endif #if HAS_EXTRUDERS - static void M104(); - static void M109(); + static void M104_M109(const bool isM109); + FORCE_INLINE static void M104() { M104_M109(false); } + FORCE_INLINE static void M109() { M104_M109(true); } #endif static void M105(); @@ -699,8 +700,9 @@ class GcodeSuite { #endif #if HAS_HEATED_BED - static void M140(); - static void M190(); + static void M140_M190(const bool isM190); + FORCE_INLINE static void M140() { M140_M190(false); } + FORCE_INLINE static void M190() { M140_M190(true); } #endif #if HAS_HEATED_CHAMBER diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index eb350a577afc..b6a3fa850716 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -51,89 +51,29 @@ /** * M104: Set Hotend Temperature target and return immediately - * - * Parameters: - * I : Material Preset index (if material presets are defined) - * T : Tool index. If omitted, applies to the active tool - * S : The target temperature in current units - */ -void GcodeSuite::M104() { - - if (DEBUGGING(DRYRUN)) return; - - #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1 - constexpr int8_t target_extruder = 0; - #else - const int8_t target_extruder = get_target_extruder_from_command(); - if (target_extruder < 0) return; - #endif - - bool got_temp = false; - celsius_t temp = 0; - - // Accept 'I' if temperature presets are defined - #if PREHEAT_COUNT - got_temp = parser.seenval('I'); - if (got_temp) { - const uint8_t index = parser.value_byte(); - temp = ui.material_preset[_MIN(index, PREHEAT_COUNT - 1)].hotend_temp; - } - #endif - - // If no 'I' get the temperature from 'S' - if (!got_temp) { - got_temp = parser.seenval('S'); - if (got_temp) temp = parser.value_celsius(); - } - - if (got_temp) { - #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) - thermalManager.singlenozzle_temp[target_extruder] = temp; - if (target_extruder != active_extruder) return; - #endif - thermalManager.setTargetHotend(temp, target_extruder); - - #if ENABLED(DUAL_X_CARRIAGE) - if (idex_is_duplicating() && target_extruder == 0) - thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1); - #endif - - #if ENABLED(PRINTJOB_TIMER_AUTOSTART) - /** - * Stop the timer at the end of print. Start is managed by 'heat and wait' M109. - * Hotends use EXTRUDE_MINTEMP / 2 to allow nozzles to be put into hot standby - * mode, for instance in a dual extruder setup, without affecting the running - * print timer. - */ - thermalManager.auto_job_check_timer(false, true); - #endif - } - - TERN_(AUTOTEMP, planner.autotemp_M104_M109()); -} - -/** * M109: Set Hotend Temperature target and wait * * Parameters * I : Material Preset index (if material presets are defined) * T : Tool index. If omitted, applies to the active tool - * S : The target temperature in current units. Wait for heating only. - * R : The target temperature in current units. Wait for heating and cooling. + * S : The target temperature in current units. For M109, only wait when heating up. * * With AUTOTEMP... * F : Autotemp Scaling Factor. Set non-zero to enable Auto-temp. * S : Minimum temperature, in current units. * B : Maximum temperature, in current units. * + * M109 Parameters + * R : The target temperature in current units. Wait for heating and cooling. + * * Examples - * M109 S100 : Set target to 100°. Wait until the hotend is at or above 100°. + * M104 S100 : Set target to 100° and return. * M109 R150 : Set target to 150°. Wait until the hotend gets close to 150°. * * With PRINTJOB_TIMER_AUTOSTART turning on heaters will start the print job timer * (used by printingIsActive, etc.) and turning off heaters will stop the timer. */ -void GcodeSuite::M109() { +void GcodeSuite::M104_M109(const bool isM109) { if (DEBUGGING(DRYRUN)) return; @@ -160,7 +100,7 @@ void GcodeSuite::M109() { bool no_wait_for_cooling = false; if (!got_temp) { no_wait_for_cooling = parser.seenval('S'); - got_temp = no_wait_for_cooling || parser.seenval('R'); + got_temp = no_wait_for_cooling || (isM109 && parser.seenval('R')); if (got_temp) temp = parser.value_celsius(); } @@ -182,7 +122,7 @@ void GcodeSuite::M109() { * standby mode, (e.g., in a dual extruder setup) without affecting * the running print timer. */ - thermalManager.auto_job_check_timer(true, true); + thermalManager.auto_job_check_timer(isM109, true); #endif #if HAS_STATUS_MESSAGE @@ -193,7 +133,7 @@ void GcodeSuite::M109() { TERN_(AUTOTEMP, planner.autotemp_M104_M109()); - if (got_temp) + if (isM109 && got_temp) (void)thermalManager.wait_for_hotend(target_extruder, no_wait_for_cooling); } diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index 3aed878a0385..ddab003973a0 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -35,62 +35,28 @@ #include "../../lcd/marlinui.h" /** - * M140: Set bed temperature + * M140 - Set Bed Temperature target and return immediately + * M190 - Set Bed Temperature target and wait * * I : Preset index (if material presets are defined) * S : The target temperature in current units - */ -void GcodeSuite::M140() { - if (DEBUGGING(DRYRUN)) return; - - bool got_temp = false; - celsius_t temp = 0; - - // Accept 'I' if temperature presets are defined - #if PREHEAT_COUNT - got_temp = parser.seenval('I'); - if (got_temp) { - const uint8_t index = parser.value_byte(); - temp = ui.material_preset[_MIN(index, PREHEAT_COUNT - 1)].bed_temp; - } - #endif - - // If no 'I' get the temperature from 'S' - if (!got_temp) { - got_temp = parser.seenval('S'); - if (got_temp) temp = parser.value_celsius(); - } - - if (got_temp) { - thermalManager.setTargetBed(temp); - - #if ENABLED(PRINTJOB_TIMER_AUTOSTART) - /** - * Stop the timer at the end of print. Hotend, bed target, and chamber - * temperatures need to be set below mintemp. Order of M140, M104, and M141 - * at the end of the print does not matter. - */ - thermalManager.auto_job_check_timer(false, true); - #endif - } -} - -/** - * M190 - Set Bed Temperature target and wait * - * Parameters: + * Parameters * I : Preset index (if material presets are defined) * S : The target temperature in current units. Wait for heating only. + * + * M190 Parameters * R : The target temperature in current units. Wait for heating and cooling. * - * Examples: - * M190 S60 : Set target to 60°. Wait until the bed is at or above 60°. + * Examples + * M140 S60 : Set target to 60° and return right away. * M190 R40 : Set target to 40°. Wait until the bed gets close to 40°. * * With PRINTJOB_TIMER_AUTOSTART turning on heaters will start the print job timer * (used by printingIsActive, etc.) and turning off heaters will stop the timer. */ -void GcodeSuite::M190() { +void GcodeSuite::M140_M190(const bool isM190) { + if (DEBUGGING(DRYRUN)) return; bool got_temp = false; @@ -109,7 +75,7 @@ void GcodeSuite::M190() { bool no_wait_for_cooling = false; if (!got_temp) { no_wait_for_cooling = parser.seenval('S'); - got_temp = no_wait_for_cooling || parser.seenval('R'); + got_temp = no_wait_for_cooling || (isM190 && parser.seenval('R')); if (got_temp) temp = parser.value_celsius(); } @@ -121,7 +87,8 @@ void GcodeSuite::M190() { ui.set_status_P(thermalManager.isHeatingBed() ? GET_TEXT(MSG_BED_HEATING) : GET_TEXT(MSG_BED_COOLING)); - thermalManager.wait_for_bed(no_wait_for_cooling); + if (isM190) + thermalManager.wait_for_bed(no_wait_for_cooling); } #endif // HAS_HEATED_BED From d8c4be375c24f0cda27ff8079b78985e5b8afa97 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 22 May 2021 17:56:31 -0500 Subject: [PATCH 37/61] =?UTF-8?q?=F0=9F=8E=A8=20Null=20heating=20message?= =?UTF-8?q?=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/temp/M104_M109.cpp | 6 ++---- Marlin/src/module/temperature.cpp | 2 +- Marlin/src/module/temperature.h | 4 +++- Marlin/src/module/tool_change.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index b6a3fa850716..efda04def50a 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -125,10 +125,8 @@ void GcodeSuite::M104_M109(const bool isM109) { thermalManager.auto_job_check_timer(isM109, true); #endif - #if HAS_STATUS_MESSAGE - if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling) - thermalManager.set_heating_message(target_extruder); - #endif + if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling) + thermalManager.set_heating_message(target_extruder); } TERN_(AUTOTEMP, planner.autotemp_M104_M109()); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 03c0195085f1..f9ff9e5fa6ab 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2526,7 +2526,7 @@ void Temperature::disable_all_heaters() { if (singlenozzle_temp[new_tool] && singlenozzle_temp[new_tool] != singlenozzle_temp[old_tool]) { setTargetHotend(singlenozzle_temp[new_tool], 0); TERN_(AUTOTEMP, planner.autotemp_update()); - TERN_(HAS_STATUS_MESSAGE, set_heating_message(0)); + set_heating_message(0); (void)wait_for_hotend(0, false); // Wait for heating or cooling } #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 83fbc8fd465d..2fd2b639ec8d 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -869,8 +869,10 @@ class Temperature { #endif #endif - #if HAS_STATUS_MESSAGE + #if HAS_HOTEND && HAS_STATUS_MESSAGE static void set_heating_message(const uint8_t e); + #else + static inline void set_heating_message(const uint8_t) {} #endif #if HAS_LCD_MENU && HAS_TEMPERATURE diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index cc34acc14f12..3abab802aba4 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1382,7 +1382,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #if HAS_MULTI_HOTEND thermalManager.setTargetHotend(thermalManager.degTargetHotend(active_extruder), migration_extruder); TERN_(AUTOTEMP, planner.autotemp_update()); - TERN_(HAS_STATUS_MESSAGE, thermalManager.set_heating_message(0)); + thermalManager.set_heating_message(0); thermalManager.wait_for_hotend(active_extruder); #endif From e1921f808cf4d2a392a9c033d3182773d5292b12 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 23 May 2021 01:15:23 +0000 Subject: [PATCH 38/61] [cron] Bump distribution date (2021-05-23) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index e78166461b39..163b9284cc36 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-05-22" + #define STRING_DISTRIBUTION_DATE "2021-05-23" #endif /** From 92dea8e6ccd26950eed817fce6f574fcfe866489 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 May 2021 01:09:46 -0500 Subject: [PATCH 39/61] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor,=20comment?= =?UTF-8?q?=20endstop/probe=20enums?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/menu/menu_bed_corners.cpp | 2 +- Marlin/src/module/endstops.cpp | 9 +++++++++ Marlin/src/module/endstops.h | 24 +++++++++++++++++++----- Marlin/src/module/probe.cpp | 2 +- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index d28ef1182e86..0ab82a9b1600 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -225,7 +225,7 @@ static void _lcd_level_bed_corners_get_next_position() { if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed TERN_(BLTOUCH_SLOW_MODE, bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action do_blocking_move_to_z(last_z - LEVEL_CORNERS_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance - if (TEST(endstops.trigger_state(), TERN(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, Z_MIN, Z_MIN_PROBE))) { // check if probe triggered + if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered endstops.hit_on_purpose(); set_current_from_steppers_for_axis(Z_AXIS); sync_plan_position(); diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 7a452f1fdddd..dff0b6832a3f 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -403,12 +403,21 @@ void Endstops::event_handler() { } } +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + static void print_es_state(const bool is_hit, PGM_P const label=nullptr) { if (label) SERIAL_ECHOPGM_P(label); SERIAL_ECHOPGM(": "); SERIAL_ECHOLNPGM_P(is_hit ? PSTR(STR_ENDSTOP_HIT) : PSTR(STR_ENDSTOP_OPEN)); } +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic pop +#endif + void _O2 Endstops::report_states() { TERN_(BLTOUCH, bltouch._set_SW_mode()); SERIAL_ECHOLNPGM(STR_M119_REPORT); diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index c3819417e5d8..5da09f41cf51 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -32,12 +32,15 @@ #define _ES_ITEM(K,N) TERN_(K,DEFER4(__ES_ITEM)(N)) enum EndstopEnum : char { + // Common XYZ (ABC) endstops. Defined according to USE_[XYZ](MIN|MAX)_PLUG settings. _ES_ITEM(HAS_X_MIN, X_MIN) _ES_ITEM(HAS_X_MAX, X_MAX) _ES_ITEM(HAS_Y_MIN, Y_MIN) _ES_ITEM(HAS_Y_MAX, Y_MAX) _ES_ITEM(HAS_Z_MIN, Z_MIN) _ES_ITEM(HAS_Z_MAX, Z_MAX) + + // Extra Endstops for XYZ #if ENABLED(X_DUAL_ENDSTOPS) _ES_ITEM(HAS_X_MIN, X2_MIN) _ES_ITEM(HAS_X_MAX, X2_MAX) @@ -58,13 +61,24 @@ enum EndstopEnum : char { _ES_ITEM(HAS_Z_MAX, Z4_MAX) #endif #endif - _ES_ITEM(HAS_Z_MIN_PROBE_PIN, Z_MIN_PROBE) + + // Bed Probe state is distinct or shared with Z_MIN (i.e., when the probe is the only Z endstop) + _ES_ITEM(HAS_BED_PROBE, Z_MIN_PROBE IF_DISABLED(HAS_CUSTOM_PROBE_PIN, = Z_MIN)) + + // The total number of states NUM_ENDSTOP_STATES -}; -#define X_ENDSTOP TERN(X_HOME_TO_MAX, X_MAX, X_MIN) -#define Y_ENDSTOP TERN(Y_HOME_TO_MAX, Y_MAX, Y_MIN) -#define Z_ENDSTOP TERN(Z_HOME_TO_MAX, Z_MAX, TERN(HOMING_Z_WITH_PROBE, Z_MIN_PROBE, Z_MIN)) + // Endstops can be either MIN or MAX but not both + #if HAS_X_MIN || HAS_X_MAX + , X_ENDSTOP = TERN(X_HOME_TO_MAX, X_MAX, X_MIN) + #endif + #if HAS_Y_MIN || HAS_Y_MAX + , Y_ENDSTOP = TERN(Y_HOME_TO_MAX, Y_MAX, Y_MIN) + #endif + #if HAS_Z_MIN || HAS_Z_MAX + , Z_ENDSTOP = TERN(Z_HOME_TO_MAX, Z_MAX, TERN(HOMING_Z_WITH_PROBE, Z_MIN_PROBE, Z_MIN)) + #endif +}; #undef __ES_ITEM #undef _ES_ITEM diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 655b8cc2495e..6d4a0228820a 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -509,7 +509,7 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { #if BOTH(DELTA, SENSORLESS_PROBING) endstops.trigger_state() & (_BV(X_MAX) | _BV(Y_MAX) | _BV(Z_MAX)) #else - TEST(endstops.trigger_state(), TERN(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, Z_MIN, Z_MIN_PROBE)) + TEST(endstops.trigger_state(), Z_MIN_PROBE) #endif ; From ff0318c5bd95c6cb18ae9765f1ecb344dc2d6e4e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 22 May 2021 21:08:57 -0500 Subject: [PATCH 40/61] =?UTF-8?q?=F0=9F=8E=A8=20pause=20=3D>=20pause=5Fhea?= =?UTF-8?q?ters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/probe.cpp | 2 +- Marlin/src/module/temperature.cpp | 4 ++-- Marlin/src/module/temperature.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 6d4a0228820a..0042302fc790 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -243,7 +243,7 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() #endif void Probe::set_probing_paused(const bool dopause) { - TERN_(PROBING_HEATERS_OFF, thermalManager.pause(dopause)); + TERN_(PROBING_HEATERS_OFF, thermalManager.pause_heaters(dopause)); TERN_(PROBING_FANS_OFF, thermalManager.set_fans_paused(dopause)); #if ENABLED(PROBING_STEPPERS_OFF) IF_DISABLED(DELTA, static uint8_t old_trusted); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index f9ff9e5fa6ab..898ffa7d5f7a 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2439,7 +2439,7 @@ void Temperature::disable_all_heaters() { TERN_(AUTOTEMP, planner.autotemp_enabled = false); // Unpause and reset everything - TERN_(PROBING_HEATERS_OFF, pause(false)); + TERN_(PROBING_HEATERS_OFF, pause_heaters(false)); #if HAS_HOTEND HOTEND_LOOP() { @@ -2498,7 +2498,7 @@ void Temperature::disable_all_heaters() { #if ENABLED(PROBING_HEATERS_OFF) - void Temperature::pause(const bool p) { + void Temperature::pause_heaters(const bool p) { if (p != paused_for_probing) { paused_for_probing = p; if (p) { diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 2fd2b639ec8d..a80e39cbd879 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -838,7 +838,7 @@ class Temperature { #endif #if ENABLED(PROBING_HEATERS_OFF) - static void pause(const bool p); + static void pause_heaters(const bool p); #endif #if HEATER_IDLE_HANDLER From d71b35c24f5e8d4c40d5e721f3548abfe899592d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 22 May 2021 21:12:53 -0500 Subject: [PATCH 41/61] =?UTF-8?q?=F0=9F=8E=A8=20Apply=20shorthand=20and=20?= =?UTF-8?q?cleanups?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/caselight.cpp | 8 ++------ Marlin/src/feature/dac/stepper_dac.cpp | 2 +- Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/libs/L64XX/L64XX_Marlin.cpp | 21 +++------------------ Marlin/src/module/planner.h | 6 +++--- 5 files changed, 10 insertions(+), 29 deletions(-) diff --git a/Marlin/src/feature/caselight.cpp b/Marlin/src/feature/caselight.cpp index fb0f6e3bee47..5a4e2b2579dd 100644 --- a/Marlin/src/feature/caselight.cpp +++ b/Marlin/src/feature/caselight.cpp @@ -44,10 +44,6 @@ bool CaseLight::on = CASE_LIGHT_DEFAULT_ON; LEDColor CaseLight::color = { init_case_light[0], init_case_light[1], init_case_light[2], TERN_(HAS_WHITE_LED, init_case_light[3]) }; #endif -#ifndef INVERT_CASE_LIGHT - #define INVERT_CASE_LIGHT false -#endif - void CaseLight::update(const bool sflag) { #if CASELIGHT_USES_BRIGHTNESS /** @@ -64,7 +60,7 @@ void CaseLight::update(const bool sflag) { if (sflag && on) brightness = brightness_sav; // Restore last brightness for M355 S1 - const uint8_t i = on ? brightness : 0, n10ct = INVERT_CASE_LIGHT ? 255 - i : i; + const uint8_t i = on ? brightness : 0, n10ct = ENABLED(INVERT_CASE_LIGHT) ? 255 - i : i; UNUSED(n10ct); #endif @@ -86,7 +82,7 @@ void CaseLight::update(const bool sflag) { else #endif { - const bool s = on ? !INVERT_CASE_LIGHT : INVERT_CASE_LIGHT; + const bool s = on ? TERN(INVERT_CASE_LIGHT, LOW, HIGH) : TERN(INVERT_CASE_LIGHT, HIGH, LOW); WRITE(CASE_LIGHT_PIN, s ? HIGH : LOW); } diff --git a/Marlin/src/feature/dac/stepper_dac.cpp b/Marlin/src/feature/dac/stepper_dac.cpp index bb7954cfe05f..1cb0813daa6c 100644 --- a/Marlin/src/feature/dac/stepper_dac.cpp +++ b/Marlin/src/feature/dac/stepper_dac.cpp @@ -51,7 +51,7 @@ int StepperDAC::init() { mcp4728.setVref_all(DAC_STEPPER_VREF); mcp4728.setGain_all(DAC_STEPPER_GAIN); - if (mcp4728.getDrvPct(0) < 1 || mcp4728.getDrvPct(1) < 1 || mcp4728.getDrvPct(2) < 1 || mcp4728.getDrvPct(3) < 1 ) { + if (mcp4728.getDrvPct(0) < 1 || mcp4728.getDrvPct(1) < 1 || mcp4728.getDrvPct(2) < 1 || mcp4728.getDrvPct(3) < 1) { mcp4728.setDrvPct(dac_channel_pct); mcp4728.eepromWrite(); } diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 30151b3bd0cb..fa4682c0823f 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -566,7 +566,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { #endif #if ENABLED(AUTO_REPORT_POSITION) - case 154: M154(); break; // M155: Set position auto-report interval + case 154: M154(); break; // M154: Set position auto-report interval #endif #if BOTH(AUTO_REPORT_TEMPERATURES, HAS_TEMP_SENSOR) diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp index 45c947e7904e..a6aed2ad24fb 100644 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp +++ b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp @@ -445,12 +445,7 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in position_min = X_center - displacement; position_max = X_center + displacement; echo_min_max('X', position_min, position_max); - if (false - #if HAS_ENDSTOPS - || position_min < (X_MIN_POS) - || position_max > (X_MAX_POS) - #endif - ) { + if (TERN0(HAS_ENDSTOPS, position_min < (X_MIN_POS) || position_max > (X_MAX_POS))) { err_out_of_bounds(); return true; } @@ -460,12 +455,7 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in position_min = Y_center - displacement; position_max = Y_center + displacement; echo_min_max('Y', position_min, position_max); - if (false - #if HAS_ENDSTOPS - || position_min < (Y_MIN_POS) - || position_max > (Y_MAX_POS) - #endif - ) { + if (TERN0(HAS_ENDSTOPS, position_min < (Y_MIN_POS) || position_max > (Y_MAX_POS))) { err_out_of_bounds(); return true; } @@ -475,12 +465,7 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in position_min = Z_center - displacement; position_max = Z_center + displacement; echo_min_max('Z', position_min, position_max); - if (false - #if HAS_ENDSTOPS - || position_min < (Z_MIN_POS) - || position_max > (Z_MAX_POS) - #endif - ) { + if (TERN0(HAS_ENDSTOPS, position_min < (Z_MIN_POS) || position_max > (Z_MAX_POS))) { err_out_of_bounds(); return true; } diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 2ec90e1fa239..66e98f4a5704 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -491,7 +491,7 @@ class Planner { #if HAS_CLASSIC_JERK static void set_max_jerk(const AxisEnum axis, float inMaxJerkMMS); #else - static inline void set_max_jerk(const AxisEnum, const_float_t ) {} + static inline void set_max_jerk(const AxisEnum, const_float_t) {} #endif #if HAS_EXTRUDERS @@ -592,9 +592,9 @@ class Planner { #else - FORCE_INLINE static float fade_scaling_factor_for_z(const_float_t ) { return 1; } + FORCE_INLINE static float fade_scaling_factor_for_z(const_float_t) { return 1; } - FORCE_INLINE static bool leveling_active_at_z(const_float_t ) { return true; } + FORCE_INLINE static bool leveling_active_at_z(const_float_t) { return true; } #endif From 5fde86406fdcf4c9ea21f81c4a834de39dadb3bb Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 24 May 2021 01:12:27 +0000 Subject: [PATCH 42/61] [cron] Bump distribution date (2021-05-24) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 163b9284cc36..3690ea2c92f7 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-05-23" + #define STRING_DISTRIBUTION_DATE "2021-05-24" #endif /** From 731370051de73ad4c92d60ec01563def3da53ddb Mon Sep 17 00:00:00 2001 From: ellensp Date: Mon, 24 May 2021 13:29:19 +1200 Subject: [PATCH 43/61] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20PIO=20filters=20for?= =?UTF-8?q?=20M117,=20M300=20and=20M414=20(#21972)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/gcode.cpp | 4 +++- Marlin/src/gcode/gcode.h | 6 +++++- Marlin/src/gcode/lcd/M117.cpp | 6 ++++++ ini/features.ini | 4 +++- platformio.ini | 3 +++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index fa4682c0823f..29dbf8d1c2dd 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -605,7 +605,9 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 92: M92(); break; // M92: Set the steps-per-unit for one or more axes case 114: M114(); break; // M114: Report current position case 115: M115(); break; // M115: Report capabilities - case 117: M117(); break; // M117: Set LCD message text, if possible + + case 117: TERN_(HAS_STATUS_MESSAGE, M117()); break; // M117: Set LCD message text, if possible + case 118: M118(); break; // M118: Display a message in the host console case 119: M119(); break; // M119: Report endstop states case 120: M120(); break; // M120: Enable endstops diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 6f8568730b49..befc328bb974 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -678,7 +678,11 @@ class GcodeSuite { static void M114(); static void M115(); - static void M117(); + + #if HAS_STATUS_MESSAGE + static void M117(); + #endif + static void M118(); static void M119(); static void M120(); diff --git a/Marlin/src/gcode/lcd/M117.cpp b/Marlin/src/gcode/lcd/M117.cpp index 59305d94c5b5..f26694bd6463 100644 --- a/Marlin/src/gcode/lcd/M117.cpp +++ b/Marlin/src/gcode/lcd/M117.cpp @@ -20,6 +20,10 @@ * */ +#include "../../inc/MarlinConfig.h" + +#if HAS_STATUS_MESSAGE + #include "../gcode.h" #include "../../lcd/marlinui.h" @@ -34,3 +38,5 @@ void GcodeSuite::M117() { ui.reset_status(); } + +#endif // HAS_STATUS_MESSAGE diff --git a/ini/features.ini b/ini/features.ini index 2b69daa88aeb..89df3b99fe07 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -61,7 +61,7 @@ HAS_MENU_DELTA_CALIBRATE = src_filter=+ LCD_INFO_MENU = src_filter=+ HAS_MENU_JOB_RECOVERY = src_filter=+ -HAS_MULTI_LANGUAGE = src_filter=+ +HAS_MULTI_LANGUAGE = src_filter=+ + HAS_MENU_LED = src_filter=+ HAS_MENU_MEDIA = src_filter=+ HAS_MENU_MIXER = src_filter=+ @@ -186,7 +186,9 @@ AUTO_REPORT_POSITION = src_filter=+ REPETIER_GCODE_M360 = src_filter=+ HAS_GCODE_M876 = src_filter=+ HAS_RESUME_CONTINUE = src_filter=+ +HAS_STATUS_MESSAGE = src_filter=+ HAS_LCD_CONTRAST = src_filter=+ +HAS_BUZZER = src_filter=+ LCD_SET_PROGRESS_MANUALLY = src_filter=+ TOUCH_SCREEN_CALIBRATION = src_filter=+ ARC_SUPPORT = src_filter=+ diff --git a/platformio.ini b/platformio.ini index 0516149da9a5..b552eda81dc6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -202,7 +202,10 @@ default_src_filter = + - - + - - - + - - + - + - - - - From 84fd0eff17d089e3f75f6585d4bba47f15c00ba7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 May 2021 21:33:22 -0500 Subject: [PATCH 44/61] =?UTF-8?q?=F0=9F=8E=A8=20Macros=20for=20optional=20?= =?UTF-8?q?arguments=20(#21969)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/macros.h | 5 ++ .../feature/bedlevel/mbl/mesh_bed_leveling.h | 4 +- .../src/feature/bedlevel/ubl/ubl_motion.cpp | 8 +- Marlin/src/feature/caselight.cpp | 2 +- Marlin/src/feature/fwretract.cpp | 6 +- Marlin/src/feature/fwretract.h | 6 +- Marlin/src/feature/leds/leds.cpp | 4 +- Marlin/src/feature/leds/leds.h | 71 ++++------------- Marlin/src/feature/leds/pca9632.cpp | 8 +- Marlin/src/feature/tmc_util.h | 12 +-- Marlin/src/gcode/bedlevel/G26.cpp | 15 +--- Marlin/src/gcode/motion/G2_G3.cpp | 8 +- Marlin/src/gcode/queue.cpp | 8 +- Marlin/src/gcode/queue.h | 8 +- Marlin/src/lcd/marlinui.cpp | 8 +- Marlin/src/lcd/marlinui.h | 6 +- Marlin/src/lcd/menu/menu_motion.cpp | 12 +-- Marlin/src/lcd/tft/ui_1024x600.cpp | 6 +- Marlin/src/lcd/tft/ui_320x240.cpp | 6 +- Marlin/src/lcd/tft/ui_480x320.cpp | 6 +- Marlin/src/module/motion.cpp | 26 ++----- Marlin/src/module/motion.h | 6 +- Marlin/src/module/planner.cpp | 24 ++---- Marlin/src/module/planner.h | 43 +++-------- Marlin/src/module/temperature.cpp | 77 ++++--------------- Marlin/src/module/temperature.h | 71 +++++++---------- .../sd/usb_flashdrive/lib-uhs2/masstorage.cpp | 10 +-- .../sd/usb_flashdrive/lib-uhs2/masstorage.h | 5 +- 28 files changed, 120 insertions(+), 351 deletions(-) diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 566087b76b2e..7a2d731c01df 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -195,6 +195,11 @@ #define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1' #define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B. +#define _OPTARG(A) , A +#define OPTARG(O,A) TERN_(O,DEFER4(_OPTARG)(A)) +#define _OPTCODE(A) A; +#define OPTCODE(O,A) TERN_(O,DEFER4(_OPTCODE)(A)) + // Macros to avoid 'f + 0.0' which is not always optimized away. Minus included for symmetry. // Compiler flags -fno-signed-zeros -ffinite-math-only also cover 'f * 1.0', 'f - f', etc. #define PLUS_TERN0(O,A) _TERN(_ENA_1(O),,+ (A)) // OPTION ? '+ (A)' : '' diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h index 1ae8135458f3..cc5469577189 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h @@ -103,9 +103,7 @@ class mesh_bed_leveling { } static float get_z(const xy_pos_t &pos - #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - , const_float_t factor=1.0f - #endif + OPTARG(ENABLE_LEVELING_FADE_HEIGHT, const_float_t factor=1.0f) ) { #if DISABLED(ENABLE_LEVELING_FADE_HEIGHT) constexpr float factor = 1.0f; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index 3ebc5fc2bdaf..4af608cce45e 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -362,15 +362,11 @@ while (--segments) { raw += diff; planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm - #if ENABLED(SCARA_FEEDRATE_SCALING) - , inv_duration - #endif + OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) ); } planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, segment_xyz_mm - #if ENABLED(SCARA_FEEDRATE_SCALING) - , inv_duration - #endif + OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) ); return false; // Did not set current from destination } diff --git a/Marlin/src/feature/caselight.cpp b/Marlin/src/feature/caselight.cpp index 5a4e2b2579dd..ec4ad99c75eb 100644 --- a/Marlin/src/feature/caselight.cpp +++ b/Marlin/src/feature/caselight.cpp @@ -41,7 +41,7 @@ bool CaseLight::on = CASE_LIGHT_DEFAULT_ON; #if CASE_LIGHT_IS_COLOR_LED #include "leds/leds.h" constexpr uint8_t init_case_light[] = CASE_LIGHT_DEFAULT_COLOR; - LEDColor CaseLight::color = { init_case_light[0], init_case_light[1], init_case_light[2], TERN_(HAS_WHITE_LED, init_case_light[3]) }; + LEDColor CaseLight::color = { init_case_light[0], init_case_light[1], init_case_light[2] OPTARG(HAS_WHITE_LED, init_case_light[3]) }; #endif void CaseLight::update(const bool sflag) { diff --git a/Marlin/src/feature/fwretract.cpp b/Marlin/src/feature/fwretract.cpp index d133d6060c75..41dbf430e829 100644 --- a/Marlin/src/feature/fwretract.cpp +++ b/Marlin/src/feature/fwretract.cpp @@ -91,11 +91,7 @@ void FWRetract::reset() { * Note: Auto-retract will apply the set Z hop in addition to any Z hop * included in the G-code. Use M207 Z0 to to prevent double hop. */ -void FWRetract::retract(const bool retracting - #if HAS_MULTI_EXTRUDER - , bool swapping/*=false*/ - #endif -) { +void FWRetract::retract(const bool retracting OPTARG(HAS_MULTI_EXTRUDER, bool swapping/*=false*/)) { // Prevent two retracts or recovers in a row if (retracted[active_extruder] == retracting) return; diff --git a/Marlin/src/feature/fwretract.h b/Marlin/src/feature/fwretract.h index 4fa64ad83b80..cd93e9cf39ed 100644 --- a/Marlin/src/feature/fwretract.h +++ b/Marlin/src/feature/fwretract.h @@ -74,11 +74,7 @@ class FWRetract { #endif } - static void retract(const bool retracting - #if HAS_MULTI_EXTRUDER - , bool swapping = false - #endif - ); + static void retract(const bool retracting OPTARG(HAS_MULTI_EXTRUDER, bool swapping = false)); static void M207(); static void M207_report(const bool forReplay=false); diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 8349049a00cc..c9178effa88c 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -75,9 +75,7 @@ void LEDLights::setup() { } void LEDLights::set_color(const LEDColor &incol - #if ENABLED(NEOPIXEL_LED) - , bool isSequence/*=false*/ - #endif + OPTARG(NEOPIXEL_LED, bool isSequence/*=false*/) ) { #if ENABLED(NEOPIXEL_LED) diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index cec95102d761..4157ff816eec 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -43,46 +43,21 @@ */ typedef struct LEDColor { uint8_t r, g, b - #if HAS_WHITE_LED - , w - #if ENABLED(NEOPIXEL_LED) - , i - #endif - #endif + OPTARG(HAS_WHITE_LED, w) + OPTARG(NEOPIXEL_LED, i) ; LEDColor() : r(255), g(255), b(255) - #if HAS_WHITE_LED - , w(255) - #if ENABLED(NEOPIXEL_LED) - , i(NEOPIXEL_BRIGHTNESS) - #endif - #endif + OPTARG(HAS_WHITE_LED, w(255)) + OPTARG(NEOPIXEL_LED, i(NEOPIXEL_BRIGHTNESS)) {} - LEDColor(uint8_t r, uint8_t g, uint8_t b - #if HAS_WHITE_LED - , uint8_t w=0 - #if ENABLED(NEOPIXEL_LED) - , uint8_t i=NEOPIXEL_BRIGHTNESS - #endif - #endif - ) : r(r), g(g), b(b) - #if HAS_WHITE_LED - , w(w) - #if ENABLED(NEOPIXEL_LED) - , i(i) - #endif - #endif - {} + LEDColor(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w=0) OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS)) + : r(r), g(g), b(b) OPTARG(HAS_WHITE_LED, w(w)) OPTARG(NEOPIXEL_LED, i(i)) {} LEDColor(const uint8_t (&rgbw)[4]) : r(rgbw[0]), g(rgbw[1]), b(rgbw[2]) - #if HAS_WHITE_LED - , w(rgbw[3]) - #if ENABLED(NEOPIXEL_LED) - , i(NEOPIXEL_BRIGHTNESS) - #endif - #endif + OPTARG(HAS_WHITE_LED, w(rgbw[3])) + OPTARG(NEOPIXEL_LED, i(NEOPIXEL_BRIGHTNESS)) {} LEDColor& operator=(const uint8_t (&rgbw)[4]) { @@ -111,15 +86,7 @@ typedef struct LEDColor { /** * Color helpers and presets */ -#if HAS_WHITE_LED - #if ENABLED(NEOPIXEL_LED) - #define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B, W, I) - #else - #define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B, W) - #endif -#else - #define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B) -#endif +#define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B OPTARG(HAS_WHITE_LED, W) OPTARG(NEOPIXEL_LED, I)) #define LEDColorOff() LEDColor( 0, 0, 0) #define LEDColorRed() LEDColor(255, 0, 0) @@ -147,25 +114,15 @@ class LEDLights { static void setup(); // init() static void set_color(const LEDColor &color - #if ENABLED(NEOPIXEL_LED) - , bool isSequence=false - #endif + OPTARG(NEOPIXEL_LED, bool isSequence=false) ); static inline void set_color(uint8_t r, uint8_t g, uint8_t b - #if HAS_WHITE_LED - , uint8_t w=0 - #endif - #if ENABLED(NEOPIXEL_LED) - , uint8_t i=NEOPIXEL_BRIGHTNESS - , bool isSequence=false - #endif + OPTARG(HAS_WHITE_LED, uint8_t w=0) + OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS) + OPTARG(NEOPIXEL_LED, bool isSequence=false) ) { - set_color(MakeLEDColor(r, g, b, w, i) - #if ENABLED(NEOPIXEL_LED) - , isSequence - #endif - ); + set_color(MakeLEDColor(r, g, b, w, i) OPTARG(NEOPIXEL_LED, isSequence)); } static inline void set_off() { set_color(LEDColorOff()); } diff --git a/Marlin/src/feature/leds/pca9632.cpp b/Marlin/src/feature/leds/pca9632.cpp index bb30e0b48b0e..abea98800451 100644 --- a/Marlin/src/feature/leds/pca9632.cpp +++ b/Marlin/src/feature/leds/pca9632.cpp @@ -93,9 +93,7 @@ static void PCA9632_WriteRegister(const byte addr, const byte regadd, const byte } static void PCA9632_WriteAllRegisters(const byte addr, const byte regadd, const byte vr, const byte vg, const byte vb - #if ENABLED(PCA9632_RGBW) - , const byte vw - #endif + OPTARG(PCA9632_RGBW, const byte vw) ) { #if DISABLED(PCA9632_NO_AUTO_INC) uint8_t data[4]; @@ -143,9 +141,7 @@ void PCA9632_set_led_color(const LEDColor &color) { ; PCA9632_WriteAllRegisters(PCA9632_ADDRESS,PCA9632_PWM0, color.r, color.g, color.b - #if ENABLED(PCA9632_RGBW) - , color.w - #endif + OPTARG(PCA9632_RGBW, color.w) ); PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_LEDOUT, LEDOUT); } diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index a0e07ab8a8c6..179f38f72998 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -70,15 +70,9 @@ class TMCStorage { } struct { - #if ENABLED(HAS_STEALTHCHOP) - bool stealthChop_enabled = false; - #endif - #if ENABLED(HYBRID_THRESHOLD) - uint8_t hybrid_thrs = 0; - #endif - #if ENABLED(USE_SENSORLESS) - int16_t homing_thrs = 0; - #endif + OPTCODE(HAS_STEALTHCHOP, bool stealthChop_enabled = false) + OPTCODE(HYBRID_THRESHOLD, uint8_t hybrid_thrs = 0) + OPTCODE(USE_SENSORLESS, int16_t homing_thrs = 0) } stored; }; diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 1e70652bdcef..616f16a58a66 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -330,12 +330,8 @@ typedef struct { thermalManager.setTargetBed(bed_temp); // Wait for the temperature to stabilize - if (!thermalManager.wait_for_bed(true - #if G26_CLICK_CAN_CANCEL - , true - #endif - ) - ) return G26_ERR; + if (!thermalManager.wait_for_bed(true OPTARG(G26_CLICK_CAN_CANCEL, true))) + return G26_ERR; } #else @@ -352,11 +348,8 @@ typedef struct { thermalManager.setTargetHotend(hotend_temp, active_extruder); // Wait for the temperature to stabilize - if (!thermalManager.wait_for_hotend(active_extruder, true - #if G26_CLICK_CAN_CANCEL - , true - #endif - )) return G26_ERR; + if (!thermalManager.wait_for_hotend(active_extruder, true OPTARG(G26_CLICK_CAN_CANCEL, true))) + return G26_ERR; #if HAS_WIRED_LCD ui.reset_status(); diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index 41ff7e976595..bafc79bcac9a 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -249,9 +249,7 @@ void plan_arc( #endif if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0 - #if ENABLED(SCARA_FEEDRATE_SCALING) - , inv_duration - #endif + OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) )) break; } @@ -266,9 +264,7 @@ void plan_arc( #endif planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0 - #if ENABLED(SCARA_FEEDRATE_SCALING) - , inv_duration - #endif + OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) ); TERN_(AUTO_BED_LEVELING_UBL, raw[l_axis] = start_L); diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index c0075373986f..09755fbf21a8 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -84,9 +84,7 @@ char GCodeQueue::injected_commands[64]; // = { 0 } void GCodeQueue::RingBuffer::commit_command(bool skip_ok - #if HAS_MULTI_SERIAL - , serial_index_t serial_ind/*=-1*/ - #endif + OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind/*=-1*/) ) { commands[index_w].skip_ok = skip_ok; TERN_(HAS_MULTI_SERIAL, commands[index_w].port = serial_ind); @@ -100,9 +98,7 @@ void GCodeQueue::RingBuffer::commit_command(bool skip_ok * Return false for a full buffer, or if the 'command' is a comment. */ bool GCodeQueue::RingBuffer::enqueue(const char *cmd, bool skip_ok/*=true*/ - #if HAS_MULTI_SERIAL - , serial_index_t serial_ind/*=-1*/ - #endif + OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind/*=-1*/) ) { if (*cmd == ';' || length >= BUFSIZE) return false; strcpy(commands[index_w].buffer, cmd); diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 5df4a0104c49..ea99ce7a2d54 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -80,15 +80,11 @@ class GCodeQueue { void advance_pos(uint8_t &p, const int inc) { if (++p >= BUFSIZE) p = 0; length += inc; } void commit_command(bool skip_ok - #if HAS_MULTI_SERIAL - , serial_index_t serial_ind = serial_index_t() - #endif + OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind = serial_index_t()) ); bool enqueue(const char *cmd, bool skip_ok = true - #if HAS_MULTI_SERIAL - , serial_index_t serial_ind = serial_index_t() - #endif + OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind = serial_index_t()) ); void ok_to_send(); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 14959851fa34..ba3abc0e2dd2 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -758,13 +758,9 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { // Tell ui.update() to start a move to current_position after a short delay. // void ManualMove::soon(const AxisEnum move_axis - #if MULTI_E_MANUAL - , const int8_t eindex/*=-1*/ - #endif + OPTARG(MULTI_E_MANUAL, const int8_t eindex/*=active_extruder*/) ) { - #if MULTI_E_MANUAL - if (move_axis == E_AXIS) e_index = eindex >= 0 ? eindex : active_extruder; - #endif + TERN_(MULTI_E_MANUAL, if (move_axis == E_AXIS) e_index = eindex); start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves axis = move_axis; //SERIAL_ECHOLNPAIR("Post Move with Axis ", AS_CHAR(axis_codes[axis]), " soon."); diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index ba0221713b53..766e46c66b22 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -182,11 +182,7 @@ static bool constexpr processing = false; #endif static void task(); - static void soon(const AxisEnum axis - #if MULTI_E_MANUAL - , const int8_t eindex=-1 - #endif - ); + static void soon(const AxisEnum axis OPTARG(MULTI_E_MANUAL, const int8_t eindex=active_extruder)); }; #endif diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 06d635ffc835..516f04632ed0 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -94,17 +94,13 @@ void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); } #if E_MANUAL - static void lcd_move_e(TERN_(MULTI_E_MANUAL, const int8_t eindex=-1)) { + static void lcd_move_e(TERN_(MULTI_E_MANUAL, const int8_t eindex=active_extruder)) { if (ui.use_click()) return ui.goto_previous_screen_no_defer(); if (ui.encoderPosition) { if (!ui.manual_move.processing) { const float diff = float(int32_t(ui.encoderPosition)) * ui.manual_move.menu_scale; TERN(IS_KINEMATIC, ui.manual_move.offset, current_position.e) += diff; - ui.manual_move.soon(E_AXIS - #if MULTI_E_MANUAL - , eindex - #endif - ); + ui.manual_move.soon(E_AXIS OPTARG(MULTI_E_MANUAL, eindex)); ui.refresh(LCDVIEW_REDRAW_NOW); } ui.encoderPosition = 0; @@ -139,7 +135,7 @@ void _goto_manual_move(const_float_t scale) { ui.goto_screen(_manual_move_func_ptr); } -void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=-1) { +void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=active_extruder) { _manual_move_func_ptr = func; START_MENU(); if (LCD_HEIGHT >= 4) { @@ -188,7 +184,7 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int #if E_MANUAL inline void _goto_menu_move_distance_e() { - ui.goto_screen([]{ _menu_move_distance(E_AXIS, []{ lcd_move_e(TERN_(MULTI_E_MANUAL, active_extruder)); }, -1); }); + ui.goto_screen([]{ _menu_move_distance(E_AXIS, []{ lcd_move_e(); }); }); } inline void _menu_move_distance_e_maybe() { diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index 87b016b1eca3..631d6d85826c 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -724,11 +724,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { drawMessage(msg); #endif - ui.manual_move.soon(axis - #if MULTI_E_MANUAL - , motionAxisState.e_selection - #endif - ); + ui.manual_move.soon(axis OPTARG(MULTI_E_MANUAL, motionAxisState.e_selection)); } drawAxisValue(axis); diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 89a127b01ed9..f7b6ffc75d30 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -709,11 +709,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { drawMessage(msg); #endif - ui.manual_move.soon(axis - #if MULTI_E_MANUAL - , motionAxisState.e_selection - #endif - ); + ui.manual_move.soon(axis OPTARG(MULTI_E_MANUAL, motionAxisState.e_selection)); } drawAxisValue(axis); diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 6923bdd71c0e..93df6eb961d0 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -711,11 +711,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { drawMessage(msg); #endif - ui.manual_move.soon(axis - #if MULTI_E_MANUAL - , motionAxisState.e_selection - #endif - ); + ui.manual_move.soon(axis OPTARG(MULTI_E_MANUAL, motionAxisState.e_selection)); } drawAxisValue(axis); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 235a969f66e7..6801b210af69 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -411,9 +411,7 @@ void line_to_current_position(const_feedRate_t fr_mm_s/*=feedrate_mm_s*/) { * - Extrude the specified length regardless of flow percentage. */ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ - #if IS_KINEMATIC - , const bool is_fast/*=false*/ - #endif + OPTARG(IS_KINEMATIC, const bool is_fast/*=false*/) ) { const feedRate_t old_feedrate = feedrate_mm_s; if (fr_mm_s) feedrate_mm_s = fr_mm_s; @@ -433,9 +431,7 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ feedrate_mm_s = old_feedrate; feedrate_percentage = old_pct; - #if HAS_EXTRUDERS - planner.e_factor[active_extruder] = old_fac; - #endif + TERN_(HAS_EXTRUDERS, planner.e_factor[active_extruder] = old_fac); } /** @@ -607,10 +603,8 @@ void restore_feedrate_and_scaling() { * at the same positions relative to the machine. */ void update_software_endstops(const AxisEnum axis - #if HAS_HOTEND_OFFSET - , const uint8_t old_tool_index/*=0*/ - , const uint8_t new_tool_index/*=0*/ - #endif + OPTARG(HAS_HOTEND_OFFSET, const uint8_t old_tool_index/*=0*/) + OPTARG(HAS_HOTEND_OFFSET, const uint8_t new_tool_index/*=0*/) ) { #if ENABLED(DUAL_X_CARRIAGE) @@ -858,17 +852,13 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { segment_idle(next_idle_ms); raw += segment_distance; if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, cartesian_segment_mm - #if ENABLED(SCARA_FEEDRATE_SCALING) - , inv_duration - #endif + OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) )) break; } // Ensure last segment arrives at target location. planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, cartesian_segment_mm - #if ENABLED(SCARA_FEEDRATE_SCALING) - , inv_duration - #endif + OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) ); return false; // caller will update current_position @@ -929,9 +919,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { segment_idle(next_idle_ms); raw += segment_distance; if (!planner.buffer_line(raw, fr_mm_s, active_extruder, cartesian_segment_mm - #if ENABLED(SCARA_FEEDRATE_SCALING) - , inv_duration - #endif + OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) )) break; } diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index a43af6446b2d..67205a763602 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -278,11 +278,7 @@ void line_to_current_position(const_feedRate_t fr_mm_s=feedrate_mm_s); void prepare_line_to_destination(); -void _internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f - #if IS_KINEMATIC - , const bool is_fast=false - #endif -); +void _internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f OPTARG(IS_KINEMATIC, const bool is_fast=false)); inline void prepare_internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f) { _internal_move_to_destination(fr_mm_s); diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 714be8019e20..09db12cd7abd 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1757,12 +1757,8 @@ void Planner::synchronize() { * Returns true if movement was properly queued, false otherwise (if cleaning) */ bool Planner::_buffer_steps(const xyze_long_t &target - #if HAS_POSITION_FLOAT - , const xyze_pos_t &target_float - #endif - #if HAS_DIST_MM_ARG - , const xyze_float_t &cart_dist_mm - #endif + OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) + OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters ) { @@ -1823,12 +1819,8 @@ bool Planner::_buffer_steps(const xyze_long_t &target */ bool Planner::_populate_block(block_t * const block, bool split_move, const abce_long_t &target - #if HAS_POSITION_FLOAT - , const xyze_pos_t &target_float - #endif - #if HAS_DIST_MM_ARG - , const xyze_float_t &cart_dist_mm - #endif + OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) + OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/ ) { @@ -2763,9 +2755,7 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_ * Return 'false' if no segment was queued due to cleaning, cold extrusion, full queue, etc. */ bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e - #if HAS_DIST_MM_ARG - , const xyze_float_t &cart_dist_mm - #endif + OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/ ) { @@ -2857,9 +2847,7 @@ bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c, * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) */ bool Planner::buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters - #if ENABLED(SCARA_FEEDRATE_SCALING) - , const_float_t inv_duration - #endif + OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration) ) { xyze_pos_t machine = { rx, ry, rz, e }; TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine)); diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 66e98f4a5704..be004dd3f4c3 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -707,12 +707,8 @@ class Planner { * Returns true if movement was buffered, false otherwise */ static bool _buffer_steps(const xyze_long_t &target - #if HAS_POSITION_FLOAT - , const xyze_pos_t &target_float - #endif - #if HAS_DIST_MM_ARG - , const xyze_float_t &cart_dist_mm - #endif + OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) + OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 ); @@ -728,14 +724,9 @@ class Planner { * * Returns true is movement is acceptable, false otherwise */ - static bool _populate_block(block_t * const block, bool split_move, - const xyze_long_t &target - #if HAS_POSITION_FLOAT - , const xyze_pos_t &target_float - #endif - #if HAS_DIST_MM_ARG - , const xyze_float_t &cart_dist_mm - #endif + static bool _populate_block(block_t * const block, bool split_move, const xyze_long_t &target + OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) + OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 ); @@ -768,22 +759,16 @@ class Planner { * millimeters - the length of the movement, if known */ static bool buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e - #if HAS_DIST_MM_ARG - , const xyze_float_t &cart_dist_mm - #endif + OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 ); FORCE_INLINE static bool buffer_segment(abce_pos_t &abce - #if HAS_DIST_MM_ARG - , const xyze_float_t &cart_dist_mm - #endif + OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 ) { return buffer_segment(abce.a, abce.b, abce.c, abce.e - #if HAS_DIST_MM_ARG - , cart_dist_mm - #endif + OPTARG(HAS_DIST_MM_ARG, cart_dist_mm) , fr_mm_s, extruder, millimeters); } @@ -801,20 +786,14 @@ class Planner { * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) */ static bool buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters=0.0 - #if ENABLED(SCARA_FEEDRATE_SCALING) - , const_float_t inv_duration=0.0 - #endif + OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration=0.0) ); FORCE_INLINE static bool buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters=0.0 - #if ENABLED(SCARA_FEEDRATE_SCALING) - , const_float_t inv_duration=0.0 - #endif + OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration=0.0) ) { return buffer_line(cart.x, cart.y, cart.z, cart.e, fr_mm_s, extruder, millimeters - #if ENABLED(SCARA_FEEDRATE_SCALING) - , inv_duration - #endif + OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) ); } diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 898ffa7d5f7a..e2a189920201 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -3335,11 +3335,8 @@ void Temperature::isr() { * Extruder: " T0:nnn.nn /nnn.nn" * With ADC: " T0:nnn.nn /nnn.nn (nnn.nn)" */ - static void print_heater_state(const_celsius_float_t c, const_celsius_float_t t - #if ENABLED(SHOW_TEMP_ADC_VALUES) - , const float r - #endif - , const heater_id_t e=INDEX_NONE + static void print_heater_state(const heater_id_t e, const_celsius_float_t c, const_celsius_float_t t + OPTARG(SHOW_TEMP_ADC_VALUES, const float r) ) { char k; switch (e) { @@ -3385,64 +3382,28 @@ void Temperature::isr() { } void Temperature::print_heater_states(const uint8_t target_extruder - #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - , const bool include_r/*=false*/ - #endif + OPTARG(TEMP_SENSOR_1_AS_REDUNDANT, const bool include_r/*=false*/) ) { #if HAS_TEMP_HOTEND - print_heater_state(degHotend(target_extruder), degTargetHotend(target_extruder) - #if ENABLED(SHOW_TEMP_ADC_VALUES) - , rawHotendTemp(target_extruder) - #endif - ); + print_heater_state(H_NONE, degHotend(target_extruder), degTargetHotend(target_extruder) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(target_extruder))); #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - if (include_r) print_heater_state(degHotendRedundant(), degTargetHotend(0) - #if ENABLED(SHOW_TEMP_ADC_VALUES) - , rawHotendTempRedundant() - #endif - , H_REDUNDANT - ); + if (include_r) print_heater_state(H_REDUNDANT, degHotendRedundant(), degTargetHotend(0) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTempRedundant())); #endif #endif #if HAS_HEATED_BED - print_heater_state(degBed(), degTargetBed() - #if ENABLED(SHOW_TEMP_ADC_VALUES) - , rawBedTemp() - #endif - , H_BED - ); + print_heater_state(H_BED, degBed(), degTargetBed() OPTARG(SHOW_TEMP_ADC_VALUES, rawBedTemp())); #endif #if HAS_TEMP_CHAMBER - print_heater_state(degChamber(), TERN0(HAS_HEATED_CHAMBER, degTargetChamber()) - #if ENABLED(SHOW_TEMP_ADC_VALUES) - , rawChamberTemp() - #endif - , H_CHAMBER - ); - #endif // HAS_TEMP_CHAMBER + print_heater_state(H_CHAMBER, degChamber(), TERN0(HAS_HEATED_CHAMBER, degTargetChamber()) OPTARG(SHOW_TEMP_ADC_VALUES, rawChamberTemp())); + #endif #if HAS_TEMP_COOLER - print_heater_state(degCooler(), TERN0(HAS_COOLER, degTargetCooler()) - #if ENABLED(SHOW_TEMP_ADC_VALUES) - , rawCoolerTemp() - #endif - , H_COOLER - ); - #endif // HAS_TEMP_COOLER + print_heater_state(H_COOLER, degCooler(), TERN0(HAS_COOLER, degTargetCooler()) OPTARG(SHOW_TEMP_ADC_VALUES, rawCoolerTemp())); + #endif #if HAS_TEMP_PROBE - print_heater_state(degProbe(), 0 - #if ENABLED(SHOW_TEMP_ADC_VALUES) - , rawProbeTemp() - #endif - , H_PROBE - ); + print_heater_state(H_PROBE, degProbe(), 0 OPTARG(SHOW_TEMP_ADC_VALUES, rawProbeTemp()) ); #endif #if HAS_MULTI_HOTEND - HOTEND_LOOP() print_heater_state(degHotend(e), degTargetHotend(e) - #if ENABLED(SHOW_TEMP_ADC_VALUES) - , rawHotendTemp(e) - #endif - , (heater_id_t)e - ); + HOTEND_LOOP() print_heater_state((heater_id_t)e, degHotend(e), degTargetHotend(e) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(e))); #endif SERIAL_ECHOPAIR(" @:", getHeaterPower((heater_id_t)target_extruder)); #if HAS_HEATED_BED @@ -3465,10 +3426,7 @@ void Temperature::isr() { #if ENABLED(AUTO_REPORT_TEMPERATURES) AutoReporter Temperature::auto_reporter; - void Temperature::AutoReportTemp::report() { - print_heater_states(active_extruder); - SERIAL_EOL(); - } + void Temperature::AutoReportTemp::report() { print_heater_states(active_extruder); SERIAL_EOL(); } #endif #if HAS_HOTEND && HAS_STATUS_MESSAGE @@ -3495,11 +3453,8 @@ void Temperature::isr() { #endif bool Temperature::wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling/*=true*/ - #if G26_CLICK_CAN_CANCEL - , const bool click_to_cancel/*=false*/ - #endif + OPTARG(G26_CLICK_CAN_CANCEL, const bool click_to_cancel/*=false*/) ) { - #if ENABLED(AUTOTEMP) REMEMBER(1, planner.autotemp_enabled, false); #endif @@ -3638,9 +3593,7 @@ void Temperature::isr() { #endif bool Temperature::wait_for_bed(const bool no_wait_for_cooling/*=true*/ - #if G26_CLICK_CAN_CANCEL - , const bool click_to_cancel/*=false*/ - #endif + OPTARG(G26_CLICK_CAN_CANCEL, const bool click_to_cancel/*=false*/) ) { #if TEMP_BED_RESIDENCY_TIME > 0 millis_t residency_start_ms = 0; diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index a80e39cbd879..660fde8af68a 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -46,7 +46,7 @@ // Element identifiers. Positive values are hotends. Negative values are other heaters or coolers. typedef enum : int8_t { - INDEX_NONE = -6, + H_NONE = -6, H_COOLER, H_PROBE, H_REDUNDANT, H_CHAMBER, H_BED, H_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7 } heater_id_t; @@ -395,21 +395,21 @@ class Temperature { } heater_idle_t; // Indices and size for the heater_idle array - #define _ENUM_FOR_E(N) IDLE_INDEX_E##N, - enum IdleIndex : uint8_t { - REPEAT(HOTENDS, _ENUM_FOR_E) - #if ENABLED(HAS_HEATED_BED) - IDLE_INDEX_BED, - #endif - NR_HEATER_IDLE + enum IdleIndex : int8_t { + _II = -1 + + #define _IDLE_INDEX_E(N) ,IDLE_INDEX_E##N + REPEAT(HOTENDS, _IDLE_INDEX_E) + #undef _IDLE_INDEX_E + + OPTARG(HAS_HEATED_BED, IDLE_INDEX_BED) + + , NR_HEATER_IDLE }; - #undef _ENUM_FOR_E // Convert the given heater_id_t to idle array index static inline IdleIndex idle_index_for_id(const int8_t heater_id) { - #if HAS_HEATED_BED - if (heater_id == H_BED) return IDLE_INDEX_BED; - #endif + TERN_(HAS_HEATED_BED, if (heater_id == H_BED) return IDLE_INDEX_BED); return (IdleIndex)_MAX(heater_id, 0); } @@ -672,9 +672,7 @@ class Temperature { #if HAS_TEMP_HOTEND static bool wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling=true - #if G26_CLICK_CAN_CANCEL - , const bool click_to_cancel=false - #endif + OPTARG(G26_CLICK_CAN_CANCEL, const bool click_to_cancel=false) ); #if ENABLED(WAIT_FOR_HOTEND) @@ -721,9 +719,7 @@ class Temperature { } static bool wait_for_bed(const bool no_wait_for_cooling=true - #if G26_CLICK_CAN_CANCEL - , const bool click_to_cancel=false - #endif + OPTARG(G26_CLICK_CAN_CANCEL, const bool click_to_cancel=false) ); static void wait_for_bed_heating(); @@ -859,9 +855,7 @@ class Temperature { #if HAS_TEMP_SENSOR static void print_heater_states(const uint8_t target_extruder - #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - , const bool include_r=false - #endif + OPTARG(TEMP_SENSOR_1_AS_REDUNDANT, const bool include_r=false) ); #if ENABLED(AUTO_REPORT_TEMPERATURES) struct AutoReportTemp { static void report(); }; @@ -925,35 +919,24 @@ class Temperature { #if HAS_THERMAL_PROTECTION // Indices and size for the tr_state_machine array. One for each protected heater. - #define _ENUM_FOR_E(N) RUNAWAY_IND_E##N, - enum RunawayIndex : uint8_t { + enum RunawayIndex : int8_t { + _RI = -1 #if ENABLED(THERMAL_PROTECTION_HOTENDS) - REPEAT(HOTENDS, _ENUM_FOR_E) + #define _RUNAWAY_IND_E(N) ,RUNAWAY_IND_E##N + REPEAT(HOTENDS, _RUNAWAY_IND_E) + #undef _RUNAWAY_IND_E #endif - #if ENABLED(HAS_THERMALLY_PROTECTED_BED) - RUNAWAY_IND_BED, - #endif - #if ENABLED(THERMAL_PROTECTION_CHAMBER) - RUNAWAY_IND_CHAMBER, - #endif - #if ENABLED(THERMAL_PROTECTION_COOLER) - RUNAWAY_IND_COOLER, - #endif - NR_HEATER_RUNAWAY + OPTARG(HAS_THERMALLY_PROTECTED_BED, RUNAWAY_IND_BED) + OPTARG(THERMAL_PROTECTION_CHAMBER, RUNAWAY_IND_CHAMBER) + OPTARG(THERMAL_PROTECTION_COOLER, RUNAWAY_IND_COOLER) + , NR_HEATER_RUNAWAY }; - #undef _ENUM_FOR_E // Convert the given heater_id_t to runaway state array index static inline RunawayIndex runaway_index_for_id(const int8_t heater_id) { - #if HAS_THERMALLY_PROTECTED_CHAMBER - if (heater_id == H_CHAMBER) return RUNAWAY_IND_CHAMBER; - #endif - #if HAS_THERMALLY_PROTECTED_CHAMBER - if (heater_id == H_COOLER) return RUNAWAY_IND_COOLER; - #endif - #if HAS_THERMALLY_PROTECTED_BED - if (heater_id == H_BED) return RUNAWAY_IND_BED; - #endif + TERN_(HAS_THERMALLY_PROTECTED_CHAMBER, if (heater_id == H_CHAMBER) return RUNAWAY_IND_CHAMBER); + TERN_(HAS_THERMALLY_PROTECTED_CHAMBER, if (heater_id == H_COOLER) return RUNAWAY_IND_COOLER); + TERN_(HAS_THERMALLY_PROTECTED_BED, if (heater_id == H_BED) return RUNAWAY_IND_BED); return (RunawayIndex)_MAX(heater_id, 0); } diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp b/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp index a84a68320413..1aeef1703fec 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp @@ -956,12 +956,6 @@ uint8_t BulkOnly::HandleUsbError(uint8_t error, uint8_t index) { return ((error && !count) ? MASS_ERR_GENERAL_USB_ERROR : MASS_ERR_SUCCESS); } -#if MS_WANT_PARSER - uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf) { - return Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf, 0); - } -#endif - /** * For driver use only. * @@ -972,9 +966,7 @@ uint8_t BulkOnly::HandleUsbError(uint8_t error, uint8_t index) { * @return */ uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf - #if MS_WANT_PARSER - , uint8_t flags - #endif + OPTARG(MS_WANT_PARSER, uint8_t flags/*=0*/) ) { #if MS_WANT_PARSER uint16_t bytes = (pcbw->dCBWDataTransferLength > buf_size) ? buf_size : pcbw->dCBWDataTransferLength; diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.h b/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.h index 25df006e513d..aafb91624b00 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.h +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.h @@ -553,10 +553,7 @@ class BulkOnly : public USBDeviceConfig, public UsbConfigXtracter { bool IsValidCSW(CommandStatusWrapper *pcsw, CommandBlockWrapperBase *pcbw); uint8_t ClearEpHalt(uint8_t index); - #if MS_WANT_PARSER - uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf, uint8_t flags); - #endif - uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf); + uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf OPTARG(MS_WANT_PARSER, uint8_t flags=0)); uint8_t HandleUsbError(uint8_t error, uint8_t index); uint8_t HandleSCSIError(uint8_t status); }; From 9398c431128fc92dcd18ac8cf556e266e4692bf4 Mon Sep 17 00:00:00 2001 From: gjdodd <31553294+gjdodd@users.noreply.github.com> Date: Mon, 24 May 2021 07:54:10 +0100 Subject: [PATCH 45/61] =?UTF-8?q?=F0=9F=90=9B=20Fix=20flowmeter=20calculat?= =?UTF-8?q?ion=20(#21959)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/cooler.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Marlin/src/feature/cooler.h b/Marlin/src/feature/cooler.h index 1e24c729f39f..9bd98d0b1032 100644 --- a/Marlin/src/feature/cooler.h +++ b/Marlin/src/feature/cooler.h @@ -78,10 +78,8 @@ class Cooler { // Get the total flow (in liters per minute) since the last reading static void calc_flowrate() { - //flowmeter_interrupt_disable(); - // const uint16_t pulses = flowpulses; - //flowmeter_interrupt_enable(); - flowrate = flowpulses * 60.0f * (1000.0f / (FLOWMETER_INTERVAL)) * (1000.0f / (FLOWMETER_PPL)); + // flowrate = (litres) * (seconds) = litres per minute + flowrate = (flowpulses / (float)FLOWMETER_PPL) * ((1000.0f / (float)FLOWMETER_INTERVAL) * 60.0f); flowpulses = 0; } From 76e80aa40010e7699af3dcaff4af2bbd7e269842 Mon Sep 17 00:00:00 2001 From: BigTreeTech <38851044+bigtreetech@users.noreply.github.com> Date: Mon, 24 May 2021 14:57:45 +0800 Subject: [PATCH 46/61] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Octopus=20HS=20USB?= =?UTF-8?q?=20(#21961)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PeripheralPins.c | 173 +++++++++++------- 1 file changed, 108 insertions(+), 65 deletions(-) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1_0/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1_0/PeripheralPins.c index 75bbd1cf206c..333bef3db2c2 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1_0/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1_0/PeripheralPins.c @@ -132,70 +132,96 @@ const PinMap PinMap_I2C_SCL[] = { #ifdef HAL_TIM_MODULE_ENABLED const PinMap PinMap_PWM[] = { - {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 - // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 - // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - STLink Tx - // {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 - STLink Tx - // {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - STLink Tx - // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - STLink Rx - // {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 - STLink Rx - // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - STLink Rx - {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N - {PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 - // {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 - // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - // {PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N - {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 - {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - // {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - {PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // Fan0, TIM8_CH2N - // {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - // {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 - {PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // Fan1, TIM8_CH3N - {PB_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // Fan2, TIM2_CH4 - {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // E0 Heater, TIM2_CH2 - {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // E1 Heater, TIM3_CH1 - {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // LED G, TIM3_CH2 - {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // LED R, TIM4_CH1 - {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // LED B, TIM4_CH2 - // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 - // {PB_8, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 - {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 - // {PB_9, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - // {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 - {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - {PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 - // {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - // {PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N - {PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 - // {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - // {PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N - {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - // {PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 - // {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - {PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 - {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - // {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 - // {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 - {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 - {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 BED - {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 HEATER1 - {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 - {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 FAN1 - {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - {PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 BED + {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 HEATER0 + {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 HEATER1 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 HEATER2 + {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 HEATER3 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 FAN0 + {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 FAN1 + {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 FAN2 + {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 FAN3 + {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 FAN4 + {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 FAN5 + + /** + * Unused by specifications on Octopus. + * Uncomment the corresponding line if you want to have HardwarePWM on some pins. + * WARNING: check timers' usage first to avoid conflicts. + * If you don't know what you're doing leave things as they are or you WILL break something (including hardware) + * If you alter this section DO NOT report bugs to Marlin team since they are most likely caused by you. Thank you. + */ + //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + //{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 BLTOUCH is a "servo" + //{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 BLTOUCH is a "servo" + //{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + //{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 + //{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + //{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + //{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + //{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + //{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + //{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + //{PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + //{PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + //{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + //{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + //{PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + //{PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 + //{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 + //{PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + //{PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + //{PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + //{PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + //{PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + //{PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + //{PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + //{PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + //{PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + //144 pins mcu, 114 gpio + //{PF_6, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + //{PF_7, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + //{PF_8, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + //{PF_9, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + + //176 pins mcu, 140 gpio + //{PH_10, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + //{PH_6, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 + //{PH_11, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + //{PI_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + //{PI_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + {NC, NP, 0} }; #endif @@ -367,7 +393,24 @@ const PinMap PinMap_USB_OTG_FS[] = { #endif #ifdef HAL_PCD_MODULE_ENABLED -const PinMap PinMap_USB_OTG_HS[] = { +const PinMap PinMap_USB_OTG_HS[] = { + //{PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID + //{PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS + {PB_14, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM + {PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP + + /*#error "USB in HS mode isn't supported by the board" + {PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D0 + {PB_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D1 + {PB_1, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D2 + {PB_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D7 + {PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D3 + {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D5 + {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D6 + {PC_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_STP + {PC_2, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_DIR + {PC_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_NXT + */ {NC, NP, 0} }; From 0d7075b90c225d2f88e1d790b2df4acbdfcfac8b Mon Sep 17 00:00:00 2001 From: LawnMo <81721212+LawnMo@users.noreply.github.com> Date: Mon, 24 May 2021 09:21:21 +0200 Subject: [PATCH 47/61] =?UTF-8?q?=F0=9F=A9=B9=20Improved=20SKR2=2012864=20?= =?UTF-8?q?LCD=20Delays=20(#21956)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h index 5e2f88190d73..c46e0f03f0c9 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h @@ -502,13 +502,13 @@ // Alter timing for graphical display #if HAS_MARLINUI_U8GLIB #ifndef BOARD_ST7920_DELAY_1 - #define BOARD_ST7920_DELAY_1 DELAY_NS(96) + #define BOARD_ST7920_DELAY_1 DELAY_NS(120) #endif #ifndef BOARD_ST7920_DELAY_2 - #define BOARD_ST7920_DELAY_2 DELAY_NS(48) + #define BOARD_ST7920_DELAY_2 DELAY_NS(80) #endif #ifndef BOARD_ST7920_DELAY_3 - #define BOARD_ST7920_DELAY_3 DELAY_NS(600) + #define BOARD_ST7920_DELAY_3 DELAY_NS(580) #endif #endif From dd4990252e891cdfe56cb7d6e3bbe1e6289be649 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 24 May 2021 16:38:57 -0500 Subject: [PATCH 48/61] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20Linear=20?= =?UTF-8?q?/=20Logical=20/=20Distinct=20Axes=20(#21953)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * More patches supporting EXTRUDERS 0 * Extend types in prep for more axes --- Marlin/src/core/serial.cpp | 7 +- Marlin/src/core/serial.h | 7 +- Marlin/src/core/types.h | 440 ++++++++++-------- Marlin/src/core/utility.h | 8 + Marlin/src/feature/encoder_i2c.cpp | 43 +- Marlin/src/feature/tmc_util.cpp | 34 +- Marlin/src/feature/tmc_util.h | 14 +- Marlin/src/gcode/calibrate/G28.cpp | 27 +- Marlin/src/gcode/calibrate/G425.cpp | 12 +- Marlin/src/gcode/calibrate/M425.cpp | 10 +- Marlin/src/gcode/config/M200-M205.cpp | 27 +- Marlin/src/gcode/config/M92.cpp | 43 +- Marlin/src/gcode/control/M17_M18_M84.cpp | 24 +- Marlin/src/gcode/feature/pause/G61.cpp | 12 +- Marlin/src/gcode/feature/trinamic/M122.cpp | 18 +- Marlin/src/gcode/gcode.cpp | 26 +- Marlin/src/gcode/gcode.h | 37 +- Marlin/src/gcode/geometry/G92.cpp | 37 +- Marlin/src/gcode/host/M114.cpp | 2 +- Marlin/src/gcode/motion/G0_G1.cpp | 10 +- Marlin/src/gcode/motion/G2_G3.cpp | 31 +- Marlin/src/gcode/motion/M290.cpp | 2 +- Marlin/src/gcode/parser.cpp | 3 +- Marlin/src/gcode/parser.h | 2 +- Marlin/src/inc/Conditionals_LCD.h | 94 ++-- Marlin/src/inc/Conditionals_adv.h | 20 + Marlin/src/inc/Conditionals_post.h | 249 +++++----- Marlin/src/inc/SanityCheck.h | 27 +- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 6 +- .../src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp | 8 +- Marlin/src/lcd/marlinui.cpp | 10 +- Marlin/src/lcd/menu/menu_advanced.cpp | 40 +- Marlin/src/module/endstops.cpp | 11 +- Marlin/src/module/motion.cpp | 102 ++-- Marlin/src/module/motion.h | 14 +- Marlin/src/module/planner.cpp | 266 ++++++----- Marlin/src/module/planner.h | 50 +- Marlin/src/module/settings.cpp | 46 +- Marlin/src/module/stepper.cpp | 56 ++- Marlin/src/module/stepper.h | 16 +- Marlin/src/module/stepper/trinamic.cpp | 23 +- buildroot/tests/mega2560 | 12 +- buildroot/tests/rambo | 2 + 43 files changed, 1141 insertions(+), 787 deletions(-) diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index b4184fcd623b..60729440e6e7 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -101,8 +101,11 @@ void print_bin(uint16_t val) { } } -void print_pos(const_float_t x, const_float_t y, const_float_t z, PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) { +void print_pos( + LINEAR_AXIS_LIST(const_float_t x, const_float_t y, const_float_t z) + , PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/ +) { if (prefix) serialprintPGM(prefix); - SERIAL_ECHOPAIR_P(SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z); + SERIAL_ECHOPAIR_P(LIST_N(DOUBLE(LINEAR_AXES), SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z)); if (suffix) serialprintPGM(suffix); else SERIAL_EOL(); } diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 74b96dbb6476..6f893795df7b 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -310,10 +310,13 @@ void serialprint_truefalse(const bool tf); void serial_spaces(uint8_t count); void print_bin(const uint16_t val); -void print_pos(const_float_t x, const_float_t y, const_float_t z, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr); +void print_pos( + LINEAR_AXIS_LIST(const_float_t x, const_float_t y, const_float_t z), + PGM_P const prefix=nullptr, PGM_P const suffix=nullptr +); inline void print_pos(const xyz_pos_t &xyz, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr) { - print_pos(xyz.x, xyz.y, xyz.z, prefix, suffix); + print_pos(LINEAR_AXIS_LIST(xyz.x, xyz.y, xyz.z), prefix, suffix); } #define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n")); }while(0) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index b7ae85eb2ee1..41cb39f16303 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -39,6 +39,26 @@ struct IF { typedef R type; }; template struct IF { typedef L type; }; +#define LINEAR_AXIS_GANG(V...) GANG_N(LINEAR_AXES, V) +#define LINEAR_AXIS_CODE(V...) CODE_N(LINEAR_AXES, V) +#define LINEAR_AXIS_LIST(V...) LIST_N(LINEAR_AXES, V) +#define LINEAR_AXIS_ARRAY(V...) { LINEAR_AXIS_LIST(V) } + +#define LOGICAL_AXIS_GANG(E,V...) LINEAR_AXIS_GANG(V) GANG_ITEM_E(E) +#define LOGICAL_AXIS_CODE(E,V...) LINEAR_AXIS_CODE(V) CODE_ITEM_E(E) +#define LOGICAL_AXIS_LIST(E,V...) LINEAR_AXIS_LIST(V) LIST_ITEM_E(E) +#define LOGICAL_AXIS_ARRAY(E,V...) { LOGICAL_AXIS_LIST(E,V) } + +#if HAS_EXTRUDERS + #define LIST_ITEM_E(N) , N + #define CODE_ITEM_E(N) ; N + #define GANG_ITEM_E(N) N +#else + #define LIST_ITEM_E(N) + #define CODE_ITEM_E(N) + #define GANG_ITEM_E(N) +#endif + // // Enumerated axis indices // @@ -47,16 +67,43 @@ struct IF { typedef L type; }; // - X_HEAD, Y_HEAD, and Z_HEAD should be used for Steppers on Core kinematics // enum AxisEnum : uint8_t { - X_AXIS = 0, A_AXIS = X_AXIS, - Y_AXIS = 1, B_AXIS = Y_AXIS, - Z_AXIS = 2, C_AXIS = Z_AXIS, - E_AXIS, - X_HEAD, Y_HEAD, Z_HEAD, - E0_AXIS = E_AXIS, - E1_AXIS, E2_AXIS, E3_AXIS, E4_AXIS, E5_AXIS, E6_AXIS, E7_AXIS, + + // Linear axes may be controlled directly or indirectly + LINEAR_AXIS_LIST(X_AXIS, Y_AXIS, Z_AXIS), + + // Extruder axes may be considered distinctly + #define _EN_ITEM(N) E##N##_AXIS, + REPEAT(EXTRUDERS, _EN_ITEM) + #undef _EN_ITEM + + // Core also keeps toolhead directions + #if IS_CORE + X_HEAD, Y_HEAD, Z_HEAD, + #endif + + // Distinct axes, including all E and Core + NUM_AXIS_ENUMS, + + // Most of the time we refer only to the single E_AXIS + #if HAS_EXTRUDERS + E_AXIS = E0_AXIS, + #endif + + // A, B, and C are for DELTA, SCARA, etc. + A_AXIS = X_AXIS, + #if LINEAR_AXES >= 2 + B_AXIS = Y_AXIS, + #endif + #if LINEAR_AXES >= 3 + C_AXIS = Z_AXIS, + #endif + + // To refer to all or none ALL_AXES_ENUM = 0xFE, NO_AXIS_ENUM = 0xFF }; +typedef IF<(NUM_AXIS_ENUMS > 8), uint16_t, uint8_t>::type axis_bits_t; + // // Loop over axes // @@ -185,7 +232,7 @@ void toNative(xyz_pos_t &raw); void toNative(xyze_pos_t &raw); // -// XY coordinates, counters, etc. +// Paired XY coordinates, counters, flags, etc. // template struct XYval { @@ -197,10 +244,14 @@ struct XYval { FI void set(const T px) { x = px; } FI void set(const T px, const T py) { x = px; y = py; } FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; } - FI void set(const T (&arr)[XYZ]) { x = arr[0]; y = arr[1]; } - FI void set(const T (&arr)[XYZE]) { x = arr[0]; y = arr[1]; } - #if DISTINCT_AXES > LOGICAL_AXES - FI void set(const T (&arr)[DISTINCT_AXES]) { x = arr[0]; y = arr[1]; } + #if LINEAR_AXES > XY + FI void set(const T (&arr)[LINEAR_AXES]) { x = arr[0]; y = arr[1]; } + #endif + #if LOGICAL_AXES > LINEAR_AXES + FI void set(const T (&arr)[LOGICAL_AXES]) { x = arr[0]; y = arr[1]; } + #if DISTINCT_AXES > LOGICAL_AXES + FI void set(const T (&arr)[DISTINCT_AXES]) { x = arr[0]; y = arr[1]; } + #endif #endif FI void reset() { x = y = 0; } FI T magnitude() const { return (T)sqrtf(x*x + y*y); } @@ -223,8 +274,8 @@ struct XYval { FI operator XYZval() const { return { x, y }; } FI operator XYZEval() { return { x, y }; } FI operator XYZEval() const { return { x, y }; } - FI T& operator[](const int i) { return pos[i]; } - FI const T& operator[](const int i) const { return pos[i]; } + FI T& operator[](const int n) { return pos[n]; } + FI const T& operator[](const int n) const { return pos[n]; } FI XYval& operator= (const T v) { set(v, v ); return *this; } FI XYval& operator= (const XYZval &rs) { set(rs.x, rs.y); return *this; } FI XYval& operator= (const XYZEval &rs) { set(rs.x, rs.y); return *this; } @@ -294,219 +345,227 @@ struct XYval { }; // -// XYZ coordinates, counters, etc. +// Linear Axes coordinates, counters, flags, etc. // template struct XYZval { union { - struct { T x, y, z; }; - struct { T a, b, c; }; - T pos[3]; + struct { T LINEAR_AXIS_LIST(x, y, z); }; + struct { T LINEAR_AXIS_LIST(a, b, c); }; + T pos[LINEAR_AXES]; }; FI void set(const T px) { x = px; } FI void set(const T px, const T py) { x = px; y = py; } - FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } + FI void set(const XYval pxy) { x = pxy.x; y = pxy.y; } FI void set(const XYval pxy, const T pz) { x = pxy.x; y = pxy.y; z = pz; } FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; } - FI void set(const T (&arr)[XYZ]) { x = arr[0]; y = arr[1]; z = arr[2]; } - FI void set(const T (&arr)[XYZE]) { x = arr[0]; y = arr[1]; z = arr[2]; } - #if DISTINCT_AXES > XYZE - FI void set(const T (&arr)[DISTINCT_AXES]) { x = arr[0]; y = arr[1]; z = arr[2]; } + FI void set(const T (&arr)[LINEAR_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2]); } + #if LINEAR_AXES >= XYZ + FI void set(LINEAR_AXIS_LIST(const T px, const T py, const T pz)) + { LINEAR_AXIS_CODE(x = px, y = py, z = pz); } + #endif + #if LOGICAL_AXES > LINEAR_AXES + FI void set(const T (&arr)[LOGICAL_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2]); } + FI void set(LOGICAL_AXIS_LIST(const T, const T px, const T py, const T pz)) + { LINEAR_AXIS_CODE(x = px, y = py, z = pz); } + #if DISTINCT_AXES > LOGICAL_AXES + FI void set(const T (&arr)[DISTINCT_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2]); } + #endif #endif - FI void reset() { x = y = z = 0; } - FI T magnitude() const { return (T)sqrtf(x*x + y*y + z*z); } + FI void reset() { LINEAR_AXIS_GANG(x =, y =, z =) 0; } + FI T magnitude() const { return (T)sqrtf(LINEAR_AXIS_GANG(x*x, + y*y, + z*z)); } FI operator T* () { return pos; } - FI operator bool() { return z || x || y; } + FI operator bool() { return LINEAR_AXIS_GANG(z, || x, || y); } FI XYZval copy() const { XYZval o = *this; return o; } - FI XYZval ABS() const { return { T(_ABS(x)), T(_ABS(y)), T(_ABS(z)) }; } - FI XYZval asInt() { return { int16_t(x), int16_t(y), int16_t(z) }; } - FI XYZval asInt() const { return { int16_t(x), int16_t(y), int16_t(z) }; } - FI XYZval asLong() { return { int32_t(x), int32_t(y), int32_t(z) }; } - FI XYZval asLong() const { return { int32_t(x), int32_t(y), int32_t(z) }; } - FI XYZval ROUNDL() { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)) }; } - FI XYZval ROUNDL() const { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)) }; } - FI XYZval asFloat() { return { static_cast(x), static_cast(y), static_cast(z) }; } - FI XYZval asFloat() const { return { static_cast(x), static_cast(y), static_cast(z) }; } - FI XYZval reciprocal() const { return { _RECIP(x), _RECIP(y), _RECIP(z) }; } + FI XYZval ABS() const { return LINEAR_AXIS_ARRAY(T(_ABS(x)), T(_ABS(y)), T(_ABS(z))); } + FI XYZval asInt() { return LINEAR_AXIS_ARRAY(int16_t(x), int16_t(y), int16_t(z)); } + FI XYZval asInt() const { return LINEAR_AXIS_ARRAY(int16_t(x), int16_t(y), int16_t(z)); } + FI XYZval asLong() { return LINEAR_AXIS_ARRAY(int32_t(x), int32_t(y), int32_t(z)); } + FI XYZval asLong() const { return LINEAR_AXIS_ARRAY(int32_t(x), int32_t(y), int32_t(z)); } + FI XYZval ROUNDL() { return LINEAR_AXIS_ARRAY(int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z))); } + FI XYZval ROUNDL() const { return LINEAR_AXIS_ARRAY(int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z))); } + FI XYZval asFloat() { return LINEAR_AXIS_ARRAY(static_cast(x), static_cast(y), static_cast(z)); } + FI XYZval asFloat() const { return LINEAR_AXIS_ARRAY(static_cast(x), static_cast(y), static_cast(z)); } + FI XYZval reciprocal() const { return LINEAR_AXIS_ARRAY(_RECIP(x), _RECIP(y), _RECIP(z)); } FI XYZval asLogical() const { XYZval o = asFloat(); toLogical(o); return o; } FI XYZval asNative() const { XYZval o = asFloat(); toNative(o); return o; } FI operator XYval&() { return *(XYval*)this; } FI operator const XYval&() const { return *(const XYval*)this; } - FI operator XYZEval() const { return { x, y, z }; } - FI T& operator[](const int i) { return pos[i]; } - FI const T& operator[](const int i) const { return pos[i]; } - FI XYZval& operator= (const T v) { set(v, v, v ); return *this; } + FI operator XYZEval() const { return LINEAR_AXIS_ARRAY(x, y, z); } + FI T& operator[](const int n) { return pos[n]; } + FI const T& operator[](const int n) const { return pos[n]; } + FI XYZval& operator= (const T v) { set(ARRAY_N_1(LINEAR_AXES, v)); return *this; } FI XYZval& operator= (const XYval &rs) { set(rs.x, rs.y ); return *this; } - FI XYZval& operator= (const XYZEval &rs) { set(rs.x, rs.y, rs.z); return *this; } - FI XYZval operator+ (const XYval &rs) const { XYZval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } - FI XYZval operator+ (const XYval &rs) { XYZval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } - FI XYZval operator- (const XYval &rs) const { XYZval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } - FI XYZval operator- (const XYval &rs) { XYZval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } - FI XYZval operator* (const XYval &rs) const { XYZval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } - FI XYZval operator* (const XYval &rs) { XYZval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } - FI XYZval operator/ (const XYval &rs) const { XYZval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYZval operator/ (const XYval &rs) { XYZval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYZval operator+ (const XYZval &rs) const { XYZval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; } - FI XYZval operator+ (const XYZval &rs) { XYZval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; } - FI XYZval operator- (const XYZval &rs) const { XYZval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; } - FI XYZval operator- (const XYZval &rs) { XYZval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; } - FI XYZval operator* (const XYZval &rs) const { XYZval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; } - FI XYZval operator* (const XYZval &rs) { XYZval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; } - FI XYZval operator/ (const XYZval &rs) const { XYZval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; } - FI XYZval operator/ (const XYZval &rs) { XYZval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; } - FI XYZval operator+ (const XYZEval &rs) const { XYZval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; } - FI XYZval operator+ (const XYZEval &rs) { XYZval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; } - FI XYZval operator- (const XYZEval &rs) const { XYZval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; } - FI XYZval operator- (const XYZEval &rs) { XYZval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; } - FI XYZval operator* (const XYZEval &rs) const { XYZval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; } - FI XYZval operator* (const XYZEval &rs) { XYZval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; } - FI XYZval operator/ (const XYZEval &rs) const { XYZval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; } - FI XYZval operator/ (const XYZEval &rs) { XYZval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; } - FI XYZval operator* (const float &v) const { XYZval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; return ls; } - FI XYZval operator* (const float &v) { XYZval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; return ls; } - FI XYZval operator* (const int &v) const { XYZval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; return ls; } - FI XYZval operator* (const int &v) { XYZval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; return ls; } - FI XYZval operator/ (const float &v) const { XYZval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; return ls; } - FI XYZval operator/ (const float &v) { XYZval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; return ls; } - FI XYZval operator/ (const int &v) const { XYZval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; return ls; } - FI XYZval operator/ (const int &v) { XYZval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; return ls; } - FI XYZval operator>>(const int &v) const { XYZval ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); return ls; } - FI XYZval operator>>(const int &v) { XYZval ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); return ls; } - FI XYZval operator<<(const int &v) const { XYZval ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); return ls; } - FI XYZval operator<<(const int &v) { XYZval ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); return ls; } - FI XYZval& operator+=(const XYval &rs) { x += rs.x; y += rs.y; return *this; } - FI XYZval& operator-=(const XYval &rs) { x -= rs.x; y -= rs.y; return *this; } - FI XYZval& operator*=(const XYval &rs) { x *= rs.x; y *= rs.y; return *this; } - FI XYZval& operator/=(const XYval &rs) { x /= rs.x; y /= rs.y; return *this; } - FI XYZval& operator+=(const XYZval &rs) { x += rs.x; y += rs.y; z += rs.z; return *this; } - FI XYZval& operator-=(const XYZval &rs) { x -= rs.x; y -= rs.y; z -= rs.z; return *this; } - FI XYZval& operator*=(const XYZval &rs) { x *= rs.x; y *= rs.y; z *= rs.z; return *this; } - FI XYZval& operator/=(const XYZval &rs) { x /= rs.x; y /= rs.y; z /= rs.z; return *this; } - FI XYZval& operator+=(const XYZEval &rs) { x += rs.x; y += rs.y; z += rs.z; return *this; } - FI XYZval& operator-=(const XYZEval &rs) { x -= rs.x; y -= rs.y; z -= rs.z; return *this; } - FI XYZval& operator*=(const XYZEval &rs) { x *= rs.x; y *= rs.y; z *= rs.z; return *this; } - FI XYZval& operator/=(const XYZEval &rs) { x /= rs.x; y /= rs.y; z /= rs.z; return *this; } - FI XYZval& operator*=(const float &v) { x *= v; y *= v; z *= v; return *this; } - FI XYZval& operator*=(const int &v) { x *= v; y *= v; z *= v; return *this; } - FI XYZval& operator>>=(const int &v) { _RS(x); _RS(y); _RS(z); return *this; } - FI XYZval& operator<<=(const int &v) { _LS(x); _LS(y); _LS(z); return *this; } - FI bool operator==(const XYZEval &rs) { return x == rs.x && y == rs.y && z == rs.z; } + FI XYZval& operator= (const XYZEval &rs) { set(LINEAR_AXIS_LIST(rs.x, rs.y, rs.z)); return *this; } + FI XYZval operator+ (const XYval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, NOOP ); return ls; } + FI XYZval operator+ (const XYval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, NOOP ); return ls; } + FI XYZval operator- (const XYval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, NOOP ); return ls; } + FI XYZval operator- (const XYval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, NOOP ); return ls; } + FI XYZval operator* (const XYval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, NOOP ); return ls; } + FI XYZval operator* (const XYval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, NOOP ); return ls; } + FI XYZval operator/ (const XYval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, NOOP ); return ls; } + FI XYZval operator/ (const XYval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, NOOP ); return ls; } + FI XYZval operator+ (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z); return ls; } + FI XYZval operator+ (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z); return ls; } + FI XYZval operator- (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z); return ls; } + FI XYZval operator- (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z); return ls; } + FI XYZval operator* (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z); return ls; } + FI XYZval operator* (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z); return ls; } + FI XYZval operator/ (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z); return ls; } + FI XYZval operator/ (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z); return ls; } + FI XYZval operator+ (const XYZEval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z); return ls; } + FI XYZval operator+ (const XYZEval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z); return ls; } + FI XYZval operator- (const XYZEval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z); return ls; } + FI XYZval operator- (const XYZEval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z); return ls; } + FI XYZval operator* (const XYZEval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z); return ls; } + FI XYZval operator* (const XYZEval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z); return ls; } + FI XYZval operator/ (const XYZEval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z); return ls; } + FI XYZval operator/ (const XYZEval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z); return ls; } + FI XYZval operator* (const float &v) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v ); return ls; } + FI XYZval operator* (const float &v) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v ); return ls; } + FI XYZval operator* (const int &v) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v ); return ls; } + FI XYZval operator* (const int &v) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v ); return ls; } + FI XYZval operator/ (const float &v) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v ); return ls; } + FI XYZval operator/ (const float &v) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v ); return ls; } + FI XYZval operator/ (const int &v) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v ); return ls; } + FI XYZval operator/ (const int &v) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v ); return ls; } + FI XYZval operator>>(const int &v) const { XYZval ls = *this; LINEAR_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z) ); return ls; } + FI XYZval operator>>(const int &v) { XYZval ls = *this; LINEAR_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z) ); return ls; } + FI XYZval operator<<(const int &v) const { XYZval ls = *this; LINEAR_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z) ); return ls; } + FI XYZval operator<<(const int &v) { XYZval ls = *this; LINEAR_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z) ); return ls; } + FI XYZval& operator+=(const XYval &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, NOOP ); return *this; } + FI XYZval& operator-=(const XYval &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, NOOP ); return *this; } + FI XYZval& operator*=(const XYval &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, NOOP ); return *this; } + FI XYZval& operator/=(const XYval &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, NOOP ); return *this; } + FI XYZval& operator+=(const XYZval &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z ); return *this; } + FI XYZval& operator-=(const XYZval &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z ); return *this; } + FI XYZval& operator*=(const XYZval &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z ); return *this; } + FI XYZval& operator/=(const XYZval &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z ); return *this; } + FI XYZval& operator+=(const XYZEval &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z ); return *this; } + FI XYZval& operator-=(const XYZEval &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z ); return *this; } + FI XYZval& operator*=(const XYZEval &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z ); return *this; } + FI XYZval& operator/=(const XYZEval &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z ); return *this; } + FI XYZval& operator*=(const float &v) { LINEAR_AXIS_CODE(x *= v, y *= v, z *= v ); return *this; } + FI XYZval& operator*=(const int &v) { LINEAR_AXIS_CODE(x *= v, y *= v, z *= v ); return *this; } + FI XYZval& operator>>=(const int &v) { LINEAR_AXIS_CODE(_RS(x), _RS(y), _RS(z) ); return *this; } + FI XYZval& operator<<=(const int &v) { LINEAR_AXIS_CODE(_LS(x), _LS(y), _LS(z) ); return *this; } + FI bool operator==(const XYZEval &rs) { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z); } + FI bool operator==(const XYZEval &rs) const { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z); } FI bool operator!=(const XYZEval &rs) { return !operator==(rs); } - FI bool operator==(const XYZEval &rs) const { return x == rs.x && y == rs.y && z == rs.z; } FI bool operator!=(const XYZEval &rs) const { return !operator==(rs); } - FI XYZval operator-() { XYZval o = *this; o.x = -x; o.y = -y; o.z = -z; return o; } - FI const XYZval operator-() const { XYZval o = *this; o.x = -x; o.y = -y; o.z = -z; return o; } + FI XYZval operator-() { XYZval o = *this; LINEAR_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z); return o; } + FI const XYZval operator-() const { XYZval o = *this; LINEAR_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z); return o; } }; // -// XYZE coordinates, counters, etc. +// Logical Axes coordinates, counters, etc. // template struct XYZEval { union { - struct{ T x, y, z, e; }; - struct{ T a, b, c; }; - T pos[4]; + struct{ T LOGICAL_AXIS_LIST(e, x, y, z); }; + struct{ T LINEAR_AXIS_LIST(a, b, c); }; + T pos[LOGICAL_AXES]; }; - FI void reset() { x = y = z = e = 0; } - FI T magnitude() const { return (T)sqrtf(x*x + y*y + z*z + e*e); } + FI void reset() { LOGICAL_AXIS_GANG(e =, x =, y =, z =) 0; } + FI T magnitude() const { return (T)sqrtf(LOGICAL_AXIS_GANG(+ e*e, + x*x, + y*y, + z*z)); } FI operator T* () { return pos; } - FI operator bool() { return e || z || x || y; } - FI void set(const T px) { x = px; } - FI void set(const T px, const T py) { x = px; y = py; } - FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } - FI void set(const T px, const T py, const T pz, const T pe) { x = px; y = py; z = pz; e = pe; } - FI void set(const XYval pxy) { x = pxy.x; y = pxy.y; } - FI void set(const XYval pxy, const T pz) { x = pxy.x; y = pxy.y; z = pz; } - FI void set(const XYZval pxyz) { x = pxyz.x; y = pxyz.y; z = pxyz.z; } - FI void set(const XYval pxy, const T pz, const T pe) { x = pxy.x; y = pxy.y; z = pz; e = pe; } - FI void set(const XYval pxy, const XYval pze) { x = pxy.x; y = pxy.y; z = pze.z; e = pze.e; } - FI void set(const XYZval pxyz, const T pe) { x = pxyz.x; y = pxyz.y; z = pxyz.z; e = pe; } - FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; } - FI void set(const T (&arr)[XYZ]) { x = arr[0]; y = arr[1]; z = arr[2]; } - FI void set(const T (&arr)[XYZE]) { x = arr[0]; y = arr[1]; z = arr[2]; e = arr[3]; } - #if DISTINCT_AXES > XYZE - FI void set(const T (&arr)[DISTINCT_AXES]) { x = arr[0]; y = arr[1]; z = arr[2]; e = arr[3]; } + FI operator bool() { return false LOGICAL_AXIS_GANG(|| e, || x, || y, || z); } + FI void set(const T px) { x = px; } + FI void set(const T px, const T py) { x = px; y = py; } + FI void set(const XYval pxy) { x = pxy.x; y = pxy.y; } + FI void set(const XYZval pxyz) { set(LINEAR_AXIS_LIST(pxyz.x, pxyz.y, pxyz.z)); } + #if LINEAR_AXES >= XYZ + FI void set(LINEAR_AXIS_LIST(const T px, const T py, const T pz)) { + LINEAR_AXIS_CODE(x = px, y = py, z = pz); + } #endif - FI XYZEval copy() const { return *this; } - FI XYZEval ABS() const { return { T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(e)) }; } - FI XYZEval asInt() { return { int16_t(x), int16_t(y), int16_t(z), int16_t(e) }; } - FI XYZEval asInt() const { return { int16_t(x), int16_t(y), int16_t(z), int16_t(e) }; } - FI XYZEval asLong() { return { int32_t(x), int32_t(y), int32_t(z), int32_t(e) }; } - FI XYZEval asLong() const { return { int32_t(x), int32_t(y), int32_t(z), int32_t(e) }; } - FI XYZEval ROUNDL() { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(e)) }; } - FI XYZEval ROUNDL() const { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(e)) }; } - FI XYZEval asFloat() { return { static_cast(x), static_cast(y), static_cast(z), static_cast(e) }; } - FI XYZEval asFloat() const { return { static_cast(x), static_cast(y), static_cast(z), static_cast(e) }; } - FI XYZEval reciprocal() const { return { _RECIP(x), _RECIP(y), _RECIP(z), _RECIP(e) }; } + #if LOGICAL_AXES > LINEAR_AXES + FI void set(LOGICAL_AXIS_LIST(const T pe, const T px, const T py, const T pz)) { + LOGICAL_AXIS_CODE(e = pe, x = px, y = py, z = pz); + } + FI void set(const XYval pxy, const T pe) { set(pxy); e = pe; } + FI void set(const XYZval pxyz, const T pe) { set(pxyz); e = pe; } + #endif + FI XYZEval copy() const { XYZEval o = *this; return o; } + FI XYZEval ABS() const { return LOGICAL_AXIS_ARRAY(T(_ABS(e)), T(_ABS(x)), T(_ABS(y)), T(_ABS(z))); } + FI XYZEval asInt() { return LOGICAL_AXIS_ARRAY(int16_t(e), int16_t(x), int16_t(y), int16_t(z)); } + FI XYZEval asInt() const { return LOGICAL_AXIS_ARRAY(int16_t(e), int16_t(x), int16_t(y), int16_t(z)); } + FI XYZEval asLong() { return LOGICAL_AXIS_ARRAY(int32_t(e), int32_t(x), int32_t(y), int32_t(z)); } + FI XYZEval asLong() const { return LOGICAL_AXIS_ARRAY(int32_t(e), int32_t(x), int32_t(y), int32_t(z)); } + FI XYZEval ROUNDL() { return LOGICAL_AXIS_ARRAY(int32_t(LROUND(e)), int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z))); } + FI XYZEval ROUNDL() const { return LOGICAL_AXIS_ARRAY(int32_t(LROUND(e)), int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z))); } + FI XYZEval asFloat() { return LOGICAL_AXIS_ARRAY(static_cast(e), static_cast(x), static_cast(y), static_cast(z)); } + FI XYZEval asFloat() const { return LOGICAL_AXIS_ARRAY(static_cast(e), static_cast(x), static_cast(y), static_cast(z)); } + FI XYZEval reciprocal() const { return LOGICAL_AXIS_ARRAY(_RECIP(e), _RECIP(x), _RECIP(y), _RECIP(z)); } FI XYZEval asLogical() const { XYZEval o = asFloat(); toLogical(o); return o; } FI XYZEval asNative() const { XYZEval o = asFloat(); toNative(o); return o; } FI operator XYval&() { return *(XYval*)this; } FI operator const XYval&() const { return *(const XYval*)this; } FI operator XYZval&() { return *(XYZval*)this; } FI operator const XYZval&() const { return *(const XYZval*)this; } - FI T& operator[](const int i) { return pos[i]; } - FI const T& operator[](const int i) const { return pos[i]; } - FI XYZEval& operator= (const T v) { set(v, v, v, v); return *this; } + FI T& operator[](const int n) { return pos[n]; } + FI const T& operator[](const int n) const { return pos[n]; } + FI XYZEval& operator= (const T v) { set(LIST_N_1(LINEAR_AXES, v)); return *this; } FI XYZEval& operator= (const XYval &rs) { set(rs.x, rs.y); return *this; } - FI XYZEval& operator= (const XYZval &rs) { set(rs.x, rs.y, rs.z); return *this; } - FI XYZEval operator+ (const XYval &rs) const { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } - FI XYZEval operator+ (const XYval &rs) { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } - FI XYZEval operator- (const XYval &rs) const { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } - FI XYZEval operator- (const XYval &rs) { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } - FI XYZEval operator* (const XYval &rs) const { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } - FI XYZEval operator* (const XYval &rs) { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } - FI XYZEval operator/ (const XYval &rs) const { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYZEval operator/ (const XYval &rs) { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYZEval operator+ (const XYZval &rs) const { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; } - FI XYZEval operator+ (const XYZval &rs) { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; } - FI XYZEval operator- (const XYZval &rs) const { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; } - FI XYZEval operator- (const XYZval &rs) { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; } - FI XYZEval operator* (const XYZval &rs) const { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; } - FI XYZEval operator* (const XYZval &rs) { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; } - FI XYZEval operator/ (const XYZval &rs) const { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; } - FI XYZEval operator/ (const XYZval &rs) { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; } - FI XYZEval operator+ (const XYZEval &rs) const { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; ls.e += rs.e; return ls; } - FI XYZEval operator+ (const XYZEval &rs) { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; ls.e += rs.e; return ls; } - FI XYZEval operator- (const XYZEval &rs) const { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; ls.e -= rs.e; return ls; } - FI XYZEval operator- (const XYZEval &rs) { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; ls.e -= rs.e; return ls; } - FI XYZEval operator* (const XYZEval &rs) const { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; ls.e *= rs.e; return ls; } - FI XYZEval operator* (const XYZEval &rs) { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; ls.e *= rs.e; return ls; } - FI XYZEval operator/ (const XYZEval &rs) const { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; ls.e /= rs.e; return ls; } - FI XYZEval operator/ (const XYZEval &rs) { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; ls.e /= rs.e; return ls; } - FI XYZEval operator* (const float &v) const { XYZEval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; } - FI XYZEval operator* (const float &v) { XYZEval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; } - FI XYZEval operator* (const int &v) const { XYZEval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; } - FI XYZEval operator* (const int &v) { XYZEval ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; } - FI XYZEval operator/ (const float &v) const { XYZEval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; } - FI XYZEval operator/ (const float &v) { XYZEval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; } - FI XYZEval operator/ (const int &v) const { XYZEval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; } - FI XYZEval operator/ (const int &v) { XYZEval ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; } - FI XYZEval operator>>(const int &v) const { XYZEval ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); _RS(ls.e); return ls; } - FI XYZEval operator>>(const int &v) { XYZEval ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); _RS(ls.e); return ls; } - FI XYZEval operator<<(const int &v) const { XYZEval ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); _LS(ls.e); return ls; } - FI XYZEval operator<<(const int &v) { XYZEval ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); _LS(ls.e); return ls; } - FI XYZEval& operator+=(const XYval &rs) { x += rs.x; y += rs.y; return *this; } - FI XYZEval& operator-=(const XYval &rs) { x -= rs.x; y -= rs.y; return *this; } - FI XYZEval& operator*=(const XYval &rs) { x *= rs.x; y *= rs.y; return *this; } - FI XYZEval& operator/=(const XYval &rs) { x /= rs.x; y /= rs.y; return *this; } - FI XYZEval& operator+=(const XYZval &rs) { x += rs.x; y += rs.y; z += rs.z; return *this; } - FI XYZEval& operator-=(const XYZval &rs) { x -= rs.x; y -= rs.y; z -= rs.z; return *this; } - FI XYZEval& operator*=(const XYZval &rs) { x *= rs.x; y *= rs.y; z *= rs.z; return *this; } - FI XYZEval& operator/=(const XYZval &rs) { x /= rs.x; y /= rs.y; z /= rs.z; return *this; } - FI XYZEval& operator+=(const XYZEval &rs) { x += rs.x; y += rs.y; z += rs.z; e += rs.e; return *this; } - FI XYZEval& operator-=(const XYZEval &rs) { x -= rs.x; y -= rs.y; z -= rs.z; e -= rs.e; return *this; } - FI XYZEval& operator*=(const XYZEval &rs) { x *= rs.x; y *= rs.y; z *= rs.z; e *= rs.e; return *this; } - FI XYZEval& operator/=(const XYZEval &rs) { x /= rs.x; y /= rs.y; z /= rs.z; e /= rs.e; return *this; } - FI XYZEval& operator*=(const T &v) { x *= v; y *= v; z *= v; e *= v; return *this; } - FI XYZEval& operator>>=(const int &v) { _RS(x); _RS(y); _RS(z); _RS(e); return *this; } - FI XYZEval& operator<<=(const int &v) { _LS(x); _LS(y); _LS(z); _LS(e); return *this; } - FI bool operator==(const XYZval &rs) { return x == rs.x && y == rs.y && z == rs.z; } + FI XYZEval& operator= (const XYZval &rs) { set(LINEAR_AXIS_LIST(rs.x, rs.y, rs.z)); return *this; } + FI XYZEval operator+ (const XYval &rs) const { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } + FI XYZEval operator+ (const XYval &rs) { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } + FI XYZEval operator- (const XYval &rs) const { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } + FI XYZEval operator- (const XYval &rs) { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } + FI XYZEval operator* (const XYval &rs) const { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } + FI XYZEval operator* (const XYval &rs) { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } + FI XYZEval operator/ (const XYval &rs) const { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } + FI XYZEval operator/ (const XYval &rs) { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } + FI XYZEval operator+ (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z); return ls; } + FI XYZEval operator+ (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z); return ls; } + FI XYZEval operator- (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z); return ls; } + FI XYZEval operator- (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z); return ls; } + FI XYZEval operator* (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z); return ls; } + FI XYZEval operator* (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z); return ls; } + FI XYZEval operator/ (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z); return ls; } + FI XYZEval operator/ (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z); return ls; } + FI XYZEval operator+ (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z ); return ls; } + FI XYZEval operator+ (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z ); return ls; } + FI XYZEval operator- (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z ); return ls; } + FI XYZEval operator- (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z ); return ls; } + FI XYZEval operator* (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z ); return ls; } + FI XYZEval operator* (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z ); return ls; } + FI XYZEval operator/ (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z ); return ls; } + FI XYZEval operator/ (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z ); return ls; } + FI XYZEval operator* (const float &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v ); return ls; } + FI XYZEval operator* (const float &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v ); return ls; } + FI XYZEval operator* (const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v ); return ls; } + FI XYZEval operator* (const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v ); return ls; } + FI XYZEval operator/ (const float &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v ); return ls; } + FI XYZEval operator/ (const float &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v ); return ls; } + FI XYZEval operator/ (const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v ); return ls; } + FI XYZEval operator/ (const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v ); return ls; } + FI XYZEval operator>>(const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z) ); return ls; } + FI XYZEval operator>>(const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z) ); return ls; } + FI XYZEval operator<<(const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z) ); return ls; } + FI XYZEval operator<<(const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z) ); return ls; } + FI XYZEval& operator+=(const XYval &rs) { x += rs.x; y += rs.y; return *this; } + FI XYZEval& operator-=(const XYval &rs) { x -= rs.x; y -= rs.y; return *this; } + FI XYZEval& operator*=(const XYval &rs) { x *= rs.x; y *= rs.y; return *this; } + FI XYZEval& operator/=(const XYval &rs) { x /= rs.x; y /= rs.y; return *this; } + FI XYZEval& operator+=(const XYZval &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z); return *this; } + FI XYZEval& operator-=(const XYZval &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z); return *this; } + FI XYZEval& operator*=(const XYZval &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z); return *this; } + FI XYZEval& operator/=(const XYZval &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z); return *this; } + FI XYZEval& operator+=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e += rs.e, x += rs.x, y += rs.y, z += rs.z); return *this; } + FI XYZEval& operator-=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e -= rs.e, x -= rs.x, y -= rs.y, z -= rs.z); return *this; } + FI XYZEval& operator*=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e *= rs.e, x *= rs.x, y *= rs.y, z *= rs.z); return *this; } + FI XYZEval& operator/=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e /= rs.e, x /= rs.x, y /= rs.y, z /= rs.z); return *this; } + FI XYZEval& operator*=(const T &v) { LOGICAL_AXIS_CODE(e *= v, x *= v, y *= v, z *= v); return *this; } + FI XYZEval& operator>>=(const int &v) { LOGICAL_AXIS_CODE(_RS(e), _RS(x), _RS(y), _RS(z)); return *this; } + FI XYZEval& operator<<=(const int &v) { LOGICAL_AXIS_CODE(_LS(e), _LS(x), _LS(y), _LS(z)); return *this; } + FI bool operator==(const XYZval &rs) { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z); } + FI bool operator==(const XYZval &rs) const { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z); } FI bool operator!=(const XYZval &rs) { return !operator==(rs); } - FI bool operator==(const XYZval &rs) const { return x == rs.x && y == rs.y && z == rs.z; } FI bool operator!=(const XYZval &rs) const { return !operator==(rs); } - FI XYZEval operator-() { return { -x, -y, -z, -e }; } - FI const XYZEval operator-() const { return { -x, -y, -z, -e }; } + FI XYZEval operator-() { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z); } + FI const XYZEval operator-() const { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z); } }; #undef _RECIP @@ -514,6 +573,3 @@ struct XYZEval { #undef _LS #undef _RS #undef FI - -const xyze_char_t axis_codes { 'X', 'Y', 'Z', 'E' }; -#define AXIS_CHAR(A) ((char)('X' + A)) diff --git a/Marlin/src/core/utility.h b/Marlin/src/core/utility.h index d774b007b6d5..31d0ac6ef40a 100644 --- a/Marlin/src/core/utility.h +++ b/Marlin/src/core/utility.h @@ -76,3 +76,11 @@ class restorer { // Converts from an uint8_t in the range of 0-255 to an uint8_t // in the range 0-100 while avoiding rounding artifacts constexpr uint8_t ui8_to_percent(const uint8_t i) { return (int(i) * 100 + 127) / 255; } + +const xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z'); + +#if LINEAR_AXES <= XYZ + #define AXIS_CHAR(A) ((char)('X' + A)) +#else + #define AXIS_CHAR(A) axis_codes[A] +#endif diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index d6c88613fd81..c6881591b6b9 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -327,7 +327,7 @@ int32_t I2CPositionEncoder::get_raw_count() { } bool I2CPositionEncoder::test_axis() { - //only works on XYZ cartesian machines for the time being + // Only works on XYZ Cartesian machines for the time being if (!(encoderAxis == X_AXIS || encoderAxis == Y_AXIS || encoderAxis == Z_AXIS)) return false; const float startPosition = soft_endstop.min[encoderAxis] + 10, @@ -344,11 +344,14 @@ bool I2CPositionEncoder::test_axis() { startCoord[encoderAxis] = startPosition; endCoord[encoderAxis] = endPosition; - planner.synchronize(); - startCoord.e = planner.get_axis_position_mm(E_AXIS); - planner.buffer_line(startCoord, fr_mm_s, 0); planner.synchronize(); + #if HAS_EXTRUDERS + startCoord.e = planner.get_axis_position_mm(E_AXIS); + planner.buffer_line(startCoord, fr_mm_s, 0); + planner.synchronize(); + #endif + // if the module isn't currently trusted, wait until it is (or until it should be if things are working) if (!trusted) { int32_t startWaitingTime = millis(); @@ -357,7 +360,7 @@ bool I2CPositionEncoder::test_axis() { } if (trusted) { // if trusted, commence test - endCoord.e = planner.get_axis_position_mm(E_AXIS); + TERN_(HAS_EXTRUDERS, endCoord.e = planner.get_axis_position_mm(E_AXIS)); planner.buffer_line(endCoord, fr_mm_s, 0); planner.synchronize(); } @@ -402,7 +405,7 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) { planner.synchronize(); LOOP_L_N(i, iter) { - startCoord.e = planner.get_axis_position_mm(E_AXIS); + TERN_(HAS_EXTRUDERS, startCoord.e = planner.get_axis_position_mm(E_AXIS)); planner.buffer_line(startCoord, fr_mm_s, 0); planner.synchronize(); @@ -411,7 +414,7 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) { //do_blocking_move_to(endCoord); - endCoord.e = planner.get_axis_position_mm(E_AXIS); + TERN_(HAS_EXTRUDERS, endCoord.e = planner.get_axis_position_mm(E_AXIS)); planner.buffer_line(endCoord, fr_mm_s, 0); planner.synchronize(); @@ -497,9 +500,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_active(encoders[i].passes_test(true)); - #if I2CPE_ENC_1_AXIS == E_AXIS - encoders[i].set_homed(); - #endif + TERN_(HAS_EXTRUDERS, if (I2CPE_ENC_1_AXIS == E_AXIS) encoders[i].set_homed()); #endif #if I2CPE_ENCODER_CNT > 1 @@ -528,9 +529,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_active(encoders[i].passes_test(true)); - #if I2CPE_ENC_2_AXIS == E_AXIS - encoders[i].set_homed(); - #endif + TERN_(HAS_EXTRUDERS, if (I2CPE_ENC_2_AXIS == E_AXIS) encoders[i].set_homed()); #endif #if I2CPE_ENCODER_CNT > 2 @@ -557,11 +556,9 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_ec_threshold(I2CPE_ENC_3_EC_THRESH); #endif - encoders[i].set_active(encoders[i].passes_test(true)); + encoders[i].set_active(encoders[i].passes_test(true)); - #if I2CPE_ENC_3_AXIS == E_AXIS - encoders[i].set_homed(); - #endif + TERN_(HAS_EXTRUDERS, if (I2CPE_ENC_3_AXIS == E_AXIS) encoders[i].set_homed()); #endif #if I2CPE_ENCODER_CNT > 3 @@ -590,9 +587,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_active(encoders[i].passes_test(true)); - #if I2CPE_ENC_4_AXIS == E_AXIS - encoders[i].set_homed(); - #endif + TERN_(HAS_EXTRUDERS, if (I2CPE_ENC_4_AXIS == E_AXIS) encoders[i].set_homed()); #endif #if I2CPE_ENCODER_CNT > 4 @@ -621,9 +616,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_active(encoders[i].passes_test(true)); - #if I2CPE_ENC_5_AXIS == E_AXIS - encoders[i].set_homed(); - #endif + TERN_(HAS_EXTRUDERS, if (I2CPE_ENC_5_AXIS == E_AXIS) encoders[i].set_homed()); #endif #if I2CPE_ENCODER_CNT > 5 @@ -652,9 +645,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_active(encoders[i].passes_test(true)); - #if I2CPE_ENC_6_AXIS == E_AXIS - encoders[i].set_homed(); - #endif + TERN_(HAS_EXTRUDERS, if (I2CPE_ENC_6_AXIS == E_AXIS) encoders[i].set_homed()); #endif } diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index 9c4fbf08dfc8..e244a33eee46 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -757,7 +757,10 @@ } } - static void tmc_debug_loop(const TMC_debug_enum i, const bool print_x, const bool print_y, const bool print_z, const bool print_e) { + static void tmc_debug_loop( + const TMC_debug_enum i, + LOGICAL_AXIS_LIST(const bool print_e, const bool print_x, const bool print_y, const bool print_z) + ) { if (print_x) { #if AXIS_IS_TMC(X) tmc_status(stepperX, i); @@ -821,7 +824,10 @@ SERIAL_EOL(); } - static void drv_status_loop(const TMC_drv_status_enum i, const bool print_x, const bool print_y, const bool print_z, const bool print_e) { + static void drv_status_loop( + const TMC_drv_status_enum i, + LOGICAL_AXIS_LIST(const bool print_e, const bool print_x, const bool print_y, const bool print_z) + ) { if (print_x) { #if AXIS_IS_TMC(X) tmc_parse_drv_status(stepperX, i); @@ -889,9 +895,12 @@ * M122 report functions */ - void tmc_report_all(const bool print_x/*=true*/, const bool print_y/*=true*/, const bool print_z/*=true*/, const bool print_e/*=true*/) { - #define TMC_REPORT(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); tmc_debug_loop(ITEM, print_x, print_y, print_z, print_e); }while(0) - #define DRV_REPORT(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); drv_status_loop(ITEM, print_x, print_y, print_z, print_e); }while(0) + void tmc_report_all( + LOGICAL_AXIS_LIST(const bool print_e/*=true*/, const bool print_x/*=true*/, const bool print_y/*=true*/, const bool print_z/*=true*/) + ) { + #define TMC_REPORT(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); tmc_debug_loop(ITEM, LOGICAL_AXIS_LIST(print_e, print_x, print_y, print_z)); }while(0) + #define DRV_REPORT(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); drv_status_loop(ITEM, LOGICAL_AXIS_LIST(print_e, print_x, print_y, print_z)); }while(0) + TMC_REPORT("\t", TMC_CODES); #if HAS_DRIVER(TMC2209) TMC_REPORT("Address\t", TMC_UART_ADDR); @@ -1015,7 +1024,10 @@ } #endif - static void tmc_get_registers(TMC_get_registers_enum i, const bool print_x, const bool print_y, const bool print_z, const bool print_e) { + static void tmc_get_registers( + TMC_get_registers_enum i, + LOGICAL_AXIS_LIST(const bool print_e, const bool print_x, const bool print_y, const bool print_z) + ) { if (print_x) { #if AXIS_IS_TMC(X) tmc_get_registers(stepperX, i); @@ -1079,8 +1091,10 @@ SERIAL_EOL(); } - void tmc_get_registers(bool print_x, bool print_y, bool print_z, bool print_e) { - #define _TMC_GET_REG(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); tmc_get_registers(ITEM, print_x, print_y, print_z, print_e); }while(0) + void tmc_get_registers( + LOGICAL_AXIS_LIST(bool print_e, bool print_x, bool print_y, bool print_z) + ) { + #define _TMC_GET_REG(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); tmc_get_registers(ITEM, LOGICAL_AXIS_LIST(print_e, print_x, print_y, print_z)); }while(0) #define TMC_GET_REG(NAME, TABS) _TMC_GET_REG(STRINGIFY(NAME) TABS, TMC_GET_##NAME) _TMC_GET_REG("\t", TMC_AXIS_CODES); TMC_GET_REG(GCONF, "\t\t"); @@ -1214,7 +1228,9 @@ static bool test_connection(TMC &st) { return test_result; } -void test_tmc_connection(const bool test_x/*=true*/, const bool test_y/*=true*/, const bool test_z/*=true*/, const bool test_e/*=true*/) { +void test_tmc_connection( + LOGICAL_AXIS_LIST(const bool test_e/*=true*/, const bool test_x/*=true*/, const bool test_y/*=true*/, const bool test_z/*=true*/) +) { uint8_t axis_connection = 0; if (test_x) { diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index 179f38f72998..a07d6ce0ee17 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -335,14 +335,20 @@ void tmc_print_current(TMC &st) { #endif void monitor_tmc_drivers(); -void test_tmc_connection(const bool test_x=true, const bool test_y=true, const bool test_z=true, const bool test_e=true); +void test_tmc_connection( + LOGICAL_AXIS_LIST(const bool test_e=true, const bool test_x=true, const bool test_y=true, const bool test_z=true) +); #if ENABLED(TMC_DEBUG) #if ENABLED(MONITOR_DRIVER_STATUS) void tmc_set_report_interval(const uint16_t update_interval); #endif - void tmc_report_all(const bool print_x=true, const bool print_y=true, const bool print_z=true, const bool print_e=true); - void tmc_get_registers(const bool print_x, const bool print_y, const bool print_z, const bool print_e); + void tmc_report_all( + LOGICAL_AXIS_LIST(const bool print_e=true, const bool print_x=true, const bool print_y=true, const bool print_z=true) + ); + void tmc_get_registers( + LOGICAL_AXIS_LIST(const bool print_e, const bool print_x, const bool print_y, const bool print_z) + ); #endif /** @@ -355,7 +361,7 @@ void test_tmc_connection(const bool test_x=true, const bool test_y=true, const b #if USE_SENSORLESS // Track enabled status of stealthChop and only re-enable where applicable - struct sensorless_t { bool x, y, z, x2, y2, z2, z3, z4; }; + struct sensorless_t { bool LINEAR_AXIS_LIST(x, y, z), x2, y2, z2, z3, z4; }; #if ENABLED(IMPROVE_HOMING_RELIABILITY) extern millis_t sg_guard_period; diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index aacfcfa42f5a..a71f5415935d 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -321,12 +321,23 @@ void GcodeSuite::G28() { #else + #define _UNSAFE(A) (homeZ && TERN0(Z_SAFE_HOMING, axes_should_home(_BV(A##_AXIS)))) + const bool homeZ = parser.seen_test('Z'), - needX = homeZ && TERN0(Z_SAFE_HOMING, axes_should_home(_BV(X_AXIS))), - needY = homeZ && TERN0(Z_SAFE_HOMING, axes_should_home(_BV(Y_AXIS))), - homeX = needX || parser.seen_test('X'), homeY = needY || parser.seen_test('Y'), - home_all = homeX == homeY && homeX == homeZ, // All or None - doX = home_all || homeX, doY = home_all || homeY, doZ = home_all || homeZ; + LINEAR_AXIS_LIST( // Other axes should be homed before Z safe-homing + needX = _UNSAFE(X), needY = _UNSAFE(Y), needZ = false // UNUSED + ), + LINEAR_AXIS_LIST( // Home each axis if needed or flagged + homeX = needX || parser.seen_test('X'), + homeY = needY || parser.seen_test('Y'), + homeZZ = homeZ // UNUSED + ), + // Home-all if all or none are flagged + home_all = true LINEAR_AXIS_GANG(&& homeX == homeX, && homeX == homeY, && homeX == homeZ), + LINEAR_AXIS_LIST(doX = home_all || homeX, doY = home_all || homeY, doZ = home_all || homeZ); + + UNUSED(needZ); + UNUSED(homeZZ); #if ENABLED(HOME_Z_FIRST) @@ -336,7 +347,7 @@ void GcodeSuite::G28() { const float z_homing_height = parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT; - if (z_homing_height && (doX || doY || TERN0(Z_SAFE_HOMING, doZ))) { + if (z_homing_height && (0 LINEAR_AXIS_GANG(|| doX, || doY, || TERN0(Z_SAFE_HOMING, doZ)))) { // Raise Z before homing any other axes and z is not already high enough (never lower z) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) by ", z_homing_height); do_z_clearance(z_homing_height); @@ -469,7 +480,7 @@ void GcodeSuite::G28() { #if HAS_CURRENT_HOME(Y2) stepperY2.rms_current(tmc_save_current_Y2); #endif - #endif + #endif // HAS_HOMING_CURRENT ui.refresh(); @@ -490,7 +501,7 @@ void GcodeSuite::G28() { static constexpr AxisEnum L64XX_axis_xref[MAX_L64XX] = { X_AXIS, Y_AXIS, Z_AXIS, X_AXIS, Y_AXIS, Z_AXIS, Z_AXIS, - E_AXIS, E_AXIS, E_AXIS, E_AXIS, E_AXIS, E_AXIS + E_AXIS, E_AXIS, E_AXIS, E_AXIS, E_AXIS, E_AXIS, E_AXIS, E_AXIS }; for (uint8_t j = 1; j <= L64XX::chain[0]; j++) { const uint8_t cv = L64XX::chain[j]; diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index 2fb450226797..723f1ebd7b96 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -307,9 +307,11 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { // The difference between the known and the measured location // of the calibration object is the positional error - m.pos_error.x = TERN0(HAS_X_CENTER, true_center.x - m.obj_center.x); - m.pos_error.y = TERN0(HAS_Y_CENTER, true_center.y - m.obj_center.y); - m.pos_error.z = true_center.z - m.obj_center.z; + LINEAR_AXIS_CODE( + m.pos_error.x = TERN0(HAS_X_CENTER, true_center.x - m.obj_center.x), + m.pos_error.y = TERN0(HAS_Y_CENTER, true_center.y - m.obj_center.y), + m.pos_error.z = true_center.z - m.obj_center.z + ); } #if ENABLED(CALIBRATION_REPORTING) @@ -455,7 +457,9 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) { // New scope for TEMPORARY_BACKLASH_CORRECTION TEMPORARY_BACKLASH_CORRECTION(all_on); TEMPORARY_BACKLASH_SMOOTHING(0.0f); - const xyz_float_t move = { AXIS_CAN_CALIBRATE(X) * 3, AXIS_CAN_CALIBRATE(Y) * 3, AXIS_CAN_CALIBRATE(Z) * 3 }; + const xyz_float_t move = LINEAR_AXIS_ARRAY( + AXIS_CAN_CALIBRATE(X) * 3, AXIS_CAN_CALIBRATE(Y) * 3, AXIS_CAN_CALIBRATE(Z) * 3 + ); current_position += move; calibration_move(); current_position -= move; calibration_move(); } diff --git a/Marlin/src/gcode/calibrate/M425.cpp b/Marlin/src/gcode/calibrate/M425.cpp index 432144f491c0..7de33c1f2a9d 100644 --- a/Marlin/src/gcode/calibrate/M425.cpp +++ b/Marlin/src/gcode/calibrate/M425.cpp @@ -48,10 +48,12 @@ void GcodeSuite::M425() { auto axis_can_calibrate = [](const uint8_t a) { switch (a) { - default: - case X_AXIS: return AXIS_CAN_CALIBRATE(X); - case Y_AXIS: return AXIS_CAN_CALIBRATE(Y); - case Z_AXIS: return AXIS_CAN_CALIBRATE(Z); + default: return false; + LINEAR_AXIS_CODE( + case X_AXIS: return AXIS_CAN_CALIBRATE(X), + case Y_AXIS: return AXIS_CAN_CALIBRATE(Y), + case Z_AXIS: return AXIS_CAN_CALIBRATE(Z) + ); } }; diff --git a/Marlin/src/gcode/config/M200-M205.cpp b/Marlin/src/gcode/config/M200-M205.cpp index 06751f41c499..e765fd55b22d 100644 --- a/Marlin/src/gcode/config/M200-M205.cpp +++ b/Marlin/src/gcode/config/M200-M205.cpp @@ -88,7 +88,7 @@ void GcodeSuite::M201() { LOOP_LOGICAL_AXES(i) { if (parser.seenval(axis_codes[i])) { - const uint8_t a = (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i); + const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i); planner.set_max_acceleration(a, parser.value_axis_units((AxisEnum)a)); } } @@ -106,7 +106,7 @@ void GcodeSuite::M203() { LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) { - const uint8_t a = (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i); + const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i); planner.set_max_feedrate(a, parser.value_axis_units((AxisEnum)a)); } } @@ -165,17 +165,16 @@ void GcodeSuite::M205() { } #endif #if HAS_CLASSIC_JERK - if (parser.seenval('X')) planner.set_max_jerk(X_AXIS, parser.value_linear_units()); - if (parser.seenval('Y')) planner.set_max_jerk(Y_AXIS, parser.value_linear_units()); - if (parser.seenval('Z')) { - planner.set_max_jerk(Z_AXIS, parser.value_linear_units()); - #if HAS_MESH && DISABLED(LIMITED_JERK_EDITING) - if (planner.max_jerk.z <= 0.1f) - SERIAL_ECHOLNPGM("WARNING! Low Z Jerk may lead to unwanted pauses."); - #endif - } - #if HAS_CLASSIC_E_JERK - if (parser.seenval('E')) planner.set_max_jerk(E_AXIS, parser.value_linear_units()); + bool seenZ = false; + LOGICAL_AXIS_CODE( + if (parser.seenval('E')) planner.set_max_jerk(E_AXIS, parser.value_linear_units()), + if (parser.seenval('X')) planner.set_max_jerk(X_AXIS, parser.value_linear_units()), + if (parser.seenval('Y')) planner.set_max_jerk(Y_AXIS, parser.value_linear_units()), + if ((seenZ = parser.seenval('Z'))) planner.set_max_jerk(Z_AXIS, parser.value_linear_units()) + ); + #if HAS_MESH && DISABLED(LIMITED_JERK_EDITING) + if (seenZ && planner.max_jerk.z <= 0.1f) + SERIAL_ECHOLNPGM("WARNING! Low Z Jerk may lead to unwanted pauses."); #endif - #endif + #endif // HAS_CLASSIC_JERK } diff --git a/Marlin/src/gcode/config/M92.cpp b/Marlin/src/gcode/config/M92.cpp index 06c47b825334..100cf96f151b 100644 --- a/Marlin/src/gcode/config/M92.cpp +++ b/Marlin/src/gcode/config/M92.cpp @@ -25,10 +25,12 @@ void report_M92(const bool echo=true, const int8_t e=-1) { if (echo) SERIAL_ECHO_START(); else SERIAL_CHAR(' '); - SERIAL_ECHOPAIR_P(PSTR(" M92 X"), LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]), - SP_Y_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]), - SP_Z_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Z_AXIS])); - #if DISABLED(DISTINCT_E_FACTORS) + SERIAL_ECHOPAIR_P(LIST_N(DOUBLE(LINEAR_AXES), + PSTR(" M92 X"), LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]), + SP_Y_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]), + SP_Z_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Z_AXIS]) + )); + #if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS) SERIAL_ECHOPAIR_P(SP_E_STR, VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS])); #endif SERIAL_EOL(); @@ -64,25 +66,28 @@ void GcodeSuite::M92() { if (target_extruder < 0) return; // No arguments? Show M92 report. - if (!parser.seen("XYZE" TERN_(MAGIC_NUMBERS_GCODE, "HL"))) - return report_M92(true, target_extruder); + if (!parser.seen( + LOGICAL_AXIS_GANG("E", "X", "Y", "Z") + TERN_(MAGIC_NUMBERS_GCODE, "HL") + )) return report_M92(true, target_extruder); LOOP_LOGICAL_AXES(i) { if (parser.seenval(axis_codes[i])) { - if (i == E_AXIS) { - const float value = parser.value_per_axis_units((AxisEnum)(E_AXIS_N(target_extruder))); - if (value < 20) { - float factor = planner.settings.axis_steps_per_mm[E_AXIS_N(target_extruder)] / value; // increase e constants if M92 E14 is given for netfab. - #if HAS_CLASSIC_JERK && HAS_CLASSIC_E_JERK - planner.max_jerk.e *= factor; - #endif - planner.settings.max_feedrate_mm_s[E_AXIS_N(target_extruder)] *= factor; - planner.max_acceleration_steps_per_s2[E_AXIS_N(target_extruder)] *= factor; - } - planner.settings.axis_steps_per_mm[E_AXIS_N(target_extruder)] = value; - } - else { + if (TERN1(HAS_EXTRUDERS, i != E_AXIS)) planner.settings.axis_steps_per_mm[i] = parser.value_per_axis_units((AxisEnum)i); + else { + #if HAS_EXTRUDERS + const float value = parser.value_per_axis_units((AxisEnum)(E_AXIS_N(target_extruder))); + if (value < 20) { + float factor = planner.settings.axis_steps_per_mm[E_AXIS_N(target_extruder)] / value; // increase e constants if M92 E14 is given for netfab. + #if HAS_CLASSIC_JERK && HAS_CLASSIC_E_JERK + planner.max_jerk.e *= factor; + #endif + planner.settings.max_feedrate_mm_s[E_AXIS_N(target_extruder)] *= factor; + planner.max_acceleration_steps_per_s2[E_AXIS_N(target_extruder)] *= factor; + } + planner.settings.axis_steps_per_mm[E_AXIS_N(target_extruder)] = value; + #endif } } } diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index f02508a90171..b7cec2d48df5 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -33,11 +33,13 @@ * M17: Enable stepper motors */ void GcodeSuite::M17() { - if (parser.seen("XYZE")) { - if (parser.seen_test('X')) ENABLE_AXIS_X(); - if (parser.seen_test('Y')) ENABLE_AXIS_Y(); - if (parser.seen_test('Z')) ENABLE_AXIS_Z(); - if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen_test('E'))) enable_e_steppers(); + if (parser.seen(LOGICAL_AXIS_GANG("E", "X", "Y", "Z"))) { + LOGICAL_AXIS_CODE( + if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen_test('E'))) enable_e_steppers(), + if (parser.seen_test('X')) ENABLE_AXIS_X(), + if (parser.seen_test('Y')) ENABLE_AXIS_Y(), + if (parser.seen_test('Z')) ENABLE_AXIS_Z() + ); } else { LCD_MESSAGEPGM(MSG_NO_MOVE); @@ -54,12 +56,14 @@ void GcodeSuite::M18_M84() { stepper_inactive_time = parser.value_millis_from_seconds(); } else { - if (parser.seen("XYZE")) { + if (parser.seen(LOGICAL_AXIS_GANG("E", "X", "Y", "Z"))) { planner.synchronize(); - if (parser.seen_test('X')) DISABLE_AXIS_X(); - if (parser.seen_test('Y')) DISABLE_AXIS_Y(); - if (parser.seen_test('Z')) DISABLE_AXIS_Z(); - if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen_test('E'))) disable_e_steppers(); + LOGICAL_AXIS_CODE( + if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen_test('E'))) disable_e_steppers(), + if (parser.seen_test('X')) DISABLE_AXIS_X(), + if (parser.seen_test('Y')) DISABLE_AXIS_Y(), + if (parser.seen_test('Z')) DISABLE_AXIS_Z() + ); } else planner.finish_and_disable(); diff --git a/Marlin/src/gcode/feature/pause/G61.cpp b/Marlin/src/gcode/feature/pause/G61.cpp index a6d7cb3094c4..14a2e649695b 100644 --- a/Marlin/src/gcode/feature/pause/G61.cpp +++ b/Marlin/src/gcode/feature/pause/G61.cpp @@ -69,7 +69,7 @@ void GcodeSuite::G61(void) { SYNC_E(stored_position[slot].e); } else { - if (parser.seen("XYZ")) { + if (parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z"))) { DEBUG_ECHOPAIR(STR_RESTORING_POS " S", slot); LOOP_LINEAR_AXES(i) { destination[i] = parser.seen(AXIS_CHAR(i)) @@ -82,10 +82,12 @@ void GcodeSuite::G61(void) { // Move to the saved position prepare_line_to_destination(); } - if (parser.seen_test('E')) { - DEBUG_ECHOLNPAIR(STR_RESTORING_POS " S", slot, " E", current_position.e, "=>", stored_position[slot].e); - SYNC_E(stored_position[slot].e); - } + #if HAS_EXTRUDERS + if (parser.seen_test('E')) { + DEBUG_ECHOLNPAIR(STR_RESTORING_POS " S", slot, " E", current_position.e, "=>", stored_position[slot].e); + SYNC_E(stored_position[slot].e); + } + #endif } feedrate_mm_s = saved_feedrate; diff --git a/Marlin/src/gcode/feature/trinamic/M122.cpp b/Marlin/src/gcode/feature/trinamic/M122.cpp index 054d145c8c23..3b4406705c17 100644 --- a/Marlin/src/gcode/feature/trinamic/M122.cpp +++ b/Marlin/src/gcode/feature/trinamic/M122.cpp @@ -49,13 +49,21 @@ void GcodeSuite::M122() { tmc_set_report_interval(interval); #endif - if (parser.seen_test('V')) - tmc_get_registers(print_axis.x, print_axis.y, print_axis.z, print_axis.e); - else - tmc_report_all(print_axis.x, print_axis.y, print_axis.z, print_axis.e); + if (parser.seen_test('V')) { + tmc_get_registers( + LOGICAL_AXIS_LIST(print_axis.e, print_axis.x, print_axis.y, print_axis.z) + ); + } + else { + tmc_report_all( + LOGICAL_AXIS_LIST(print_axis.e, print_axis.x, print_axis.y, print_axis.z) + ); + } #endif - test_tmc_connection(print_axis.x, print_axis.y, print_axis.z, print_axis.e); + test_tmc_connection( + LOGICAL_AXIS_LIST(print_axis.e, print_axis.x, print_axis.y, print_axis.z) + ); } #endif // HAS_TRINAMIC_CONFIG diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 29dbf8d1c2dd..b7a842ece745 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -74,11 +74,11 @@ millis_t GcodeSuite::previous_move_ms = 0, // Relative motion mode for each logical axis static constexpr xyze_bool_t ar_init = AXIS_RELATIVE_MODES; -uint8_t GcodeSuite::axis_relative = ( - (ar_init.x ? _BV(REL_X) : 0) - | (ar_init.y ? _BV(REL_Y) : 0) - | (ar_init.z ? _BV(REL_Z) : 0) - | (ar_init.e ? _BV(REL_E) : 0) +uint8_t GcodeSuite::axis_relative = 0 LOGICAL_AXIS_GANG( + | (ar_init.e << REL_E), + | (ar_init.x << REL_X), + | (ar_init.y << REL_Y), + | (ar_init.z << REL_Z) ); #if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE) @@ -161,13 +161,15 @@ void GcodeSuite::get_destination_from_command() { destination[i] = current_position[i]; } - // Get new E position, whether absolute or relative - if ( (seen.e = parser.seenval('E')) ) { - const float v = parser.value_axis_units(E_AXIS); - destination.e = axis_is_relative(E_AXIS) ? current_position.e + v : v; - } - else - destination.e = current_position.e; + #if HAS_EXTRUDERS + // Get new E position, whether absolute or relative + if ( (seen.e = parser.seenval('E')) ) { + const float v = parser.value_axis_units(E_AXIS); + destination.e = axis_is_relative(E_AXIS) ? current_position.e + v : v; + } + else + destination.e = current_position.e; + #endif #if ENABLED(POWER_LOSS_RECOVERY) && !PIN_EXISTS(POWER_LOSS) // Only update power loss recovery on moves with E diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index befc328bb974..05b6c0cdd52c 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -314,7 +314,12 @@ #define HAS_FAST_MOVES 1 #endif -enum AxisRelative : uint8_t { REL_X, REL_Y, REL_Z, REL_E, E_MODE_ABS, E_MODE_REL }; +enum AxisRelative : uint8_t { + LOGICAL_AXIS_LIST(REL_E, REL_X, REL_Y, REL_Z) + #if HAS_EXTRUDERS + , E_MODE_ABS, E_MODE_REL + #endif +}; extern const char G28_STR[]; @@ -324,23 +329,27 @@ class GcodeSuite { static uint8_t axis_relative; static inline bool axis_is_relative(const AxisEnum a) { - if (a == E_AXIS) { - if (TEST(axis_relative, E_MODE_REL)) return true; - if (TEST(axis_relative, E_MODE_ABS)) return false; - } + #if HAS_EXTRUDERS + if (a == E_AXIS) { + if (TEST(axis_relative, E_MODE_REL)) return true; + if (TEST(axis_relative, E_MODE_ABS)) return false; + } + #endif return TEST(axis_relative, a); } static inline void set_relative_mode(const bool rel) { - axis_relative = rel ? _BV(REL_X) | _BV(REL_Y) | _BV(REL_Z) | _BV(REL_E) : 0; - } - static inline void set_e_relative() { - CBI(axis_relative, E_MODE_ABS); - SBI(axis_relative, E_MODE_REL); - } - static inline void set_e_absolute() { - CBI(axis_relative, E_MODE_REL); - SBI(axis_relative, E_MODE_ABS); + axis_relative = rel ? (0 LOGICAL_AXIS_GANG(| _BV(REL_E), | _BV(REL_X), | _BV(REL_Y), | _BV(REL_Z))) : 0; } + #if HAS_EXTRUDERS + static inline void set_e_relative() { + CBI(axis_relative, E_MODE_ABS); + SBI(axis_relative, E_MODE_REL); + } + static inline void set_e_absolute() { + CBI(axis_relative, E_MODE_REL); + SBI(axis_relative, E_MODE_ABS); + } + #endif #if ENABLED(CNC_WORKSPACE_PLANES) /** diff --git a/Marlin/src/gcode/geometry/G92.cpp b/Marlin/src/gcode/geometry/G92.cpp index a9970b1e9c09..990236c0e878 100644 --- a/Marlin/src/gcode/geometry/G92.cpp +++ b/Marlin/src/gcode/geometry/G92.cpp @@ -48,7 +48,10 @@ */ void GcodeSuite::G92() { - bool sync_E = false, sync_XYZE = false; + #if HAS_EXTRUDERS + bool sync_E = false; + #endif + bool sync_XYZE = false; #if USE_GCODE_SUBCODES const uint8_t subcode_G92 = parser.subcode; @@ -72,7 +75,11 @@ void GcodeSuite::G92() { case 9: // G92.9 - Set Current Position directly (like Marlin 1.0) LOOP_LOGICAL_AXES(i) { if (parser.seenval(axis_codes[i])) { - if (i == E_AXIS) sync_E = true; else sync_XYZE = true; + if (TERN1(HAS_EXTRUDERS, i != E_AXIS)) + sync_XYZE = true; + else { + TERN_(HAS_EXTRUDERS, sync_E = true); + } current_position[i] = parser.value_axis_units((AxisEnum)i); } } @@ -83,20 +90,26 @@ void GcodeSuite::G92() { LOOP_LOGICAL_AXES(i) { if (parser.seenval(axis_codes[i])) { const float l = parser.value_axis_units((AxisEnum)i), // Given axis coordinate value, converted to millimeters - v = i == E_AXIS ? l : LOGICAL_TO_NATIVE(l, i), // Axis position in NATIVE space (applying the existing offset) + v = TERN0(HAS_EXTRUDERS, i == E_AXIS) ? l : LOGICAL_TO_NATIVE(l, i), // Axis position in NATIVE space (applying the existing offset) d = v - current_position[i]; // How much is the current axis position altered by? if (!NEAR_ZERO(d)) { #if HAS_POSITION_SHIFT && !IS_SCARA // When using workspaces... - if (i == E_AXIS) { - sync_E = true; - current_position.e = v; // ...E is still set directly + if (TERN1(HAS_EXTRUDERS, i != E_AXIS)) { + position_shift[i] += d; // ...most axes offset the workspace... + update_workspace_offset((AxisEnum)i); } else { - position_shift[i] += d; // ...but other axes offset the workspace. - update_workspace_offset((AxisEnum)i); + #if HAS_EXTRUDERS + sync_E = true; + current_position.e = v; // ...but E is set directly + #endif } #else // Without workspaces... - if (i == E_AXIS) sync_E = true; else sync_XYZE = true; + if (TERN1(HAS_EXTRUDERS, i != E_AXIS)) + sync_XYZE = true; + else { + TERN_(HAS_EXTRUDERS, sync_E = true); + } current_position[i] = v; // ...set Current Position directly (like Marlin 1.0) #endif } @@ -111,8 +124,10 @@ void GcodeSuite::G92() { coordinate_system[active_coordinate_system] = position_shift; #endif - if (sync_XYZE) sync_plan_position(); - else if (sync_E) sync_plan_position_e(); + if (sync_XYZE) sync_plan_position(); + #if HAS_EXTRUDERS + else if (sync_E) sync_plan_position_e(); + #endif IF_DISABLED(DIRECT_STEPPING, report_current_position()); } diff --git a/Marlin/src/gcode/host/M114.cpp b/Marlin/src/gcode/host/M114.cpp index 2d43d33aa122..d28373696ad2 100644 --- a/Marlin/src/gcode/host/M114.cpp +++ b/Marlin/src/gcode/host/M114.cpp @@ -170,7 +170,7 @@ SERIAL_ECHOPGM("FromStp:"); get_cartesian_from_steppers(); // writes 'cartes' (with forward kinematics) - xyze_pos_t from_steppers = { cartes.x, cartes.y, cartes.z, planner.get_axis_position_mm(E_AXIS) }; + xyze_pos_t from_steppers = LOGICAL_AXIS_ARRAY(planner.get_axis_position_mm(E_AXIS), cartes.x, cartes.y, cartes.z); report_all_axis_pos(from_steppers); const xyze_float_t diff = from_steppers - leveled; diff --git a/Marlin/src/gcode/motion/G0_G1.cpp b/Marlin/src/gcode/motion/G0_G1.cpp index 73c5b1171422..30f824803772 100644 --- a/Marlin/src/gcode/motion/G0_G1.cpp +++ b/Marlin/src/gcode/motion/G0_G1.cpp @@ -49,9 +49,11 @@ void GcodeSuite::G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move/*=false*/)) { if (IsRunning() #if ENABLED(NO_MOTION_BEFORE_HOMING) && !homing_needed_error( - (parser.seen_test('X') ? _BV(X_AXIS) : 0) - | (parser.seen_test('Y') ? _BV(Y_AXIS) : 0) - | (parser.seen_test('Z') ? _BV(Z_AXIS) : 0) ) + LINEAR_AXIS_GANG( + (parser.seen_test('X') ? _BV(X_AXIS) : 0), + | (parser.seen_test('Y') ? _BV(Y_AXIS) : 0), + | (parser.seen_test('Z') ? _BV(Z_AXIS) : 0)) + ) #endif ) { TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_RUNNING)); @@ -83,7 +85,7 @@ void GcodeSuite::G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move/*=false*/)) { if (MIN_AUTORETRACT <= MAX_AUTORETRACT) { // When M209 Autoretract is enabled, convert E-only moves to firmware retract/recover moves - if (fwretract.autoretract_enabled && parser.seen('E') && !parser.seen("XYZ")) { + if (fwretract.autoretract_enabled && parser.seen_test('E') && !parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z"))) { const float echange = destination.e - current_position.e; // Is this a retract or recover move? if (WITHIN(ABS(echange), MIN_AUTORETRACT, MAX_AUTORETRACT) && fwretract.retracted[active_extruder] == (echange > 0.0)) { diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index bafc79bcac9a..4d9f5559fe19 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -109,23 +109,32 @@ void plan_arc( #endif } - float linear_travel = cart[l_axis] - start_L, - extruder_travel = cart.e - current_position.e; + float linear_travel = cart[l_axis] - start_L; + + #if HAS_EXTRUDERS + float extruder_travel = cart.e - current_position.e; + #endif // If circling around... if (ENABLED(ARC_P_CIRCLES) && circles) { const float total_angular = angular_travel + circles * RADIANS(360), // Total rotation with all circles and remainder part_per_circle = RADIANS(360) / total_angular, // Each circle's part of the total - l_per_circle = linear_travel * part_per_circle, // L movement per circle - e_per_circle = extruder_travel * part_per_circle; // E movement per circle + l_per_circle = linear_travel * part_per_circle; // L movement per circle + + #if HAS_EXTRUDERS + const float e_per_circle = extruder_travel * part_per_circle; // E movement per circle + #endif + xyze_pos_t temp_position = current_position; // for plan_arc to compare to current_position for (uint16_t n = circles; n--;) { - temp_position.e += e_per_circle; // Destination E axis + TERN_(HAS_EXTRUDERS, temp_position.e += e_per_circle); // Destination E axis temp_position[l_axis] += l_per_circle; // Destination L axis plan_arc(temp_position, offset, clockwise, 0); // Plan a single whole circle } linear_travel = cart[l_axis] - current_position[l_axis]; - extruder_travel = cart.e - current_position.e; + #if HAS_EXTRUDERS + extruder_travel = cart.e - current_position.e; + #endif } const float flat_mm = radius * angular_travel, @@ -179,16 +188,19 @@ void plan_arc( xyze_pos_t raw; const float theta_per_segment = angular_travel / segments, linear_per_segment = linear_travel / segments, - extruder_per_segment = extruder_travel / segments, sq_theta_per_segment = sq(theta_per_segment), sin_T = theta_per_segment - sq_theta_per_segment * theta_per_segment / 6, cos_T = 1 - 0.5f * sq_theta_per_segment; // Small angle approximation + #if HAS_EXTRUDERS + const float extruder_per_segment = extruder_travel / segments; + #endif + // Initialize the linear axis raw[l_axis] = current_position[l_axis]; // Initialize the extruder axis - raw.e = current_position.e; + TERN_(HAS_EXTRUDERS, raw.e = current_position.e); #if ENABLED(SCARA_FEEDRATE_SCALING) const float inv_duration = scaled_fr_mm_s / seg_length; @@ -240,7 +252,8 @@ void plan_arc( #else raw[l_axis] += linear_per_segment; #endif - raw.e += extruder_per_segment; + + TERN_(HAS_EXTRUDERS, raw.e += extruder_per_segment); apply_motion_limits(raw); diff --git a/Marlin/src/gcode/motion/M290.cpp b/Marlin/src/gcode/motion/M290.cpp index 0a858090f955..1f0d494baf3a 100644 --- a/Marlin/src/gcode/motion/M290.cpp +++ b/Marlin/src/gcode/motion/M290.cpp @@ -87,7 +87,7 @@ void GcodeSuite::M290() { } #endif - if (!parser.seen("XYZ") || parser.seen('R')) { + if (!parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z")) || parser.seen('R')) { SERIAL_ECHO_START(); #if ENABLED(BABYSTEP_ZPROBE_OFFSET) diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index 514d6b7a5daf..b07e92555cae 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -248,7 +248,8 @@ void GCodeParser::parse(char *p) { case 'R': if (!WITHIN(motion_mode_codenum, 2, 3)) return; #endif - case 'X' ... 'Z': case 'E' ... 'F': + LOGICAL_AXIS_GANG(case 'E':, case 'X':, case 'Y':, case 'Z':) + case 'F': if (motion_mode_codenum < 0) return; command_letter = 'G'; codenum = motion_mode_codenum; diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 4270e04c9f09..dc3f3c35fb64 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -226,7 +226,7 @@ class GCodeParser { // Seen any axis parameter static inline bool seen_axis() { - return seen("XYZE"); + return seen(LOGICAL_AXIS_GANG("E", "X", "Y", "Z")); } #if ENABLED(GCODE_QUOTED_STRINGS) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 8001674dc4d5..a8bd7a70ac97 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -537,12 +537,12 @@ * E_STEPPERS - Number of actual E stepper motors * E_MANUAL - Number of E steppers for LCD move options */ - #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 @@ -551,6 +551,7 @@ #undef SWITCHING_NOZZLE #undef MIXING_EXTRUDER #undef HOTEND_IDLE_TIMEOUT + #undef DISABLE_E #endif #if ENABLED(SWITCHING_EXTRUDER) // One stepper for every two EXTRUDERS @@ -604,6 +605,50 @@ #define E_MANUAL EXTRUDERS #endif +/** + * Number of Linear Axes (e.g., XYZ) + * All the logical axes except for the tool (E) axis + */ +#ifndef LINEAR_AXES + #define LINEAR_AXES XYZ +#endif + +/** + * Number of Logical Axes (e.g., XYZE) + * All the logical axes that can be commanded directly by G-code. + * Delta maps stepper-specific values to ABC steppers. + */ +#if HAS_EXTRUDERS + #define LOGICAL_AXES INCREMENT(LINEAR_AXES) +#else + #define LOGICAL_AXES LINEAR_AXES +#endif + +/** + * DISTINCT_E_FACTORS is set to give extruders (some) individual settings. + * + * DISTINCT_AXES is the number of distinct addressable axes (not steppers). + * Includes all linear axes plus all distinguished extruders. + * The default behavior is to treat all extruders as a single E axis + * with shared motion and temperature settings. + * + * DISTINCT_E is the number of distinguished extruders. By default this + * well be 1 which indicates all extruders share the same settings. + * + * E_INDEX_N(E) should be used to get the E index of any item that might be + * distinguished. + */ +#if ENABLED(DISTINCT_E_FACTORS) && E_STEPPERS > 1 + #define DISTINCT_AXES (LINEAR_AXES + E_STEPPERS) + #define DISTINCT_E E_STEPPERS + #define E_INDEX_N(E) (E) +#else + #undef DISTINCT_E_FACTORS + #define DISTINCT_AXES LOGICAL_AXES + #define DISTINCT_E 1 + #define E_INDEX_N(E) 0 +#endif + #if HOTENDS #define HAS_HOTEND 1 #ifndef HOTEND_OVERSHOOT @@ -624,10 +669,6 @@ #define ARRAY_BY_HOTENDS(V...) ARRAY_N(HOTENDS, V) #define ARRAY_BY_HOTENDS1(v1) ARRAY_N_1(HOTENDS, v1) -#if ENABLED(SWITCHING_EXTRUDER) && (DISABLED(SWITCHING_NOZZLE) || SWITCHING_EXTRUDER_SERVO_NR != SWITCHING_NOZZLE_SERVO_NR) - #define DO_SWITCH_EXTRUDER 1 -#endif - /** * Default hotend offsets, if not defined */ @@ -653,39 +694,10 @@ #undef SINGLENOZZLE_STANDBY_FAN #endif -/** - * Number of Linear Axes (e.g., XYZ) - * All the logical axes except for the tool (E) axis - */ -#ifndef LINEAR_AXES - #define LINEAR_AXES XYZ -#endif - -/** - * Number of Logical Axes (e.g., XYZE) - * All the logical axes that can be commanded directly by G-code. - * Delta maps stepper-specific values to ABC steppers. - */ -#if HAS_EXTRUDERS - #define LOGICAL_AXES INCREMENT(LINEAR_AXES) -#else - #define LOGICAL_AXES LINEAR_AXES -#endif - -/** - * DISTINCT_E_FACTORS affects whether Extruders use different settings - */ -#if ENABLED(DISTINCT_E_FACTORS) && E_STEPPERS > 1 - #define DISTINCT_E E_STEPPERS - #define DISTINCT_AXES (LINEAR_AXES + E_STEPPERS) - #define E_INDEX_N(E) (E) -#else - #undef DISTINCT_E_FACTORS - #define DISTINCT_E 1 - #define DISTINCT_AXES LOGICAL_AXES - #define E_INDEX_N(E) 0 +// Switching extruder has its own servo? +#if ENABLED(SWITCHING_EXTRUDER) && (DISABLED(SWITCHING_NOZZLE) || SWITCHING_EXTRUDER_SERVO_NR != SWITCHING_NOZZLE_SERVO_NR) + #define DO_SWITCH_EXTRUDER 1 #endif -#define E_AXIS_N(E) AxisEnum(E_AXIS + E_INDEX_N(E)) /** * The BLTouch Probe emulates a servo probe @@ -726,6 +738,9 @@ #define HAS_BED_PROBE 1 #endif +/** + * Fill in undefined Filament Sensor options + */ #if ENABLED(FILAMENT_RUNOUT_SENSOR) #if NUM_RUNOUT_SENSORS >= 1 #ifndef FIL_RUNOUT1_STATE @@ -834,6 +849,9 @@ #define Z_HOME_TO_MIN 1 #endif +/** + * Conditionals based on the type of Bed Probe + */ #if HAS_BED_PROBE #if DISABLED(NOZZLE_AS_PROBE) #define HAS_PROBE_XY_OFFSET 1 @@ -868,7 +886,7 @@ #endif /** - * Set granular options based on the specific type of leveling + * Conditionals based on the type of Bed Leveling */ #if ENABLED(AUTO_BED_LEVELING_UBL) #undef LCD_BED_LEVELING diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 1d3253b1ccb2..18082044e066 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -103,6 +103,9 @@ #undef THERMAL_PROTECTION_PERIOD #undef WATCH_TEMP_PERIOD #undef SHOW_TEMP_ADC_VALUES + #undef LCD_SHOW_E_TOTAL + #undef MANUAL_E_MOVES_RELATIVE + #undef STEALTHCHOP_E #endif #if TEMP_SENSOR_BED == 0 @@ -482,6 +485,23 @@ #endif #endif +// Remove unused STEALTHCHOP flags +#if LINEAR_AXES < 6 + #undef STEALTHCHOP_K + #if LINEAR_AXES < 5 + #undef STEALTHCHOP_J + #if LINEAR_AXES < 4 + #undef STEALTHCHOP_I + #if LINEAR_AXES < 3 + #undef STEALTHCHOP_Z + #if LINEAR_AXES < 2 + #undef STEALTHCHOP_Y + #endif + #endif + #endif + #endif +#endif + // // SD Card connection methods // Defined here so pins and sanity checks can use them diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index d86b02bdc233..a0e5db301ea1 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1563,133 +1563,137 @@ #endif // Extruder steppers and solenoids -#if PIN_EXISTS(E0_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)) - #define HAS_E0_ENABLE 1 -#endif -#if PIN_EXISTS(E0_DIR) - #define HAS_E0_DIR 1 -#endif -#if PIN_EXISTS(E0_STEP) - #define HAS_E0_STEP 1 -#endif -#if PIN_EXISTS(E0_MS1) - #define HAS_E0_MS_PINS 1 -#endif -#if PIN_EXISTS(SOL0) - #define HAS_SOLENOID_0 1 -#endif +#if HAS_EXTRUDERS -#if PIN_EXISTS(E1_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)) - #define HAS_E1_ENABLE 1 -#endif -#if PIN_EXISTS(E1_DIR) - #define HAS_E1_DIR 1 -#endif -#if PIN_EXISTS(E1_STEP) - #define HAS_E1_STEP 1 -#endif -#if PIN_EXISTS(E1_MS1) - #define HAS_E1_MS_PINS 1 -#endif -#if PIN_EXISTS(SOL1) - #define HAS_SOLENOID_1 1 -#endif + #if PIN_EXISTS(E0_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)) + #define HAS_E0_ENABLE 1 + #endif + #if PIN_EXISTS(E0_DIR) + #define HAS_E0_DIR 1 + #endif + #if PIN_EXISTS(E0_STEP) + #define HAS_E0_STEP 1 + #endif + #if PIN_EXISTS(E0_MS1) + #define HAS_E0_MS_PINS 1 + #endif + #if PIN_EXISTS(SOL0) + #define HAS_SOLENOID_0 1 + #endif -#if PIN_EXISTS(E2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)) - #define HAS_E2_ENABLE 1 -#endif -#if PIN_EXISTS(E2_DIR) - #define HAS_E2_DIR 1 -#endif -#if PIN_EXISTS(E2_STEP) - #define HAS_E2_STEP 1 -#endif -#if PIN_EXISTS(E2_MS1) - #define HAS_E2_MS_PINS 1 -#endif -#if PIN_EXISTS(SOL2) - #define HAS_SOLENOID_2 1 -#endif + #if PIN_EXISTS(E1_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)) + #define HAS_E1_ENABLE 1 + #endif + #if PIN_EXISTS(E1_DIR) + #define HAS_E1_DIR 1 + #endif + #if PIN_EXISTS(E1_STEP) + #define HAS_E1_STEP 1 + #endif + #if PIN_EXISTS(E1_MS1) + #define HAS_E1_MS_PINS 1 + #endif + #if PIN_EXISTS(SOL1) + #define HAS_SOLENOID_1 1 + #endif -#if PIN_EXISTS(E3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)) - #define HAS_E3_ENABLE 1 -#endif -#if PIN_EXISTS(E3_DIR) - #define HAS_E3_DIR 1 -#endif -#if PIN_EXISTS(E3_STEP) - #define HAS_E3_STEP 1 -#endif -#if PIN_EXISTS(E3_MS1) - #define HAS_E3_MS_PINS 1 -#endif -#if PIN_EXISTS(SOL3) - #define HAS_SOLENOID_3 1 -#endif + #if PIN_EXISTS(E2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)) + #define HAS_E2_ENABLE 1 + #endif + #if PIN_EXISTS(E2_DIR) + #define HAS_E2_DIR 1 + #endif + #if PIN_EXISTS(E2_STEP) + #define HAS_E2_STEP 1 + #endif + #if PIN_EXISTS(E2_MS1) + #define HAS_E2_MS_PINS 1 + #endif + #if PIN_EXISTS(SOL2) + #define HAS_SOLENOID_2 1 + #endif -#if PIN_EXISTS(E4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)) - #define HAS_E4_ENABLE 1 -#endif -#if PIN_EXISTS(E4_DIR) - #define HAS_E4_DIR 1 -#endif -#if PIN_EXISTS(E4_STEP) - #define HAS_E4_STEP 1 -#endif -#if PIN_EXISTS(E4_MS1) - #define HAS_E4_MS_PINS 1 -#endif -#if PIN_EXISTS(SOL4) - #define HAS_SOLENOID_4 1 -#endif + #if PIN_EXISTS(E3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)) + #define HAS_E3_ENABLE 1 + #endif + #if PIN_EXISTS(E3_DIR) + #define HAS_E3_DIR 1 + #endif + #if PIN_EXISTS(E3_STEP) + #define HAS_E3_STEP 1 + #endif + #if PIN_EXISTS(E3_MS1) + #define HAS_E3_MS_PINS 1 + #endif + #if PIN_EXISTS(SOL3) + #define HAS_SOLENOID_3 1 + #endif -#if PIN_EXISTS(E5_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)) - #define HAS_E5_ENABLE 1 -#endif -#if PIN_EXISTS(E5_DIR) - #define HAS_E5_DIR 1 -#endif -#if PIN_EXISTS(E5_STEP) - #define HAS_E5_STEP 1 -#endif -#if PIN_EXISTS(E5_MS1) - #define HAS_E5_MS_PINS 1 -#endif -#if PIN_EXISTS(SOL5) - #define HAS_SOLENOID_5 1 -#endif + #if PIN_EXISTS(E4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)) + #define HAS_E4_ENABLE 1 + #endif + #if PIN_EXISTS(E4_DIR) + #define HAS_E4_DIR 1 + #endif + #if PIN_EXISTS(E4_STEP) + #define HAS_E4_STEP 1 + #endif + #if PIN_EXISTS(E4_MS1) + #define HAS_E4_MS_PINS 1 + #endif + #if PIN_EXISTS(SOL4) + #define HAS_SOLENOID_4 1 + #endif -#if PIN_EXISTS(E6_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)) - #define HAS_E6_ENABLE 1 -#endif -#if PIN_EXISTS(E6_DIR) - #define HAS_E6_DIR 1 -#endif -#if PIN_EXISTS(E6_STEP) - #define HAS_E6_STEP 1 -#endif -#if PIN_EXISTS(E6_MS1) - #define HAS_E6_MS_PINS 1 -#endif -#if PIN_EXISTS(SOL6) - #define HAS_SOLENOID_6 1 -#endif + #if PIN_EXISTS(E5_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)) + #define HAS_E5_ENABLE 1 + #endif + #if PIN_EXISTS(E5_DIR) + #define HAS_E5_DIR 1 + #endif + #if PIN_EXISTS(E5_STEP) + #define HAS_E5_STEP 1 + #endif + #if PIN_EXISTS(E5_MS1) + #define HAS_E5_MS_PINS 1 + #endif + #if PIN_EXISTS(SOL5) + #define HAS_SOLENOID_5 1 + #endif -#if PIN_EXISTS(E7_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)) - #define HAS_E7_ENABLE 1 -#endif -#if PIN_EXISTS(E7_DIR) - #define HAS_E7_DIR 1 -#endif -#if PIN_EXISTS(E7_STEP) - #define HAS_E7_STEP 1 -#endif -#if PIN_EXISTS(E7_MS1) - #define HAS_E7_MS_PINS 1 -#endif -#if PIN_EXISTS(SOL7) - #define HAS_SOLENOID_7 1 -#endif + #if PIN_EXISTS(E6_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)) + #define HAS_E6_ENABLE 1 + #endif + #if PIN_EXISTS(E6_DIR) + #define HAS_E6_DIR 1 + #endif + #if PIN_EXISTS(E6_STEP) + #define HAS_E6_STEP 1 + #endif + #if PIN_EXISTS(E6_MS1) + #define HAS_E6_MS_PINS 1 + #endif + #if PIN_EXISTS(SOL6) + #define HAS_SOLENOID_6 1 + #endif + + #if PIN_EXISTS(E7_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)) + #define HAS_E7_ENABLE 1 + #endif + #if PIN_EXISTS(E7_DIR) + #define HAS_E7_DIR 1 + #endif + #if PIN_EXISTS(E7_STEP) + #define HAS_E7_STEP 1 + #endif + #if PIN_EXISTS(E7_MS1) + #define HAS_E7_MS_PINS 1 + #endif + #if PIN_EXISTS(SOL7) + #define HAS_SOLENOID_7 1 + #endif + +#endif // HAS_EXTRUDERS // // Trinamic Stepper Drivers @@ -2348,7 +2352,10 @@ #if PIN_EXISTS(DIGIPOTSS) #define HAS_MOTOR_CURRENT_SPI 1 #endif -#if ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_Z, MOTOR_CURRENT_PWM_E) +#if HAS_EXTRUDERS && PIN_EXISTS(MOTOR_CURRENT_PWM_E) + #define HAS_MOTOR_CURRENT_PWM_E 1 +#endif +#if HAS_MOTOR_CURRENT_PWM_E || ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_Z) #define HAS_MOTOR_CURRENT_PWM 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 897cb2824fc9..eea67661481e 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1593,11 +1593,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Homing */ constexpr float hbm[] = HOMING_BUMP_MM; -static_assert(COUNT(hbm) == XYZ, "HOMING_BUMP_MM requires X, Y, and Z elements."); -static_assert(hbm[X_AXIS] >= 0, "HOMING_BUMP_MM.X must be greater than or equal to 0."); -static_assert(hbm[Y_AXIS] >= 0, "HOMING_BUMP_MM.Y must be greater than or equal to 0."); -static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal to 0."); - +static_assert(COUNT(hbm) == LINEAR_AXES, "HOMING_BUMP_MM requires one element per linear axis."); +LINEAR_AXIS_CODE( + static_assert(hbm[X_AXIS] >= 0, "HOMING_BUMP_MM.X must be greater than or equal to 0."), + static_assert(hbm[Y_AXIS] >= 0, "HOMING_BUMP_MM.Y must be greater than or equal to 0."), + static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal to 0.") +); #if ENABLED(CODEPENDENT_XY_HOMING) #if ENABLED(QUICK_HOME) #error "QUICK_HOME is incompatible with CODEPENDENT_XY_HOMING." @@ -1976,12 +1977,16 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "HEATER_0_PIN not defined for this board." #elif !ANY_PIN(TEMP_0, MAX6675_SS) #error "TEMP_0_PIN or MAX6675_SS not defined for this board." -#elif ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR)) - #error "E0_STEP_PIN or E0_DIR_PIN not defined for this board." -#elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE)) - #error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board." -#elif EXTRUDERS && TEMP_SENSOR_0 == 0 - #error "TEMP_SENSOR_0 is required if there are any extruders." +#endif + +#if HAS_EXTRUDERS + #if ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR)) + #error "E0_STEP_PIN or E0_DIR_PIN not defined for this board." + #elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE)) + #error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board." + #elif EXTRUDERS && TEMP_SENSOR_0 == 0 + #error "TEMP_SENSOR_0 is required if there are any extruders." + #endif #endif /** diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 010d9a668034..f05958e67536 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -856,8 +856,10 @@ void MarlinUI::draw_status_screen() { #else if (show_e_total) { - _draw_axis_value(E_AXIS, xstring, true); - lcd_put_u8str_P(PSTR(" ")); + #if ENABLED(LCD_SHOW_E_TOTAL) + _draw_axis_value(E_AXIS, xstring, true); + lcd_put_u8str_P(PSTR(" ")); + #endif } else { _draw_axis_value(X_AXIS, xstring, blink); diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp index 3d68df7b7f02..4f9021064dc8 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp @@ -666,10 +666,10 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_Z_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Z_AXIS], ScreenHandler.HandleMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), #if HOTENDS >= 1 - VPHELPER(VP_E0_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E0_AXIS], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_E0_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(0)], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), #endif #if HOTENDS >= 2 - VPHELPER(VP_E1_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E1_AXIS], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_E1_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), #endif VPHELPER(VP_X_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[X_AXIS], ScreenHandler.HandleMaxAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), @@ -677,10 +677,10 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_Z_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Z_AXIS], ScreenHandler.HandleMaxAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #if HOTENDS >= 1 - VPHELPER(VP_E0_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E0_AXIS], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_E0_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(0)], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #endif #if HOTENDS >= 2 - VPHELPER(VP_E1_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E1_AXIS], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_E1_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #endif VPHELPER(VP_TRAVEL_SPEED, (uint16_t *)&planner.settings.travel_acceleration, ScreenHandler.HandleTravelAccChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index ba3abc0e2dd2..044a6642fc1f 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -712,13 +712,15 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { // Add a manual move to the queue? if (axis != NO_AXIS_ENUM && ELAPSED(millis(), start_time) && !planner.is_full()) { - const feedRate_t fr_mm_s = (axis <= E_AXIS) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; + const feedRate_t fr_mm_s = (axis <= LOGICAL_AXES) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; #if IS_KINEMATIC #if HAS_MULTI_EXTRUDER REMEMBER(ae, active_extruder); - if (axis == E_AXIS) active_extruder = e_index; + #if MULTI_E_MANUAL + if (axis == E_AXIS) active_extruder = e_index; + #endif #endif // Apply a linear offset to a single axis @@ -744,7 +746,9 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { #else // For Cartesian / Core motion simply move to the current_position - planner.buffer_line(current_position, fr_mm_s, axis == E_AXIS ? e_index : active_extruder); + planner.buffer_line(current_position, fr_mm_s, + TERN_(MULTI_E_MANUAL, axis == E_AXIS ? e_index :) active_extruder + ); //SERIAL_ECHOLNPAIR("Add planner.move with Axis ", AS_CHAR(axis_codes[axis]), " at FR ", fr_mm_s); diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index e751b534466f..5c5ec9d3e140 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -68,10 +68,7 @@ void menu_backlash(); START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); #define EDIT_DAC_PERCENT(A) EDIT_ITEM(uint8, MSG_DAC_PERCENT_##A, &driverPercent[_AXIS(A)], 0, 100, []{ stepper_dac.set_current_percents(driverPercent); }) - EDIT_DAC_PERCENT(X); - EDIT_DAC_PERCENT(Y); - EDIT_DAC_PERCENT(Z); - EDIT_DAC_PERCENT(E); + LOGICAL_AXIS_CODE(EDIT_DAC_PERCENT(E), EDIT_DAC_PERCENT(X), EDIT_DAC_PERCENT(Y), EDIT_DAC_PERCENT(Z), EDIT_DAC_PERCENT(I), EDIT_DAC_PERCENT(J), EDIT_DAC_PERCENT(K)); ACTION_ITEM(MSG_DAC_EEPROM_WRITE, stepper_dac.commit_eeprom); END_MENU(); } @@ -359,7 +356,7 @@ void menu_backlash(); #elif ENABLED(LIMITED_MAX_FR_EDITING) DEFAULT_MAX_FEEDRATE #else - { 9999, 9999, 9999, 9999 } + LOGICAL_AXIS_ARRAY(9999, 9999, 9999, 9999) #endif ; #if ENABLED(LIMITED_MAX_FR_EDITING) && !defined(MAX_FEEDRATE_EDIT_VALUES) @@ -372,9 +369,7 @@ void menu_backlash(); BACK_ITEM(MSG_ADVANCED_SETTINGS); #define EDIT_VMAX(N) EDIT_ITEM_FAST(float5, MSG_VMAX_##N, &planner.settings.max_feedrate_mm_s[_AXIS(N)], 1, max_fr_edit_scaled[_AXIS(N)]) - EDIT_VMAX(A); - EDIT_VMAX(B); - EDIT_VMAX(C); + LINEAR_AXIS_CODE(EDIT_VMAX(A), EDIT_VMAX(B), EDIT_VMAX(C), EDIT_VMAX(I), EDIT_VMAX(J), EDIT_VMAX(K)); #if E_STEPPERS EDIT_ITEM_FAST(float5, MSG_VMAX_E, &planner.settings.max_feedrate_mm_s[E_AXIS_N(active_extruder)], 1, max_fr_edit_scaled.e); @@ -404,7 +399,7 @@ void menu_backlash(); #elif ENABLED(LIMITED_MAX_ACCEL_EDITING) DEFAULT_MAX_ACCELERATION #else - { 99000, 99000, 99000, 99000 } + LOGICAL_AXIS_ARRAY(99000, 99000, 99000, 99000) #endif ; #if ENABLED(LIMITED_MAX_ACCEL_EDITING) && !defined(MAX_ACCEL_EDIT_VALUES) @@ -419,16 +414,19 @@ void menu_backlash(); // M204 P Acceleration EDIT_ITEM_FAST(float5_25, MSG_ACC, &planner.settings.acceleration, 25, max_accel); - // M204 R Retract Acceleration - EDIT_ITEM_FAST(float5, MSG_A_RETRACT, &planner.settings.retract_acceleration, 100, planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)]); + #if HAS_EXTRUDERS + // M204 R Retract Acceleration + EDIT_ITEM_FAST(float5, MSG_A_RETRACT, &planner.settings.retract_acceleration, 100, planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)]); + #endif // M204 T Travel Acceleration EDIT_ITEM_FAST(float5_25, MSG_A_TRAVEL, &planner.settings.travel_acceleration, 25, max_accel); #define EDIT_AMAX(Q,L) EDIT_ITEM_FAST(long5_25, MSG_AMAX_##Q, &planner.settings.max_acceleration_mm_per_s2[_AXIS(Q)], L, max_accel_edit_scaled[_AXIS(Q)], []{ planner.reset_acceleration_rates(); }) - EDIT_AMAX(A, 100); - EDIT_AMAX(B, 100); - EDIT_AMAX(C, 10); + LINEAR_AXIS_CODE( + EDIT_AMAX(A, 100), EDIT_AMAX(B, 100), EDIT_AMAX(C, 10), + EDIT_AMAX(I, 10), EDIT_AMAX(J, 10), EDIT_AMAX(K, 10) + ); #if ENABLED(DISTINCT_E_FACTORS) EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); }); @@ -474,14 +472,14 @@ void menu_backlash(); #endif ; #define EDIT_JERK(N) EDIT_ITEM_FAST(float3, MSG_V##N##_JERK, &planner.max_jerk[_AXIS(N)], 1, max_jerk_edit[_AXIS(N)]) - EDIT_JERK(A); - EDIT_JERK(B); #if ENABLED(DELTA) - EDIT_JERK(C); + #define EDIT_JERK_C() EDIT_JERK(C) #else - EDIT_ITEM_FAST(float52sign, MSG_VC_JERK, &planner.max_jerk.c, 0.1f, max_jerk_edit.c); + #define EDIT_JERK_C() EDIT_ITEM_FAST(float52sign, MSG_VC_JERK, &planner.max_jerk.c, 0.1f, max_jerk_edit.c) #endif - #if HAS_CLASSIC_E_JERK + LINEAR_AXIS_CODE(EDIT_JERK(A), EDIT_JERK(B), EDIT_JERK_C()); + + #if HAS_EXTRUDERS EDIT_ITEM_FAST(float52sign, MSG_VE_JERK, &planner.max_jerk.e, 0.1f, max_jerk_edit.e); #endif @@ -517,9 +515,7 @@ void menu_advanced_steps_per_mm() { BACK_ITEM(MSG_ADVANCED_SETTINGS); #define EDIT_QSTEPS(Q) EDIT_ITEM_FAST(float51, MSG_##Q##_STEPS, &planner.settings.axis_steps_per_mm[_AXIS(Q)], 5, 9999, []{ planner.refresh_positioning(); }) - EDIT_QSTEPS(A); - EDIT_QSTEPS(B); - EDIT_QSTEPS(C); + LINEAR_AXIS_CODE(EDIT_QSTEPS(A), EDIT_QSTEPS(B), EDIT_QSTEPS(C)); #if ENABLED(DISTINCT_E_FACTORS) LOOP_L_N(n, E_STEPPERS) diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index dff0b6832a3f..cf152ff0281a 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -361,7 +361,8 @@ void Endstops::event_handler() { prev_hit_state = hit_state; if (hit_state) { #if HAS_STATUS_MESSAGE - char chrX = ' ', chrY = ' ', chrZ = ' ', chrP = ' '; + char LINEAR_AXIS_LIST(chrX = ' ', chrY = ' ', chrZ = ' '), + chrP = ' '; #define _SET_STOP_CHAR(A,C) (chr## A = C) #else #define _SET_STOP_CHAR(A,C) NOOP @@ -390,7 +391,13 @@ void Endstops::event_handler() { #endif SERIAL_EOL(); - TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %c %c %c %c"), GET_TEXT(MSG_LCD_ENDSTOPS), chrX, chrY, chrZ, chrP)); + TERN_(HAS_STATUS_MESSAGE, + ui.status_printf_P(0, + PSTR(S_FMT GANG_N_1(LINEAR_AXES, " %c") " %c"), + GET_TEXT(MSG_LCD_ENDSTOPS), + LINEAR_AXIS_LIST(chrX, chrY, chrZ), chrP + ) + ); #if BOTH(SD_ABORT_ON_ENDSTOP_HIT, SDSUPPORT) if (planner.abort_on_endstop_hit) { diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 6801b210af69..ad0537b5cfb1 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -89,7 +89,7 @@ bool relative_mode; // = false; #define Z_INIT_POS Z_HOME_POS #endif -xyze_pos_t current_position = { X_HOME_POS, Y_HOME_POS, Z_INIT_POS }; +xyze_pos_t current_position = LOGICAL_AXIS_ARRAY(0, X_HOME_POS, Y_HOME_POS, Z_INIT_POS); /** * Cartesian Destination @@ -195,16 +195,25 @@ inline void report_more_positions() { // Report the logical position for a given machine position inline void report_logical_position(const xyze_pos_t &rpos) { const xyze_pos_t lpos = rpos.asLogical(); - SERIAL_ECHOPAIR_P(X_LBL, lpos.x, SP_Y_LBL, lpos.y, SP_Z_LBL, lpos.z, SP_E_LBL, lpos.e); + SERIAL_ECHOPAIR_P( + LIST_N(DOUBLE(LINEAR_AXES), X_LBL, lpos.x, SP_Y_LBL, lpos.y, SP_Z_LBL, lpos.z) + #if HAS_EXTRUDERS + , SP_E_LBL, lpos.e + #endif + ); } // Report the real current position according to the steppers. // Forward kinematics and un-leveling are applied. void report_real_position() { get_cartesian_from_steppers(); - xyze_pos_t npos = cartes; - npos.e = planner.get_axis_position_mm(E_AXIS); + xyze_pos_t npos = LOGICAL_AXIS_ARRAY( + planner.get_axis_position_mm(E_AXIS), + cartes.x, cartes.y, cartes.z + ); + TERN_(HAS_POSITION_MODIFIERS, planner.unapply_modifiers(npos, true)); + report_logical_position(npos); report_more_positions(); } @@ -309,7 +318,9 @@ void sync_plan_position() { planner.set_position_mm(current_position); } -void sync_plan_position_e() { planner.set_e_position_mm(current_position.e); } +#if HAS_EXTRUDERS + void sync_plan_position_e() { planner.set_e_position_mm(current_position.e); } +#endif /** * Get the stepper positions in the cartes[] array. @@ -354,7 +365,10 @@ void get_cartesian_from_steppers() { void set_current_from_steppers_for_axis(const AxisEnum axis) { get_cartesian_from_steppers(); xyze_pos_t pos = cartes; - pos.e = planner.get_axis_position_mm(E_AXIS); + + #if HAS_EXTRUDERS + pos.e = planner.get_axis_position_mm(E_AXIS); + #endif #if HAS_POSITION_MODIFIERS planner.unapply_modifiers(pos, true); @@ -442,9 +456,12 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ * - Delta may lower Z first to get into the free motion zone. * - Before returning, wait for the planner buffer to empty. */ -void do_blocking_move_to(const float rx, const float ry, const float rz, const_feedRate_t fr_mm_s/*=0.0*/) { +void do_blocking_move_to( + LINEAR_AXIS_LIST(const float rx, const float ry, const float rz), + const_feedRate_t fr_mm_s/*=0.0f*/ +) { DEBUG_SECTION(log_move, "do_blocking_move_to", DEBUGGING(LEVELING)); - if (DEBUGGING(LEVELING)) DEBUG_XYZ("> ", rx, ry, rz); + if (DEBUGGING(LEVELING)) DEBUG_XYZ("> ", LINEAR_AXIS_LIST(rx, ry, rz)); const feedRate_t z_feedrate = fr_mm_s ?: homing_feedrate(Z_AXIS), xy_feedrate = fr_mm_s ?: feedRate_t(XY_PROBE_FEEDRATE_MM_S); @@ -529,34 +546,46 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const_f } void do_blocking_move_to(const xy_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) { - do_blocking_move_to(raw.x, raw.y, current_position.z, fr_mm_s); + do_blocking_move_to(LINEAR_AXIS_LIST(raw.x, raw.y, current_position.z, current_position.i), fr_mm_s); } void do_blocking_move_to(const xyz_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) { - do_blocking_move_to(raw.x, raw.y, raw.z, fr_mm_s); + do_blocking_move_to(LINEAR_AXIS_LIST(raw.x, raw.y, raw.z), fr_mm_s); } void do_blocking_move_to(const xyze_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) { - do_blocking_move_to(raw.x, raw.y, raw.z, fr_mm_s); + do_blocking_move_to(LINEAR_AXIS_LIST(raw.x, raw.y, raw.z), fr_mm_s); } void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { - do_blocking_move_to(rx, current_position.y, current_position.z, fr_mm_s); + do_blocking_move_to( + LINEAR_AXIS_LIST(rx, current_position.y, current_position.z), + fr_mm_s + ); } void do_blocking_move_to_y(const_float_t ry, const_feedRate_t fr_mm_s/*=0.0*/) { - do_blocking_move_to(current_position.x, ry, current_position.z, fr_mm_s); + do_blocking_move_to( + LINEAR_AXIS_LIST(current_position.x, ry, current_position.z), + fr_mm_s + ); } void do_blocking_move_to_z(const_float_t rz, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to_xy_z(current_position, rz, fr_mm_s); } void do_blocking_move_to_xy(const_float_t rx, const_float_t ry, const_feedRate_t fr_mm_s/*=0.0*/) { - do_blocking_move_to(rx, ry, current_position.z, fr_mm_s); + do_blocking_move_to( + LINEAR_AXIS_LIST(rx, ry, current_position.z), + fr_mm_s + ); } void do_blocking_move_to_xy(const xy_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) { do_blocking_move_to_xy(raw.x, raw.y, fr_mm_s); } void do_blocking_move_to_xy_z(const xy_pos_t &raw, const_float_t z, const_feedRate_t fr_mm_s/*=0.0f*/) { - do_blocking_move_to(raw.x, raw.y, z, fr_mm_s); + do_blocking_move_to( + LINEAR_AXIS_LIST(raw.x, raw.y, z), + fr_mm_s + ); } void do_z_clearance(const_float_t zclear, const bool lower_allowed/*=false*/) { @@ -589,8 +618,8 @@ void restore_feedrate_and_scaling() { // Software Endstops are based on the configured limits. soft_endstops_t soft_endstop = { true, false, - { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }, - { X_MAX_POS, Y_MAX_POS, Z_MAX_POS } + LINEAR_AXIS_ARRAY(X_MIN_POS, Y_MIN_POS, Z_MIN_POS), + LINEAR_AXIS_ARRAY(X_MAX_BED, Y_MAX_BED, Z_MAX_POS) }; /** @@ -1176,9 +1205,12 @@ void prepare_line_to_destination() { if (TEST(b, a) && TERN(HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(a)) CBI(b, a); }; - set_should(axis_bits, X_AXIS); // Clear test bits that are trusted - set_should(axis_bits, Y_AXIS); - set_should(axis_bits, Z_AXIS); + // Clear test bits that are trusted + LINEAR_AXIS_CODE( + set_should(axis_bits, X_AXIS), + set_should(axis_bits, Y_AXIS), + set_should(axis_bits, Z_AXIS) + ); return axis_bits; } @@ -1187,9 +1219,11 @@ void prepare_line_to_destination() { PGM_P home_first = GET_TEXT(MSG_HOME_FIRST); char msg[strlen_P(home_first)+1]; sprintf_P(msg, home_first, - TEST(axis_bits, X_AXIS) ? "X" : "", - TEST(axis_bits, Y_AXIS) ? "Y" : "", - TEST(axis_bits, Z_AXIS) ? "Z" : "" + LINEAR_AXIS_LIST( + TEST(axis_bits, X_AXIS) ? "X" : "", + TEST(axis_bits, Y_AXIS) ? "Y" : "", + TEST(axis_bits, Z_AXIS) ? "Z" : "" + ) ); SERIAL_ECHO_START(); SERIAL_ECHOLN(msg); @@ -1356,7 +1390,7 @@ void prepare_line_to_destination() { const feedRate_t home_fr_mm_s = fr_mm_s ?: homing_feedrate(axis); if (DEBUGGING(LEVELING)) { - DEBUG_ECHOPAIR("...(", AS_CHAR(axis_codes[axis]), ", ", distance, ", "); + DEBUG_ECHOPAIR("...(", AS_CHAR(AXIS_CHAR(axis)), ", ", distance, ", "); if (fr_mm_s) DEBUG_ECHO(fr_mm_s); else @@ -1441,12 +1475,12 @@ void prepare_line_to_destination() { * "trusted" position). */ void set_axis_never_homed(const AxisEnum axis) { - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_never_homed(", AS_CHAR(axis_codes[axis]), ")"); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_never_homed(", AS_CHAR(AXIS_CHAR(axis)), ")"); set_axis_untrusted(axis); set_axis_unhomed(axis); - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_never_homed(", AS_CHAR(axis_codes[axis]), ")"); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_never_homed(", AS_CHAR(AXIS_CHAR(axis)), ")"); TERN_(I2C_POSITION_ENCODERS, I2CPEM.unhomed(axis)); } @@ -1507,7 +1541,7 @@ void prepare_line_to_destination() { if (ABS(phaseDelta) * planner.steps_to_mm[axis] / phasePerUStep < 0.05f) SERIAL_ECHOLNPAIR("Selected home phase ", home_phase[axis], " too close to endstop trigger phase ", phaseCurrent, - ". Pick a different phase for ", AS_CHAR(axis_codes[axis])); + ". Pick a different phase for ", AS_CHAR(AXIS_CHAR(axis))); // Skip to next if target position is behind current. So it only moves away from endstop. if (phaseDelta < 0) phaseDelta += 1024; @@ -1518,7 +1552,7 @@ void prepare_line_to_destination() { // Optional debug messages if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPAIR( - "Endstop ", AS_CHAR(axis_codes[axis]), " hit at Phase:", phaseCurrent, + "Endstop ", AS_CHAR(AXIS_CHAR(axis)), " hit at Phase:", phaseCurrent, " Delta:", phaseDelta, " Distance:", mmDelta ); } @@ -1556,7 +1590,7 @@ void prepare_line_to_destination() { if (!_CAN_HOME(X) && !_CAN_HOME(Y) && !_CAN_HOME(Z)) return; #endif - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> homeaxis(", AS_CHAR(axis_codes[axis]), ")"); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> homeaxis(", AS_CHAR(AXIS_CHAR(axis)), ")"); const int axis_home_dir = TERN0(DUAL_X_CARRIAGE, axis == X_AXIS) ? TOOL_X_HOME_DIR(active_extruder) : home_dir(axis); @@ -1634,7 +1668,7 @@ void prepare_line_to_destination() { case Z_AXIS: es = Z_ENDSTOP; break; } if (TEST(endstops.state(), es)) { - SERIAL_ECHO_MSG("Bad ", AS_CHAR(axis_codes[axis]), " Endstop?"); + SERIAL_ECHO_MSG("Bad ", AS_CHAR(AXIS_CHAR(axis)), " Endstop?"); kill(GET_TEXT(MSG_KILL_HOMING_FAILED)); } #endif @@ -1856,7 +1890,7 @@ void prepare_line_to_destination() { if (axis == Z_AXIS) fwretract.current_hop = 0.0; #endif - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< homeaxis(", AS_CHAR(axis_codes[axis]), ")"); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< homeaxis(", AS_CHAR(AXIS_CHAR(axis)), ")"); } // homeaxis() @@ -1881,7 +1915,7 @@ void prepare_line_to_destination() { * Callers must sync the planner position after calling this! */ void set_axis_is_at_home(const AxisEnum axis) { - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_at_home(", AS_CHAR(axis_codes[axis]), ")"); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_at_home(", AS_CHAR(AXIS_CHAR(axis)), ")"); set_axis_trusted(axis); set_axis_homed(axis); @@ -1931,10 +1965,10 @@ void set_axis_is_at_home(const AxisEnum axis) { if (DEBUGGING(LEVELING)) { #if HAS_HOME_OFFSET - DEBUG_ECHOLNPAIR("> home_offset[", AS_CHAR(axis_codes[axis]), "] = ", home_offset[axis]); + DEBUG_ECHOLNPAIR("> home_offset[", AS_CHAR(AXIS_CHAR(axis)), "] = ", home_offset[axis]); #endif DEBUG_POS("", current_position); - DEBUG_ECHOLNPAIR("<<< set_axis_is_at_home(", AS_CHAR(axis_codes[axis]), ")"); + DEBUG_ECHOLNPAIR("<<< set_axis_is_at_home(", AS_CHAR(AXIS_CHAR(axis)), ")"); } } diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 67205a763602..0706b721b345 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -124,7 +124,7 @@ inline int8_t pgm_read_any(const int8_t *p) { return TERN(__IMXRT1062__, *p, pgm #define XYZ_DEFS(T, NAME, OPT) \ inline T NAME(const AxisEnum axis) { \ - static const XYZval NAME##_P DEFS_PROGMEM = { X_##OPT, Y_##OPT, Z_##OPT }; \ + static const XYZval NAME##_P DEFS_PROGMEM = LINEAR_AXIS_ARRAY(X_##OPT, Y_##OPT, Z_##OPT); \ return pgm_read_any(&NAME##_P[axis]); \ } XYZ_DEFS(float, base_min_pos, MIN_POS); @@ -264,7 +264,10 @@ void quickstop_stepper(); * no kinematic translation. Used for homing axes and cartesian/core syncing. */ void sync_plan_position(); -void sync_plan_position_e(); + +#if HAS_EXTRUDERS + void sync_plan_position_e(); +#endif /** * Move the planner to the current position from wherever it last moved @@ -295,7 +298,10 @@ inline void prepare_internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f) /** * Blocking movement and shorthand functions */ -void do_blocking_move_to(const float rx, const float ry, const float rz, const_feedRate_t fr_mm_s=0.0f); +void do_blocking_move_to( + LINEAR_AXIS_LIST(const float rx, const float ry, const float rz), + const_feedRate_t fr_mm_s=0.0f +); void do_blocking_move_to(const xy_pos_t &raw, const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to(const xyz_pos_t &raw, const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to(const xyze_pos_t &raw, const_feedRate_t fr_mm_s=0.0f); @@ -322,7 +328,7 @@ void do_z_clearance(const_float_t zclear, const bool lower_allowed=false); /** * Homing and Trusted Axes */ -typedef IF<(LINEAR_AXES>8), uint16_t, uint8_t>::type linear_axis_bits_t; +typedef IF<(LINEAR_AXES > 8), uint16_t, uint8_t>::type linear_axis_bits_t; constexpr linear_axis_bits_t linear_bits = _BV(LINEAR_AXES) - 1; void set_axis_is_at_home(const AxisEnum axis); diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 09db12cd7abd..c06e4be79b44 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1345,10 +1345,12 @@ void Planner::check_axes_activity() { #if ANY(DISABLE_X, DISABLE_Y, DISABLE_Z, DISABLE_E) for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) { block_t *block = &block_buffer[b]; - if (ENABLED(DISABLE_X) && block->steps.x) axis_active.x = true; - if (ENABLED(DISABLE_Y) && block->steps.y) axis_active.y = true; - if (ENABLED(DISABLE_Z) && block->steps.z) axis_active.z = true; - if (ENABLED(DISABLE_E) && block->steps.e) axis_active.e = true; + LOGICAL_AXIS_CODE( + if (TERN0(DISABLE_E, block->steps.e)) axis_active.e = true, + if (TERN0(DISABLE_X, block->steps.x)) axis_active.x = true, + if (TERN0(DISABLE_Y, block->steps.y)) axis_active.y = true, + if (TERN0(DISABLE_Z, block->steps.z)) axis_active.z = true + ); } #endif } @@ -1369,10 +1371,12 @@ void Planner::check_axes_activity() { // // Disable inactive axes // - if (TERN0(DISABLE_X, !axis_active.x)) DISABLE_AXIS_X(); - if (TERN0(DISABLE_Y, !axis_active.y)) DISABLE_AXIS_Y(); - if (TERN0(DISABLE_Z, !axis_active.z)) DISABLE_AXIS_Z(); - if (TERN0(DISABLE_E, !axis_active.e)) disable_e_steppers(); + LOGICAL_AXIS_CODE( + if (TERN0(DISABLE_E, !axis_active.e)) disable_e_steppers(), + if (TERN0(DISABLE_X, !axis_active.x)) DISABLE_AXIS_X(), + if (TERN0(DISABLE_Y, !axis_active.y)) DISABLE_AXIS_Y(), + if (TERN0(DISABLE_Z, !axis_active.z)) DISABLE_AXIS_Z() + ); // // Update Fan speeds @@ -1823,16 +1827,12 @@ bool Planner::_populate_block(block_t * const block, bool split_move, OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/ ) { - - const int32_t da = target.a - position.a, - db = target.b - position.b, - dc = target.c - position.c; - - #if HAS_EXTRUDERS - int32_t de = target.e - position.e; - #else - constexpr int32_t de = 0; - #endif + int32_t LOGICAL_AXIS_LIST( + de = target.e - position.e, + da = target.a - position.a, + db = target.b - position.b, + dc = target.c - position.c + ); /* <-- add a slash to enable SERIAL_ECHOLNPAIR( @@ -1883,35 +1883,39 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Compute direction bit-mask for this block uint8_t dm = 0; #if CORE_IS_XY - if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis + if (da < 0) SBI(dm, X_HEAD); // Save the toolhead's true direction in X if (db < 0) SBI(dm, Y_HEAD); // ...and Y if (dc < 0) SBI(dm, Z_AXIS); if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction if (CORESIGN(da - db) < 0) SBI(dm, B_AXIS); // Motor B direction #elif CORE_IS_XZ - if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis + if (da < 0) SBI(dm, X_HEAD); // Save the toolhead's true direction in X if (db < 0) SBI(dm, Y_AXIS); if (dc < 0) SBI(dm, Z_HEAD); // ...and Z if (da + dc < 0) SBI(dm, A_AXIS); // Motor A direction if (CORESIGN(da - dc) < 0) SBI(dm, C_AXIS); // Motor C direction #elif CORE_IS_YZ if (da < 0) SBI(dm, X_AXIS); - if (db < 0) SBI(dm, Y_HEAD); // Save the real Extruder (head) direction in Y Axis + if (db < 0) SBI(dm, Y_HEAD); // Save the toolhead's true direction in Y if (dc < 0) SBI(dm, Z_HEAD); // ...and Z if (db + dc < 0) SBI(dm, B_AXIS); // Motor B direction if (CORESIGN(db - dc) < 0) SBI(dm, C_AXIS); // Motor C direction #elif ENABLED(MARKFORGED_XY) - if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis + if (da < 0) SBI(dm, X_HEAD); // Save the toolhead's true direction in X if (db < 0) SBI(dm, Y_HEAD); // ...and Y if (dc < 0) SBI(dm, Z_AXIS); if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction if (db < 0) SBI(dm, B_AXIS); // Motor B direction #else - if (da < 0) SBI(dm, X_AXIS); - if (db < 0) SBI(dm, Y_AXIS); - if (dc < 0) SBI(dm, Z_AXIS); + LINEAR_AXIS_CODE( + if (da < 0) SBI(dm, X_AXIS), + if (db < 0) SBI(dm, Y_AXIS), + if (dc < 0) SBI(dm, Z_AXIS) + ); + #endif + #if HAS_EXTRUDERS + if (de < 0) SBI(dm, E_AXIS); #endif - if (de < 0) SBI(dm, E_AXIS); #if HAS_EXTRUDERS const float esteps_float = de * e_factor[extruder]; @@ -1947,7 +1951,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, block->steps.set(ABS(da), ABS(db), ABS(dc)); #else // default non-h-bot planning - block->steps.set(ABS(da), ABS(db), ABS(dc)); + block->steps.set(LINEAR_AXIS_LIST(ABS(da), ABS(db), ABS(dc))); #endif /** @@ -1990,41 +1994,51 @@ bool Planner::_populate_block(block_t * const block, bool split_move, steps_dist_mm.a = (da - db) * steps_to_mm[A_AXIS]; steps_dist_mm.b = db * steps_to_mm[B_AXIS]; #else - steps_dist_mm.a = da * steps_to_mm[A_AXIS]; - steps_dist_mm.b = db * steps_to_mm[B_AXIS]; - steps_dist_mm.c = dc * steps_to_mm[C_AXIS]; + LINEAR_AXIS_CODE( + steps_dist_mm.a = da * steps_to_mm[A_AXIS], + steps_dist_mm.b = db * steps_to_mm[B_AXIS], + steps_dist_mm.c = dc * steps_to_mm[C_AXIS] + ); #endif #if HAS_EXTRUDERS steps_dist_mm.e = esteps_float * steps_to_mm[E_AXIS_N(extruder)]; - #else - steps_dist_mm.e = 0.0f; #endif TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator += steps_dist_mm.e); - if (block->steps.a < MIN_STEPS_PER_SEGMENT && block->steps.b < MIN_STEPS_PER_SEGMENT && block->steps.c < MIN_STEPS_PER_SEGMENT) { - block->millimeters = (0 - #if HAS_EXTRUDERS - + ABS(steps_dist_mm.e) - #endif - ); + if (true LINEAR_AXIS_GANG( + && block->steps.a < MIN_STEPS_PER_SEGMENT, + && block->steps.b < MIN_STEPS_PER_SEGMENT, + && block->steps.c < MIN_STEPS_PER_SEGMENT + ) + ) { + block->millimeters = TERN0(HAS_EXTRUDERS, ABS(steps_dist_mm.e)); } else { if (millimeters) block->millimeters = millimeters; - else + else { block->millimeters = SQRT( #if EITHER(CORE_IS_XY, MARKFORGED_XY) - sq(steps_dist_mm.head.x) + sq(steps_dist_mm.head.y) + sq(steps_dist_mm.z) + LINEAR_AXIS_GANG( + sq(steps_dist_mm.head.x), + sq(steps_dist_mm.head.y), + sq(steps_dist_mm.z) + ) #elif CORE_IS_XZ - sq(steps_dist_mm.head.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.head.z) + LINEAR_AXIS_GANG( + sq(steps_dist_mm.head.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.head.z) + ) #elif CORE_IS_YZ - sq(steps_dist_mm.x) + sq(steps_dist_mm.head.y) + sq(steps_dist_mm.head.z) + LINEAR_AXIS_GANG( + sq(steps_dist_mm.x), + sq(steps_dist_mm.head.y), + sq(steps_dist_mm.head.z) + ) #else - sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.z) + LINEAR_AXIS_GANG( + sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z) + ) #endif ); + } /** * At this point at least one of the axes has more steps than @@ -2038,11 +2052,11 @@ bool Planner::_populate_block(block_t * const block, bool split_move, TERN_(BACKLASH_COMPENSATION, backlash.add_correction_steps(da, db, dc, dm, block)); } - #if HAS_EXTRUDERS - block->steps.e = esteps; - #endif + TERN_(HAS_EXTRUDERS, block->steps.e = esteps); - block->step_event_count = _MAX(block->steps.a, block->steps.b, block->steps.c, esteps); + block->step_event_count = _MAX(LOGICAL_AXIS_LIST( + esteps, block->steps.a, block->steps.b, block->steps.c + )); // Bail if this is a zero-length block if (block->step_event_count < MIN_STEPS_PER_SEGMENT) return false; @@ -2065,8 +2079,11 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif #if ENABLED(AUTO_POWER_CONTROL) - if (block->steps.x || block->steps.y || block->steps.z) - powerManager.power_on(); + if (LINEAR_AXIS_GANG( + block->steps.x, + || block->steps.y, + || block->steps.z + )) powerManager.power_on(); #endif // Enable active axes @@ -2091,11 +2108,11 @@ bool Planner::_populate_block(block_t * const block, bool split_move, } if (block->steps.x) ENABLE_AXIS_X(); #else - if (block->steps.x) ENABLE_AXIS_X(); - if (block->steps.y) ENABLE_AXIS_Y(); - #if DISABLED(Z_LATE_ENABLE) - if (block->steps.z) ENABLE_AXIS_Z(); - #endif + LINEAR_AXIS_CODE( + if (block->steps.x) ENABLE_AXIS_X(), + if (block->steps.y) ENABLE_AXIS_Y(), + if (TERN(Z_LATE_ENABLE, 0, block->steps.z)) ENABLE_AXIS_Z() + ); #endif // Enable extruder(s) @@ -2281,7 +2298,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Compute and limit the acceleration rate for the trapezoid generator. const float steps_per_mm = block->step_event_count * inverse_millimeters; uint32_t accel; - if (!block->steps.a && !block->steps.b && !block->steps.c) { // Is this a retract / recover move? + if (LINEAR_AXIS_GANG( + !block->steps.a, && !block->steps.b, && !block->steps.c + )) { // Is this a retract / recover move? accel = CEIL(settings.retract_acceleration * steps_per_mm); // Convert to: acceleration steps/sec^2 TERN_(LIN_ADVANCE, block->use_advance_lead = false); // No linear advance for simple retract/recover } @@ -2346,16 +2365,20 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Limit acceleration per axis if (block->step_event_count <= acceleration_long_cutoff) { - LIMIT_ACCEL_LONG(A_AXIS, 0); - LIMIT_ACCEL_LONG(B_AXIS, 0); - LIMIT_ACCEL_LONG(C_AXIS, 0); - LIMIT_ACCEL_LONG(E_AXIS, E_INDEX_N(extruder)); + LOGICAL_AXIS_CODE( + LIMIT_ACCEL_LONG(E_AXIS, E_INDEX_N(extruder)), + LIMIT_ACCEL_LONG(A_AXIS, 0), + LIMIT_ACCEL_LONG(B_AXIS, 0), + LIMIT_ACCEL_LONG(C_AXIS, 0) + ); } else { - LIMIT_ACCEL_FLOAT(A_AXIS, 0); - LIMIT_ACCEL_FLOAT(B_AXIS, 0); - LIMIT_ACCEL_FLOAT(C_AXIS, 0); - LIMIT_ACCEL_FLOAT(E_AXIS, E_INDEX_N(extruder)); + LOGICAL_AXIS_CODE( + LIMIT_ACCEL_FLOAT(E_AXIS, E_INDEX_N(extruder)), + LIMIT_ACCEL_FLOAT(A_AXIS, 0), + LIMIT_ACCEL_FLOAT(B_AXIS, 0), + LIMIT_ACCEL_FLOAT(C_AXIS, 0) + ); } } block->acceleration_steps_per_s2 = accel; @@ -2419,7 +2442,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #if HAS_DIST_MM_ARG cart_dist_mm #else - { steps_dist_mm.x, steps_dist_mm.y, steps_dist_mm.z, steps_dist_mm.e } + LOGICAL_AXIS_ARRAY(steps_dist_mm.e, steps_dist_mm.x, steps_dist_mm.y, steps_dist_mm.z) #endif ; @@ -2438,8 +2461,12 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (moves_queued && !UNEAR_ZERO(previous_nominal_speed_sqr)) { // Compute cosine of angle between previous and current path. (prev_unit_vec is negative) // NOTE: Max junction velocity is computed without sin() or acos() by trig half angle identity. - float junction_cos_theta = (-prev_unit_vec.x * unit_vec.x) + (-prev_unit_vec.y * unit_vec.y) - + (-prev_unit_vec.z * unit_vec.z) + (-prev_unit_vec.e * unit_vec.e); + float junction_cos_theta = LOGICAL_AXIS_GANG( + + (-prev_unit_vec.e * unit_vec.e), + (-prev_unit_vec.x * unit_vec.x), + + (-prev_unit_vec.y * unit_vec.y), + + (-prev_unit_vec.z * unit_vec.z) + ); // NOTE: Computed without any expensive trig, sin() or acos(), by trig half angle identity of cos(theta). if (junction_cos_theta > 0.999999f) { @@ -2754,7 +2781,8 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_ * * Return 'false' if no segment was queued due to cleaning, cold extrusion, full queue, etc. */ -bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e +bool Planner::buffer_segment( + LOGICAL_AXIS_LIST(const_float_t e, const_float_t a, const_float_t b, const_float_t c) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/ ) { @@ -2773,21 +2801,25 @@ bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c, // The target position of the tool in absolute steps // Calculate target position in absolute steps const abce_long_t target = { - int32_t(LROUND(a * settings.axis_steps_per_mm[A_AXIS])), - int32_t(LROUND(b * settings.axis_steps_per_mm[B_AXIS])), - int32_t(LROUND(c * settings.axis_steps_per_mm[C_AXIS])), - int32_t(LROUND(e * settings.axis_steps_per_mm[E_AXIS_N(extruder)])) + LOGICAL_AXIS_LIST( + int32_t(LROUND(e * settings.axis_steps_per_mm[E_AXIS_N(extruder)])), + int32_t(LROUND(a * settings.axis_steps_per_mm[A_AXIS])), + int32_t(LROUND(b * settings.axis_steps_per_mm[B_AXIS])), + int32_t(LROUND(c * settings.axis_steps_per_mm[C_AXIS])) + ) }; #if HAS_POSITION_FLOAT - const xyze_pos_t target_float = { a, b, c, e }; + const xyze_pos_t target_float = LOGICAL_AXIS_ARRAY(e, a, b, c); #endif - // DRYRUN prevents E moves from taking place - if (DEBUGGING(DRYRUN) || TERN0(CANCEL_OBJECTS, cancelable.skipping)) { - position.e = target.e; - TERN_(HAS_POSITION_FLOAT, position_float.e = e); - } + #if HAS_EXTRUDERS + // DRYRUN prevents E moves from taking place + if (DEBUGGING(DRYRUN) || TERN0(CANCEL_OBJECTS, cancelable.skipping)) { + position.e = target.e; + TERN_(HAS_POSITION_FLOAT, position_float.e = e); + } + #endif /* <-- add a slash to enable SERIAL_ECHOPAIR(" buffer_segment FR:", fr_mm_s); @@ -2846,10 +2878,12 @@ bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c, * millimeters - the length of the movement, if known * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) */ -bool Planner::buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters +bool Planner::buffer_line( + LOGICAL_AXIS_LIST(const_float_t e, const_float_t rx, const_float_t ry, const_float_t rz) + , const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration) ) { - xyze_pos_t machine = { rx, ry, rz, e }; + xyze_pos_t machine = LOGICAL_AXIS_ARRAY(e, rx, ry, rz); TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine)); #if IS_KINEMATIC @@ -2912,16 +2946,12 @@ bool Planner::buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; #endif - #if HAS_MULTI_EXTRUDER - block->extruder = extruder; - #endif + TERN_(HAS_MULTI_EXTRUDER, block->extruder = extruder); block->page_idx = page_idx; block->step_event_count = num_steps; - block->initial_rate = - block->final_rate = - block->nominal_rate = last_page_step_rate; // steps/s + block->initial_rate = block->final_rate = block->nominal_rate = last_page_step_rate; // steps/s block->accelerate_until = 0; block->decelerate_after = block->step_event_count; @@ -2965,13 +2995,19 @@ bool Planner::buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, * The provided ABC position is in machine units. */ -void Planner::set_machine_position_mm(const_float_t a, const_float_t b, const_float_t c, const_float_t e) { +void Planner::set_machine_position_mm( + LOGICAL_AXIS_LIST(const_float_t e, const_float_t a, const_float_t b, const_float_t c) +) { TERN_(DISTINCT_E_FACTORS, last_extruder = active_extruder); - TERN_(HAS_POSITION_FLOAT, position_float.set(a, b, c, e)); - position.set(LROUND(a * settings.axis_steps_per_mm[A_AXIS]), - LROUND(b * settings.axis_steps_per_mm[B_AXIS]), - LROUND(c * settings.axis_steps_per_mm[C_AXIS]), - LROUND(e * settings.axis_steps_per_mm[E_AXIS_N(active_extruder)])); + TERN_(HAS_POSITION_FLOAT, position_float.set(LOGICAL_AXIS_LIST(e, a, b, c))); + position.set( + LOGICAL_AXIS_LIST( + LROUND(e * settings.axis_steps_per_mm[E_AXIS_N(active_extruder)]), + LROUND(a * settings.axis_steps_per_mm[A_AXIS]), + LROUND(b * settings.axis_steps_per_mm[B_AXIS]), + LROUND(c * settings.axis_steps_per_mm[C_AXIS]) + ) + ); if (has_blocks_queued()) { //previous_nominal_speed_sqr = 0.0; // Reset planner junction speeds. Assume start from rest. //previous_speed.reset(); @@ -2981,11 +3017,11 @@ void Planner::set_machine_position_mm(const_float_t a, const_float_t b, const_fl stepper.set_position(position); } -void Planner::set_position_mm(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e) { - xyze_pos_t machine = { rx, ry, rz, e }; - #if HAS_POSITION_MODIFIERS - apply_modifiers(machine, true); - #endif +void Planner::set_position_mm( + LOGICAL_AXIS_LIST(const_float_t e, const_float_t rx, const_float_t ry, const_float_t rz) +) { + xyze_pos_t machine = LOGICAL_AXIS_ARRAY(e, rx, ry, rz); + TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine, true)); #if IS_KINEMATIC position_cart.set(rx, ry, rz, e); inverse_kinematics(machine); @@ -2995,23 +3031,27 @@ void Planner::set_position_mm(const_float_t rx, const_float_t ry, const_float_t #endif } -/** - * Setters for planner position (also setting stepper position). - */ -void Planner::set_e_position_mm(const_float_t e) { - const uint8_t axis_index = E_AXIS_N(active_extruder); - TERN_(DISTINCT_E_FACTORS, last_extruder = active_extruder); +#if HAS_EXTRUDERS - const float e_new = DIFF_TERN(FWRETRACT, e, fwretract.current_retract[active_extruder]); - position.e = LROUND(settings.axis_steps_per_mm[axis_index] * e_new); - TERN_(HAS_POSITION_FLOAT, position_float.e = e_new); - TERN_(IS_KINEMATIC, position_cart.e = e); + /** + * Setters for planner position (also setting stepper position). + */ + void Planner::set_e_position_mm(const_float_t e) { + const uint8_t axis_index = E_AXIS_N(active_extruder); + TERN_(DISTINCT_E_FACTORS, last_extruder = active_extruder); - if (has_blocks_queued()) - buffer_sync_block(); - else - stepper.set_axis_position(E_AXIS, position.e); -} + const float e_new = DIFF_TERN(FWRETRACT, e, fwretract.current_retract[active_extruder]); + position.e = LROUND(settings.axis_steps_per_mm[axis_index] * e_new); + TERN_(HAS_POSITION_FLOAT, position_float.e = e_new); + TERN_(IS_KINEMATIC, position_cart.e = e); + + if (has_blocks_queued()) + buffer_sync_block(); + else + stepper.set_axis_position(E_AXIS, position.e); + } + +#endif // Recalculate the steps/s^2 acceleration rates, based on the mm/s^2 void Planner::reset_acceleration_rates() { @@ -3041,11 +3081,11 @@ void Planner::refresh_positioning() { // Apply limits to a variable and give a warning if the value was out of range inline void limit_and_warn(float &val, const uint8_t axis, PGM_P const setting_name, const xyze_float_t &max_limit) { - const uint8_t lim_axis = axis > E_AXIS ? E_AXIS : axis; + const uint8_t lim_axis = TERN_(HAS_EXTRUDERS, axis > E_AXIS ? E_AXIS :) axis; const float before = val; LIMIT(val, 0.1, max_limit[lim_axis]); if (before != val) { - SERIAL_CHAR(axis_codes[lim_axis]); + SERIAL_CHAR(AXIS_CHAR(lim_axis)); SERIAL_ECHOPGM(" Max "); SERIAL_ECHOPGM_P(setting_name); SERIAL_ECHOLNPAIR(" limited to ", val); diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index be004dd3f4c3..edeac9b7f942 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -76,7 +76,7 @@ // Feedrate for manual moves #ifdef MANUAL_FEEDRATE constexpr xyze_feedrate_t _mf = MANUAL_FEEDRATE, - manual_feedrate_mm_s { _mf.x / 60.0f, _mf.y / 60.0f, _mf.z / 60.0f, _mf.e / 60.0f }; + manual_feedrate_mm_s = LOGICAL_AXIS_ARRAY(_mf.e / 60.0f, _mf.x / 60.0f, _mf.y / 60.0f, _mf.z / 60.0f); #endif #if IS_KINEMATIC && HAS_JUNCTION_DEVIATION @@ -758,7 +758,8 @@ class Planner { * extruder - target extruder * millimeters - the length of the movement, if known */ - static bool buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e + static bool buffer_segment( + LOGICAL_AXIS_LIST(const_float_t e, const_float_t a, const_float_t b, const_float_t c) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 ); @@ -767,9 +768,11 @@ class Planner { OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 ) { - return buffer_segment(abce.a, abce.b, abce.c, abce.e + return buffer_segment( + LOGICAL_AXIS_LIST(abce.e, abce.a, abce.b, abce.c) OPTARG(HAS_DIST_MM_ARG, cart_dist_mm) - , fr_mm_s, extruder, millimeters); + , fr_mm_s, extruder, millimeters + ); } public: @@ -785,14 +788,18 @@ class Planner { * millimeters - the length of the movement, if known * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) */ - static bool buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters=0.0 + static bool buffer_line( + LOGICAL_AXIS_LIST(const_float_t e, const_float_t rx, const_float_t ry, const_float_t rz) + , const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters=0.0 OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration=0.0) ); FORCE_INLINE static bool buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters=0.0 OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration=0.0) ) { - return buffer_line(cart.x, cart.y, cart.z, cart.e, fr_mm_s, extruder, millimeters + return buffer_line( + LOGICAL_AXIS_LIST(cart.e, cart.x, cart.y, cart.z) + , fr_mm_s, extruder, millimeters OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) ); } @@ -814,9 +821,16 @@ class Planner { * * Clears previous speed values. */ - static void set_position_mm(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e); - FORCE_INLINE static void set_position_mm(const xyze_pos_t &cart) { set_position_mm(cart.x, cart.y, cart.z, cart.e); } - static void set_e_position_mm(const_float_t e); + static void set_position_mm( + LOGICAL_AXIS_LIST(const_float_t e, const_float_t rx, const_float_t ry, const_float_t rz) + ); + FORCE_INLINE static void set_position_mm(const xyze_pos_t &cart) { + set_position_mm(LOGICAL_AXIS_LIST(cart.e, cart.x, cart.y, cart.z, cart.i, cart.j, cart.k)); + } + + #if HAS_EXTRUDERS + static void set_e_position_mm(const_float_t e); + #endif /** * Set the planner.position and individual stepper positions. @@ -824,8 +838,12 @@ class Planner { * The supplied position is in machine space, and no additional * conversions are applied. */ - static void set_machine_position_mm(const_float_t a, const_float_t b, const_float_t c, const_float_t e); - FORCE_INLINE static void set_machine_position_mm(const abce_pos_t &abce) { set_machine_position_mm(abce.a, abce.b, abce.c, abce.e); } + static void set_machine_position_mm( + LOGICAL_AXIS_LIST(const_float_t e, const_float_t a, const_float_t b, const_float_t c) + ); + FORCE_INLINE static void set_machine_position_mm(const abce_pos_t &abce) { + set_machine_position_mm(LOGICAL_AXIS_LIST(abce.e, abce.a, abce.b, abce.c)); + } /** * Get an axis position according to stepper position(s) @@ -834,12 +852,10 @@ class Planner { static float get_axis_position_mm(const AxisEnum axis); static inline abce_pos_t get_axis_positions_mm() { - const abce_pos_t out = { - get_axis_position_mm(A_AXIS), - get_axis_position_mm(B_AXIS), - get_axis_position_mm(C_AXIS), - get_axis_position_mm(E_AXIS) - }; + const abce_pos_t out = LOGICAL_AXIS_ARRAY( + get_axis_position_mm(E_AXIS), + get_axis_position_mm(A_AXIS), get_axis_position_mm(B_AXIS), get_axis_position_mm(C_AXIS) + ); return out; } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index eae4728793fe..fc4fdc1f92a8 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -168,10 +168,10 @@ void M554_report(); #endif -typedef struct { uint16_t X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_stepper_current_t; -typedef struct { uint32_t X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_hybrid_threshold_t; -typedef struct { int16_t X, Y, Z, X2, Y2, Z2, Z3, Z4; } tmc_sgt_t; -typedef struct { bool X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_stealth_enabled_t; +typedef struct { uint16_t LINEAR_AXIS_LIST(X, Y, Z), X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_stepper_current_t; +typedef struct { uint32_t LINEAR_AXIS_LIST(X, Y, Z), X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_hybrid_threshold_t; +typedef struct { int16_t LINEAR_AXIS_LIST(X, Y, Z), X2, Y2, Z2, Z3, Z4; } tmc_sgt_t; +typedef struct { bool LINEAR_AXIS_LIST(X, Y, Z), X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_stealth_enabled_t; // Limit an index to an array size #define ALIM(I,ARR) _MIN(I, (signed)COUNT(ARR) - 1) @@ -654,7 +654,7 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(dummyf); #endif #else - const xyze_pos_t planner_max_jerk = { 10, 10, 0.4, float(DEFAULT_EJERK) }; + const xyze_pos_t planner_max_jerk = LOGICAL_AXIS_ARRAY(float(DEFAULT_EJERK), 10, 10, 0.4); EEPROM_WRITE(planner_max_jerk); #endif @@ -1188,10 +1188,10 @@ void MarlinSettings::postprocess() { #endif #else const tmc_hybrid_threshold_t tmc_hybrid_threshold = { - .X = 100, .Y = 100, .Z = 3, + LINEAR_AXIS_LIST(.X = 100, .Y = 100, .Z = 3), .X2 = 100, .Y2 = 100, .Z2 = 3, .Z3 = 3, .Z4 = 3, - .E0 = 30, .E1 = 30, .E2 = 30, - .E3 = 30, .E4 = 30, .E5 = 30 + .E0 = 30, .E1 = 30, .E2 = 30, .E3 = 30, + .E4 = 30, .E5 = 30, .E6 = 30, .E7 = 30 }; #endif EEPROM_WRITE(tmc_hybrid_threshold); @@ -2604,7 +2604,7 @@ void MarlinSettings::reset() { #ifndef DEFAULT_ZJERK #define DEFAULT_ZJERK 0 #endif - planner.max_jerk.set(DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK); + planner.max_jerk.set(LINEAR_AXIS_LIST(DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK)); TERN_(HAS_CLASSIC_E_JERK, planner.max_jerk.e = DEFAULT_EJERK;); #endif @@ -3142,10 +3142,12 @@ void MarlinSettings::reset() { CONFIG_ECHO_HEADING("Maximum feedrates (units/s):"); CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR_P( - PSTR(" M203 X"), LINEAR_UNIT(planner.settings.max_feedrate_mm_s[X_AXIS]) - , SP_Y_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Y_AXIS]) - , SP_Z_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Z_AXIS]) - #if DISABLED(DISTINCT_E_FACTORS) + LIST_N(DOUBLE(LINEAR_AXES), + PSTR(" M203 X"), LINEAR_UNIT(planner.settings.max_feedrate_mm_s[X_AXIS]), + SP_Y_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Y_AXIS]), + SP_Z_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Z_AXIS]) + ) + #if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS) , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS]) #endif ); @@ -3162,10 +3164,12 @@ void MarlinSettings::reset() { CONFIG_ECHO_HEADING("Maximum Acceleration (units/s2):"); CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR_P( - PSTR(" M201 X"), LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[X_AXIS]) - , SP_Y_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Y_AXIS]) - , SP_Z_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Z_AXIS]) - #if DISABLED(DISTINCT_E_FACTORS) + LIST_N(DOUBLE(LINEAR_AXES), + PSTR(" M201 X"), LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[X_AXIS]), + SP_Y_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Y_AXIS]), + SP_Z_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Z_AXIS]) + ) + #if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS) , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_acceleration_mm_per_s2[E_AXIS]) #endif ); @@ -3894,9 +3898,11 @@ void MarlinSettings::reset() { CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR_P( PSTR(" M425 F"), backlash.get_correction() - , SP_X_STR, LINEAR_UNIT(backlash.distance_mm.x) - , SP_Y_STR, LINEAR_UNIT(backlash.distance_mm.y) - , SP_Z_STR, LINEAR_UNIT(backlash.distance_mm.z) + , LIST_N(DOUBLE(LINEAR_AXES), + SP_X_STR, LINEAR_UNIT(backlash.distance_mm.x), + SP_Y_STR, LINEAR_UNIT(backlash.distance_mm.y), + SP_Z_STR, LINEAR_UNIT(backlash.distance_mm.z) + ) #ifdef BACKLASH_SMOOTHING_MM , PSTR(" S"), LINEAR_UNIT(backlash.smoothing_mm) #endif diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 2e2afaeb90b6..bc6dbeaf255c 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -498,7 +498,7 @@ void Stepper::set_directions() { MIXER_STEPPER_LOOP(j) NORM_E_DIR(j); count_direction.e = 1; } - #else + #elif HAS_EXTRUDERS if (motor_direction(E_AXIS)) { REV_E_DIR(stepper_extruder); count_direction.e = -1; @@ -1627,7 +1627,7 @@ void Stepper::pulse_phase_isr() { PAGE_PULSE_PREP(X); PAGE_PULSE_PREP(Y); PAGE_PULSE_PREP(Z); - PAGE_PULSE_PREP(E); + TERN_(HAS_EXTRUDERS, PAGE_PULSE_PREP(E)); page_step_state.segment_steps++; @@ -1660,7 +1660,7 @@ void Stepper::pulse_phase_isr() { PAGE_PULSE_PREP(X); PAGE_PULSE_PREP(Y); PAGE_PULSE_PREP(Z); - PAGE_PULSE_PREP(E); + TERN_(HAS_EXTRUDERS, PAGE_PULSE_PREP(E)); page_step_state.segment_steps++; @@ -2103,13 +2103,15 @@ uint32_t Stepper::block_phase_isr() { #endif uint8_t axis_bits = 0; - if (X_MOVE_TEST) SBI(axis_bits, A_AXIS); - if (Y_MOVE_TEST) SBI(axis_bits, B_AXIS); - if (Z_MOVE_TEST) SBI(axis_bits, C_AXIS); - //if (!!current_block->steps.e) SBI(axis_bits, E_AXIS); - //if (!!current_block->steps.a) SBI(axis_bits, X_HEAD); - //if (!!current_block->steps.b) SBI(axis_bits, Y_HEAD); - //if (!!current_block->steps.c) SBI(axis_bits, Z_HEAD); + LINEAR_AXIS_CODE( + if (X_MOVE_TEST) SBI(axis_bits, A_AXIS), + if (Y_MOVE_TEST) SBI(axis_bits, B_AXIS), + if (Z_MOVE_TEST) SBI(axis_bits, C_AXIS) + ); + //if (current_block->steps.e) SBI(axis_bits, E_AXIS); + //if (current_block->steps.a) SBI(axis_bits, X_HEAD); + //if (current_block->steps.b) SBI(axis_bits, Y_HEAD); + //if (current_block->steps.c) SBI(axis_bits, Z_HEAD); axis_did_move = axis_bits; // No acceleration / deceleration time elapsed so far @@ -2606,9 +2608,13 @@ void Stepper::init() { #endif // Init direction bits for first moves - set_directions((INVERT_X_DIR ? _BV(X_AXIS) : 0) - | (INVERT_Y_DIR ? _BV(Y_AXIS) : 0) - | (INVERT_Z_DIR ? _BV(Z_AXIS) : 0)); + set_directions(0 + LINEAR_AXIS_GANG( + | TERN0(INVERT_X_DIR, _BV(X_AXIS)), + | TERN0(INVERT_Y_DIR, _BV(Y_AXIS)), + | TERN0(INVERT_Z_DIR, _BV(Z_AXIS)) + ) + ); #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM initialized = true; @@ -2625,7 +2631,9 @@ void Stepper::init() { * This allows get_axis_position_mm to correctly * derive the current XYZ position later on. */ -void Stepper::_set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e) { +void Stepper::_set_position( + LOGICAL_AXIS_LIST(const int32_t &e, const int32_t &a, const int32_t &b, const int32_t &c) +) { #if CORE_IS_XY // corexy positioning // these equations follow the form of the dA and dB equations on https://www.corexy.com/theory.html @@ -2640,9 +2648,9 @@ void Stepper::_set_position(const int32_t &a, const int32_t &b, const int32_t &c count_position.set(a - b, b, c); #else // default non-h-bot planning - count_position.set(a, b, c); + count_position.set(LINEAR_AXIS_LIST(a, b, c)); #endif - count_position.e = e; + TERN_(HAS_EXTRUDERS, count_position.e = e); } /** @@ -2665,10 +2673,13 @@ int32_t Stepper::position(const AxisEnum axis) { } // Set the current position in steps -void Stepper::set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e) { +//TODO: Test for LINEAR_AXES >= 4 +void Stepper::set_position( + LOGICAL_AXIS_LIST(const int32_t &e, const int32_t &a, const int32_t &b, const int32_t &c) +) { planner.synchronize(); const bool was_enabled = suspend(); - _set_position(a, b, c, e); + _set_position(LOGICAL_AXIS_LIST(e, a, b, c)); if (was_enabled) wake_up(); } @@ -2743,10 +2754,11 @@ void Stepper::report_a_position(const xyz_long_t &pos) { SERIAL_ECHOPAIR_P(PSTR(STR_COUNT_X), pos.x, SP_Y_LBL, pos.y); #endif #if ANY(CORE_IS_XZ, CORE_IS_YZ, DELTA) - SERIAL_ECHOLNPAIR(" C:", pos.z); - #else - SERIAL_ECHOLNPAIR_P(SP_Z_LBL, pos.z); + SERIAL_ECHOPAIR(" C:", pos.z); + #elif LINEAR_AXES >= 3 + SERIAL_ECHOPAIR_P(SP_Z_LBL, pos.z); #endif + SERIAL_EOL(); } void Stepper::report_positions() { @@ -2903,7 +2915,7 @@ void Stepper::report_positions() { DIR_WAIT_BEFORE(); - const xyz_byte_t old_dir = { X_DIR_READ(), Y_DIR_READ(), Z_DIR_READ() }; + const xyz_byte_t old_dir = LINEAR_AXIS_ARRAY(X_DIR_READ(), Y_DIR_READ(), Z_DIR_READ()); X_DIR_WRITE(INVERT_X_DIR ^ z_direction); Y_DIR_WRITE(INVERT_Y_DIR ^ z_direction); diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 020f72e9e685..67ca6fa433e4 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -433,8 +433,12 @@ class Stepper { static int32_t position(const AxisEnum axis); // Set the current position in steps - static void set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e); - static inline void set_position(const xyze_long_t &abce) { set_position(abce.a, abce.b, abce.c, abce.e); } + static void set_position( + LOGICAL_AXIS_LIST(const int32_t &e, const int32_t &a, const int32_t &b, const int32_t &c) + ); + static inline void set_position(const xyze_long_t &abce) { + set_position(LOGICAL_AXIS_LIST(abce.e, abce.a, abce.b, abce.c)); + } static void set_axis_position(const AxisEnum a, const int32_t &v); // Report the positions of the steppers, in steps @@ -530,8 +534,12 @@ class Stepper { private: // Set the current position in steps - static void _set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e); - FORCE_INLINE static void _set_position(const abce_long_t &spos) { _set_position(spos.a, spos.b, spos.c, spos.e); } + static void _set_position( + LOGICAL_AXIS_LIST(const int32_t &e, const int32_t &a, const int32_t &b, const int32_t &c) + ); + FORCE_INLINE static void _set_position(const abce_long_t &spos) { + _set_position(LOGICAL_AXIS_LIST(spos.e, spos.a, spos.b, spos.c)); + } FORCE_INLINE static uint32_t calc_timer_interval(uint32_t step_rate, uint8_t *loops) { uint32_t timer; diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index 8c943048ba96..5acc8607878d 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -35,7 +35,9 @@ #include #include -enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; +enum StealthIndex : uint8_t { + LOGICAL_AXIS_LIST(STEALTH_AXIS_E, STEALTH_AXIS_X, STEALTH_AXIS_Y, STEALTH_AXIS_Z) +}; #define TMC_INIT(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, stealthchop_by_axis[STEALTH_INDEX], chopper_timing_##ST, ST##_INTERPOLATE) // IC = TMC model number @@ -351,7 +353,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; #endif #endif - enum TMCAxis : uint8_t { X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7, TOTAL }; + enum TMCAxis : uint8_t { LINEAR_AXIS_LIST(X, Y, Z), X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7, TOTAL }; void tmc_serial_begin() { #if HAS_TMC_HW_SERIAL @@ -716,19 +718,24 @@ void restore_trinamic_drivers() { } void reset_trinamic_drivers() { - static constexpr bool stealthchop_by_axis[] = { ENABLED(STEALTHCHOP_XY), ENABLED(STEALTHCHOP_Z), ENABLED(STEALTHCHOP_E) }; + static constexpr bool stealthchop_by_axis[] = LOGICAL_AXIS_ARRAY( + ENABLED(STEALTHCHOP_E), + ENABLED(STEALTHCHOP_XY), + ENABLED(STEALTHCHOP_XY), + ENABLED(STEALTHCHOP_Z) + ); #if AXIS_IS_TMC(X) - TMC_INIT(X, STEALTH_AXIS_XY); + TMC_INIT(X, STEALTH_AXIS_X); #endif #if AXIS_IS_TMC(X2) - TMC_INIT(X2, STEALTH_AXIS_XY); + TMC_INIT(X2, STEALTH_AXIS_X); #endif #if AXIS_IS_TMC(Y) - TMC_INIT(Y, STEALTH_AXIS_XY); + TMC_INIT(Y, STEALTH_AXIS_Y); #endif #if AXIS_IS_TMC(Y2) - TMC_INIT(Y2, STEALTH_AXIS_XY); + TMC_INIT(Y2, STEALTH_AXIS_Y); #endif #if AXIS_IS_TMC(Z) TMC_INIT(Z, STEALTH_AXIS_Z); @@ -792,7 +799,7 @@ void reset_trinamic_drivers() { stepperZ4.homing_threshold(CAT(TERN(Z4_SENSORLESS, Z4, Z), _STALL_SENSITIVITY)); #endif #endif - #endif + #endif // USE SENSORLESS #ifdef TMC_ADV TMC_ADV() diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index a3711ca0766e..ecf82267f49c 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -171,10 +171,12 @@ exec_test $1 $2 "Azteeg X3 | Mixing Extruder (x5) | Gradient Mix | Greek" "$3" # Test Laser features with 12864 LCD # restore_configs -opt_set MOTHERBOARD BOARD_RAMPS_14_EFB LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 EXTRUDERS 0 TEMP_SENSOR_1 0 SERIAL_PORT_2 2 \ +opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 TEMP_SENSOR_1 0 SERIAL_PORT_2 2 \ DEFAULT_AXIS_STEPS_PER_UNIT '{ 80, 80, 400 }' \ DEFAULT_MAX_FEEDRATE '{ 300, 300, 5 }' \ - DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' + DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \ + MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ + AXIS_RELATIVE_MODES '{ false, false, false }' opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT \ LASER_FEATURE AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_COOLANT_FLOW_METER MEATPACK_ON_SERIAL_PORT_1 @@ -184,10 +186,12 @@ exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air As # Test Laser features with 44780 LCD # restore_configs -opt_set MOTHERBOARD BOARD_RAMPS_14_EFB LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 EXTRUDERS 0 TEMP_SENSOR_1 0 \ +opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 TEMP_SENSOR_1 0 \ DEFAULT_AXIS_STEPS_PER_UNIT '{ 80, 80, 400 }' \ DEFAULT_MAX_FEEDRATE '{ 300, 300, 5 }' \ - DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' + DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \ + MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ + AXIS_RELATIVE_MODES '{ false, false, false }' opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT \ LASER_FEATURE AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_COOLANT_FLOW_METER diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index 9869b96b3478..953e7e8efca9 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -48,6 +48,7 @@ opt_set MOTHERBOARD BOARD_RAMBO \ DEFAULT_AXIS_STEPS_PER_UNIT '{ 80, 80, 4000 }' \ DEFAULT_MAX_FEEDRATE '{ 300, 300, 5 }' \ DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \ + MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ AXIS_RELATIVE_MODES '{ false, false, false }' \ LEVEL_CORNERS_LEVELING_ORDER '{ LF, RF }' opt_enable USE_XMAX_PLUG USE_YMAX_PLUG USE_ZMAX_PLUG \ @@ -66,6 +67,7 @@ opt_set MOTHERBOARD BOARD_RAMBO EXTRUDERS 0 TEMP_SENSOR_BED 1 \ DEFAULT_AXIS_STEPS_PER_UNIT '{ 80, 80, 4000 }' \ DEFAULT_MAX_FEEDRATE '{ 300, 300, 5 }' \ DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \ + MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ AXIS_RELATIVE_MODES '{ false, false, false }' opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER exec_test $1 $2 "Rambo heated bed only" "$3" From 2dd25938ccba501a9bb74b55dfd0ce7ff4f508cc Mon Sep 17 00:00:00 2001 From: LawnMo <81721212+LawnMo@users.noreply.github.com> Date: Tue, 25 May 2021 00:53:48 +0200 Subject: [PATCH 49/61] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20multi=5Fvolume=20+?= =?UTF-8?q?=20SDIO=20onboard=20compile=20(#21975)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/sd/cardreader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 405da103de73..3890b08147de 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -144,7 +144,7 @@ uint32_t CardReader::filesize, CardReader::sdpos; CardReader::CardReader() { changeMedia(& #if SHARED_VOLUME_IS(SD_ONBOARD) - media_sd_spi + TERN(SDIO_SUPPORT, media_sdio, media_sd_spi) #elif SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT) media_usbFlashDrive #else From d051495dec8bbbe07ebcd95eb2e5b9e6d08d1fec Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 25 May 2021 01:09:52 +0000 Subject: [PATCH 50/61] [cron] Bump distribution date (2021-05-25) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 3690ea2c92f7..2c57bad3701c 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-05-24" + #define STRING_DISTRIBUTION_DATE "2021-05-25" #endif /** From e60c38b6220678b3b9f3a3b31516852f8d25b3b0 Mon Sep 17 00:00:00 2001 From: ellensp Date: Wed, 26 May 2021 11:38:23 +1200 Subject: [PATCH 51/61] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20LEDs=20refactor=20an?= =?UTF-8?q?d=20extend=20(#21962)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 11 +-- Marlin/src/feature/caselight.cpp | 4 +- Marlin/src/feature/leds/leds.cpp | 51 ++++++------ Marlin/src/feature/leds/leds.h | 31 ++++--- Marlin/src/feature/leds/neopixel.cpp | 80 +++++++++---------- Marlin/src/feature/leds/neopixel.h | 73 +++++++++-------- .../src/feature/leds/printer_event_leds.cpp | 8 +- Marlin/src/gcode/feature/leds/M150.cpp | 8 +- Marlin/src/inc/Conditionals_LCD.h | 7 ++ Marlin/src/inc/SanityCheck.h | 2 + Marlin/src/lcd/marlinui.cpp | 4 +- Marlin/src/lcd/menu/menu_led.cpp | 12 +-- buildroot/tests/DUE | 2 +- buildroot/tests/LPC1768 | 6 +- buildroot/tests/rambo | 2 +- 15 files changed, 158 insertions(+), 143 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index dd6abd562999..366267aa7e97 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2690,7 +2690,7 @@ //#define NEOPIXEL_LED #if ENABLED(NEOPIXEL_LED) #define NEOPIXEL_TYPE NEO_GRBW // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) - #define NEOPIXEL_PIN 4 // LED driving pin + //#define NEOPIXEL_PIN 4 // LED driving pin //#define NEOPIXEL2_TYPE NEOPIXEL_TYPE //#define NEOPIXEL2_PIN 5 #define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip. (Longest strip when NEOPIXEL2_SEPARATE is disabled.) @@ -2708,10 +2708,11 @@ //#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel #endif - // Use a single NeoPixel LED for static (background) lighting - //#define NEOPIXEL_BKGD_LED_INDEX 0 // Index of the LED to use - //#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W - //#define NEOPIXEL_BKGD_ALWAYS_ON // Keep the backlight on when other NeoPixels are off + // Use some of the NeoPixel LEDs for static (background) lighting + //#define NEOPIXEL_BKGD_INDEX_FIRST 0 // Index of the first background LED + //#define NEOPIXEL_BKGD_INDEX_LAST 5 // Index of the last background LED + //#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W + //#define NEOPIXEL_BKGD_ALWAYS_ON // Keep the backlight on when other NeoPixels are off #endif /** diff --git a/Marlin/src/feature/caselight.cpp b/Marlin/src/feature/caselight.cpp index ec4ad99c75eb..1baef6d46845 100644 --- a/Marlin/src/feature/caselight.cpp +++ b/Marlin/src/feature/caselight.cpp @@ -65,9 +65,7 @@ void CaseLight::update(const bool sflag) { #endif #if CASE_LIGHT_IS_COLOR_LED - - leds.set_color(MakeLEDColor(color.r, color.g, color.b, color.w, n10ct)); - + leds.set_color(LEDColor(color.r, color.g, color.b OPTARG(HAS_WHITE_LED, color.w), n10ct)); #else // !CASE_LIGHT_IS_COLOR_LED #if CASELIGHT_USES_BRIGHTNESS diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index c9178effa88c..328daa626d46 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -47,9 +47,10 @@ #endif #if ENABLED(LED_COLOR_PRESETS) - const LEDColor LEDLights::defaultLEDColor = MakeLEDColor( - LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, - LED_USER_PRESET_WHITE, LED_USER_PRESET_BRIGHTNESS + const LEDColor LEDLights::defaultLEDColor = LEDColor( + LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE + OPTARG(HAS_WHITE_LED, LED_USER_PRESET_WHITE) + OPTARG(NEOPIXEL_LED, LED_USER_PRESET_BRIGHTNESS) ); #endif @@ -75,34 +76,35 @@ void LEDLights::setup() { } void LEDLights::set_color(const LEDColor &incol - OPTARG(NEOPIXEL_LED, bool isSequence/*=false*/) + OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence/*=false*/) ) { #if ENABLED(NEOPIXEL_LED) const uint32_t neocolor = LEDColorWhite() == incol ? neo.Color(NEO_WHITE) - : neo.Color(incol.r, incol.g, incol.b, incol.w); - static uint16_t nextLed = 0; - - #ifdef NEOPIXEL_BKGD_LED_INDEX - if (NEOPIXEL_BKGD_LED_INDEX == nextLed) { - neo.set_color_background(); - if (++nextLed >= neo.pixels()) { - nextLed = 0; - return; + : neo.Color(incol.r, incol.g, incol.b OPTARG(HAS_WHITE_LED, incol.w)); + + #if ENABLED(NEOPIXEL_IS_SEQUENTIAL) + static uint16_t nextLed = 0; + #ifdef NEOPIXEL_BKGD_INDEX_FIRST + while (WITHIN(nextLed, NEOPIXEL_BKGD_INDEX_FIRST, NEOPIXEL_BKGD_INDEX_LAST)) { + neo.reset_background_color(); + if (++nextLed >= neo.pixels()) { nextLed = 0; return; } } - } + #endif #endif neo.set_brightness(incol.i); - if (isSequence) { - neo.set_pixel_color(nextLed, neocolor); - neo.show(); - if (++nextLed >= neo.pixels()) nextLed = 0; - return; - } + #if ENABLED(NEOPIXEL_IS_SEQUENTIAL) + if (isSequence) { + neo.set_pixel_color(nextLed, neocolor); + neo.show(); + if (++nextLed >= neo.pixels()) nextLed = 0; + return; + } + #endif neo.set_color(neocolor); @@ -167,9 +169,10 @@ void LEDLights::set_color(const LEDColor &incol #if ENABLED(NEOPIXEL2_SEPARATE) #if ENABLED(NEO2_COLOR_PRESETS) - const LEDColor LEDLights2::defaultLEDColor = MakeLEDColor( - NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, - NEO2_USER_PRESET_WHITE, NEO2_USER_PRESET_BRIGHTNESS + const LEDColor LEDLights2::defaultLEDColor = LEDColor( + LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE + OPTARG(HAS_WHITE_LED2, LED_USER_PRESET_WHITE) + OPTARG(NEOPIXEL_LED, LED_USER_PRESET_BRIGHTNESS) ); #endif @@ -188,7 +191,7 @@ void LEDLights::set_color(const LEDColor &incol void LEDLights2::set_color(const LEDColor &incol) { const uint32_t neocolor = LEDColorWhite() == incol ? neo2.Color(NEO2_WHITE) - : neo2.Color(incol.r, incol.g, incol.b, incol.w); + : neo2.Color(incol.r, incol.g, incol.b OPTARG(HAS_WHITE_LED2, incol.w)); neo2.set_brightness(incol.i); neo2.set_color(neocolor); diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 4157ff816eec..74964b51a8e4 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -29,15 +29,17 @@ #include -#if ENABLED(NEOPIXEL_LED) - #include "neopixel.h" -#endif - // A white component can be passed -#if ANY(RGBW_LED, NEOPIXEL_LED, PCA9632_RGBW) +#if EITHER(RGBW_LED, PCA9632_RGBW) #define HAS_WHITE_LED 1 #endif +#if ENABLED(NEOPIXEL_LED) + #define _NEOPIXEL_INCLUDE_ + #include "neopixel.h" + #undef _NEOPIXEL_INCLUDE_ +#endif + /** * LEDcolor type for use with leds.set_color */ @@ -84,9 +86,8 @@ typedef struct LEDColor { } LEDColor; /** - * Color helpers and presets + * Color presets */ -#define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B OPTARG(HAS_WHITE_LED, W) OPTARG(NEOPIXEL_LED, I)) #define LEDColorOff() LEDColor( 0, 0, 0) #define LEDColorRed() LEDColor(255, 0, 0) @@ -114,15 +115,15 @@ class LEDLights { static void setup(); // init() static void set_color(const LEDColor &color - OPTARG(NEOPIXEL_LED, bool isSequence=false) + OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence=false) ); static inline void set_color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w=0) OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS) - OPTARG(NEOPIXEL_LED, bool isSequence=false) + OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence=false) ) { - set_color(MakeLEDColor(r, g, b, w, i) OPTARG(NEOPIXEL_LED, isSequence)); + set_color(LEDColor(r, g, b OPTARG(HAS_WHITE_LED, w) OPTARG(NEOPIXEL_LED, i)) OPTARG(NEOPIXEL_IS_SEQUENTIAL, isSequence)); } static inline void set_off() { set_color(LEDColorOff()); } @@ -180,8 +181,14 @@ extern LEDLights leds; static void set_color(const LEDColor &color); - inline void set_color(uint8_t r, uint8_t g, uint8_t b, uint8_t w=0, uint8_t i=NEOPIXEL2_BRIGHTNESS) { - set_color(MakeLEDColor(r, g, b, w, i)); + static inline void set_color(uint8_t r, uint8_t g, uint8_t b + OPTARG(HAS_WHITE_LED, uint8_t w=0) + OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS) + ) { + set_color(LEDColor(r, g, b + OPTARG(HAS_WHITE_LED, w) + OPTARG(NEOPIXEL_LED, i) + )); } static inline void set_off() { set_color(LEDColorOff()); } diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index bdd22837ada5..2654e9a1df5a 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -28,7 +28,7 @@ #if ENABLED(NEOPIXEL_LED) -#include "neopixel.h" +#include "leds.h" #if EITHER(NEOPIXEL_STARTUP_TEST, NEOPIXEL2_STARTUP_TEST) #include "../../core/utility.h" @@ -37,17 +37,21 @@ Marlin_NeoPixel neo; int8_t Marlin_NeoPixel::neoindex; -Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800) - #if CONJOINED_NEOPIXEL - , Marlin_NeoPixel::adaneo2(NEOPIXEL_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE + NEO_KHZ800) - #endif -; +Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800); +#if CONJOINED_NEOPIXEL + Adafruit_NeoPixel Marlin_NeoPixel::adaneo2(NEOPIXEL_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE + NEO_KHZ800); +#endif -#ifdef NEOPIXEL_BKGD_LED_INDEX +#ifdef NEOPIXEL_BKGD_INDEX_FIRST + + void Marlin_NeoPixel::set_background_color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { + for (int background_led = NEOPIXEL_BKGD_INDEX_FIRST; background_led <= NEOPIXEL_BKGD_INDEX_LAST; background_led++) + set_pixel_color(background_led, adaneo1.Color(r, g, b, w)); + } - void Marlin_NeoPixel::set_color_background() { - uint8_t background_color[4] = NEOPIXEL_BKGD_COLOR; - set_pixel_color(NEOPIXEL_BKGD_LED_INDEX, adaneo1.Color(background_color[0], background_color[1], background_color[2], background_color[3])); + void Marlin_NeoPixel::reset_background_color() { + constexpr uint8_t background_color[4] = NEOPIXEL_BKGD_COLOR; + set_background_color(background_color[0], background_color[1], background_color[2], background_color[3]); } #endif @@ -59,9 +63,10 @@ void Marlin_NeoPixel::set_color(const uint32_t color) { } else { for (uint16_t i = 0; i < pixels(); ++i) { - #ifdef NEOPIXEL_BKGD_LED_INDEX - if (i == NEOPIXEL_BKGD_LED_INDEX && TERN(NEOPIXEL_BKGD_ALWAYS_ON, true, color != 0x000000)) { - set_color_background(); + #ifdef NEOPIXEL_BKGD_INDEX_FIRST + if (i == NEOPIXEL_BKGD_INDEX_FIRST && TERN(NEOPIXEL_BKGD_ALWAYS_ON, true, color != 0x000000)) { + reset_background_color(); + i += NEOPIXEL_BKGD_INDEX_LAST - (NEOPIXEL_BKGD_INDEX_FIRST); continue; } #endif @@ -90,35 +95,22 @@ void Marlin_NeoPixel::init() { safe_delay(500); set_color_startup(adaneo1.Color(0, 0, 255, 0)); // blue safe_delay(500); + #if HAS_WHITE_LED + set_color_startup(adaneo1.Color(0, 0, 0, 255)); // white + safe_delay(500); + #endif #endif - #ifdef NEOPIXEL_BKGD_LED_INDEX - set_color_background(); - #endif - - #if ENABLED(LED_USER_PRESET_STARTUP) - set_color(adaneo1.Color(LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE)); - #else - set_color(adaneo1.Color(0, 0, 0, 0)); + #ifdef NEOPIXEL_BKGD_INDEX_FIRST + reset_background_color(); #endif -} -#if 0 -bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p) { - const uint32_t color = adaneo1.Color(r, g, b, w); - set_brightness(p); - #if DISABLED(NEOPIXEL_IS_SEQUENTIAL) - set_color(color); - return false; - #else - static uint16_t nextLed = 0; - set_pixel_color(nextLed, color); - show(); - if (++nextLed >= pixels()) nextLed = 0; - return true; - #endif + set_color(adaneo1.Color + TERN(LED_USER_PRESET_STARTUP, + (LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE), + (0, 0, 0, 0)) + ); } -#endif #if ENABLED(NEOPIXEL2_SEPARATE) @@ -158,13 +150,17 @@ bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint safe_delay(500); set_color_startup(adaneo.Color(0, 0, 255, 0)); // blue safe_delay(500); + #if HAS_WHITE_LED2 + set_color_startup(adaneo.Color(0, 0, 0, 255)); // white + safe_delay(500); + #endif #endif - #if ENABLED(NEO2_USER_PRESET_STARTUP) - set_color(adaneo.Color(NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, NEO2_USER_PRESET_WHITE)); - #else - set_color(adaneo.Color(0, 0, 0, 0)); - #endif + set_color(adaneo.Color + TERN(NEO2_USER_PRESET_STARTUP, + (NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, NEO2_USER_PRESET_WHITE), + (0, 0, 0, 0)) + ); } #endif // NEOPIXEL2_SEPARATE diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index acf2e7f54d3b..e577948cd851 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -25,6 +25,10 @@ * NeoPixel support */ +#ifndef _NEOPIXEL_INCLUDE_ + #error "Always include 'leds.h' and not 'neopixel.h' directly." +#endif + // ------------------------ // Includes // ------------------------ @@ -38,24 +42,24 @@ // Defines // ------------------------ -#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE && DISABLED(NEOPIXEL2_SEPARATE) - #define MULTIPLE_NEOPIXEL_TYPES 1 -#endif +#define _NEO_IS_RGB(N) (N == NEO_RGB || N == NEO_RBG || N == NEO_GRB || N == NEO_GBR || N == NEO_BRG || N == NEO_BGR) -#if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) - #define CONJOINED_NEOPIXEL 1 +#if !_NEO_IS_RGB(NEOPIXEL_TYPE) + #define HAS_WHITE_LED 1 #endif -#if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR - #define NEOPIXEL_IS_RGB 1 +#if HAS_WHITE_LED + #define NEO_WHITE 0, 0, 0, 255 #else - #define NEOPIXEL_IS_RGBW 1 + #define NEO_WHITE 255, 255, 255 #endif -#if NEOPIXEL_IS_RGB - #define NEO_WHITE 255, 255, 255, 0 -#else - #define NEO_WHITE 0, 0, 0, 255 +#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE && DISABLED(NEOPIXEL2_SEPARATE) + #define MULTIPLE_NEOPIXEL_TYPES 1 +#endif + +#if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) + #define CONJOINED_NEOPIXEL 1 #endif // ------------------------ @@ -64,11 +68,10 @@ class Marlin_NeoPixel { private: - static Adafruit_NeoPixel adaneo1 - #if CONJOINED_NEOPIXEL - , adaneo2 - #endif - ; + static Adafruit_NeoPixel adaneo1; + #if CONJOINED_NEOPIXEL + static Adafruit_NeoPixel adaneo2; + #endif public: static int8_t neoindex; @@ -78,8 +81,9 @@ class Marlin_NeoPixel { static void set_color(const uint32_t c); - #ifdef NEOPIXEL_BKGD_LED_INDEX - static void set_color_background(); + #ifdef NEOPIXEL_BKGD_INDEX_FIRST + static void set_background_color(uint8_t r, uint8_t g, uint8_t b, uint8_t w); + static void reset_background_color(); #endif static inline void begin() { @@ -93,9 +97,7 @@ class Marlin_NeoPixel { else adaneo1.setPixelColor(n, c); #else adaneo1.setPixelColor(n, c); - #if MULTIPLE_NEOPIXEL_TYPES - adaneo2.setPixelColor(n, c); - #endif + TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setPixelColor(n, c)); #endif } @@ -120,15 +122,13 @@ class Marlin_NeoPixel { TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT()); } - #if 0 - bool set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p); - #endif - // Accessors - static inline uint16_t pixels() { TERN(NEOPIXEL2_INSERIES, return adaneo1.numPixels() * 2, return adaneo1.numPixels()); } + static inline uint16_t pixels() { return adaneo1.numPixels() * TERN1(NEOPIXEL2_INSERIES, 2); } + static inline uint8_t brightness() { return adaneo1.getBrightness(); } - static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { - return adaneo1.Color(r, g, b, w); + + static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w)) { + return adaneo1.Color(r, g, b OPTARG(HAS_WHITE_LED, w)); } }; @@ -137,15 +137,12 @@ extern Marlin_NeoPixel neo; // Neo pixel channel 2 #if ENABLED(NEOPIXEL2_SEPARATE) - #if NEOPIXEL2_TYPE == NEO_RGB || NEOPIXEL2_TYPE == NEO_RBG || NEOPIXEL2_TYPE == NEO_GRB || NEOPIXEL2_TYPE == NEO_GBR || NEOPIXEL2_TYPE == NEO_BRG || NEOPIXEL2_TYPE == NEO_BGR + #if _NEO_IS_RGB(NEOPIXEL2_TYPE) #define NEOPIXEL2_IS_RGB 1 + #define NEO2_WHITE 255, 255, 255 #else #define NEOPIXEL2_IS_RGBW 1 - #endif - - #if NEOPIXEL2_IS_RGB - #define NEO2_WHITE 255, 255, 255, 0 - #else + #define HAS_WHITE_LED2 1 // A white component can be passed for NEOPIXEL2 #define NEO2_WHITE 0, 0, 0, 255 #endif @@ -172,11 +169,13 @@ extern Marlin_NeoPixel neo; // Accessors static inline uint16_t pixels() { return adaneo.numPixels();} static inline uint8_t brightness() { return adaneo.getBrightness(); } - static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { - return adaneo.Color(r, g, b, w); + static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED2, uint8_t w)) { + return adaneo.Color(r, g, b OPTARG(HAS_WHITE_LED2, w)); } }; extern Marlin_NeoPixel2 neo2; #endif // NEOPIXEL2_SEPARATE + +#undef _NEO_IS_RGB diff --git a/Marlin/src/feature/leds/printer_event_leds.cpp b/Marlin/src/feature/leds/printer_event_leds.cpp index 4765f82e56f6..e6407a6320a5 100644 --- a/Marlin/src/feature/leds/printer_event_leds.cpp +++ b/Marlin/src/feature/leds/printer_event_leds.cpp @@ -45,12 +45,10 @@ PrinterEventLEDs printerEventLEDs; return (uint8_t)map(constrain(current, start, target), start, target, 0, 255); } - inline void pel_set_rgb(const uint8_t r, const uint8_t g, const uint8_t b) { + inline void pel_set_rgb(const uint8_t r, const uint8_t g, const uint8_t b OPTARG(HAS_WHITE_LED, const uint8_t w=0)) { leds.set_color( - MakeLEDColor(r, g, b, 0, neo.brightness()) - #if ENABLED(NEOPIXEL_IS_SEQUENTIAL) - , true - #endif + LEDColor(r, g, b OPTARG(HAS_WHITE_LED, w) OPTARG(NEOPIXEL_LED, neo.brightness())) + OPTARG(NEOPIXEL_IS_SEQUENTIAL, true) ); } diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index cf09bf14ead7..5d175ea8f779 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -66,12 +66,12 @@ void GcodeSuite::M150() { #endif #endif - const LEDColor color = MakeLEDColor( + const LEDColor color = LEDColor( parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : 0, parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : 0, - parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : 0, - parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : 0, - parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : brightness + parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : 0 + OPTARG(HAS_WHITE_LED, parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : 0) + OPTARG(NEOPIXEL_LED, parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : brightness) ); #if ENABLED(NEOPIXEL2_SEPARATE) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index a8bd7a70ac97..c89aaada37fe 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1321,3 +1321,10 @@ #else #define COORDINATE_OKAY(N,L,H) true #endif + +/** + * LED Backlight INDEX END + */ +#if defined(NEOPIXEL_BKGD_INDEX_FIRST) && !defined(NEOPIXEL_BKGD_INDEX_LAST) + #define NEOPIXEL_BKGD_INDEX_LAST NEOPIXEL_BKGD_INDEX_FIRST +#endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index eea67661481e..6ab1fdd3c2d3 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -562,6 +562,8 @@ #error "CUSTOM_USER_MENUS has been replaced by CUSTOM_MENU_MAIN and CUSTOM_MENU_CONFIG." #elif defined(MKS_LCD12864) #error "MKS_LCD12864 is now MKS_LCD12864A or MKS_LCD12864B." +#elif defined(NEOPIXEL_BKGD_LED_INDEX) + #error "NEOPIXEL_BKGD_LED_INDEX is now NEOPIXEL_BKGD_INDEX_FIRST." #endif /** diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 044a6642fc1f..cff6e1935494 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -636,8 +636,8 @@ void MarlinUI::kill_screen(PGM_P lcd_error, PGM_P lcd_component) { // RED ALERT. RED ALERT. #ifdef LED_BACKLIGHT_TIMEOUT leds.set_color(LEDColorRed()); - #ifdef NEOPIXEL_BKGD_LED_INDEX - neo.set_pixel_color(NEOPIXEL_BKGD_LED_INDEX, 255, 0, 0, 0); + #ifdef NEOPIXEL_BKGD_INDEX_FIRST + neo.set_background_color(255, 0, 0, 0); neo.show(); #endif #endif diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index 5ab5e8a9d8dc..284e80c931b7 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -84,18 +84,20 @@ EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true); - #if EITHER(RGBW_LED, NEOPIXEL_LED) + #if HAS_WHITE_LED EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds.color.w, 0, 255, leds.update, true); - #if ENABLED(NEOPIXEL_LED) - EDIT_ITEM(uint8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true); - #endif + #endif + #if ENABLED(NEOPIXEL_LED) + EDIT_ITEM(uint8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true); #endif #if ENABLED(NEOPIXEL2_SEPARATE) STATIC_ITEM_N(MSG_LED_CHANNEL_N, 2, SS_DEFAULT|SS_INVERT); EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds2.color.r, 0, 255, leds2.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds2.color.g, 0, 255, leds2.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds2.color.b, 0, 255, leds2.update, true); - EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds2.color.w, 0, 255, leds2.update, true); + #if HAS_WHITE_LED2 + EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds2.color.w, 0, 255, leds2.update, true); + #endif EDIT_ITEM(uint8, MSG_NEO2_BRIGHTNESS, &leds2.color.i, 0, 255, leds2.update, true); #endif END_MENU(); diff --git a/buildroot/tests/DUE b/buildroot/tests/DUE index d1601edf5ab7..9931776e0046 100755 --- a/buildroot/tests/DUE +++ b/buildroot/tests/DUE @@ -18,7 +18,7 @@ opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \ ASSISTED_TRAMMING ASSISTED_TRAMMING_WIZARD REPORT_TRAMMING_MM ASSISTED_TRAMMING_WAIT_POSITION \ EEPROM_SETTINGS SDSUPPORT BINARY_FILE_TRANSFER \ BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \ - NEOPIXEL_LED CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_USE_RGB_LED CASE_LIGHT_MENU \ + NEOPIXEL_LED NEOPIXEL_PIN CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_USE_RGB_LED CASE_LIGHT_MENU \ NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_DISTANCE_MM FILAMENT_RUNOUT_SENSOR \ AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE CALIBRATION_GCODE \ diff --git a/buildroot/tests/LPC1768 b/buildroot/tests/LPC1768 index 92fda5448346..95a055d6951f 100755 --- a/buildroot/tests/LPC1768 +++ b/buildroot/tests/LPC1768 @@ -14,8 +14,10 @@ set -e #exec_test $1 $2 "Default Configuration" "$3" restore_configs -opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB NEOPIXEL_PIN P1_16 SERIAL_PORT_3 3 -opt_enable VIKI2 SDSUPPORT SDCARD_READONLY SERIAL_PORT_2 NEOPIXEL_LED +opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB SERIAL_PORT_3 3 \ + NEOPIXEL_TYPE NEO_GRB RGB_LED_R_PIN P2_12 RGB_LED_G_PIN P1_23 RGB_LED_B_PIN P1_22 RGB_LED_W_PIN P1_24 +opt_enable FYSETC_MINI_12864_2_1 SDSUPPORT SDCARD_READONLY SERIAL_PORT_2 RGBW_LED \ + NEOPIXEL_LED NEOPIXEL_IS_SEQUENTIAL NEOPIXEL_STARTUP_TEST NEOPIXEL_BKGD_INDEX_FIRST NEOPIXEL_BKGD_INDEX_LAST NEOPIXEL_BKGD_COLOR NEOPIXEL_BKGD_ALWAYS_ON exec_test $1 $2 "ReARM EFB VIKI2, SDSUPPORT, 2 Serial ports (USB CDC + UART0), NeoPixel" "$3" #restore_configs diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index 953e7e8efca9..df2717c715a6 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -22,7 +22,7 @@ opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_P PREHEAT_BEFORE_PROBING PROBING_HEATERS_OFF PROBING_FANS_OFF PROBING_STEPPERS_OFF WAIT_FOR_BED_HEATER \ EEPROM_SETTINGS SDSUPPORT SD_REPRINT_LAST_SELECTED_FILE BINARY_FILE_TRANSFER \ BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \ - NEOPIXEL_LED CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_MENU \ + NEOPIXEL_LED NEOPIXEL_PIN CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_MENU \ PID_PARAMS_PER_HOTEND PID_AUTOTUNE_MENU PID_EDIT_MENU LCD_SHOW_E_TOTAL \ PRINTCOUNTER SERVICE_NAME_1 SERVICE_INTERVAL_1 LEVEL_BED_CORNERS LEVEL_CENTER_TOO \ NOZZLE_PARK_FEATURE FILAMENT_RUNOUT_SENSOR FILAMENT_RUNOUT_DISTANCE_MM \ From e400ef346a317fe36dd98b821c3b04098d8b7a3c Mon Sep 17 00:00:00 2001 From: Allen Bauer Date: Tue, 25 May 2021 17:08:10 -0700 Subject: [PATCH 52/61] =?UTF-8?q?=F0=9F=90=9B=20Fix=20BTT002=20variant=20M?= =?UTF-8?q?MU2=20serial=20pins=20=F0=9F=A7=A9=20(#21980)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h index ecc319f47ce0..59a7f24527ba 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h @@ -264,6 +264,11 @@ extern "C" { #define PIN_SERIAL_RX PA10 #define PIN_SERIAL_TX PA9 +// Serial Pins for the MMU2 +#define ENABLE_HWSERIAL4 +#define PIN_SERIAL4_RX PC11 +#define PIN_SERIAL4_TX PC10 + #ifdef __cplusplus } // extern "C" #endif From 214fe90a3bb840a15affa350a61e54b8bd740f0e Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 26 May 2021 01:24:58 +0000 Subject: [PATCH 53/61] [cron] Bump distribution date (2021-05-26) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 2c57bad3701c..4d02ddf997f4 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-05-25" + #define STRING_DISTRIBUTION_DATE "2021-05-26" #endif /** From 6a32d87e582af5434061d6413648e6ee1822275e Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 27 May 2021 01:36:38 +0000 Subject: [PATCH 54/61] [cron] Bump distribution date (2021-05-27) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 4d02ddf997f4..7f7765515c51 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-05-26" + #define STRING_DISTRIBUTION_DATE "2021-05-27" #endif /** From 5c6a2f4d0d19c786ee00c8a828e150290d793c26 Mon Sep 17 00:00:00 2001 From: Andy Barratt Date: Thu, 27 May 2021 03:07:13 +0100 Subject: [PATCH 55/61] =?UTF-8?q?=F0=9F=9A=B8=20cap:HOST=5FACTION=5FCOMMAN?= =?UTF-8?q?DS=20(#21987)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/host/M115.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index ef4c8983cdd7..49bb806377a9 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -119,6 +119,9 @@ void GcodeSuite::M115() { // EMERGENCY_PARSER (M108, M112, M410, M876) cap_line(PSTR("EMERGENCY_PARSER"), ENABLED(EMERGENCY_PARSER)); + // HOST ACTION COMMANDS (paused, resume, resumed, cancel, etc.) + cap_line(PSTR("HOST_ACTION_COMMANDS"), ENABLED(HOST_ACTION_COMMANDS)); + // PROMPT SUPPORT (M876) cap_line(PSTR("PROMPT_SUPPORT"), ENABLED(HOST_PROMPT_SUPPORT)); From 605b539ecdcaaa54cfaec2317c2fe7eab0ba2680 Mon Sep 17 00:00:00 2001 From: ellensp Date: Thu, 27 May 2021 22:13:43 +1200 Subject: [PATCH 56/61] =?UTF-8?q?=F0=9F=A5=85=20Add=20MESH=5FEDIT=5FMENU?= =?UTF-8?q?=20sanity=20check=20(#21922)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 6ab1fdd3c2d3..9181b240001d 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1584,6 +1584,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "LCD_BED_LEVELING requires a programmable LCD controller." #elif !(ENABLED(MESH_BED_LEVELING) || HAS_ABL_NOT_UBL) #error "LCD_BED_LEVELING requires MESH_BED_LEVELING or AUTO_BED_LEVELING." + #elif ENABLED(MESH_EDIT_MENU) && !HAS_MESH + #error "MESH_EDIT_MENU requires MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR or AUTO_BED_LEVELING_UBL." #endif #endif From b80179d14a23911dc81dfa7fe9d6fca653326798 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 28 May 2021 01:45:42 +0000 Subject: [PATCH 57/61] [cron] Bump distribution date (2021-05-28) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 7f7765515c51..5c5ff6c31cab 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-05-27" + #define STRING_DISTRIBUTION_DATE "2021-05-28" #endif /** From 25a8bbcbf3c7dbbc68aec9a85a8091488a2011b4 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 29 May 2021 02:01:09 +0000 Subject: [PATCH 58/61] [cron] Bump distribution date (2021-05-29) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 5c5ff6c31cab..1312a0788031 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-05-28" + #define STRING_DISTRIBUTION_DATE "2021-05-29" #endif /** From dbed0090900d3924cf8e30f2afa2e349d7ecbb18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20B=C5=82a=C5=BCewicz?= Date: Sat, 29 May 2021 20:48:56 +0200 Subject: [PATCH 59/61] =?UTF-8?q?=F0=9F=8C=90=20Update=20Polish=20language?= =?UTF-8?q?=20(#21993)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/language/language_pl.h | 328 ++++++++++++++++++++------ 1 file changed, 259 insertions(+), 69 deletions(-) diff --git a/Marlin/src/lcd/language/language_pl.h b/Marlin/src/lcd/language/language_pl.h index 9004722cfcdf..7b4733b7ba32 100644 --- a/Marlin/src/lcd/language/language_pl.h +++ b/Marlin/src/lcd/language/language_pl.h @@ -26,6 +26,13 @@ * * LCD Menu Messages * See also https://marlinfw.org/docs/development/lcd_language.html + * + * Substitutions are applied for the following characters when used + * in menu items that call lcd_put_u8str_ind_P with an index: + * + * = displays '0'....'10' for indexes 0 - 10 + * ~ displays '1'....'11' for indexes 0 - 10 + * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) */ #define DISPLAY_CHARSET_ISO10646_PL @@ -34,9 +41,10 @@ namespace Language_pl { using namespace Language_en; // Inherit undefined strings from English constexpr uint8_t CHARSIZE = 2; - PROGMEM Language_Str LANGUAGE = _UxGT("Polish"); + PROGMEM Language_Str LANGUAGE = _UxGT("Polski"); PROGMEM Language_Str WELCOME_MSG = MACHINE_NAME _UxGT(" gotowy."); + //PROGMEM Language_Str MSG_MARLIN = _UxGT("Marlin"); PROGMEM Language_Str MSG_YES = _UxGT("TAK"); PROGMEM Language_Str MSG_NO = _UxGT("NIE"); PROGMEM Language_Str MSG_BACK = _UxGT("Wstecz"); @@ -44,9 +52,11 @@ namespace Language_pl { PROGMEM Language_Str MSG_MEDIA_INSERTED = _UxGT("Karta włożona"); PROGMEM Language_Str MSG_MEDIA_REMOVED = _UxGT("Karta usunięta"); PROGMEM Language_Str MSG_MEDIA_WAITING = _UxGT("Oczekiwanie na kartę"); + PROGMEM Language_Str MSG_SD_INIT_FAIL = _UxGT("Błąd inicializacji karty"); PROGMEM Language_Str MSG_MEDIA_READ_ERROR = _UxGT("Bład odczytu karty"); PROGMEM Language_Str MSG_MEDIA_USB_REMOVED = _UxGT("Urządzenie USB usunięte"); PROGMEM Language_Str MSG_MEDIA_USB_FAILED = _UxGT("Błąd uruchomienia USB"); + //PROGMEM Language_Str MSG_KILL_SUBCALL_OVERFLOW = _UxGT("Subcall Overflow"); PROGMEM Language_Str MSG_LCD_ENDSTOPS = _UxGT("Krańców."); // Max length 8 characters PROGMEM Language_Str MSG_LCD_SOFT_ENDSTOPS = _UxGT("Progr. Krańcówki"); PROGMEM Language_Str MSG_MAIN = _UxGT("Menu główne"); @@ -61,14 +71,24 @@ namespace Language_pl { PROGMEM Language_Str MSG_AUTO_HOME_Y = _UxGT("Zeruj Y"); PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Zeruj Z"); PROGMEM Language_Str MSG_AUTO_Z_ALIGN = _UxGT("Autowyrównanie Z"); + //PROGMEM Language_Str MSG_ITERATION = _UxGT("G34 Iteration: %i"); + PROGMEM Language_Str MSG_DECREASING_ACCURACY = _UxGT("Spadek dokładności!"); + PROGMEM Language_Str MSG_ACCURACY_ACHIEVED = _UxGT("Osiągnięto dokładność"); PROGMEM Language_Str MSG_LEVEL_BED_HOMING = _UxGT("Pozycja zerowa"); PROGMEM Language_Str MSG_LEVEL_BED_WAITING = _UxGT("Kliknij by rozp."); PROGMEM Language_Str MSG_LEVEL_BED_NEXT_POINT = _UxGT("Następny punkt"); PROGMEM Language_Str MSG_LEVEL_BED_DONE = _UxGT("Wypoziomowano!"); PROGMEM Language_Str MSG_Z_FADE_HEIGHT = _UxGT("Wys. zanikania"); PROGMEM Language_Str MSG_SET_HOME_OFFSETS = _UxGT("Ust. poz. zer."); + //PROGMEM Language_Str MSG_HOME_OFFSET_X = _UxGT("Home Offset X"); + //PROGMEM Language_Str MSG_HOME_OFFSET_Y = _UxGT("Home Offset Y"); + //PROGMEM Language_Str MSG_HOME_OFFSET_Z = _UxGT("Home Offset Z"); PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED = _UxGT("Poz. zerowa ust."); PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Ustaw punkt zero"); + //PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Assisted Tramming"); + //PROGMEM Language_Str MSG_TRAMMING_WIZARD = _UxGT("Tramming Wizard"); + PROGMEM Language_Str MSG_SELECT_ORIGIN = _UxGT("Wybierz punkt zero"); + PROGMEM Language_Str MSG_LAST_VALUE_SP = _UxGT("Poprzednia wartość "); #if PREHEAT_COUNT PROGMEM Language_Str MSG_PREHEAT_1 = _UxGT("Rozgrzej ") PREHEAT_1_LABEL; PROGMEM Language_Str MSG_PREHEAT_1_H = _UxGT("Rozgrzej ") PREHEAT_1_LABEL " ~"; @@ -88,10 +108,21 @@ namespace Language_pl { #endif PROGMEM Language_Str MSG_PREHEAT_CUSTOM = _UxGT("Rozgrzej własne ust."); PROGMEM Language_Str MSG_COOLDOWN = _UxGT("Chłodzenie"); + + PROGMEM Language_Str MSG_CUTTER_FREQUENCY = _UxGT("Częstotliwość"); PROGMEM Language_Str MSG_LASER_MENU = _UxGT("Sterowanie Lasera"); - PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Zasilanie Lasera"); PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Sterowanie wrzeciona"); + PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Zasilanie Lasera"); PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Zasilanie wrzeciona"); + //PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Toggle Laser"); + //PROGMEM Language_Str MSG_LASER_EVAC_TOGGLE = _UxGT("Toggle Blower"); + //PROGMEM Language_Str MSG_LASER_ASSIST_TOGGLE = _UxGT("Air Assist"); + //PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Test Pulse ms"); + //PROGMEM Language_Str MSG_LASER_FIRE_PULSE = _UxGT("Fire Pulse"); + //PROGMEM Language_Str MSG_FLOWMETER_FAULT = _UxGT("Coolant Flow Fault"); + //PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Toggle Spindle"); + //PROGMEM Language_Str MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Toggle Vacuum"); + //PROGMEM Language_Str MSG_SPINDLE_FORWARD = _UxGT("Spindle Forward"); PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Rewers wrzeciona"); PROGMEM Language_Str MSG_SWITCH_PS_ON = _UxGT("Włącz zasilacz"); PROGMEM Language_Str MSG_SWITCH_PS_OFF = _UxGT("Wyłącz zasilacz"); @@ -101,6 +132,10 @@ namespace Language_pl { PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Poziomowanie stołu"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Wypoziomuj stół"); PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Narożniki poziomowania"); + //PROGMEM Language_Str MSG_LEVEL_CORNERS_RAISE = _UxGT("Raise Bed Until Probe Triggered"); + //PROGMEM Language_Str MSG_LEVEL_CORNERS_IN_RANGE = _UxGT("All Corners Within Tolerance. Level Bed"); + //PROGMEM Language_Str MSG_LEVEL_CORNERS_GOOD_POINTS = _UxGT("Good Points: "); + //PROGMEM Language_Str MSG_LEVEL_CORNERS_LAST_Z = _UxGT("Last Z: "); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Nastepny narożnik"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Edytor siatki"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Edycja siatki"); @@ -112,6 +147,7 @@ namespace Language_pl { PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Własne Polecenia"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 Test sondy"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 Punky"); + //PROGMEM Language_Str MSG_M48_OUT_OF_BOUNDS = _UxGT("Probe out of bounds"); PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("Odchylenie"); PROGMEM Language_Str MSG_IDEX_MENU = _UxGT("Tryb IDEX"); PROGMEM Language_Str MSG_OFFSETS_MENU = _UxGT("Przesunięcie narzędzia"); @@ -119,14 +155,16 @@ namespace Language_pl { PROGMEM Language_Str MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplikowanie"); PROGMEM Language_Str MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Kopia lustrzana"); PROGMEM Language_Str MSG_IDEX_MODE_FULL_CTRL = _UxGT("Pełne sterowanie"); + //PROGMEM Language_Str MSG_IDEX_DUPE_GAP = _UxGT("Duplicate X-Gap"); PROGMEM Language_Str MSG_HOTEND_OFFSET_X = _UxGT("2ga dysza X"); PROGMEM Language_Str MSG_HOTEND_OFFSET_Y = _UxGT("2ga dysza Y"); PROGMEM Language_Str MSG_HOTEND_OFFSET_Z = _UxGT("2ga dysza Z"); PROGMEM Language_Str MSG_UBL_DOING_G29 = _UxGT("Wykonywanie G29"); PROGMEM Language_Str MSG_UBL_TOOLS = _UxGT("Narzędzia UBL"); - PROGMEM Language_Str MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling"); + //PROGMEM Language_Str MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling"); PROGMEM Language_Str MSG_LCD_TILTING_MESH = _UxGT("Punkt pochylenia"); PROGMEM Language_Str MSG_UBL_MANUAL_MESH = _UxGT("Ręczne Budowanie Siatki"); + //PROGMEM Language_Str MSG_UBL_MESH_WIZARD = _UxGT("UBL Mesh Wizard"); PROGMEM Language_Str MSG_UBL_BC_INSERT = _UxGT("Umieść podkładkę i zmierz"); PROGMEM Language_Str MSG_UBL_BC_INSERT2 = _UxGT("Zmierz"); PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Usuń & Zmierz Stół"); @@ -143,14 +181,12 @@ namespace Language_pl { PROGMEM Language_Str MSG_UBL_DONE_EDITING_MESH = _UxGT("Koniec edycji siati"); PROGMEM Language_Str MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Buduj własna siatkę"); PROGMEM Language_Str MSG_UBL_BUILD_MESH_MENU = _UxGT("Buduj siatkę"); - #if PREHEAT_COUNT - PROGMEM Language_Str MSG_UBL_BUILD_MESH_M = _UxGT("Buduj siatkę ($)"); - PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_M = _UxGT("Sprawdzenie siatki ($)"); - #endif + PROGMEM Language_Str MSG_UBL_BUILD_MESH_M = _UxGT("Buduj siatkę ($)"); PROGMEM Language_Str MSG_UBL_BUILD_COLD_MESH = _UxGT("Buduj siatkę na zimno"); PROGMEM Language_Str MSG_UBL_MESH_HEIGHT_ADJUST = _UxGT("Dostrojenie wysokości siatki"); PROGMEM Language_Str MSG_UBL_MESH_HEIGHT_AMOUNT = _UxGT("Wartość wysokości"); PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_MENU = _UxGT("Sprawdzenie siatki"); + PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_M = _UxGT("Sprawdzenie siatki ($)"); PROGMEM Language_Str MSG_UBL_VALIDATE_CUSTOM_MESH = _UxGT("Sprawdzenie własnej siatki"); PROGMEM Language_Str MSG_G26_HEATING_BED = _UxGT("G26 Nagrzewanie stołu"); PROGMEM Language_Str MSG_G26_HEATING_NOZZLE = _UxGT("G26 Nagrzewanie dyszy"); @@ -211,6 +247,10 @@ namespace Language_pl { PROGMEM Language_Str MSG_SET_LEDS_VIOLET = _UxGT("Fioletowy"); PROGMEM Language_Str MSG_SET_LEDS_WHITE = _UxGT("Biały"); PROGMEM Language_Str MSG_SET_LEDS_DEFAULT = _UxGT("Domyślny"); + PROGMEM Language_Str MSG_LED_CHANNEL_N = _UxGT("Kanał ="); + //PROGMEM Language_Str MSG_LEDS2 = _UxGT("Lights #2"); + //PROGMEM Language_Str MSG_NEO2_PRESETS = _UxGT("Light #2 Presets"); + PROGMEM Language_Str MSG_NEO2_BRIGHTNESS = _UxGT("Jasność"); PROGMEM Language_Str MSG_CUSTOM_LEDS = _UxGT("Własne światła"); PROGMEM Language_Str MSG_INTENSITY_R = _UxGT("Czerwony"); PROGMEM Language_Str MSG_INTENSITY_G = _UxGT("Zielony"); @@ -226,31 +266,60 @@ namespace Language_pl { PROGMEM Language_Str MSG_MOVE_E = _UxGT("Ekstruzja (os E)"); PROGMEM Language_Str MSG_MOVE_EN = _UxGT("Ekstruzja (os E) *"); PROGMEM Language_Str MSG_HOTEND_TOO_COLD = _UxGT("Dysza za zimna"); - PROGMEM Language_Str MSG_MOVE_N_MM = _UxGT("Przesuń co %smm"); - PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Przesuń co .1mm"); - PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Przesuń co 1mm"); - PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Przesuń co 10mm"); + PROGMEM Language_Str MSG_MOVE_N_MM = _UxGT("Przesuń co %s mm"); + PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Przesuń co .1 mm"); + PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Przesuń co 1 mm"); + PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Przesuń co 10 mm"); + PROGMEM Language_Str MSG_MOVE_0001IN = _UxGT("Przesuń co 0.001 cala"); + PROGMEM Language_Str MSG_MOVE_001IN = _UxGT("Przesuń co 0.01 cala"); + PROGMEM Language_Str MSG_MOVE_01IN = _UxGT("Przesuń co 0.1 cala"); PROGMEM Language_Str MSG_SPEED = _UxGT("Predkość"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Stół Z"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Dysza"); PROGMEM Language_Str MSG_NOZZLE_N = _UxGT("Dysza ~"); + //PROGMEM Language_Str MSG_NOZZLE_PARKED = _UxGT("Nozzle Parked"); + PROGMEM Language_Str MSG_NOZZLE_STANDBY = _UxGT("Dysza w oczekiwaniu"); PROGMEM Language_Str MSG_BED = _UxGT("Stół"); PROGMEM Language_Str MSG_CHAMBER = _UxGT("Obudowa"); - PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Obroty wiatraka"); - PROGMEM Language_Str MSG_FAN_SPEED_N = _UxGT("Obroty wiatraka ~"); - PROGMEM Language_Str MSG_EXTRA_FAN_SPEED = _UxGT("Obroty dodatkowego wiatraka"); - PROGMEM Language_Str MSG_EXTRA_FAN_SPEED_N = _UxGT("Obroty dodatkowego wiatraka ~"); + //PROGMEM Language_Str MSG_COOLER = _UxGT("Laser Coolant"); + //PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Toggle Cooler"); + //PROGMEM Language_Str MSG_FLOWMETER_SAFETY = _UxGT("Flow Safety"); + //PROGMEM Language_Str MSG_LASER = _UxGT("Laser"); + PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Obroty wentylatora"); + PROGMEM Language_Str MSG_FAN_SPEED_N = _UxGT("Obroty wentylatora ~"); + //PROGMEM Language_Str MSG_STORED_FAN_N = _UxGT("Stored Fan ~"); + PROGMEM Language_Str MSG_EXTRA_FAN_SPEED = _UxGT("Obroty dodatkowego wentylatora"); + PROGMEM Language_Str MSG_EXTRA_FAN_SPEED_N = _UxGT("Obroty dodatkowego wentylatora ~"); + PROGMEM Language_Str MSG_CONTROLLER_FAN = _UxGT("Wentylator kontrolera"); + //PROGMEM Language_Str MSG_CONTROLLER_FAN_IDLE_SPEED = _UxGT("Idle Speed"); + //PROGMEM Language_Str MSG_CONTROLLER_FAN_AUTO_ON = _UxGT("Auto Mode"); + //PROGMEM Language_Str MSG_CONTROLLER_FAN_SPEED = _UxGT("Active Speed"); + //PROGMEM Language_Str MSG_CONTROLLER_FAN_DURATION = _UxGT("Idle Period"); PROGMEM Language_Str MSG_FLOW = _UxGT("Przepływ"); PROGMEM Language_Str MSG_FLOW_N = _UxGT("Przepływ ~"); PROGMEM Language_Str MSG_CONTROL = _UxGT("Ustawienia"); - PROGMEM Language_Str MSG_MIN = " " LCD_STR_THERMOMETER _UxGT(" Min"); - PROGMEM Language_Str MSG_MAX = " " LCD_STR_THERMOMETER _UxGT(" Max"); + //PROGMEM Language_Str MSG_MIN = " " LCD_STR_THERMOMETER _UxGT(" Min"); + //PROGMEM Language_Str MSG_MAX = " " LCD_STR_THERMOMETER _UxGT(" Max"); PROGMEM Language_Str MSG_FACTOR = " " LCD_STR_THERMOMETER _UxGT(" Mnożnik"); PROGMEM Language_Str MSG_AUTOTEMP = _UxGT("Auto. temperatura"); PROGMEM Language_Str MSG_LCD_ON = _UxGT("Wł."); PROGMEM Language_Str MSG_LCD_OFF = _UxGT("Wył."); PROGMEM Language_Str MSG_PID_AUTOTUNE = _UxGT("PID Autostrojenie"); PROGMEM Language_Str MSG_PID_AUTOTUNE_E = _UxGT("PID Autostrojenie *"); + PROGMEM Language_Str MSG_PID_AUTOTUNE_DONE = _UxGT("Strojenie PID zakończone"); + //PROGMEM Language_Str MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Autotune failed. Bad extruder."); + //PROGMEM Language_Str MSG_PID_TEMP_TOO_HIGH = _UxGT("Autotune failed. Temperature too high."); + //PROGMEM Language_Str MSG_PID_TIMEOUT = _UxGT("Autotune failed! Timeout."); + //PROGMEM Language_Str MSG_PID_P = _UxGT("PID-P"); + //PROGMEM Language_Str MSG_PID_P_E = _UxGT("PID-P *"); + //PROGMEM Language_Str MSG_PID_I = _UxGT("PID-I"); + //PROGMEM Language_Str MSG_PID_I_E = _UxGT("PID-I *"); + //PROGMEM Language_Str MSG_PID_D = _UxGT("PID-D"); + //PROGMEM Language_Str MSG_PID_D_E = _UxGT("PID-D *"); + //PROGMEM Language_Str MSG_PID_C = _UxGT("PID-C"); + //PROGMEM Language_Str MSG_PID_C_E = _UxGT("PID-C *"); + //PROGMEM Language_Str MSG_PID_F = _UxGT("PID-F"); + //PROGMEM Language_Str MSG_PID_F_E = _UxGT("PID-F *"); PROGMEM Language_Str MSG_SELECT = _UxGT("Wybierz"); PROGMEM Language_Str MSG_SELECT_E = _UxGT("Wybierz *"); PROGMEM Language_Str MSG_ACC = _UxGT("Przyspieszenie"); @@ -259,61 +328,83 @@ namespace Language_pl { PROGMEM Language_Str MSG_VB_JERK = _UxGT("Zryw V") LCD_STR_B; PROGMEM Language_Str MSG_VC_JERK = _UxGT("Zryw V") LCD_STR_C; PROGMEM Language_Str MSG_VE_JERK = _UxGT("Zryw Ve"); - PROGMEM Language_Str MSG_JUNCTION_DEVIATION = _UxGT("Junction Dev"); + //PROGMEM Language_Str MSG_JUNCTION_DEVIATION = _UxGT("Junction Dev"); PROGMEM Language_Str MSG_VELOCITY = _UxGT("Prędkość (V)"); - PROGMEM Language_Str MSG_VMAX_A = _UxGT("Vmax ") LCD_STR_A; - PROGMEM Language_Str MSG_VMAX_B = _UxGT("Vmax ") LCD_STR_B; - PROGMEM Language_Str MSG_VMAX_C = _UxGT("Vmax ") LCD_STR_C; - PROGMEM Language_Str MSG_VMAX_E = _UxGT("Vmax ") LCD_STR_E; - PROGMEM Language_Str MSG_VMAX_EN = _UxGT("Vmax *"); - PROGMEM Language_Str MSG_VMIN = _UxGT("Vmin"); + //PROGMEM Language_Str MSG_VMAX_A = _UxGT("Vmax ") LCD_STR_A; + //PROGMEM Language_Str MSG_VMAX_B = _UxGT("Vmax ") LCD_STR_B; + //PROGMEM Language_Str MSG_VMAX_C = _UxGT("Vmax ") LCD_STR_C; + //PROGMEM Language_Str MSG_VMAX_E = _UxGT("Vmax ") LCD_STR_E; + //PROGMEM Language_Str MSG_VMAX_EN = _UxGT("Vmax *"); + //PROGMEM Language_Str MSG_VMIN = _UxGT("Vmin"); PROGMEM Language_Str MSG_VTRAV_MIN = _UxGT("Vskok min"); PROGMEM Language_Str MSG_ACCELERATION = _UxGT("Przyspieszenie (A)"); - PROGMEM Language_Str MSG_AMAX_A = _UxGT("Amax ") LCD_STR_A; - PROGMEM Language_Str MSG_AMAX_B = _UxGT("Amax ") LCD_STR_B; - PROGMEM Language_Str MSG_AMAX_C = _UxGT("Amax ") LCD_STR_C; - PROGMEM Language_Str MSG_AMAX_E = _UxGT("Amax ") LCD_STR_E; - PROGMEM Language_Str MSG_AMAX_EN = _UxGT("Amax *"); + //PROGMEM Language_Str MSG_AMAX_A = _UxGT("Amax ") LCD_STR_A; + //PROGMEM Language_Str MSG_AMAX_B = _UxGT("Amax ") LCD_STR_B; + //PROGMEM Language_Str MSG_AMAX_C = _UxGT("Amax ") LCD_STR_C; + //PROGMEM Language_Str MSG_AMAX_E = _UxGT("Amax ") LCD_STR_E; + //PROGMEM Language_Str MSG_AMAX_EN = _UxGT("Amax *"); PROGMEM Language_Str MSG_A_RETRACT = _UxGT("A-wycofanie"); PROGMEM Language_Str MSG_A_TRAVEL = _UxGT("A-przesuń."); + PROGMEM Language_Str MSG_XY_FREQUENCY_LIMIT = _UxGT("Częstotliwość max"); + //PROGMEM Language_Str MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Feed min"); PROGMEM Language_Str MSG_STEPS_PER_MM = _UxGT("kroki/mm"); - PROGMEM Language_Str MSG_A_STEPS = _UxGT("kroki") LCD_STR_A _UxGT("/mm"); - PROGMEM Language_Str MSG_B_STEPS = _UxGT("kroki") LCD_STR_B _UxGT("/mm"); - PROGMEM Language_Str MSG_C_STEPS = _UxGT("kroki") LCD_STR_C _UxGT("/mm"); - PROGMEM Language_Str MSG_E_STEPS = _UxGT("krokiE/mm"); - PROGMEM Language_Str MSG_EN_STEPS = _UxGT("kroki */mm"); + PROGMEM Language_Str MSG_A_STEPS = LCD_STR_A _UxGT(" kroki/mm"); + PROGMEM Language_Str MSG_B_STEPS = LCD_STR_B _UxGT(" kroki/mm"); + PROGMEM Language_Str MSG_C_STEPS = LCD_STR_C _UxGT(" kroki/mm"); + PROGMEM Language_Str MSG_E_STEPS = _UxGT("E kroki/mm"); + PROGMEM Language_Str MSG_EN_STEPS = _UxGT("* kroki/mm"); PROGMEM Language_Str MSG_TEMPERATURE = _UxGT("Temperatura"); PROGMEM Language_Str MSG_MOTION = _UxGT("Ruch"); - PROGMEM Language_Str MSG_FILAMENT = _UxGT("Filament"); + //PROGMEM Language_Str MSG_FILAMENT = _UxGT("Filament"); PROGMEM Language_Str MSG_VOLUMETRIC_ENABLED = _UxGT("E w mm") SUPERSCRIPT_THREE; + //PROGMEM Language_Str MSG_VOLUMETRIC_LIMIT = _UxGT("E Limit in mm") SUPERSCRIPT_THREE; + //PROGMEM Language_Str MSG_VOLUMETRIC_LIMIT_E = _UxGT("E Limit *"); PROGMEM Language_Str MSG_FILAMENT_DIAM = _UxGT("Śr. fil."); PROGMEM Language_Str MSG_FILAMENT_DIAM_E = _UxGT("Śr. fil. *"); PROGMEM Language_Str MSG_FILAMENT_UNLOAD = _UxGT("Wysuń mm"); PROGMEM Language_Str MSG_FILAMENT_LOAD = _UxGT("Wsuń mm"); - PROGMEM Language_Str MSG_ADVANCE_K = _UxGT("Advance K"); - PROGMEM Language_Str MSG_ADVANCE_K_E = _UxGT("Advance K *"); + //PROGMEM Language_Str MSG_ADVANCE_K = _UxGT("Advance K"); + //PROGMEM Language_Str MSG_ADVANCE_K_E = _UxGT("Advance K *"); PROGMEM Language_Str MSG_CONTRAST = _UxGT("Kontrast LCD"); PROGMEM Language_Str MSG_STORE_EEPROM = _UxGT("Zapisz w pamięci"); PROGMEM Language_Str MSG_LOAD_EEPROM = _UxGT("Wczytaj z pamięci"); PROGMEM Language_Str MSG_RESTORE_DEFAULTS = _UxGT("Ustaw. fabryczne"); PROGMEM Language_Str MSG_INIT_EEPROM = _UxGT("Initializuj EEPROM"); + //PROGMEM Language_Str MSG_ERR_EEPROM_CRC = _UxGT("EEPROM CRC Error"); + //PROGMEM Language_Str MSG_ERR_EEPROM_INDEX = _UxGT("EEPROM Index Error"); + //PROGMEM Language_Str MSG_ERR_EEPROM_VERSION = _UxGT("EEPROM Version Error"); + //PROGMEM Language_Str MSG_SETTINGS_STORED = _UxGT("Settings Stored"); PROGMEM Language_Str MSG_MEDIA_UPDATE = _UxGT("Uaktualnij kartę"); PROGMEM Language_Str MSG_RESET_PRINTER = _UxGT("Resetuj drukarkę"); PROGMEM Language_Str MSG_REFRESH = LCD_STR_REFRESH _UxGT("Odswież"); PROGMEM Language_Str MSG_INFO_SCREEN = _UxGT("Ekran główny"); PROGMEM Language_Str MSG_PREPARE = _UxGT("Przygotuj"); PROGMEM Language_Str MSG_TUNE = _UxGT("Strojenie"); + //PROGMEM Language_Str MSG_POWER_MONITOR = _UxGT("Power monitor"); + PROGMEM Language_Str MSG_CURRENT = _UxGT("Natężenie"); + PROGMEM Language_Str MSG_VOLTAGE = _UxGT("Napięcie"); + PROGMEM Language_Str MSG_POWER = _UxGT("Moc"); PROGMEM Language_Str MSG_START_PRINT = _UxGT("Start wydruku"); PROGMEM Language_Str MSG_BUTTON_NEXT = _UxGT("Następny"); PROGMEM Language_Str MSG_BUTTON_INIT = _UxGT("Inic."); - PROGMEM Language_Str MSG_BUTTON_STOP = _UxGT("Stop"); + //PROGMEM Language_Str MSG_BUTTON_STOP = _UxGT("Stop"); PROGMEM Language_Str MSG_BUTTON_PRINT = _UxGT("Drukuj"); PROGMEM Language_Str MSG_BUTTON_RESET = _UxGT("Resetuj"); + PROGMEM Language_Str MSG_BUTTON_IGNORE = _UxGT("Ignoruj"); PROGMEM Language_Str MSG_BUTTON_CANCEL = _UxGT("Przerwij"); PROGMEM Language_Str MSG_BUTTON_DONE = _UxGT("Gotowe"); + PROGMEM Language_Str MSG_BUTTON_BACK = _UxGT("Wstecz"); + PROGMEM Language_Str MSG_BUTTON_PROCEED = _UxGT("Kontynuuj"); + PROGMEM Language_Str MSG_BUTTON_SKIP = _UxGT("Pomiń"); + PROGMEM Language_Str MSG_PAUSING = _UxGT("Wstrzymywanie..."); PROGMEM Language_Str MSG_PAUSE_PRINT = _UxGT("Wstrzymaj druk"); PROGMEM Language_Str MSG_RESUME_PRINT = _UxGT("Wznowienie"); + //PROGMEM Language_Str MSG_HOST_START_PRINT = _UxGT("Host Start"); PROGMEM Language_Str MSG_STOP_PRINT = _UxGT("Stop"); + //PROGMEM Language_Str MSG_END_LOOPS = _UxGT("End Repeat Loops"); + PROGMEM Language_Str MSG_PRINTING_OBJECT = _UxGT("Drukowanie obiektu"); + PROGMEM Language_Str MSG_CANCEL_OBJECT = _UxGT("Anunuj obiekt"); + PROGMEM Language_Str MSG_CANCEL_OBJECT_N = _UxGT("Anunuj obiekt ="); PROGMEM Language_Str MSG_OUTAGE_RECOVERY = _UxGT("Odzyskiwanie po awarii"); PROGMEM Language_Str MSG_MEDIA_MENU = _UxGT("Karta SD"); PROGMEM Language_Str MSG_NO_MEDIA = _UxGT("Brak karty"); @@ -322,6 +413,7 @@ namespace Language_pl { PROGMEM Language_Str MSG_PRINT_PAUSED = _UxGT("Druk wstrzymany"); PROGMEM Language_Str MSG_PRINTING = _UxGT("Drukowanie..."); PROGMEM Language_Str MSG_PRINT_ABORTED = _UxGT("Druk przerwany"); + PROGMEM Language_Str MSG_PRINT_DONE = _UxGT("Druk zakończony"); PROGMEM Language_Str MSG_NO_MOVE = _UxGT("Brak ruchu"); PROGMEM Language_Str MSG_KILLED = _UxGT("Ubity. "); PROGMEM Language_Str MSG_STOPPED = _UxGT("Zatrzymany. "); @@ -331,15 +423,26 @@ namespace Language_pl { PROGMEM Language_Str MSG_CONTROL_RETRACT_ZHOP = _UxGT("Skok Z mm"); PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVER = _UxGT("Cof. wycof. mm"); PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVER_SWAP = _UxGT("Z Cof. wyc. mm"); + //PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVERF = _UxGT("Unretract V"); PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVERF = _UxGT("Cof. wycof. V"); PROGMEM Language_Str MSG_AUTORETRACT = _UxGT("Auto. wycofanie"); PROGMEM Language_Str MSG_FILAMENT_SWAP_LENGTH = _UxGT("Długość zmiany"); + //PROGMEM Language_Str MSG_FILAMENT_SWAP_EXTRA = _UxGT("Swap Extra"); PROGMEM Language_Str MSG_FILAMENT_PURGE_LENGTH = _UxGT("Długość oczyszczania"); PROGMEM Language_Str MSG_TOOL_CHANGE = _UxGT("Zmiana narzędzia"); PROGMEM Language_Str MSG_TOOL_CHANGE_ZLIFT = _UxGT("Podniesienie Z"); PROGMEM Language_Str MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Prędkość napełniania"); PROGMEM Language_Str MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Prędkość wycofania"); - PROGMEM Language_Str MSG_NOZZLE_STANDBY = _UxGT("Dysza w oczekiwaniu"); + //PROGMEM Language_Str MSG_FILAMENT_PARK_ENABLED = _UxGT("Park Head"); + //PROGMEM Language_Str MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Recover Speed"); + //PROGMEM Language_Str MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("Fan Speed"); + //PROGMEM Language_Str MSG_SINGLENOZZLE_FAN_TIME = _UxGT("Fan Time"); + //PROGMEM Language_Str MSG_TOOL_MIGRATION_ON = _UxGT("Auto ON"); + //PROGMEM Language_Str MSG_TOOL_MIGRATION_OFF = _UxGT("Auto OFF"); + //PROGMEM Language_Str MSG_TOOL_MIGRATION = _UxGT("Tool Migration"); + //PROGMEM Language_Str MSG_TOOL_MIGRATION_AUTO = _UxGT("Auto-migration"); + //PROGMEM Language_Str MSG_TOOL_MIGRATION_END = _UxGT("Last Extruder"); + //PROGMEM Language_Str MSG_TOOL_MIGRATION_SWAP = _UxGT("Migrate to *"); PROGMEM Language_Str MSG_FILAMENTCHANGE = _UxGT("Zmień filament"); PROGMEM Language_Str MSG_FILAMENTCHANGE_E = _UxGT("Zmień filament *"); PROGMEM Language_Str MSG_FILAMENTLOAD = _UxGT("Wsuń Filament"); @@ -352,31 +455,35 @@ namespace Language_pl { PROGMEM Language_Str MSG_RELEASE_MEDIA = _UxGT("Zwolnienie karty"); PROGMEM Language_Str MSG_ZPROBE_OUT = _UxGT("Sonda Z za stołem"); PROGMEM Language_Str MSG_SKEW_FACTOR = _UxGT("Współczynik skrzywienia"); - PROGMEM Language_Str MSG_BLTOUCH = _UxGT("BLTouch"); + //PROGMEM Language_Str MSG_BLTOUCH = _UxGT("BLTouch"); PROGMEM Language_Str MSG_BLTOUCH_SELFTEST = _UxGT("BLTouch Self-Test"); PROGMEM Language_Str MSG_BLTOUCH_RESET = _UxGT("Reset BLTouch"); - PROGMEM Language_Str MSG_BLTOUCH_STOW = _UxGT("Stow"); - PROGMEM Language_Str MSG_BLTOUCH_DEPLOY = _UxGT("Deploy"); - PROGMEM Language_Str MSG_BLTOUCH_SW_MODE = _UxGT("SW-Mode"); - PROGMEM Language_Str MSG_BLTOUCH_5V_MODE = _UxGT("5V-Mode"); - PROGMEM Language_Str MSG_BLTOUCH_OD_MODE = _UxGT("OD-Mode"); - PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE = _UxGT("Mode-Store"); - PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE_5V = _UxGT("Set BLTouch to 5V"); - PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE_OD = _UxGT("Set BLTouch to OD"); - PROGMEM Language_Str MSG_BLTOUCH_MODE_ECHO = _UxGT("Report Drain"); + //PROGMEM Language_Str MSG_BLTOUCH_STOW = _UxGT("Stow"); + //PROGMEM Language_Str MSG_BLTOUCH_DEPLOY = _UxGT("Deploy"); + //PROGMEM Language_Str MSG_BLTOUCH_SW_MODE = _UxGT("SW-Mode"); + //PROGMEM Language_Str MSG_BLTOUCH_5V_MODE = _UxGT("5V-Mode"); + //PROGMEM Language_Str MSG_BLTOUCH_OD_MODE = _UxGT("OD-Mode"); + //PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE = _UxGT("Mode-Store"); + //PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE_5V = _UxGT("Set BLTouch to 5V"); + //PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE_OD = _UxGT("Set BLTouch to OD"); + //PROGMEM Language_Str MSG_BLTOUCH_MODE_ECHO = _UxGT("Report Drain"); PROGMEM Language_Str MSG_BLTOUCH_MODE_CHANGE = _UxGT("UWAGA: Złe ustawienia mogą uszkodzić drukarkę. Kontynuować?"); - PROGMEM Language_Str MSG_TOUCHMI_PROBE = _UxGT("TouchMI"); - PROGMEM Language_Str MSG_TOUCHMI_INIT = _UxGT("Init TouchMI"); - PROGMEM Language_Str MSG_TOUCHMI_ZTEST = _UxGT("Z Offset Test"); - PROGMEM Language_Str MSG_TOUCHMI_SAVE = _UxGT("Save"); - PROGMEM Language_Str MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Deploy TouchMI"); - PROGMEM Language_Str MSG_MANUAL_DEPLOY = _UxGT("Deploy Z-Probe"); - PROGMEM Language_Str MSG_MANUAL_STOW = _UxGT("Stow Z-Probe"); + //PROGMEM Language_Str MSG_TOUCHMI_PROBE = _UxGT("TouchMI"); + //PROGMEM Language_Str MSG_TOUCHMI_INIT = _UxGT("Init TouchMI"); + //PROGMEM Language_Str MSG_TOUCHMI_ZTEST = _UxGT("Z Offset Test"); + //PROGMEM Language_Str MSG_TOUCHMI_SAVE = _UxGT("Save"); + //PROGMEM Language_Str MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Deploy TouchMI"); + //PROGMEM Language_Str MSG_MANUAL_DEPLOY = _UxGT("Deploy Z-Probe"); + //PROGMEM Language_Str MSG_MANUAL_STOW = _UxGT("Stow Z-Probe"); PROGMEM Language_Str MSG_HOME_FIRST = _UxGT("Najpierw Home %s%s%s"); + //PROGMEM Language_Str MSG_ZPROBE_OFFSETS = _UxGT("Probe Offsets"); + //PROGMEM Language_Str MSG_ZPROBE_XOFFSET = _UxGT("Probe X Offset"); + //PROGMEM Language_Str MSG_ZPROBE_YOFFSET = _UxGT("Probe Y Offset"); PROGMEM Language_Str MSG_ZPROBE_ZOFFSET = _UxGT("Offset Z"); - PROGMEM Language_Str MSG_BABYSTEP_X = _UxGT("Babystep X"); - PROGMEM Language_Str MSG_BABYSTEP_Y = _UxGT("Babystep Y"); - PROGMEM Language_Str MSG_BABYSTEP_Z = _UxGT("Babystep Z"); + PROGMEM Language_Str MSG_MOVE_NOZZLE_TO_BED = _UxGT("Przesuń dyszę do stołu"); + //PROGMEM Language_Str MSG_BABYSTEP_X = _UxGT("Babystep X"); + //PROGMEM Language_Str MSG_BABYSTEP_Y = _UxGT("Babystep Y"); + //PROGMEM Language_Str MSG_BABYSTEP_Z = _UxGT("Babystep Z"); PROGMEM Language_Str MSG_BABYSTEP_TOTAL = _UxGT("Łącznie"); PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Błąd krańcówki"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Rozgrz. nieudane"); @@ -384,19 +491,24 @@ namespace Language_pl { PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("ZANIK TEMPERATURY"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("ZANIK TEMP. STOŁU"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("ZANIK TEMP.KOMORY"); + //PROGMEM Language_Str MSG_THERMAL_RUNAWAY_COOLER = _UxGT("Cooler Runaway"); + //PROGMEM Language_Str MSG_COOLING_FAILED = _UxGT("Cooling Failed"); PROGMEM Language_Str MSG_ERR_MAXTEMP = _UxGT("Błąd: MAXTEMP"); PROGMEM Language_Str MSG_ERR_MINTEMP = _UxGT("Błąd: MINTEMP"); PROGMEM Language_Str MSG_HALTED = _UxGT("Drukarka zatrzym."); PROGMEM Language_Str MSG_PLEASE_RESET = _UxGT("Proszę zresetować"); - PROGMEM Language_Str MSG_SHORT_DAY = _UxGT("d"); // One character only + //PROGMEM Language_Str MSG_SHORT_DAY = _UxGT("d"); // One character only PROGMEM Language_Str MSG_SHORT_HOUR = _UxGT("g"); // One character only - PROGMEM Language_Str MSG_SHORT_MINUTE = _UxGT("m"); // One character only + //PROGMEM Language_Str MSG_SHORT_MINUTE = _UxGT("m"); // One character only PROGMEM Language_Str MSG_HEATING = _UxGT("Rozgrzewanie..."); PROGMEM Language_Str MSG_COOLING = _UxGT("Chłodzenie..."); PROGMEM Language_Str MSG_BED_HEATING = _UxGT("Rozgrzewanie stołu..."); PROGMEM Language_Str MSG_BED_COOLING = _UxGT("Chłodzenie stołu..."); + //PROGMEM Language_Str MSG_PROBE_HEATING = _UxGT("Probe Heating..."); + //PROGMEM Language_Str MSG_PROBE_COOLING = _UxGT("Probe Cooling..."); PROGMEM Language_Str MSG_CHAMBER_HEATING = _UxGT("Rozgrzewanie komory..."); PROGMEM Language_Str MSG_CHAMBER_COOLING = _UxGT("Chłodzenie komory..."); + //PROGMEM Language_Str MSG_LASER_COOLING = _UxGT("Laser Cooling..."); PROGMEM Language_Str MSG_DELTA_CALIBRATE = _UxGT("Kalibrowanie Delty"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_X = _UxGT("Kalibruj X"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_Y = _UxGT("Kalibruj Y"); @@ -414,8 +526,9 @@ namespace Language_pl { PROGMEM Language_Str MSG_3POINT_LEVELING = _UxGT("Poziomowanie 3-punktowe"); PROGMEM Language_Str MSG_LINEAR_LEVELING = _UxGT("Poziomowanie liniowe"); PROGMEM Language_Str MSG_BILINEAR_LEVELING = _UxGT("Poziomowanie biliniowe"); - PROGMEM Language_Str MSG_UBL_LEVELING = _UxGT("Unified Bed Leveling"); + //PROGMEM Language_Str MSG_UBL_LEVELING = _UxGT("Unified Bed Leveling"); PROGMEM Language_Str MSG_MESH_LEVELING = _UxGT("Poziomowanie siatką"); + //PROGMEM Language_Str MSG_MESH_DONE = _UxGT("Mesh probing done"); PROGMEM Language_Str MSG_INFO_STATS_MENU = _UxGT("Statystyki"); PROGMEM Language_Str MSG_INFO_BOARD_MENU = _UxGT("Info płyty"); PROGMEM Language_Str MSG_INFO_THERMISTOR_MENU = _UxGT("Termistory"); @@ -424,6 +537,7 @@ namespace Language_pl { PROGMEM Language_Str MSG_INFO_PROTOCOL = _UxGT("Protokół"); PROGMEM Language_Str MSG_INFO_RUNAWAY_OFF = _UxGT("Zegar pracy: OFF"); PROGMEM Language_Str MSG_INFO_RUNAWAY_ON = _UxGT("Zegar pracy: ON"); + //PROGMEM Language_Str MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Hotend Idle Timeout"); PROGMEM Language_Str MSG_CASE_LIGHT = _UxGT("Oświetlenie obudowy"); PROGMEM Language_Str MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Jasność oświetlenia"); @@ -443,8 +557,8 @@ namespace Language_pl { PROGMEM Language_Str MSG_INFO_PRINT_FILAMENT = _UxGT("Użyty fil."); #endif - PROGMEM Language_Str MSG_INFO_MIN_TEMP = _UxGT("Min Temp"); - PROGMEM Language_Str MSG_INFO_MAX_TEMP = _UxGT("Max Temp"); + //PROGMEM Language_Str MSG_INFO_MIN_TEMP = _UxGT("Min Temp"); + //PROGMEM Language_Str MSG_INFO_MAX_TEMP = _UxGT("Max Temp"); PROGMEM Language_Str MSG_INFO_PSU = _UxGT("Zasilacz"); PROGMEM Language_Str MSG_DRIVE_STRENGTH = _UxGT("Siła silnika"); PROGMEM Language_Str MSG_DAC_PERCENT_X = _UxGT("X Siła %"); @@ -467,7 +581,7 @@ namespace Language_pl { PROGMEM Language_Str MSG_LCD_PROBING_FAILED = _UxGT("Sondowanie nieudane"); PROGMEM Language_Str MSG_MMU2_CHOOSE_FILAMENT_HEADER = _UxGT("WYBIERZ FILAMENT"); - PROGMEM Language_Str MSG_MMU2_MENU = _UxGT("MMU"); + //PROGMEM Language_Str MSG_MMU2_MENU = _UxGT("MMU"); PROGMEM Language_Str MSG_KILL_MMU2_FIRMWARE = _UxGT("Uaktualnij firmware MMU!"); PROGMEM Language_Str MSG_MMU2_NOT_RESPONDING = _UxGT("MMU wymaga uwagi."); PROGMEM Language_Str MSG_MMU2_RESUME = _UxGT("Wznów wydruk"); @@ -482,7 +596,7 @@ namespace Language_pl { PROGMEM Language_Str MSG_MMU2_EJECTING_FILAMENT = _UxGT("Wysuwanie fil. ..."); PROGMEM Language_Str MSG_MMU2_UNLOADING_FILAMENT = _UxGT("Wysuwanie fil...."); PROGMEM Language_Str MSG_MMU2_ALL = _UxGT("Wszystko"); - PROGMEM Language_Str MSG_MMU2_FILAMENT_N = _UxGT("Filament ~"); + //PROGMEM Language_Str MSG_MMU2_FILAMENT_N = _UxGT("Filament ~"); PROGMEM Language_Str MSG_MMU2_RESET = _UxGT("Resetuj MMU"); PROGMEM Language_Str MSG_MMU2_RESETTING = _UxGT("Resetowanie MMU..."); PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("Usuń, kliknij"); @@ -490,12 +604,41 @@ namespace Language_pl { PROGMEM Language_Str MSG_MIX = _UxGT("Miks"); PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Komponent ="); PROGMEM Language_Str MSG_MIXER = _UxGT("Mikser"); - PROGMEM Language_Str MSG_GRADIENT = _UxGT("Gradient"); + //PROGMEM Language_Str MSG_GRADIENT = _UxGT("Gradient"); PROGMEM Language_Str MSG_FULL_GRADIENT = _UxGT("Pełny gradient"); PROGMEM Language_Str MSG_TOGGLE_MIX = _UxGT("Przełacz miks"); - PROGMEM Language_Str MSG_CYCLE_MIX = _UxGT("Cycle Mix"); - PROGMEM Language_Str MSG_GRADIENT_MIX = _UxGT("Gradient Mix"); + //PROGMEM Language_Str MSG_CYCLE_MIX = _UxGT("Cycle Mix"); + //PROGMEM Language_Str MSG_GRADIENT_MIX = _UxGT("Gradient Mix"); PROGMEM Language_Str MSG_REVERSE_GRADIENT = _UxGT("Odwrotny gradient"); + //PROGMEM Language_Str MSG_ACTIVE_VTOOL = _UxGT("Active V-tool"); + //PROGMEM Language_Str MSG_START_VTOOL = _UxGT("Start V-tool"); + //PROGMEM Language_Str MSG_END_VTOOL = _UxGT(" End V-tool"); + //PROGMEM Language_Str MSG_GRADIENT_ALIAS = _UxGT("Alias V-tool"); + //PROGMEM Language_Str MSG_RESET_VTOOLS = _UxGT("Reset V-tools"); + //PROGMEM Language_Str MSG_COMMIT_VTOOL = _UxGT("Commit V-tool Mix"); + //PROGMEM Language_Str MSG_VTOOLS_RESET = _UxGT("V-tools Were Reset"); + //PROGMEM Language_Str MSG_START_Z = _UxGT("Start Z:"); + //PROGMEM Language_Str MSG_END_Z = _UxGT(" End Z:"); + + PROGMEM Language_Str MSG_GAMES = _UxGT("Gry"); + //PROGMEM Language_Str MSG_BRICKOUT = _UxGT("Brickout"); + //PROGMEM Language_Str MSG_INVADERS = _UxGT("Invaders"); + //PROGMEM Language_Str MSG_SNAKE = _UxGT("Sn4k3"); + //PROGMEM Language_Str MSG_MAZE = _UxGT("Maze"); + + //PROGMEM Language_Str MSG_BAD_PAGE = _UxGT("Bad page index"); + //PROGMEM Language_Str MSG_BAD_PAGE_SPEED = _UxGT("Bad page speed"); + + PROGMEM Language_Str MSG_EDIT_PASSWORD = _UxGT("Zmień hasło"); + PROGMEM Language_Str MSG_LOGIN_REQUIRED = _UxGT("Wymagane zalogowanie"); + PROGMEM Language_Str MSG_PASSWORD_SETTINGS = _UxGT("Ustawienia hasła"); + PROGMEM Language_Str MSG_ENTER_DIGIT = _UxGT("Wprowadź cyfrę"); + PROGMEM Language_Str MSG_CHANGE_PASSWORD = _UxGT("Ustaw/zmień hasło"); + PROGMEM Language_Str MSG_REMOVE_PASSWORD = _UxGT("Usuń hasło"); + PROGMEM Language_Str MSG_PASSWORD_SET = _UxGT("Hasło to "); + PROGMEM Language_Str MSG_START_OVER = _UxGT("Od nowa"); + PROGMEM Language_Str MSG_REMINDER_SAVE_SETTINGS = _UxGT("Pamiętaj by zapisać!"); + PROGMEM Language_Str MSG_PASSWORD_REMOVED = _UxGT("Hasło usunięte"); // // Filament Change screens show up to 3 lines on a 4-line display @@ -526,4 +669,51 @@ namespace Language_pl { PROGMEM Language_Str MSG_FILAMENT_CHANGE_CONT_PURGE = _UxGT(MSG_1_LINE("Kliknij by zakończyć")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_RESUME = _UxGT(MSG_1_LINE("Wznawianie...")); #endif + PROGMEM Language_Str MSG_TMC_DRIVERS = _UxGT("Sterowniki TMC"); + PROGMEM Language_Str MSG_TMC_CURRENT = _UxGT("Prąd sterownika"); + //PROGMEM Language_Str MSG_TMC_HYBRID_THRS = _UxGT("Hybrid Threshold"); + PROGMEM Language_Str MSG_TMC_HOMING_THRS = _UxGT("Zerowanie bezczujnikowe"); + //PROGMEM Language_Str MSG_TMC_STEPPING_MODE = _UxGT("Stepping Mode"); + //PROGMEM Language_Str MSG_TMC_STEALTH_ENABLED = _UxGT("StealthChop Enabled"); + //PROGMEM Language_Str MSG_SERVICE_RESET = _UxGT("Reset"); + //PROGMEM Language_Str MSG_SERVICE_IN = _UxGT(" in:"); + //PROGMEM Language_Str MSG_BACKLASH = _UxGT("Backlash"); + //PROGMEM Language_Str MSG_BACKLASH_A = LCD_STR_A; + //PROGMEM Language_Str MSG_BACKLASH_B = LCD_STR_B; + //PROGMEM Language_Str MSG_BACKLASH_C = LCD_STR_C; + PROGMEM Language_Str MSG_BACKLASH_CORRECTION = _UxGT("Korekcja"); + PROGMEM Language_Str MSG_BACKLASH_SMOOTHING = _UxGT("Wygładzanie"); + + PROGMEM Language_Str MSG_LEVEL_X_AXIS = _UxGT("Wypoziomuj oś X"); + PROGMEM Language_Str MSG_AUTO_CALIBRATE = _UxGT("Autokalibracja"); + #if ENABLED(TOUCH_UI_FTDI_EVE) + //PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT("Idle timeout, temperature decreased. Press Okay to reheat and again to resume."); + #else + //PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT("Heater Timeout"); + #endif + //PROGMEM Language_Str MSG_REHEAT = _UxGT("Reheat"); + //PROGMEM Language_Str MSG_REHEATING = _UxGT("Reheating..."); + + //PROGMEM Language_Str MSG_PROBE_WIZARD = _UxGT("Z Probe Wizard"); + //PROGMEM Language_Str MSG_PROBE_WIZARD_PROBING = _UxGT("Probing Z Reference"); + //PROGMEM Language_Str MSG_PROBE_WIZARD_MOVING = _UxGT("Moving to Probing Pos"); + + PROGMEM Language_Str MSG_SOUND = _UxGT("Dźwięk"); + + //PROGMEM Language_Str MSG_TOP_LEFT = _UxGT("Top Left"); + //PROGMEM Language_Str MSG_BOTTOM_LEFT = _UxGT("Bottom Left"); + //PROGMEM Language_Str MSG_TOP_RIGHT = _UxGT("Top Right"); + //PROGMEM Language_Str MSG_BOTTOM_RIGHT = _UxGT("Bottom Right"); + PROGMEM Language_Str MSG_CALIBRATION_COMPLETED = _UxGT("Kalibracja zakończona"); + PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Kalibracja nie powiodła się"); + + //PROGMEM Language_Str MSG_DRIVER_BACKWARD = _UxGT(" driver backward"); } + +#if FAN_COUNT == 1 + #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED + #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED +#else + #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N + #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N +#endif From dceaeeeaf9591f67135356d0485e4c2936c08f2f Mon Sep 17 00:00:00 2001 From: Timo Date: Sat, 29 May 2021 14:00:39 -0700 Subject: [PATCH 60/61] =?UTF-8?q?=E2=9C=A8=20Malyan=20M180=20(#21992)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/boards.h | 1 + Marlin/src/pins/mega/pins_MALYAN_M180.h | 100 ++++++++++++++++++++++++ Marlin/src/pins/pins.h | 2 + 3 files changed, 103 insertions(+) create mode 100644 Marlin/src/pins/mega/pins_MALYAN_M180.h diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 20aeac654dae..1f73f04d16a3 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -159,6 +159,7 @@ #define BOARD_PICA_REVB 1324 // PICA Shield (original version) #define BOARD_PICA 1325 // PICA Shield (rev C or later) #define BOARD_INTAMSYS40 1326 // Intamsys 4.0 (Funmat HT) +#define BOARD_MALYAN_M180 1327 // Malyan M180 Mainboard Version 2 (no display function, direct gcode only) // // ATmega1281, ATmega2561 diff --git a/Marlin/src/pins/mega/pins_MALYAN_M180.h b/Marlin/src/pins/mega/pins_MALYAN_M180.h new file mode 100644 index 000000000000..e244d294f1c6 --- /dev/null +++ b/Marlin/src/pins/mega/pins_MALYAN_M180.h @@ -0,0 +1,100 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Malyan M180 pin assignments + * Contributed by Timo Birnschein (timo.birnschein@microforge.de) + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Malyan M180 v.2" +// +// Limit Switches +// +#define X_STOP_PIN 48 +#define Y_STOP_PIN 46 +#define Z_STOP_PIN 42 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN -1 +#endif + +// +// Steppers +// +#define X_STEP_PIN 55 +#define X_DIR_PIN 54 +#define X_ENABLE_PIN 56 + +#define Y_STEP_PIN 59 +#define Y_DIR_PIN 58 +#define Y_ENABLE_PIN 60 + +#define Z_STEP_PIN 63 +#define Z_DIR_PIN 62 +#define Z_ENABLE_PIN 64 + +#define E0_STEP_PIN 25 +#define E0_DIR_PIN 24 +#define E0_ENABLE_PIN 26 + +#define E1_STEP_PIN 29 +#define E1_DIR_PIN 28 +#define E1_ENABLE_PIN 39 + +// +// Temperature Sensors +// +#define TEMP_BED_PIN 15 // Analog Input + +// Extruder thermocouples 0 and 1 are read out by two separate ICs using +// SPI for Max6675 Thermocouple +// Uses a separate SPI bus +#define THERMO_SCK_PIN 78 // E2 - SCK +#define THERMO_DO_PIN 3 // E5 - DO +#define THERMO_CS1_PIN 5 // E3 - CS0 +#define THERMO_CS2_PIN 2 // E4 - CS1 + +#define MAX6675_SS_PIN THERMO_CS1_PIN +#define MAX6675_SS2_PIN THERMO_CS2_PIN +#define MAX6675_SCK_PIN THERMO_SCK_PIN +#define MAX6675_DO_PIN THERMO_DO_PIN + +// +// Heaters / Fans +// +#define HEATER_0_PIN 6 +#define HEATER_1_PIN 11 +#define HEATER_BED_PIN 45 + +#ifndef FAN_PIN + #define FAN_PIN 7 // M106 Sxxx command supported and tested. M107 as well. +#endif + +#ifndef FAN_PIN1 + #define FAN_PIN1 12 // Currently Unsupported by Marlin +#endif diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index a8ed35b00953..3176b5e8323d 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -270,6 +270,8 @@ #include "mega/pins_PICAOLD.h" // ATmega2560 env:mega2560 #elif MB(INTAMSYS40) #include "mega/pins_INTAMSYS40.h" // ATmega2560 env:mega2560 +#elif MB(MALYAN_M180) + #include "mega/pins_MALYAN_M180.h" // ATmega2560 env:mega2560 // // ATmega1281, ATmega2561 From 52ae3e6967bb6e3105d31772a58f820ca71477a9 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 30 May 2021 02:14:17 +0000 Subject: [PATCH 61/61] [cron] Bump distribution date (2021-05-30) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 1312a0788031..e383f182b380 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-05-29" + #define STRING_DISTRIBUTION_DATE "2021-05-30" #endif /**