From 131acf304b4d09466e916cbe31ff3cf3f2913804 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 27 Jan 2020 13:57:22 -0800 Subject: [PATCH 01/23] Fix Manual Bed Leveling with multiple extruders (#16688) --- Marlin/src/lcd/menu/menu_filament.cpp | 2 +- Marlin/src/module/tool_change.cpp | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index 894d8de238..5248cbbab1 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -119,7 +119,7 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) { SUBMENU_N_P(s, msg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, MenuItemBase::itemIndex); }); else { ACTION_ITEM_N_P(s, msg, []{ - char cmd[12]; + char cmd[13]; sprintf_P(cmd, PSTR("M600 B0 T%i"), int(MenuItemBase::itemIndex)); lcd_enqueue_one_now(cmd); }); diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 45c5805f4d..324b979570 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -821,10 +821,6 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("No move (not homed)"); } - #if HAS_LCD_MENU - ui.return_to_status(); - #endif - #if ENABLED(DUAL_X_CARRIAGE) const bool idex_full_control = dual_x_carriage_mode == DXC_FULL_CONTROL_MODE; #else From 0c3cae59d9e323aa5cd39faae18e08d0ec2341fc Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 28 Jan 2020 00:06:59 +0000 Subject: [PATCH 02/23] [cron] Bump distribution date (2020-01-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 f120d87571..cf531930af 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 "2020-01-27" + #define STRING_DISTRIBUTION_DATE "2020-01-28" #endif /** From e4eaf32b4da705c924087bcb1d9f720fb8beb731 Mon Sep 17 00:00:00 2001 From: felixstorm Date: Tue, 28 Jan 2020 01:16:44 +0100 Subject: [PATCH 03/23] Prevent SD access from resetting ESP32 (#16690) --- Marlin/src/sd/SdVolume.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Marlin/src/sd/SdVolume.cpp b/Marlin/src/sd/SdVolume.cpp index 926dd1c7d4..c51e42108c 100644 --- a/Marlin/src/sd/SdVolume.cpp +++ b/Marlin/src/sd/SdVolume.cpp @@ -291,6 +291,16 @@ int32_t SdVolume::freeClusterCount() { for (uint16_t i = 0; i < n; i++) if (cacheBuffer_.fat32[i] == 0) free++; } + #ifdef ESP32 + // Needed to reset the idle task watchdog timer on ESP32 as reading the complete FAT may easily + // block for 10+ seconds. yield() is insufficient since it blocks lower prio tasks (e.g., idle). + static millis_t nextTaskTime = 0; + const millis_t ms = millis(); + if (ELAPSED(ms, nextTaskTime) { + vTaskDelay(1); // delay 1 tick (Minimum. Usually 10 or 1 ms depending on skdconfig.h) + nextTaskTime = ms + 1000; // tickle the task manager again in 1 second + } + #endif // ESP32 } return free; } From 9b45f342ee8ec1765cc564ffb811755c366cc50c Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 29 Jan 2020 00:07:02 +0000 Subject: [PATCH 04/23] [cron] Bump distribution date (2020-01-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 cf531930af..9eeb6dbcee 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 "2020-01-28" + #define STRING_DISTRIBUTION_DATE "2020-01-29" #endif /** From 9bb8176d341e769af5080cc22a45a433d75b8318 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Wed, 29 Jan 2020 01:06:06 -0500 Subject: [PATCH 05/23] Fix Toolchange (!no_move) return to status (#16699) --- Marlin/src/feature/binary_protocol.h | 2 +- Marlin/src/module/tool_change.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Marlin/src/feature/binary_protocol.h b/Marlin/src/feature/binary_protocol.h index 0025fbe138..8e69ab7a75 100644 --- a/Marlin/src/feature/binary_protocol.h +++ b/Marlin/src/feature/binary_protocol.h @@ -242,7 +242,7 @@ public: uint8_t protocol() { return (meta >> 4) & 0xF; } uint8_t type() { return meta & 0xF; } void reset() { token = 0; sync = 0; meta = 0; size = 0; checksum = 0; } - uint8_t data[1]; + uint8_t data[2]; }; union Footer { diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 324b979570..b42722b87c 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -821,6 +821,10 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("No move (not homed)"); } + #if HAS_LCD_MENU + if (!no_move) ui.return_to_status(); + #endif + #if ENABLED(DUAL_X_CARRIAGE) const bool idex_full_control = dual_x_carriage_mode == DXC_FULL_CONTROL_MODE; #else From a5f72330fb760287673b7724f304fdc24b3b90a4 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 30 Jan 2020 00:06:48 +0000 Subject: [PATCH 06/23] [cron] Bump distribution date (2020-01-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 9eeb6dbcee..4b933d0327 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 "2020-01-29" + #define STRING_DISTRIBUTION_DATE "2020-01-30" #endif /** From e8ed4329ea0a94cc3929c34573882f9c662fb53c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 29 Jan 2020 22:16:09 -0600 Subject: [PATCH 07/23] Cleanup of old includes, add comments --- Marlin/Configuration_adv.h | 2 +- Marlin/src/gcode/lcd/M0_M1.cpp | 8 ++++---- Marlin/src/pins/rambo/pins_EINSY_RETRO.h | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index db5ad52abf..e2bda3f805 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -819,7 +819,7 @@ // probing on a screwhead or hollow washer, probe near the edges. //#define CALIBRATION_MEASURE_AT_TOP_EDGES - // Define pin which is read during calibration + // Define the pin to read during calibration #ifndef CALIBRATION_PIN #define CALIBRATION_PIN -1 // Override in pins.h or set to -1 to use your Z endstop #define CALIBRATION_PIN_INVERTING false // Set to true to invert the pin diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index 5bf9e94325..6a6d00ed34 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -20,12 +20,14 @@ * */ -#include "../../inc/MarlinConfig.h" +#include "../../inc/MarlinConfigPre.h" #if HAS_RESUME_CONTINUE #include "../gcode.h" -#include "../../module/stepper.h" +#include "../../module/planner.h" + +#include "../../inc/MarlinConfig.h" #if HAS_LCD_MENU #include "../../lcd/ultralcd.h" @@ -35,8 +37,6 @@ #include "../../lcd/extensible_ui/ui_api.h" #endif -#include "../../sd/cardreader.h" - #if HAS_LEDS_OFF_FLAG #include "../../feature/leds/printer_event_leds.h" #endif diff --git a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h index 9ca51ac86f..1cb4cf3566 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h @@ -38,7 +38,7 @@ #error "You must set ([XYZ]|E0)_DRIVER_TYPE to TMC2130 in Configuration.h for EinsyRetro." #endif -// TMC2130 Diag Pins (currently just for reference) +// TMC2130 Diag Pins #define X_DIAG_PIN 64 #define Y_DIAG_PIN 69 #define Z_DIAG_PIN 68 @@ -55,27 +55,27 @@ #if DISABLED(SENSORLESS_HOMING) - #define X_MIN_PIN 12 - #define Y_MIN_PIN 11 - #define Z_MIN_PIN 10 - #define X_MAX_PIN 81 - #define Y_MAX_PIN 57 + #define X_MIN_PIN 12 // X- + #define Y_MIN_PIN 11 // Y- + #define Z_MIN_PIN 10 // Z- + #define X_MAX_PIN 81 // X+ + #define Y_MAX_PIN 57 // Y+ #else #if X_HOME_DIR < 0 #define X_MIN_PIN X_DIAG_PIN - #define X_MAX_PIN 81 + #define X_MAX_PIN 81 // X+ #else - #define X_MIN_PIN 12 + #define X_MIN_PIN 12 // X- #define X_MAX_PIN X_DIAG_PIN #endif #if Y_HOME_DIR < 0 #define Y_MIN_PIN Y_DIAG_PIN - #define Y_MAX_PIN 57 + #define Y_MAX_PIN 57 // Y+ #else - #define Y_MIN_PIN 11 + #define Y_MIN_PIN 11 // Y- #define Y_MAX_PIN Y_DIAG_PIN #endif From 8737c35ded48c639ffded58a587f555da65d6f1a Mon Sep 17 00:00:00 2001 From: 0r31 <37673727+0r31@users.noreply.github.com> Date: Thu, 30 Jan 2020 05:48:26 +0100 Subject: [PATCH 08/23] Fix HAS_FAN macro (#16717) --- Marlin/src/inc/Conditionals_post.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 1a2c39ec25..5b9ba7c683 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1220,7 +1220,7 @@ // Other fans #define HAS_FAN0 (PIN_EXISTS(FAN)) -#define _HAS_FAN(P) (PIN_EXISTS(FAN_##P) && CONTROLLER_FAN_PIN != FAN_##P##_PIN && E0_AUTO_FAN_PIN != FAN_##P##_PIN && E1_AUTO_FAN_PIN != FAN_##P##_PIN && E2_AUTO_FAN_PIN != FAN_##P##_PIN && E3_AUTO_FAN_PIN != FAN_##P##_PIN && E4_AUTO_FAN_PIN != FAN_##P##_PIN && E5_AUTO_FAN_PIN != FAN_##P##_PIN && E6_AUTO_FAN_PIN != FAN_##P##_PIN && E7_AUTO_FAN_PIN != FAN_##P##_PIN) +#define _HAS_FAN(P) (PIN_EXISTS(FAN##P) && CONTROLLER_FAN_PIN != FAN##P##_PIN && E0_AUTO_FAN_PIN != FAN##P##_PIN && E1_AUTO_FAN_PIN != FAN##P##_PIN && E2_AUTO_FAN_PIN != FAN##P##_PIN && E3_AUTO_FAN_PIN != FAN##P##_PIN && E4_AUTO_FAN_PIN != FAN##P##_PIN && E5_AUTO_FAN_PIN != FAN##P##_PIN && E6_AUTO_FAN_PIN != FAN##P##_PIN && E7_AUTO_FAN_PIN != FAN##P##_PIN) #define HAS_FAN1 _HAS_FAN(1) #define HAS_FAN2 _HAS_FAN(2) #define HAS_FAN3 _HAS_FAN(3) From 1db9d9f76f43850539437e22745ea7f026e8a361 Mon Sep 17 00:00:00 2001 From: Neskik Date: Thu, 30 Jan 2020 10:00:38 +0100 Subject: [PATCH 09/23] Fix probe temp calibration (#16718) --- Marlin/src/feature/probe_temp_compensation.h | 6 +++--- Marlin/src/gcode/calibrate/G76_M871.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/src/feature/probe_temp_compensation.h b/Marlin/src/feature/probe_temp_compensation.h index 64f8cc7a06..91f652980b 100644 --- a/Marlin/src/feature/probe_temp_compensation.h +++ b/Marlin/src/feature/probe_temp_compensation.h @@ -48,10 +48,10 @@ class ProbeTempComp { public: static constexpr temp_calib_t cali_info_init[TSI_COUNT] = { - { 30, 10, 5, 30 + 10 * 5 }, // Probe - { 60, 10, 5, 60 + 10 * 5 }, // Bed + { 10, 5, 30, 30 + 10 * 5 }, // Probe + { 10, 5, 60, 60 + 10 * 5 }, // Bed #if ENABLED(USE_TEMP_EXT_COMPENSATION) - { 180, 5, 20, 180 + 5 * 20 } // Extruder + { 20, 5, 180, 180 + 5 * 20 } // Extruder #endif }; static const temp_calib_t cali_info[TSI_COUNT]; diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index 0e0899fa7a..479f13d50c 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -256,7 +256,7 @@ void GcodeSuite::G76() { // Initialize temperatures uint16_t target_bed = temp_comp.probe_calib_bed_temp, - target_probe = temp_comp.cali_info_init[TSI_BED].start_temp; + target_probe = temp_comp.cali_info_init[TSI_PROBE].start_temp; thermalManager.setTargetBed(target_bed); SERIAL_ECHOLNPGM("Waiting for bed and probe temperature."); while (fabs(thermalManager.degBed() - float(target_bed)) > 0.1f @@ -332,13 +332,13 @@ void GcodeSuite::G76() { else SERIAL_ECHOLNPAIR_F("Measured: ", measured_z); - if (target_probe == temp_comp.cali_info_init[TSI_BED].start_temp) + if (target_probe == temp_comp.cali_info_init[TSI_PROBE].start_temp) temp_comp.prepare_new_calibration(measured_z); else temp_comp.push_back_new_measurement(TSI_PROBE, measured_z); - target_probe += temp_comp.cali_info_init[TSI_BED].temp_res; - if (target_probe > temp_comp.cali_info_init[TSI_BED].end_temp) break; + target_probe += temp_comp.cali_info_init[TSI_PROBE].temp_res; + if (target_probe > temp_comp.cali_info_init[TSI_PROBE].end_temp) break; } SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); From 1bc6509d026e7d3bf853eee729369998c64ce339 Mon Sep 17 00:00:00 2001 From: Mauro Date: Thu, 30 Jan 2020 10:06:17 +0100 Subject: [PATCH 10/23] Support for E4d@BOX mainboard (#16716) --- Marlin/src/core/boards.h | 3 +- Marlin/src/pins/esp32/pins_E4D.h | 90 ++++++++++++++++++++++++++++++++ Marlin/src/pins/pins.h | 2 + 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 Marlin/src/pins/esp32/pins_E4D.h diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 7a3b413e99..f4ada7aaf4 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -332,9 +332,10 @@ // // Espressif ESP32 WiFi // -#define BOARD_ESPRESSIF_ESP32 6000 +#define BOARD_ESPRESSIF_ESP32 6000 // Generic ESP32 #define BOARD_MRR_ESPA 6001 #define BOARD_MRR_ESPE 6002 +#define BOARD_E4D_BOX 6003 // E4d@BOX // // Simulations diff --git a/Marlin/src/pins/esp32/pins_E4D.h b/Marlin/src/pins/esp32/pins_E4D.h new file mode 100644 index 0000000000..d457a7be55 --- /dev/null +++ b/Marlin/src/pins/esp32/pins_E4D.h @@ -0,0 +1,90 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2019 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 + +/** + * E4d@Box pin assignments + * E4d@Box is a small factor 3D printer control board based on the ESP32 microcontroller for Laser, CNC and 3d printers + * for more info check http://atbox.tech/ and join to Facebook page E4d@box. + */ + +#ifndef ARDUINO_ARCH_ESP32 + #error "Oops! Select an ESP32 board in 'Tools > Board.'" +#elif EXTRUDERS > 1 || E_STEPPERS > 1 + #error "E4d@box only supports one E Stepper. Comment out this line to continue." +#elif HOTENDS > 2 + #error "E4d@box currently supports only one hotend. Comment out this line to continue." +#endif + +#define BOARD_INFO_NAME "E4D@BOX" +#define BOARD_WEBSITE_URL "github.com/Exilaus/E4d@box" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// +// Limit Switches +// +#define X_MIN_PIN 34 +#define Y_MIN_PIN 35 +#define Z_MIN_PIN 16 // 15 + +// +// Steppers +// +#define X_STEP_PIN 12 // 34//27 +#define X_DIR_PIN 13 // 35//26 +#define X_ENABLE_PIN 17 // 0//17//25 // used free pin +//#define X_CS_PIN 0 + +#define Y_STEP_PIN 32 // 33 +#define Y_DIR_PIN 33 // 32 +#define Y_ENABLE_PIN X_ENABLE_PIN +//#define Y_CS_PIN 13 + +#define Z_STEP_PIN 25 // 14 +#define Z_DIR_PIN 26 // 12 +#define Z_ENABLE_PIN X_ENABLE_PIN +//#define Z_CS_PIN 5 // SS_PIN + +#define E0_STEP_PIN 27 // 16 +#define E0_DIR_PIN 14 // 17 +#define E0_ENABLE_PIN X_ENABLE_PIN +//#define E0_CS_PIN 21 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 36 // Analog Input +#define TEMP_BED_PIN 39 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 2 // 4//2//(D8) +#define FAN_PIN 0 // 2//15//13 (D9) +#define HEATER_BED_PIN 15 // 15//0 //(D10) + +// SPI +#define SDSS 5 +#define I2S_STEPPER_STREAM +#define I2S_WS 23 +#define I2S_BCK 22 +#define I2S_DATA 21 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index bd799e5e91..3dbbb5e724 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -571,6 +571,8 @@ #include "esp32/pins_MRR_ESPA.h" // ESP32 env:esp32 #elif MB(MRR_ESPE) #include "esp32/pins_MRR_ESPE.h" // ESP32 env:esp32 +#elif MB(E4D_BOX) + #include "esp32/pins_E4D.h" // ESP32 env:esp32 // // Linux Native Debug board From e6a675e6ecaccb5b897bb7c6e4bcf3bf48bfbf6d Mon Sep 17 00:00:00 2001 From: Radek Pietruszewski Date: Thu, 30 Jan 2020 10:13:32 +0100 Subject: [PATCH 11/23] Fix missing string for M48 build (#16708) --- Marlin/src/gcode/calibrate/M48.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index f111de4b17..75c5ed9a81 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -53,6 +53,9 @@ * * This function requires the machine to be homed before invocation. */ + +extern const char SP_Y_STR[]; + void GcodeSuite::M48() { if (axis_unhomed_error()) return; From 99b6a132bcf5ccf54215ef6962eea3e199ea4c0d Mon Sep 17 00:00:00 2001 From: chgi Date: Thu, 30 Jan 2020 18:18:45 +0900 Subject: [PATCH 12/23] Fix G60/G61 slots > 8 and compile error (#16715) --- Marlin/src/gcode/feature/pause/G60.cpp | 2 +- Marlin/src/gcode/feature/pause/G61.cpp | 4 ++-- Marlin/src/module/motion.cpp | 2 +- Marlin/src/module/motion.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/src/gcode/feature/pause/G60.cpp b/Marlin/src/gcode/feature/pause/G60.cpp index 94b73cd7d9..a0d099ad69 100644 --- a/Marlin/src/gcode/feature/pause/G60.cpp +++ b/Marlin/src/gcode/feature/pause/G60.cpp @@ -45,7 +45,7 @@ void GcodeSuite::G60() { } stored_position[slot] = current_position; - SBI(saved_slots, slot); + SBI(saved_slots[slot >> 3], slot & 0b00000111); #if ENABLED(SAVED_POSITIONS_DEBUG) const xyze_pos_t &pos = stored_position[slot]; diff --git a/Marlin/src/gcode/feature/pause/G61.cpp b/Marlin/src/gcode/feature/pause/G61.cpp index 5d854dfab4..d531c15c80 100644 --- a/Marlin/src/gcode/feature/pause/G61.cpp +++ b/Marlin/src/gcode/feature/pause/G61.cpp @@ -25,7 +25,7 @@ #if SAVED_POSITIONS #include "../../../core/language.h" -#include "../../module/planner.h" +#include "../../../module/planner.h" #include "../../gcode.h" #include "../../../module/motion.h" @@ -48,7 +48,7 @@ void GcodeSuite::G61(void) { #endif // No saved position? No axes being restored? - if (!TEST(saved_slots, slot) || !parser.seen("XYZ")) return; + if (!TEST(saved_slots[slot >> 3], slot & 0b00000111) || !parser.seen("XYZ")) return; // Apply any given feedrate over 0.0 const float fr = parser.linearval('F'); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 6dbf940add..50092406c5 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -111,7 +111,7 @@ xyze_pos_t destination; // {0} // G60/G61 Position Save and Return #if SAVED_POSITIONS - uint8_t saved_slots; + uint8_t saved_slots[(SAVED_POSITIONS + 7) >> 3]; xyz_pos_t stored_position[SAVED_POSITIONS]; #endif diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index a30573e797..eafa5ca849 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -67,7 +67,7 @@ extern xyze_pos_t current_position, // High-level current tool position // G60/G61 Position Save and Return #if SAVED_POSITIONS - extern uint8_t saved_slots; + extern uint8_t saved_slots[(SAVED_POSITIONS + 7) >> 3]; extern xyz_pos_t stored_position[SAVED_POSITIONS]; #endif From 50889c0f94778c378357bcc4d4a966fa869bc5c1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 30 Jan 2020 03:24:23 -0600 Subject: [PATCH 13/23] Move L64XX index_to_axis to progmem (#16697) --- Marlin/src/MarlinCore.cpp | 32 +- Marlin/src/feature/babystep.cpp | 2 +- Marlin/src/feature/prusa_MMU2/mmu2.cpp | 16 +- Marlin/src/gcode/calibrate/G33.cpp | 4 +- Marlin/src/gcode/control/M17_M18_M84.cpp | 12 +- Marlin/src/libs/L64XX/L64XX_Marlin.cpp | 102 ++-- Marlin/src/libs/L64XX/L64XX_Marlin.h | 6 +- Marlin/src/module/planner.cpp | 40 +- Marlin/src/module/probe.cpp | 2 +- Marlin/src/module/stepper.cpp | 16 +- Marlin/src/module/stepper/L64xx.h | 50 ++ Marlin/src/module/stepper/indirection.h | 662 +++++++++++++---------- 12 files changed, 539 insertions(+), 405 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 7ec6ffb488..6d78190218 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -291,7 +291,7 @@ void quickstop_stepper() { } void enable_e_steppers() { - #define _ENA_E(N) enable_E##N(); + #define _ENA_E(N) ENABLE_AXIS_E##N(); REPEAT(E_STEPPERS, _ENA_E) } @@ -299,28 +299,28 @@ void enable_all_steppers() { #if ENABLED(AUTO_POWER_CONTROL) powerManager.power_on(); #endif - enable_X(); - enable_Y(); - enable_Z(); + ENABLE_AXIS_X(); + ENABLE_AXIS_Y(); + ENABLE_AXIS_Z(); enable_e_steppers(); } void disable_e_steppers() { - #define _DIS_E(N) disable_E##N(); + #define _DIS_E(N) DISABLE_AXIS_E##N(); REPEAT(E_STEPPERS, _DIS_E) } void disable_e_stepper(const uint8_t e) { - #define _CASE_DIS_E(N) case N: disable_E##N(); break; + #define _CASE_DIS_E(N) case N: DISABLE_AXIS_E##N(); break; switch (e) { REPEAT(EXTRUDERS, _CASE_DIS_E) } } void disable_all_steppers() { - disable_X(); - disable_Y(); - disable_Z(); + DISABLE_AXIS_X(); + DISABLE_AXIS_Y(); + DISABLE_AXIS_Z(); disable_e_steppers(); } @@ -461,13 +461,13 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) { if (!already_shutdown_steppers) { already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this #if ENABLED(DISABLE_INACTIVE_X) - disable_X(); + DISABLE_AXIS_X(); #endif #if ENABLED(DISABLE_INACTIVE_Y) - disable_Y(); + DISABLE_AXIS_Y(); #endif #if ENABLED(DISABLE_INACTIVE_Z) - disable_Z(); + DISABLE_AXIS_Z(); #endif #if ENABLED(DISABLE_INACTIVE_E) disable_e_steppers(); @@ -542,11 +542,11 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) { #if ENABLED(SWITCHING_EXTRUDER) bool oldstatus; switch (active_extruder) { - default: oldstatus = E0_ENABLE_READ(); enable_E0(); break; + default: oldstatus = E0_ENABLE_READ(); ENABLE_AXIS_E0(); break; #if E_STEPPERS > 1 - case 2: case 3: oldstatus = E1_ENABLE_READ(); enable_E1(); break; + case 2: case 3: oldstatus = E1_ENABLE_READ(); ENABLE_AXIS_E1(); break; #if E_STEPPERS > 2 - case 4: case 5: oldstatus = E2_ENABLE_READ(); enable_E2(); break; + case 4: case 5: oldstatus = E2_ENABLE_READ(); ENABLE_AXIS_E2(); break; #endif // E_STEPPERS > 2 #endif // E_STEPPERS > 1 } @@ -554,7 +554,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) { bool oldstatus; switch (active_extruder) { default: - #define _CASE_EN(N) case N: oldstatus = E##N##_ENABLE_READ(); enable_E##N(); break; + #define _CASE_EN(N) case N: oldstatus = E##N##_ENABLE_READ(); ENABLE_AXIS_E##N(); break; REPEAT(E_STEPPERS, _CASE_EN); } #endif diff --git a/Marlin/src/feature/babystep.cpp b/Marlin/src/feature/babystep.cpp index 510950095f..0b08f8ae41 100644 --- a/Marlin/src/feature/babystep.cpp +++ b/Marlin/src/feature/babystep.cpp @@ -78,7 +78,7 @@ void Babystep::add_steps(const AxisEnum axis, const int16_t distance) { #endif #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE) - #define BSA_ENABLE(AXIS) do{ switch (AXIS) { case X_AXIS: enable_X(); break; case Y_AXIS: enable_Y(); break; case Z_AXIS: enable_Z(); break; default: break; } }while(0) + #define BSA_ENABLE(AXIS) do{ switch (AXIS) { case X_AXIS: ENABLE_AXIS_X(); break; case Y_AXIS: ENABLE_AXIS_Y(); break; case Z_AXIS: ENABLE_AXIS_Z(); break; default: break; } }while(0) #else #define BSA_ENABLE(AXIS) NOOP #endif diff --git a/Marlin/src/feature/prusa_MMU2/mmu2.cpp b/Marlin/src/feature/prusa_MMU2/mmu2.cpp index 0e25c86708..d96cbf9720 100644 --- a/Marlin/src/feature/prusa_MMU2/mmu2.cpp +++ b/Marlin/src/feature/prusa_MMU2/mmu2.cpp @@ -448,7 +448,7 @@ void MMU2::tool_change(uint8_t index) { if (index != extruder) { - disable_E0(); + DISABLE_AXIS_E0(); ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); command(MMU_CMD_T0 + index); @@ -459,7 +459,7 @@ void MMU2::tool_change(uint8_t index) { extruder = index; //filament change is finished active_extruder = 0; - enable_E0(); + ENABLE_AXIS_E0(); SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR(MSG_ACTIVE_EXTRUDER, int(extruder)); @@ -497,13 +497,13 @@ void MMU2::tool_change(const char* special) { case 'x': { planner.synchronize(); uint8_t index = mmu2_choose_filament(); - disable_E0(); + DISABLE_AXIS_E0(); command(MMU_CMD_T0 + index); manage_response(true, true); command(MMU_CMD_C0); mmu_loop(); - enable_E0(); + ENABLE_AXIS_E0(); extruder = index; active_extruder = 0; } break; @@ -697,7 +697,7 @@ void MMU2::filament_runout() { LCD_MESSAGEPGM(MSG_MMU2_EJECTING_FILAMENT); - enable_E0(); + ENABLE_AXIS_E0(); current_position.e -= MMU2_FILAMENTCHANGE_EJECT_FEED; line_to_current_position(2500 / 60); planner.synchronize(); @@ -731,7 +731,7 @@ void MMU2::filament_runout() { BUZZ(200, 404); - disable_E0(); + DISABLE_AXIS_E0(); return true; } @@ -776,7 +776,7 @@ void MMU2::filament_runout() { void MMU2::execute_extruder_sequence(const E_Step * sequence, int steps) { planner.synchronize(); - enable_E0(); + ENABLE_AXIS_E0(); const E_Step* step = sequence; @@ -794,7 +794,7 @@ void MMU2::filament_runout() { step++; } - disable_E0(); + DISABLE_AXIS_E0(); } #endif // HAS_LCD_MENU && MMU2_MENUS diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 1931d226af..2ce45359d3 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -439,7 +439,6 @@ void GcodeSuite::G33() { _opposite_results = (_4p_calibration && !towers_set) || probe_points >= 3, _endstop_results = probe_points != 1 && probe_points != -1 && probe_points != 0, _angle_results = probe_points >= 3 && towers_set; - static const char save_message[] PROGMEM = "Save with M500 and/or copy to Configuration.h"; int8_t iterations = 0; float test_precision, zero_std_dev = (verbose_level ? 999.0f : 0.0f), // 0.0 in dry-run mode : forced end @@ -625,8 +624,7 @@ void GcodeSuite::G33() { sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev_min)); ui.set_status(mess); print_calibration_settings(_endstop_results, _angle_results); - serialprintPGM(save_message); - SERIAL_EOL(); + SERIAL_ECHOLNPGM("Save with M500 and/or copy to Configuration.h"); } else { // !end iterations char mess[15]; diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index 081ca18d89..4908a64ecb 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -34,9 +34,9 @@ */ void GcodeSuite::M17() { if (parser.seen("XYZE")) { - if (parser.seen('X')) enable_X(); - if (parser.seen('Y')) enable_Y(); - if (parser.seen('Z')) enable_Z(); + if (parser.seen('X')) ENABLE_AXIS_X(); + if (parser.seen('Y')) ENABLE_AXIS_Y(); + if (parser.seen('Z')) ENABLE_AXIS_Z(); #if HAS_E_STEPPER_ENABLE if (parser.seen('E')) enable_e_steppers(); #endif @@ -57,9 +57,9 @@ void GcodeSuite::M18_M84() { else { if (parser.seen("XYZE")) { planner.synchronize(); - if (parser.seen('X')) disable_X(); - if (parser.seen('Y')) disable_Y(); - if (parser.seen('Z')) disable_Z(); + if (parser.seen('X')) DISABLE_AXIS_X(); + if (parser.seen('Y')) DISABLE_AXIS_Y(); + if (parser.seen('Z')) DISABLE_AXIS_Z(); #if HAS_E_STEPPER_ENABLE if (parser.seen('E')) disable_e_steppers(); #endif diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp index cfa28586b6..645823a126 100644 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp +++ b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp @@ -39,39 +39,40 @@ L64XX_Marlin L64xxManager; void echo_yes_no(const bool yes) { serialprintPGM(yes ? PSTR(" YES") : PSTR(" NO ")); } -char L64XX_Marlin::index_to_axis[MAX_L64XX][3] = { "X ", "Y ", "Z ", "X2", "Y2", "Z2", "Z3", "Z4", "E0", "E1", "E2", "E3", "E4", "E5", "E6", "E7" }; +static const char str_X[] PROGMEM = "X ", str_Y[] PROGMEM = "Y ", str_Z[] PROGMEM = "Z ", + str_X2[] PROGMEM = "X2", str_Y2[] PROGMEM = "Y2", + str_Z2[] PROGMEM = "Z2", str_Z3[] PROGMEM = "Z3", str_Z4[] PROGMEM = "Z4", + str_E0[] PROGMEM = "E0", str_E1[] PROGMEM = "E1", + str_E2[] PROGMEM = "E2", str_E3[] PROGMEM = "E3", + str_E4[] PROGMEM = "E4", str_E5[] PROGMEM = "E5", + str_E6[] PROGMEM = "E6", str_E7[] PROGMEM = "E7" + ; + +PGM_P const L64XX_Marlin::index_to_axis[] PROGMEM = { + str_X, str_Y, str_Z, str_X2, str_Y2, str_Z2, str_Z3, str_Z4, + str_E0, str_E1, str_E2, str_E3, str_E4, str_E5, str_E6, str_E7 +}; #define DEBUG_OUT ENABLED(L6470_CHITCHAT) #include "../../core/debug_out.h" uint8_t L64XX_Marlin::dir_commands[MAX_L64XX]; // array to hold direction command for each driver -uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = { (INVERT_X_DIR), // 0 X - (INVERT_Y_DIR), // 1 Y - (INVERT_Z_DIR), // 2 Z - #if ENABLED(X_DUAL_STEPPER_DRIVERS) // 3 X2 - (INVERT_X_DIR) ^ (INVERT_X2_VS_X_DIR), - #else - (INVERT_X_DIR), - #endif - #if ENABLED(Y_DUAL_STEPPER_DRIVERS) // 4 Y2 - (INVERT_Y_DIR) ^ (INVERT_Y2_VS_Y_DIR), - #else - (INVERT_Y_DIR), - #endif - (INVERT_Z_DIR), // 5 Z2 - (INVERT_Z_DIR), // 6 Z3 - (INVERT_Z_DIR), // 7 Z4 +const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = { + INVERT_X_DIR, INVERT_Y_DIR, INVERT_Z_DIR + , (INVERT_X_DIR) // X2 + #if ENABLED(X_DUAL_STEPPER_DRIVERS) + ^ (INVERT_X2_VS_X_DIR) + #endif + , (INVERT_Y_DIR) // Y2 + #if ENABLED(Y_DUAL_STEPPER_DRIVERS) + ^ (INVERT_Y2_VS_Y_DIR) + #endif + , INVERT_Z_DIR, INVERT_Z_DIR, INVERT_Z_DIR // Z2,Z3,Z4 - (INVERT_E0_DIR), // 8 E0 - (INVERT_E1_DIR), // 9 E1 - (INVERT_E2_DIR), // 10 E2 - (INVERT_E3_DIR), // 11 E3 - (INVERT_E4_DIR), // 12 E4 - (INVERT_E5_DIR), // 13 E5 - (INVERT_E6_DIR), // 14 E6 - (INVERT_E7_DIR) // 15 E7 - }; + , INVERT_E0_DIR, INVERT_E1_DIR, INVERT_E2_DIR, INVERT_E3_DIR + , INVERT_E4_DIR, INVERT_E5_DIR, INVERT_E6_DIR, INVERT_E7_DIR +}; volatile uint8_t L64XX_Marlin::spi_abort = false; uint8_t L64XX_Marlin::spi_active = false; @@ -379,35 +380,27 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in found_displacement = true; displacement = _displacement; uint8_t axis_offset = parser.byteval('J'); - axis_mon[0][0] = axis_codes[i]; // axis ASCII value (target character) + axis_mon[0][0] = axis_codes[i]; // Axis first character, one of XYZE + const bool single_or_e = axis_offset >= 2 || axis_mon[0][0] == 'E', + one_or_more = !single_or_e && axis_offset == 0; uint8_t driver_count_local = 0; // Can't use "driver_count" directly as a subscript because it's passed by reference - if (axis_offset >= 2 || axis_mon[0][0] == 'E') { // Single axis, E0, or E1 - axis_mon[0][1] = axis_offset + '0'; - for (j = 0; j < MAX_L64XX; j++) { // See how many drivers on this axis - const char * const str = index_to_axis[j]; - if (axis_mon[0][0] == str[0]) { - char * const mon = axis_mon[driver_count_local]; - mon[0] = str[0]; - mon[1] = str[1]; - mon[2] = str[2]; // append end of string - axis_index[driver_count_local] = (L64XX_axis_t)j; // set axis index + if (single_or_e) // Single axis, E0, or E1 + axis_mon[0][1] = axis_offset + '0'; // Index given by 'J' parameter + + if (single_or_e || one_or_more) { + for (j = 0; j < MAX_L64XX; j++) { // Count up the drivers on this axis + PGM_P str = (PGM_P)pgm_read_ptr(&index_to_axis[j]); // Get a PGM_P from progmem + const char c = pgm_read_byte(str); // Get a char from progmem + if (axis_mon[0][0] == c) { // For each stepper on this axis... + char *mon = axis_mon[driver_count_local]; + *mon++ = c; // Copy the 3 letter axis name + *mon++ = pgm_read_byte(&str[1]); // to the axis_mon array + *mon = pgm_read_byte(&str[2]); + axis_index[driver_count_local] = (L64XX_axis_t)j; // And store the L64XX axis index driver_count_local++; } } - } - else if (axis_offset == 0) { // One or more axes - for (j = 0; j < MAX_L64XX; j++) { // See how many drivers on this axis - const char * const str = index_to_axis[j]; - if (axis_mon[0][0] == str[0]) { - char * const mon = axis_mon[driver_count_local]; - mon[0] = str[0]; - mon[1] = str[1]; - mon[2] = str[2]; // append end of string - axis_index[driver_count_local] = (L64XX_axis_t)j; // set axis index - driver_count_local++; - } - } - driver_count = driver_count_local; + if (one_or_more) driver_count = driver_count_local; } break; // only take first axis found } @@ -494,8 +487,8 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in for (uint8_t k = 0; k < driver_count; k++) { uint8_t not_found = true; for (j = 1; j <= L64XX::chain[0]; j++) { - const char * const ind_axis = index_to_axis[L64XX::chain[j]]; - if (ind_axis[0] == axis_mon[k][0] && ind_axis[1] == axis_mon[k][1]) { // See if a L6470 driver + PGM_P const str = (PGM_P)pgm_read_ptr(&index_to_axis[L64XX::chain[j]]); + if (pgm_read_byte(&str[0]) == axis_mon[k][0] && pgm_read_byte(&str[1]) == axis_mon[k][1]) { // See if a L6470 driver not_found = false; break; } @@ -724,7 +717,8 @@ void L64XX_Marlin::say_axis(const L64XX_axis_t axis, const uint8_t label/*=true* }; void L64XX_Marlin::append_stepper_err(char* &p, const uint8_t stepper_index, const char * const err/*=nullptr*/) { - p += sprintf_P(p, PSTR("Stepper %c%c "), index_to_axis[stepper_index][0], index_to_axis[stepper_index][1]); + PGM_P const str = (PGM_P)pgm_read_ptr(&index_to_axis[stepper_index]); + p += sprintf_P(p, PSTR("Stepper %c%c "), pgm_read_byte(&str[0]), pgm_read_byte(&str[1])); if (err) p += sprintf_P(p, err); } diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.h b/Marlin/src/libs/L64XX/L64XX_Marlin.h index 9c233fdf03..08315fc68f 100644 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.h +++ b/Marlin/src/libs/L64XX/L64XX_Marlin.h @@ -39,9 +39,10 @@ enum L64XX_axis_t : uint8_t { X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E class L64XX_Marlin : public L64XXHelper { public: - static char index_to_axis[MAX_L64XX][3]; + static PGM_P const index_to_axis[MAX_L64XX]; + + static const uint8_t index_to_dir[MAX_L64XX]; - static uint8_t index_to_dir[MAX_L64XX]; static uint8_t dir_commands[MAX_L64XX]; // Flags to guarantee graceful switch if stepper interrupts L6470 SPI transfer @@ -69,7 +70,6 @@ public: static void transfer(uint8_t L6470_buf[], const uint8_t length); - //static char* index_to_axis(const uint8_t index); static void say_axis(const L64XX_axis_t axis, const uint8_t label=true); #if ENABLED(L6470_CHITCHAT) static void error_status_decode( diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 0552206315..351b089895 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1252,13 +1252,13 @@ void Planner::check_axes_activity() { // Disable inactive axes // #if ENABLED(DISABLE_X) - if (!axis_active.x) disable_X(); + if (!axis_active.x) DISABLE_AXIS_X(); #endif #if ENABLED(DISABLE_Y) - if (!axis_active.y) disable_Y(); + if (!axis_active.y) DISABLE_AXIS_Y(); #endif #if ENABLED(DISABLE_Z) - if (!axis_active.z) disable_Z(); + if (!axis_active.z) DISABLE_AXIS_Z(); #endif #if ENABLED(DISABLE_E) if (!axis_active.e) disable_e_steppers(); @@ -1905,29 +1905,29 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Enable active axes #if CORE_IS_XY if (block->steps.a || block->steps.b) { - enable_X(); - enable_Y(); + ENABLE_AXIS_X(); + ENABLE_AXIS_Y(); } #if DISABLED(Z_LATE_ENABLE) - if (block->steps.z) enable_Z(); + if (block->steps.z) ENABLE_AXIS_Z(); #endif #elif CORE_IS_XZ if (block->steps.a || block->steps.c) { - enable_X(); - enable_Z(); + ENABLE_AXIS_X(); + ENABLE_AXIS_Z(); } - if (block->steps.y) enable_Y(); + if (block->steps.y) ENABLE_AXIS_Y(); #elif CORE_IS_YZ if (block->steps.b || block->steps.c) { - enable_Y(); - enable_Z(); + ENABLE_AXIS_Y(); + ENABLE_AXIS_Z(); } - if (block->steps.x) enable_X(); + if (block->steps.x) ENABLE_AXIS_X(); #else - if (block->steps.x) enable_X(); - if (block->steps.y) enable_Y(); + if (block->steps.x) ENABLE_AXIS_X(); + if (block->steps.y) ENABLE_AXIS_Y(); #if DISABLED(Z_LATE_ENABLE) - if (block->steps.z) enable_Z(); + if (block->steps.z) ENABLE_AXIS_Z(); #endif #endif @@ -1945,27 +1945,27 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #if HAS_DUPLICATION_MODE if (extruder_duplication_enabled && extruder == 0) { - enable_E1(); + ENABLE_AXIS_E1(); g_uc_extruder_last_move[1] = (BLOCK_BUFFER_SIZE) * 2; } #endif #define ENABLE_ONE_E(N) do{ \ if (extruder == N) { \ - enable_E##N(); \ + ENABLE_AXIS_E##N(); \ g_uc_extruder_last_move[N] = (BLOCK_BUFFER_SIZE) * 2; \ } \ else if (!g_uc_extruder_last_move[N]) \ - disable_E##N(); \ + DISABLE_AXIS_E##N(); \ }while(0); #else - #define ENABLE_ONE_E(N) enable_E##N(); + #define ENABLE_ONE_E(N) ENABLE_AXIS_E##N(); #endif - REPEAT(EXTRUDERS, ENABLE_ONE_E); + REPEAT(EXTRUDERS, ENABLE_ONE_E); // (ENABLE_ONE_E must end with semicolon) } #endif // EXTRUDERS diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 31c1128369..5710614e00 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -251,7 +251,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load() #if ENABLED(PROBING_STEPPERS_OFF) disable_e_steppers(); #if NONE(DELTA, HOME_AFTER_DEACTIVATE) - disable_X(); disable_Y(); + DISABLE_AXIS_X(); DISABLE_AXIS_Y(); #endif #endif if (p) safe_delay( diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 6e4977984f..4e46ea56cd 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -1927,7 +1927,7 @@ uint32_t Stepper::stepper_block_phase_isr() { // If delayed Z enable, enable it now. This option will severely interfere with // timing between pulses when chaining motion between blocks, and it could lead // to lost steps in both X and Y axis, so avoid using it unless strictly necessary!! - if (current_block->steps.z) enable_Z(); + if (current_block->steps.z) ENABLE_AXIS_Z(); #endif // Mark the time_nominal as not calculated yet @@ -2215,12 +2215,12 @@ void Stepper::init() { #define _STEP_INIT(AXIS) AXIS ##_STEP_INIT() #define _WRITE_STEP(AXIS, HIGHLOW) AXIS ##_STEP_WRITE(HIGHLOW) - #define _DISABLE(AXIS) disable_## AXIS() + #define _DISABLE_AXIS(AXIS) DISABLE_AXIS_## AXIS() #define AXIS_INIT(AXIS, PIN) \ _STEP_INIT(AXIS); \ _WRITE_STEP(AXIS, _INVERT_STEP_PIN(PIN)); \ - _DISABLE(AXIS) + _DISABLE_AXIS(AXIS) #define E_AXIS_INIT(NUM) AXIS_INIT(E## NUM, E) @@ -2437,7 +2437,7 @@ void Stepper::report_positions() { #endif #define EXTRA_CYCLES_BABYSTEP (STEP_PULSE_CYCLES - (CYCLES_EATEN_BABYSTEP)) - #define _ENABLE(AXIS) enable_## AXIS() + #define _ENABLE_AXIS(AXIS) ENABLE_AXIS_## AXIS() #define _READ_DIR(AXIS) AXIS ##_DIR_READ() #define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR #define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true) @@ -2460,7 +2460,7 @@ void Stepper::report_positions() { #define BABYSTEP_AXIS(AXIS, INVERT, DIR) { \ const uint8_t old_dir = _READ_DIR(AXIS); \ - _ENABLE(AXIS); \ + _ENABLE_AXIS(AXIS); \ DELAY_NS(MINIMUM_STEPPER_PRE_DIR_DELAY); \ _APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^DIR^INVERT); \ DELAY_NS(MINIMUM_STEPPER_POST_DIR_DELAY); \ @@ -2523,9 +2523,9 @@ void Stepper::report_positions() { const bool z_direction = direction ^ BABYSTEP_INVERT_Z; - enable_X(); - enable_Y(); - enable_Z(); + ENABLE_AXIS_X(); + ENABLE_AXIS_Y(); + ENABLE_AXIS_Z(); #if MINIMUM_STEPPER_PRE_DIR_DELAY > 0 DELAY_NS(MINIMUM_STEPPER_PRE_DIR_DELAY); diff --git a/Marlin/src/module/stepper/L64xx.h b/Marlin/src/module/stepper/L64xx.h index 35b3d723de..919e966940 100644 --- a/Marlin/src/module/stepper/L64xx.h +++ b/Marlin/src/module/stepper/L64xx.h @@ -55,6 +55,9 @@ #define X_DIR_INIT() NOOP #define X_DIR_WRITE(STATE) L64XX_DIR_WRITE(X, STATE) #define X_DIR_READ() (stepper##X.getStatus() & STATUS_DIR); + #if AXIS_DRIVER_TYPE_X(L6470) + #define DISABLE_STEPPER_X() stepperX.free() + #endif #endif #endif @@ -72,6 +75,9 @@ #define Y_DIR_INIT() NOOP #define Y_DIR_WRITE(STATE) L64XX_DIR_WRITE(Y, STATE) #define Y_DIR_READ() (stepper##Y.getStatus() & STATUS_DIR); + #if AXIS_DRIVER_TYPE_Y(L6470) + #define DISABLE_STEPPER_Y() stepperY.free() + #endif #endif #endif @@ -89,6 +95,9 @@ #define Z_DIR_INIT() NOOP #define Z_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z, STATE) #define Z_DIR_READ() (stepper##Z.getStatus() & STATUS_DIR); + #if AXIS_DRIVER_TYPE_Z(L6470) + #define DISABLE_STEPPER_Z() stepperZ.free() + #endif #endif #endif @@ -109,6 +118,10 @@ #endif #endif +#if AXIS_DRIVER_TYPE_X2(L6470) + #define DISABLE_STEPPER_X2() stepperX2.free() +#endif + // Y2 Stepper #if HAS_Y2_ENABLE && AXIS_IS_L64XX(Y2) extern L64XX_CLASS(Y2) stepperY2; @@ -126,6 +139,10 @@ #endif #endif +#if AXIS_DRIVER_TYPE_Y2(L6470) + #define DISABLE_STEPPER_Y2() stepperY2.free() +#endif + // Z2 Stepper #if HAS_Z2_ENABLE && AXIS_IS_L64XX(Z2) extern L64XX_CLASS(Z2) stepperZ2; @@ -143,6 +160,10 @@ #endif #endif +#if AXIS_DRIVER_TYPE_Z2(L6470) + #define DISABLE_STEPPER_Z2() stepperZ2.free() +#endif + // Z3 Stepper #if HAS_Z3_ENABLE && AXIS_IS_L64XX(Z3) extern L64XX_CLASS(Z3) stepperZ3; @@ -160,6 +181,10 @@ #endif #endif +#if AXIS_DRIVER_TYPE_Z3(L6470) + #define DISABLE_STEPPER_Z3() stepperZ3.free() +#endif + // Z4 Stepper #if HAS_Z4_ENABLE && AXIS_IS_L64XX(Z4) extern L64XX_CLASS(Z4) stepperZ4; @@ -177,6 +202,10 @@ #endif #endif +#if AXIS_DRIVER_TYPE_Z4(L6470) + #define DISABLE_STEPPER_Z4() stepperZ4.free() +#endif + // E0 Stepper #if AXIS_IS_L64XX(E0) extern L64XX_CLASS(E0) stepperE0; @@ -191,6 +220,9 @@ #define E0_DIR_INIT() NOOP #define E0_DIR_WRITE(STATE) L64XX_DIR_WRITE(E0, STATE) #define E0_DIR_READ() (stepper##E0.getStatus() & STATUS_DIR); + #if AXIS_DRIVER_TYPE_E0(L6470) + #define DISABLE_STEPPER_E0() do{ stepperE0.free(); CBI(axis_known_position, E_AXIS); }while(0) + #endif #endif #endif @@ -208,6 +240,9 @@ #define E1_DIR_INIT() NOOP #define E1_DIR_WRITE(STATE) L64XX_DIR_WRITE(E1, STATE) #define E1_DIR_READ() (stepper##E1.getStatus() & STATUS_DIR); + #if AXIS_DRIVER_TYPE_E1(L6470) + #define DISABLE_STEPPER_E1() do{ stepperE1.free(); CBI(axis_known_position, E_AXIS); }while(0) + #endif #endif #endif @@ -225,6 +260,9 @@ #define E2_DIR_INIT() NOOP #define E2_DIR_WRITE(STATE) L64XX_DIR_WRITE(E2, STATE) #define E2_DIR_READ() (stepper##E2.getStatus() & STATUS_DIR); + #if AXIS_DRIVER_TYPE_E2(L6470) + #define DISABLE_STEPPER_E2() do{ stepperE2.free(); CBI(axis_known_position, E_AXIS); }while(0) + #endif #endif #endif @@ -259,6 +297,9 @@ #define E4_DIR_INIT() NOOP #define E4_DIR_WRITE(STATE) L64XX_DIR_WRITE(E4, STATE) #define E4_DIR_READ() (stepper##E4.getStatus() & STATUS_DIR); + #if AXIS_DRIVER_TYPE_E4(L6470) + #define DISABLE_STEPPER_E4() do{ stepperE4.free(); CBI(axis_known_position, E_AXIS); }while(0) + #endif #endif #endif @@ -276,6 +317,9 @@ #define E5_DIR_INIT() NOOP #define E5_DIR_WRITE(STATE) L64XX_DIR_WRITE(E5, STATE) #define E5_DIR_READ() (stepper##E5.getStatus() & STATUS_DIR); + #if AXIS_DRIVER_TYPE_E5(L6470) + #define DISABLE_STEPPER_E5() do{ stepperE5.free(); CBI(axis_known_position, E_AXIS); }while(0) + #endif #endif #endif @@ -293,6 +337,9 @@ #define E6_DIR_INIT() NOOP #define E6_DIR_WRITE(STATE) L64XX_DIR_WRITE(E6, STATE) #define E6_DIR_READ() (stepper##E6.getStatus() & STATUS_DIR); + #if AXIS_DRIVER_TYPE_E6(L6470) + #define DISABLE_STEPPER_E6() do{ stepperE6.free(); CBI(axis_known_position, E_AXIS); }while(0) + #endif #endif #endif @@ -310,5 +357,8 @@ #define E7_DIR_INIT() NOOP #define E7_DIR_WRITE(STATE) L64XX_DIR_WRITE(E7, STATE) #define E7_DIR_READ() (stepper##E7.getStatus() & STATUS_DIR); + #if AXIS_DRIVER_TYPE_E7(L6470) + #define DISABLE_STEPPER_E7() do{ stepperE7.free(); CBI(axis_known_position, E_AXIS); }while(0) + #endif #endif #endif diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index d05c7e3db3..55e44fbe04 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -594,320 +594,412 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #endif // -// X, Y, Z Stepper enable / disable -// -#if AXIS_DRIVER_TYPE_X(L6470) - extern L6470 stepperX; - #define X_enable() NOOP - #define X_disable() stepperX.free() -#elif HAS_X_ENABLE - #define X_enable() X_ENABLE_WRITE( X_ENABLE_ON) - #define X_disable() X_ENABLE_WRITE(!X_ENABLE_ON) -#else - #define X_enable() NOOP - #define X_disable() NOOP -#endif - -#if AXIS_DRIVER_TYPE_X2(L6470) - extern L6470 stepperX2; - #define X2_enable() NOOP - #define X2_disable() stepperX2.free() -#elif HAS_X2_ENABLE - #define X2_enable() X2_ENABLE_WRITE( X_ENABLE_ON) - #define X2_disable() X2_ENABLE_WRITE(!X_ENABLE_ON) -#else - #define X2_enable() NOOP - #define X2_disable() NOOP -#endif - -#define enable_X() do{ X_enable(); X2_enable(); }while(0) -#define disable_X() do{ X_disable(); X2_disable(); CBI(axis_known_position, X_AXIS); }while(0) - -#if AXIS_DRIVER_TYPE_Y(L6470) - extern L6470 stepperY; - #define Y_enable() NOOP - #define Y_disable() stepperY.free() -#elif HAS_Y_ENABLE - #define Y_enable() Y_ENABLE_WRITE( Y_ENABLE_ON) - #define Y_disable() Y_ENABLE_WRITE(!Y_ENABLE_ON) -#else - #define Y_enable() NOOP - #define Y_disable() NOOP -#endif - -#if AXIS_DRIVER_TYPE_Y2(L6470) - extern L6470 stepperY2; - #define Y2_enable() NOOP - #define Y2_disable() stepperY2.free() -#elif HAS_Y2_ENABLE - #define Y2_enable() Y2_ENABLE_WRITE( Y_ENABLE_ON) - #define Y2_disable() Y2_ENABLE_WRITE(!Y_ENABLE_ON) -#else - #define Y2_enable() NOOP - #define Y2_disable() NOOP -#endif - -#define enable_Y() do{ Y_enable(); Y2_enable(); }while(0) -#define disable_Y() do{ Y_disable(); Y2_disable(); CBI(axis_known_position, Y_AXIS); }while(0) - -#if AXIS_DRIVER_TYPE_Z(L6470) - extern L6470 stepperZ; - #define Z_enable() NOOP - #define Z_disable() stepperZ.free() -#elif HAS_Z_ENABLE - #define Z_enable() Z_ENABLE_WRITE( Z_ENABLE_ON) - #define Z_disable() Z_ENABLE_WRITE(!Z_ENABLE_ON) -#else - #define Z_enable() NOOP - #define Z_disable() NOOP -#endif - -#if AXIS_DRIVER_TYPE_Z2(L6470) - extern L6470 stepperZ2; - #define Z2_enable() NOOP - #define Z2_disable() stepperZ2.free() -#elif HAS_Z2_ENABLE - #define Z2_enable() Z2_ENABLE_WRITE( Z_ENABLE_ON) - #define Z2_disable() Z2_ENABLE_WRITE(!Z_ENABLE_ON) -#else - #define Z2_enable() NOOP - #define Z2_disable() NOOP -#endif - -#if AXIS_DRIVER_TYPE_Z3(L6470) - extern L6470 stepperZ3; - #define Z3_enable() NOOP - #define Z3_disable() stepperZ3.free() -#elif HAS_Z3_ENABLE - #define Z3_enable() Z3_ENABLE_WRITE( Z_ENABLE_ON) - #define Z3_disable() Z3_ENABLE_WRITE(!Z_ENABLE_ON) -#else - #define Z3_enable() NOOP - #define Z3_disable() NOOP -#endif - -#if AXIS_DRIVER_TYPE_Z4(L6470) - extern L6470 stepperZ4; - #define Z4_enable() NOOP - #define Z4_disable() stepperZ4.free() -#elif HAS_Z4_ENABLE - #define Z4_enable() Z4_ENABLE_WRITE( Z_ENABLE_ON) - #define Z4_disable() Z4_ENABLE_WRITE(!Z_ENABLE_ON) -#else - #define Z4_enable() NOOP - #define Z4_disable() NOOP -#endif - -#define enable_Z() do{ Z_enable(); Z2_enable(); Z3_enable(); Z4_enable(); }while(0) -#define disable_Z() do{ Z_disable(); Z2_disable(); Z3_disable(); Z4_disable(); CBI(axis_known_position, Z_AXIS); }while(0) - -// -// Extruder Stepper enable / disable +// Individual stepper enable / disable macros // -// define the individual enables/disables -#if AXIS_DRIVER_TYPE_E0(L6470) - extern L6470 stepperE0; - #define E0_enable() NOOP - #define E0_disable() do{ stepperE0.free(); CBI(axis_known_position, E_AXIS); }while(0) -#elif HAS_E0_ENABLE - #define E0_enable() E0_ENABLE_WRITE( E_ENABLE_ON) - #define E0_disable() E0_ENABLE_WRITE(!E_ENABLE_ON) -#else - #define E0_enable() NOOP - #define E0_disable() NOOP +#ifndef ENABLE_STEPPER_X + #if HAS_X_ENABLE + #define ENABLE_STEPPER_X() X_ENABLE_WRITE( X_ENABLE_ON) + #else + #define ENABLE_STEPPER_X() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_X + #if HAS_X_ENABLE + #define DISABLE_STEPPER_X() X_ENABLE_WRITE(!X_ENABLE_ON) + #else + #define DISABLE_STEPPER_X() NOOP + #endif #endif -#if AXIS_DRIVER_TYPE_E1(L6470) - extern L6470 stepperE1; - #define E1_enable() NOOP - #define E1_disable() do{ stepperE1.free(); CBI(axis_known_position, E_AXIS); }while(0) -#elif E_STEPPERS > 1 && HAS_E1_ENABLE - #define E1_enable() E1_ENABLE_WRITE( E_ENABLE_ON) - #define E1_disable() E1_ENABLE_WRITE(!E_ENABLE_ON) -#else - #define E1_enable() NOOP - #define E1_disable() NOOP +#ifndef ENABLE_STEPPER_X2 + #if HAS_X2_ENABLE + #define ENABLE_STEPPER_X2() X2_ENABLE_WRITE( X_ENABLE_ON) + #else + #define ENABLE_STEPPER_X2() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_X2 + #if HAS_X2_ENABLE + #define DISABLE_STEPPER_X2() X2_ENABLE_WRITE(!X_ENABLE_ON) + #else + #define DISABLE_STEPPER_X2() NOOP + #endif #endif -#if AXIS_DRIVER_TYPE_E2(L6470) - extern L6470 stepperE2; - #define E2_enable() NOOP - #define E2_disable() do{ stepperE2.free(); CBI(axis_known_position, E_AXIS); }while(0) -#elif E_STEPPERS > 2 && HAS_E2_ENABLE - #define E2_enable() E2_ENABLE_WRITE( E_ENABLE_ON) - #define E2_disable() E2_ENABLE_WRITE(!E_ENABLE_ON) -#else - #define E2_enable() NOOP - #define E2_disable() NOOP +#ifndef ENABLE_STEPPER_Y + #if HAS_Y_ENABLE + #define ENABLE_STEPPER_Y() Y_ENABLE_WRITE( Y_ENABLE_ON) + #else + #define ENABLE_STEPPER_Y() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_Y + #if HAS_Y_ENABLE + #define DISABLE_STEPPER_Y() Y_ENABLE_WRITE(!Y_ENABLE_ON) + #else + #define DISABLE_STEPPER_Y() NOOP + #endif #endif -#if AXIS_DRIVER_TYPE_E3(L6470) - extern L6470 stepperE3; - #define E3_enable() NOOP - #define E3_disable() do{ stepperE3.free(); CBI(axis_known_position, E_AXIS); }while(0) -#elif E_STEPPERS > 3 && HAS_E3_ENABLE - #define E3_enable() E3_ENABLE_WRITE( E_ENABLE_ON) - #define E3_disable() E3_ENABLE_WRITE(!E_ENABLE_ON) -#else - #define E3_enable() NOOP - #define E3_disable() NOOP +#ifndef ENABLE_STEPPER_Y2 + #if HAS_Y2_ENABLE + #define ENABLE_STEPPER_Y2() Y2_ENABLE_WRITE( Y_ENABLE_ON) + #else + #define ENABLE_STEPPER_Y2() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_Y2 + #if HAS_Y2_ENABLE + #define DISABLE_STEPPER_Y2() Y2_ENABLE_WRITE(!Y_ENABLE_ON) + #else + #define DISABLE_STEPPER_Y2() NOOP + #endif #endif -#if AXIS_DRIVER_TYPE_E4(L6470) - extern L6470 stepperE4; - #define E4_enable() NOOP - #define E4_disable() do{ stepperE4.free(); CBI(axis_known_position, E_AXIS); }while(0) -#elif E_STEPPERS > 4 && HAS_E4_ENABLE - #define E4_enable() E4_ENABLE_WRITE( E_ENABLE_ON) - #define E4_disable() E4_ENABLE_WRITE(!E_ENABLE_ON) -#else - #define E4_enable() NOOP - #define E4_disable() NOOP +#ifndef ENABLE_STEPPER_Z + #if HAS_Z_ENABLE + #define ENABLE_STEPPER_Z() Z_ENABLE_WRITE( Z_ENABLE_ON) + #else + #define ENABLE_STEPPER_Z() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_Z + #if HAS_Z_ENABLE + #define DISABLE_STEPPER_Z() Z_ENABLE_WRITE(!Z_ENABLE_ON) + #else + #define DISABLE_STEPPER_Z() NOOP + #endif #endif -#if AXIS_DRIVER_TYPE_E5(L6470) - extern L6470 stepperE5; - #define E5_enable() NOOP - #define E5_disable() do{ stepperE5.free(); CBI(axis_known_position, E_AXIS); }while(0) -#elif E_STEPPERS > 5 && HAS_E5_ENABLE - #define E5_enable() E5_ENABLE_WRITE( E_ENABLE_ON) - #define E5_disable() E5_ENABLE_WRITE(!E_ENABLE_ON) -#else - #define E5_enable() NOOP - #define E5_disable() NOOP +#ifndef ENABLE_STEPPER_Z2 + #if HAS_Z2_ENABLE + #define ENABLE_STEPPER_Z2() Z2_ENABLE_WRITE( Z_ENABLE_ON) + #else + #define ENABLE_STEPPER_Z2() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_Z2 + #if HAS_Z2_ENABLE + #define DISABLE_STEPPER_Z2() Z2_ENABLE_WRITE(!Z_ENABLE_ON) + #else + #define DISABLE_STEPPER_Z2() NOOP + #endif #endif -#if AXIS_DRIVER_TYPE_E6(L6470) - extern L6470 stepperE6; - #define E6_enable() NOOP - #define E6_disable() do{ stepperE6.free(); CBI(axis_known_position, E_AXIS); }while(0) -#elif E_STEPPERS > 6 && HAS_E6_ENABLE - #define E6_enable() E6_ENABLE_WRITE( E_ENABLE_ON) - #define E6_disable() E6_ENABLE_WRITE(!E_ENABLE_ON) -#else - #define E6_enable() NOOP - #define E6_disable() NOOP +#ifndef ENABLE_STEPPER_Z3 + #if HAS_Z3_ENABLE + #define ENABLE_STEPPER_Z3() Z3_ENABLE_WRITE( Z_ENABLE_ON) + #else + #define ENABLE_STEPPER_Z3() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_Z3 + #if HAS_Z3_ENABLE + #define DISABLE_STEPPER_Z3() Z3_ENABLE_WRITE(!Z_ENABLE_ON) + #else + #define DISABLE_STEPPER_Z3() NOOP + #endif #endif -#if AXIS_DRIVER_TYPE_E7(L6470) - extern L6470 stepperE7; - #define E7_enable() NOOP - #define E7_disable() do{ stepperE7.free(); CBI(axis_known_position, E_AXIS); }while(0) -#elif E_STEPPERS > 7 && HAS_E7_ENABLE - #define E7_enable() E7_ENABLE_WRITE( E_ENABLE_ON) - #define E7_disable() E7_ENABLE_WRITE(!E_ENABLE_ON) -#else - #define E7_enable() NOOP - #define E7_disable() NOOP +#ifndef ENABLE_STEPPER_Z4 + #if HAS_Z4_ENABLE + #define ENABLE_STEPPER_Z4() Z4_ENABLE_WRITE( Z_ENABLE_ON) + #else + #define ENABLE_STEPPER_Z4() NOOP + #endif #endif +#ifndef DISABLE_STEPPER_Z4 + #if HAS_Z4_ENABLE + #define DISABLE_STEPPER_Z4() Z4_ENABLE_WRITE(!Z_ENABLE_ON) + #else + #define DISABLE_STEPPER_Z4() NOOP + #endif +#endif + +#ifndef ENABLE_STEPPER_E0 + #if HAS_E0_ENABLE + #define ENABLE_STEPPER_E0() E0_ENABLE_WRITE( E_ENABLE_ON) + #else + #define ENABLE_STEPPER_E0() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_E0 + #if HAS_E0_ENABLE + #define DISABLE_STEPPER_E0() E0_ENABLE_WRITE(!E_ENABLE_ON) + #else + #define DISABLE_STEPPER_E0() NOOP + #endif +#endif + +#ifndef ENABLE_STEPPER_E1 + #if E_STEPPERS > 1 && HAS_E1_ENABLE + #define ENABLE_STEPPER_E1() E1_ENABLE_WRITE( E_ENABLE_ON) + #else + #define ENABLE_STEPPER_E1() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_E1 + #if E_STEPPERS > 1 && HAS_E1_ENABLE + #define DISABLE_STEPPER_E1() E1_ENABLE_WRITE(!E_ENABLE_ON) + #else + #define DISABLE_STEPPER_E1() NOOP + #endif +#endif + +#ifndef ENABLE_STEPPER_E2 + #if E_STEPPERS > 2 && HAS_E2_ENABLE + #define ENABLE_STEPPER_E2() E2_ENABLE_WRITE( E_ENABLE_ON) + #else + #define ENABLE_STEPPER_E2() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_E2 + #if E_STEPPERS > 2 && HAS_E2_ENABLE + #define DISABLE_STEPPER_E2() E2_ENABLE_WRITE(!E_ENABLE_ON) + #else + #define DISABLE_STEPPER_E2() NOOP + #endif +#endif + +#ifndef ENABLE_STEPPER_E3 + #if E_STEPPERS > 3 && HAS_E3_ENABLE + #define ENABLE_STEPPER_E3() E3_ENABLE_WRITE( E_ENABLE_ON) + #else + #define ENABLE_STEPPER_E3() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_E3 + #if E_STEPPERS > 3 && HAS_E3_ENABLE + #define DISABLE_STEPPER_E3() E3_ENABLE_WRITE(!E_ENABLE_ON) + #else + #define DISABLE_STEPPER_E3() NOOP + #endif +#endif + +#ifndef ENABLE_STEPPER_E4 + #if E_STEPPERS > 4 && HAS_E4_ENABLE + #define ENABLE_STEPPER_E4() E4_ENABLE_WRITE( E_ENABLE_ON) + #else + #define ENABLE_STEPPER_E4() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_E4 + #if E_STEPPERS > 4 && HAS_E4_ENABLE + #define DISABLE_STEPPER_E4() E4_ENABLE_WRITE(!E_ENABLE_ON) + #else + #define DISABLE_STEPPER_E4() NOOP + #endif +#endif + +#ifndef ENABLE_STEPPER_E5 + #if E_STEPPERS > 5 && HAS_E5_ENABLE + #define ENABLE_STEPPER_E5() E5_ENABLE_WRITE( E_ENABLE_ON) + #else + #define ENABLE_STEPPER_E5() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_E5 + #if E_STEPPERS > 5 && HAS_E5_ENABLE + #define DISABLE_STEPPER_E5() E5_ENABLE_WRITE(!E_ENABLE_ON) + #else + #define DISABLE_STEPPER_E5() NOOP + #endif +#endif + +#ifndef ENABLE_STEPPER_E6 + #if E_STEPPERS > 6 && HAS_E6_ENABLE + #define ENABLE_STEPPER_E6() E6_ENABLE_WRITE( E_ENABLE_ON) + #else + #define ENABLE_STEPPER_E6() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_E6 + #if E_STEPPERS > 6 && HAS_E6_ENABLE + #define DISABLE_STEPPER_E6() E6_ENABLE_WRITE(!E_ENABLE_ON) + #else + #define DISABLE_STEPPER_E6() NOOP + #endif +#endif + +#ifndef ENABLE_STEPPER_E7 + #if E_STEPPERS > 7 && HAS_E7_ENABLE + #define ENABLE_STEPPER_E7() E7_ENABLE_WRITE( E_ENABLE_ON) + #else + #define ENABLE_STEPPER_E7() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_E7 + #if E_STEPPERS > 7 && HAS_E7_ENABLE + #define DISABLE_STEPPER_E7() E7_ENABLE_WRITE(!E_ENABLE_ON) + #else + #define DISABLE_STEPPER_E7() NOOP + #endif +#endif + +// +// Axis steppers enable / disable macros +// + +#define ENABLE_AXIS_X() do{ ENABLE_STEPPER_X(); ENABLE_STEPPER_X2(); }while(0) +#define DISABLE_AXIS_X() do{ DISABLE_STEPPER_X(); DISABLE_STEPPER_X2(); CBI(axis_known_position, X_AXIS); }while(0) + +#define ENABLE_AXIS_Y() do{ ENABLE_STEPPER_Y(); ENABLE_STEPPER_Y2(); }while(0) +#define DISABLE_AXIS_Y() do{ DISABLE_STEPPER_Y(); DISABLE_STEPPER_Y2(); CBI(axis_known_position, Y_AXIS); }while(0) + +#define ENABLE_AXIS_Z() do{ ENABLE_STEPPER_Z(); ENABLE_STEPPER_Z2(); ENABLE_STEPPER_Z3(); ENABLE_STEPPER_Z4(); }while(0) +#define DISABLE_AXIS_Z() do{ DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); CBI(axis_known_position, Z_AXIS); }while(0) + +// +// Extruder steppers enable / disable macros +// #if ENABLED(MIXING_EXTRUDER) /** - * Mixing steppers synchronize their enable (and direction) together + * Mixing steppers keep all their enable (and direction) states synchronized */ #if MIXING_STEPPERS > 7 - #define enable_E0() { E0_enable(); E1_enable(); E2_enable(); E3_enable(); E4_enable(); E5_enable(); E6_enable(); E7_enable(); } - #define disable_E0() { E0_disable(); E1_disable(); E2_disable(); E3_disable(); E4_disable(); E5_disable(); E6_disable(); E7_disable(); } + #define ENABLE_AXIS_E0() { ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); ENABLE_STEPPER_E2(); ENABLE_STEPPER_E3(); ENABLE_STEPPER_E4(); ENABLE_STEPPER_E5(); ENABLE_STEPPER_E6(); ENABLE_STEPPER_E7(); } + #define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); DISABLE_STEPPER_E3(); DISABLE_STEPPER_E4(); DISABLE_STEPPER_E5(); DISABLE_STEPPER_E6(); DISABLE_STEPPER_E7(); } #elif MIXING_STEPPERS > 6 - #define enable_E0() { E0_enable(); E1_enable(); E2_enable(); E3_enable(); E4_enable(); E5_enable(); E6_enable(); } - #define disable_E0() { E0_disable(); E1_disable(); E2_disable(); E3_disable(); E4_disable(); E5_disable(); E6_disable(); } + #define ENABLE_AXIS_E0() { ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); ENABLE_STEPPER_E2(); ENABLE_STEPPER_E3(); ENABLE_STEPPER_E4(); ENABLE_STEPPER_E5(); ENABLE_STEPPER_E6(); } + #define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); DISABLE_STEPPER_E3(); DISABLE_STEPPER_E4(); DISABLE_STEPPER_E5(); DISABLE_STEPPER_E6(); } #elif MIXING_STEPPERS > 5 - #define enable_E0() { E0_enable(); E1_enable(); E2_enable(); E3_enable(); E4_enable(); E5_enable(); } - #define disable_E0() { E0_disable(); E1_disable(); E2_disable(); E3_disable(); E4_disable(); E5_disable(); } + #define ENABLE_AXIS_E0() { ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); ENABLE_STEPPER_E2(); ENABLE_STEPPER_E3(); ENABLE_STEPPER_E4(); ENABLE_STEPPER_E5(); } + #define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); DISABLE_STEPPER_E3(); DISABLE_STEPPER_E4(); DISABLE_STEPPER_E5(); } #elif MIXING_STEPPERS > 4 - #define enable_E0() { E0_enable(); E1_enable(); E2_enable(); E3_enable(); E4_enable(); } - #define disable_E0() { E0_disable(); E1_disable(); E2_disable(); E3_disable(); E4_disable(); } + #define ENABLE_AXIS_E0() { ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); ENABLE_STEPPER_E2(); ENABLE_STEPPER_E3(); ENABLE_STEPPER_E4(); } + #define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); DISABLE_STEPPER_E3(); DISABLE_STEPPER_E4(); } #elif MIXING_STEPPERS > 3 - #define enable_E0() { E0_enable(); E1_enable(); E2_enable(); E3_enable(); } - #define disable_E0() { E0_disable(); E1_disable(); E2_disable(); E3_disable(); } + #define ENABLE_AXIS_E0() { ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); ENABLE_STEPPER_E2(); ENABLE_STEPPER_E3(); } + #define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); DISABLE_STEPPER_E3(); } #elif MIXING_STEPPERS > 2 - #define enable_E0() { E0_enable(); E1_enable(); E2_enable(); } - #define disable_E0() { E0_disable(); E1_disable(); E2_disable(); } + #define ENABLE_AXIS_E0() { ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); ENABLE_STEPPER_E2(); } + #define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); DISABLE_STEPPER_E2(); } #else - #define enable_E0() { E0_enable(); E1_enable(); } - #define disable_E0() { E0_disable(); E1_disable(); } - #endif - #define enable_E1() NOOP - #define disable_E1() NOOP - #define enable_E2() NOOP - #define disable_E2() NOOP - #define enable_E3() NOOP - #define disable_E3() NOOP - #define enable_E4() NOOP - #define disable_E4() NOOP - #define enable_E5() NOOP - #define disable_E5() NOOP - #define enable_E6() NOOP - #define disable_E6() NOOP - #define enable_E7() NOOP - #define disable_E7() NOOP - -#else // !MIXING_EXTRUDER - - #if HAS_E0_ENABLE - #define enable_E0() E0_enable() - #define disable_E0() E0_disable() - #else - #define enable_E0() NOOP - #define disable_E0() NOOP - #endif - - #if E_STEPPERS > 1 && HAS_E1_ENABLE - #define enable_E1() E1_enable() - #define disable_E1() E1_disable() - #else - #define enable_E1() NOOP - #define disable_E1() NOOP - #endif - - #if E_STEPPERS > 2 && HAS_E2_ENABLE - #define enable_E2() E2_enable() - #define disable_E2() E2_disable() - #else - #define enable_E2() NOOP - #define disable_E2() NOOP - #endif - - #if E_STEPPERS > 3 && HAS_E3_ENABLE - #define enable_E3() E3_enable() - #define disable_E3() E3_disable() - #else - #define enable_E3() NOOP - #define disable_E3() NOOP - #endif - - #if E_STEPPERS > 4 && HAS_E4_ENABLE - #define enable_E4() E4_enable() - #define disable_E4() E4_disable() - #else - #define enable_E4() NOOP - #define disable_E4() NOOP - #endif - - #if E_STEPPERS > 5 && HAS_E5_ENABLE - #define enable_E5() E5_enable() - #define disable_E5() E5_disable() - #else - #define enable_E5() NOOP - #define disable_E5() NOOP - #endif - - #if E_STEPPERS > 6 && HAS_E6_ENABLE - #define enable_E6() E6_enable() - #define disable_E6() E6_disable() - #else - #define enable_E6() NOOP - #define disable_E6() NOOP - #endif - - #if E_STEPPERS > 7 && HAS_E7_ENABLE - #define enable_E7() E7_enable() - #define disable_E7() E7_disable() - #else - #define enable_E7() NOOP - #define disable_E7() NOOP + #define ENABLE_AXIS_E0() { ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); } + #define DISABLE_AXIS_E0() { DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); } #endif #endif // !MIXING_EXTRUDER + +#ifndef ENABLE_AXIS_E0 + #if E_STEPPERS > 0 && HAS_E0_ENABLE + #define ENABLE_AXIS_E0() ENABLE_STEPPER_E0() + #else + #define ENABLE_AXIS_E0() NOOP + #endif +#endif +#ifndef DISABLE_AXIS_E0 + #if E_STEPPERS > 0 && HAS_E0_DISABLE + #define DISABLE_AXIS_E0() DISABLE_STEPPER_E0() + #else + #define DISABLE_AXIS_E0() NOOP + #endif +#endif + +#ifndef ENABLE_AXIS_E1 + #if E_STEPPERS > 1 && HAS_E1_ENABLE + #define ENABLE_AXIS_E1() ENABLE_STEPPER_E1() + #else + #define ENABLE_AXIS_E1() NOOP + #endif +#endif +#ifndef DISABLE_AXIS_E1 + #if E_STEPPERS > 1 && HAS_E1_DISABLE + #define DISABLE_AXIS_E1() DISABLE_STEPPER_E1() + #else + #define DISABLE_AXIS_E1() NOOP + #endif +#endif + +#ifndef ENABLE_AXIS_E2 + #if E_STEPPERS > 2 && HAS_E2_ENABLE + #define ENABLE_AXIS_E2() ENABLE_STEPPER_E2() + #else + #define ENABLE_AXIS_E2() NOOP + #endif +#endif +#ifndef DISABLE_AXIS_E2 + #if E_STEPPERS > 2 && HAS_E2_DISABLE + #define DISABLE_AXIS_E2() DISABLE_STEPPER_E2() + #else + #define DISABLE_AXIS_E2() NOOP + #endif +#endif + +#ifndef ENABLE_AXIS_E3 + #if E_STEPPERS > 3 && HAS_E3_ENABLE + #define ENABLE_AXIS_E3() ENABLE_STEPPER_E3() + #else + #define ENABLE_AXIS_E3() NOOP + #endif +#endif +#ifndef DISABLE_AXIS_E3 + #if E_STEPPERS > 3 && HAS_E3_DISABLE + #define DISABLE_AXIS_E3() DISABLE_STEPPER_E3() + #else + #define DISABLE_AXIS_E3() NOOP + #endif +#endif + +#ifndef ENABLE_AXIS_E4 + #if E_STEPPERS > 4 && HAS_E4_ENABLE + #define ENABLE_AXIS_E4() ENABLE_STEPPER_E4() + #else + #define ENABLE_AXIS_E4() NOOP + #endif +#endif +#ifndef DISABLE_AXIS_E4 + #if E_STEPPERS > 4 && HAS_E4_DISABLE + #define DISABLE_AXIS_E4() DISABLE_STEPPER_E4() + #else + #define DISABLE_AXIS_E4() NOOP + #endif +#endif + +#ifndef ENABLE_AXIS_E5 + #if E_STEPPERS > 5 && HAS_E5_ENABLE + #define ENABLE_AXIS_E5() ENABLE_STEPPER_E5() + #else + #define ENABLE_AXIS_E5() NOOP + #endif +#endif +#ifndef DISABLE_AXIS_E5 + #if E_STEPPERS > 5 && HAS_E5_DISABLE + #define DISABLE_AXIS_E5() DISABLE_STEPPER_E5() + #else + #define DISABLE_AXIS_E5() NOOP + #endif +#endif + +#ifndef ENABLE_AXIS_E6 + #if E_STEPPERS > 6 && HAS_E6_ENABLE + #define ENABLE_AXIS_E6() ENABLE_STEPPER_E6() + #else + #define ENABLE_AXIS_E6() NOOP + #endif +#endif +#ifndef DISABLE_AXIS_E6 + #if E_STEPPERS > 6 && HAS_E6_DISABLE + #define DISABLE_AXIS_E6() DISABLE_STEPPER_E6() + #else + #define DISABLE_AXIS_E6() NOOP + #endif +#endif + +#ifndef ENABLE_AXIS_E7 + #if E_STEPPERS > 7 && HAS_E7_ENABLE + #define ENABLE_AXIS_E7() ENABLE_STEPPER_E7() + #else + #define ENABLE_AXIS_E7() NOOP + #endif +#endif +#ifndef DISABLE_AXIS_E7 + #if E_STEPPERS > 7 && HAS_E7_DISABLE + #define DISABLE_AXIS_E7() DISABLE_STEPPER_E7() + #else + #define DISABLE_AXIS_E7() NOOP + #endif +#endif From 9caf5c05e7e408c7192e689e4ed5fe2735bb2995 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 30 Jan 2020 03:24:43 -0600 Subject: [PATCH 14/23] Refactor heater watch, job timer auto-start (#16725) --- Marlin/src/feature/pause.cpp | 4 +- Marlin/src/gcode/temperature/M104_M109.cpp | 30 +++++------ Marlin/src/gcode/temperature/M140_M190.cpp | 11 +++- Marlin/src/gcode/temperature/M141_M191.cpp | 9 +++- Marlin/src/lcd/extensible_ui/ui_api.cpp | 4 +- Marlin/src/module/temperature.cpp | 61 +++++++++++++--------- Marlin/src/module/temperature.h | 51 ++++++++++++++---- 7 files changed, 113 insertions(+), 57 deletions(-) diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 10a1ba6a96..6a2f148ea3 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -564,7 +564,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep #endif // Re-enable the heaters if they timed out - HOTEND_LOOP() thermalManager.reset_heater_idle_timer(e); + HOTEND_LOOP() thermalManager.reset_hotend_idle_timer(e); // Wait for the heaters to reach the target temperatures ensure_safe_temperature(); @@ -633,7 +633,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le bool nozzle_timed_out = false; HOTEND_LOOP() { nozzle_timed_out |= thermalManager.hotend_idle[e].timed_out; - thermalManager.reset_heater_idle_timer(e); + thermalManager.reset_hotend_idle_timer(e); } if (nozzle_timed_out || thermalManager.hotEnoughToExtrude(active_extruder)) // Load the new filament diff --git a/Marlin/src/gcode/temperature/M104_M109.cpp b/Marlin/src/gcode/temperature/M104_M109.cpp index 8c5827e83b..8dbb3af235 100644 --- a/Marlin/src/gcode/temperature/M104_M109.cpp +++ b/Marlin/src/gcode/temperature/M104_M109.cpp @@ -20,6 +20,12 @@ * */ +/** + * gcode/temperature/M104_M109.cpp + * + * Hotend target temperature control + */ + #include "../../inc/MarlinConfigPre.h" #if EXTRUDERS @@ -73,14 +79,11 @@ void GcodeSuite::M104() { #if ENABLED(PRINTJOB_TIMER_AUTOSTART) /** * Stop the timer at the end of print. Start is managed by 'heat and wait' M109. - * We use half EXTRUDE_MINTEMP here to allow nozzles to be put into hot - * standby mode, for instance in a dual extruder setup, without affecting - * the running print timer. + * 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. */ - if (temp <= (EXTRUDE_MINTEMP) / 2) { - print_job_timer.stop(); - ui.reset_status(); - } + thermalManager.check_timer_autostart(false, true); #endif } @@ -90,8 +93,10 @@ void GcodeSuite::M104() { } /** - * M109: Sxxx Wait for extruder(s) to reach temperature. Waits only when heating. - * Rxxx Wait for extruder(s) to reach temperature. Waits when heating and cooling. + * M109: Sxxx Wait for hotend(s) to reach temperature. Waits only when heating. + * Rxxx Wait for hotend(s) to reach temperature. Waits when heating and cooling. + * + * With PRINTJOB_TIMER_AUTOSTART also start the job timer on heating and stop it if turned off. */ void GcodeSuite::M109() { @@ -125,12 +130,7 @@ void GcodeSuite::M109() { * standby mode, (e.g., in a dual extruder setup) without affecting * the running print timer. */ - if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) { - print_job_timer.stop(); - ui.reset_status(); - } - else - startOrResumeJob(); + thermalManager.check_timer_autostart(true, true); #endif #if HAS_DISPLAY diff --git a/Marlin/src/gcode/temperature/M140_M190.cpp b/Marlin/src/gcode/temperature/M140_M190.cpp index d6386cef50..f5c3d36832 100644 --- a/Marlin/src/gcode/temperature/M140_M190.cpp +++ b/Marlin/src/gcode/temperature/M140_M190.cpp @@ -20,6 +20,12 @@ * */ +/** + * gcode/temperature/M140_M190.cpp + * + * Bed target temperature control + */ + #include "../../inc/MarlinConfig.h" #if HAS_HEATED_BED @@ -50,6 +56,8 @@ void GcodeSuite::M140() { /** * M190: Sxxx Wait for bed current temp to reach target temp. Waits only when heating * Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling + * + * With PRINTJOB_TIMER_AUTOSTART also start the job timer on heating. */ void GcodeSuite::M190() { if (DEBUGGING(DRYRUN)) return; @@ -58,8 +66,7 @@ void GcodeSuite::M190() { if (no_wait_for_cooling || parser.seenval('R')) { thermalManager.setTargetBed(parser.value_celsius()); #if ENABLED(PRINTJOB_TIMER_AUTOSTART) - if (parser.value_celsius() > BED_MINTEMP) - startOrResumeJob(); + thermalManager.check_timer_autostart(true, false); #endif } else return; diff --git a/Marlin/src/gcode/temperature/M141_M191.cpp b/Marlin/src/gcode/temperature/M141_M191.cpp index 12eaa24bf9..3c99346599 100644 --- a/Marlin/src/gcode/temperature/M141_M191.cpp +++ b/Marlin/src/gcode/temperature/M141_M191.cpp @@ -20,6 +20,12 @@ * */ +/** + * gcode/temperature/M141_M191.cpp + * + * Chamber target temperature control + */ + #include "../../inc/MarlinConfig.h" #if HAS_HEATED_CHAMBER @@ -59,8 +65,7 @@ void GcodeSuite::M191() { if (no_wait_for_cooling || parser.seenval('R')) { thermalManager.setTargetChamber(parser.value_celsius()); #if ENABLED(PRINTJOB_TIMER_AUTOSTART) - if (parser.value_celsius() > CHAMBER_MINTEMP) - startOrResumeJob(); + thermalManager.check_timer_autostart(true, false); #endif } else return; diff --git a/Marlin/src/lcd/extensible_ui/ui_api.cpp b/Marlin/src/lcd/extensible_ui/ui_api.cpp index 8c8133f22b..5e053b670a 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.cpp +++ b/Marlin/src/lcd/extensible_ui/ui_api.cpp @@ -171,7 +171,7 @@ namespace ExtUI { void enableHeater(const extruder_t extruder) { #if HOTENDS && HEATER_IDLE_HANDLER - thermalManager.reset_heater_idle_timer(extruder - E0); + thermalManager.reset_hotend_idle_timer(extruder - E0); #else UNUSED(extruder); #endif @@ -190,7 +190,7 @@ namespace ExtUI { #endif default: #if HOTENDS - thermalManager.reset_heater_idle_timer(heater - H0); + thermalManager.reset_hotend_idle_timer(heater - H0); #endif break; } diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 559b3d5a1e..61ed04aaea 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -220,10 +220,10 @@ Temperature thermalManager; #endif // FAN_COUNT > 0 #if WATCH_HOTENDS - heater_watch_t Temperature::watch_hotend[HOTENDS]; // = { { 0 } } + hotend_watch_t Temperature::watch_hotend[HOTENDS]; // = { { 0 } } #endif #if HEATER_IDLE_HANDLER - heater_idle_t Temperature::hotend_idle[HOTENDS]; // = { { 0 } } + hotend_idle_t Temperature::hotend_idle[HOTENDS]; // = { { 0 } } #endif #if HAS_HEATED_BED @@ -236,13 +236,13 @@ Temperature thermalManager; int16_t Temperature::maxtemp_raw_BED = HEATER_BED_RAW_HI_TEMP; #endif #if WATCH_BED - heater_watch_t Temperature::watch_bed; // = { 0 } + bed_watch_t Temperature::watch_bed; // = { 0 } #endif #if DISABLED(PIDTEMPBED) millis_t Temperature::next_bed_check_ms; #endif #if HEATER_IDLE_HANDLER - heater_idle_t Temperature::bed_idle; // = { 0 } + hotend_idle_t Temperature::bed_idle; // = { 0 } #endif #endif // HAS_HEATED_BED @@ -256,7 +256,7 @@ Temperature thermalManager; int16_t Temperature::maxtemp_raw_CHAMBER = HEATER_CHAMBER_RAW_HI_TEMP; #endif #if WATCH_CHAMBER - heater_watch_t Temperature::watch_chamber{0}; + chamber_watch_t Temperature::watch_chamber{0}; #endif millis_t Temperature::next_chamber_check_ms; #endif // HAS_HEATED_CHAMBER @@ -1974,12 +1974,7 @@ void Temperature::init() { */ void Temperature::start_watching_hotend(const uint8_t E_NAME) { const uint8_t ee = HOTEND_INDEX; - if (degTargetHotend(ee) && degHotend(ee) < degTargetHotend(ee) - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1)) { - watch_hotend[ee].target = degHotend(ee) + WATCH_TEMP_INCREASE; - watch_hotend[ee].next_ms = millis() + (WATCH_TEMP_PERIOD) * 1000UL; - } - else - watch_hotend[ee].next_ms = 0; + watch_hotend[ee].restart(degHotend(ee), degTargetHotend(ee)); } #endif @@ -1990,12 +1985,7 @@ void Temperature::init() { * This is called when the temperature is set. (M140, M190) */ void Temperature::start_watching_bed() { - if (degTargetBed() && degBed() < degTargetBed() - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1)) { - watch_bed.target = degBed() + WATCH_BED_TEMP_INCREASE; - watch_bed.next_ms = millis() + (WATCH_BED_TEMP_PERIOD) * 1000UL; - } - else - watch_bed.next_ms = 0; + watch_bed.restart(degBed(), degTargetBed()); } #endif @@ -2006,12 +1996,7 @@ void Temperature::init() { * This is called when the temperature is set. (M141, M191) */ void Temperature::start_watching_chamber() { - if (degChamber() < degTargetChamber() - (WATCH_CHAMBER_TEMP_INCREASE + TEMP_CHAMBER_HYSTERESIS + 1)) { - watch_chamber.target = degChamber() + WATCH_CHAMBER_TEMP_INCREASE; - watch_chamber.next_ms = millis() + (WATCH_CHAMBER_TEMP_PERIOD) * 1000UL; - } - else - watch_chamber.next_ms = 0; + watch_chamber.restart(degChamber(), degTargetChamber()); } #endif @@ -2154,6 +2139,34 @@ void Temperature::disable_all_heaters() { #endif } +#if ENABLED(PRINTJOB_TIMER_AUTOSTART) + + bool Temperature::over_autostart_threshold() { + #if HOTENDS + HOTEND_LOOP() if (degTargetHotend(e) < (EXTRUDE_MINTEMP) / 2) return true; + #endif + #if HAS_HEATED_BED + if (degTargetBed() > BED_MINTEMP) return true; + #endif + #if HAS_HEATED_CHAMBER + if (degTargetChamber() > CHAMBER_MINTEMP) return true; + #endif + return false; + } + + void Temperature::check_timer_autostart(const bool can_start, const bool can_stop) { + if (over_autostart_threshold()) { + if (can_start) startOrResumeJob(); + } + else if (can_stop) { + print_job_timer.stop(); + ui.reset_status(); + } + } + +#endif + + #if ENABLED(PROBING_HEATERS_OFF) void Temperature::pause(const bool p) { @@ -2166,7 +2179,7 @@ void Temperature::disable_all_heaters() { #endif } else { - HOTEND_LOOP() reset_heater_idle_timer(e); + HOTEND_LOOP() reset_hotend_idle_timer(e); #if HAS_HEATED_BED reset_bed_idle_timer(); #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index da73ed37a4..a360394f24 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -228,15 +228,38 @@ typedef struct { inline void start(const millis_t &ms) { timeout_ms = millis() + ms; timed_out = false; } inline void reset() { timeout_ms = 0; timed_out = false; } inline void expire() { start(0); } -} heater_idle_t; +} hotend_idle_t; // Heater watch handling -typedef struct { +template +struct HeaterWatch { uint16_t target; millis_t next_ms; inline bool elapsed(const millis_t &ms) { return next_ms && ELAPSED(ms, next_ms); } inline bool elapsed() { return elapsed(millis()); } -} heater_watch_t; + + inline void restart(const int16_t curr, const int16_t tgt) { + if (tgt) { + const int16_t newtarget = curr + INCREASE; + if (newtarget < tgt - HYSTERESIS - 1) { + target = newtarget; + next_ms = millis() + PERIOD * 1000UL; + return; + } + } + next_ms = 0; + } +}; + +#if WATCH_HOTENDS + typedef struct HeaterWatch hotend_watch_t; +#endif +#if WATCH_BED + typedef struct HeaterWatch bed_watch_t; +#endif +#if WATCH_CHAMBER + typedef struct HeaterWatch chamber_watch_t; +#endif // Temperature sensor read value ranges typedef struct { int16_t raw_min, raw_max; } raw_range_t; @@ -345,12 +368,12 @@ class Temperature { FORCE_INLINE static bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); } #if HEATER_IDLE_HANDLER - static heater_idle_t hotend_idle[HOTENDS]; + static hotend_idle_t hotend_idle[HOTENDS]; #if HAS_HEATED_BED - static heater_idle_t bed_idle; + static hotend_idle_t bed_idle; #endif #if HAS_HEATED_CHAMBER - static heater_idle_t chamber_idle; + static hotend_idle_t chamber_idle; #endif #endif @@ -363,7 +386,7 @@ class Temperature { static volatile bool raw_temps_ready; #if WATCH_HOTENDS - static heater_watch_t watch_hotend[HOTENDS]; + static hotend_watch_t watch_hotend[HOTENDS]; #endif #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) @@ -382,7 +405,7 @@ class Temperature { #if HAS_HEATED_BED #if WATCH_BED - static heater_watch_t watch_bed; + static bed_watch_t watch_bed; #endif #if DISABLED(PIDTEMPBED) static millis_t next_bed_check_ms; @@ -397,7 +420,7 @@ class Temperature { #if HAS_HEATED_CHAMBER #if WATCH_CHAMBER - static heater_watch_t watch_chamber; + static chamber_watch_t watch_chamber; #endif static millis_t next_chamber_check_ms; #ifdef CHAMBER_MINTEMP @@ -736,6 +759,14 @@ class Temperature { */ static void disable_all_heaters(); + #if ENABLED(PRINTJOB_TIMER_AUTOSTART) + /** + * Methods to check if heaters are enabled, indicating an active job + */ + static bool over_autostart_threshold(); + static void check_timer_autostart(const bool can_start, const bool can_stop); + #endif + /** * Perform auto-tuning for hotend or bed in response to M303 */ @@ -768,7 +799,7 @@ class Temperature { #if HEATER_IDLE_HANDLER - static void reset_heater_idle_timer(const uint8_t E_NAME) { + static void reset_hotend_idle_timer(const uint8_t E_NAME) { hotend_idle[HOTEND_INDEX].reset(); start_watching_hotend(HOTEND_INDEX); } From 5b12627e146cc8b2a61d347ae6608b5c4d4497df Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 30 Jan 2020 03:24:57 -0600 Subject: [PATCH 15/23] Auto assign DIAG pins for multi-endstop (#16723) --- Marlin/src/core/macros.h | 23 +- Marlin/src/inc/Conditionals_post.h | 430 +++++++++++++++++--- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h | 58 ++- Marlin/src/pins/pins.h | 125 +++++- Marlin/src/pins/pinsDebug_list.h | 67 ++- 5 files changed, 604 insertions(+), 99 deletions(-) diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index f3c9f3a818..e83aa409b9 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -29,12 +29,23 @@ #define _AXIS(A) (A##_AXIS) -#define _XMIN_ 100 -#define _YMIN_ 200 -#define _ZMIN_ 300 -#define _XMAX_ 101 -#define _YMAX_ 201 -#define _ZMAX_ 301 +#define _XMIN_ 100 +#define _YMIN_ 200 +#define _ZMIN_ 300 +#define _XMAX_ 101 +#define _YMAX_ 201 +#define _ZMAX_ 301 +#define _XDIAG_ 102 +#define _YDIAG_ 202 +#define _ZDIAG_ 302 +#define _E0DIAG_ 400 +#define _E1DIAG_ 401 +#define _E2DIAG_ 402 +#define _E3DIAG_ 403 +#define _E4DIAG_ 404 +#define _E5DIAG_ 405 +#define _E6DIAG_ 406 +#define _E7DIAG_ 407 #define _FORCE_INLINE_ __attribute__((__always_inline__)) __inline__ #define FORCE_INLINE __attribute__((always_inline)) inline diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 5b9ba7c683..85d2557f93 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -679,48 +679,110 @@ #if X_HOME_DIR > 0 #if X2_USE_ENDSTOP == _XMIN_ #define X2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING - #define X2_MAX_PIN X_MIN_PIN #elif X2_USE_ENDSTOP == _XMAX_ #define X2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING - #define X2_MAX_PIN X_MAX_PIN #elif X2_USE_ENDSTOP == _YMIN_ #define X2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING - #define X2_MAX_PIN Y_MIN_PIN #elif X2_USE_ENDSTOP == _YMAX_ #define X2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING - #define X2_MAX_PIN Y_MAX_PIN #elif X2_USE_ENDSTOP == _ZMIN_ #define X2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING - #define X2_MAX_PIN Z_MIN_PIN #elif X2_USE_ENDSTOP == _ZMAX_ #define X2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #define X2_MAX_PIN Z_MAX_PIN #else #define X2_MAX_ENDSTOP_INVERTING false #endif + #ifndef X2_MAX_PIN + #if X2_USE_ENDSTOP == _XMIN_ + #define X2_MAX_PIN X_MIN_PIN + #elif X2_USE_ENDSTOP == _XMAX_ + #define X2_MAX_PIN X_MAX_PIN + #elif X2_USE_ENDSTOP == _YMIN_ + #define X2_MAX_PIN Y_MIN_PIN + #elif X2_USE_ENDSTOP == _YMAX_ + #define X2_MAX_PIN Y_MAX_PIN + #elif X2_USE_ENDSTOP == _ZMIN_ + #define X2_MAX_PIN Z_MIN_PIN + #elif X2_USE_ENDSTOP == _ZMAX_ + #define X2_MAX_PIN Z_MAX_PIN + #elif X2_USE_ENDSTOP == _XDIAG_ + #define X2_MAX_PIN X_DIAG_PIN + #elif X2_USE_ENDSTOP == _YDIAG_ + #define X2_MAX_PIN Y_DIAG_PIN + #elif X2_USE_ENDSTOP == _ZDIAG_ + #define X2_MAX_PIN Z_DIAG_PIN + #elif X2_USE_ENDSTOP == _E0DIAG_ + #define X2_MAX_PIN E0_DIAG_PIN + #elif X2_USE_ENDSTOP == _E1DIAG_ + #define X2_MAX_PIN E1_DIAG_PIN + #elif X2_USE_ENDSTOP == _E2DIAG_ + #define X2_MAX_PIN E2_DIAG_PIN + #elif X2_USE_ENDSTOP == _E3DIAG_ + #define X2_MAX_PIN E3_DIAG_PIN + #elif X2_USE_ENDSTOP == _E4DIAG_ + #define X2_MAX_PIN E4_DIAG_PIN + #elif X2_USE_ENDSTOP == _E5DIAG_ + #define X2_MAX_PIN E5_DIAG_PIN + #elif X2_USE_ENDSTOP == _E6DIAG_ + #define X2_MAX_PIN E6_DIAG_PIN + #elif X2_USE_ENDSTOP == _E7DIAG_ + #define X2_MAX_PIN E7_DIAG_PIN + #endif + #endif #define X2_MIN_ENDSTOP_INVERTING false #else #if X2_USE_ENDSTOP == _XMIN_ #define X2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING - #define X2_MIN_PIN X_MIN_PIN #elif X2_USE_ENDSTOP == _XMAX_ #define X2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING - #define X2_MIN_PIN X_MAX_PIN #elif X2_USE_ENDSTOP == _YMIN_ #define X2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING - #define X2_MIN_PIN Y_MIN_PIN #elif X2_USE_ENDSTOP == _YMAX_ #define X2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING - #define X2_MIN_PIN Y_MAX_PIN #elif X2_USE_ENDSTOP == _ZMIN_ #define X2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING - #define X2_MIN_PIN Z_MIN_PIN #elif X2_USE_ENDSTOP == _ZMAX_ #define X2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #define X2_MIN_PIN Z_MAX_PIN #else #define X2_MIN_ENDSTOP_INVERTING false #endif + #ifndef X2_MIN_PIN + #if X2_USE_ENDSTOP == _XMIN_ + #define X2_MIN_PIN X_MIN_PIN + #elif X2_USE_ENDSTOP == _XMAX_ + #define X2_MIN_PIN X_MAX_PIN + #elif X2_USE_ENDSTOP == _YMIN_ + #define X2_MIN_PIN Y_MIN_PIN + #elif X2_USE_ENDSTOP == _YMAX_ + #define X2_MIN_PIN Y_MAX_PIN + #elif X2_USE_ENDSTOP == _ZMIN_ + #define X2_MIN_PIN Z_MIN_PIN + #elif X2_USE_ENDSTOP == _ZMAX_ + #define X2_MIN_PIN Z_MAX_PIN + #elif X2_USE_ENDSTOP == _XDIAG_ + #define X2_MIN_PIN X_DIAG_PIN + #elif X2_USE_ENDSTOP == _YDIAG_ + #define X2_MIN_PIN Y_DIAG_PIN + #elif X2_USE_ENDSTOP == _ZDIAG_ + #define X2_MIN_PIN Z_DIAG_PIN + #elif X2_USE_ENDSTOP == _E0DIAG_ + #define X2_MIN_PIN E0_DIAG_PIN + #elif X2_USE_ENDSTOP == _E1DIAG_ + #define X2_MIN_PIN E1_DIAG_PIN + #elif X2_USE_ENDSTOP == _E2DIAG_ + #define X2_MIN_PIN E2_DIAG_PIN + #elif X2_USE_ENDSTOP == _E3DIAG_ + #define X2_MIN_PIN E3_DIAG_PIN + #elif X2_USE_ENDSTOP == _E4DIAG_ + #define X2_MIN_PIN E4_DIAG_PIN + #elif X2_USE_ENDSTOP == _E5DIAG_ + #define X2_MIN_PIN E5_DIAG_PIN + #elif X2_USE_ENDSTOP == _E6DIAG_ + #define X2_MIN_PIN E6_DIAG_PIN + #elif X2_USE_ENDSTOP == _E7DIAG_ + #define X2_MIN_PIN E7_DIAG_PIN + #endif + #endif #define X2_MAX_ENDSTOP_INVERTING false #endif #endif @@ -732,48 +794,110 @@ #if Y_HOME_DIR > 0 #if Y2_USE_ENDSTOP == _XMIN_ #define Y2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING - #define Y2_MAX_PIN X_MIN_PIN #elif Y2_USE_ENDSTOP == _XMAX_ #define Y2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING - #define Y2_MAX_PIN X_MAX_PIN #elif Y2_USE_ENDSTOP == _YMIN_ #define Y2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING - #define Y2_MAX_PIN Y_MIN_PIN #elif Y2_USE_ENDSTOP == _YMAX_ #define Y2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING - #define Y2_MAX_PIN Y_MAX_PIN #elif Y2_USE_ENDSTOP == _ZMIN_ #define Y2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING - #define Y2_MAX_PIN Z_MIN_PIN #elif Y2_USE_ENDSTOP == _ZMAX_ #define Y2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #define Y2_MAX_PIN Z_MAX_PIN #else #define Y2_MAX_ENDSTOP_INVERTING false #endif + #ifndef Y2_MAX_PIN + #if Y2_USE_ENDSTOP == _XMIN_ + #define Y2_MAX_PIN X_MIN_PIN + #elif Y2_USE_ENDSTOP == _XMAX_ + #define Y2_MAX_PIN X_MAX_PIN + #elif Y2_USE_ENDSTOP == _YMIN_ + #define Y2_MAX_PIN Y_MIN_PIN + #elif Y2_USE_ENDSTOP == _YMAX_ + #define Y2_MAX_PIN Y_MAX_PIN + #elif Y2_USE_ENDSTOP == _ZMIN_ + #define Y2_MAX_PIN Z_MIN_PIN + #elif Y2_USE_ENDSTOP == _ZMAX_ + #define Y2_MAX_PIN Z_MAX_PIN + #elif Y2_USE_ENDSTOP == _XDIAG_ + #define Y2_MAX_PIN X_DIAG_PIN + #elif Y2_USE_ENDSTOP == _YDIAG_ + #define Y2_MAX_PIN Y_DIAG_PIN + #elif Y2_USE_ENDSTOP == _ZDIAG_ + #define Y2_MAX_PIN Z_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E0DIAG_ + #define Y2_MAX_PIN E0_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E1DIAG_ + #define Y2_MAX_PIN E1_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E2DIAG_ + #define Y2_MAX_PIN E2_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E3DIAG_ + #define Y2_MAX_PIN E3_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E4DIAG_ + #define Y2_MAX_PIN E4_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E5DIAG_ + #define Y2_MAX_PIN E5_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E6DIAG_ + #define Y2_MAX_PIN E6_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E7DIAG_ + #define Y2_MAX_PIN E7_DIAG_PIN + #endif + #endif #define Y2_MIN_ENDSTOP_INVERTING false #else #if Y2_USE_ENDSTOP == _XMIN_ #define Y2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING - #define Y2_MIN_PIN X_MIN_PIN #elif Y2_USE_ENDSTOP == _XMAX_ #define Y2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING - #define Y2_MIN_PIN X_MAX_PIN #elif Y2_USE_ENDSTOP == _YMIN_ #define Y2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING - #define Y2_MIN_PIN Y_MIN_PIN #elif Y2_USE_ENDSTOP == _YMAX_ #define Y2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING - #define Y2_MIN_PIN Y_MAX_PIN #elif Y2_USE_ENDSTOP == _ZMIN_ #define Y2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING - #define Y2_MIN_PIN Z_MIN_PIN #elif Y2_USE_ENDSTOP == _ZMAX_ #define Y2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #define Y2_MIN_PIN Z_MAX_PIN #else #define Y2_MIN_ENDSTOP_INVERTING false #endif + #ifndef Y2_MIN_PIN + #if Y2_USE_ENDSTOP == _XMIN_ + #define Y2_MIN_PIN X_MIN_PIN + #elif Y2_USE_ENDSTOP == _XMAX_ + #define Y2_MIN_PIN X_MAX_PIN + #elif Y2_USE_ENDSTOP == _YMIN_ + #define Y2_MIN_PIN Y_MIN_PIN + #elif Y2_USE_ENDSTOP == _YMAX_ + #define Y2_MIN_PIN Y_MAX_PIN + #elif Y2_USE_ENDSTOP == _ZMIN_ + #define Y2_MIN_PIN Z_MIN_PIN + #elif Y2_USE_ENDSTOP == _ZMAX_ + #define Y2_MIN_PIN Z_MAX_PIN + #elif Y2_USE_ENDSTOP == _XDIAG_ + #define Y2_MIN_PIN X_DIAG_PIN + #elif Y2_USE_ENDSTOP == _YDIAG_ + #define Y2_MIN_PIN Y_DIAG_PIN + #elif Y2_USE_ENDSTOP == _ZDIAG_ + #define Y2_MIN_PIN Z_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E0DIAG_ + #define Y2_MIN_PIN E0_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E1DIAG_ + #define Y2_MIN_PIN E1_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E2DIAG_ + #define Y2_MIN_PIN E2_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E3DIAG_ + #define Y2_MIN_PIN E3_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E4DIAG_ + #define Y2_MIN_PIN E4_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E5DIAG_ + #define Y2_MIN_PIN E5_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E6DIAG_ + #define Y2_MIN_PIN E6_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E7DIAG_ + #define Y2_MIN_PIN E7_DIAG_PIN + #endif + #endif #define Y2_MAX_ENDSTOP_INVERTING false #endif #endif @@ -786,48 +910,110 @@ #if Z_HOME_DIR > 0 #if Z2_USE_ENDSTOP == _XMIN_ #define Z2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING - #define Z2_MAX_PIN X_MIN_PIN #elif Z2_USE_ENDSTOP == _XMAX_ #define Z2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING - #define Z2_MAX_PIN X_MAX_PIN #elif Z2_USE_ENDSTOP == _YMIN_ #define Z2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING - #define Z2_MAX_PIN Y_MIN_PIN #elif Z2_USE_ENDSTOP == _YMAX_ #define Z2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING - #define Z2_MAX_PIN Y_MAX_PIN #elif Z2_USE_ENDSTOP == _ZMIN_ #define Z2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING - #define Z2_MAX_PIN Z_MIN_PIN #elif Z2_USE_ENDSTOP == _ZMAX_ #define Z2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #define Z2_MAX_PIN Z_MAX_PIN #else #define Z2_MAX_ENDSTOP_INVERTING false #endif + #ifndef Z2_MAX_PIN + #if Z2_USE_ENDSTOP == _XMIN_ + #define Z2_MAX_PIN X_MIN_PIN + #elif Z2_USE_ENDSTOP == _XMAX_ + #define Z2_MAX_PIN X_MAX_PIN + #elif Z2_USE_ENDSTOP == _YMIN_ + #define Z2_MAX_PIN Y_MIN_PIN + #elif Z2_USE_ENDSTOP == _YMAX_ + #define Z2_MAX_PIN Y_MAX_PIN + #elif Z2_USE_ENDSTOP == _ZMIN_ + #define Z2_MAX_PIN Z_MIN_PIN + #elif Z2_USE_ENDSTOP == _ZMAX_ + #define Z2_MAX_PIN Z_MAX_PIN + #elif Z2_USE_ENDSTOP == _XDIAG_ + #define Z2_MAX_PIN X_DIAG_PIN + #elif Z2_USE_ENDSTOP == _YDIAG_ + #define Z2_MAX_PIN Y_DIAG_PIN + #elif Z2_USE_ENDSTOP == _ZDIAG_ + #define Z2_MAX_PIN Z_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E0DIAG_ + #define Z2_MAX_PIN E0_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E1DIAG_ + #define Z2_MAX_PIN E1_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E2DIAG_ + #define Z2_MAX_PIN E2_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E3DIAG_ + #define Z2_MAX_PIN E3_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E4DIAG_ + #define Z2_MAX_PIN E4_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E5DIAG_ + #define Z2_MAX_PIN E5_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E6DIAG_ + #define Z2_MAX_PIN E6_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E7DIAG_ + #define Z2_MAX_PIN E7_DIAG_PIN + #endif + #endif #define Z2_MIN_ENDSTOP_INVERTING false #else #if Z2_USE_ENDSTOP == _XMIN_ #define Z2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING - #define Z2_MIN_PIN X_MIN_PIN #elif Z2_USE_ENDSTOP == _XMAX_ #define Z2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING - #define Z2_MIN_PIN X_MAX_PIN #elif Z2_USE_ENDSTOP == _YMIN_ #define Z2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING - #define Z2_MIN_PIN Y_MIN_PIN #elif Z2_USE_ENDSTOP == _YMAX_ #define Z2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING - #define Z2_MIN_PIN Y_MAX_PIN #elif Z2_USE_ENDSTOP == _ZMIN_ #define Z2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING - #define Z2_MIN_PIN Z_MIN_PIN #elif Z2_USE_ENDSTOP == _ZMAX_ #define Z2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #define Z2_MIN_PIN Z_MAX_PIN #else #define Z2_MIN_ENDSTOP_INVERTING false #endif + #ifndef Z2_MIN_PIN + #if Z2_USE_ENDSTOP == _XMIN_ + #define Z2_MIN_PIN X_MIN_PIN + #elif Z2_USE_ENDSTOP == _XMAX_ + #define Z2_MIN_PIN X_MAX_PIN + #elif Z2_USE_ENDSTOP == _YMIN_ + #define Z2_MIN_PIN Y_MIN_PIN + #elif Z2_USE_ENDSTOP == _YMAX_ + #define Z2_MIN_PIN Y_MAX_PIN + #elif Z2_USE_ENDSTOP == _ZMIN_ + #define Z2_MIN_PIN Z_MIN_PIN + #elif Z2_USE_ENDSTOP == _ZMAX_ + #define Z2_MIN_PIN Z_MAX_PIN + #elif Z2_USE_ENDSTOP == _XDIAG_ + #define Z2_MIN_PIN X_DIAG_PIN + #elif Z2_USE_ENDSTOP == _YDIAG_ + #define Z2_MIN_PIN Y_DIAG_PIN + #elif Z2_USE_ENDSTOP == _ZDIAG_ + #define Z2_MIN_PIN Z_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E0DIAG_ + #define Z2_MIN_PIN E0_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E1DIAG_ + #define Z2_MIN_PIN E1_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E2DIAG_ + #define Z2_MIN_PIN E2_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E3DIAG_ + #define Z2_MIN_PIN E3_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E4DIAG_ + #define Z2_MIN_PIN E4_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E5DIAG_ + #define Z2_MIN_PIN E5_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E6DIAG_ + #define Z2_MIN_PIN E6_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E7DIAG_ + #define Z2_MIN_PIN E7_DIAG_PIN + #endif + #endif #define Z2_MAX_ENDSTOP_INVERTING false #endif @@ -835,48 +1021,110 @@ #if Z_HOME_DIR > 0 #if Z3_USE_ENDSTOP == _XMIN_ #define Z3_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING - #define Z3_MAX_PIN X_MIN_PIN #elif Z3_USE_ENDSTOP == _XMAX_ #define Z3_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING - #define Z3_MAX_PIN X_MAX_PIN #elif Z3_USE_ENDSTOP == _YMIN_ #define Z3_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING - #define Z3_MAX_PIN Y_MIN_PIN #elif Z3_USE_ENDSTOP == _YMAX_ #define Z3_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING - #define Z3_MAX_PIN Y_MAX_PIN #elif Z3_USE_ENDSTOP == _ZMIN_ #define Z3_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING - #define Z3_MAX_PIN Z_MIN_PIN #elif Z3_USE_ENDSTOP == _ZMAX_ #define Z3_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #define Z3_MAX_PIN Z_MAX_PIN #else #define Z3_MAX_ENDSTOP_INVERTING false #endif + #ifndef Z3_MAX_PIN + #if Z3_USE_ENDSTOP == _XMIN_ + #define Z3_MAX_PIN X_MIN_PIN + #elif Z3_USE_ENDSTOP == _XMAX_ + #define Z3_MAX_PIN X_MAX_PIN + #elif Z3_USE_ENDSTOP == _YMIN_ + #define Z3_MAX_PIN Y_MIN_PIN + #elif Z3_USE_ENDSTOP == _YMAX_ + #define Z3_MAX_PIN Y_MAX_PIN + #elif Z3_USE_ENDSTOP == _ZMIN_ + #define Z3_MAX_PIN Z_MIN_PIN + #elif Z3_USE_ENDSTOP == _ZMAX_ + #define Z3_MAX_PIN Z_MAX_PIN + #elif Z3_USE_ENDSTOP == _XDIAG_ + #define Z3_MAX_PIN X_DIAG_PIN + #elif Z3_USE_ENDSTOP == _YDIAG_ + #define Z3_MAX_PIN Y_DIAG_PIN + #elif Z3_USE_ENDSTOP == _ZDIAG_ + #define Z3_MAX_PIN Z_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E0DIAG_ + #define Z3_MAX_PIN E0_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E1DIAG_ + #define Z3_MAX_PIN E1_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E2DIAG_ + #define Z3_MAX_PIN E2_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E3DIAG_ + #define Z3_MAX_PIN E3_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E4DIAG_ + #define Z3_MAX_PIN E4_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E5DIAG_ + #define Z3_MAX_PIN E5_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E6DIAG_ + #define Z3_MAX_PIN E6_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E7DIAG_ + #define Z3_MAX_PIN E7_DIAG_PIN + #endif + #endif #define Z3_MIN_ENDSTOP_INVERTING false #else #if Z3_USE_ENDSTOP == _XMIN_ #define Z3_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING - #define Z3_MIN_PIN X_MIN_PIN #elif Z3_USE_ENDSTOP == _XMAX_ #define Z3_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING - #define Z3_MIN_PIN X_MAX_PIN #elif Z3_USE_ENDSTOP == _YMIN_ #define Z3_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING - #define Z3_MIN_PIN Y_MIN_PIN #elif Z3_USE_ENDSTOP == _YMAX_ #define Z3_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING - #define Z3_MIN_PIN Y_MAX_PIN #elif Z3_USE_ENDSTOP == _ZMIN_ #define Z3_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING - #define Z3_MIN_PIN Z_MIN_PIN #elif Z3_USE_ENDSTOP == _ZMAX_ #define Z3_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #define Z3_MIN_PIN Z_MAX_PIN #else #define Z3_MIN_ENDSTOP_INVERTING false #endif + #ifndef Z3_MIN_PIN + #if Z3_USE_ENDSTOP == _XMIN_ + #define Z3_MIN_PIN X_MIN_PIN + #elif Z3_USE_ENDSTOP == _XMAX_ + #define Z3_MIN_PIN X_MAX_PIN + #elif Z3_USE_ENDSTOP == _YMIN_ + #define Z3_MIN_PIN Y_MIN_PIN + #elif Z3_USE_ENDSTOP == _YMAX_ + #define Z3_MIN_PIN Y_MAX_PIN + #elif Z3_USE_ENDSTOP == _ZMIN_ + #define Z3_MIN_PIN Z_MIN_PIN + #elif Z3_USE_ENDSTOP == _ZMAX_ + #define Z3_MIN_PIN Z_MAX_PIN + #elif Z3_USE_ENDSTOP == _XDIAG_ + #define Z3_MIN_PIN X_DIAG_PIN + #elif Z3_USE_ENDSTOP == _YDIAG_ + #define Z3_MIN_PIN Y_DIAG_PIN + #elif Z3_USE_ENDSTOP == _ZDIAG_ + #define Z3_MIN_PIN Z_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E0DIAG_ + #define Z3_MIN_PIN E0_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E1DIAG_ + #define Z3_MIN_PIN E1_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E2DIAG_ + #define Z3_MIN_PIN E2_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E3DIAG_ + #define Z3_MIN_PIN E3_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E4DIAG_ + #define Z3_MIN_PIN E4_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E5DIAG_ + #define Z3_MIN_PIN E5_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E6DIAG_ + #define Z3_MIN_PIN E6_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E7DIAG_ + #define Z3_MIN_PIN E7_DIAG_PIN + #endif + #endif #define Z3_MAX_ENDSTOP_INVERTING false #endif #endif @@ -885,48 +1133,110 @@ #if Z_HOME_DIR > 0 #if Z4_USE_ENDSTOP == _XMIN_ #define Z4_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING - #define Z4_MAX_PIN X_MIN_PIN #elif Z4_USE_ENDSTOP == _XMAX_ #define Z4_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING - #define Z4_MAX_PIN X_MAX_PIN #elif Z4_USE_ENDSTOP == _YMIN_ #define Z4_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING - #define Z4_MAX_PIN Y_MIN_PIN #elif Z4_USE_ENDSTOP == _YMAX_ #define Z4_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING - #define Z4_MAX_PIN Y_MAX_PIN #elif Z4_USE_ENDSTOP == _ZMIN_ #define Z4_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING - #define Z4_MAX_PIN Z_MIN_PIN #elif Z4_USE_ENDSTOP == _ZMAX_ #define Z4_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #define Z4_MAX_PIN Z_MAX_PIN #else #define Z4_MAX_ENDSTOP_INVERTING false #endif + #ifndef Z4_MAX_PIN + #if Z4_USE_ENDSTOP == _XMIN_ + #define Z4_MAX_PIN X_MIN_PIN + #elif Z4_USE_ENDSTOP == _XMAX_ + #define Z4_MAX_PIN X_MAX_PIN + #elif Z4_USE_ENDSTOP == _YMIN_ + #define Z4_MAX_PIN Y_MIN_PIN + #elif Z4_USE_ENDSTOP == _YMAX_ + #define Z4_MAX_PIN Y_MAX_PIN + #elif Z4_USE_ENDSTOP == _ZMIN_ + #define Z4_MAX_PIN Z_MIN_PIN + #elif Z4_USE_ENDSTOP == _ZMAX_ + #define Z4_MAX_PIN Z_MAX_PIN + #elif Z4_USE_ENDSTOP == _XDIAG_ + #define Z4_MAX_PIN X_DIAG_PIN + #elif Z4_USE_ENDSTOP == _YDIAG_ + #define Z4_MAX_PIN Y_DIAG_PIN + #elif Z4_USE_ENDSTOP == _ZDIAG_ + #define Z4_MAX_PIN Z_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E0DIAG_ + #define Z4_MAX_PIN E0_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E1DIAG_ + #define Z4_MAX_PIN E1_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E2DIAG_ + #define Z4_MAX_PIN E2_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E3DIAG_ + #define Z4_MAX_PIN E3_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E4DIAG_ + #define Z4_MAX_PIN E4_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E5DIAG_ + #define Z4_MAX_PIN E5_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E6DIAG_ + #define Z4_MAX_PIN E6_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E7DIAG_ + #define Z4_MAX_PIN E7_DIAG_PIN + #endif + #endif #define Z4_MIN_ENDSTOP_INVERTING false #else #if Z4_USE_ENDSTOP == _XMIN_ #define Z4_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING - #define Z4_MIN_PIN X_MIN_PIN #elif Z4_USE_ENDSTOP == _XMAX_ #define Z4_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING - #define Z4_MIN_PIN X_MAX_PIN #elif Z4_USE_ENDSTOP == _YMIN_ #define Z4_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING - #define Z4_MIN_PIN Y_MIN_PIN #elif Z4_USE_ENDSTOP == _YMAX_ #define Z4_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING - #define Z4_MIN_PIN Y_MAX_PIN #elif Z4_USE_ENDSTOP == _ZMIN_ #define Z4_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING - #define Z4_MIN_PIN Z_MIN_PIN #elif Z4_USE_ENDSTOP == _ZMAX_ #define Z4_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #define Z4_MIN_PIN Z_MAX_PIN #else #define Z4_MIN_ENDSTOP_INVERTING false #endif + #ifndef Z4_MIN_PIN + #if Z4_USE_ENDSTOP == _XMIN_ + #define Z4_MIN_PIN X_MIN_PIN + #elif Z4_USE_ENDSTOP == _XMAX_ + #define Z4_MIN_PIN X_MAX_PIN + #elif Z4_USE_ENDSTOP == _YMIN_ + #define Z4_MIN_PIN Y_MIN_PIN + #elif Z4_USE_ENDSTOP == _YMAX_ + #define Z4_MIN_PIN Y_MAX_PIN + #elif Z4_USE_ENDSTOP == _ZMIN_ + #define Z4_MIN_PIN Z_MIN_PIN + #elif Z4_USE_ENDSTOP == _ZMAX_ + #define Z4_MIN_PIN Z_MAX_PIN + #elif Z4_USE_ENDSTOP == _XDIAG_ + #define Z4_MIN_PIN X_DIAG_PIN + #elif Z4_USE_ENDSTOP == _YDIAG_ + #define Z4_MIN_PIN Y_DIAG_PIN + #elif Z4_USE_ENDSTOP == _ZDIAG_ + #define Z4_MIN_PIN Z_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E0DIAG_ + #define Z4_MIN_PIN E0_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E1DIAG_ + #define Z4_MIN_PIN E1_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E2DIAG_ + #define Z4_MIN_PIN E2_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E3DIAG_ + #define Z4_MIN_PIN E3_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E4DIAG_ + #define Z4_MIN_PIN E4_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E5DIAG_ + #define Z4_MIN_PIN E5_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E6DIAG_ + #define Z4_MIN_PIN E6_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E7DIAG_ + #define Z4_MIN_PIN E7_DIAG_PIN + #endif + #endif #define Z4_MAX_ENDSTOP_INVERTING false #endif #endif 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 7f74456a48..2b6595cd74 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -23,33 +23,55 @@ #define BOARD_INFO_NAME "BIGTREE SKR 1.3" +/** + * Trinamic Stallguard pins + */ +#define X_DIAG_PIN P1_29 // X- +#define Y_DIAG_PIN P1_27 // Y- +#define Z_DIAG_PIN P1_25 // Z- +#define E0_DIAG_PIN P1_28 // X+ +#define E1_DIAG_PIN P1_26 // Y+ + /** * Limit Switches */ -#if X_HOME_DIR > 0 && X_STALL_SENSITIVITY && !defined(USE_XMAX_PLUG) - // For StallGuard homing to MAX swap the MIN / MAX pins - // so the MAX physical connectors may be used for other things. - #define X_MIN_PIN P1_28 // X_MAX (free) - #define X_MAX_PIN P1_29 // X_MIN -#else // else, non-endstop is free and appears in M43 output - #define X_MIN_PIN P1_29 // X_MIN - #define X_MAX_PIN P1_28 // X_MAX +#if X_STALL_SENSITIVITY + #if X_HOME_DIR < 0 + #define X_MIN_PIN X_DIAG_PIN + #define X_MAX_PIN P1_28 // X+ + #else + #define X_MAX_PIN X_DIAG_PIN + #define X_MIN_PIN P1_28 // X+ + #endif +#else + #define X_MIN_PIN P1_29 // X- + #define X_MAX_PIN P1_28 // X+ #endif -#if Y_HOME_DIR > 0 && Y_STALL_SENSITIVITY && !defined(USE_YMAX_PLUG) - #define Y_MIN_PIN P1_26 // Y_MAX (free) - #define Y_MAX_PIN P1_27 // Y_MIN +#if Y_STALL_SENSITIVITY + #if Y_HOME_DIR < 0 + #define Y_MIN_PIN Y_DIAG_PIN + #define Y_MAX_PIN P1_26 // Y+ + #else + #define Y_MAX_PIN Y_DIAG_PIN + #define Y_MIN_PIN P1_26 // Y+ + #endif #else - #define Y_MIN_PIN P1_27 // Y_MIN - #define Y_MAX_PIN P1_26 // Y_MAX + #define Y_MIN_PIN P1_27 // Y- + #define Y_MAX_PIN P1_26 // Y+ #endif -#if Z_HOME_DIR > 0 && Z_STALL_SENSITIVITY && !defined(USE_ZMAX_PLUG) - #define Z_MIN_PIN P1_24 // Z_MAX (free) - #define Z_MAX_PIN P1_25 // Z_MIN +#if Z_STALL_SENSITIVITY + #if Z_HOME_DIR < 0 + #define Z_MIN_PIN Z_DIAG_PIN + #define Z_MAX_PIN P1_24 // Z+ + #else + #define Z_MAX_PIN Z_DIAG_PIN + #define Z_MIN_PIN P1_24 // Z+ + #endif #else - #define Z_MIN_PIN P1_25 // Z_MIN - #define Z_MAX_PIN P1_24 // Z_MAX + #define Z_MIN_PIN P1_25 // Z- + #define Z_MAX_PIN P1_24 // Z+ #endif #define ONBOARD_ENDSTOPPULLUPS // Board has built-in pullups diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 3dbbb5e724..736dbdace0 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -1129,40 +1129,66 @@ #define __EPIN(p,q) E##p##_##q##_PIN #define _EPIN(p,q) __EPIN(p,q) +#define DIAG_REMAPPED(P,Q) (PIN_EXISTS(Q) && (P##_DIAG_PIN == Q##_PIN)) // The X2 axis, if any, should be the next open extruder port +#define X2_E_INDEX E_STEPPERS + #if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS) #ifndef X2_STEP_PIN - #define X2_STEP_PIN _EPIN(E_STEPPERS, STEP) - #define X2_DIR_PIN _EPIN(E_STEPPERS, DIR) - #define X2_ENABLE_PIN _EPIN(E_STEPPERS, ENABLE) - #if E_STEPPERS >= MAX_EXTRUDERS || !PIN_EXISTS(X2_STEP) + #define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP) + #define X2_DIR_PIN _EPIN(X2_E_INDEX, DIR) + #define X2_ENABLE_PIN _EPIN(X2_E_INDEX, ENABLE) + #if X2_E_INDEX >= MAX_EXTRUDERS || !PIN_EXISTS(X2_STEP) #error "No E stepper plug left for X2!" #endif #endif #ifndef X2_MS1_PIN - #define X2_MS1_PIN _EPIN(E_STEPPERS, MS1) + #define X2_MS1_PIN _EPIN(X2_E_INDEX, MS1) #endif #ifndef X2_MS2_PIN - #define X2_MS2_PIN _EPIN(E_STEPPERS, MS2) + #define X2_MS2_PIN _EPIN(X2_E_INDEX, MS2) #endif #ifndef X2_MS3_PIN - #define X2_MS3_PIN _EPIN(E_STEPPERS, MS3) + #define X2_MS3_PIN _EPIN(X2_E_INDEX, MS3) #endif #if AXIS_HAS_SPI(X2) && !defined(X2_CS_PIN) - #define X2_CS_PIN _EPIN(E_STEPPERS, CS) + #define X2_CS_PIN _EPIN(X2_E_INDEX, CS) #endif #if AXIS_HAS_UART(X2) #ifndef X2_SERIAL_TX_PIN - #define X2_SERIAL_TX_PIN _EPIN(E_STEPPERS, SERIAL_TX) + #define X2_SERIAL_TX_PIN _EPIN(X2_E_INDEX, SERIAL_TX) #endif #ifndef X2_SERIAL_RX_PIN - #define X2_SERIAL_RX_PIN _EPIN(E_STEPPERS, SERIAL_RX) + #define X2_SERIAL_RX_PIN _EPIN(X2_E_INDEX, SERIAL_RX) #endif #endif - #define Y2_E_INDEX INCREMENT(E_STEPPERS) + + // + // Auto-assign pins for stallGuard sensorless homing + // + #if X2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(X2_E_INDEX, DIAG) > 0 + #if DIAG_REMAPPED(X2, X_MIN) // If already remapped in the pins file... + #define X2_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(X2, Y_MIN) + #define X2_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(X2, Z_MIN) + #define X2_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(X2, X_MAX) + #define X2_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(X2, Y_MAX) + #define X2_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(X2, Z_MAX) + #define X2_USE_ENDSTOP _ZMAX_ + #else // Otherwise use the driver DIAG_PIN directly + #define _X2_USE_ENDSTOP(P) _E##P##_DIAG_ + #define X2_USE_ENDSTOP _X2_USE_ENDSTOP(X2_E_INDEX) + #endif + #endif + + #define Y2_E_INDEX INCREMENT(X2_E_INDEX) #else - #define Y2_E_INDEX E_STEPPERS + #define Y2_E_INDEX X2_E_INDEX #endif #ifndef X2_CS_PIN @@ -1208,6 +1234,24 @@ #define Y2_SERIAL_RX_PIN _EPIN(Y2_E_INDEX, SERIAL_RX) #endif #endif + #if Y2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Y2_E_INDEX, DIAG) > 0 + #if DIAG_REMAPPED(Y2, X_MIN) + #define Y2_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(Y2, Y_MIN) + #define Y2_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(Y2, Z_MIN) + #define Y2_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(Y2, X_MAX) + #define Y2_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(Y2, Y_MAX) + #define Y2_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(Y2, Z_MAX) + #define Y2_USE_ENDSTOP _ZMAX_ + #else + #define _Y2_USE_ENDSTOP(P) _E##P##_DIAG_ + #define Y2_USE_ENDSTOP _Y2_USE_ENDSTOP(Y2_E_INDEX) + #endif + #endif #define Z2_E_INDEX INCREMENT(Y2_E_INDEX) #else #define Z2_E_INDEX Y2_E_INDEX @@ -1256,6 +1300,24 @@ #define Z2_SERIAL_RX_PIN _EPIN(Z2_E_INDEX, SERIAL_RX) #endif #endif + #if Z2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Z2_E_INDEX, DIAG) > 0 + #if DIAG_REMAPPED(Z2, X_MIN) + #define Z2_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(Z2, Y_MIN) + #define Z2_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(Z2, Z_MIN) + #define Z2_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(Z2, X_MAX) + #define Z2_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(Z2, Y_MAX) + #define Z2_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(Z2, Z_MAX) + #define Z2_USE_ENDSTOP _ZMAX_ + #else + #define _Z2_USE_ENDSTOP(P) _E##P##_DIAG_ + #define Z2_USE_ENDSTOP _Z2_USE_ENDSTOP(Z2_E_INDEX) + #endif + #endif #define Z3_E_INDEX INCREMENT(Z2_E_INDEX) #else #define Z3_E_INDEX Z2_E_INDEX @@ -1285,7 +1347,7 @@ #endif #if AXIS_HAS_SPI(Z3) #ifndef Z3_CS_PIN - #define Z3_CS_PIN _EPIN(Z3_E_INDEX, CS) + #define Z3_CS_PIN _EPIN(Z3_E_INDEX, CS) #endif #endif #ifndef Z3_MS1_PIN @@ -1305,6 +1367,24 @@ #define Z3_SERIAL_RX_PIN _EPIN(Z3_E_INDEX, SERIAL_RX) #endif #endif + #if Z3_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Z3_E_INDEX, DIAG) > 0 + #if DIAG_REMAPPED(Z3, X_MIN) + #define Z3_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(Z3, Y_MIN) + #define Z3_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(Z3, Z_MIN) + #define Z3_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(Z3, X_MAX) + #define Z3_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(Z3, Y_MAX) + #define Z3_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(Z3, Z_MAX) + #define Z3_USE_ENDSTOP _ZMAX_ + #else + #define _Z3_USE_ENDSTOP(P) _E##P##_DIAG_ + #define Z3_USE_ENDSTOP _Y2_USE_ENDSTOP(Y2_E_INDEX) + #endif + #endif #define Z4_E_INDEX INCREMENT(Z3_E_INDEX) #endif @@ -1352,6 +1432,24 @@ #define Z4_SERIAL_RX_PIN _EPIN(Z4_E_INDEX, SERIAL_RX) #endif #endif + #if Z4_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Z4_E_INDEX, DIAG) > 0 + #if DIAG_REMAPPED(Z4, X_MIN) + #define Z4_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(Z4, Y_MIN) + #define Z4_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(Z4, Z_MIN) + #define Z4_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(Z4, X_MAX) + #define Z4_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(Z4, Y_MAX) + #define Z4_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(Z4, Z_MAX) + #define Z4_USE_ENDSTOP _ZMAX_ + #else + #define _Z4_USE_ENDSTOP(P) _E##P##_DIAG_ + #define Z4_USE_ENDSTOP _Z4_USE_ENDSTOP(Z4_E_INDEX) + #endif + #endif #endif #ifndef Z4_CS_PIN @@ -1384,3 +1482,4 @@ #endif #undef HAS_FREE_AUX2_PINS +#undef DIAG_REMAPPED diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index ca8c3f9a99..acd74767a3 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -1323,6 +1323,9 @@ #if PIN_EXISTS(X_MIN) REPORT_NAME_DIGITAL(__LINE__, X_MIN_PIN) #endif +#if PIN_EXISTS(X_DIAG) + REPORT_NAME_DIGITAL(__LINE__, X_DIAG_PIN) +#endif #if PIN_EXISTS(X_MS1) REPORT_NAME_DIGITAL(__LINE__, X_MS1_PIN) #endif @@ -1344,6 +1347,12 @@ #if PIN_EXISTS(X2_ENABLE) REPORT_NAME_DIGITAL(__LINE__, X2_ENABLE_PIN) #endif +#if PIN_EXISTS(X2_MAX) + REPORT_NAME_DIGITAL(__LINE__, X2_MAX_PIN) +#endif +#if PIN_EXISTS(X2_MIN) + REPORT_NAME_DIGITAL(__LINE__, X2_MIN_PIN) +#endif #if PIN_EXISTS(X2_MS1) REPORT_NAME_DIGITAL(__LINE__, X2_MS1_PIN) #endif @@ -1374,6 +1383,9 @@ #if PIN_EXISTS(Y_MIN) REPORT_NAME_DIGITAL(__LINE__, Y_MIN_PIN) #endif +#if PIN_EXISTS(Y_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Y_DIAG_PIN) +#endif #if PIN_EXISTS(Y_MS1) REPORT_NAME_DIGITAL(__LINE__, Y_MS1_PIN) #endif @@ -1395,6 +1407,12 @@ #if PIN_EXISTS(Y2_ENABLE) REPORT_NAME_DIGITAL(__LINE__, Y2_ENABLE_PIN) #endif +#if PIN_EXISTS(Y2_MAX) + REPORT_NAME_DIGITAL(__LINE__, Y2_MAX_PIN) +#endif +#if PIN_EXISTS(Y2_MIN) + REPORT_NAME_DIGITAL(__LINE__, Y2_MIN_PIN) +#endif #if PIN_EXISTS(Y2_MS1) REPORT_NAME_DIGITAL(__LINE__, Y2_MS1_PIN) #endif @@ -1425,8 +1443,8 @@ #if PIN_EXISTS(Z_MIN) REPORT_NAME_DIGITAL(__LINE__, Z_MIN_PIN) #endif -#if PIN_EXISTS(Z_MIN_PROBE) - REPORT_NAME_DIGITAL(__LINE__, Z_MIN_PROBE_PIN) +#if PIN_EXISTS(Z_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Z_DIAG_PIN) #endif #if PIN_EXISTS(Z_MS1) REPORT_NAME_DIGITAL(__LINE__, Z_MS1_PIN) @@ -1452,6 +1470,12 @@ #if PIN_EXISTS(Z2_ENABLE) REPORT_NAME_DIGITAL(__LINE__, Z2_ENABLE_PIN) #endif +#if PIN_EXISTS(Z2_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z2_MAX_PIN) +#endif +#if PIN_EXISTS(Z2_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z2_MIN_PIN) +#endif #if PIN_EXISTS(Z2_MS1) REPORT_NAME_DIGITAL(__LINE__, Z2_MS1_PIN) #endif @@ -1473,6 +1497,12 @@ #if PIN_EXISTS(Z3_ENABLE) REPORT_NAME_DIGITAL(__LINE__, Z3_ENABLE_PIN) #endif +#if PIN_EXISTS(Z3_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z3_MAX_PIN) +#endif +#if PIN_EXISTS(Z3_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z3_MIN_PIN) +#endif #if PIN_EXISTS(Z3_MS1) REPORT_NAME_DIGITAL(__LINE__, Z3_MS1_PIN) #endif @@ -1494,6 +1524,12 @@ #if PIN_EXISTS(Z4_ENABLE) REPORT_NAME_DIGITAL(__LINE__, Z4_ENABLE_PIN) #endif +#if PIN_EXISTS(Z4_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z4_MAX_PIN) +#endif +#if PIN_EXISTS(Z4_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z4_MIN_PIN) +#endif #if PIN_EXISTS(Z4_MS1) REPORT_NAME_DIGITAL(__LINE__, Z4_MS1_PIN) #endif @@ -1506,6 +1542,9 @@ #if PIN_EXISTS(Z4_STEP) REPORT_NAME_DIGITAL(__LINE__, Z4_STEP_PIN) #endif +#if PIN_EXISTS(Z_MIN_PROBE) + REPORT_NAME_DIGITAL(__LINE__, Z_MIN_PROBE_PIN) +#endif #if PIN_EXISTS(ZRIB_V20_D6) REPORT_NAME_DIGITAL(__LINE__, ZRIB_V20_D6_PIN) #endif @@ -1560,48 +1599,72 @@ #if PIN_EXISTS(Z4_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, Z4_SERIAL_RX_PIN) #endif +#if PIN_EXISTS(E0_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E0_DIAG_PIN) +#endif #if PIN_EXISTS(E0_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E0_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E0_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E0_SERIAL_RX_PIN) #endif +#if PIN_EXISTS(E1_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E1_DIAG_PIN) +#endif #if PIN_EXISTS(E1_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E1_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E1_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E1_SERIAL_RX_PIN) #endif +#if PIN_EXISTS(E2_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E2_DIAG_PIN) +#endif #if PIN_EXISTS(E2_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E2_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E2_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E2_SERIAL_RX_PIN) #endif +#if PIN_EXISTS(E3_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E3_DIAG_PIN) +#endif #if PIN_EXISTS(E3_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E3_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E3_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E3_SERIAL_RX_PIN) #endif +#if PIN_EXISTS(E4_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E4_DIAG_PIN) +#endif #if PIN_EXISTS(E4_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E4_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E4_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E4_SERIAL_RX_PIN) #endif +#if PIN_EXISTS(E5_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E5_DIAG_PIN) +#endif #if PIN_EXISTS(E5_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E5_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E5_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E5_SERIAL_RX_PIN) #endif +#if PIN_EXISTS(E6_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E6_DIAG_PIN) +#endif #if PIN_EXISTS(E6_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E6_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E6_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E6_SERIAL_RX_PIN) #endif +#if PIN_EXISTS(E7_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E7_DIAG_PIN) +#endif #if PIN_EXISTS(E7_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E7_SERIAL_TX_PIN) #endif From 3c9464eea4765a8635917049e704d5d37c6721fd Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 30 Jan 2020 03:21:37 -0600 Subject: [PATCH 16/23] Tweak G60/G61 slots --- Marlin/src/gcode/feature/pause/G60.cpp | 2 +- Marlin/src/gcode/feature/pause/G61.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/feature/pause/G60.cpp b/Marlin/src/gcode/feature/pause/G60.cpp index a0d099ad69..50db01d73c 100644 --- a/Marlin/src/gcode/feature/pause/G60.cpp +++ b/Marlin/src/gcode/feature/pause/G60.cpp @@ -45,7 +45,7 @@ void GcodeSuite::G60() { } stored_position[slot] = current_position; - SBI(saved_slots[slot >> 3], slot & 0b00000111); + SBI(saved_slots[slot >> 3], slot & 0x07); #if ENABLED(SAVED_POSITIONS_DEBUG) const xyze_pos_t &pos = stored_position[slot]; diff --git a/Marlin/src/gcode/feature/pause/G61.cpp b/Marlin/src/gcode/feature/pause/G61.cpp index d531c15c80..df6345df0f 100644 --- a/Marlin/src/gcode/feature/pause/G61.cpp +++ b/Marlin/src/gcode/feature/pause/G61.cpp @@ -48,7 +48,7 @@ void GcodeSuite::G61(void) { #endif // No saved position? No axes being restored? - if (!TEST(saved_slots[slot >> 3], slot & 0b00000111) || !parser.seen("XYZ")) return; + if (!TEST(saved_slots[slot >> 3], slot & 0x07) || !parser.seen("XYZ")) return; // Apply any given feedrate over 0.0 const float fr = parser.linearval('F'); From 8d4dd88bf918db66bd611fa0977322d715baffdd Mon Sep 17 00:00:00 2001 From: felixstorm Date: Thu, 30 Jan 2020 19:22:42 +0100 Subject: [PATCH 17/23] Fix compile error in SdVolume on ESP32 (#16728) --- Marlin/src/sd/SdVolume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/sd/SdVolume.cpp b/Marlin/src/sd/SdVolume.cpp index c51e42108c..70dfa52e30 100644 --- a/Marlin/src/sd/SdVolume.cpp +++ b/Marlin/src/sd/SdVolume.cpp @@ -296,7 +296,7 @@ int32_t SdVolume::freeClusterCount() { // block for 10+ seconds. yield() is insufficient since it blocks lower prio tasks (e.g., idle). static millis_t nextTaskTime = 0; const millis_t ms = millis(); - if (ELAPSED(ms, nextTaskTime) { + if (ELAPSED(ms, nextTaskTime)) { vTaskDelay(1); // delay 1 tick (Minimum. Usually 10 or 1 ms depending on skdconfig.h) nextTaskTime = ms + 1000; // tickle the task manager again in 1 second } From c45d6b2017fa45cbb0f417dc6aaf06828b2b4671 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilenko Date: Thu, 30 Jan 2020 21:29:30 +0300 Subject: [PATCH 18/23] Simultaneous use of rotary encoder and touch buttons (#16729) --- Marlin/src/lcd/ultralcd.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 04ebd5079f..35366d761c 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -777,13 +777,12 @@ void MarlinUI::update() { static bool wait_for_unclick; // = false #if ENABLED(TOUCH_BUTTONS) - if (touch_buttons) { RESET_STATUS_TIMEOUT(); - if (buttons & (EN_A | EN_B)) { // Menu arrows, in priority + if (touch_buttons & (EN_A | EN_B)) { // Menu arrows, in priority if (ELAPSED(ms, next_button_update_ms)) { encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * (ENCODER_PULSES_PER_STEP) * encoderDirection; - if (buttons & EN_A) encoderDiff *= -1; + if (touch_buttons & EN_A) encoderDiff *= -1; #if ENABLED(AUTO_BED_LEVELING_UBL) if (external_control) ubl.encoder_diff = encoderDiff; #endif @@ -1246,7 +1245,11 @@ void MarlinUI::update() { | slow_buttons #endif #if ENABLED(TOUCH_BUTTONS) && HAS_ENCODER_ACTION - | touch_buttons + | (touch_buttons + #if HAS_ENCODER_WHEEL + & (~(EN_A | EN_B)) + #endif + ) #endif ); @@ -1277,7 +1280,7 @@ void MarlinUI::update() { } // next_button_update_ms - #if HAS_ENCODER_WHEEL && DISABLED(TOUCH_BUTTONS) + #if HAS_ENCODER_WHEEL static uint8_t lastEncoderBits; #define encrot0 0 From 2822c0890a041038b9a32eeff5212cbc709a347d Mon Sep 17 00:00:00 2001 From: Robert Stein Date: Thu, 30 Jan 2020 20:17:15 +0100 Subject: [PATCH 19/23] Set up DIAG endstops for BTT SKR 1.4 / 1.4 Turbo (#16727) --- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 55 ++++++++++++++++++--- 1 file changed, 48 insertions(+), 7 deletions(-) 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 8e2a0cec23..90b5edca88 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -37,12 +37,53 @@ // #define SERVO0_PIN P2_00 +// +// TMC StallGuard DIAG pins +// +#define X_DIAG_PIN P1_29 // X-STOP +#define Y_DIAG_PIN P1_28 // Y-STOP +#define Z_DIAG_PIN P1_27 // Z-STOP +#define E0_DIAG_PIN P1_26 // E0DET +#define E1_DIAG_PIN P1_25 // E1DET + // // Limit Switches // -#define X_STOP_PIN P1_29 -#define Y_STOP_PIN P1_28 -#define Z_STOP_PIN P1_27 +#if X_STALL_SENSITIVITY + #if X_HOME_DIR < 0 + #define X_MIN_PIN X_DIAG_PIN + #define X_MAX_PIN P1_26 // E0DET + #else + #define X_MAX_PIN X_DIAG_PIN + #define X_MIN_PIN P1_26 // E0DET + #endif +#else + #define X_STOP_PIN P1_29 // X-STOP +#endif + +#if Y_STALL_SENSITIVITY + #if Y_HOME_DIR < 0 + #define Y_MIN_PIN Y_DIAG_PIN + #define Y_MAX_PIN P1_25 // E1DET + #else + #define Y_MAX_PIN Y_DIAG_PIN + #define Y_MIN_PIN P1_25 // E1DET + #endif +#else + #define Y_STOP_PIN P1_28 // Y-STOP +#endif + +#if Z_STALL_SENSITIVITY + #if Z_HOME_DIR < 0 + #define Z_MIN_PIN Z_DIAG_PIN + #define Z_MAX_PIN P1_24 // PWRDET + #else + #define Z_MAX_PIN Z_DIAG_PIN + #define Z_MIN_PIN P1_24 // PWRDET + #endif +#else + #define Z_STOP_PIN P1_27 // Z-STOP +#endif // // Z Probe (when not Z_MIN_PIN) @@ -54,21 +95,21 @@ // // Filament Runout Sensor // -#define FIL_RUNOUT_PIN P1_26 -#define FIL_RUNOUT2_PIN P1_25 +#define FIL_RUNOUT_PIN P1_26 // E0DET +#define FIL_RUNOUT2_PIN P1_25 // E1DET // // Power Supply Control // #ifndef PS_ON_PIN - #define PS_ON_PIN P1_00 + #define PS_ON_PIN P1_00 // PWRDET #endif // // Power Loss Detection // #ifndef POWER_LOSS_PIN - #define POWER_LOSS_PIN P1_00 + #define POWER_LOSS_PIN P1_00 // PWRDET #endif // From e8e25b80d1d3a78f3e5358e8992bd4a4900d6c1c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 30 Jan 2020 13:29:08 -0600 Subject: [PATCH 20/23] Extend RX/TX pins for up to 8 extruders --- Marlin/src/pins/linux/pins_RAMPS_LINUX.h | 18 ++++++++++++++++++ Marlin/src/pins/ramps/pins_RAMPS.h | 18 ++++++++++++++++++ Marlin/src/pins/ramps/pins_TT_OSCAR.h | 3 +++ Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h | 18 ++++++++++++++++++ 4 files changed, 57 insertions(+) diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index 2cb6fb597b..d21c487e57 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -363,6 +363,24 @@ #ifndef E4_SERIAL_RX_PIN #define E4_SERIAL_RX_PIN -1 #endif + #ifndef E5_SERIAL_TX_PIN + #define E5_SERIAL_TX_PIN -1 + #endif + #ifndef E5_SERIAL_RX_PIN + #define E5_SERIAL_RX_PIN -1 + #endif + #ifndef E6_SERIAL_TX_PIN + #define E6_SERIAL_TX_PIN -1 + #endif + #ifndef E6_SERIAL_RX_PIN + #define E6_SERIAL_RX_PIN -1 + #endif + #ifndef E7_SERIAL_TX_PIN + #define E7_SERIAL_TX_PIN -1 + #endif + #ifndef E7_SERIAL_RX_PIN + #define E7_SERIAL_RX_PIN -1 + #endif #endif ////////////////////////// diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index f6ccff24f6..b7e9df4759 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -390,6 +390,24 @@ #ifndef E4_SERIAL_RX_PIN #define E4_SERIAL_RX_PIN -1 #endif + #ifndef E5_SERIAL_TX_PIN + #define E5_SERIAL_TX_PIN -1 + #endif + #ifndef E5_SERIAL_RX_PIN + #define E5_SERIAL_RX_PIN -1 + #endif + #ifndef E6_SERIAL_TX_PIN + #define E6_SERIAL_TX_PIN -1 + #endif + #ifndef E6_SERIAL_RX_PIN + #define E6_SERIAL_RX_PIN -1 + #endif + #ifndef E7_SERIAL_TX_PIN + #define E7_SERIAL_TX_PIN -1 + #endif + #ifndef E7_SERIAL_RX_PIN + #define E7_SERIAL_RX_PIN -1 + #endif #endif // diff --git a/Marlin/src/pins/ramps/pins_TT_OSCAR.h b/Marlin/src/pins/ramps/pins_TT_OSCAR.h index 1c40729a87..145817b484 100644 --- a/Marlin/src/pins/ramps/pins_TT_OSCAR.h +++ b/Marlin/src/pins/ramps/pins_TT_OSCAR.h @@ -147,6 +147,9 @@ #define E3_SERIAL_RX_PIN -1 #define E4_SERIAL_TX_PIN -1 #define E4_SERIAL_RX_PIN -1 + #define E5_SERIAL_RX_PIN -1 + #define E6_SERIAL_RX_PIN -1 + #define E7_SERIAL_RX_PIN -1 #endif // diff --git a/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h b/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h index 8545dc488a..d94f5e44cb 100644 --- a/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h +++ b/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h @@ -285,4 +285,22 @@ #ifndef E4_SERIAL_RX_PIN #define E4_SERIAL_RX_PIN -1 #endif + #ifndef E5_SERIAL_TX_PIN + #define E5_SERIAL_TX_PIN -1 + #endif + #ifndef E5_SERIAL_RX_PIN + #define E5_SERIAL_RX_PIN -1 + #endif + #ifndef E6_SERIAL_TX_PIN + #define E6_SERIAL_TX_PIN -1 + #endif + #ifndef E6_SERIAL_RX_PIN + #define E6_SERIAL_RX_PIN -1 + #endif + #ifndef E7_SERIAL_TX_PIN + #define E7_SERIAL_TX_PIN -1 + #endif + #ifndef E7_SERIAL_RX_PIN + #define E7_SERIAL_RX_PIN -1 + #endif #endif From 62f52ebb3a0ef69b166407d1f6b0e8ed9627397f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 30 Jan 2020 14:09:33 -0600 Subject: [PATCH 21/23] Fix up, improve endstop pin auto-assignment Followup for #16723 --- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h | 12 ++--- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 9 ++-- Marlin/src/pins/pins.h | 50 +++++++++++++++------ 3 files changed, 43 insertions(+), 28 deletions(-) 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 2b6595cd74..4889e4d3c3 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -36,11 +36,10 @@ * Limit Switches */ #if X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN #if X_HOME_DIR < 0 - #define X_MIN_PIN X_DIAG_PIN #define X_MAX_PIN P1_28 // X+ #else - #define X_MAX_PIN X_DIAG_PIN #define X_MIN_PIN P1_28 // X+ #endif #else @@ -49,11 +48,10 @@ #endif #if Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN #if Y_HOME_DIR < 0 - #define Y_MIN_PIN Y_DIAG_PIN #define Y_MAX_PIN P1_26 // Y+ #else - #define Y_MAX_PIN Y_DIAG_PIN #define Y_MIN_PIN P1_26 // Y+ #endif #else @@ -62,11 +60,10 @@ #endif #if Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN #if Z_HOME_DIR < 0 - #define Z_MIN_PIN Z_DIAG_PIN #define Z_MAX_PIN P1_24 // Z+ #else - #define Z_MAX_PIN Z_DIAG_PIN #define Z_MIN_PIN P1_24 // Z+ #endif #else @@ -184,9 +181,6 @@ #define E1_SERIAL_TX_PIN P1_04 #define E1_SERIAL_RX_PIN P1_01 - #define Z2_SERIAL_TX_PIN P1_04 - #define Z2_SERIAL_RX_PIN P1_01 - // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 #endif 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 90b5edca88..d0dcd5008a 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -50,11 +50,10 @@ // Limit Switches // #if X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN #if X_HOME_DIR < 0 - #define X_MIN_PIN X_DIAG_PIN #define X_MAX_PIN P1_26 // E0DET #else - #define X_MAX_PIN X_DIAG_PIN #define X_MIN_PIN P1_26 // E0DET #endif #else @@ -62,11 +61,10 @@ #endif #if Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN #if Y_HOME_DIR < 0 - #define Y_MIN_PIN Y_DIAG_PIN #define Y_MAX_PIN P1_25 // E1DET #else - #define Y_MAX_PIN Y_DIAG_PIN #define Y_MIN_PIN P1_25 // E1DET #endif #else @@ -74,11 +72,10 @@ #endif #if Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN #if Z_HOME_DIR < 0 - #define Z_MIN_PIN Z_DIAG_PIN #define Z_MAX_PIN P1_24 // PWRDET #else - #define Z_MAX_PIN Z_DIAG_PIN #define Z_MIN_PIN P1_24 // PWRDET #endif #else diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 736dbdace0..4df871a50c 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -1026,10 +1026,14 @@ #ifdef X_STOP_PIN #if X_HOME_DIR < 0 #define X_MIN_PIN X_STOP_PIN - #define X_MAX_PIN -1 + #ifndef X_MAX_PIN + #define X_MAX_PIN -1 + #endif #else - #define X_MIN_PIN -1 #define X_MAX_PIN X_STOP_PIN + #ifndef X_MIN_PIN + #define X_MIN_PIN -1 + #endif #endif #elif X_HOME_DIR < 0 #define X_STOP_PIN X_MIN_PIN @@ -1040,10 +1044,14 @@ #ifdef Y_STOP_PIN #if Y_HOME_DIR < 0 #define Y_MIN_PIN Y_STOP_PIN - #define Y_MAX_PIN -1 + #ifndef Y_MAX_PIN + #define Y_MAX_PIN -1 + #endif #else - #define Y_MIN_PIN -1 #define Y_MAX_PIN Y_STOP_PIN + #ifndef Y_MIN_PIN + #define Y_MIN_PIN -1 + #endif #endif #elif Y_HOME_DIR < 0 #define Y_STOP_PIN Y_MIN_PIN @@ -1054,10 +1062,14 @@ #ifdef Z_STOP_PIN #if Z_HOME_DIR < 0 #define Z_MIN_PIN Z_STOP_PIN - #define Z_MAX_PIN -1 + #ifndef Z_MAX_PIN + #define Z_MAX_PIN -1 + #endif #else - #define Z_MIN_PIN -1 #define Z_MAX_PIN Z_STOP_PIN + #ifndef Z_MIN_PIN + #define Z_MIN_PIN -1 + #endif #endif #elif Z_HOME_DIR < 0 #define Z_STOP_PIN Z_MIN_PIN @@ -1127,9 +1139,11 @@ * overridden in Configuration.h or Configuration_adv.h. */ +#define __PEXI(p,q) PIN_EXISTS(E##p##_##q) +#define _PEXI(p,q) __PEXI(p,q) #define __EPIN(p,q) E##p##_##q##_PIN #define _EPIN(p,q) __EPIN(p,q) -#define DIAG_REMAPPED(P,Q) (PIN_EXISTS(Q) && (P##_DIAG_PIN == Q##_PIN)) +#define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN) // The X2 axis, if any, should be the next open extruder port #define X2_E_INDEX E_STEPPERS @@ -1167,7 +1181,8 @@ // // Auto-assign pins for stallGuard sensorless homing // - #if X2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(X2_E_INDEX, DIAG) > 0 + #if X2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _PEXI(X2_E_INDEX, DIAG) + #define X2_DIAG_PIN _EPIN(X2_E_INDEX, DIAG) #if DIAG_REMAPPED(X2, X_MIN) // If already remapped in the pins file... #define X2_USE_ENDSTOP _XMIN_ #elif DIAG_REMAPPED(X2, Y_MIN) @@ -1184,6 +1199,7 @@ #define _X2_USE_ENDSTOP(P) _E##P##_DIAG_ #define X2_USE_ENDSTOP _X2_USE_ENDSTOP(X2_E_INDEX) #endif + #undef X2_DIAG_PIN #endif #define Y2_E_INDEX INCREMENT(X2_E_INDEX) @@ -1234,7 +1250,8 @@ #define Y2_SERIAL_RX_PIN _EPIN(Y2_E_INDEX, SERIAL_RX) #endif #endif - #if Y2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Y2_E_INDEX, DIAG) > 0 + #if Y2_STALL_SENSITIVITY && ENABLED(Y_DUAL_ENDSTOPS) && _PEXI(Y2_E_INDEX, DIAG) + #define Y2_DIAG_PIN _EPIN(Y2_E_INDEX, DIAG) #if DIAG_REMAPPED(Y2, X_MIN) #define Y2_USE_ENDSTOP _XMIN_ #elif DIAG_REMAPPED(Y2, Y_MIN) @@ -1251,6 +1268,7 @@ #define _Y2_USE_ENDSTOP(P) _E##P##_DIAG_ #define Y2_USE_ENDSTOP _Y2_USE_ENDSTOP(Y2_E_INDEX) #endif + #undef Y2_DIAG_PIN #endif #define Z2_E_INDEX INCREMENT(Y2_E_INDEX) #else @@ -1300,7 +1318,8 @@ #define Z2_SERIAL_RX_PIN _EPIN(Z2_E_INDEX, SERIAL_RX) #endif #endif - #if Z2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Z2_E_INDEX, DIAG) > 0 + #if Z2_STALL_SENSITIVITY && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 2 && _PEXI(Z2_E_INDEX, DIAG) + #define Z2_DIAG_PIN _EPIN(Z2_E_INDEX, DIAG) #if DIAG_REMAPPED(Z2, X_MIN) #define Z2_USE_ENDSTOP _XMIN_ #elif DIAG_REMAPPED(Z2, Y_MIN) @@ -1317,6 +1336,7 @@ #define _Z2_USE_ENDSTOP(P) _E##P##_DIAG_ #define Z2_USE_ENDSTOP _Z2_USE_ENDSTOP(Z2_E_INDEX) #endif + #undef Z2_DIAG_PIN #endif #define Z3_E_INDEX INCREMENT(Z2_E_INDEX) #else @@ -1367,7 +1387,8 @@ #define Z3_SERIAL_RX_PIN _EPIN(Z3_E_INDEX, SERIAL_RX) #endif #endif - #if Z3_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Z3_E_INDEX, DIAG) > 0 + #if Z3_STALL_SENSITIVITY && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 && _PEXI(Z3_E_INDEX, DIAG) + #define Z3_DIAG_PIN _EPIN(Z3_E_INDEX, DIAG) #if DIAG_REMAPPED(Z3, X_MIN) #define Z3_USE_ENDSTOP _XMIN_ #elif DIAG_REMAPPED(Z3, Y_MIN) @@ -1382,8 +1403,9 @@ #define Z3_USE_ENDSTOP _ZMAX_ #else #define _Z3_USE_ENDSTOP(P) _E##P##_DIAG_ - #define Z3_USE_ENDSTOP _Y2_USE_ENDSTOP(Y2_E_INDEX) + #define Z3_USE_ENDSTOP _Z3_USE_ENDSTOP(Z3_E_INDEX) #endif + #undef Z3_DIAG_PIN #endif #define Z4_E_INDEX INCREMENT(Z3_E_INDEX) #endif @@ -1432,7 +1454,8 @@ #define Z4_SERIAL_RX_PIN _EPIN(Z4_E_INDEX, SERIAL_RX) #endif #endif - #if Z4_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Z4_E_INDEX, DIAG) > 0 + #if Z4_STALL_SENSITIVITY && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 && _PEXI(Z4_E_INDEX, DIAG) + #define Z4_DIAG_PIN _EPIN(Z4_E_INDEX, DIAG) #if DIAG_REMAPPED(Z4, X_MIN) #define Z4_USE_ENDSTOP _XMIN_ #elif DIAG_REMAPPED(Z4, Y_MIN) @@ -1449,6 +1472,7 @@ #define _Z4_USE_ENDSTOP(P) _E##P##_DIAG_ #define Z4_USE_ENDSTOP _Z4_USE_ENDSTOP(Z4_E_INDEX) #endif + #undef Z4_DIAG_PIN #endif #endif From e4679c1b787887c466fa607b7408f69e420f4b90 Mon Sep 17 00:00:00 2001 From: Artur Petrzak Date: Fri, 31 Jan 2020 01:00:37 +0100 Subject: [PATCH 22/23] (21) PT100 for MCUs with 3.3v logic (#16731) --- Marlin/Configuration.h | 3 +- Marlin/src/lcd/thermistornames.h | 4 +- Marlin/src/module/thermistor/thermistor_21.h | 77 ++++++++++++++++++++ Marlin/src/module/thermistor/thermistors.h | 6 +- 4 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 Marlin/src/module/thermistor/thermistor_21.h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 7f242dce79..550ea35467 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -379,7 +379,8 @@ * 13 : 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" * 15 : 100k thermistor calibration for JGAurora A5 hotend * 18 : ATC Semitec 204GT-2 (4.7k pullup) Dagoma.Fr - MKS_Base_DKU001327 - * 20 : Pt100 with circuit in the Ultimainboard V2.x + * 20 : Pt100 with circuit in the Ultimainboard V2.x with 5v excitation (AVR) + * 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v excitation (STM32 \ LPC176x....) * 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x * 60 : 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 * 61 : 100k Formbot / Vivedino 3950 350C thermistor 4.7k pullup diff --git a/Marlin/src/lcd/thermistornames.h b/Marlin/src/lcd/thermistornames.h index 17772d7880..9cfb80fba3 100644 --- a/Marlin/src/lcd/thermistornames.h +++ b/Marlin/src/lcd/thermistornames.h @@ -85,7 +85,9 @@ #elif THERMISTOR_ID == 18 #define THERMISTOR_NAME "ATC Semitec 204GT-2" #elif THERMISTOR_ID == 20 - #define THERMISTOR_NAME "Pt100 UltiMB" + #define THERMISTOR_NAME "Pt100 UltiMB 5v" +#elif THERMISTOR_ID == 21 + #define THERMISTOR_NAME "Pt100 UltiMB 3.3v" #elif THERMISTOR_ID == 201 #define THERMISTOR_NAME "Pt100 OverLord" #elif THERMISTOR_ID == 60 diff --git a/Marlin/src/module/thermistor/thermistor_21.h b/Marlin/src/module/thermistor/thermistor_21.h new file mode 100644 index 0000000000..e65f90b75d --- /dev/null +++ b/Marlin/src/module/thermistor/thermistor_21.h @@ -0,0 +1,77 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2019 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 + +#define REVERSE_TEMP_SENSOR_RANGE + +#undef OV_SCALE +#define OV_SCALE(N) (float((N) * 5) / 3.3f) + +// Pt100 with INA826 amp with 3.3v excitation based on "Pt100 with INA826 amp on Ultimaker v2.0 electronics" +const short temptable_21[][2] PROGMEM = { + { OV( 0), 0 }, + { OV(227), 1 }, + { OV(236), 10 }, + { OV(245), 20 }, + { OV(253), 30 }, + { OV(262), 40 }, + { OV(270), 50 }, + { OV(279), 60 }, + { OV(287), 70 }, + { OV(295), 80 }, + { OV(304), 90 }, + { OV(312), 100 }, + { OV(320), 110 }, + { OV(329), 120 }, + { OV(337), 130 }, + { OV(345), 140 }, + { OV(353), 150 }, + { OV(361), 160 }, + { OV(369), 170 }, + { OV(377), 180 }, + { OV(385), 190 }, + { OV(393), 200 }, + { OV(401), 210 }, + { OV(409), 220 }, + { OV(417), 230 }, + { OV(424), 240 }, + { OV(432), 250 }, + { OV(440), 260 }, + { OV(447), 270 }, + { OV(455), 280 }, + { OV(463), 290 }, + { OV(470), 300 }, + { OV(478), 310 }, + { OV(485), 320 }, + { OV(493), 330 }, + { OV(500), 340 }, + { OV(507), 350 }, + { OV(515), 360 }, + { OV(522), 370 }, + { OV(529), 380 }, + { OV(537), 390 }, + { OV(544), 400 }, + { OV(614), 500 } +}; + +#undef OV_SCALE +#define OV_SCALE(N) (N) diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 875f742ccb..58e1ef115f 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -37,7 +37,8 @@ #error "MAX_RAW_THERMISTOR_VALUE is too large for int16_t. Reduce OVERSAMPLENR or HAL_ADC_RESOLUTION." #endif -#define OV(N) int16_t((N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE)) +#define OV_SCALE(N) (N) +#define OV(N) int16_t(OV_SCALE(N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE)) #define ANY_THERMISTOR_IS(n) (THERMISTOR_HEATER_0 == n || THERMISTOR_HEATER_1 == n || THERMISTOR_HEATER_2 == n || THERMISTOR_HEATER_3 == n || THERMISTOR_HEATER_4 == n || THERMISTOR_HEATER_5 == n || THERMISTOR_HEATER_6 == n || THERMISTOR_HEATER_7 == n || THERMISTORBED == n || THERMISTORCHAMBER == n || THERMISTORPROBE == n) @@ -105,6 +106,9 @@ #if ANY_THERMISTOR_IS(20) // Pt100 with INA826 amp on Ultimaker v2.0 electronics #include "thermistor_20.h" #endif +#if ANY_THERMISTOR_IS(21) // Pt100 with INA826 amp with 3.3v excitation based on "Pt100 with INA826 amp on Ultimaker v2.0 electronics" + #include "thermistor_21.h" +#endif #if ANY_THERMISTOR_IS(51) // beta25 = 4092 K, R25 = 100 kOhm, Pull-up = 1 kOhm, "EPCOS" #include "thermistor_51.h" #endif From dabf3939209fd8ea7f6a6327d764c16743aa22aa Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 31 Jan 2020 00:06:46 +0000 Subject: [PATCH 23/23] [cron] Bump distribution date (2020-01-31) --- 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 4b933d0327..89b5d02c63 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 "2020-01-30" + #define STRING_DISTRIBUTION_DATE "2020-01-31" #endif /**