From 3a9d96763c4633122b219b7d621ca924a6742c66 Mon Sep 17 00:00:00 2001 From: JoAnn Manges Date: Sat, 12 Dec 2020 00:45:10 -0500 Subject: [PATCH 01/44] First commit --- Marlin/src/HAL/LPC1768/inc/SanityCheck.h | 6 +- Marlin/src/MarlinCore.cpp | 27 +- Marlin/src/core/boards.h | 2 + Marlin/src/inc/Conditionals_post.h | 57 ++++ Marlin/src/inc/SanityCheck.h | 4 +- Marlin/src/module/temperature.cpp | 287 ++++++++++++++---- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h | 1 + Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h | 4 +- platformio.ini | 5 +- 9 files changed, 323 insertions(+), 70 deletions(-) diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index 21d149fcafe6..f94677d4c67a 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -31,7 +31,11 @@ /** * Detect an old pins file by checking for old ADC pins values. */ -#define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && _CAT(P,_PIN) != 2 && _CAT(P,_PIN) != 3 +#if LPC1768_IS_SKRV1_3 + #define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && !(_CAT(P,_PIN) >= 0 && _CAT(P,_PIN) <= 3) //include P0_00 and P0_01 for SKR V1.3 board +#else + #define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && _CAT(P,_PIN) != 2 && _CAT(P,_PIN) != 3 +#endif #if _OLD_TEMP_PIN(TEMP_BED) #error "TEMP_BED_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)." #elif _OLD_TEMP_PIN(TEMP_0) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 0171690d4e6e..246e604e8088 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1012,14 +1012,35 @@ void setup() { SETUP_RUN(HAL_init()); - // Init and disable SPI thermocouples - #if HEATER_0_USES_MAX6675 +// Init and disable SPI thermocouples + #if HEATER_0_USES_MAX6675 && PIN_EXISTS(MAX6675_SS) OUT_WRITE(MAX6675_SS_PIN, HIGH); // Disable #endif - #if HEATER_1_USES_MAX6675 + #if HEATER_1_USES_MAX6675 && PIN_EXISTS(MAX6675_SS2) OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable #endif + #if HEATER_0_USES_MAX6675 && PIN_EXISTS(MAX31855_CS) + OUT_WRITE(MAX31855_CS_PIN, HIGH); // Disable + #endif + #if HEATER_1_USES_MAX6675 && PIN_EXISTS(MAX31855_CS2) + OUT_WRITE(MAX31855_CS2_PIN, HIGH); // Disable + #endif + + #if HEATER_0_USES_MAX6675 && PIN_EXISTS(MAX31865_CS) + OUT_WRITE(MAX31865_CS_PIN, HIGH); // Disable + #endif + #if HEATER_1_USES_MAX6675 && PIN_EXISTS(MAX31865_CS2) + OUT_WRITE(MAX31865_CS2_PIN, HIGH); // Disable + #endif + + #if HEATER_0_USES_MAX6675 && PIN_EXISTS(MAX6675_CS) + OUT_WRITE(MAX6675_CS_PIN, HIGH); // Disable + #endif + #if HEATER_1_USES_MAX6675 && PIN_EXISTS(MAX6675_CS2) + OUT_WRITE(MAX6675_CS2_PIN, HIGH); // Disable + #endif + #if HAS_L64XX SETUP_RUN(L64xxManager.init()); // Set up SPI, init drivers #endif diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 7f0a99dca329..dcd1a3938462 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -408,3 +408,5 @@ #define MB(V...) DO(MB,||,V) #define IS_MELZI MB(MELZI, MELZI_CREALITY, MELZI_MAKR3D, MELZI_MALYAN, MELZI_TRONXY, MELZI_V2) + +#define IS_LPC1768 MB(BTT_SKR_V1_3, BTT_SKR_V1_4, BTT_SKR_V1_4_TURBO) \ No newline at end of file diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 092dc818b84f..941c0d9916ea 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -411,6 +411,8 @@ #define MAX6675_0_IS_MAX31865 1 #elif TEMP_SENSOR_0 == -3 #define MAX6675_0_IS_MAX31855 1 + #elif TEMP_SENSOR_0 == -2 + #define MAX6675_0_IS_MAX6675 1 #endif #elif TEMP_SENSOR_0 == -4 #define HEATER_0_USES_AD8495 1 @@ -442,6 +444,8 @@ #define MAX6675_1_IS_MAX31865 1 #elif TEMP_SENSOR_1 == -3 #define MAX6675_1_IS_MAX31855 1 + #elif TEMP_SENSOR_1 == -2 + #define MAX6675_1_IS_MAX6675 1 #endif #if TEMP_SENSOR_1 != TEMP_SENSOR_0 #if TEMP_SENSOR_1 == -5 @@ -469,6 +473,59 @@ #undef HEATER_1_MAXTEMP #endif +#if (MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855) && IS_LPC1768 + #define MAX6675_HAS_MAX31855_LPC176X 1 + #define LPC1768_HAS_MAX31855 1 + #if PIN_EXISTS(MAX6675_DO) || PIN_EXISTS(MAX31855_MISO) + #define MAX31855_USES_DO 1 + #endif + #if PIN_EXISTS(MAX6675_SCK) || PIN_EXISTS(MAX31855_SCK) + #define MAX31855_USES_SCK 1 + #endif + #if MAX31855_USES_DO && MAX31855_USES_SCK + #define MAX31855_USES_SW_LIB 1 + #endif +#endif + +#if (MAX6675_0_IS_MAX31865 || MAX6675_1_IS_MAX31865) && IS_LPC1768 + #define LPC1768_HAS_MAX31865 1 + #if PIN_EXISTS(MAX6675_DO) || PIN_EXISTS(MAX31865_MISO) + #define MAX31865_USES_DO 1 + #endif + #if PIN_EXISTS(MAX6675_SCK) || PIN_EXISTS(MAX31865_SCK) + #define MAX31865_USES_SCK 1 + #endif + #if MAX31865_USES_DO && MAX31865_USES_SCK + #define MAX31865_USES_SW_LIB 1 + #endif +#endif + +#if (MAX6675_0_IS_MAX31865 || MAX6675_1_IS_MAX31865) && !IS_LPC1768 + #define MAX6675_HAS_MAX31865 1 + #if PIN_EXISTS(MAX6675_DO) || PIN_EXISTS(MAX31865_MISO) + #define MAX31865_USES_DO 1 + #endif + #if PIN_EXISTS(MAX6675_SCK) || PIN_EXISTS(MAX31865_SCK) + #define MAX31865_USES_SCK 1 + #endif + #if MAX31865_USES_DO && MAX31865_USES_SCK + #define MAX31865_USES_SW_LIB 1 + #endif +#endif + +#if (MAX6675_0_IS_MAX6675 || MAX6675_1_IS_MAX6675) && IS_LPC1768 + #define LPC1768_HAS_MAX6675 1 + #if PIN_EXISTS(MAX6675_DO) || PIN_EXISTS(MAX6675_MISO) + #define MAX6675_USES_DO 1 + #endif + #if PIN_EXISTS(MAX6675_SCK) + #define MAX6675_USES_SCK 1 + #endif + #if MAX6675_USES_DO && MAX6675_USES_SCK + #define MAX6675_USES_SW_LIB 1 + #endif +#endif + #if TEMP_SENSOR_2 == -4 #define HEATER_2_USES_AD8495 1 #elif TEMP_SENSOR_2 == -3 diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 857f12e4548b..8b9cefd90d3b 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1698,7 +1698,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal /** * Pins and Sensor IDs must be set for each heater */ -#if HEATER_0_USES_MAX6675 && !PIN_EXISTS(MAX6675_SS) +#if HEATER_0_USES_MAX6675 && !PIN_EXISTS(MAX6675_SS) && !(PIN_EXISTS(MAX31855_CS) || PIN_EXISTS(MAX31865_CS) || PIN_EXISTS(MAX6675_CS)) #error "MAX6675_SS_PIN (required for TEMP_SENSOR_0) not defined for this board." #elif HAS_HOTEND && !HAS_TEMP_HOTEND && !HEATER_0_DUMMY_THERMISTOR #error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board." @@ -1707,7 +1707,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #endif #if HAS_MULTI_HOTEND - #if HEATER_1_USES_MAX6675 && !PIN_EXISTS(MAX6675_SS2) + #if HEATER_1_USES_MAX6675 && !PIN_EXISTS(MAX6675_SS2) && !(PIN_EXISTS(MAX31855_CS2) || PIN_EXISTS(MAX31865_CS2) || PIN_EXISTS(MAX6675_CS2)) #error "MAX6675_SS2_PIN (required for TEMP_SENSOR_1) not defined for this board." #elif TEMP_SENSOR_1 == 0 #error "TEMP_SENSOR_1 is required with 2 or more HOTENDS." diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index d704ebc85bfd..57a677b31138 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -44,7 +44,43 @@ #include "../lcd/extui/ui_api.h" #endif -#if MAX6675_0_IS_MAX31865 || MAX6675_1_IS_MAX31865 +// +// Only needed for LPC176x boards +// +#if MAX6675_HAS_MAX31855_LPC176X + #include + #if !defined(MAX31855_CS_PIN) && PIN_EXISTS(MAX6675_SS) + #define MAX31855_CS_PIN MAX6675_SS_PIN + #endif + #if !defined(MAX31855_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) + #define MAX31855_CS2_PIN MAX6675_SS2_PIN + #endif + #if !defined(MAX31855_MISO_PIN) && PIN_EXISTS(MAX6675_DO) + #define MAX31855_MISO_PIN MAX6675_DO_PIN + #endif + #if !defined(MAX31855_SCK_PIN) && PIN_EXISTS(MAX6675_SCK) + #define MAX31855_SCK_PIN MAX6675_SCK_PIN + #endif + #if MAX6675_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS) && MAX31855_USES_SW_LIB + #define HAS_MAX31855 1 + Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855(MAX31855_SCK_PIN, MAX31855_CS_PIN, MAX31855_MISO_PIN); + #elif MAX6675_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS) + #define HAS_MAX31855 1 + Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855(MAX31855_CS_PIN); + #endif + #if MAX6675_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2) && MAX31855_USES_SW_LIB + #define HAS_MAX31855 1 + Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855(MAX31855_SCK_PIN, MAX31855_CS2_PIN, MAX31855_MISO_PIN); + #elif MAX6675_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2) + #define HAS_MAX31855 1 + Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855(MAX31855_CS2_PIN); + #endif +#endif + +// +// For boards that are not LPC176x +// +#if MAX6675_HAS_MAX31865 #include #if MAX6675_0_IS_MAX31865 && !defined(MAX31865_CS_PIN) && PIN_EXISTS(MAX6675_SS) #define MAX31865_CS_PIN MAX6675_SS_PIN @@ -79,7 +115,82 @@ #endif #endif -#if EITHER(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) +// +// Only needed for LPC176x boards +// +#if LPC1768_HAS_MAX31865 + #include + #if !defined(MAX31865_CS_PIN) && PIN_EXISTS(MAX6675_SS) + #define MAX31865_CS_PIN MAX6675_SS_PIN + #endif + #if !defined(MAX31865_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) + #define MAX31865_CS2_PIN MAX6675_SS2_PIN + #endif + #ifndef MAX31865_MOSI_PIN + #define MAX31865_MOSI_PIN MOSI_PIN + #endif + #if !defined(MAX31865_MISO_PIN) && PIN_EXISTS(MAX6675_DO) + #define MAX31865_MISO_PIN MAX6675_DO_PIN + #endif + #if !defined(MAX31865_SCK_PIN) && PIN_EXISTS(MAX6675_SCK) + #define MAX31865_SCK_PIN MAX6675_SCK_PIN + #endif + #if MAX6675_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS) + #define HAS_MAX31865 1 + Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN + #if MAX31865_USES_SW_LIB + , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK + #endif + ); + #endif + #if MAX6675_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2) + #define HAS_MAX31865 1 + Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN + #if MAX31865_USES_SW_LIB + , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK + #endif + ); + #endif +#endif + +// +// Only needed for LPC176x boards +// +#if LPC1768_HAS_MAX6675 + #include + #if !defined(MAX6675_CS_PIN) && PIN_EXISTS(MAX6675_SS) + #define MAX6675_CS_PIN MAX6675_SS_PIN + #endif + #if !defined(MAX6675_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) + #define MAX6675_CS2_PIN MAX6675_SS2_PIN + #endif + #if !defined(MAX6675_MISO_PIN) && PIN_EXISTS(MAX6675_DO) + #define MAX6675_MISO_PIN MAX6675_DO_PIN + #endif + #if MAX6675_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) + #define HAS_MAX6675_FOR_LPC 1 + MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN + #if MAX6675_USES_SW_LIB && PIN_EXISTS(MAX6675_SCK) + , MAX6675_SCK_PIN, MAX6675_MISO_PIN + #endif + ); + //#elif defined(MAX6675_CS_PIN) && !PIN_EXISTS(MAX6675_SS) + //#define MAX6675_SS_PIN MAX6675_CS_PIN + #endif + #if MAX6675_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) + #define HAS_MAX6675_FOR_LPC 1 + MAX6675 max6675_1 = MAX6675(MAX6675_CS2_PIN + #if MAX6675_USES_SW_LIB && PIN_EXISTS(MAX6675_SCK) + , MAX6675_SCK_PIN, MAX6675_MISO_PIN + #endif + ); + //#elif defined(MAX6675_CS2_PIN) && !PIN_EXISTS(MAX6675_SS2) + //#define MAX6675_SS2_PIN MAX6675_CS2_PIN + #endif +#endif + + +#if EITHER(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && !HAS_MAX31855 && !HAS_MAX31865 && !HAS_MAX6675_FOR_LPC #define MAX6675_SEPARATE_SPI 1 #endif @@ -1701,6 +1812,14 @@ void Temperature::init() { TERN_(MAX6675_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE TERN_(MAX6675_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE)); + #if HAS_MAX31855 + TERN_(MAX6675_0_IS_MAX31855, max31855_0.begin()); + TERN_(MAX6675_1_IS_MAX31855, max31855_1.begin()); + #endif + #if HAS_MAX6675_FOR_LPC + TERN_(MAX6675_0_IS_MAX6675, max6675_0.begin()); + TERN_(MAX6675_1_IS_MAX6675, max6675_1.begin()); + #endif #if EARLY_WATCHDOG // Flag that the thermalManager should be running @@ -1718,10 +1837,10 @@ void Temperature::init() { #endif // Thermistor activation by MCU pin - #if PIN_EXISTS(TEMP_0_TR_ENABLE_PIN) + #if PIN_EXISTS(TEMP_0_TR_ENABLE) OUT_WRITE(TEMP_0_TR_ENABLE_PIN, ENABLED(HEATER_0_USES_MAX6675)); #endif - #if PIN_EXISTS(TEMP_1_TR_ENABLE_PIN) + #if PIN_EXISTS(TEMP_1_TR_ENABLE) OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(HEATER_1_USES_MAX6675)); #endif @@ -2224,7 +2343,7 @@ void Temperature::disable_all_heaters() { #else constexpr uint8_t hindex = 0; #define MAX6675_TEMP(I) max6675_temp - #if MAX6675_1_IS_MAX31865 + #if MAX6675_1_IS_MAX31865 || MAX6675_1_IS_MAX31855 || MAX6675_1_IS_MAX6675 #define MAX6675_SEL(A,B) B #else #define MAX6675_SEL(A,B) A @@ -2246,84 +2365,130 @@ void Temperature::disable_all_heaters() { if (PENDING(ms, next_max6675_ms[hindex])) return int(MAX6675_TEMP(hindex)); next_max6675_ms[hindex] = ms + MAX6675_HEAT_INTERVAL; - #if HAS_MAX31865 - Adafruit_MAX31865 &maxref = MAX6675_SEL(max31865_0, max31865_1); - const uint16_t max31865_ohms = (uint32_t(maxref.readRTD()) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; - #endif - // // TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used. // - #if !MAX6675_SEPARATE_SPI + #if !MAX6675_SEPARATE_SPI && !HAS_MAX31865 && !HAS_MAX31855 && !HAS_MAX6675_FOR_LPC spiBegin(); spiInit(MAX6675_SPEED_BITS); #endif - MAX6675_WRITE(LOW); // enable TT_MAX6675 - DELAY_NS(100); // Ensure 100ns delay + #if !HAS_MAX31865 && !HAS_MAX31855 && !HAS_MAX6675_FOR_LPC + MAX6675_WRITE(LOW); // enable TT_MAX6675 + DELAY_NS(100); // Ensure 100ns delay + #endif // Read a big-endian temperature value max6675_temp = 0; - for (uint8_t i = sizeof(max6675_temp); i--;) { - max6675_temp |= TERN(MAX6675_SEPARATE_SPI, max6675_spi.receive(), spiRec()); - if (i > 0) max6675_temp <<= 8; // shift left if not the last byte - } + #if !HAS_MAX31865 && !HAS_MAX31855 && !HAS_MAX6675_FOR_LPC + for (uint8_t i = sizeof(max6675_temp); i--;) { + max6675_temp |= TERN(MAX6675_SEPARATE_SPI, max6675_spi.receive(), spiRec()); + if (i > 0) max6675_temp <<= 8; // shift left if not the last byte + } + MAX6675_WRITE(HIGH); // disable TT_MAX6675 + #endif - MAX6675_WRITE(HIGH); // disable TT_MAX6675 + #if HAS_MAX31855 + Adafruit_MAX31855 &max855ref = MAX6675_SEL(max31855_0, max31855_1); + max6675_temp = max855ref.readRaw32(); + #endif + + #if HAS_MAX31865 + Adafruit_MAX31865 &max865ref = MAX6675_SEL(max31865_0, max31865_1); + #endif - const uint8_t fault_31865 = TERN1(HAS_MAX31865, maxref.readFault()); + #if HAS_MAX6675_FOR_LPC + MAX6675 &max6675ref = MAX6675_SEL(max6675_0, max6675_1); + #endif + + #if LPC1768_HAS_MAX31865 + max6675_temp = max865ref.readRTD_with_Fault(); + #elif HAS_MAX6675_FOR_LPC + max6675_temp = max6675ref.readRaw16(); + #else + // At the present time we do not have the ability to set the MAX31865 HIGH threshold + // or thr LOW threshold, so no need to check for them, zero these bits out + const uint8_t fault_31865 = TERN1(HAS_MAX31865, (max865ref.readFault() & 0x3FU)); + #endif - if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK) && fault_31865) { - max6675_errors[hindex]++; - if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { - SERIAL_ERROR_START(); - SERIAL_ECHOPGM("Temp measurement error! "); - #if MAX6675_ERROR_MASK == 7 - SERIAL_ECHOPGM("MAX31855 "); - if (max6675_temp & 1) - SERIAL_ECHOLNPGM("Open Circuit"); - else if (max6675_temp & 2) - SERIAL_ECHOLNPGM("Short to GND"); - else if (max6675_temp & 4) - SERIAL_ECHOLNPGM("Short to VCC"); - #elif HAS_MAX31865 - if (fault_31865) { - maxref.clearFault(); - SERIAL_ECHOPAIR("MAX31865 Fault :(", fault_31865, ") >>"); - if (fault_31865 & MAX31865_FAULT_HIGHTHRESH) - SERIAL_ECHOLNPGM("RTD High Threshold"); - else if (fault_31865 & MAX31865_FAULT_LOWTHRESH) - SERIAL_ECHOLNPGM("RTD Low Threshold"); - else if (fault_31865 & MAX31865_FAULT_REFINLOW) - SERIAL_ECHOLNPGM("REFIN- > 0.85 x Bias"); - else if (fault_31865 & MAX31865_FAULT_REFINHIGH) - SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); - else if (fault_31865 & MAX31865_FAULT_RTDINLOW) - SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); - else if (fault_31865 & MAX31865_FAULT_OVUV) - SERIAL_ECHOLNPGM("Under/Over voltage"); - } - #else - SERIAL_ECHOLNPGM("MAX6675"); - #endif + #if LPC1768_HAS_MAX31865 || HAS_MAX6675_FOR_LPC + if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK)) { + #else + if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK) && fault_31865) { + #endif + max6675_errors[hindex]++; + if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { + SERIAL_ERROR_START(); + SERIAL_ECHOPGM("Temp measurement error! "); + #if MAX6675_ERROR_MASK == 7 + SERIAL_ECHOPGM("MAX31855 "); + if (max6675_temp & 1) + SERIAL_ECHOLNPAIR("Fault :(", max6675_temp & 1 ,") >> Open Circuit"); + else if (max6675_temp & 2) + SERIAL_ECHOLNPAIR("Fault : (", max6675_temp & 2 ,") >> Short to GND"); + else if (max6675_temp & 4) + SERIAL_ECHOLNPAIR("Fault : (", max6675_temp & 4 ,") >> Short to VCC"); + #elif MAX6675_HAS_MAX31865 + max865ref.clearFault(); + if (fault_31865) { + SERIAL_ECHOLNPAIR("\nMAX31865 Fault :(", fault_31865, ") >>"); + if (fault_31865 & MAX31865_FAULT_HIGHTHRESH) + SERIAL_ECHOLNPGM("RTD High Threshold"); + if (fault_31865 & MAX31865_FAULT_LOWTHRESH) + SERIAL_ECHOLNPGM("RTD Low Threshold"); + if (fault_31865 & MAX31865_FAULT_REFINLOW) + SERIAL_ECHOLNPGM("REFIN- > 0.85 x Bias"); + if (fault_31865 & MAX31865_FAULT_REFINHIGH) + SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); + if (fault_31865 & MAX31865_FAULT_RTDINLOW) + SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); + if (fault_31865 & MAX31865_FAULT_OVUV) + SERIAL_ECHOLNPGM("Under/Over voltage"); + } + #elif LPC1768_HAS_MAX31865 + const uint8_t fault_31865 = max865ref.readFault(); + max865ref.clearFault(); + if (fault_31865) { + SERIAL_ECHOLNPAIR("\nMAX31865 Fault :(", fault_31865, ") >>"); + if (fault_31865 & MAX31865_FAULT_HIGHTHRESH) + SERIAL_ECHOLNPGM("RTD High Threshold"); + if (fault_31865 & MAX31865_FAULT_LOWTHRESH) + SERIAL_ECHOLNPGM("RTD Low Threshold"); + if (fault_31865 & MAX31865_FAULT_REFINLOW) + SERIAL_ECHOLNPGM("REFIN- > 0.85 x Bias"); + if (fault_31865 & MAX31865_FAULT_REFINHIGH) + SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); + if (fault_31865 & MAX31865_FAULT_RTDINLOW) + SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); + if (fault_31865 & MAX31865_FAULT_OVUV) + SERIAL_ECHOLNPGM("Under/Over voltage"); + } + #else + SERIAL_ECHOPGM("MAX6675 "); + SERIAL_ECHOLNPGM("Open Circuit"); + #endif - // Thermocouple open - max6675_temp = 4 * MAX6675_SEL(HEATER_0_MAX6675_TMAX, HEATER_1_MAX6675_TMAX); + // Thermocouple open + max6675_temp = 4 * MAX6675_SEL(HEATER_0_MAX6675_TMAX, HEATER_1_MAX6675_TMAX); + } + else + max6675_temp >>= MAX6675_DISCARD_BITS; } - else + else { max6675_temp >>= MAX6675_DISCARD_BITS; - } - else { - max6675_temp >>= MAX6675_DISCARD_BITS; - max6675_errors[hindex] = 0; - } + max6675_errors[hindex] = 0; + } #if MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855 if (max6675_temp & 0x00002000) max6675_temp |= 0xFFFFC000; // Support negative temperature #endif // Return the RTD resistance for MAX31865 for display in SHOW_TEMP_ADC_VALUES - TERN_(HAS_MAX31865, max6675_temp = max31865_ohms); + #if MAX6675_HAS_MAX31865 + max6675_temp = (uint32_t(max865ref.readRTD()) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; + #elif LPC1768_HAS_MAX31865 + max6675_temp = (uint32_t(max6675_temp) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; + #endif MAX6675_TEMP(hindex) = max6675_temp; 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 c621f93a2ac5..df19f1141cbe 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -22,6 +22,7 @@ #pragma once #define BOARD_INFO_NAME "BTT SKR V1.3" +#define LPC1768_IS_SKRV1_3 1 // // Trinamic Stallguard pins diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h index a75eb6ae5d8f..a8dd55bf2721 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -29,7 +29,7 @@ #error "Oops! Make sure you have the LPC1768 environment selected in your IDE." #endif -// If you have the Big tree tech driver expantion module, enable HAS_BTT_EXP_MOT +// If you have the Big tree tech driver expansion module, enable HAS_BTT_EXP_MOT // https://github.com/bigtreetech/BTT-Expansion-module/tree/master/BTT%20EXP-MOT //#define HAS_BTT_EXP_MOT 1 @@ -37,7 +37,7 @@ #if EITHER(CR10_STOCKDISPLAY, ENDER2_STOCKDISPLAY) #define EXP_MOT_USE_EXP2_ONLY #else - #error "Having a LCD that uses both EXP1/EXP2 and a expanion motor module on EXP1/EXP2 is not possible." + #error "Having a LCD that uses both EXP1/EXP2 and an expansion motor module on EXP1/EXP2 is not possible." #endif #endif diff --git a/platformio.ini b/platformio.ini index e2f1388efda3..b039adbfd310 100644 --- a/platformio.ini +++ b/platformio.ini @@ -225,7 +225,10 @@ HAS_L64XX = Arduino-L6470@0.8.0 src_filter=+ + + NEOPIXEL_LED = Adafruit NeoPixel@1.5.0 src_filter=+ -MAX6675_._IS_MAX31865 = Adafruit MAX31865 library@~1.1.0 +MAX6675_HAS_MAX31865 = Adafruit MAX31865 library@~1.1.0 +LPC1768_HAS_MAX31865 = https://github.com/GadgetAngel/Adafruit-MAX31865-V1.1.0-Mod-M.git +LPC1768_HAS_MAX31855 = https://github.com/GadgetAngel/Adafruit-MAX31855-V1.0.3-Mod-M.git +LPC1768_HAS_MAX6675 = https://github.com/GadgetAngel/MAX6675-V1.1.0-Mod-M.git USES_LIQUIDCRYSTAL = LiquidCrystal@1.5.0 USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4 USES_LIQUIDTWI2 = LiquidTWI2@1.2.7 From ec4032cb66740e3d2fc7c693e3f749ebe4236d13 Mon Sep 17 00:00:00 2001 From: JoAnn Manges Date: Sat, 12 Dec 2020 06:42:36 -0500 Subject: [PATCH 02/44] remove comments --- Marlin/src/module/temperature.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 57a677b31138..e5bbea43dbb8 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -174,8 +174,6 @@ , MAX6675_SCK_PIN, MAX6675_MISO_PIN #endif ); - //#elif defined(MAX6675_CS_PIN) && !PIN_EXISTS(MAX6675_SS) - //#define MAX6675_SS_PIN MAX6675_CS_PIN #endif #if MAX6675_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) #define HAS_MAX6675_FOR_LPC 1 @@ -184,8 +182,6 @@ , MAX6675_SCK_PIN, MAX6675_MISO_PIN #endif ); - //#elif defined(MAX6675_CS2_PIN) && !PIN_EXISTS(MAX6675_SS2) - //#define MAX6675_SS2_PIN MAX6675_CS2_PIN #endif #endif From ed9418af3040c44f26d98075a3310ad3dbe9d653 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Sat, 12 Dec 2020 18:55:18 -0500 Subject: [PATCH 03/44] Generalized library calls The following was done: For MAX31855 library added ARDUNIOLPC constant and changed order of parms on SW obj to (CS, DO, SCK) instead of (SCK, CS, DO) added .readRaw32 method and now all MCU boards will use the library call for MAX31855 when the need arises. For MAX31865 added ARDUINOLPC constant and added two new methods: .readRTD_with_Fault method and .readRTD_Resistance method, and now all MCU boards will use the MAX31865 library when the need arises. For MAX6675 added ARDUNIOLPC constant and change order of parms on SW obj to (CS, DO, SCK) instead of (SCK, CS, DO) added a .begin method; added interface obj for hardware SPI; and added .readRaw16 method. The MAX31855 and MAX31865 library are identical to the Adafruit MAX31855 and Adafruit MAX31865 in platformio except for the changes I added. The MAX6675 library is open domain source and I add features that the Marlin code needed. --- Marlin/src/inc/Conditionals_post.h | 24 +--- Marlin/src/module/temperature.cpp | 216 ++++++++++------------------- platformio.ini | 9 +- 3 files changed, 83 insertions(+), 166 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 941c0d9916ea..14415cb5d6bc 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -473,9 +473,8 @@ #undef HEATER_1_MAXTEMP #endif -#if (MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855) && IS_LPC1768 - #define MAX6675_HAS_MAX31855_LPC176X 1 - #define LPC1768_HAS_MAX31855 1 +#if (MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855) + #define MAX6675_HAS_MAX31855 1 #if PIN_EXISTS(MAX6675_DO) || PIN_EXISTS(MAX31855_MISO) #define MAX31855_USES_DO 1 #endif @@ -487,20 +486,7 @@ #endif #endif -#if (MAX6675_0_IS_MAX31865 || MAX6675_1_IS_MAX31865) && IS_LPC1768 - #define LPC1768_HAS_MAX31865 1 - #if PIN_EXISTS(MAX6675_DO) || PIN_EXISTS(MAX31865_MISO) - #define MAX31865_USES_DO 1 - #endif - #if PIN_EXISTS(MAX6675_SCK) || PIN_EXISTS(MAX31865_SCK) - #define MAX31865_USES_SCK 1 - #endif - #if MAX31865_USES_DO && MAX31865_USES_SCK - #define MAX31865_USES_SW_LIB 1 - #endif -#endif - -#if (MAX6675_0_IS_MAX31865 || MAX6675_1_IS_MAX31865) && !IS_LPC1768 +#if (MAX6675_0_IS_MAX31865 || MAX6675_1_IS_MAX31865) #define MAX6675_HAS_MAX31865 1 #if PIN_EXISTS(MAX6675_DO) || PIN_EXISTS(MAX31865_MISO) #define MAX31865_USES_DO 1 @@ -513,8 +499,8 @@ #endif #endif -#if (MAX6675_0_IS_MAX6675 || MAX6675_1_IS_MAX6675) && IS_LPC1768 - #define LPC1768_HAS_MAX6675 1 +#if (MAX6675_0_IS_MAX6675 || MAX6675_1_IS_MAX6675) + #define MAX6675_HAS_MAX6675 1 #if PIN_EXISTS(MAX6675_DO) || PIN_EXISTS(MAX6675_MISO) #define MAX6675_USES_DO 1 #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index e5bbea43dbb8..0c106633190a 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -44,15 +44,12 @@ #include "../lcd/extui/ui_api.h" #endif -// -// Only needed for LPC176x boards -// -#if MAX6675_HAS_MAX31855_LPC176X +#if MAX6675_HAS_MAX31855 #include - #if !defined(MAX31855_CS_PIN) && PIN_EXISTS(MAX6675_SS) + #if MAX6675_0_IS_MAX31855 && !defined(MAX31855_CS_PIN) && PIN_EXISTS(MAX6675_SS) #define MAX31855_CS_PIN MAX6675_SS_PIN #endif - #if !defined(MAX31855_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) + #if MAX6675_1_IS_MAX31855 && !defined(MAX31855_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) #define MAX31855_CS2_PIN MAX6675_SS2_PIN #endif #if !defined(MAX31855_MISO_PIN) && PIN_EXISTS(MAX6675_DO) @@ -61,25 +58,24 @@ #if !defined(MAX31855_SCK_PIN) && PIN_EXISTS(MAX6675_SCK) #define MAX31855_SCK_PIN MAX6675_SCK_PIN #endif - #if MAX6675_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS) && MAX31855_USES_SW_LIB + #if MAX6675_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS) #define HAS_MAX31855 1 - Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855(MAX31855_SCK_PIN, MAX31855_CS_PIN, MAX31855_MISO_PIN); - #elif MAX6675_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS) - #define HAS_MAX31855 1 - Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855(MAX31855_CS_PIN); + Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855(MAX31855_CS_PIN + #if MAX31855_USES_SW_LIB + , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK + #endif + ); #endif - #if MAX6675_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2) && MAX31855_USES_SW_LIB + #if MAX6675_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2) #define HAS_MAX31855 1 - Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855(MAX31855_SCK_PIN, MAX31855_CS2_PIN, MAX31855_MISO_PIN); - #elif MAX6675_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2) - #define HAS_MAX31855 1 - Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855(MAX31855_CS2_PIN); + Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855(MAX31855_CS2_PIN + #if MAX31855_USES_SW_LIB + , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK + #endif + ); #endif #endif -// -// For boards that are not LPC176x -// #if MAX6675_HAS_MAX31865 #include #if MAX6675_0_IS_MAX31865 && !defined(MAX31865_CS_PIN) && PIN_EXISTS(MAX6675_SS) @@ -88,44 +84,6 @@ #if MAX6675_1_IS_MAX31865 && !defined(MAX31865_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) #define MAX31865_CS2_PIN MAX6675_SS2_PIN #endif - #ifndef MAX31865_MOSI_PIN - #define MAX31865_MOSI_PIN MOSI_PIN - #endif - #ifndef MAX31865_MISO_PIN - #define MAX31865_MISO_PIN MAX6675_DO_PIN - #endif - #ifndef MAX31865_SCK_PIN - #define MAX31865_SCK_PIN MAX6675_SCK_PIN - #endif - #if MAX6675_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS) - #define HAS_MAX31865 1 - Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN - #if MAX31865_CS_PIN != MAX6675_SS_PIN - , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK - #endif - ); - #endif - #if MAX6675_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2) - #define HAS_MAX31865 1 - Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN - #if MAX31865_CS2_PIN != MAX6675_SS2_PIN - , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK - #endif - ); - #endif -#endif - -// -// Only needed for LPC176x boards -// -#if LPC1768_HAS_MAX31865 - #include - #if !defined(MAX31865_CS_PIN) && PIN_EXISTS(MAX6675_SS) - #define MAX31865_CS_PIN MAX6675_SS_PIN - #endif - #if !defined(MAX31865_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) - #define MAX31865_CS2_PIN MAX6675_SS2_PIN - #endif #ifndef MAX31865_MOSI_PIN #define MAX31865_MOSI_PIN MOSI_PIN #endif @@ -156,19 +114,19 @@ // // Only needed for LPC176x boards // -#if LPC1768_HAS_MAX6675 +#if MAX6675_HAS_MAX6675 #include - #if !defined(MAX6675_CS_PIN) && PIN_EXISTS(MAX6675_SS) + #if MAX6675_0_IS_MAX6675 && !defined(MAX6675_CS_PIN) && PIN_EXISTS(MAX6675_SS) #define MAX6675_CS_PIN MAX6675_SS_PIN #endif - #if !defined(MAX6675_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) + #if MAX6675_1_IS_MAX6675 && !defined(MAX6675_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) #define MAX6675_CS2_PIN MAX6675_SS2_PIN #endif #if !defined(MAX6675_MISO_PIN) && PIN_EXISTS(MAX6675_DO) #define MAX6675_MISO_PIN MAX6675_DO_PIN #endif #if MAX6675_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) - #define HAS_MAX6675_FOR_LPC 1 + #define HAS_MAX6675_TEMP 1 MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN #if MAX6675_USES_SW_LIB && PIN_EXISTS(MAX6675_SCK) , MAX6675_SCK_PIN, MAX6675_MISO_PIN @@ -176,7 +134,7 @@ ); #endif #if MAX6675_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) - #define HAS_MAX6675_FOR_LPC 1 + #define HAS_MAX6675_TEMP 1 MAX6675 max6675_1 = MAX6675(MAX6675_CS2_PIN #if MAX6675_USES_SW_LIB && PIN_EXISTS(MAX6675_SCK) , MAX6675_SCK_PIN, MAX6675_MISO_PIN @@ -186,7 +144,7 @@ #endif -#if EITHER(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && !HAS_MAX31855 && !HAS_MAX31865 && !HAS_MAX6675_FOR_LPC +#if EITHER(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && !HAS_MAX31855 && !HAS_MAX31865 && !HAS_MAX6675_TEMP #define MAX6675_SEPARATE_SPI 1 #endif @@ -1812,7 +1770,7 @@ void Temperature::init() { TERN_(MAX6675_0_IS_MAX31855, max31855_0.begin()); TERN_(MAX6675_1_IS_MAX31855, max31855_1.begin()); #endif - #if HAS_MAX6675_FOR_LPC + #if HAS_MAX6675_TEMP TERN_(MAX6675_0_IS_MAX6675, max6675_0.begin()); TERN_(MAX6675_1_IS_MAX6675, max6675_1.begin()); #endif @@ -2364,19 +2322,19 @@ void Temperature::disable_all_heaters() { // // TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used. // - #if !MAX6675_SEPARATE_SPI && !HAS_MAX31865 && !HAS_MAX31855 && !HAS_MAX6675_FOR_LPC + #if !MAX6675_SEPARATE_SPI && !HAS_MAX31865 && !HAS_MAX31855 && !HAS_MAX6675_TEMP spiBegin(); spiInit(MAX6675_SPEED_BITS); #endif - #if !HAS_MAX31865 && !HAS_MAX31855 && !HAS_MAX6675_FOR_LPC + #if !HAS_MAX31865 && !HAS_MAX31855 && !HAS_MAX6675_TEMP MAX6675_WRITE(LOW); // enable TT_MAX6675 DELAY_NS(100); // Ensure 100ns delay #endif // Read a big-endian temperature value max6675_temp = 0; - #if !HAS_MAX31865 && !HAS_MAX31855 && !HAS_MAX6675_FOR_LPC + #if !HAS_MAX31865 && !HAS_MAX31855 && !HAS_MAX6675_TEMP for (uint8_t i = sizeof(max6675_temp); i--;) { max6675_temp |= TERN(MAX6675_SEPARATE_SPI, max6675_spi.receive(), spiRec()); if (i > 0) max6675_temp <<= 8; // shift left if not the last byte @@ -2391,89 +2349,65 @@ void Temperature::disable_all_heaters() { #if HAS_MAX31865 Adafruit_MAX31865 &max865ref = MAX6675_SEL(max31865_0, max31865_1); + max6675_temp = max865ref.readRTD_with_Fault(); #endif - #if HAS_MAX6675_FOR_LPC + #if HAS_MAX6675_TEMP MAX6675 &max6675ref = MAX6675_SEL(max6675_0, max6675_1); + max6675_temp = max6675ref.readRaw16(); #endif - #if LPC1768_HAS_MAX31865 - max6675_temp = max865ref.readRTD_with_Fault(); - #elif HAS_MAX6675_FOR_LPC - max6675_temp = max6675ref.readRaw16(); - #else - // At the present time we do not have the ability to set the MAX31865 HIGH threshold - // or thr LOW threshold, so no need to check for them, zero these bits out - const uint8_t fault_31865 = TERN1(HAS_MAX31865, (max865ref.readFault() & 0x3FU)); - #endif + // At the present time we do not have the ability to set the MAX31865 HIGH threshold + // or thr LOW threshold, so no need to check for them, zero these bits out + const uint8_t fault_31865 = TERN1(HAS_MAX31865, (max865ref.readFault() & 0x3FU)); - #if LPC1768_HAS_MAX31865 || HAS_MAX6675_FOR_LPC - if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK)) { - #else - if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK) && fault_31865) { - #endif - max6675_errors[hindex]++; - if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { - SERIAL_ERROR_START(); - SERIAL_ECHOPGM("Temp measurement error! "); - #if MAX6675_ERROR_MASK == 7 - SERIAL_ECHOPGM("MAX31855 "); - if (max6675_temp & 1) - SERIAL_ECHOLNPAIR("Fault :(", max6675_temp & 1 ,") >> Open Circuit"); - else if (max6675_temp & 2) - SERIAL_ECHOLNPAIR("Fault : (", max6675_temp & 2 ,") >> Short to GND"); - else if (max6675_temp & 4) - SERIAL_ECHOLNPAIR("Fault : (", max6675_temp & 4 ,") >> Short to VCC"); - #elif MAX6675_HAS_MAX31865 - max865ref.clearFault(); - if (fault_31865) { - SERIAL_ECHOLNPAIR("\nMAX31865 Fault :(", fault_31865, ") >>"); - if (fault_31865 & MAX31865_FAULT_HIGHTHRESH) - SERIAL_ECHOLNPGM("RTD High Threshold"); - if (fault_31865 & MAX31865_FAULT_LOWTHRESH) - SERIAL_ECHOLNPGM("RTD Low Threshold"); - if (fault_31865 & MAX31865_FAULT_REFINLOW) - SERIAL_ECHOLNPGM("REFIN- > 0.85 x Bias"); - if (fault_31865 & MAX31865_FAULT_REFINHIGH) - SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); - if (fault_31865 & MAX31865_FAULT_RTDINLOW) - SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); - if (fault_31865 & MAX31865_FAULT_OVUV) - SERIAL_ECHOLNPGM("Under/Over voltage"); - } - #elif LPC1768_HAS_MAX31865 - const uint8_t fault_31865 = max865ref.readFault(); + + if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK) && fault_31865) { + max6675_errors[hindex]++; + if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { + SERIAL_ERROR_START(); + SERIAL_ECHOPGM("Temp measurement error! "); + #if MAX6675_ERROR_MASK == 7 + SERIAL_ECHOPGM("MAX31855 "); + if (max6675_temp & 1) + SERIAL_ECHOLNPAIR("Fault :(", max6675_temp & 1 ,") >> Open Circuit"); + else if (max6675_temp & 2) + SERIAL_ECHOLNPAIR("Fault : (", max6675_temp & 2 ,") >> Short to GND"); + else if (max6675_temp & 4) + SERIAL_ECHOLNPAIR("Fault : (", max6675_temp & 4 ,") >> Short to VCC"); + #elif MAX6675_HAS_MAX31865 + const uint8_t fault_31865 = max865ref.readFault(); max865ref.clearFault(); - if (fault_31865) { - SERIAL_ECHOLNPAIR("\nMAX31865 Fault :(", fault_31865, ") >>"); - if (fault_31865 & MAX31865_FAULT_HIGHTHRESH) - SERIAL_ECHOLNPGM("RTD High Threshold"); - if (fault_31865 & MAX31865_FAULT_LOWTHRESH) - SERIAL_ECHOLNPGM("RTD Low Threshold"); - if (fault_31865 & MAX31865_FAULT_REFINLOW) - SERIAL_ECHOLNPGM("REFIN- > 0.85 x Bias"); - if (fault_31865 & MAX31865_FAULT_REFINHIGH) - SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); - if (fault_31865 & MAX31865_FAULT_RTDINLOW) - SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); - if (fault_31865 & MAX31865_FAULT_OVUV) - SERIAL_ECHOLNPGM("Under/Over voltage"); - } - #else - SERIAL_ECHOPGM("MAX6675 "); - SERIAL_ECHOLNPGM("Open Circuit"); - #endif + if (fault_31865) { + SERIAL_ECHOLNPAIR("\nMAX31865 Fault :(", fault_31865, ") >>"); + if (fault_31865 & MAX31865_FAULT_HIGHTHRESH) + SERIAL_ECHOLNPGM("RTD High Threshold"); + if (fault_31865 & MAX31865_FAULT_LOWTHRESH) + SERIAL_ECHOLNPGM("RTD Low Threshold"); + if (fault_31865 & MAX31865_FAULT_REFINLOW) + SERIAL_ECHOLNPGM("REFIN- > 0.85 x Bias"); + if (fault_31865 & MAX31865_FAULT_REFINHIGH) + SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); + if (fault_31865 & MAX31865_FAULT_RTDINLOW) + SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); + if (fault_31865 & MAX31865_FAULT_OVUV) + SERIAL_ECHOLNPGM("Under/Over voltage"); + } + #else + SERIAL_ECHOPGM("MAX6675 "); + SERIAL_ECHOLNPGM("Open Circuit"); + #endif - // Thermocouple open - max6675_temp = 4 * MAX6675_SEL(HEATER_0_MAX6675_TMAX, HEATER_1_MAX6675_TMAX); - } - else - max6675_temp >>= MAX6675_DISCARD_BITS; + // Thermocouple open + max6675_temp = 4 * MAX6675_SEL(HEATER_0_MAX6675_TMAX, HEATER_1_MAX6675_TMAX); } - else { + else max6675_temp >>= MAX6675_DISCARD_BITS; - max6675_errors[hindex] = 0; - } + } + else { + max6675_temp >>= MAX6675_DISCARD_BITS; + max6675_errors[hindex] = 0; + } #if MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855 if (max6675_temp & 0x00002000) max6675_temp |= 0xFFFFC000; // Support negative temperature @@ -2481,8 +2415,6 @@ void Temperature::disable_all_heaters() { // Return the RTD resistance for MAX31865 for display in SHOW_TEMP_ADC_VALUES #if MAX6675_HAS_MAX31865 - max6675_temp = (uint32_t(max865ref.readRTD()) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; - #elif LPC1768_HAS_MAX31865 max6675_temp = (uint32_t(max6675_temp) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; #endif diff --git a/platformio.ini b/platformio.ini index b039adbfd310..21cf619484b0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -224,11 +224,10 @@ HAS_TMC26X = TMC26XStepper=https://github.com/trinamic/TMC26XSteppe HAS_L64XX = Arduino-L6470@0.8.0 src_filter=+ + + NEOPIXEL_LED = Adafruit NeoPixel@1.5.0 - src_filter=+ -MAX6675_HAS_MAX31865 = Adafruit MAX31865 library@~1.1.0 -LPC1768_HAS_MAX31865 = https://github.com/GadgetAngel/Adafruit-MAX31865-V1.1.0-Mod-M.git -LPC1768_HAS_MAX31855 = https://github.com/GadgetAngel/Adafruit-MAX31855-V1.0.3-Mod-M.git -LPC1768_HAS_MAX6675 = https://github.com/GadgetAngel/MAX6675-V1.1.0-Mod-M.git + src_filter=+ +MAX6675_HAS_MAX31865 = https://github.com/GadgetAngel/Adafruit-MAX31865-V1.1.0-Mod-M.git # Added ARDUINOLPC constant and added two new methods: .readRTD_with_Fault method and .readRTD_Resistance method +MAX6675_HAS_MAX31855 = https://github.com/GadgetAngel/Adafruit-MAX31855-V1.0.3-Mod-M.git # Added ARDUNIOLPC constant and change order of parms on SW obj to (CS, DO, SCK) instead of (SCK, CS, DO) added .readRaw32 method +MAX6675_HAS_MAX6675 = https://github.com/GadgetAngel/MAX6675-V1.1.0-Mod-M.git # Added ARDUNIOLPC constant and change order of parms on SW obj to (CS, DO, SCK) instead of (SCK, CS, DO) added a .begin method; Added interface obj using hardware SPI; and Added .readRaw16 method USES_LIQUIDCRYSTAL = LiquidCrystal@1.5.0 USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4 USES_LIQUIDTWI2 = LiquidTWI2@1.2.7 From 4ac3222324c3e3b34cd1fc6caa4d609c74102c76 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Sat, 12 Dec 2020 19:05:41 -0500 Subject: [PATCH 04/44] removed comment --- platformio.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index 21cf619484b0..9c3e8ef0185a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -225,9 +225,9 @@ HAS_L64XX = Arduino-L6470@0.8.0 src_filter=+ + + NEOPIXEL_LED = Adafruit NeoPixel@1.5.0 src_filter=+ -MAX6675_HAS_MAX31865 = https://github.com/GadgetAngel/Adafruit-MAX31865-V1.1.0-Mod-M.git # Added ARDUINOLPC constant and added two new methods: .readRTD_with_Fault method and .readRTD_Resistance method -MAX6675_HAS_MAX31855 = https://github.com/GadgetAngel/Adafruit-MAX31855-V1.0.3-Mod-M.git # Added ARDUNIOLPC constant and change order of parms on SW obj to (CS, DO, SCK) instead of (SCK, CS, DO) added .readRaw32 method -MAX6675_HAS_MAX6675 = https://github.com/GadgetAngel/MAX6675-V1.1.0-Mod-M.git # Added ARDUNIOLPC constant and change order of parms on SW obj to (CS, DO, SCK) instead of (SCK, CS, DO) added a .begin method; Added interface obj using hardware SPI; and Added .readRaw16 method +MAX6675_HAS_MAX31865 = https://github.com/GadgetAngel/Adafruit-MAX31865-V1.1.0-Mod-M.git +MAX6675_HAS_MAX31855 = https://github.com/GadgetAngel/Adafruit-MAX31855-V1.0.3-Mod-M.git +MAX6675_HAS_MAX6675 = https://github.com/GadgetAngel/MAX6675-V1.1.0-Mod-M.git USES_LIQUIDCRYSTAL = LiquidCrystal@1.5.0 USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4 USES_LIQUIDTWI2 = LiquidTWI2@1.2.7 From 710d7e24483314b4b146270604f47cd753bcb181 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Sat, 12 Dec 2020 19:12:53 -0500 Subject: [PATCH 05/44] used the correct case on header file --- Marlin/src/module/temperature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 0c106633190a..1c2abebec532 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -115,7 +115,7 @@ // Only needed for LPC176x boards // #if MAX6675_HAS_MAX6675 - #include + #include #if MAX6675_0_IS_MAX6675 && !defined(MAX6675_CS_PIN) && PIN_EXISTS(MAX6675_SS) #define MAX6675_CS_PIN MAX6675_SS_PIN #endif From 49ff321edc602ff35041824c1a6459d7340c1f5c Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Sun, 13 Dec 2020 00:03:39 -0500 Subject: [PATCH 06/44] updated lib --- Marlin/src/module/temperature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 1c2abebec532..d37d954d7785 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -219,7 +219,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, /** * Macros to include the heater id in temp errors. The compiler's dead-code * elimination should (hopefully) optimize out the unused strings. - */ + */ #if HAS_HEATED_BED #define _BED_PSTR(h) (h) == H_BED ? GET_TEXT(MSG_BED) : From 268c70bf319ecf8d3ed9ca180e9a5d9a725a931c Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Sat, 12 Dec 2020 19:12:53 -0500 Subject: [PATCH 07/44] used the correct case on header file --- Marlin/src/module/temperature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 0c106633190a..1c2abebec532 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -115,7 +115,7 @@ // Only needed for LPC176x boards // #if MAX6675_HAS_MAX6675 - #include + #include #if MAX6675_0_IS_MAX6675 && !defined(MAX6675_CS_PIN) && PIN_EXISTS(MAX6675_SS) #define MAX6675_CS_PIN MAX6675_SS_PIN #endif From 0ab9874816f5a21f60941685176d4b0023e4e017 Mon Sep 17 00:00:00 2001 From: ellensp Date: Sun, 13 Dec 2020 07:59:17 +1300 Subject: [PATCH 08/44] Add HAS_PIN_27_BOARD for CREALITY_V4 (#20446) Co-authored-by: ellensp --- Marlin/src/pins/stm32f1/pins_CREALITY_V4.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index 44be73029d8e..69371f0f73df 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -48,17 +48,21 @@ #endif #if ENABLED(IIC_BL24CXX_EEPROM) - #define IIC_EEPROM_SDA PA11 - #define IIC_EEPROM_SCL PA12 - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb (24C16) + #define IIC_EEPROM_SDA PA11 + #define IIC_EEPROM_SCL PA12 + #define MARLIN_EEPROM_SIZE 0x800 // 2Kb (24C16) #elif ENABLED(SDCARD_EEPROM_EMULATION) - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb + #define MARLIN_EEPROM_SIZE 0x800 // 2Kb #endif // // Servos // -#define SERVO0_PIN PB0 // BLTouch OUT +#ifndef HAS_PIN_27_BOARD + #define SERVO0_PIN PB0 // BLTouch OUT +#else + #define SERVO0_PIN PC6 +#endif // // Limit Switches @@ -156,7 +160,9 @@ #define BTN_EN1 PB10 #define BTN_EN2 PB14 - #define BEEPER_PIN PC6 + #ifndef HAS_PIN_27_BOARD + #define BEEPER_PIN PC6 + #endif #elif ENABLED(VET6_12864_LCD) From 9c8ce6c151c00d1ca2b0e065ce81c16dfea6085c Mon Sep 17 00:00:00 2001 From: qwewer0 <57561110+qwewer0@users.noreply.github.com> Date: Sat, 12 Dec 2020 20:03:28 +0100 Subject: [PATCH 09/44] Improve ASSISTED_TRAMMING_WIZARD probe stowing (#20437) * When BLTOUCH_HS_MODE enabled, stow pin before user interaction * For all probes, ensure probe stows at end of wizard --- Marlin/src/lcd/menu/menu_tramming.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index c9043a118bd8..a0dad20e6247 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -43,11 +43,9 @@ float z_measured[G35_PROBE_COUNT] = { 0 }; static uint8_t tram_index = 0; bool probe_single_point() { - // In BLTOUCH HS mode, the probe travels in a deployed state. - // Users of Tramming Wizard might have a badly misaligned bed, so raise Z by the - // length of the deployed pin (BLTOUCH stroke < 7mm) - do_blocking_move_to_z((Z_CLEARANCE_BETWEEN_PROBES) + TERN0(BLTOUCH_HS_MODE, 7)); - const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[tram_index], PROBE_PT_RAISE, 0, true); + do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES)); + //Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety + const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[tram_index], TERN(BLTOUCH_HS_MODE, PROBE_PT_STOW, PROBE_PT_RAISE), 0, true); DEBUG_ECHOLNPAIR("probe_single_point: ", z_probed_height, "mm"); z_measured[tram_index] = z_probed_height; @@ -81,7 +79,10 @@ void tramming_wizard_menu() { LOOP_L_N(i, G35_PROBE_COUNT) SUBMENU_N_P(i, (char*)pgm_read_ptr(&tramming_point_name[i]), []{ _menu_single_probe(MenuItemBase::itemIndex); }); - ACTION_ITEM(MSG_BUTTON_DONE, []{ ui.goto_previous_screen_no_defer(); }); + ACTION_ITEM(MSG_BUTTON_DONE, []{ + probe.stow(); // Stow before exiting Tramming Wizard + ui.goto_previous_screen_no_defer(); + }); END_MENU(); } From 5a7fc64502e7537afbde56dec60539270da3850d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 12 Dec 2020 20:29:42 -0600 Subject: [PATCH 10/44] Relocate IS_MELZI define --- Marlin/src/core/boards.h | 2 -- Marlin/src/pins/sanguino/pins_MELZI.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index dcd1a3938462..7ac629ea334e 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -407,6 +407,4 @@ #define _MB_1(B) (defined(BOARD_##B) && MOTHERBOARD==BOARD_##B) #define MB(V...) DO(MB,||,V) -#define IS_MELZI MB(MELZI, MELZI_CREALITY, MELZI_MAKR3D, MELZI_MALYAN, MELZI_TRONXY, MELZI_V2) - #define IS_LPC1768 MB(BTT_SKR_V1_3, BTT_SKR_V1_4, BTT_SKR_V1_4_TURBO) \ No newline at end of file diff --git a/Marlin/src/pins/sanguino/pins_MELZI.h b/Marlin/src/pins/sanguino/pins_MELZI.h index 887aae18584a..de4dd1b01d10 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI.h +++ b/Marlin/src/pins/sanguino/pins_MELZI.h @@ -29,4 +29,6 @@ #define BOARD_INFO_NAME "Melzi" #endif +#define IS_MELZI 1 + #include "pins_SANGUINOLOLU_12.h" From 1ba54456949f40c5a5e6d5f150e423d210fb62a4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 12 Dec 2020 23:21:32 -0600 Subject: [PATCH 11/44] Some cleanup --- Marlin/src/MarlinCore.cpp | 27 +++++++++++++-------------- Marlin/src/core/boards.h | 2 -- Marlin/src/inc/Conditionals_post.h | 14 +++++++------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 246e604e8088..6589e011793a 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1012,34 +1012,33 @@ void setup() { SETUP_RUN(HAL_init()); -// Init and disable SPI thermocouples + // Init and disable SPI thermocouples #if HEATER_0_USES_MAX6675 && PIN_EXISTS(MAX6675_SS) - OUT_WRITE(MAX6675_SS_PIN, HIGH); // Disable + OUT_WRITE(MAX6675_SS_PIN, HIGH); #endif #if HEATER_1_USES_MAX6675 && PIN_EXISTS(MAX6675_SS2) - OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable + OUT_WRITE(MAX6675_SS2_PIN, HIGH); + #endif + #if HEATER_0_USES_MAX6675 && PIN_EXISTS(MAX6675_CS) + OUT_WRITE(MAX6675_CS_PIN, HIGH); + #endif + #if HEATER_1_USES_MAX6675 && PIN_EXISTS(MAX6675_CS2) + OUT_WRITE(MAX6675_CS2_PIN, HIGH); #endif #if HEATER_0_USES_MAX6675 && PIN_EXISTS(MAX31855_CS) - OUT_WRITE(MAX31855_CS_PIN, HIGH); // Disable + OUT_WRITE(MAX31855_CS_PIN, HIGH); #endif #if HEATER_1_USES_MAX6675 && PIN_EXISTS(MAX31855_CS2) - OUT_WRITE(MAX31855_CS2_PIN, HIGH); // Disable + OUT_WRITE(MAX31855_CS2_PIN, HIGH); #endif #if HEATER_0_USES_MAX6675 && PIN_EXISTS(MAX31865_CS) - OUT_WRITE(MAX31865_CS_PIN, HIGH); // Disable + OUT_WRITE(MAX31865_CS_PIN, HIGH); #endif #if HEATER_1_USES_MAX6675 && PIN_EXISTS(MAX31865_CS2) - OUT_WRITE(MAX31865_CS2_PIN, HIGH); // Disable - #endif - - #if HEATER_0_USES_MAX6675 && PIN_EXISTS(MAX6675_CS) - OUT_WRITE(MAX6675_CS_PIN, HIGH); // Disable + OUT_WRITE(MAX31865_CS2_PIN, HIGH); #endif - #if HEATER_1_USES_MAX6675 && PIN_EXISTS(MAX6675_CS2) - OUT_WRITE(MAX6675_CS2_PIN, HIGH); // Disable - #endif #if HAS_L64XX SETUP_RUN(L64xxManager.init()); // Set up SPI, init drivers diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 7ac629ea334e..3d0051e96c91 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -406,5 +406,3 @@ #define _MB_1(B) (defined(BOARD_##B) && MOTHERBOARD==BOARD_##B) #define MB(V...) DO(MB,||,V) - -#define IS_LPC1768 MB(BTT_SKR_V1_3, BTT_SKR_V1_4, BTT_SKR_V1_4_TURBO) \ No newline at end of file diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 14415cb5d6bc..f5cc7c90e0d3 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -473,7 +473,7 @@ #undef HEATER_1_MAXTEMP #endif -#if (MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855) +#if MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855 #define MAX6675_HAS_MAX31855 1 #if PIN_EXISTS(MAX6675_DO) || PIN_EXISTS(MAX31855_MISO) #define MAX31855_USES_DO 1 @@ -486,7 +486,7 @@ #endif #endif -#if (MAX6675_0_IS_MAX31865 || MAX6675_1_IS_MAX31865) +#if MAX6675_0_IS_MAX31865 || MAX6675_1_IS_MAX31865 #define MAX6675_HAS_MAX31865 1 #if PIN_EXISTS(MAX6675_DO) || PIN_EXISTS(MAX31865_MISO) #define MAX31865_USES_DO 1 @@ -496,20 +496,20 @@ #endif #if MAX31865_USES_DO && MAX31865_USES_SCK #define MAX31865_USES_SW_LIB 1 - #endif + #endif #endif -#if (MAX6675_0_IS_MAX6675 || MAX6675_1_IS_MAX6675) - #define MAX6675_HAS_MAX6675 1 +#if MAX6675_0_IS_MAX6675 || MAX6675_1_IS_MAX6675 + #define MAX6675_HAS_MAX6675 1 #if PIN_EXISTS(MAX6675_DO) || PIN_EXISTS(MAX6675_MISO) #define MAX6675_USES_DO 1 #endif - #if PIN_EXISTS(MAX6675_SCK) + #if PIN_EXISTS(MAX6675_SCK) #define MAX6675_USES_SCK 1 #endif #if MAX6675_USES_DO && MAX6675_USES_SCK #define MAX6675_USES_SW_LIB 1 - #endif + #endif #endif #if TEMP_SENSOR_2 == -4 From 6c1379f237b6bbd8aae760e63b681fa4b9398708 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Sun, 13 Dec 2020 00:57:02 -0500 Subject: [PATCH 12/44] updated MAX6675 lib --- Marlin/src/module/temperature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index d37d954d7785..a876932092f0 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -219,7 +219,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, /** * Macros to include the heater id in temp errors. The compiler's dead-code * elimination should (hopefully) optimize out the unused strings. - */ + */ #if HAS_HEATED_BED #define _BED_PSTR(h) (h) == H_BED ? GET_TEXT(MSG_BED) : From ec0ce581f9a44fe7f15b7cda86e7bc715acc2e91 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Sun, 13 Dec 2020 01:06:48 -0500 Subject: [PATCH 13/44] fix MAX6675 lib --- Marlin/src/module/temperature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index a876932092f0..a829c80a69ee 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -219,7 +219,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, /** * Macros to include the heater id in temp errors. The compiler's dead-code * elimination should (hopefully) optimize out the unused strings. - */ + */ #if HAS_HEATED_BED #define _BED_PSTR(h) (h) == H_BED ? GET_TEXT(MSG_BED) : From 3726ea2fed27b2efd16bda45e3d45e091f59a8fa Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Sun, 13 Dec 2020 01:37:16 -0500 Subject: [PATCH 14/44] removed outdated comment --- Marlin/src/module/temperature.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index a829c80a69ee..dd5883bd46e3 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -111,9 +111,6 @@ #endif #endif -// -// Only needed for LPC176x boards -// #if MAX6675_HAS_MAX6675 #include #if MAX6675_0_IS_MAX6675 && !defined(MAX6675_CS_PIN) && PIN_EXISTS(MAX6675_SS) From b72aedfcee49d1a3f0cf12c9f6b01803282241b0 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Sun, 13 Dec 2020 01:41:08 -0500 Subject: [PATCH 15/44] Corrected the order of Parms on MAX6675 lib call --- Marlin/src/module/temperature.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index dd5883bd46e3..e82efa4da025 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -126,7 +126,7 @@ #define HAS_MAX6675_TEMP 1 MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN #if MAX6675_USES_SW_LIB && PIN_EXISTS(MAX6675_SCK) - , MAX6675_SCK_PIN, MAX6675_MISO_PIN + , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif ); #endif @@ -134,7 +134,7 @@ #define HAS_MAX6675_TEMP 1 MAX6675 max6675_1 = MAX6675(MAX6675_CS2_PIN #if MAX6675_USES_SW_LIB && PIN_EXISTS(MAX6675_SCK) - , MAX6675_SCK_PIN, MAX6675_MISO_PIN + , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif ); #endif From b5a48edba8d57c7d7568716bbf08132e4ec0999c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 13 Dec 2020 19:35:53 -0600 Subject: [PATCH 16/44] Some cleanup --- Marlin/src/inc/Conditionals_post.h | 6 +++--- Marlin/src/inc/SanityCheck.h | 14 +++++++------- Marlin/src/module/temperature.cpp | 28 ++++++++++++++-------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index f5cc7c90e0d3..796eea1d958f 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -479,7 +479,7 @@ #define MAX31855_USES_DO 1 #endif #if PIN_EXISTS(MAX6675_SCK) || PIN_EXISTS(MAX31855_SCK) - #define MAX31855_USES_SCK 1 + #define MAX31855_USES_SCK 1 #endif #if MAX31855_USES_DO && MAX31855_USES_SCK #define MAX31855_USES_SW_LIB 1 @@ -492,7 +492,7 @@ #define MAX31865_USES_DO 1 #endif #if PIN_EXISTS(MAX6675_SCK) || PIN_EXISTS(MAX31865_SCK) - #define MAX31865_USES_SCK 1 + #define MAX31865_USES_SCK 1 #endif #if MAX31865_USES_DO && MAX31865_USES_SCK #define MAX31865_USES_SW_LIB 1 @@ -505,7 +505,7 @@ #define MAX6675_USES_DO 1 #endif #if PIN_EXISTS(MAX6675_SCK) - #define MAX6675_USES_SCK 1 + #define MAX6675_USES_SCK 1 #endif #if MAX6675_USES_DO && MAX6675_USES_SCK #define MAX6675_USES_SW_LIB 1 diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 8b9cefd90d3b..f49ea194f208 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1698,8 +1698,8 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal /** * Pins and Sensor IDs must be set for each heater */ -#if HEATER_0_USES_MAX6675 && !PIN_EXISTS(MAX6675_SS) && !(PIN_EXISTS(MAX31855_CS) || PIN_EXISTS(MAX31865_CS) || PIN_EXISTS(MAX6675_CS)) - #error "MAX6675_SS_PIN (required for TEMP_SENSOR_0) not defined for this board." +#if HEATER_0_USES_MAX6675 && !ANY_PIN(MAX6675_SS, MAX31855_CS, MAX31865_CS, MAX6675_CS) + #error "TEMP_SENSOR_0 requires a MAX6675_SS2_PIN, MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN." #elif HAS_HOTEND && !HAS_TEMP_HOTEND && !HEATER_0_DUMMY_THERMISTOR #error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board." #elif EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) && !HAS_HEATER_1 @@ -1707,12 +1707,12 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #endif #if HAS_MULTI_HOTEND - #if HEATER_1_USES_MAX6675 && !PIN_EXISTS(MAX6675_SS2) && !(PIN_EXISTS(MAX31855_CS2) || PIN_EXISTS(MAX31865_CS2) || PIN_EXISTS(MAX6675_CS2)) - #error "MAX6675_SS2_PIN (required for TEMP_SENSOR_1) not defined for this board." + #if HEATER_1_USES_MAX6675 && !ANY_PIN(MAX6675_SS2, MAX31855_CS2, MAX31865_CS2, MAX6675_CS2) + #error "TEMP_SENSOR_1 requires a MAX6675_SS2_PIN, MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN." #elif TEMP_SENSOR_1 == 0 #error "TEMP_SENSOR_1 is required with 2 or more HOTENDS." #elif !ANY_PIN(TEMP_1, MAX6675_SS2) && !HEATER_1_DUMMY_THERMISTOR - #error "TEMP_1_PIN not defined for this board." + #error "TEMP_1_PIN or MAX6675_SS2_PIN not defined for this board." #elif ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) #error "HOTENDS must be 1 with TEMP_SENSOR_1_AS_REDUNDANT." #endif @@ -1882,7 +1882,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #if !HAS_HEATER_0 && EXTRUDERS #error "HEATER_0_PIN not defined for this board." #elif !ANY_PIN(TEMP_0, MAX6675_SS) - #error "TEMP_0_PIN not defined for this board." + #error "TEMP_0_PIN or MAX6675_SS not defined for this board." #elif ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR)) #error "E0_STEP_PIN or E0_DIR_PIN not defined for this board." #elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE)) @@ -2657,7 +2657,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #elif ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) #error "SENSORLESS_PROBING cannot be used with Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN." #elif ENABLED(USE_PROBE_FOR_Z_HOMING) - #error "SENSORLESS_PROBING cannot be used with USE_PROBE_FOR_Z_HOMING." + #error "SENSORLESS_PROBING cannot be used with USE_PROBE_FOR_Z_HOMING." #elif !Z_SENSORLESS #error "SENSORLESS_PROBING requires a TMC stepper driver with StallGuard on Z." #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index e82efa4da025..d03be1abaeaa 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -72,7 +72,7 @@ #if MAX31855_USES_SW_LIB , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK #endif - ); + ); #endif #endif @@ -86,7 +86,7 @@ #endif #ifndef MAX31865_MOSI_PIN #define MAX31865_MOSI_PIN MOSI_PIN - #endif + #endif #if !defined(MAX31865_MISO_PIN) && PIN_EXISTS(MAX6675_DO) #define MAX31865_MISO_PIN MAX6675_DO_PIN #endif @@ -124,7 +124,7 @@ #endif #if MAX6675_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) #define HAS_MAX6675_TEMP 1 - MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN + MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN #if MAX6675_USES_SW_LIB && PIN_EXISTS(MAX6675_SCK) , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif @@ -136,7 +136,7 @@ #if MAX6675_USES_SW_LIB && PIN_EXISTS(MAX6675_SCK) , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif - ); + ); #endif #endif @@ -216,7 +216,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, /** * Macros to include the heater id in temp errors. The compiler's dead-code * elimination should (hopefully) optimize out the unused strings. - */ + */ #if HAS_HEATED_BED #define _BED_PSTR(h) (h) == H_BED ? GET_TEXT(MSG_BED) : @@ -2325,8 +2325,8 @@ void Temperature::disable_all_heaters() { #endif #if !HAS_MAX31865 && !HAS_MAX31855 && !HAS_MAX6675_TEMP - MAX6675_WRITE(LOW); // enable TT_MAX6675 - DELAY_NS(100); // Ensure 100ns delay + MAX6675_WRITE(LOW); // enable TT_MAX6675 + DELAY_NS(100); // Ensure 100ns delay #endif // Read a big-endian temperature value @@ -2340,8 +2340,8 @@ void Temperature::disable_all_heaters() { #endif #if HAS_MAX31855 - Adafruit_MAX31855 &max855ref = MAX6675_SEL(max31855_0, max31855_1); - max6675_temp = max855ref.readRaw32(); + Adafruit_MAX31855 &max855ref = MAX6675_SEL(max31855_0, max31855_1); + max6675_temp = max855ref.readRaw32(); #endif #if HAS_MAX31865 @@ -2353,8 +2353,8 @@ void Temperature::disable_all_heaters() { MAX6675 &max6675ref = MAX6675_SEL(max6675_0, max6675_1); max6675_temp = max6675ref.readRaw16(); #endif - - // At the present time we do not have the ability to set the MAX31865 HIGH threshold + + // At the present time we do not have the ability to set the MAX31865 HIGH threshold // or thr LOW threshold, so no need to check for them, zero these bits out const uint8_t fault_31865 = TERN1(HAS_MAX31865, (max865ref.readFault() & 0x3FU)); @@ -2373,8 +2373,8 @@ void Temperature::disable_all_heaters() { else if (max6675_temp & 4) SERIAL_ECHOLNPAIR("Fault : (", max6675_temp & 4 ,") >> Short to VCC"); #elif MAX6675_HAS_MAX31865 - const uint8_t fault_31865 = max865ref.readFault(); - max865ref.clearFault(); + const uint8_t fault_31865 = max865ref.readFault(); + max865ref.clearFault(); if (fault_31865) { SERIAL_ECHOLNPAIR("\nMAX31865 Fault :(", fault_31865, ") >>"); if (fault_31865 & MAX31865_FAULT_HIGHTHRESH) @@ -2392,7 +2392,7 @@ void Temperature::disable_all_heaters() { } #else SERIAL_ECHOPGM("MAX6675 "); - SERIAL_ECHOLNPGM("Open Circuit"); + SERIAL_ECHOLNPGM("Open Circuit"); #endif // Thermocouple open From 692a088e876e26d05287c1d19de7624ef4877c32 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 13 Dec 2020 19:53:49 -0600 Subject: [PATCH 17/44] Fewer 'global' defines --- Marlin/src/inc/Conditionals_post.h | 29 ----------------------- Marlin/src/module/temperature.cpp | 38 ++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 42 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 796eea1d958f..d1028c6997f2 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -475,41 +475,12 @@ #if MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855 #define MAX6675_HAS_MAX31855 1 - #if PIN_EXISTS(MAX6675_DO) || PIN_EXISTS(MAX31855_MISO) - #define MAX31855_USES_DO 1 - #endif - #if PIN_EXISTS(MAX6675_SCK) || PIN_EXISTS(MAX31855_SCK) - #define MAX31855_USES_SCK 1 - #endif - #if MAX31855_USES_DO && MAX31855_USES_SCK - #define MAX31855_USES_SW_LIB 1 - #endif #endif - #if MAX6675_0_IS_MAX31865 || MAX6675_1_IS_MAX31865 #define MAX6675_HAS_MAX31865 1 - #if PIN_EXISTS(MAX6675_DO) || PIN_EXISTS(MAX31865_MISO) - #define MAX31865_USES_DO 1 - #endif - #if PIN_EXISTS(MAX6675_SCK) || PIN_EXISTS(MAX31865_SCK) - #define MAX31865_USES_SCK 1 - #endif - #if MAX31865_USES_DO && MAX31865_USES_SCK - #define MAX31865_USES_SW_LIB 1 - #endif #endif - #if MAX6675_0_IS_MAX6675 || MAX6675_1_IS_MAX6675 #define MAX6675_HAS_MAX6675 1 - #if PIN_EXISTS(MAX6675_DO) || PIN_EXISTS(MAX6675_MISO) - #define MAX6675_USES_DO 1 - #endif - #if PIN_EXISTS(MAX6675_SCK) - #define MAX6675_USES_SCK 1 - #endif - #if MAX6675_USES_DO && MAX6675_USES_SCK - #define MAX6675_USES_SW_LIB 1 - #endif #endif #if TEMP_SENSOR_2 == -4 diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index d03be1abaeaa..55939ed30ffb 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -58,8 +58,11 @@ #if !defined(MAX31855_SCK_PIN) && PIN_EXISTS(MAX6675_SCK) #define MAX31855_SCK_PIN MAX6675_SCK_PIN #endif + #if ANY_PIN(MAX6675_DO, MAX31855_MISO) && ANY_PIN(MAX6675_SCK, MAX31855_SCK) + #define MAX31855_USES_SW_LIB 1 + #endif #if MAX6675_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS) - #define HAS_MAX31855 1 + #define HAS_MAX31855_TEMP 1 Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855(MAX31855_CS_PIN #if MAX31855_USES_SW_LIB , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK @@ -67,7 +70,7 @@ ); #endif #if MAX6675_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2) - #define HAS_MAX31855 1 + #define HAS_MAX31855_TEMP 1 Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855(MAX31855_CS2_PIN #if MAX31855_USES_SW_LIB , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK @@ -93,8 +96,11 @@ #if !defined(MAX31865_SCK_PIN) && PIN_EXISTS(MAX6675_SCK) #define MAX31865_SCK_PIN MAX6675_SCK_PIN #endif + #if ANY_PIN(MAX6675_DO, MAX31865_MISO) && ANY_PIN(MAX6675_SCK, MAX31865_SCK) + #define MAX31865_USES_SW_LIB 1 + #endif #if MAX6675_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS) - #define HAS_MAX31865 1 + #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN #if MAX31865_USES_SW_LIB , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK @@ -102,7 +108,7 @@ ); #endif #if MAX6675_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2) - #define HAS_MAX31865 1 + #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN #if MAX31865_USES_SW_LIB , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK @@ -122,6 +128,9 @@ #if !defined(MAX6675_MISO_PIN) && PIN_EXISTS(MAX6675_DO) #define MAX6675_MISO_PIN MAX6675_DO_PIN #endif + #if ANY_PIN(MAX6675_DO, MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK) + #define MAX6675_USES_SW_LIB 1 + #endif #if MAX6675_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) #define HAS_MAX6675_TEMP 1 MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN @@ -140,8 +149,11 @@ #endif #endif +#if !HAS_MAX6675_TEMP && !HAS_MAX31855_TEMP && !HAS_MAX31865_TEMP + #define NO_THERMO_TEMPS 1 +#endif -#if EITHER(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && !HAS_MAX31855 && !HAS_MAX31865 && !HAS_MAX6675_TEMP +#if (HEATER_0_USES_MAX6675 || HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS #define MAX6675_SEPARATE_SPI 1 #endif @@ -1763,7 +1775,7 @@ void Temperature::init() { TERN_(MAX6675_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE TERN_(MAX6675_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE)); - #if HAS_MAX31855 + #if HAS_MAX31855_TEMP TERN_(MAX6675_0_IS_MAX31855, max31855_0.begin()); TERN_(MAX6675_1_IS_MAX31855, max31855_1.begin()); #endif @@ -2272,7 +2284,7 @@ void Temperature::disable_all_heaters() { #define MAX6675_ERROR_MASK 7 #define MAX6675_DISCARD_BITS 18 #define MAX6675_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64 - #elif HAS_MAX31865 + #elif HAS_MAX31865_TEMP static uint16_t max6675_temp = 2000; // From datasheet 16 bits D15-D0 #define MAX6675_ERROR_MASK 1 // D0 Bit not used #define MAX6675_DISCARD_BITS 1 // Data is in D15-D1 @@ -2319,19 +2331,19 @@ void Temperature::disable_all_heaters() { // // TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used. // - #if !MAX6675_SEPARATE_SPI && !HAS_MAX31865 && !HAS_MAX31855 && !HAS_MAX6675_TEMP + #if !MAX6675_SEPARATE_SPI && NO_THERMO_TEMPS spiBegin(); spiInit(MAX6675_SPEED_BITS); #endif - #if !HAS_MAX31865 && !HAS_MAX31855 && !HAS_MAX6675_TEMP + #if NO_THERMO_TEMPS MAX6675_WRITE(LOW); // enable TT_MAX6675 DELAY_NS(100); // Ensure 100ns delay #endif // Read a big-endian temperature value max6675_temp = 0; - #if !HAS_MAX31865 && !HAS_MAX31855 && !HAS_MAX6675_TEMP + #if NO_THERMO_TEMPS for (uint8_t i = sizeof(max6675_temp); i--;) { max6675_temp |= TERN(MAX6675_SEPARATE_SPI, max6675_spi.receive(), spiRec()); if (i > 0) max6675_temp <<= 8; // shift left if not the last byte @@ -2339,12 +2351,12 @@ void Temperature::disable_all_heaters() { MAX6675_WRITE(HIGH); // disable TT_MAX6675 #endif - #if HAS_MAX31855 + #if HAS_MAX31855_TEMP Adafruit_MAX31855 &max855ref = MAX6675_SEL(max31855_0, max31855_1); max6675_temp = max855ref.readRaw32(); #endif - #if HAS_MAX31865 + #if HAS_MAX31865_TEMP Adafruit_MAX31865 &max865ref = MAX6675_SEL(max31865_0, max31865_1); max6675_temp = max865ref.readRTD_with_Fault(); #endif @@ -2356,7 +2368,7 @@ void Temperature::disable_all_heaters() { // At the present time we do not have the ability to set the MAX31865 HIGH threshold // or thr LOW threshold, so no need to check for them, zero these bits out - const uint8_t fault_31865 = TERN1(HAS_MAX31865, (max865ref.readFault() & 0x3FU)); + const uint8_t fault_31865 = TERN1(HAS_MAX31865_TEMP, (max865ref.readFault() & 0x3FU)); if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK) && fault_31865) { From ccffad1733bd21a1209b6c3cf91b7c9e7c52021b Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Mon, 14 Dec 2020 01:52:38 -0500 Subject: [PATCH 18/44] Removed LPC1768_IS_SKRV1_3 directive --- Marlin/src/HAL/LPC1768/inc/SanityCheck.h | 6 +----- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index f94677d4c67a..1755a5c400a6 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -31,11 +31,7 @@ /** * Detect an old pins file by checking for old ADC pins values. */ -#if LPC1768_IS_SKRV1_3 - #define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && !(_CAT(P,_PIN) >= 0 && _CAT(P,_PIN) <= 3) //include P0_00 and P0_01 for SKR V1.3 board -#else - #define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && _CAT(P,_PIN) != 2 && _CAT(P,_PIN) != 3 -#endif +#define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && !(_CAT(P,_PIN) >= 0 && _CAT(P,_PIN) <= 3) #if _OLD_TEMP_PIN(TEMP_BED) #error "TEMP_BED_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)." #elif _OLD_TEMP_PIN(TEMP_0) 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 df19f1141cbe..c621f93a2ac5 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -22,7 +22,6 @@ #pragma once #define BOARD_INFO_NAME "BTT SKR V1.3" -#define LPC1768_IS_SKRV1_3 1 // // Trinamic Stallguard pins From 0d4336241ca692ac06204ce8bfa9493b1f1b6a67 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Mon, 14 Dec 2020 10:12:37 -0500 Subject: [PATCH 19/44] setup platformio.ini --- platformio.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 9c3e8ef0185a..7849190cc983 100644 --- a/platformio.ini +++ b/platformio.ini @@ -18,7 +18,8 @@ [platformio] src_dir = Marlin boards_dir = buildroot/share/PlatformIO/boards -default_envs = mega2560 +#LPC1768 LPC1769 BIGTREE_SKR_PRO BIGTREE_GTR_V1_0 STM32F103RET6_creality mega2560 STM32F103RC_btt +default_envs = LPC1769 include_dir = Marlin # From 87263e051fea065e38e8bbb5da43778801b6d705 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Mon, 14 Dec 2020 12:16:00 -0500 Subject: [PATCH 20/44] Created Compatibility Layer for MAX boards --- Marlin/Configuration.h | 112 +++++++------- Marlin/Configuration_adv.h | 43 +++--- Marlin/src/inc/Conditionals_post.h | 41 ++++++ Marlin/src/module/temperature.cpp | 95 +++++------- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h | 44 +++--- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 68 ++++----- Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h | 139 +++++++++++++++++- Marlin/src/pins/ramps/pins_RAMPS.h | 23 ++- .../pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h | 6 +- .../stm32f1/pins_BTT_SKR_MINI_E3_common.h | 22 +-- Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h | 54 ++++--- .../pins/stm32f4/pins_BTT_SKR_PRO_common.h | 34 +++-- 12 files changed, 437 insertions(+), 244 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index d528a97bf783..b6b70c9902e0 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -70,7 +70,7 @@ // @section info // Author info of this build printed to the host during boot and M115 -#define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. +#define STRING_CONFIG_H_AUTHOR "(GadgetAngel, Ender-3 Pro)" // Who made the changes. //#define CUSTOM_VERSION_FILE Version.h // Path from the root directory (no quotes) /** @@ -103,14 +103,14 @@ * * :[-1, 0, 1, 2, 3, 4, 5, 6, 7] */ -#define SERIAL_PORT 0 - +#define SERIAL_PORT -1 +//ga /** * Select a secondary serial port on the board to use for communication with the host. * Currently Ethernet (-2) is only supported on Teensy 4.1 boards. * :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7] - */ -//#define SERIAL_PORT_2 -1 + *///ga +//#define SERIAL_PORT_2 -1 //0 for SKR V1.3/V1.4 for TFT // 1 for SKR PRO // 3 for GTR /** * This setting determines the communication speed of the printer. @@ -121,18 +121,18 @@ * * :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] */ -#define BAUDRATE 250000 +#define BAUDRATE 115200 // Enable the Bluetooth serial interface on AT90USB devices //#define BLUETOOTH - +//ga // Choose the name from boards.h that matches your setup #ifndef MOTHERBOARD - #define MOTHERBOARD BOARD_RAMPS_14_EFB + #define MOTHERBOARD BOARD_BTT_SKR_V1_4_TURBO //BOARD_RAMPS_14_EFB BOARD_BTT_SKR_V1_4 BOARD_BTT_SKR_V1_4_TURBO BOARD_BTT_SKR_PRO_V1_1 BOARD_BTT_GTR_V1_0 BOARD_BTT_SKR_MINI_E3_V1_2 BOARD_CREALITY_V427 #endif // Name displayed in the LCD "Ready" message and Info menu -//#define CUSTOM_MACHINE_NAME "3D Printer" +#define CUSTOM_MACHINE_NAME "Ender-3 Pro" // Printer's unique ID, used by some programs to differentiate between machines. // Choose your own or use a service like https://www.uuidgenerator.net/version4 @@ -142,6 +142,7 @@ // This defines the number of extruders // :[0, 1, 2, 3, 4, 5, 6, 7, 8] +//ga #define EXTRUDERS 1 // Generally expected filament diameter (1.75, 2.85, 3.0, ...). Used for Volumetric, Filament Width Sensor, etc. @@ -407,8 +408,8 @@ * Use these for Testing or Development purposes. NEVER for production machine. * 998 : Dummy Table that ALWAYS reads 25°C or the temperature defined below. * 999 : Dummy Table that ALWAYS reads 100°C or the temperature defined below. - */ -#define TEMP_SENSOR_0 1 + *///ga +#define TEMP_SENSOR_0 -5 #define TEMP_SENSOR_1 0 #define TEMP_SENSOR_2 0 #define TEMP_SENSOR_3 0 @@ -416,7 +417,7 @@ #define TEMP_SENSOR_5 0 #define TEMP_SENSOR_6 0 #define TEMP_SENSOR_7 0 -#define TEMP_SENSOR_BED 0 +#define TEMP_SENSOR_BED 1 #define TEMP_SENSOR_PROBE 0 #define TEMP_SENSOR_CHAMBER 0 @@ -425,10 +426,10 @@ #define DUMMY_THERMISTOR_999_VALUE 100 // Resistor values when using MAX31865 sensors (-5) on TEMP_SENSOR_0 / 1 -//#define MAX31865_SENSOR_OHMS_0 100 // (Ω) Typically 100 or 1000 (PT100 or PT1000) -//#define MAX31865_CALIBRATION_OHMS_0 430 // (Ω) Typically 430 for AdaFruit PT100; 4300 for AdaFruit PT1000 -//#define MAX31865_SENSOR_OHMS_1 100 -//#define MAX31865_CALIBRATION_OHMS_1 430 +#define MAX31865_SENSOR_OHMS_0 100 // (Ω) Typically 100 or 1000 (PT100 or PT1000) +#define MAX31865_CALIBRATION_OHMS_0 430 // (Ω) Typically 430 for AdaFruit PT100; 4300 for AdaFruit PT1000 +#define MAX31865_SENSOR_OHMS_1 100 +#define MAX31865_CALIBRATION_OHMS_1 430 // Use temp sensor 1 as a redundant sensor with sensor 0. If the readings // from the two sensors differ too much the print will be aborted. @@ -466,7 +467,7 @@ #define HEATER_5_MAXTEMP 275 #define HEATER_6_MAXTEMP 275 #define HEATER_7_MAXTEMP 275 -#define BED_MAXTEMP 150 +#define BED_MAXTEMP 125 //=========================================================================== //============================= PID Settings ================================ @@ -480,21 +481,22 @@ #define PID_K1 0.95 // Smoothing factor within any PID loop #if ENABLED(PIDTEMP) - //#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM) - //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) + #define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM) + #define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) // Set/get with gcode: M301 E[extruder number, 0-2] + // Creality Ender-3 #if ENABLED(PID_PARAMS_PER_HOTEND) // Specify between 1 and HOTENDS values per array. // If fewer than EXTRUDER values are provided, the last element will be repeated. - #define DEFAULT_Kp_LIST { 22.20, 22.20 } - #define DEFAULT_Ki_LIST { 1.08, 1.08 } - #define DEFAULT_Kd_LIST { 114.00, 114.00 } + #define DEFAULT_Kp_LIST { 21.73, 21.73 } + #define DEFAULT_Ki_LIST { 1.54, 1.54 } + #define DEFAULT_Kd_LIST { 76.55, 76.55 } #else - #define DEFAULT_Kp 22.20 - #define DEFAULT_Ki 1.08 - #define DEFAULT_Kd 114.00 + #define DEFAULT_Kp 21.73 + #define DEFAULT_Ki 1.54 + #define DEFAULT_Kd 76.55 #endif #endif // PIDTEMP @@ -584,9 +586,9 @@ * details can be tuned in Configuration_adv.h */ -#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders -#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed -#define THERMAL_PROTECTION_CHAMBER // Enable thermal protection for the heated chamber +//#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +//#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed +//#define THERMAL_PROTECTION_CHAMBER // Enable thermal protection for the heated chamber //=========================================================================== //============================= Mechanical Settings ========================= @@ -672,16 +674,16 @@ * TMC26X, TMC26X_STANDALONE, TMC2660, TMC2660_STANDALONE, * TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE'] - */ -#define X_DRIVER_TYPE A4988 -#define Y_DRIVER_TYPE A4988 -#define Z_DRIVER_TYPE A4988 + *///ga +#define X_DRIVER_TYPE TMC2209 +#define Y_DRIVER_TYPE TMC2209 +#define Z_DRIVER_TYPE TMC2209 //#define X2_DRIVER_TYPE A4988 //#define Y2_DRIVER_TYPE A4988 //#define Z2_DRIVER_TYPE A4988 //#define Z3_DRIVER_TYPE A4988 //#define Z4_DRIVER_TYPE A4988 -#define E0_DRIVER_TYPE A4988 +#define E0_DRIVER_TYPE TMC2130 //#define E1_DRIVER_TYPE A4988 //#define E2_DRIVER_TYPE A4988 //#define E3_DRIVER_TYPE A4988 @@ -736,14 +738,14 @@ * Override with M92 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 500 } +#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 93 } /** * Default Max Feed Rate (mm/s) * Override with M203 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_MAX_FEEDRATE { 300, 300, 5, 25 } +#define DEFAULT_MAX_FEEDRATE { 500, 500, 5, 25 } //#define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2 #if ENABLED(LIMITED_MAX_FR_EDITING) @@ -756,7 +758,7 @@ * Override with M201 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_MAX_ACCELERATION { 3000, 3000, 100, 10000 } +#define DEFAULT_MAX_ACCELERATION { 500, 500, 100, 5000 } //#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2 #if ENABLED(LIMITED_MAX_ACCEL_EDITING) @@ -771,9 +773,9 @@ * M204 R Retract Acceleration * M204 T Travel Acceleration */ -#define DEFAULT_ACCELERATION 3000 // X, Y, Z and E acceleration for printing moves -#define DEFAULT_RETRACT_ACCELERATION 3000 // E acceleration for retracts -#define DEFAULT_TRAVEL_ACCELERATION 3000 // X, Y, Z acceleration for travel (non printing) moves +#define DEFAULT_ACCELERATION 500 // X, Y, Z and E acceleration for printing moves +#define DEFAULT_RETRACT_ACCELERATION 500 // E acceleration for retracts +#define DEFAULT_TRAVEL_ACCELERATION 500 // X, Y, Z acceleration for travel (non printing) moves /** * Default Jerk limits (mm/s) @@ -807,7 +809,7 @@ * https://blog.kyneticcnc.com/2018/10/computing-junction-deviation-for-marlin.html */ #if DISABLED(CLASSIC_JERK) - #define JUNCTION_DEVIATION_MM 0.013 // (mm) Distance from real junction edge + #define JUNCTION_DEVIATION_MM 0.08 // (mm) Distance from real junction edge #define JD_HANDLE_SMALL_SEGMENTS // Use curvature estimation instead of just the junction angle // for small segments (< 1mm) with large junction angles (> 135°). #endif @@ -1086,14 +1088,14 @@ // @section extruder #define DISABLE_E false // Disable the extruder when not stepping -#define DISABLE_INACTIVE_EXTRUDER // Keep only the active extruder enabled +//#define DISABLE_INACTIVE_EXTRUDER // Keep only the active extruder enabled // @section machine // Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. #define INVERT_X_DIR false -#define INVERT_Y_DIR true -#define INVERT_Z_DIR false +#define INVERT_Y_DIR false +#define INVERT_Z_DIR true // @section extruder @@ -1127,8 +1129,8 @@ // @section machine // The size of the print bed -#define X_BED_SIZE 200 -#define Y_BED_SIZE 200 +#define X_BED_SIZE 235 +#define Y_BED_SIZE 235 // Travel limits (mm) after homing, corresponding to endstop positions. #define X_MIN_POS 0 @@ -1136,7 +1138,7 @@ #define Z_MIN_POS 0 #define X_MAX_POS X_BED_SIZE #define Y_MAX_POS Y_BED_SIZE -#define Z_MAX_POS 200 +#define Z_MAX_POS 250 /** * Software Endstops @@ -1447,7 +1449,7 @@ #endif // Homing speeds (mm/min) -#define HOMING_FEEDRATE_XY (50*60) +#define HOMING_FEEDRATE_XY (20*60) #define HOMING_FEEDRATE_Z (4*60) // Validate that endstops are triggered on homing moves @@ -1525,12 +1527,12 @@ * M501 - Read settings from EEPROM. (i.e., Throw away unsaved changes) * M502 - Revert settings to "factory" defaults. (Follow with M500 to init the EEPROM.) */ -//#define EEPROM_SETTINGS // Persistent storage with M500 and M501 +#define EEPROM_SETTINGS // Persistent storage with M500 and M501 //#define DISABLE_M503 // Saves ~2700 bytes of PROGMEM. Disable for release! #define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save PROGMEM. #define EEPROM_BOOT_SILENT // Keep M503 quiet and only give errors during first load #if ENABLED(EEPROM_SETTINGS) - //#define EEPROM_AUTO_INIT // Init EEPROM automatically on any errors. + #define EEPROM_AUTO_INIT // Init EEPROM automatically on any errors. #endif // @@ -1777,7 +1779,7 @@ * * SD Card support is disabled by default. If your controller has an SD slot, * you must uncomment the following option or it won't work. - */ + *///ga //#define SDSUPPORT /** @@ -1865,7 +1867,7 @@ // // If you have a speaker that can produce tones, enable it here. // By default Marlin assumes you have a buzzer with a fixed frequency. -// +////ga //#define SPEAKER // @@ -2038,8 +2040,8 @@ // // RepRapDiscount FULL GRAPHIC Smart Controller // https://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller -// -//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER +////ga +#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER // // ReprapWorld Graphical LCD @@ -2126,7 +2128,9 @@ // (For CR-10 owners who want to replace the Melzi Creality board but retain the display) // //#define CR10_STOCKDISPLAY - +#if ENABLED(CR10_STOCKDISPLAY) + #define RET6_12864_LCD // Specific to the SoC (can either be RET / VET) +#endif // // Ender-2 OEM display, a variant of the MKS_MINI_12864 // diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 9e5ebb33ba7f..6fb9b056fbf1 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -47,7 +47,7 @@ * stream of errors from the sensor. * * Set this value to 0 to fail on the first error to occur. - */ + *///ga #define THERMOCOUPLE_MAX_ERRORS 15 // @@ -325,7 +325,7 @@ // Show Temperature ADC value // Enable for M105 to include ADC values read from temperature sensors. -//#define SHOW_TEMP_ADC_VALUES +#define SHOW_TEMP_ADC_VALUES /** * High Temperature Thermistor Support @@ -345,7 +345,8 @@ // The number of consecutive low temperature errors that can occur // before a min_temp_error is triggered. (Shouldn't be more than 10.) -//#define MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED 0 +//ga +#define MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED 15 // The number of milliseconds a hotend will preheat before starting to check // the temperature. This value should NOT be set to the time it takes the @@ -661,7 +662,7 @@ //#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (mm) Backoff from endstops after homing -//#define QUICK_HOME // If G28 contains XY do a diagonal move first +#define QUICK_HOME // If G28 contains XY do a diagonal move first //#define HOME_Y_BEFORE_X // If G28 contains XY home Y before X //#define HOME_Z_FIRST // Home Z first. Requires a Z-MIN endstop (not a probe). //#define CODEPENDENT_XY_HOMING // If X/Y can't home without homing Y/X first @@ -712,7 +713,7 @@ * differs, a mode set eeprom write will be completed at initialization. * Use the option below to force an eeprom write to a V3.1 probe regardless. */ - //#define BLTOUCH_SET_5V_MODE + #define BLTOUCH_SET_5V_MODE /** * Safety: Activate if connecting a probe with an unknown voltage mode. @@ -849,7 +850,7 @@ #define DISABLE_INACTIVE_X true #define DISABLE_INACTIVE_Y true #define DISABLE_INACTIVE_Z true // Set 'false' if the nozzle could fall onto your printed part! -#define DISABLE_INACTIVE_E true +#define DISABLE_INACTIVE_E false //ga // If the Nozzle or Bed falls when the Z stepper is disabled, set its resting position here. //#define Z_AFTER_DEACTIVATE Z_HOME_POS @@ -1135,7 +1136,7 @@ #endif // HAS_LCD_MENU // Scroll a longer status message into view -//#define STATUS_MESSAGE_SCROLLING +#define STATUS_MESSAGE_SCROLLING // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY @@ -1189,7 +1190,7 @@ #define SD_PROCEDURE_DEPTH 1 // Increase if you need more nested M32 calls - #define SD_FINISHED_STEPPERRELEASE true // Disable steppers when SD Print is finished + #define SD_FINISHED_STEPPERRELEASE false // Disable steppers when SD Print is finished #define SD_FINISHED_RELEASECOMMAND "M84" // Use "M84XYE" to keep Z enabled so your bed stays in place // Reverse SD sort to show "more recent" files first, according to the card's FAT. @@ -1281,7 +1282,7 @@ //#define LONG_FILENAME_HOST_SUPPORT // Enable this option to scroll long filenames in the SD card menu - //#define SCROLL_LONG_FILENAMES + #define SCROLL_LONG_FILENAMES // Leave the heaters on after Stop Print (not recommended!) //#define SD_ABORT_NO_COOLDOWN @@ -1641,7 +1642,7 @@ #define BABYSTEP_MULTIPLICATOR_Z 1 // (steps or mm) Steps or millimeter distance for each Z babystep #define BABYSTEP_MULTIPLICATOR_XY 1 // (steps or mm) Steps or millimeter distance for each XY babystep - //#define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping. + #define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping. #if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING) #define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds. // Note: Extra time may be added to mitigate controller latency. @@ -2296,7 +2297,7 @@ #define INTERPOLATE true #if AXIS_IS_TMC(X) - #define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current. + #define X_CURRENT 760 // (mA) RMS current. Multiply by 1.414 for peak current. #define X_CURRENT_HOME X_CURRENT // (mA) RMS current for sensorless homing #define X_MICROSTEPS 16 // 0..256 #define X_RSENSE 0.11 @@ -2314,7 +2315,7 @@ #endif #if AXIS_IS_TMC(Y) - #define Y_CURRENT 800 + #define Y_CURRENT 760 #define Y_CURRENT_HOME Y_CURRENT #define Y_MICROSTEPS 16 #define Y_RSENSE 0.11 @@ -2332,7 +2333,7 @@ #endif #if AXIS_IS_TMC(Z) - #define Z_CURRENT 800 + #define Z_CURRENT 760 #define Z_CURRENT_HOME Z_CURRENT #define Z_MICROSTEPS 16 #define Z_RSENSE 0.11 @@ -2368,7 +2369,7 @@ #endif #if AXIS_IS_TMC(E0) - #define E0_CURRENT 800 + #define E0_CURRENT 900 #define E0_MICROSTEPS 16 #define E0_RSENSE 0.11 #define E0_CHAIN_POS -1 @@ -2455,8 +2456,8 @@ * Software option for SPI driven drivers (TMC2130, TMC2160, TMC2660, TMC5130 and TMC5160). * The default SW SPI pins are defined the respective pins files, * but you can override or define them here. - */ - //#define TMC_USE_SW_SPI + *///ga + #define TMC_USE_SW_SPI //#define TMC_SW_MOSI -1 //#define TMC_SW_MISO -1 //#define TMC_SW_SCK -1 @@ -2522,7 +2523,7 @@ * Define your own with: * { , , hysteresis_start[1..8] } */ - #define CHOPPER_TIMING CHOPPER_DEFAULT_12V // All axes (override below) + #define CHOPPER_TIMING CHOPPER_DEFAULT_24V // All axes (override below) //#define CHOPPER_TIMING_X CHOPPER_DEFAULT_12V // For X Axes (override below) //#define CHOPPER_TIMING_X2 CHOPPER_DEFAULT_12V //#define CHOPPER_TIMING_Y CHOPPER_DEFAULT_12V // For Y Axes (override below) @@ -2550,8 +2551,8 @@ * M911 - Report stepper driver overtemperature pre-warn condition. * M912 - Clear stepper driver overtemperature pre-warn condition flag. * M122 - Report driver parameters (Requires TMC_DEBUG) - */ - //#define MONITOR_DRIVER_STATUS + *///ga + #define MONITOR_DRIVER_STATUS #if ENABLED(MONITOR_DRIVER_STATUS) #define CURRENT_STEP_DOWN 50 // [mA] @@ -2647,8 +2648,8 @@ /** * Enable M122 debugging command for TMC stepper drivers. * M122 S0/1 will enable continous reporting. - */ - //#define TMC_DEBUG + *///ga + #define TMC_DEBUG /** * You can set your own advanced settings by filling in predefined functions. diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index d1028c6997f2..3070548ff0c2 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -483,6 +483,47 @@ #define MAX6675_HAS_MAX6675 1 #endif +// +// Compatibility layer for MAX (SPI) temp boards +// +#if PIN_EXISTS(MAX6675_SS) + #if MAX6675_0_IS_MAX31855 + #define MAX31855_CS_PIN MAX6675_SS_PIN + #elif MAX6675_0_IS_MAX31865 + #define MAX31865_CS_PIN MAX6675_SS_PIN + #elif MAX6675_0_IS_MAX6675 + #define MAX6675_CS_PIN MAX6675_SS_PIN + #endif +#endif + +#if PIN_EXISTS(MAX6675_SS2) + #if MAX6675_1_IS_MAX31855 + #define MAX31855_CS2_PIN MAX6675_SS2_PIN + #elif MAX6675_1_IS_MAX31865 + #define MAX31865_CS2_PIN MAX6675_SS2_PIN + #elif MAX6675_1_IS_MAX6675 + #define MAX6675_CS2_PIN MAX6675_SS2_PIN + #endif +#endif + +#if PIN_EXISTS(MAX6675_DO) + #if MAX6675_HAS_MAX31855 + #define MAX31855_MISO_PIN MAX6675_DO_PIN + #elif MAX6675_HAS_MAX31865 + #define MAX31865_MISO_PIN MAX6675_DO_PIN + #elif MAX6675_HAS_MAX6675 + #define MAX6675_MISO_PIN MAX6675_DO_PIN + #endif +#endif + +#if PIN_EXISTS(MAX6675_SCK) + #if MAX6675_HAS_MAX31855 + #define MAX31855_SCK_PIN MAX6675_SCK_PIN + #elif MAX6675_HAS_MAX31865 + #define MAX31865_SCK_PIN MAX6675_SCK_PIN + #endif +#endif + #if TEMP_SENSOR_2 == -4 #define HEATER_2_USES_AD8495 1 #elif TEMP_SENSOR_2 == -3 diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 55939ed30ffb..dc9fb638a300 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -25,6 +25,7 @@ */ // Useful when debugging thermocouples +//ga //#define IGNORE_THERMOCOUPLE_ERRORS #include "temperature.h" @@ -43,28 +44,16 @@ #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" #endif - +//ga #if MAX6675_HAS_MAX31855 #include - #if MAX6675_0_IS_MAX31855 && !defined(MAX31855_CS_PIN) && PIN_EXISTS(MAX6675_SS) - #define MAX31855_CS_PIN MAX6675_SS_PIN - #endif - #if MAX6675_1_IS_MAX31855 && !defined(MAX31855_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) - #define MAX31855_CS2_PIN MAX6675_SS2_PIN - #endif - #if !defined(MAX31855_MISO_PIN) && PIN_EXISTS(MAX6675_DO) - #define MAX31855_MISO_PIN MAX6675_DO_PIN - #endif - #if !defined(MAX31855_SCK_PIN) && PIN_EXISTS(MAX6675_SCK) - #define MAX31855_SCK_PIN MAX6675_SCK_PIN - #endif - #if ANY_PIN(MAX6675_DO, MAX31855_MISO) && ANY_PIN(MAX6675_SCK, MAX31855_SCK) - #define MAX31855_USES_SW_LIB 1 + #if PIN_EXISTS(MAX31855_MISO) && PIN_EXISTS(MAX31855_SCK) + #define MAX31855_USES_SW_SPI 1 #endif #if MAX6675_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS) #define HAS_MAX31855_TEMP 1 Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855(MAX31855_CS_PIN - #if MAX31855_USES_SW_LIB + #if MAX31855_USES_SW_SPI , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK #endif ); @@ -72,7 +61,7 @@ #if MAX6675_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2) #define HAS_MAX31855_TEMP 1 Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855(MAX31855_CS2_PIN - #if MAX31855_USES_SW_LIB + #if MAX31855_USES_SW_SPI , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK #endif ); @@ -81,28 +70,13 @@ #if MAX6675_HAS_MAX31865 #include - #if MAX6675_0_IS_MAX31865 && !defined(MAX31865_CS_PIN) && PIN_EXISTS(MAX6675_SS) - #define MAX31865_CS_PIN MAX6675_SS_PIN - #endif - #if MAX6675_1_IS_MAX31865 && !defined(MAX31865_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) - #define MAX31865_CS2_PIN MAX6675_SS2_PIN - #endif - #ifndef MAX31865_MOSI_PIN - #define MAX31865_MOSI_PIN MOSI_PIN - #endif - #if !defined(MAX31865_MISO_PIN) && PIN_EXISTS(MAX6675_DO) - #define MAX31865_MISO_PIN MAX6675_DO_PIN - #endif - #if !defined(MAX31865_SCK_PIN) && PIN_EXISTS(MAX6675_SCK) - #define MAX31865_SCK_PIN MAX6675_SCK_PIN - #endif - #if ANY_PIN(MAX6675_DO, MAX31865_MISO) && ANY_PIN(MAX6675_SCK, MAX31865_SCK) - #define MAX31865_USES_SW_LIB 1 + #if PIN_EXISTS(MAX31865_MISO) && PIN_EXISTS(MAX31865_SCK) + #define MAX31865_USES_SW_SPI 1 #endif #if MAX6675_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS) #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN - #if MAX31865_USES_SW_LIB + #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK #endif ); @@ -110,7 +84,7 @@ #if MAX6675_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2) #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN - #if MAX31865_USES_SW_LIB + #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK #endif ); @@ -119,22 +93,13 @@ #if MAX6675_HAS_MAX6675 #include - #if MAX6675_0_IS_MAX6675 && !defined(MAX6675_CS_PIN) && PIN_EXISTS(MAX6675_SS) - #define MAX6675_CS_PIN MAX6675_SS_PIN - #endif - #if MAX6675_1_IS_MAX6675 && !defined(MAX6675_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) - #define MAX6675_CS2_PIN MAX6675_SS2_PIN - #endif - #if !defined(MAX6675_MISO_PIN) && PIN_EXISTS(MAX6675_DO) - #define MAX6675_MISO_PIN MAX6675_DO_PIN - #endif - #if ANY_PIN(MAX6675_DO, MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK) - #define MAX6675_USES_SW_LIB 1 + #if PIN_EXISTS(MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK) + #define MAX6675_USES_SW_SPI 1 #endif #if MAX6675_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) #define HAS_MAX6675_TEMP 1 MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN - #if MAX6675_USES_SW_LIB && PIN_EXISTS(MAX6675_SCK) + #if MAX6675_USES_SW_SPI , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif ); @@ -142,7 +107,7 @@ #if MAX6675_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) #define HAS_MAX6675_TEMP 1 MAX6675 max6675_1 = MAX6675(MAX6675_CS2_PIN - #if MAX6675_USES_SW_LIB && PIN_EXISTS(MAX6675_SCK) + #if MAX6675_USES_SW_SPI , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif ); @@ -1541,7 +1506,7 @@ void Temperature::manage_heater() { return _MIN(value + THERMISTOR_ABS_ZERO_C, 999); } #endif - +//ga #if HAS_HOTEND // Derived from RepRap FiveD extruder::getTemperature() // For hot end temperature measurement. @@ -1714,7 +1679,7 @@ void Temperature::manage_heater() { * The raw values are created in interrupt context, * and this function is called from normal context * as it would block the stepper routine. - */ + *///ga void Temperature::updateTemperaturesFromRawValues() { TERN_(HEATER_0_USES_MAX6675, temp_hotend[0].raw = READ_MAX6675(0)); TERN_(HEATER_1_USES_MAX6675, temp_hotend[1].raw = READ_MAX6675(1)); @@ -1734,6 +1699,7 @@ void Temperature::updateTemperaturesFromRawValues() { raw_temps_ready = false; } +//ga #if MAX6675_SEPARATE_SPI template SoftSPI SPIclass::softSPI; SPIclass max6675_spi; @@ -1772,7 +1738,7 @@ void Temperature::updateTemperaturesFromRawValues() { * The manager is implemented by periodic calls to manage_heater() */ void Temperature::init() { - +//ga TERN_(MAX6675_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE TERN_(MAX6675_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE)); #if HAS_MAX31855_TEMP @@ -1881,6 +1847,7 @@ void Temperature::init() { INIT_FAN_PIN(CONTROLLER_FAN_PIN); #endif + //ga TERN_(MAX6675_SEPARATE_SPI, max6675_spi.init()); HAL_adc_init(); @@ -2271,7 +2238,7 @@ void Temperature::disable_all_heaters() { #endif // PROBING_HEATERS_OFF #if HAS_MAX6675 - +//ga #ifndef THERMOCOUPLE_MAX_ERRORS #define THERMOCOUPLE_MAX_ERRORS 15 #endif @@ -2330,7 +2297,7 @@ void Temperature::disable_all_heaters() { // // TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used. - // + ////ga #if !MAX6675_SEPARATE_SPI && NO_THERMO_TEMPS spiBegin(); spiInit(MAX6675_SPEED_BITS); @@ -2359,6 +2326,9 @@ void Temperature::disable_all_heaters() { #if HAS_MAX31865_TEMP Adafruit_MAX31865 &max865ref = MAX6675_SEL(max31865_0, max31865_1); max6675_temp = max865ref.readRTD_with_Fault(); + #if ECHO_TEMP + SERIAL_ECHOLNPAIR("Max31865 RTD MSB: ", max6675_temp >> 8 ," LSB: ", max6675_temp & 0x00FF," "); + #endif #endif #if HAS_MAX6675_TEMP @@ -2371,6 +2341,7 @@ void Temperature::disable_all_heaters() { const uint8_t fault_31865 = TERN1(HAS_MAX31865_TEMP, (max865ref.readFault() & 0x3FU)); + //ga if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK) && fault_31865) { max6675_errors[hindex]++; if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { @@ -2426,6 +2397,18 @@ void Temperature::disable_all_heaters() { #if MAX6675_HAS_MAX31865 max6675_temp = (uint32_t(max6675_temp) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; #endif + //ga + #if ECHO_TEMP + #if HAS_MAX31855 || HAS_MAX6675_TEMP + SERIAL_ECHOLNPAIR("Temp: ", max6675_temp ," "); + #endif + #if HAS_MAX6675_TEMP + SERIAL_ECHOLNPAIR("Max6675 Temp in Celsius : ", max6675ref.readCelsius() ," "); + #endif + #if MAX6675_HAS_MAX31865 && ECHO_MAX31865_RESITANCE + SERIAL_ECHOLNPAIR("MAX31865 RTD readRTD_Resistance : ", max865ref.readRTD_Resistance(MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) ," Calculated : ", max6675_temp ," "); + #endif + #endif MAX6675_TEMP(hindex) = max6675_temp; @@ -2506,7 +2489,9 @@ void Temperature::readings_ready() { const int8_t tdir = temp_dir[e]; if (tdir) { const int16_t rawtemp = temp_hotend[e].raw * tdir; // normal direction, +rawtemp, else -rawtemp - const bool heater_on = (temp_hotend[e].target > 0 + //ga NEEDED FOR TESTING ON THE BENCH WITH TEMPERATURE SENSORS + //const bool heater_on = (temp_hotend[e].target > 0 + const bool heater_on = (temp_hotend[e].target >= 0 || TERN0(PIDTEMP, temp_hotend[e].soft_pwm_amount) > 0 ); if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error((heater_id_t)e); 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 c621f93a2ac5..af702f720b6d 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -25,12 +25,12 @@ // // Trinamic Stallguard pins -// +////ga #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+ +//#define E1_DIAG_PIN P1_26 // Y+ // // Limit Switches @@ -96,27 +96,27 @@ // // Steppers -// +////ga #define X_STEP_PIN P2_02 #define X_DIR_PIN P2_06 #define X_ENABLE_PIN P2_01 -#ifndef X_CS_PIN - #define X_CS_PIN P1_17 -#endif +//#ifndef X_CS_PIN + //#define X_CS_PIN P1_17 +//#endif #define Y_STEP_PIN P0_19 #define Y_DIR_PIN P0_20 #define Y_ENABLE_PIN P2_08 -#ifndef Y_CS_PIN - #define Y_CS_PIN P1_15 -#endif +//#ifndef Y_CS_PIN + //#define Y_CS_PIN P1_15 +//#endif #define Z_STEP_PIN P0_22 #define Z_DIR_PIN P2_11 #define Z_ENABLE_PIN P0_21 -#ifndef Z_CS_PIN - #define Z_CS_PIN P1_10 -#endif +//#ifndef Z_CS_PIN + //#define Z_CS_PIN P1_10 +//#endif #define E0_STEP_PIN P2_13 #define E0_DIR_PIN P0_11 @@ -125,13 +125,13 @@ #define E0_CS_PIN P1_08 #endif -#ifndef E1_CS_PIN - #define E1_CS_PIN P1_01 -#endif +//#ifndef E1_CS_PIN + //#define E1_CS_PIN P1_01 +//#endif // // Software SPI pins for TMC2130 stepper drivers -// +////ga #if ENABLED(TMC_USE_SW_SPI) #ifndef TMC_SW_MOSI #define TMC_SW_MOSI P4_28 @@ -165,7 +165,7 @@ // // Software serial - // + ////ga #define X_SERIAL_TX_PIN P4_29 #define X_SERIAL_RX_PIN P1_17 @@ -175,11 +175,11 @@ #define Z_SERIAL_TX_PIN P1_14 #define Z_SERIAL_RX_PIN P1_10 - #define E0_SERIAL_TX_PIN P1_09 - #define E0_SERIAL_RX_PIN P1_08 + //#define E0_SERIAL_TX_PIN P1_09 + //#define E0_SERIAL_RX_PIN P1_08 - #define E1_SERIAL_TX_PIN P1_04 - #define E1_SERIAL_RX_PIN P1_01 + //#define E1_SERIAL_TX_PIN P1_04 + //#define E1_SERIAL_RX_PIN P1_01 // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 @@ -368,7 +368,7 @@ // // SD Support -// +////ga #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION LCD 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 86fbd18ba28b..f9bb9dd631ba 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -31,7 +31,7 @@ // // SD Connection -// +////ga #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION LCD #endif @@ -39,7 +39,7 @@ // // Servos // -#define SERVO0_PIN P2_00 +//#define SERVO0_PIN P2_00 // // TMC StallGuard DIAG pins @@ -48,7 +48,7 @@ #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 +//#define E1_DIAG_PIN P1_25 // E1DET // // Limit Switches @@ -95,49 +95,49 @@ #define Z_MIN_PROBE_PIN P0_10 #endif -// +////ga // Filament Runout Sensor // -#define FIL_RUNOUT_PIN P1_26 // E0DET -#define FIL_RUNOUT2_PIN P1_25 // E1DET +//#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 // PWRDET -#endif +//#ifndef PS_ON_PIN + //#define PS_ON_PIN P1_00 // PWRDET +//#endif // // Power Loss Detection // -#ifndef POWER_LOSS_PIN - #define POWER_LOSS_PIN P1_00 // PWRDET -#endif +//#ifndef POWER_LOSS_PIN + //#define POWER_LOSS_PIN P1_00 // PWRDET +//#endif // // Steppers -// +////ga #define X_STEP_PIN P2_02 #define X_DIR_PIN P2_06 #define X_ENABLE_PIN P2_01 -#ifndef X_CS_PIN - #define X_CS_PIN P1_10 -#endif +//#ifndef X_CS_PIN + //#define X_CS_PIN P1_10 +//#endif #define Y_STEP_PIN P0_19 #define Y_DIR_PIN P0_20 #define Y_ENABLE_PIN P2_08 -#ifndef Y_CS_PIN - #define Y_CS_PIN P1_09 -#endif +//#ifndef Y_CS_PIN + //#define Y_CS_PIN P1_09 +//#endif #define Z_STEP_PIN P0_22 #define Z_DIR_PIN P2_11 #define Z_ENABLE_PIN P0_21 -#ifndef Z_CS_PIN - #define Z_CS_PIN P1_08 -#endif +//#ifndef Z_CS_PIN + //#define Z_CS_PIN P1_08 +//#endif #define E0_STEP_PIN P2_13 #define E0_DIR_PIN P0_11 @@ -146,19 +146,21 @@ #define E0_CS_PIN P1_04 #endif +/* #define E1_STEP_PIN P1_15 #define E1_DIR_PIN P1_14 #define E1_ENABLE_PIN P1_16 -#ifndef E1_CS_PIN - #define E1_CS_PIN P1_01 -#endif +//#ifndef E1_CS_PIN + //#define E1_CS_PIN P1_01 +//#endif +*/ -#define TEMP_1_PIN P0_23_A0 // A0 (T0) - (67) - TEMP_1_PIN +//#define TEMP_1_PIN P0_23_A0 // A0 (T0) - (67) - TEMP_1_PIN #define TEMP_BED_PIN P0_25_A2 // A2 (T2) - (69) - TEMP_BED_PIN // // Software SPI pins for TMC2130 stepper drivers -// +////ga #if ENABLED(TMC_USE_SW_SPI) #ifndef TMC_SW_MOSI #define TMC_SW_MOSI P1_17 @@ -192,7 +194,7 @@ // // Software serial - // + ////ga #define X_SERIAL_TX_PIN P1_10 #define X_SERIAL_RX_PIN P1_10 @@ -202,11 +204,11 @@ #define Z_SERIAL_TX_PIN P1_08 #define Z_SERIAL_RX_PIN P1_08 - #define E0_SERIAL_TX_PIN P1_04 - #define E0_SERIAL_RX_PIN P1_04 + //#define E0_SERIAL_TX_PIN P1_04 + //#define E0_SERIAL_RX_PIN P1_04 - #define E1_SERIAL_TX_PIN P1_01 - #define E1_SERIAL_RX_PIN P1_01 + //#define E1_SERIAL_TX_PIN P1_01 + //#define E1_SERIAL_RX_PIN P1_01 // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 @@ -442,7 +444,7 @@ // NeoPixel LED // #ifndef NEOPIXEL_PIN - #define NEOPIXEL_PIN P1_24 + //#define NEOPIXEL_PIN P1_24 #endif /** diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h index a8dd55bf2721..ea4d14b5d63c 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -47,6 +47,7 @@ // // Steppers // +/* #ifndef E1_STEP_PIN #define E1_STEP_PIN P0_01 #endif @@ -57,15 +58,16 @@ #define E1_ENABLE_PIN P0_10 #endif +*/ // // Temperature Sensors // 3.3V max when defined as an analog input // #ifndef TEMP_0_PIN - #define TEMP_0_PIN P0_24_A1 // A1 (T1) - (68) - TEMP_0_PIN + //#define TEMP_0_PIN P0_24_A1 // A1 (T1) - (68) - TEMP_0_PIN #endif #ifndef TEMP_1_PIN - #define TEMP_1_PIN P0_25_A2 // A2 (T2) - (69) - TEMP_1_PIN + //#define TEMP_1_PIN P0_25_A2 // A2 (T2) - (69) - TEMP_1_PIN #endif #ifndef TEMP_BED_PIN #define TEMP_BED_PIN P0_23_A0 // A0 (T0) - (67) - TEMP_BED_PIN @@ -79,6 +81,139 @@ #endif #endif +//ga +// GADGETANGEL SECTION Begins ==============================================>> +// +// SET ONLY ONE of theses variables or NONE +#define TEMP_0_PIN P1_14 //SW P1_14 //HW P0_03 +#define TEMP_SENSOR_0_PIN TEMP_0_PIN +#define ECHO_TEMP 1 +#define ECHO_MAX31865_RESITANCE 0 +//#define TEMP_SENSOR_1_PIN P0_03 +// +#define MAX31865_SW_SPI //-5 +//#define MAX31865_HW_SPI //-5 +//#define MAX31855_SW_SPI //-3 +//#define MAX31855_HW_SPI //-3 +//#define MAX6675_SW_SPI //-2 +//#define MAX6675_HW_SPI //-2 + +#ifndef MAX6675_SS_PIN + #ifdef MAX31865_SW_SPI + #define MAX6675_DO_PIN P0_01 + //#define MAX31865_MISO_PIN P1_15 + #define MAX6675_SCK_PIN P1_01 + //#define MAX31865_SCK_PIN P1_01 + // + #define MAX31865_MOSI_PIN P0_03 + // + #define MAX31865_CS_PIN TEMP_SENSOR_0_PIN + //#define MAX6675_SS_PIN TEMP_SENSOR_0_PIN + // enable the below two lines if you have a second Adafruit MAX31865 in software SPI mode + //#define MAX31865_CS2_PIN TEMP_1_PIN + //#define MAX6675_SS2_PIN TEMP_1_PIN + #endif + + #ifdef MAX31865_HW_SPI + // SKR V1.4 or SKR V1.4 Turbo or SKR v1.3 + // if SD_CONNECTION_IS(LCD) + // SCK_PIN P0_15 + // MISO_PIN P0_17 + // MOSI_PIN P0_18 + // if SD_CONNECTION_IS(ONBOARD) + // SCK_PIN P0_07 + // MISO_PIN P0_08 + // MOSI_PIN P0_09 + // + //#define MAX6675_SS_PIN TEMP_SENSOR_0_PIN //P0_26 SPI header // + // below forces hardware spi + ////#define MAX31865_CS_PIN MAX6675_SS_PIN //forces Hardware SPI + #define MAX31865_CS_PIN TEMP_SENSOR_0_PIN + //enable the below two lines if you have a second Adafruit MAX31865 board on hardware SPI + //#define MAX6675_SS2_PIN TEMP_1_PIN //P1_00 - PWRDET + ////#define MAX31865_CS2_PIN MAX6675_SS2_PIN //forces Hardware SPI for the second MAX31865 board + //#define MAX31865_CS2_PIN TEMP_1_PIN + #endif + + //MAX31855 board configuration for Software SPI + #ifdef MAX31855_SW_SPI + //#define MAX6675_DO_PIN P1_15 //P1_15 is E1_STEP_PIN + #define MAX31855_MISO_PIN P1_15 + //#define MAX6675_SCK_PIN P1_01 //P1_01 is E1_SERIAL_RX_PIN + #define MAX31855_SCK_PIN P1_01 + //#define MAX6675_SS_PIN TEMP_0_PIN + //#define MAX6675_SS_PIN TEMP_SENSOR_0_PIN //P1_14 is E1_DIR_PIN + #define MAX31855_CS_PIN TEMP_0_PIN + //#define MAX31855_CS_PIN TEMP_SENSOR_0_PIN + //enable the next lines below if you have two MAX31855 boards + //#define MAX6675_SS2_PIN TEMP_1_PIN + //#define MAX31855_CS2_PIN TEMP_1_PIN + // + #endif + + //MAX31855 board configuration for Hardware SPI + #ifdef MAX31855_HW_SPI + // SKR V1.4 or SKR V1.4 Turbo or SKR v1.3 + // if SD_CONNECTION_IS(LCD) + // SCK_PIN P0_15 + // MISO_PIN P0_17 + // MOSI_PIN P0_18 + // if SD_CONNECTION_IS(ONBOARD) + // SCK_PIN P0_07 + // MISO_PIN P0_08 + // MOSI_PIN P0_09 + // + //uncomment the below line if you want MAX6675 Hardware SPI to be used + #define MAX6675_SS_PIN TEMP_SENSOR_0_PIN + //#define MAX6675_SS_PIN TEMP_0_PIN + //uncomment the below line if you want Adafruit MAX31855 Hardware SPI to be used + //#define MAX31855_CS_PIN TEMP_SENSOR_0_PIN + //#define MAX31855_CS_PIN TEMP_0_PIN + // + //enable the next lines below if you have two MAX31855 boards + // + //uncomment the below line if you want MAX6675 Hardware SPI to be used + //#define MAX6675_SS2_PIN TEMP_1_PIN + //uncomment the below line if you want Adafruit MAX31855 Hardware SPI to be used + //#define MAX31855_CS2_PIN TEMP_1_PIN + #endif + + //MAX6675 board configuration for Software SPI + #ifdef MAX6675_SW_SPI + //#define MAX6675_DO_PIN P1_15 + #define MAX6675_MISO_PIN P1_15 + #define MAX6675_SCK_PIN P1_01 + //#define MAX6675_SS_PIN TEMP_SENSOR_0_PIN + #define MAX6675_CS_PIN TEMP_SENSOR_0_PIN + //enable the next lines below if you have two MAX6675 boards + //#define MAX6675_SS2_PIN TEMP_1_PIN + //#define MAX6675_CS2_PIN TEMP_1_PIN + #endif + + //MAX6675 board configuration for Hardware SPI + #ifdef MAX6675_HW_SPI + // SKR V1.4 or SKR V1.4 Turbo or SKR v1.3 + // if SD_CONNECTION_IS(LCD) + // SCK_PIN P0_15 + // MISO_PIN P0_17 + // MOSI_PIN P0_18 + // if SD_CONNECTION_IS(ONBOARD) + // SCK_PIN P0_07 + // MISO_PIN P0_08 + // MOSI_PIN P0_09 + // + //#define MAX6675_SS_PIN TEMP_SENSOR_0_PIN + #define MAX6675_CS_PIN TEMP_SENSOR_0_PIN + //enable the next lines below if you have two MAX6675 boards + //uncomment the below line if you want MAX6675 Hardware SPI to be used + //#define MAX6675_SS2_PIN TEMP_1_PIN + //#define MAX6675_CS2_PIN TEMP_1_PIN + #endif + +#endif + +//GADGETANGEL SECTION Ends ==============================================>> + // // Heaters / Fans // diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index 57d4c047e2e2..4794579b1f42 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -149,13 +149,14 @@ #ifndef E0_CS_PIN #define E0_CS_PIN 42 #endif - +/* #define E1_STEP_PIN 36 #define E1_DIR_PIN 34 #define E1_ENABLE_PIN 30 #ifndef E1_CS_PIN #define E1_CS_PIN 44 #endif +*/ // // Temperature Sensors @@ -177,6 +178,10 @@ #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card (SDSS) or 49 (SD_DETECT_PIN) #endif +//GADGETANGEL SECTION Begins + +//GADGETANGEL SECTION Ends + // // Augmentation for auto-assigning RAMPS plugs // @@ -246,19 +251,19 @@ // Misc. Functions // #define SDSS 53 -#define LED_PIN 13 +//#define LED_PIN 13 #ifndef FILWIDTH_PIN - #define FILWIDTH_PIN 5 // Analog Input on AUX2 + //#define FILWIDTH_PIN 5 // Analog Input on AUX2 #endif // RAMPS 1.4 DIO 4 on the servos connector #ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN 4 + //#define FIL_RUNOUT_PIN 4 #endif #ifndef PS_ON_PIN - #define PS_ON_PIN 12 + //#define PS_ON_PIN 12 #endif #if ENABLED(CASE_LIGHT_ENABLE) && !defined(CASE_LIGHT_PIN) && !defined(SPINDLE_LASER_ENA_PIN) @@ -288,7 +293,7 @@ // // TMC software SPI -// +////ga #if ENABLED(TMC_USE_SW_SPI) #ifndef TMC_SW_MOSI #define TMC_SW_MOSI 66 @@ -322,7 +327,7 @@ // // Software serial - // + ////ga #ifndef X_SERIAL_TX_PIN #define X_SERIAL_TX_PIN 40 @@ -413,9 +418,10 @@ #endif #endif +/* // // Průša i3 MK2 Multiplexer Support -// +////ga #ifndef E_MUX0_PIN #define E_MUX0_PIN 40 // Z_CS_PIN #endif @@ -425,6 +431,7 @@ #ifndef E_MUX2_PIN #define E_MUX2_PIN 44 // E1_CS_PIN #endif +*/ ////////////////////////// // LCDs and Controllers // diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h index 8ed30bffb733..658e7502ec5d 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h @@ -38,10 +38,10 @@ // Release PA13/PA14 (led, usb control) from SWD pins #define DISABLE_DEBUG +//ga +//#define NEOPIXEL_PIN PA8 // LED driving pin -#define NEOPIXEL_PIN PA8 // LED driving pin - -#define PS_ON_PIN PC13 // Power Supply Control +//#define PS_ON_PIN PC13 // Power Supply Control #define FAN1_PIN PC7 diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h index b65411be8a3b..5d968d2d7b0d 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h @@ -40,8 +40,8 @@ // // Servos -// -#define SERVO0_PIN PA1 // "SERVOS" +////ga +//#define SERVO0_PIN PA1 // "SERVOS" // // Limit Switches @@ -57,16 +57,16 @@ // // Filament Runout Sensor -// +////ga #ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN PC15 // "E0-STOP" + //#define FIL_RUNOUT_PIN PC15 // "E0-STOP" #endif // // Power-loss Detection -// +////ga #ifndef POWER_LOSS_PIN - #define POWER_LOSS_PIN PC12 // Power Loss Detection: PWR-DET + //#define POWER_LOSS_PIN PC12 // Power Loss Detection: PWR-DET #endif // @@ -91,9 +91,13 @@ // // Temperature Sensors // -#define TEMP_0_PIN PA0 // Analog Input "TH0" +//#define TEMP_0_PIN PA0 // Analog Input "TH0" #define TEMP_BED_PIN PC3 // Analog Input "TB0" +//GADGETANGEL SECTION Begins + +//GADGETANGEL SECTION Ends + // // Heaters / Fans // @@ -264,7 +268,7 @@ // // SD Support -// +////ga #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD @@ -278,6 +282,6 @@ #elif SD_CONNECTION_IS(CUSTOM_CABLE) #error "SD CUSTOM_CABLE is not compatible with SKR Mini E3." #endif - +//ga #define ONBOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index bfa4007658db..385a4de9b259 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -48,13 +48,13 @@ // // Trinamic Stallguard pins -// +////ga #define X_DIAG_PIN PF2 // X- #define Y_DIAG_PIN PC13 // Y- #define Z_DIAG_PIN PE0 // Z- #define E0_DIAG_PIN PG14 // X+ -#define E1_DIAG_PIN PG9 // Y+ -#define E2_DIAG_PIN PD3 // Z+ +//#define E1_DIAG_PIN PG9 // Y+ +//#define E2_DIAG_PIN PD3 // Z+ // // Limit Switches @@ -110,27 +110,27 @@ // // Steppers -// +////ga #define X_STEP_PIN PC15 #define X_DIR_PIN PF0 #define X_ENABLE_PIN PF1 -#ifndef X_CS_PIN - #define X_CS_PIN PC14 -#endif +//#ifndef X_CS_PIN + //#define X_CS_PIN PC14 +//#endif #define Y_STEP_PIN PE3 #define Y_DIR_PIN PE2 #define Y_ENABLE_PIN PE4 -#ifndef Y_CS_PIN - #define Y_CS_PIN PE1 -#endif +//#ifndef Y_CS_PIN + //#define Y_CS_PIN PE1 +//#endif #define Z_STEP_PIN PB8 #define Z_DIR_PIN PB7 // PB7 #define Z_ENABLE_PIN PB9 -#ifndef Z_CS_PIN - #define Z_CS_PIN PB5 -#endif +//#ifndef Z_CS_PIN + //#define Z_CS_PIN PB5 +//#endif #define E0_STEP_PIN PG12 #define E0_DIR_PIN PG11 @@ -139,6 +139,7 @@ #define E0_CS_PIN PG10 #endif +/* #define E1_STEP_PIN PD6 #define E1_DIR_PIN PD5 #define E1_ENABLE_PIN PD7 @@ -187,6 +188,7 @@ #ifndef E7_CS_PIN #define E7_CS_PIN PH14 #endif +*/ // // Software SPI pins for TMC2130 stepper drivers @@ -227,7 +229,7 @@ // // Software serial - // + ////ga #define X_SERIAL_TX_PIN PC14 #define X_SERIAL_RX_PIN PC14 @@ -237,6 +239,7 @@ #define Z_SERIAL_TX_PIN PB5 #define Z_SERIAL_RX_PIN PB5 + /* #define E0_SERIAL_TX_PIN PG10 #define E0_SERIAL_RX_PIN PG10 @@ -260,6 +263,7 @@ #define E7_SERIAL_TX_PIN PH14 #define E7_SERIAL_RX_PIN PH14 + */ // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 @@ -268,18 +272,19 @@ // // Temperature Sensors // -#define TEMP_0_PIN PC1 // T1 <-> E0 -#define TEMP_1_PIN PC2 // T2 <-> E1 -#define TEMP_2_PIN PC3 // T3 <-> E2 +//#define TEMP_0_PIN PC1 // T1 <-> E0 +//#define TEMP_1_PIN PC2 // T2 <-> E1 +//#define TEMP_2_PIN PC3 // T3 <-> E2 -#define TEMP_3_PIN PA3 // T4 <-> E3 -#define TEMP_4_PIN PF9 // T5 <-> E4 -#define TEMP_5_PIN PF10 // T6 <-> E5 -#define TEMP_6_PIN PF7 // T7 <-> E6 -#define TEMP_7_PIN PF5 // T8 <-> E7 +//#define TEMP_3_PIN PA3 // T4 <-> E3 +//#define TEMP_4_PIN PF9 // T5 <-> E4 +//#define TEMP_5_PIN PF10 // T6 <-> E5 +//#define TEMP_6_PIN PF7 // T7 <-> E6 +//#define TEMP_7_PIN PF5 // T8 <-> E7 #define TEMP_BED_PIN PC0 // T0 <-> Bed +/* // SPI for Max6675 or Max31855 Thermocouple // Uses a separate SPI bus // If you have a two-way thermocouple, you can customize two THERMO_CSx_PIN pins (x:1~2) @@ -293,6 +298,10 @@ #define MAX6675_SS2_PIN THERMO_CS2_PIN #define MAX6675_SCK_PIN THERMO_SCK_PIN #define MAX6675_DO_PIN THERMO_DO_PIN +*/ + + + // // Heaters / Fans @@ -319,6 +328,7 @@ //#define FAN6_PIN PC9 // Fan6 //#define FAN7_PIN PE14 // Fan7 +//ga #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD #endif diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h index 235ed1edcc4c..1708b9614f2a 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -52,13 +52,13 @@ // // Trinamic Stallguard pins -// +////ga #define X_DIAG_PIN PB10 // X- #define Y_DIAG_PIN PE12 // Y- #define Z_DIAG_PIN PG8 // Z- #define E0_DIAG_PIN PE15 // E0 -#define E1_DIAG_PIN PE10 // E1 -#define E2_DIAG_PIN PG5 // E2 +//#define E1_DIAG_PIN PE10 // E1 +//#define E2_DIAG_PIN PG5 // E2 // // Limit Switches @@ -121,27 +121,27 @@ // // Steppers -// +////ga #define X_STEP_PIN PE9 #define X_DIR_PIN PF1 #define X_ENABLE_PIN PF2 -#ifndef X_CS_PIN - #define X_CS_PIN PA15 -#endif +//#ifndef X_CS_PIN + //#define X_CS_PIN PA15 +//#endif #define Y_STEP_PIN PE11 #define Y_DIR_PIN PE8 #define Y_ENABLE_PIN PD7 - #ifndef Y_CS_PIN - #define Y_CS_PIN PB8 -#endif +//#ifndef Y_CS_PIN + //#define Y_CS_PIN PB8 +//#endif #define Z_STEP_PIN PE13 #define Z_DIR_PIN PC2 #define Z_ENABLE_PIN PC0 -#ifndef Z_CS_PIN - #define Z_CS_PIN PB9 -#endif +//#ifndef Z_CS_PIN + //#define Z_CS_PIN PB9 +//#endif #define E0_STEP_PIN PE14 #define E0_DIR_PIN PA0 @@ -150,6 +150,7 @@ #define E0_CS_PIN PB3 #endif +/* #define E1_STEP_PIN PD15 #define E1_DIR_PIN PE7 #define E1_ENABLE_PIN PA3 @@ -164,6 +165,7 @@ #define E2_CS_PIN PG12 #endif +*/ // // Software SPI pins for TMC2130 stepper drivers // @@ -210,6 +212,7 @@ #define Z_SERIAL_TX_PIN PE1 #define Z_SERIAL_RX_PIN PE1 + /* #define E0_SERIAL_TX_PIN PD4 #define E0_SERIAL_RX_PIN PD4 @@ -218,6 +221,7 @@ #define E2_SERIAL_TX_PIN PD6 #define E2_SERIAL_RX_PIN PD6 + */ // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 @@ -226,8 +230,8 @@ // // Temperature Sensors // -#define TEMP_0_PIN PF4 // T1 <-> E0 -#define TEMP_1_PIN PF5 // T2 <-> E1 +//#define TEMP_0_PIN PF4 // T1 <-> E0 +//#define TEMP_1_PIN PF5 // T2 <-> E1 #define TEMP_2_PIN PF6 // T3 <-> E2 #define TEMP_BED_PIN PF3 // T0 <-> Bed From 6cd413378e7e140425d7ebf8c7620e21ace4145b Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Mon, 14 Dec 2020 12:22:02 -0500 Subject: [PATCH 21/44] Revert "setup platformio.ini" This reverts commit 0d4336241ca692ac06204ce8bfa9493b1f1b6a67. --- platformio.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 7849190cc983..9c3e8ef0185a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -18,8 +18,7 @@ [platformio] src_dir = Marlin boards_dir = buildroot/share/PlatformIO/boards -#LPC1768 LPC1769 BIGTREE_SKR_PRO BIGTREE_GTR_V1_0 STM32F103RET6_creality mega2560 STM32F103RC_btt -default_envs = LPC1769 +default_envs = mega2560 include_dir = Marlin # From a6ba31cacb9950843be97dd5e8de3100638c298e Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Mon, 14 Dec 2020 12:24:08 -0500 Subject: [PATCH 22/44] Revert "Created Compatibility Layer for MAX boards" This reverts commit 87263e051fea065e38e8bbb5da43778801b6d705. --- Marlin/Configuration.h | 112 +++++++------- Marlin/Configuration_adv.h | 43 +++--- Marlin/src/inc/Conditionals_post.h | 41 ------ Marlin/src/module/temperature.cpp | 95 +++++++----- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h | 44 +++--- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 68 +++++---- Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h | 139 +----------------- Marlin/src/pins/ramps/pins_RAMPS.h | 23 +-- .../pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h | 6 +- .../stm32f1/pins_BTT_SKR_MINI_E3_common.h | 22 ++- Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h | 54 +++---- .../pins/stm32f4/pins_BTT_SKR_PRO_common.h | 34 ++--- 12 files changed, 244 insertions(+), 437 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index b6b70c9902e0..d528a97bf783 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -70,7 +70,7 @@ // @section info // Author info of this build printed to the host during boot and M115 -#define STRING_CONFIG_H_AUTHOR "(GadgetAngel, Ender-3 Pro)" // Who made the changes. +#define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. //#define CUSTOM_VERSION_FILE Version.h // Path from the root directory (no quotes) /** @@ -103,14 +103,14 @@ * * :[-1, 0, 1, 2, 3, 4, 5, 6, 7] */ -#define SERIAL_PORT -1 -//ga +#define SERIAL_PORT 0 + /** * Select a secondary serial port on the board to use for communication with the host. * Currently Ethernet (-2) is only supported on Teensy 4.1 boards. * :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7] - *///ga -//#define SERIAL_PORT_2 -1 //0 for SKR V1.3/V1.4 for TFT // 1 for SKR PRO // 3 for GTR + */ +//#define SERIAL_PORT_2 -1 /** * This setting determines the communication speed of the printer. @@ -121,18 +121,18 @@ * * :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] */ -#define BAUDRATE 115200 +#define BAUDRATE 250000 // Enable the Bluetooth serial interface on AT90USB devices //#define BLUETOOTH -//ga + // Choose the name from boards.h that matches your setup #ifndef MOTHERBOARD - #define MOTHERBOARD BOARD_BTT_SKR_V1_4_TURBO //BOARD_RAMPS_14_EFB BOARD_BTT_SKR_V1_4 BOARD_BTT_SKR_V1_4_TURBO BOARD_BTT_SKR_PRO_V1_1 BOARD_BTT_GTR_V1_0 BOARD_BTT_SKR_MINI_E3_V1_2 BOARD_CREALITY_V427 + #define MOTHERBOARD BOARD_RAMPS_14_EFB #endif // Name displayed in the LCD "Ready" message and Info menu -#define CUSTOM_MACHINE_NAME "Ender-3 Pro" +//#define CUSTOM_MACHINE_NAME "3D Printer" // Printer's unique ID, used by some programs to differentiate between machines. // Choose your own or use a service like https://www.uuidgenerator.net/version4 @@ -142,7 +142,6 @@ // This defines the number of extruders // :[0, 1, 2, 3, 4, 5, 6, 7, 8] -//ga #define EXTRUDERS 1 // Generally expected filament diameter (1.75, 2.85, 3.0, ...). Used for Volumetric, Filament Width Sensor, etc. @@ -408,8 +407,8 @@ * Use these for Testing or Development purposes. NEVER for production machine. * 998 : Dummy Table that ALWAYS reads 25°C or the temperature defined below. * 999 : Dummy Table that ALWAYS reads 100°C or the temperature defined below. - *///ga -#define TEMP_SENSOR_0 -5 + */ +#define TEMP_SENSOR_0 1 #define TEMP_SENSOR_1 0 #define TEMP_SENSOR_2 0 #define TEMP_SENSOR_3 0 @@ -417,7 +416,7 @@ #define TEMP_SENSOR_5 0 #define TEMP_SENSOR_6 0 #define TEMP_SENSOR_7 0 -#define TEMP_SENSOR_BED 1 +#define TEMP_SENSOR_BED 0 #define TEMP_SENSOR_PROBE 0 #define TEMP_SENSOR_CHAMBER 0 @@ -426,10 +425,10 @@ #define DUMMY_THERMISTOR_999_VALUE 100 // Resistor values when using MAX31865 sensors (-5) on TEMP_SENSOR_0 / 1 -#define MAX31865_SENSOR_OHMS_0 100 // (Ω) Typically 100 or 1000 (PT100 or PT1000) -#define MAX31865_CALIBRATION_OHMS_0 430 // (Ω) Typically 430 for AdaFruit PT100; 4300 for AdaFruit PT1000 -#define MAX31865_SENSOR_OHMS_1 100 -#define MAX31865_CALIBRATION_OHMS_1 430 +//#define MAX31865_SENSOR_OHMS_0 100 // (Ω) Typically 100 or 1000 (PT100 or PT1000) +//#define MAX31865_CALIBRATION_OHMS_0 430 // (Ω) Typically 430 for AdaFruit PT100; 4300 for AdaFruit PT1000 +//#define MAX31865_SENSOR_OHMS_1 100 +//#define MAX31865_CALIBRATION_OHMS_1 430 // Use temp sensor 1 as a redundant sensor with sensor 0. If the readings // from the two sensors differ too much the print will be aborted. @@ -467,7 +466,7 @@ #define HEATER_5_MAXTEMP 275 #define HEATER_6_MAXTEMP 275 #define HEATER_7_MAXTEMP 275 -#define BED_MAXTEMP 125 +#define BED_MAXTEMP 150 //=========================================================================== //============================= PID Settings ================================ @@ -481,22 +480,21 @@ #define PID_K1 0.95 // Smoothing factor within any PID loop #if ENABLED(PIDTEMP) - #define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM) - #define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) + //#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM) + //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) // Set/get with gcode: M301 E[extruder number, 0-2] - // Creality Ender-3 #if ENABLED(PID_PARAMS_PER_HOTEND) // Specify between 1 and HOTENDS values per array. // If fewer than EXTRUDER values are provided, the last element will be repeated. - #define DEFAULT_Kp_LIST { 21.73, 21.73 } - #define DEFAULT_Ki_LIST { 1.54, 1.54 } - #define DEFAULT_Kd_LIST { 76.55, 76.55 } + #define DEFAULT_Kp_LIST { 22.20, 22.20 } + #define DEFAULT_Ki_LIST { 1.08, 1.08 } + #define DEFAULT_Kd_LIST { 114.00, 114.00 } #else - #define DEFAULT_Kp 21.73 - #define DEFAULT_Ki 1.54 - #define DEFAULT_Kd 76.55 + #define DEFAULT_Kp 22.20 + #define DEFAULT_Ki 1.08 + #define DEFAULT_Kd 114.00 #endif #endif // PIDTEMP @@ -586,9 +584,9 @@ * details can be tuned in Configuration_adv.h */ -//#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders -//#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed -//#define THERMAL_PROTECTION_CHAMBER // Enable thermal protection for the heated chamber +#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed +#define THERMAL_PROTECTION_CHAMBER // Enable thermal protection for the heated chamber //=========================================================================== //============================= Mechanical Settings ========================= @@ -674,16 +672,16 @@ * TMC26X, TMC26X_STANDALONE, TMC2660, TMC2660_STANDALONE, * TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE'] - *///ga -#define X_DRIVER_TYPE TMC2209 -#define Y_DRIVER_TYPE TMC2209 -#define Z_DRIVER_TYPE TMC2209 + */ +#define X_DRIVER_TYPE A4988 +#define Y_DRIVER_TYPE A4988 +#define Z_DRIVER_TYPE A4988 //#define X2_DRIVER_TYPE A4988 //#define Y2_DRIVER_TYPE A4988 //#define Z2_DRIVER_TYPE A4988 //#define Z3_DRIVER_TYPE A4988 //#define Z4_DRIVER_TYPE A4988 -#define E0_DRIVER_TYPE TMC2130 +#define E0_DRIVER_TYPE A4988 //#define E1_DRIVER_TYPE A4988 //#define E2_DRIVER_TYPE A4988 //#define E3_DRIVER_TYPE A4988 @@ -738,14 +736,14 @@ * Override with M92 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 93 } +#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 500 } /** * Default Max Feed Rate (mm/s) * Override with M203 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_MAX_FEEDRATE { 500, 500, 5, 25 } +#define DEFAULT_MAX_FEEDRATE { 300, 300, 5, 25 } //#define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2 #if ENABLED(LIMITED_MAX_FR_EDITING) @@ -758,7 +756,7 @@ * Override with M201 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_MAX_ACCELERATION { 500, 500, 100, 5000 } +#define DEFAULT_MAX_ACCELERATION { 3000, 3000, 100, 10000 } //#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2 #if ENABLED(LIMITED_MAX_ACCEL_EDITING) @@ -773,9 +771,9 @@ * M204 R Retract Acceleration * M204 T Travel Acceleration */ -#define DEFAULT_ACCELERATION 500 // X, Y, Z and E acceleration for printing moves -#define DEFAULT_RETRACT_ACCELERATION 500 // E acceleration for retracts -#define DEFAULT_TRAVEL_ACCELERATION 500 // X, Y, Z acceleration for travel (non printing) moves +#define DEFAULT_ACCELERATION 3000 // X, Y, Z and E acceleration for printing moves +#define DEFAULT_RETRACT_ACCELERATION 3000 // E acceleration for retracts +#define DEFAULT_TRAVEL_ACCELERATION 3000 // X, Y, Z acceleration for travel (non printing) moves /** * Default Jerk limits (mm/s) @@ -809,7 +807,7 @@ * https://blog.kyneticcnc.com/2018/10/computing-junction-deviation-for-marlin.html */ #if DISABLED(CLASSIC_JERK) - #define JUNCTION_DEVIATION_MM 0.08 // (mm) Distance from real junction edge + #define JUNCTION_DEVIATION_MM 0.013 // (mm) Distance from real junction edge #define JD_HANDLE_SMALL_SEGMENTS // Use curvature estimation instead of just the junction angle // for small segments (< 1mm) with large junction angles (> 135°). #endif @@ -1088,14 +1086,14 @@ // @section extruder #define DISABLE_E false // Disable the extruder when not stepping -//#define DISABLE_INACTIVE_EXTRUDER // Keep only the active extruder enabled +#define DISABLE_INACTIVE_EXTRUDER // Keep only the active extruder enabled // @section machine // Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. #define INVERT_X_DIR false -#define INVERT_Y_DIR false -#define INVERT_Z_DIR true +#define INVERT_Y_DIR true +#define INVERT_Z_DIR false // @section extruder @@ -1129,8 +1127,8 @@ // @section machine // The size of the print bed -#define X_BED_SIZE 235 -#define Y_BED_SIZE 235 +#define X_BED_SIZE 200 +#define Y_BED_SIZE 200 // Travel limits (mm) after homing, corresponding to endstop positions. #define X_MIN_POS 0 @@ -1138,7 +1136,7 @@ #define Z_MIN_POS 0 #define X_MAX_POS X_BED_SIZE #define Y_MAX_POS Y_BED_SIZE -#define Z_MAX_POS 250 +#define Z_MAX_POS 200 /** * Software Endstops @@ -1449,7 +1447,7 @@ #endif // Homing speeds (mm/min) -#define HOMING_FEEDRATE_XY (20*60) +#define HOMING_FEEDRATE_XY (50*60) #define HOMING_FEEDRATE_Z (4*60) // Validate that endstops are triggered on homing moves @@ -1527,12 +1525,12 @@ * M501 - Read settings from EEPROM. (i.e., Throw away unsaved changes) * M502 - Revert settings to "factory" defaults. (Follow with M500 to init the EEPROM.) */ -#define EEPROM_SETTINGS // Persistent storage with M500 and M501 +//#define EEPROM_SETTINGS // Persistent storage with M500 and M501 //#define DISABLE_M503 // Saves ~2700 bytes of PROGMEM. Disable for release! #define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save PROGMEM. #define EEPROM_BOOT_SILENT // Keep M503 quiet and only give errors during first load #if ENABLED(EEPROM_SETTINGS) - #define EEPROM_AUTO_INIT // Init EEPROM automatically on any errors. + //#define EEPROM_AUTO_INIT // Init EEPROM automatically on any errors. #endif // @@ -1779,7 +1777,7 @@ * * SD Card support is disabled by default. If your controller has an SD slot, * you must uncomment the following option or it won't work. - *///ga + */ //#define SDSUPPORT /** @@ -1867,7 +1865,7 @@ // // If you have a speaker that can produce tones, enable it here. // By default Marlin assumes you have a buzzer with a fixed frequency. -////ga +// //#define SPEAKER // @@ -2040,8 +2038,8 @@ // // RepRapDiscount FULL GRAPHIC Smart Controller // https://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller -////ga -#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER +// +//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER // // ReprapWorld Graphical LCD @@ -2128,9 +2126,7 @@ // (For CR-10 owners who want to replace the Melzi Creality board but retain the display) // //#define CR10_STOCKDISPLAY -#if ENABLED(CR10_STOCKDISPLAY) - #define RET6_12864_LCD // Specific to the SoC (can either be RET / VET) -#endif + // // Ender-2 OEM display, a variant of the MKS_MINI_12864 // diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 6fb9b056fbf1..9e5ebb33ba7f 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -47,7 +47,7 @@ * stream of errors from the sensor. * * Set this value to 0 to fail on the first error to occur. - *///ga + */ #define THERMOCOUPLE_MAX_ERRORS 15 // @@ -325,7 +325,7 @@ // Show Temperature ADC value // Enable for M105 to include ADC values read from temperature sensors. -#define SHOW_TEMP_ADC_VALUES +//#define SHOW_TEMP_ADC_VALUES /** * High Temperature Thermistor Support @@ -345,8 +345,7 @@ // The number of consecutive low temperature errors that can occur // before a min_temp_error is triggered. (Shouldn't be more than 10.) -//ga -#define MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED 15 +//#define MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED 0 // The number of milliseconds a hotend will preheat before starting to check // the temperature. This value should NOT be set to the time it takes the @@ -662,7 +661,7 @@ //#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (mm) Backoff from endstops after homing -#define QUICK_HOME // If G28 contains XY do a diagonal move first +//#define QUICK_HOME // If G28 contains XY do a diagonal move first //#define HOME_Y_BEFORE_X // If G28 contains XY home Y before X //#define HOME_Z_FIRST // Home Z first. Requires a Z-MIN endstop (not a probe). //#define CODEPENDENT_XY_HOMING // If X/Y can't home without homing Y/X first @@ -713,7 +712,7 @@ * differs, a mode set eeprom write will be completed at initialization. * Use the option below to force an eeprom write to a V3.1 probe regardless. */ - #define BLTOUCH_SET_5V_MODE + //#define BLTOUCH_SET_5V_MODE /** * Safety: Activate if connecting a probe with an unknown voltage mode. @@ -850,7 +849,7 @@ #define DISABLE_INACTIVE_X true #define DISABLE_INACTIVE_Y true #define DISABLE_INACTIVE_Z true // Set 'false' if the nozzle could fall onto your printed part! -#define DISABLE_INACTIVE_E false //ga +#define DISABLE_INACTIVE_E true // If the Nozzle or Bed falls when the Z stepper is disabled, set its resting position here. //#define Z_AFTER_DEACTIVATE Z_HOME_POS @@ -1136,7 +1135,7 @@ #endif // HAS_LCD_MENU // Scroll a longer status message into view -#define STATUS_MESSAGE_SCROLLING +//#define STATUS_MESSAGE_SCROLLING // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY @@ -1190,7 +1189,7 @@ #define SD_PROCEDURE_DEPTH 1 // Increase if you need more nested M32 calls - #define SD_FINISHED_STEPPERRELEASE false // Disable steppers when SD Print is finished + #define SD_FINISHED_STEPPERRELEASE true // Disable steppers when SD Print is finished #define SD_FINISHED_RELEASECOMMAND "M84" // Use "M84XYE" to keep Z enabled so your bed stays in place // Reverse SD sort to show "more recent" files first, according to the card's FAT. @@ -1282,7 +1281,7 @@ //#define LONG_FILENAME_HOST_SUPPORT // Enable this option to scroll long filenames in the SD card menu - #define SCROLL_LONG_FILENAMES + //#define SCROLL_LONG_FILENAMES // Leave the heaters on after Stop Print (not recommended!) //#define SD_ABORT_NO_COOLDOWN @@ -1642,7 +1641,7 @@ #define BABYSTEP_MULTIPLICATOR_Z 1 // (steps or mm) Steps or millimeter distance for each Z babystep #define BABYSTEP_MULTIPLICATOR_XY 1 // (steps or mm) Steps or millimeter distance for each XY babystep - #define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping. + //#define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping. #if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING) #define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds. // Note: Extra time may be added to mitigate controller latency. @@ -2297,7 +2296,7 @@ #define INTERPOLATE true #if AXIS_IS_TMC(X) - #define X_CURRENT 760 // (mA) RMS current. Multiply by 1.414 for peak current. + #define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current. #define X_CURRENT_HOME X_CURRENT // (mA) RMS current for sensorless homing #define X_MICROSTEPS 16 // 0..256 #define X_RSENSE 0.11 @@ -2315,7 +2314,7 @@ #endif #if AXIS_IS_TMC(Y) - #define Y_CURRENT 760 + #define Y_CURRENT 800 #define Y_CURRENT_HOME Y_CURRENT #define Y_MICROSTEPS 16 #define Y_RSENSE 0.11 @@ -2333,7 +2332,7 @@ #endif #if AXIS_IS_TMC(Z) - #define Z_CURRENT 760 + #define Z_CURRENT 800 #define Z_CURRENT_HOME Z_CURRENT #define Z_MICROSTEPS 16 #define Z_RSENSE 0.11 @@ -2369,7 +2368,7 @@ #endif #if AXIS_IS_TMC(E0) - #define E0_CURRENT 900 + #define E0_CURRENT 800 #define E0_MICROSTEPS 16 #define E0_RSENSE 0.11 #define E0_CHAIN_POS -1 @@ -2456,8 +2455,8 @@ * Software option for SPI driven drivers (TMC2130, TMC2160, TMC2660, TMC5130 and TMC5160). * The default SW SPI pins are defined the respective pins files, * but you can override or define them here. - *///ga - #define TMC_USE_SW_SPI + */ + //#define TMC_USE_SW_SPI //#define TMC_SW_MOSI -1 //#define TMC_SW_MISO -1 //#define TMC_SW_SCK -1 @@ -2523,7 +2522,7 @@ * Define your own with: * { , , hysteresis_start[1..8] } */ - #define CHOPPER_TIMING CHOPPER_DEFAULT_24V // All axes (override below) + #define CHOPPER_TIMING CHOPPER_DEFAULT_12V // All axes (override below) //#define CHOPPER_TIMING_X CHOPPER_DEFAULT_12V // For X Axes (override below) //#define CHOPPER_TIMING_X2 CHOPPER_DEFAULT_12V //#define CHOPPER_TIMING_Y CHOPPER_DEFAULT_12V // For Y Axes (override below) @@ -2551,8 +2550,8 @@ * M911 - Report stepper driver overtemperature pre-warn condition. * M912 - Clear stepper driver overtemperature pre-warn condition flag. * M122 - Report driver parameters (Requires TMC_DEBUG) - *///ga - #define MONITOR_DRIVER_STATUS + */ + //#define MONITOR_DRIVER_STATUS #if ENABLED(MONITOR_DRIVER_STATUS) #define CURRENT_STEP_DOWN 50 // [mA] @@ -2648,8 +2647,8 @@ /** * Enable M122 debugging command for TMC stepper drivers. * M122 S0/1 will enable continous reporting. - *///ga - #define TMC_DEBUG + */ + //#define TMC_DEBUG /** * You can set your own advanced settings by filling in predefined functions. diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 3070548ff0c2..d1028c6997f2 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -483,47 +483,6 @@ #define MAX6675_HAS_MAX6675 1 #endif -// -// Compatibility layer for MAX (SPI) temp boards -// -#if PIN_EXISTS(MAX6675_SS) - #if MAX6675_0_IS_MAX31855 - #define MAX31855_CS_PIN MAX6675_SS_PIN - #elif MAX6675_0_IS_MAX31865 - #define MAX31865_CS_PIN MAX6675_SS_PIN - #elif MAX6675_0_IS_MAX6675 - #define MAX6675_CS_PIN MAX6675_SS_PIN - #endif -#endif - -#if PIN_EXISTS(MAX6675_SS2) - #if MAX6675_1_IS_MAX31855 - #define MAX31855_CS2_PIN MAX6675_SS2_PIN - #elif MAX6675_1_IS_MAX31865 - #define MAX31865_CS2_PIN MAX6675_SS2_PIN - #elif MAX6675_1_IS_MAX6675 - #define MAX6675_CS2_PIN MAX6675_SS2_PIN - #endif -#endif - -#if PIN_EXISTS(MAX6675_DO) - #if MAX6675_HAS_MAX31855 - #define MAX31855_MISO_PIN MAX6675_DO_PIN - #elif MAX6675_HAS_MAX31865 - #define MAX31865_MISO_PIN MAX6675_DO_PIN - #elif MAX6675_HAS_MAX6675 - #define MAX6675_MISO_PIN MAX6675_DO_PIN - #endif -#endif - -#if PIN_EXISTS(MAX6675_SCK) - #if MAX6675_HAS_MAX31855 - #define MAX31855_SCK_PIN MAX6675_SCK_PIN - #elif MAX6675_HAS_MAX31865 - #define MAX31865_SCK_PIN MAX6675_SCK_PIN - #endif -#endif - #if TEMP_SENSOR_2 == -4 #define HEATER_2_USES_AD8495 1 #elif TEMP_SENSOR_2 == -3 diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index dc9fb638a300..55939ed30ffb 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -25,7 +25,6 @@ */ // Useful when debugging thermocouples -//ga //#define IGNORE_THERMOCOUPLE_ERRORS #include "temperature.h" @@ -44,16 +43,28 @@ #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" #endif -//ga + #if MAX6675_HAS_MAX31855 #include - #if PIN_EXISTS(MAX31855_MISO) && PIN_EXISTS(MAX31855_SCK) - #define MAX31855_USES_SW_SPI 1 + #if MAX6675_0_IS_MAX31855 && !defined(MAX31855_CS_PIN) && PIN_EXISTS(MAX6675_SS) + #define MAX31855_CS_PIN MAX6675_SS_PIN + #endif + #if MAX6675_1_IS_MAX31855 && !defined(MAX31855_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) + #define MAX31855_CS2_PIN MAX6675_SS2_PIN + #endif + #if !defined(MAX31855_MISO_PIN) && PIN_EXISTS(MAX6675_DO) + #define MAX31855_MISO_PIN MAX6675_DO_PIN + #endif + #if !defined(MAX31855_SCK_PIN) && PIN_EXISTS(MAX6675_SCK) + #define MAX31855_SCK_PIN MAX6675_SCK_PIN + #endif + #if ANY_PIN(MAX6675_DO, MAX31855_MISO) && ANY_PIN(MAX6675_SCK, MAX31855_SCK) + #define MAX31855_USES_SW_LIB 1 #endif #if MAX6675_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS) #define HAS_MAX31855_TEMP 1 Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855(MAX31855_CS_PIN - #if MAX31855_USES_SW_SPI + #if MAX31855_USES_SW_LIB , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK #endif ); @@ -61,7 +72,7 @@ #if MAX6675_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2) #define HAS_MAX31855_TEMP 1 Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855(MAX31855_CS2_PIN - #if MAX31855_USES_SW_SPI + #if MAX31855_USES_SW_LIB , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK #endif ); @@ -70,13 +81,28 @@ #if MAX6675_HAS_MAX31865 #include - #if PIN_EXISTS(MAX31865_MISO) && PIN_EXISTS(MAX31865_SCK) - #define MAX31865_USES_SW_SPI 1 + #if MAX6675_0_IS_MAX31865 && !defined(MAX31865_CS_PIN) && PIN_EXISTS(MAX6675_SS) + #define MAX31865_CS_PIN MAX6675_SS_PIN + #endif + #if MAX6675_1_IS_MAX31865 && !defined(MAX31865_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) + #define MAX31865_CS2_PIN MAX6675_SS2_PIN + #endif + #ifndef MAX31865_MOSI_PIN + #define MAX31865_MOSI_PIN MOSI_PIN + #endif + #if !defined(MAX31865_MISO_PIN) && PIN_EXISTS(MAX6675_DO) + #define MAX31865_MISO_PIN MAX6675_DO_PIN + #endif + #if !defined(MAX31865_SCK_PIN) && PIN_EXISTS(MAX6675_SCK) + #define MAX31865_SCK_PIN MAX6675_SCK_PIN + #endif + #if ANY_PIN(MAX6675_DO, MAX31865_MISO) && ANY_PIN(MAX6675_SCK, MAX31865_SCK) + #define MAX31865_USES_SW_LIB 1 #endif #if MAX6675_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS) #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN - #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) + #if MAX31865_USES_SW_LIB , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK #endif ); @@ -84,7 +110,7 @@ #if MAX6675_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2) #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN - #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) + #if MAX31865_USES_SW_LIB , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK #endif ); @@ -93,13 +119,22 @@ #if MAX6675_HAS_MAX6675 #include - #if PIN_EXISTS(MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK) - #define MAX6675_USES_SW_SPI 1 + #if MAX6675_0_IS_MAX6675 && !defined(MAX6675_CS_PIN) && PIN_EXISTS(MAX6675_SS) + #define MAX6675_CS_PIN MAX6675_SS_PIN + #endif + #if MAX6675_1_IS_MAX6675 && !defined(MAX6675_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) + #define MAX6675_CS2_PIN MAX6675_SS2_PIN + #endif + #if !defined(MAX6675_MISO_PIN) && PIN_EXISTS(MAX6675_DO) + #define MAX6675_MISO_PIN MAX6675_DO_PIN + #endif + #if ANY_PIN(MAX6675_DO, MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK) + #define MAX6675_USES_SW_LIB 1 #endif #if MAX6675_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) #define HAS_MAX6675_TEMP 1 MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN - #if MAX6675_USES_SW_SPI + #if MAX6675_USES_SW_LIB && PIN_EXISTS(MAX6675_SCK) , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif ); @@ -107,7 +142,7 @@ #if MAX6675_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) #define HAS_MAX6675_TEMP 1 MAX6675 max6675_1 = MAX6675(MAX6675_CS2_PIN - #if MAX6675_USES_SW_SPI + #if MAX6675_USES_SW_LIB && PIN_EXISTS(MAX6675_SCK) , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif ); @@ -1506,7 +1541,7 @@ void Temperature::manage_heater() { return _MIN(value + THERMISTOR_ABS_ZERO_C, 999); } #endif -//ga + #if HAS_HOTEND // Derived from RepRap FiveD extruder::getTemperature() // For hot end temperature measurement. @@ -1679,7 +1714,7 @@ void Temperature::manage_heater() { * The raw values are created in interrupt context, * and this function is called from normal context * as it would block the stepper routine. - *///ga + */ void Temperature::updateTemperaturesFromRawValues() { TERN_(HEATER_0_USES_MAX6675, temp_hotend[0].raw = READ_MAX6675(0)); TERN_(HEATER_1_USES_MAX6675, temp_hotend[1].raw = READ_MAX6675(1)); @@ -1699,7 +1734,6 @@ void Temperature::updateTemperaturesFromRawValues() { raw_temps_ready = false; } -//ga #if MAX6675_SEPARATE_SPI template SoftSPI SPIclass::softSPI; SPIclass max6675_spi; @@ -1738,7 +1772,7 @@ void Temperature::updateTemperaturesFromRawValues() { * The manager is implemented by periodic calls to manage_heater() */ void Temperature::init() { -//ga + TERN_(MAX6675_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE TERN_(MAX6675_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE)); #if HAS_MAX31855_TEMP @@ -1847,7 +1881,6 @@ void Temperature::init() { INIT_FAN_PIN(CONTROLLER_FAN_PIN); #endif - //ga TERN_(MAX6675_SEPARATE_SPI, max6675_spi.init()); HAL_adc_init(); @@ -2238,7 +2271,7 @@ void Temperature::disable_all_heaters() { #endif // PROBING_HEATERS_OFF #if HAS_MAX6675 -//ga + #ifndef THERMOCOUPLE_MAX_ERRORS #define THERMOCOUPLE_MAX_ERRORS 15 #endif @@ -2297,7 +2330,7 @@ void Temperature::disable_all_heaters() { // // TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used. - ////ga + // #if !MAX6675_SEPARATE_SPI && NO_THERMO_TEMPS spiBegin(); spiInit(MAX6675_SPEED_BITS); @@ -2326,9 +2359,6 @@ void Temperature::disable_all_heaters() { #if HAS_MAX31865_TEMP Adafruit_MAX31865 &max865ref = MAX6675_SEL(max31865_0, max31865_1); max6675_temp = max865ref.readRTD_with_Fault(); - #if ECHO_TEMP - SERIAL_ECHOLNPAIR("Max31865 RTD MSB: ", max6675_temp >> 8 ," LSB: ", max6675_temp & 0x00FF," "); - #endif #endif #if HAS_MAX6675_TEMP @@ -2341,7 +2371,6 @@ void Temperature::disable_all_heaters() { const uint8_t fault_31865 = TERN1(HAS_MAX31865_TEMP, (max865ref.readFault() & 0x3FU)); - //ga if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK) && fault_31865) { max6675_errors[hindex]++; if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { @@ -2397,18 +2426,6 @@ void Temperature::disable_all_heaters() { #if MAX6675_HAS_MAX31865 max6675_temp = (uint32_t(max6675_temp) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; #endif - //ga - #if ECHO_TEMP - #if HAS_MAX31855 || HAS_MAX6675_TEMP - SERIAL_ECHOLNPAIR("Temp: ", max6675_temp ," "); - #endif - #if HAS_MAX6675_TEMP - SERIAL_ECHOLNPAIR("Max6675 Temp in Celsius : ", max6675ref.readCelsius() ," "); - #endif - #if MAX6675_HAS_MAX31865 && ECHO_MAX31865_RESITANCE - SERIAL_ECHOLNPAIR("MAX31865 RTD readRTD_Resistance : ", max865ref.readRTD_Resistance(MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) ," Calculated : ", max6675_temp ," "); - #endif - #endif MAX6675_TEMP(hindex) = max6675_temp; @@ -2489,9 +2506,7 @@ void Temperature::readings_ready() { const int8_t tdir = temp_dir[e]; if (tdir) { const int16_t rawtemp = temp_hotend[e].raw * tdir; // normal direction, +rawtemp, else -rawtemp - //ga NEEDED FOR TESTING ON THE BENCH WITH TEMPERATURE SENSORS - //const bool heater_on = (temp_hotend[e].target > 0 - const bool heater_on = (temp_hotend[e].target >= 0 + const bool heater_on = (temp_hotend[e].target > 0 || TERN0(PIDTEMP, temp_hotend[e].soft_pwm_amount) > 0 ); if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error((heater_id_t)e); 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 af702f720b6d..c621f93a2ac5 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -25,12 +25,12 @@ // // Trinamic Stallguard pins -////ga +// #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+ +#define E1_DIAG_PIN P1_26 // Y+ // // Limit Switches @@ -96,27 +96,27 @@ // // Steppers -////ga +// #define X_STEP_PIN P2_02 #define X_DIR_PIN P2_06 #define X_ENABLE_PIN P2_01 -//#ifndef X_CS_PIN - //#define X_CS_PIN P1_17 -//#endif +#ifndef X_CS_PIN + #define X_CS_PIN P1_17 +#endif #define Y_STEP_PIN P0_19 #define Y_DIR_PIN P0_20 #define Y_ENABLE_PIN P2_08 -//#ifndef Y_CS_PIN - //#define Y_CS_PIN P1_15 -//#endif +#ifndef Y_CS_PIN + #define Y_CS_PIN P1_15 +#endif #define Z_STEP_PIN P0_22 #define Z_DIR_PIN P2_11 #define Z_ENABLE_PIN P0_21 -//#ifndef Z_CS_PIN - //#define Z_CS_PIN P1_10 -//#endif +#ifndef Z_CS_PIN + #define Z_CS_PIN P1_10 +#endif #define E0_STEP_PIN P2_13 #define E0_DIR_PIN P0_11 @@ -125,13 +125,13 @@ #define E0_CS_PIN P1_08 #endif -//#ifndef E1_CS_PIN - //#define E1_CS_PIN P1_01 -//#endif +#ifndef E1_CS_PIN + #define E1_CS_PIN P1_01 +#endif // // Software SPI pins for TMC2130 stepper drivers -////ga +// #if ENABLED(TMC_USE_SW_SPI) #ifndef TMC_SW_MOSI #define TMC_SW_MOSI P4_28 @@ -165,7 +165,7 @@ // // Software serial - ////ga + // #define X_SERIAL_TX_PIN P4_29 #define X_SERIAL_RX_PIN P1_17 @@ -175,11 +175,11 @@ #define Z_SERIAL_TX_PIN P1_14 #define Z_SERIAL_RX_PIN P1_10 - //#define E0_SERIAL_TX_PIN P1_09 - //#define E0_SERIAL_RX_PIN P1_08 + #define E0_SERIAL_TX_PIN P1_09 + #define E0_SERIAL_RX_PIN P1_08 - //#define E1_SERIAL_TX_PIN P1_04 - //#define E1_SERIAL_RX_PIN P1_01 + #define E1_SERIAL_TX_PIN P1_04 + #define E1_SERIAL_RX_PIN P1_01 // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 @@ -368,7 +368,7 @@ // // SD Support -////ga +// #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION LCD 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 f9bb9dd631ba..86fbd18ba28b 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -31,7 +31,7 @@ // // SD Connection -////ga +// #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION LCD #endif @@ -39,7 +39,7 @@ // // Servos // -//#define SERVO0_PIN P2_00 +#define SERVO0_PIN P2_00 // // TMC StallGuard DIAG pins @@ -48,7 +48,7 @@ #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 +#define E1_DIAG_PIN P1_25 // E1DET // // Limit Switches @@ -95,49 +95,49 @@ #define Z_MIN_PROBE_PIN P0_10 #endif -////ga +// // Filament Runout Sensor // -//#define FIL_RUNOUT_PIN P1_26 // E0DET -//#define FIL_RUNOUT2_PIN P1_25 // E1DET +#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 // PWRDET -//#endif +#ifndef PS_ON_PIN + #define PS_ON_PIN P1_00 // PWRDET +#endif // // Power Loss Detection // -//#ifndef POWER_LOSS_PIN - //#define POWER_LOSS_PIN P1_00 // PWRDET -//#endif +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN P1_00 // PWRDET +#endif // // Steppers -////ga +// #define X_STEP_PIN P2_02 #define X_DIR_PIN P2_06 #define X_ENABLE_PIN P2_01 -//#ifndef X_CS_PIN - //#define X_CS_PIN P1_10 -//#endif +#ifndef X_CS_PIN + #define X_CS_PIN P1_10 +#endif #define Y_STEP_PIN P0_19 #define Y_DIR_PIN P0_20 #define Y_ENABLE_PIN P2_08 -//#ifndef Y_CS_PIN - //#define Y_CS_PIN P1_09 -//#endif +#ifndef Y_CS_PIN + #define Y_CS_PIN P1_09 +#endif #define Z_STEP_PIN P0_22 #define Z_DIR_PIN P2_11 #define Z_ENABLE_PIN P0_21 -//#ifndef Z_CS_PIN - //#define Z_CS_PIN P1_08 -//#endif +#ifndef Z_CS_PIN + #define Z_CS_PIN P1_08 +#endif #define E0_STEP_PIN P2_13 #define E0_DIR_PIN P0_11 @@ -146,21 +146,19 @@ #define E0_CS_PIN P1_04 #endif -/* #define E1_STEP_PIN P1_15 #define E1_DIR_PIN P1_14 #define E1_ENABLE_PIN P1_16 -//#ifndef E1_CS_PIN - //#define E1_CS_PIN P1_01 -//#endif -*/ +#ifndef E1_CS_PIN + #define E1_CS_PIN P1_01 +#endif -//#define TEMP_1_PIN P0_23_A0 // A0 (T0) - (67) - TEMP_1_PIN +#define TEMP_1_PIN P0_23_A0 // A0 (T0) - (67) - TEMP_1_PIN #define TEMP_BED_PIN P0_25_A2 // A2 (T2) - (69) - TEMP_BED_PIN // // Software SPI pins for TMC2130 stepper drivers -////ga +// #if ENABLED(TMC_USE_SW_SPI) #ifndef TMC_SW_MOSI #define TMC_SW_MOSI P1_17 @@ -194,7 +192,7 @@ // // Software serial - ////ga + // #define X_SERIAL_TX_PIN P1_10 #define X_SERIAL_RX_PIN P1_10 @@ -204,11 +202,11 @@ #define Z_SERIAL_TX_PIN P1_08 #define Z_SERIAL_RX_PIN P1_08 - //#define E0_SERIAL_TX_PIN P1_04 - //#define E0_SERIAL_RX_PIN P1_04 + #define E0_SERIAL_TX_PIN P1_04 + #define E0_SERIAL_RX_PIN P1_04 - //#define E1_SERIAL_TX_PIN P1_01 - //#define E1_SERIAL_RX_PIN P1_01 + #define E1_SERIAL_TX_PIN P1_01 + #define E1_SERIAL_RX_PIN P1_01 // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 @@ -444,7 +442,7 @@ // NeoPixel LED // #ifndef NEOPIXEL_PIN - //#define NEOPIXEL_PIN P1_24 + #define NEOPIXEL_PIN P1_24 #endif /** diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h index ea4d14b5d63c..a8dd55bf2721 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -47,7 +47,6 @@ // // Steppers // -/* #ifndef E1_STEP_PIN #define E1_STEP_PIN P0_01 #endif @@ -58,16 +57,15 @@ #define E1_ENABLE_PIN P0_10 #endif -*/ // // Temperature Sensors // 3.3V max when defined as an analog input // #ifndef TEMP_0_PIN - //#define TEMP_0_PIN P0_24_A1 // A1 (T1) - (68) - TEMP_0_PIN + #define TEMP_0_PIN P0_24_A1 // A1 (T1) - (68) - TEMP_0_PIN #endif #ifndef TEMP_1_PIN - //#define TEMP_1_PIN P0_25_A2 // A2 (T2) - (69) - TEMP_1_PIN + #define TEMP_1_PIN P0_25_A2 // A2 (T2) - (69) - TEMP_1_PIN #endif #ifndef TEMP_BED_PIN #define TEMP_BED_PIN P0_23_A0 // A0 (T0) - (67) - TEMP_BED_PIN @@ -81,139 +79,6 @@ #endif #endif -//ga -// GADGETANGEL SECTION Begins ==============================================>> -// -// SET ONLY ONE of theses variables or NONE -#define TEMP_0_PIN P1_14 //SW P1_14 //HW P0_03 -#define TEMP_SENSOR_0_PIN TEMP_0_PIN -#define ECHO_TEMP 1 -#define ECHO_MAX31865_RESITANCE 0 -//#define TEMP_SENSOR_1_PIN P0_03 -// -#define MAX31865_SW_SPI //-5 -//#define MAX31865_HW_SPI //-5 -//#define MAX31855_SW_SPI //-3 -//#define MAX31855_HW_SPI //-3 -//#define MAX6675_SW_SPI //-2 -//#define MAX6675_HW_SPI //-2 - -#ifndef MAX6675_SS_PIN - #ifdef MAX31865_SW_SPI - #define MAX6675_DO_PIN P0_01 - //#define MAX31865_MISO_PIN P1_15 - #define MAX6675_SCK_PIN P1_01 - //#define MAX31865_SCK_PIN P1_01 - // - #define MAX31865_MOSI_PIN P0_03 - // - #define MAX31865_CS_PIN TEMP_SENSOR_0_PIN - //#define MAX6675_SS_PIN TEMP_SENSOR_0_PIN - // enable the below two lines if you have a second Adafruit MAX31865 in software SPI mode - //#define MAX31865_CS2_PIN TEMP_1_PIN - //#define MAX6675_SS2_PIN TEMP_1_PIN - #endif - - #ifdef MAX31865_HW_SPI - // SKR V1.4 or SKR V1.4 Turbo or SKR v1.3 - // if SD_CONNECTION_IS(LCD) - // SCK_PIN P0_15 - // MISO_PIN P0_17 - // MOSI_PIN P0_18 - // if SD_CONNECTION_IS(ONBOARD) - // SCK_PIN P0_07 - // MISO_PIN P0_08 - // MOSI_PIN P0_09 - // - //#define MAX6675_SS_PIN TEMP_SENSOR_0_PIN //P0_26 SPI header // - // below forces hardware spi - ////#define MAX31865_CS_PIN MAX6675_SS_PIN //forces Hardware SPI - #define MAX31865_CS_PIN TEMP_SENSOR_0_PIN - //enable the below two lines if you have a second Adafruit MAX31865 board on hardware SPI - //#define MAX6675_SS2_PIN TEMP_1_PIN //P1_00 - PWRDET - ////#define MAX31865_CS2_PIN MAX6675_SS2_PIN //forces Hardware SPI for the second MAX31865 board - //#define MAX31865_CS2_PIN TEMP_1_PIN - #endif - - //MAX31855 board configuration for Software SPI - #ifdef MAX31855_SW_SPI - //#define MAX6675_DO_PIN P1_15 //P1_15 is E1_STEP_PIN - #define MAX31855_MISO_PIN P1_15 - //#define MAX6675_SCK_PIN P1_01 //P1_01 is E1_SERIAL_RX_PIN - #define MAX31855_SCK_PIN P1_01 - //#define MAX6675_SS_PIN TEMP_0_PIN - //#define MAX6675_SS_PIN TEMP_SENSOR_0_PIN //P1_14 is E1_DIR_PIN - #define MAX31855_CS_PIN TEMP_0_PIN - //#define MAX31855_CS_PIN TEMP_SENSOR_0_PIN - //enable the next lines below if you have two MAX31855 boards - //#define MAX6675_SS2_PIN TEMP_1_PIN - //#define MAX31855_CS2_PIN TEMP_1_PIN - // - #endif - - //MAX31855 board configuration for Hardware SPI - #ifdef MAX31855_HW_SPI - // SKR V1.4 or SKR V1.4 Turbo or SKR v1.3 - // if SD_CONNECTION_IS(LCD) - // SCK_PIN P0_15 - // MISO_PIN P0_17 - // MOSI_PIN P0_18 - // if SD_CONNECTION_IS(ONBOARD) - // SCK_PIN P0_07 - // MISO_PIN P0_08 - // MOSI_PIN P0_09 - // - //uncomment the below line if you want MAX6675 Hardware SPI to be used - #define MAX6675_SS_PIN TEMP_SENSOR_0_PIN - //#define MAX6675_SS_PIN TEMP_0_PIN - //uncomment the below line if you want Adafruit MAX31855 Hardware SPI to be used - //#define MAX31855_CS_PIN TEMP_SENSOR_0_PIN - //#define MAX31855_CS_PIN TEMP_0_PIN - // - //enable the next lines below if you have two MAX31855 boards - // - //uncomment the below line if you want MAX6675 Hardware SPI to be used - //#define MAX6675_SS2_PIN TEMP_1_PIN - //uncomment the below line if you want Adafruit MAX31855 Hardware SPI to be used - //#define MAX31855_CS2_PIN TEMP_1_PIN - #endif - - //MAX6675 board configuration for Software SPI - #ifdef MAX6675_SW_SPI - //#define MAX6675_DO_PIN P1_15 - #define MAX6675_MISO_PIN P1_15 - #define MAX6675_SCK_PIN P1_01 - //#define MAX6675_SS_PIN TEMP_SENSOR_0_PIN - #define MAX6675_CS_PIN TEMP_SENSOR_0_PIN - //enable the next lines below if you have two MAX6675 boards - //#define MAX6675_SS2_PIN TEMP_1_PIN - //#define MAX6675_CS2_PIN TEMP_1_PIN - #endif - - //MAX6675 board configuration for Hardware SPI - #ifdef MAX6675_HW_SPI - // SKR V1.4 or SKR V1.4 Turbo or SKR v1.3 - // if SD_CONNECTION_IS(LCD) - // SCK_PIN P0_15 - // MISO_PIN P0_17 - // MOSI_PIN P0_18 - // if SD_CONNECTION_IS(ONBOARD) - // SCK_PIN P0_07 - // MISO_PIN P0_08 - // MOSI_PIN P0_09 - // - //#define MAX6675_SS_PIN TEMP_SENSOR_0_PIN - #define MAX6675_CS_PIN TEMP_SENSOR_0_PIN - //enable the next lines below if you have two MAX6675 boards - //uncomment the below line if you want MAX6675 Hardware SPI to be used - //#define MAX6675_SS2_PIN TEMP_1_PIN - //#define MAX6675_CS2_PIN TEMP_1_PIN - #endif - -#endif - -//GADGETANGEL SECTION Ends ==============================================>> - // // Heaters / Fans // diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index 4794579b1f42..57d4c047e2e2 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -149,14 +149,13 @@ #ifndef E0_CS_PIN #define E0_CS_PIN 42 #endif -/* + #define E1_STEP_PIN 36 #define E1_DIR_PIN 34 #define E1_ENABLE_PIN 30 #ifndef E1_CS_PIN #define E1_CS_PIN 44 #endif -*/ // // Temperature Sensors @@ -178,10 +177,6 @@ #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card (SDSS) or 49 (SD_DETECT_PIN) #endif -//GADGETANGEL SECTION Begins - -//GADGETANGEL SECTION Ends - // // Augmentation for auto-assigning RAMPS plugs // @@ -251,19 +246,19 @@ // Misc. Functions // #define SDSS 53 -//#define LED_PIN 13 +#define LED_PIN 13 #ifndef FILWIDTH_PIN - //#define FILWIDTH_PIN 5 // Analog Input on AUX2 + #define FILWIDTH_PIN 5 // Analog Input on AUX2 #endif // RAMPS 1.4 DIO 4 on the servos connector #ifndef FIL_RUNOUT_PIN - //#define FIL_RUNOUT_PIN 4 + #define FIL_RUNOUT_PIN 4 #endif #ifndef PS_ON_PIN - //#define PS_ON_PIN 12 + #define PS_ON_PIN 12 #endif #if ENABLED(CASE_LIGHT_ENABLE) && !defined(CASE_LIGHT_PIN) && !defined(SPINDLE_LASER_ENA_PIN) @@ -293,7 +288,7 @@ // // TMC software SPI -////ga +// #if ENABLED(TMC_USE_SW_SPI) #ifndef TMC_SW_MOSI #define TMC_SW_MOSI 66 @@ -327,7 +322,7 @@ // // Software serial - ////ga + // #ifndef X_SERIAL_TX_PIN #define X_SERIAL_TX_PIN 40 @@ -418,10 +413,9 @@ #endif #endif -/* // // Průša i3 MK2 Multiplexer Support -////ga +// #ifndef E_MUX0_PIN #define E_MUX0_PIN 40 // Z_CS_PIN #endif @@ -431,7 +425,6 @@ #ifndef E_MUX2_PIN #define E_MUX2_PIN 44 // E1_CS_PIN #endif -*/ ////////////////////////// // LCDs and Controllers // diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h index 658e7502ec5d..8ed30bffb733 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h @@ -38,10 +38,10 @@ // Release PA13/PA14 (led, usb control) from SWD pins #define DISABLE_DEBUG -//ga -//#define NEOPIXEL_PIN PA8 // LED driving pin -//#define PS_ON_PIN PC13 // Power Supply Control +#define NEOPIXEL_PIN PA8 // LED driving pin + +#define PS_ON_PIN PC13 // Power Supply Control #define FAN1_PIN PC7 diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h index 5d968d2d7b0d..b65411be8a3b 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h @@ -40,8 +40,8 @@ // // Servos -////ga -//#define SERVO0_PIN PA1 // "SERVOS" +// +#define SERVO0_PIN PA1 // "SERVOS" // // Limit Switches @@ -57,16 +57,16 @@ // // Filament Runout Sensor -////ga +// #ifndef FIL_RUNOUT_PIN - //#define FIL_RUNOUT_PIN PC15 // "E0-STOP" + #define FIL_RUNOUT_PIN PC15 // "E0-STOP" #endif // // Power-loss Detection -////ga +// #ifndef POWER_LOSS_PIN - //#define POWER_LOSS_PIN PC12 // Power Loss Detection: PWR-DET + #define POWER_LOSS_PIN PC12 // Power Loss Detection: PWR-DET #endif // @@ -91,13 +91,9 @@ // // Temperature Sensors // -//#define TEMP_0_PIN PA0 // Analog Input "TH0" +#define TEMP_0_PIN PA0 // Analog Input "TH0" #define TEMP_BED_PIN PC3 // Analog Input "TB0" -//GADGETANGEL SECTION Begins - -//GADGETANGEL SECTION Ends - // // Heaters / Fans // @@ -268,7 +264,7 @@ // // SD Support -////ga +// #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD @@ -282,6 +278,6 @@ #elif SD_CONNECTION_IS(CUSTOM_CABLE) #error "SD CUSTOM_CABLE is not compatible with SKR Mini E3." #endif -//ga + #define ONBOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index 385a4de9b259..bfa4007658db 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -48,13 +48,13 @@ // // Trinamic Stallguard pins -////ga +// #define X_DIAG_PIN PF2 // X- #define Y_DIAG_PIN PC13 // Y- #define Z_DIAG_PIN PE0 // Z- #define E0_DIAG_PIN PG14 // X+ -//#define E1_DIAG_PIN PG9 // Y+ -//#define E2_DIAG_PIN PD3 // Z+ +#define E1_DIAG_PIN PG9 // Y+ +#define E2_DIAG_PIN PD3 // Z+ // // Limit Switches @@ -110,27 +110,27 @@ // // Steppers -////ga +// #define X_STEP_PIN PC15 #define X_DIR_PIN PF0 #define X_ENABLE_PIN PF1 -//#ifndef X_CS_PIN - //#define X_CS_PIN PC14 -//#endif +#ifndef X_CS_PIN + #define X_CS_PIN PC14 +#endif #define Y_STEP_PIN PE3 #define Y_DIR_PIN PE2 #define Y_ENABLE_PIN PE4 -//#ifndef Y_CS_PIN - //#define Y_CS_PIN PE1 -//#endif +#ifndef Y_CS_PIN + #define Y_CS_PIN PE1 +#endif #define Z_STEP_PIN PB8 #define Z_DIR_PIN PB7 // PB7 #define Z_ENABLE_PIN PB9 -//#ifndef Z_CS_PIN - //#define Z_CS_PIN PB5 -//#endif +#ifndef Z_CS_PIN + #define Z_CS_PIN PB5 +#endif #define E0_STEP_PIN PG12 #define E0_DIR_PIN PG11 @@ -139,7 +139,6 @@ #define E0_CS_PIN PG10 #endif -/* #define E1_STEP_PIN PD6 #define E1_DIR_PIN PD5 #define E1_ENABLE_PIN PD7 @@ -188,7 +187,6 @@ #ifndef E7_CS_PIN #define E7_CS_PIN PH14 #endif -*/ // // Software SPI pins for TMC2130 stepper drivers @@ -229,7 +227,7 @@ // // Software serial - ////ga + // #define X_SERIAL_TX_PIN PC14 #define X_SERIAL_RX_PIN PC14 @@ -239,7 +237,6 @@ #define Z_SERIAL_TX_PIN PB5 #define Z_SERIAL_RX_PIN PB5 - /* #define E0_SERIAL_TX_PIN PG10 #define E0_SERIAL_RX_PIN PG10 @@ -263,7 +260,6 @@ #define E7_SERIAL_TX_PIN PH14 #define E7_SERIAL_RX_PIN PH14 - */ // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 @@ -272,19 +268,18 @@ // // Temperature Sensors // -//#define TEMP_0_PIN PC1 // T1 <-> E0 -//#define TEMP_1_PIN PC2 // T2 <-> E1 -//#define TEMP_2_PIN PC3 // T3 <-> E2 +#define TEMP_0_PIN PC1 // T1 <-> E0 +#define TEMP_1_PIN PC2 // T2 <-> E1 +#define TEMP_2_PIN PC3 // T3 <-> E2 -//#define TEMP_3_PIN PA3 // T4 <-> E3 -//#define TEMP_4_PIN PF9 // T5 <-> E4 -//#define TEMP_5_PIN PF10 // T6 <-> E5 -//#define TEMP_6_PIN PF7 // T7 <-> E6 -//#define TEMP_7_PIN PF5 // T8 <-> E7 +#define TEMP_3_PIN PA3 // T4 <-> E3 +#define TEMP_4_PIN PF9 // T5 <-> E4 +#define TEMP_5_PIN PF10 // T6 <-> E5 +#define TEMP_6_PIN PF7 // T7 <-> E6 +#define TEMP_7_PIN PF5 // T8 <-> E7 #define TEMP_BED_PIN PC0 // T0 <-> Bed -/* // SPI for Max6675 or Max31855 Thermocouple // Uses a separate SPI bus // If you have a two-way thermocouple, you can customize two THERMO_CSx_PIN pins (x:1~2) @@ -298,10 +293,6 @@ #define MAX6675_SS2_PIN THERMO_CS2_PIN #define MAX6675_SCK_PIN THERMO_SCK_PIN #define MAX6675_DO_PIN THERMO_DO_PIN -*/ - - - // // Heaters / Fans @@ -328,7 +319,6 @@ //#define FAN6_PIN PC9 // Fan6 //#define FAN7_PIN PE14 // Fan7 -//ga #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD #endif diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h index 1708b9614f2a..235ed1edcc4c 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -52,13 +52,13 @@ // // Trinamic Stallguard pins -////ga +// #define X_DIAG_PIN PB10 // X- #define Y_DIAG_PIN PE12 // Y- #define Z_DIAG_PIN PG8 // Z- #define E0_DIAG_PIN PE15 // E0 -//#define E1_DIAG_PIN PE10 // E1 -//#define E2_DIAG_PIN PG5 // E2 +#define E1_DIAG_PIN PE10 // E1 +#define E2_DIAG_PIN PG5 // E2 // // Limit Switches @@ -121,27 +121,27 @@ // // Steppers -////ga +// #define X_STEP_PIN PE9 #define X_DIR_PIN PF1 #define X_ENABLE_PIN PF2 -//#ifndef X_CS_PIN - //#define X_CS_PIN PA15 -//#endif +#ifndef X_CS_PIN + #define X_CS_PIN PA15 +#endif #define Y_STEP_PIN PE11 #define Y_DIR_PIN PE8 #define Y_ENABLE_PIN PD7 -//#ifndef Y_CS_PIN - //#define Y_CS_PIN PB8 -//#endif + #ifndef Y_CS_PIN + #define Y_CS_PIN PB8 +#endif #define Z_STEP_PIN PE13 #define Z_DIR_PIN PC2 #define Z_ENABLE_PIN PC0 -//#ifndef Z_CS_PIN - //#define Z_CS_PIN PB9 -//#endif +#ifndef Z_CS_PIN + #define Z_CS_PIN PB9 +#endif #define E0_STEP_PIN PE14 #define E0_DIR_PIN PA0 @@ -150,7 +150,6 @@ #define E0_CS_PIN PB3 #endif -/* #define E1_STEP_PIN PD15 #define E1_DIR_PIN PE7 #define E1_ENABLE_PIN PA3 @@ -165,7 +164,6 @@ #define E2_CS_PIN PG12 #endif -*/ // // Software SPI pins for TMC2130 stepper drivers // @@ -212,7 +210,6 @@ #define Z_SERIAL_TX_PIN PE1 #define Z_SERIAL_RX_PIN PE1 - /* #define E0_SERIAL_TX_PIN PD4 #define E0_SERIAL_RX_PIN PD4 @@ -221,7 +218,6 @@ #define E2_SERIAL_TX_PIN PD6 #define E2_SERIAL_RX_PIN PD6 - */ // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 @@ -230,8 +226,8 @@ // // Temperature Sensors // -//#define TEMP_0_PIN PF4 // T1 <-> E0 -//#define TEMP_1_PIN PF5 // T2 <-> E1 +#define TEMP_0_PIN PF4 // T1 <-> E0 +#define TEMP_1_PIN PF5 // T2 <-> E1 #define TEMP_2_PIN PF6 // T3 <-> E2 #define TEMP_BED_PIN PF3 // T0 <-> Bed From fe73c6b9452722acc28108a0428be81fd975cf66 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Mon, 14 Dec 2020 12:35:26 -0500 Subject: [PATCH 23/44] Created Compatabilty layer - MAX (SPI) temp boards --- Marlin/src/inc/Conditionals_post.h | 41 ++++++++++++++++++++ Marlin/src/module/temperature.cpp | 60 ++++++------------------------ 2 files changed, 53 insertions(+), 48 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index d1028c6997f2..3070548ff0c2 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -483,6 +483,47 @@ #define MAX6675_HAS_MAX6675 1 #endif +// +// Compatibility layer for MAX (SPI) temp boards +// +#if PIN_EXISTS(MAX6675_SS) + #if MAX6675_0_IS_MAX31855 + #define MAX31855_CS_PIN MAX6675_SS_PIN + #elif MAX6675_0_IS_MAX31865 + #define MAX31865_CS_PIN MAX6675_SS_PIN + #elif MAX6675_0_IS_MAX6675 + #define MAX6675_CS_PIN MAX6675_SS_PIN + #endif +#endif + +#if PIN_EXISTS(MAX6675_SS2) + #if MAX6675_1_IS_MAX31855 + #define MAX31855_CS2_PIN MAX6675_SS2_PIN + #elif MAX6675_1_IS_MAX31865 + #define MAX31865_CS2_PIN MAX6675_SS2_PIN + #elif MAX6675_1_IS_MAX6675 + #define MAX6675_CS2_PIN MAX6675_SS2_PIN + #endif +#endif + +#if PIN_EXISTS(MAX6675_DO) + #if MAX6675_HAS_MAX31855 + #define MAX31855_MISO_PIN MAX6675_DO_PIN + #elif MAX6675_HAS_MAX31865 + #define MAX31865_MISO_PIN MAX6675_DO_PIN + #elif MAX6675_HAS_MAX6675 + #define MAX6675_MISO_PIN MAX6675_DO_PIN + #endif +#endif + +#if PIN_EXISTS(MAX6675_SCK) + #if MAX6675_HAS_MAX31855 + #define MAX31855_SCK_PIN MAX6675_SCK_PIN + #elif MAX6675_HAS_MAX31865 + #define MAX31865_SCK_PIN MAX6675_SCK_PIN + #endif +#endif + #if TEMP_SENSOR_2 == -4 #define HEATER_2_USES_AD8495 1 #elif TEMP_SENSOR_2 == -3 diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 55939ed30ffb..48b61db346fd 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -46,25 +46,13 @@ #if MAX6675_HAS_MAX31855 #include - #if MAX6675_0_IS_MAX31855 && !defined(MAX31855_CS_PIN) && PIN_EXISTS(MAX6675_SS) - #define MAX31855_CS_PIN MAX6675_SS_PIN - #endif - #if MAX6675_1_IS_MAX31855 && !defined(MAX31855_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) - #define MAX31855_CS2_PIN MAX6675_SS2_PIN - #endif - #if !defined(MAX31855_MISO_PIN) && PIN_EXISTS(MAX6675_DO) - #define MAX31855_MISO_PIN MAX6675_DO_PIN - #endif - #if !defined(MAX31855_SCK_PIN) && PIN_EXISTS(MAX6675_SCK) - #define MAX31855_SCK_PIN MAX6675_SCK_PIN - #endif - #if ANY_PIN(MAX6675_DO, MAX31855_MISO) && ANY_PIN(MAX6675_SCK, MAX31855_SCK) - #define MAX31855_USES_SW_LIB 1 + #if PIN_EXISTS(MAX31855_MISO) && PIN_EXISTS(MAX31855_SCK) + #define MAX31855_USES_SW_SPI 1 #endif #if MAX6675_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS) #define HAS_MAX31855_TEMP 1 Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855(MAX31855_CS_PIN - #if MAX31855_USES_SW_LIB + #if MAX31855_USES_SW_SPI , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK #endif ); @@ -72,7 +60,7 @@ #if MAX6675_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2) #define HAS_MAX31855_TEMP 1 Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855(MAX31855_CS2_PIN - #if MAX31855_USES_SW_LIB + #if MAX31855_USES_SW_SPI , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK #endif ); @@ -81,28 +69,13 @@ #if MAX6675_HAS_MAX31865 #include - #if MAX6675_0_IS_MAX31865 && !defined(MAX31865_CS_PIN) && PIN_EXISTS(MAX6675_SS) - #define MAX31865_CS_PIN MAX6675_SS_PIN - #endif - #if MAX6675_1_IS_MAX31865 && !defined(MAX31865_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) - #define MAX31865_CS2_PIN MAX6675_SS2_PIN - #endif - #ifndef MAX31865_MOSI_PIN - #define MAX31865_MOSI_PIN MOSI_PIN - #endif - #if !defined(MAX31865_MISO_PIN) && PIN_EXISTS(MAX6675_DO) - #define MAX31865_MISO_PIN MAX6675_DO_PIN - #endif - #if !defined(MAX31865_SCK_PIN) && PIN_EXISTS(MAX6675_SCK) - #define MAX31865_SCK_PIN MAX6675_SCK_PIN - #endif - #if ANY_PIN(MAX6675_DO, MAX31865_MISO) && ANY_PIN(MAX6675_SCK, MAX31865_SCK) - #define MAX31865_USES_SW_LIB 1 + #if PIN_EXISTS(MAX31865_MISO) && PIN_EXISTS(MAX31865_SCK) + #define MAX31865_USES_SW_SPI 1 #endif #if MAX6675_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS) #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN - #if MAX31865_USES_SW_LIB + #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK #endif ); @@ -110,7 +83,7 @@ #if MAX6675_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2) #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN - #if MAX31865_USES_SW_LIB + #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK #endif ); @@ -119,22 +92,13 @@ #if MAX6675_HAS_MAX6675 #include - #if MAX6675_0_IS_MAX6675 && !defined(MAX6675_CS_PIN) && PIN_EXISTS(MAX6675_SS) - #define MAX6675_CS_PIN MAX6675_SS_PIN - #endif - #if MAX6675_1_IS_MAX6675 && !defined(MAX6675_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) - #define MAX6675_CS2_PIN MAX6675_SS2_PIN - #endif - #if !defined(MAX6675_MISO_PIN) && PIN_EXISTS(MAX6675_DO) - #define MAX6675_MISO_PIN MAX6675_DO_PIN - #endif - #if ANY_PIN(MAX6675_DO, MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK) - #define MAX6675_USES_SW_LIB 1 + #if PIN_EXISTS(MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK) + #define MAX6675_USES_SW_SPI 1 #endif #if MAX6675_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) #define HAS_MAX6675_TEMP 1 MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN - #if MAX6675_USES_SW_LIB && PIN_EXISTS(MAX6675_SCK) + #if MAX6675_USES_SW_SPI , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif ); @@ -142,7 +106,7 @@ #if MAX6675_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) #define HAS_MAX6675_TEMP 1 MAX6675 max6675_1 = MAX6675(MAX6675_CS2_PIN - #if MAX6675_USES_SW_LIB && PIN_EXISTS(MAX6675_SCK) + #if MAX6675_USES_SW_SPI , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif ); From 26da0fa182fbdd49dc24244688f3611eee0df223 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Mon, 14 Dec 2020 13:47:17 -0500 Subject: [PATCH 24/44] disabled all code that will not be called --- Marlin/src/MarlinCore.cpp | 6 ------ Marlin/src/inc/SanityCheck.h | 16 ++++++++-------- Marlin/src/module/temperature.cpp | 27 +++++++++++++++++++++------ 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 6589e011793a..f7a315999895 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1013,12 +1013,6 @@ void setup() { SETUP_RUN(HAL_init()); // Init and disable SPI thermocouples - #if HEATER_0_USES_MAX6675 && PIN_EXISTS(MAX6675_SS) - OUT_WRITE(MAX6675_SS_PIN, HIGH); - #endif - #if HEATER_1_USES_MAX6675 && PIN_EXISTS(MAX6675_SS2) - OUT_WRITE(MAX6675_SS2_PIN, HIGH); - #endif #if HEATER_0_USES_MAX6675 && PIN_EXISTS(MAX6675_CS) OUT_WRITE(MAX6675_CS_PIN, HIGH); #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 002800df8dde..01e88a9f9793 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1700,8 +1700,8 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal /** * Pins and Sensor IDs must be set for each heater */ -#if HEATER_0_USES_MAX6675 && !ANY_PIN(MAX6675_SS, MAX31855_CS, MAX31865_CS, MAX6675_CS) - #error "TEMP_SENSOR_0 requires a MAX6675_SS2_PIN, MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN." +#if HEATER_0_USES_MAX6675 && !ANY_PIN(MAX31855_CS, MAX31865_CS, MAX6675_CS) + #error "TEMP_SENSOR_0 requires a MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN." #elif HAS_HOTEND && !HAS_TEMP_HOTEND && !HEATER_0_DUMMY_THERMISTOR #error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board." #elif EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) && !HAS_HEATER_1 @@ -1709,12 +1709,12 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #endif #if HAS_MULTI_HOTEND - #if HEATER_1_USES_MAX6675 && !ANY_PIN(MAX6675_SS2, MAX31855_CS2, MAX31865_CS2, MAX6675_CS2) - #error "TEMP_SENSOR_1 requires a MAX6675_SS2_PIN, MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN." + #if HEATER_1_USES_MAX6675 && !ANY_PIN(MAX31855_CS2, MAX31865_CS2, MAX6675_CS2) + #error "TEMP_SENSOR_1 requires a MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN." #elif TEMP_SENSOR_1 == 0 #error "TEMP_SENSOR_1 is required with 2 or more HOTENDS." - #elif !ANY_PIN(TEMP_1, MAX6675_SS2) && !HEATER_1_DUMMY_THERMISTOR - #error "TEMP_1_PIN or MAX6675_SS2_PIN not defined for this board." + #elif !ANY_PIN(TEMP_1, MAX6675_CS2) && !HEATER_1_DUMMY_THERMISTOR + #error "TEMP_1_PIN or MAX6675_CS2_PIN not defined for this board." #elif ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) #error "HOTENDS must be 1 with TEMP_SENSOR_1_AS_REDUNDANT." #endif @@ -1883,8 +1883,8 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal */ #if !HAS_HEATER_0 && EXTRUDERS #error "HEATER_0_PIN not defined for this board." -#elif !ANY_PIN(TEMP_0, MAX6675_SS) - #error "TEMP_0_PIN or MAX6675_SS not defined for this board." +#elif !ANY_PIN(TEMP_0, MAX6675_CS) + #error "TEMP_0_PIN or MAX6675_CS_PIN not defined for this board." #elif ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR)) #error "E0_STEP_PIN or E0_DIR_PIN not defined for this board." #elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE)) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 48b61db346fd..d20b8bf1b53e 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -113,17 +113,21 @@ #endif #endif +/* #if !HAS_MAX6675_TEMP && !HAS_MAX31855_TEMP && !HAS_MAX31865_TEMP #define NO_THERMO_TEMPS 1 #endif + #if (HEATER_0_USES_MAX6675 || HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS #define MAX6675_SEPARATE_SPI 1 #endif + #if MAX6675_SEPARATE_SPI #include "../libs/private_spi.h" #endif +*/ #if ENABLED(PID_EXTRUSION_SCALING) #include "stepper.h" @@ -1698,10 +1702,12 @@ void Temperature::updateTemperaturesFromRawValues() { raw_temps_ready = false; } +/* #if MAX6675_SEPARATE_SPI template SoftSPI SPIclass::softSPI; SPIclass max6675_spi; #endif +*/ // Init fans according to whether they're native PWM or Software PWM #ifdef ALFAWISE_UX0 @@ -1737,8 +1743,10 @@ void Temperature::updateTemperaturesFromRawValues() { */ void Temperature::init() { - TERN_(MAX6675_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE - TERN_(MAX6675_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE)); + #if HAS_MAX31865_TEMP + TERN_(MAX6675_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE + TERN_(MAX6675_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE)); + #endif #if HAS_MAX31855_TEMP TERN_(MAX6675_0_IS_MAX31855, max31855_0.begin()); TERN_(MAX6675_1_IS_MAX31855, max31855_1.begin()); @@ -1845,7 +1853,7 @@ void Temperature::init() { INIT_FAN_PIN(CONTROLLER_FAN_PIN); #endif - TERN_(MAX6675_SEPARATE_SPI, max6675_spi.init()); + //TERN_(MAX6675_SEPARATE_SPI, max6675_spi.init()); HAL_adc_init(); @@ -2265,8 +2273,8 @@ void Temperature::disable_all_heaters() { static uint16_t max6675_temp_previous[COUNT_6675] = { 0 }; #define MAX6675_TEMP(I) max6675_temp_previous[I] #define MAX6675_SEL(A,B) (hindex ? (B) : (A)) - #define MAX6675_WRITE(V) do{ switch (hindex) { case 1: WRITE(MAX6675_SS2_PIN, V); break; default: WRITE(MAX6675_SS_PIN, V); } }while(0) - #define MAX6675_SET_OUTPUT() do{ switch (hindex) { case 1: SET_OUTPUT(MAX6675_SS2_PIN); break; default: SET_OUTPUT(MAX6675_SS_PIN); } }while(0) + //#define MAX6675_WRITE(V) do{ switch (hindex) { case 1: WRITE(MAX6675_SS2_PIN, V); break; default: WRITE(MAX6675_SS_PIN, V); } }while(0) + //#define MAX6675_SET_OUTPUT() do{ switch (hindex) { case 1: SET_OUTPUT(MAX6675_SS2_PIN); break; default: SET_OUTPUT(MAX6675_SS_PIN); } }while(0) #else constexpr uint8_t hindex = 0; #define MAX6675_TEMP(I) max6675_temp @@ -2275,6 +2283,7 @@ void Temperature::disable_all_heaters() { #else #define MAX6675_SEL(A,B) A #endif + /* #if HEATER_0_USES_MAX6675 #define MAX6675_WRITE(V) WRITE(MAX6675_SS_PIN, V) #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS_PIN) @@ -2282,6 +2291,7 @@ void Temperature::disable_all_heaters() { #define MAX6675_WRITE(V) WRITE(MAX6675_SS2_PIN, V) #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS2_PIN) #endif + */ #endif static uint8_t max6675_errors[COUNT_6675] = { 0 }; @@ -2292,6 +2302,7 @@ void Temperature::disable_all_heaters() { if (PENDING(ms, next_max6675_ms[hindex])) return int(MAX6675_TEMP(hindex)); next_max6675_ms[hindex] = ms + MAX6675_HEAT_INTERVAL; + /* // // TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used. // @@ -2304,9 +2315,12 @@ void Temperature::disable_all_heaters() { MAX6675_WRITE(LOW); // enable TT_MAX6675 DELAY_NS(100); // Ensure 100ns delay #endif + */ - // Read a big-endian temperature value max6675_temp = 0; + + /* + // Read a big-endian temperature value #if NO_THERMO_TEMPS for (uint8_t i = sizeof(max6675_temp); i--;) { max6675_temp |= TERN(MAX6675_SEPARATE_SPI, max6675_spi.receive(), spiRec()); @@ -2314,6 +2328,7 @@ void Temperature::disable_all_heaters() { } MAX6675_WRITE(HIGH); // disable TT_MAX6675 #endif + */ #if HAS_MAX31855_TEMP Adafruit_MAX31855 &max855ref = MAX6675_SEL(max31855_0, max31855_1); From 24dfbc5566a70007cff9578705a631e021a032a8 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Mon, 14 Dec 2020 15:14:00 -0500 Subject: [PATCH 25/44] cleanup --- Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h index 235ed1edcc4c..20aa75471c53 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -132,7 +132,7 @@ #define Y_STEP_PIN PE11 #define Y_DIR_PIN PE8 #define Y_ENABLE_PIN PD7 - #ifndef Y_CS_PIN +#ifndef Y_CS_PIN #define Y_CS_PIN PB8 #endif From 6d7f215dddd3a87f00b3e7116b91bb95f47229c9 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Mon, 14 Dec 2020 16:16:58 -0500 Subject: [PATCH 26/44] Cleanup trailing spaces --- Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/module/temperature.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 3070548ff0c2..ec22bf6a2e4e 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -511,7 +511,7 @@ #define MAX31855_MISO_PIN MAX6675_DO_PIN #elif MAX6675_HAS_MAX31865 #define MAX31865_MISO_PIN MAX6675_DO_PIN - #elif MAX6675_HAS_MAX6675 + #elif MAX6675_HAS_MAX6675 #define MAX6675_MISO_PIN MAX6675_DO_PIN #endif #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index d20b8bf1b53e..ef689c3a2aba 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -75,7 +75,7 @@ #if MAX6675_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS) #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN - #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) + #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK #endif ); @@ -98,7 +98,7 @@ #if MAX6675_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) #define HAS_MAX6675_TEMP 1 MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN - #if MAX6675_USES_SW_SPI + #if MAX6675_USES_SW_SPI , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif ); @@ -106,7 +106,7 @@ #if MAX6675_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) #define HAS_MAX6675_TEMP 1 MAX6675 max6675_1 = MAX6675(MAX6675_CS2_PIN - #if MAX6675_USES_SW_SPI + #if MAX6675_USES_SW_SPI , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif ); From 06638614a46eb8b50484dd735d68e5183cd5ae80 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Mon, 14 Dec 2020 16:36:30 -0500 Subject: [PATCH 27/44] Cleanup --- Marlin/src/module/temperature.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index ef689c3a2aba..fe5035d0035a 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -118,7 +118,6 @@ #define NO_THERMO_TEMPS 1 #endif - #if (HEATER_0_USES_MAX6675 || HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS #define MAX6675_SEPARATE_SPI 1 #endif From ad2efd51f90e5a1873820834cefafadec6c77ac5 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Mon, 14 Dec 2020 22:50:46 -0500 Subject: [PATCH 28/44] fix name mismatch --- Marlin/src/gcode/calibrate/G28.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 092d8d643ac1..23c4d56d936a 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -435,7 +435,7 @@ void GcodeSuite::G28() { do_blocking_move_to_z(delta_clip_start_height); #endif - TERN_(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_was_active)); + TERN_(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_restore_state)); restore_feedrate_and_scaling(); From 1cfe911fac04e90427cb30f286fb77242ba9645a Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Mon, 14 Dec 2020 23:35:45 -0500 Subject: [PATCH 29/44] Update G28.cpp fix naming mismatch: leveling_was_active to leveling_restore_state --- Marlin/src/gcode/calibrate/G28.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 092d8d643ac1..23c4d56d936a 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -435,7 +435,7 @@ void GcodeSuite::G28() { do_blocking_move_to_z(delta_clip_start_height); #endif - TERN_(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_was_active)); + TERN_(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_restore_state)); restore_feedrate_and_scaling(); From a5404d8622f84ff4294415bdd270418d48f60a4c Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Tue, 15 Dec 2020 02:36:31 -0500 Subject: [PATCH 30/44] Revert "Update G28.cpp" This reverts commit 1cfe911fac04e90427cb30f286fb77242ba9645a. --- Marlin/src/gcode/calibrate/G28.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 23c4d56d936a..092d8d643ac1 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -435,7 +435,7 @@ void GcodeSuite::G28() { do_blocking_move_to_z(delta_clip_start_height); #endif - TERN_(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_restore_state)); + TERN_(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_was_active)); restore_feedrate_and_scaling(); From 8aa3f89ac4b7d8f6c77512f703abf0b824ca6249 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Tue, 15 Dec 2020 02:36:38 -0500 Subject: [PATCH 31/44] Revert "Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bugfix-2.0.x" This reverts commit bf0016331d88a47ea77e850f974e3b63fe42a9ab, reversing changes made to 1cfe911fac04e90427cb30f286fb77242ba9645a. --- Marlin/src/HAL/STM32/HAL.h | 10 +- Marlin/src/HAL/STM32F1/HAL.h | 10 +- Marlin/src/core/boards.h | 9 +- .../extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp | 2 +- .../extui/lib/dgus/hiprecy/DGUSDisplayDef.h | 2 - .../extui/lib/dgus/origin/DGUSDisplayDef.cpp | 2 +- .../extui/lib/dgus/origin/DGUSDisplayDef.h | 2 - Marlin/src/libs/buzzer.h | 1 - Marlin/src/pins/pins.h | 2 - Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h | 2 +- Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h | 2 +- .../src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h | 2 +- Marlin/src/pins/stm32f1/pins_CREALITY_V452.h | 90 +++++++++++++- Marlin/src/pins/stm32f1/pins_CREALITY_V453.h | 38 ------ Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h | 113 ------------------ Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h | 2 +- .../src/pins/stm32f1/pins_JGAURORA_A5S_A1.h | 4 +- Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h | 2 +- .../src/pins/stm32f4/pins_BTT_BTT002_V1_0.h | 2 +- Marlin/src/pins/stm32f4/pins_LERDGE_X.h | 2 +- Marlin/src/pins/stm32f7/pins_REMRAM_V1.h | 2 +- 23 files changed, 118 insertions(+), 187 deletions(-) delete mode 100644 Marlin/src/pins/stm32f1/pins_CREALITY_V453.h delete mode 100644 Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index f2fb5ddb6a25..9842cdaae4b0 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -143,15 +143,19 @@ void _delay_ms(const int delay); extern "C" char* _sbrk(int incr); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-function" +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wunused-function" +#endif static inline int freeMemory() { volatile char top; return &top - reinterpret_cast(_sbrk(0)); } -#pragma GCC diagnostic pop +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic pop +#endif // // ADC diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 7163db43a2fd..2c852f22e1c3 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -191,8 +191,10 @@ inline void HAL_reboot() {} // reboot the board or restart the bootloader void _delay_ms(const int delay); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-function" +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wunused-function" +#endif /* extern "C" { @@ -207,7 +209,9 @@ static inline int freeMemory() { return &top - _sbrk(0); } -#pragma GCC diagnostic pop +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic pop +#endif // // ADC diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 172cdd6b5a75..7f0a99dca329 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -330,11 +330,10 @@ #define BOARD_CREALITY_V4 4037 // Creality v4.x (STM32F103RE) #define BOARD_CREALITY_V427 4038 // Creality v4.2.7 (STM32F103RE) #define BOARD_CREALITY_V452 4039 // Creality v4.5.2 (STM32F103RE) -#define BOARD_CREALITY_V453 4040 // Creality v4.5.3 (STM32F103RE) -#define BOARD_TRIGORILLA_PRO 4041 // Trigorilla Pro (STM32F103ZET6) -#define BOARD_FLY_MINI 4042 // FLY MINI (STM32F103RCT6) -#define BOARD_FLSUN_HISPEED 4043 // FLSUN HiSpeedV1 (STM32F103VET6) -#define BOARD_BEAST 4044 // STM32F103RET6 Libmaple-based controller +#define BOARD_TRIGORILLA_PRO 4040 // Trigorilla Pro (STM32F103ZET6) +#define BOARD_FLY_MINI 4041 // FLY MINI (STM32F103RCT6) +#define BOARD_FLSUN_HISPEED 4042 // FLSUN HiSpeedV1 (STM32F103VET6) +#define BOARD_BEAST 4043 // STM32F103RET6 Libmaple-based controller // // ARM Cortex-M4F diff --git a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp index 536640ec9526..ed26cac3c503 100644 --- a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp @@ -26,7 +26,7 @@ #if ENABLED(DGUS_LCD_UI_HIPRECY) -#include "DGUSDisplayDef.h" +#include "../DGUSDisplayDef.h" #include "../DGUSDisplay.h" #include "../DGUSScreenHandler.h" diff --git a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.h b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.h index d18989a48b00..3ff5e06dc18c 100644 --- a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.h @@ -21,8 +21,6 @@ */ #pragma once -#include "../DGUSDisplayDef.h" - enum DGUSLCD_Screens : uint8_t { DGUSLCD_SCREEN_BOOT = 160, DGUSLCD_SCREEN_MAIN = 1, diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp index 28e66e5d7ce4..46e542a9598a 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp @@ -26,7 +26,7 @@ #if ENABLED(DGUS_LCD_UI_ORIGIN) -#include "DGUSDisplayDef.h" +#include "../DGUSDisplayDef.h" #include "../DGUSDisplay.h" #include "../DGUSScreenHandler.h" diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.h b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.h index 5c5a315de6dc..451c11adba16 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.h @@ -21,8 +21,6 @@ */ #pragma once -#include "../DGUSDisplayDef.h" - enum DGUSLCD_Screens : uint8_t { DGUSLCD_SCREEN_BOOT = 0, DGUSLCD_SCREEN_MAIN = 10, diff --git a/Marlin/src/libs/buzzer.h b/Marlin/src/libs/buzzer.h index b86fe998fa05..e901660c87d1 100644 --- a/Marlin/src/libs/buzzer.h +++ b/Marlin/src/libs/buzzer.h @@ -118,7 +118,6 @@ #elif HAS_BUZZER // Buzz indirectly via the MarlinUI instance - #include "../lcd/marlinui.h" #define BUZZ(d,f) ui.buzz(d,f) #else diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 52e6d26b142e..c9f6f7b3b35f 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -532,8 +532,6 @@ #include "stm32f1/pins_CREALITY_V427.h" // STM32F1 env:STM32F103RET6_creality #elif MB(CREALITY_V452) #include "stm32f1/pins_CREALITY_V452.h" // STM32F1 env:STM32F103RET6_creality -#elif MB(CREALITY_V453) - #include "stm32f1/pins_CREALITY_V453.h" // STM32F1 env:STM32F103RET6_creality #elif MB(TRIGORILLA_PRO) #include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro #elif MB(FLY_MINI) diff --git a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h index 6fcb7b94e0c2..3bcaae96a330 100644 --- a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h +++ b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h @@ -28,7 +28,7 @@ #if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "Longer3D LGT KIT V1.0 board only supports one hotend / E-stepper. Comment out this line to continue." + #error "Longer3D LGT KIT V1.0 board only supports 1 hotend / E-stepper. Comment out this line to continue." #endif #if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 diff --git a/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h b/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h index d9964242dd58..513c7fe8d5d6 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h @@ -22,7 +22,7 @@ #pragma once #if HOTENDS > 1 || E_STEPPERS > 1 - #error "Ender-4 only supports one hotend / E-stepper. Comment out this line to continue." + #error "Ender-4 supports only 1 hotend / E-stepper. Comment out this line to continue." #endif #define BOARD_INFO_NAME "Ender-4" diff --git a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h index a255160829ad..0e94249a993c 100644 --- a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h +++ b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h @@ -24,7 +24,7 @@ #if NOT_TARGET(TARGET_STM32F1) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "CCROBOT-ONLINE MEEB_3DP only supports one hotend / E-stepper. Comment out this line to continue." + #error "CCROBOT-ONLINE MEEB_3DP only supports 1 hotend / E-stepper. Comment out this line to continue." #endif // https://github.com/ccrobot-online/MEEB_3DP diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h index 35eea1da7891..f65e1d5474b5 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h @@ -24,15 +24,97 @@ * Creality v4.5.2 (STM32F103RET6) board pin assignments */ -#if HOTENDS > 1 || E_STEPPERS > 1 - #error "Creality v4.5.2 only supports one hotend / E-stepper. Comment out this line to continue." +#if NOT_TARGET(__STM32F1__) + #error "Oops! Select an STM32F1 board in 'Tools > Board.'" +#elif HOTENDS > 1 || E_STEPPERS > 1 + #error "CREALITY_V452 supports up to 1 hotends / E-steppers. Comment out this line to continue." #endif #define BOARD_NAME "Creality v4.5.2" +#define DEFAULT_MACHINE_NAME "Creality3D" +// +// Release PB4 (Z_STEP_PIN) from JTAG NRST role +// +#define DISABLE_DEBUG + +#define BOARD_NO_NATIVE_USB + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 + //#define SDCARD_EEPROM_EMULATION +#endif + +#if ENABLED(IIC_BL24CXX_EEPROM) + #define IIC_EEPROM_SDA PA11 + #define IIC_EEPROM_SCL PA12 + #define MARLIN_EEPROM_SIZE 0x800 // 2Kb (24C16) +#elif ENABLED(SDCARD_EEPROM_EMULATION) + #define MARLIN_EEPROM_SIZE 0x800 // 2Kb +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PC4 +#define Y_STOP_PIN PC5 +#define Z_STOP_PIN PA4 + +#define FIL_RUNOUT_PIN PA7 + +// +// Probe +// +#define PROBE_TARE_PIN PA5 +#define PROBE_ENABLE_PIN PC6 // Optoswitch to Enable Z Probe + +// +// Steppers +// +#define X_ENABLE_PIN PC3 +#define X_STEP_PIN PB8 +#define X_DIR_PIN PB7 + +#define Y_ENABLE_PIN PC3 +#define Y_STEP_PIN PB6 +#define Y_DIR_PIN PB5 + +#define Z_ENABLE_PIN PC3 +#define Z_STEP_PIN PB4 +#define Z_DIR_PIN PB3 + +#define E0_ENABLE_PIN PC3 +#define E0_STEP_PIN PC2 +#define E0_DIR_PIN PB9 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PB1 // TH1 +#define TEMP_BED_PIN PB0 // TB1 + +// +// Heaters / Fans +// #define HEATER_0_PIN PA1 // HEATER1 #define HEATER_BED_PIN PA2 // HOT BED + #define FAN_PIN PA0 // FAN -#define PROBE_ENABLE_PIN PC6 // Optoswitch to Enable Z Probe +#define FAN_SOFT_PWM + +// +// SD Card +// +#define SD_DETECT_PIN PC7 +#define NO_SD_HOST_DRIVE // SD is only seen by the printer + +#define SDIO_SUPPORT // Extra added by Creality +#define SDIO_CLOCK 6000000 // In original source code overridden by Creality in sdio.h -#include "pins_CREALITY_V45x.h" +// +// Misc. Functions +// +#define CASE_LIGHT_PIN PA6 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h deleted file mode 100644 index 836e5a91f1b6..000000000000 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 . - * - */ - -/** - * Creality v4.5.3 (STM32F103RET6) board pin assignments - */ - -#if HOTENDS > 1 || E_STEPPERS > 1 - #error "Creality v4.5.3 only supports one hotend / E-stepper. Comment out this line to continue." -#endif - -#define BOARD_NAME "Creality v4.5.3" - -#define HEATER_0_PIN PB14 // HEATER1 -#define HEATER_BED_PIN PB13 // HOT BED -#define FAN_PIN PB15 // FAN -#define PROBE_ENABLE_PIN PB2 // Optoswitch to Enable Z Probe - -#include "pins_CREALITY_V45x.h" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h deleted file mode 100644 index f2be2895305f..000000000000 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 . - * - */ - -/** - * Creality v4.5.2 and v4.5.3 (STM32F103RET6) board pin assignments - */ - -#if NOT_TARGET(__STM32F1__) - #error "Oops! Select an STM32F1 board in 'Tools > Board.'" -#endif - -#define DEFAULT_MACHINE_NAME "Creality3D" - -// -// Release PB4 (Z_STEP_PIN) from JTAG NRST role -// -#define DISABLE_DEBUG - -#define BOARD_NO_NATIVE_USB - -// -// EEPROM -// -#if NO_EEPROM_SELECTED - #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 - //#define SDCARD_EEPROM_EMULATION -#endif - -#if ENABLED(IIC_BL24CXX_EEPROM) - #define IIC_EEPROM_SDA PA11 - #define IIC_EEPROM_SCL PA12 - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb (24C16) -#elif ENABLED(SDCARD_EEPROM_EMULATION) - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb -#endif - -// -// Limit Switches -// -#define X_STOP_PIN PC4 -#define Y_STOP_PIN PC5 -#define Z_STOP_PIN PA4 - -#define FIL_RUNOUT_PIN PA7 - -// -// Probe -// -#define PROBE_TARE_PIN PA5 - -// -// Steppers -// -#define X_ENABLE_PIN PC3 -#define X_STEP_PIN PB8 -#define X_DIR_PIN PB7 - -#define Y_ENABLE_PIN PC3 -#define Y_STEP_PIN PB6 -#define Y_DIR_PIN PB5 - -#define Z_ENABLE_PIN PC3 -#define Z_STEP_PIN PB4 -#define Z_DIR_PIN PB3 - -#define E0_ENABLE_PIN PC3 -#define E0_STEP_PIN PC2 -#define E0_DIR_PIN PB9 - -// -// Temperature Sensors -// -#define TEMP_0_PIN PB1 // TH1 -#define TEMP_BED_PIN PB0 // TB1 - -// -// Heaters / Fans -// - -#define FAN_SOFT_PWM - -// -// SD Card -// -#define SD_DETECT_PIN PC7 -#define NO_SD_HOST_DRIVE // SD is only seen by the printer - -#define SDIO_SUPPORT // Extra added by Creality -#define SDIO_CLOCK 6000000 // In original source code overridden by Creality in sdio.h - -// -// Misc. Functions -// -#define CASE_LIGHT_PIN PA6 diff --git a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h index c20af310cc2a..7541f8272941 100644 --- a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h +++ b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h @@ -32,7 +32,7 @@ #if NOT_TARGET(__STM32F1__, STM32F1xx) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "FLSUN HiSpeedV1 only supports one hotend / E-stepper. Comment out this line to continue." + #error "FLSUN HiSpeedV1 supports 1 hotend / E-stepper. Comment out this line to continue." #endif #define BOARD_INFO_NAME "FLSun HiSpeedV1" diff --git a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h index 4f02b0e23cde..f86acf1f2414 100644 --- a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h +++ b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h @@ -31,10 +31,10 @@ #if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "JGAurora A5S A1 only supports one hotend / E-stepper. Comment out this line to continue." + #error "JGAurora 32-bit board only supports 1 hotend / E-stepper. Comment out this line to continue." #endif -#define BOARD_INFO_NAME "JGAurora A5S A1" +#define BOARD_INFO_NAME "JGAurora A5S A1 board" #define BOARD_NO_NATIVE_USB diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index 33f995dcaef0..fd5c57387846 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -25,7 +25,7 @@ #if NOT_TARGET(__STM32F1__, STM32F1xx) #error "Oops! Select a STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "Longer3D only supports one hotend / E-stepper. Comment out this line to continue." + #error "Longer3D board only supports 1 hotend / E-stepper. Comment out this line to continue." #endif #define BOARD_INFO_NAME "Longer3D" diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h index 1ad18a6497cf..d7c4aebe37dc 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h @@ -24,7 +24,7 @@ #if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "MKS Robin Lite only supports one hotend / E-stepper. Comment out this line to continue." + #error "MKS Robin Lite supports only 1 hotend / E-stepper. Comment out this line to continue." #endif #ifndef BOARD_INFO_NAME diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h index e6a1e929993b..ae6835758993 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h @@ -28,7 +28,7 @@ #if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "MKS Robin mini only supports one hotend / E-stepper. Comment out this line to continue." + #error "MKS Robin mini only supports 1 hotend / E-stepper. Comment out this line to continue." #endif #define BOARD_INFO_NAME "MKS Robin Mini" diff --git a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h index af2ebce9ed8b..660ba29e97d1 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -24,7 +24,7 @@ #if NOT_TARGET(STM32F4) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "BIGTREE BTT002 V1.0 only supports one hotend / E-stepper. Comment out this line to continue." + #error "BIGTREE BTT002 V1.0 only supports one hotend / E-stepper." #endif #define BOARD_INFO_NAME "BTT BTT002 V1.0" diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_X.h b/Marlin/src/pins/stm32f4/pins_LERDGE_X.h index 6e0b3e14a786..075aec6e9bf8 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_X.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_X.h @@ -21,7 +21,7 @@ #if NOT_TARGET(STM32F4, STM32F4xx) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "LERDGE X only supports one hotend / E-stepper. Comment out this line to continue." + #error "LERDGE X only supports one hotend / E-steppers" #endif #define BOARD_INFO_NAME "Lerdge X" diff --git a/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h b/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h index 133dcd2935d3..f07cf824d22c 100644 --- a/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h +++ b/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h @@ -33,7 +33,7 @@ #endif #if HOTENDS > 1 || E_STEPPERS > 1 - #error "RemRam only supports one hotend / E-stepper. Comment out this line to continue." + #error "RemRam only supports one hotend / E-stepper." #endif // From cbf5b0731c11b88f7f10e65e3b47d9818a098fe2 Mon Sep 17 00:00:00 2001 From: JoAnn Manges Date: Wed, 16 Dec 2020 18:42:30 -0500 Subject: [PATCH 32/44] Revert "Merge branch 'bugfix-2.0.x' into Marlin-Fix-LPC176x-SPI-Issues-bugfix" This reverts commit 3835d99149ca2e785efa1839377831b2d4f8a860, reversing changes made to 039cd5e3dd63aeef4cf2b884b429406f7dd81a05. --- Marlin/src/HAL/STM32/HAL.h | 10 +- Marlin/src/HAL/STM32F1/HAL.h | 10 +- Marlin/src/core/boards.h | 9 +- Marlin/src/gcode/calibrate/G28.cpp | 2 +- .../extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp | 2 +- .../extui/lib/dgus/hiprecy/DGUSDisplayDef.h | 2 + .../extui/lib/dgus/origin/DGUSDisplayDef.cpp | 2 +- .../extui/lib/dgus/origin/DGUSDisplayDef.h | 2 + Marlin/src/libs/buzzer.h | 1 + Marlin/src/pins/pins.h | 2 + Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h | 2 +- Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h | 2 +- .../src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h | 2 +- Marlin/src/pins/stm32f1/pins_CREALITY_V452.h | 90 +------------- Marlin/src/pins/stm32f1/pins_CREALITY_V453.h | 38 ++++++ Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h | 113 ++++++++++++++++++ Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h | 2 +- .../src/pins/stm32f1/pins_JGAURORA_A5S_A1.h | 4 +- Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h | 2 +- .../src/pins/stm32f4/pins_BTT_BTT002_V1_0.h | 2 +- Marlin/src/pins/stm32f4/pins_LERDGE_X.h | 2 +- Marlin/src/pins/stm32f7/pins_REMRAM_V1.h | 2 +- 24 files changed, 188 insertions(+), 119 deletions(-) create mode 100644 Marlin/src/pins/stm32f1/pins_CREALITY_V453.h create mode 100644 Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index 9842cdaae4b0..f2fb5ddb6a25 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -143,19 +143,15 @@ void _delay_ms(const int delay); extern "C" char* _sbrk(int incr); -#if GCC_VERSION <= 50000 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wunused-function" -#endif +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" static inline int freeMemory() { volatile char top; return &top - reinterpret_cast(_sbrk(0)); } -#if GCC_VERSION <= 50000 - #pragma GCC diagnostic pop -#endif +#pragma GCC diagnostic pop // // ADC diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 2c852f22e1c3..7163db43a2fd 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -191,10 +191,8 @@ inline void HAL_reboot() {} // reboot the board or restart the bootloader void _delay_ms(const int delay); -#if GCC_VERSION <= 50000 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wunused-function" -#endif +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" /* extern "C" { @@ -209,9 +207,7 @@ static inline int freeMemory() { return &top - _sbrk(0); } -#if GCC_VERSION <= 50000 - #pragma GCC diagnostic pop -#endif +#pragma GCC diagnostic pop // // ADC diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 3d0051e96c91..315a2b69375a 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -330,10 +330,11 @@ #define BOARD_CREALITY_V4 4037 // Creality v4.x (STM32F103RE) #define BOARD_CREALITY_V427 4038 // Creality v4.2.7 (STM32F103RE) #define BOARD_CREALITY_V452 4039 // Creality v4.5.2 (STM32F103RE) -#define BOARD_TRIGORILLA_PRO 4040 // Trigorilla Pro (STM32F103ZET6) -#define BOARD_FLY_MINI 4041 // FLY MINI (STM32F103RCT6) -#define BOARD_FLSUN_HISPEED 4042 // FLSUN HiSpeedV1 (STM32F103VET6) -#define BOARD_BEAST 4043 // STM32F103RET6 Libmaple-based controller +#define BOARD_CREALITY_V453 4040 // Creality v4.5.3 (STM32F103RE) +#define BOARD_TRIGORILLA_PRO 4041 // Trigorilla Pro (STM32F103ZET6) +#define BOARD_FLY_MINI 4042 // FLY MINI (STM32F103RCT6) +#define BOARD_FLSUN_HISPEED 4043 // FLSUN HiSpeedV1 (STM32F103VET6) +#define BOARD_BEAST 4044 // STM32F103RET6 Libmaple-based controller // // ARM Cortex-M4F diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 092d8d643ac1..23c4d56d936a 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -435,7 +435,7 @@ void GcodeSuite::G28() { do_blocking_move_to_z(delta_clip_start_height); #endif - TERN_(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_was_active)); + TERN_(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_restore_state)); restore_feedrate_and_scaling(); diff --git a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp index ed26cac3c503..536640ec9526 100644 --- a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp @@ -26,7 +26,7 @@ #if ENABLED(DGUS_LCD_UI_HIPRECY) -#include "../DGUSDisplayDef.h" +#include "DGUSDisplayDef.h" #include "../DGUSDisplay.h" #include "../DGUSScreenHandler.h" diff --git a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.h b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.h index 3ff5e06dc18c..d18989a48b00 100644 --- a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.h @@ -21,6 +21,8 @@ */ #pragma once +#include "../DGUSDisplayDef.h" + enum DGUSLCD_Screens : uint8_t { DGUSLCD_SCREEN_BOOT = 160, DGUSLCD_SCREEN_MAIN = 1, diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp index 46e542a9598a..28e66e5d7ce4 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp @@ -26,7 +26,7 @@ #if ENABLED(DGUS_LCD_UI_ORIGIN) -#include "../DGUSDisplayDef.h" +#include "DGUSDisplayDef.h" #include "../DGUSDisplay.h" #include "../DGUSScreenHandler.h" diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.h b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.h index 451c11adba16..5c5a315de6dc 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.h @@ -21,6 +21,8 @@ */ #pragma once +#include "../DGUSDisplayDef.h" + enum DGUSLCD_Screens : uint8_t { DGUSLCD_SCREEN_BOOT = 0, DGUSLCD_SCREEN_MAIN = 10, diff --git a/Marlin/src/libs/buzzer.h b/Marlin/src/libs/buzzer.h index e901660c87d1..b86fe998fa05 100644 --- a/Marlin/src/libs/buzzer.h +++ b/Marlin/src/libs/buzzer.h @@ -118,6 +118,7 @@ #elif HAS_BUZZER // Buzz indirectly via the MarlinUI instance + #include "../lcd/marlinui.h" #define BUZZ(d,f) ui.buzz(d,f) #else diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index c9f6f7b3b35f..52e6d26b142e 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -532,6 +532,8 @@ #include "stm32f1/pins_CREALITY_V427.h" // STM32F1 env:STM32F103RET6_creality #elif MB(CREALITY_V452) #include "stm32f1/pins_CREALITY_V452.h" // STM32F1 env:STM32F103RET6_creality +#elif MB(CREALITY_V453) + #include "stm32f1/pins_CREALITY_V453.h" // STM32F1 env:STM32F103RET6_creality #elif MB(TRIGORILLA_PRO) #include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro #elif MB(FLY_MINI) diff --git a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h index 3bcaae96a330..6fcb7b94e0c2 100644 --- a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h +++ b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h @@ -28,7 +28,7 @@ #if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "Longer3D LGT KIT V1.0 board only supports 1 hotend / E-stepper. Comment out this line to continue." + #error "Longer3D LGT KIT V1.0 board only supports one hotend / E-stepper. Comment out this line to continue." #endif #if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 diff --git a/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h b/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h index 513c7fe8d5d6..d9964242dd58 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h @@ -22,7 +22,7 @@ #pragma once #if HOTENDS > 1 || E_STEPPERS > 1 - #error "Ender-4 supports only 1 hotend / E-stepper. Comment out this line to continue." + #error "Ender-4 only supports one hotend / E-stepper. Comment out this line to continue." #endif #define BOARD_INFO_NAME "Ender-4" diff --git a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h index 0e94249a993c..a255160829ad 100644 --- a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h +++ b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h @@ -24,7 +24,7 @@ #if NOT_TARGET(TARGET_STM32F1) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "CCROBOT-ONLINE MEEB_3DP only supports 1 hotend / E-stepper. Comment out this line to continue." + #error "CCROBOT-ONLINE MEEB_3DP only supports one hotend / E-stepper. Comment out this line to continue." #endif // https://github.com/ccrobot-online/MEEB_3DP diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h index f65e1d5474b5..35eea1da7891 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h @@ -24,97 +24,15 @@ * Creality v4.5.2 (STM32F103RET6) board pin assignments */ -#if NOT_TARGET(__STM32F1__) - #error "Oops! Select an STM32F1 board in 'Tools > Board.'" -#elif HOTENDS > 1 || E_STEPPERS > 1 - #error "CREALITY_V452 supports up to 1 hotends / E-steppers. Comment out this line to continue." +#if HOTENDS > 1 || E_STEPPERS > 1 + #error "Creality v4.5.2 only supports one hotend / E-stepper. Comment out this line to continue." #endif #define BOARD_NAME "Creality v4.5.2" -#define DEFAULT_MACHINE_NAME "Creality3D" -// -// Release PB4 (Z_STEP_PIN) from JTAG NRST role -// -#define DISABLE_DEBUG - -#define BOARD_NO_NATIVE_USB - -// -// EEPROM -// -#if NO_EEPROM_SELECTED - #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 - //#define SDCARD_EEPROM_EMULATION -#endif - -#if ENABLED(IIC_BL24CXX_EEPROM) - #define IIC_EEPROM_SDA PA11 - #define IIC_EEPROM_SCL PA12 - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb (24C16) -#elif ENABLED(SDCARD_EEPROM_EMULATION) - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb -#endif - -// -// Limit Switches -// -#define X_STOP_PIN PC4 -#define Y_STOP_PIN PC5 -#define Z_STOP_PIN PA4 - -#define FIL_RUNOUT_PIN PA7 - -// -// Probe -// -#define PROBE_TARE_PIN PA5 -#define PROBE_ENABLE_PIN PC6 // Optoswitch to Enable Z Probe - -// -// Steppers -// -#define X_ENABLE_PIN PC3 -#define X_STEP_PIN PB8 -#define X_DIR_PIN PB7 - -#define Y_ENABLE_PIN PC3 -#define Y_STEP_PIN PB6 -#define Y_DIR_PIN PB5 - -#define Z_ENABLE_PIN PC3 -#define Z_STEP_PIN PB4 -#define Z_DIR_PIN PB3 - -#define E0_ENABLE_PIN PC3 -#define E0_STEP_PIN PC2 -#define E0_DIR_PIN PB9 - -// -// Temperature Sensors -// -#define TEMP_0_PIN PB1 // TH1 -#define TEMP_BED_PIN PB0 // TB1 - -// -// Heaters / Fans -// #define HEATER_0_PIN PA1 // HEATER1 #define HEATER_BED_PIN PA2 // HOT BED - #define FAN_PIN PA0 // FAN -#define FAN_SOFT_PWM - -// -// SD Card -// -#define SD_DETECT_PIN PC7 -#define NO_SD_HOST_DRIVE // SD is only seen by the printer - -#define SDIO_SUPPORT // Extra added by Creality -#define SDIO_CLOCK 6000000 // In original source code overridden by Creality in sdio.h +#define PROBE_ENABLE_PIN PC6 // Optoswitch to Enable Z Probe -// -// Misc. Functions -// -#define CASE_LIGHT_PIN PA6 +#include "pins_CREALITY_V45x.h" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h new file mode 100644 index 000000000000..836e5a91f1b6 --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h @@ -0,0 +1,38 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ + +/** + * Creality v4.5.3 (STM32F103RET6) board pin assignments + */ + +#if HOTENDS > 1 || E_STEPPERS > 1 + #error "Creality v4.5.3 only supports one hotend / E-stepper. Comment out this line to continue." +#endif + +#define BOARD_NAME "Creality v4.5.3" + +#define HEATER_0_PIN PB14 // HEATER1 +#define HEATER_BED_PIN PB13 // HOT BED +#define FAN_PIN PB15 // FAN +#define PROBE_ENABLE_PIN PB2 // Optoswitch to Enable Z Probe + +#include "pins_CREALITY_V45x.h" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h new file mode 100644 index 000000000000..f2be2895305f --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h @@ -0,0 +1,113 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ + +/** + * Creality v4.5.2 and v4.5.3 (STM32F103RET6) board pin assignments + */ + +#if NOT_TARGET(__STM32F1__) + #error "Oops! Select an STM32F1 board in 'Tools > Board.'" +#endif + +#define DEFAULT_MACHINE_NAME "Creality3D" + +// +// Release PB4 (Z_STEP_PIN) from JTAG NRST role +// +#define DISABLE_DEBUG + +#define BOARD_NO_NATIVE_USB + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 + //#define SDCARD_EEPROM_EMULATION +#endif + +#if ENABLED(IIC_BL24CXX_EEPROM) + #define IIC_EEPROM_SDA PA11 + #define IIC_EEPROM_SCL PA12 + #define MARLIN_EEPROM_SIZE 0x800 // 2Kb (24C16) +#elif ENABLED(SDCARD_EEPROM_EMULATION) + #define MARLIN_EEPROM_SIZE 0x800 // 2Kb +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PC4 +#define Y_STOP_PIN PC5 +#define Z_STOP_PIN PA4 + +#define FIL_RUNOUT_PIN PA7 + +// +// Probe +// +#define PROBE_TARE_PIN PA5 + +// +// Steppers +// +#define X_ENABLE_PIN PC3 +#define X_STEP_PIN PB8 +#define X_DIR_PIN PB7 + +#define Y_ENABLE_PIN PC3 +#define Y_STEP_PIN PB6 +#define Y_DIR_PIN PB5 + +#define Z_ENABLE_PIN PC3 +#define Z_STEP_PIN PB4 +#define Z_DIR_PIN PB3 + +#define E0_ENABLE_PIN PC3 +#define E0_STEP_PIN PC2 +#define E0_DIR_PIN PB9 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PB1 // TH1 +#define TEMP_BED_PIN PB0 // TB1 + +// +// Heaters / Fans +// + +#define FAN_SOFT_PWM + +// +// SD Card +// +#define SD_DETECT_PIN PC7 +#define NO_SD_HOST_DRIVE // SD is only seen by the printer + +#define SDIO_SUPPORT // Extra added by Creality +#define SDIO_CLOCK 6000000 // In original source code overridden by Creality in sdio.h + +// +// Misc. Functions +// +#define CASE_LIGHT_PIN PA6 diff --git a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h index 7541f8272941..c20af310cc2a 100644 --- a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h +++ b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h @@ -32,7 +32,7 @@ #if NOT_TARGET(__STM32F1__, STM32F1xx) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "FLSUN HiSpeedV1 supports 1 hotend / E-stepper. Comment out this line to continue." + #error "FLSUN HiSpeedV1 only supports one hotend / E-stepper. Comment out this line to continue." #endif #define BOARD_INFO_NAME "FLSun HiSpeedV1" diff --git a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h index f86acf1f2414..4f02b0e23cde 100644 --- a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h +++ b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h @@ -31,10 +31,10 @@ #if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "JGAurora 32-bit board only supports 1 hotend / E-stepper. Comment out this line to continue." + #error "JGAurora A5S A1 only supports one hotend / E-stepper. Comment out this line to continue." #endif -#define BOARD_INFO_NAME "JGAurora A5S A1 board" +#define BOARD_INFO_NAME "JGAurora A5S A1" #define BOARD_NO_NATIVE_USB diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index fd5c57387846..33f995dcaef0 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -25,7 +25,7 @@ #if NOT_TARGET(__STM32F1__, STM32F1xx) #error "Oops! Select a STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "Longer3D board only supports 1 hotend / E-stepper. Comment out this line to continue." + #error "Longer3D only supports one hotend / E-stepper. Comment out this line to continue." #endif #define BOARD_INFO_NAME "Longer3D" diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h index d7c4aebe37dc..1ad18a6497cf 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h @@ -24,7 +24,7 @@ #if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "MKS Robin Lite supports only 1 hotend / E-stepper. Comment out this line to continue." + #error "MKS Robin Lite only supports one hotend / E-stepper. Comment out this line to continue." #endif #ifndef BOARD_INFO_NAME diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h index ae6835758993..e6a1e929993b 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h @@ -28,7 +28,7 @@ #if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "MKS Robin mini only supports 1 hotend / E-stepper. Comment out this line to continue." + #error "MKS Robin mini only supports one hotend / E-stepper. Comment out this line to continue." #endif #define BOARD_INFO_NAME "MKS Robin Mini" diff --git a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h index 660ba29e97d1..af2ebce9ed8b 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -24,7 +24,7 @@ #if NOT_TARGET(STM32F4) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "BIGTREE BTT002 V1.0 only supports one hotend / E-stepper." + #error "BIGTREE BTT002 V1.0 only supports one hotend / E-stepper. Comment out this line to continue." #endif #define BOARD_INFO_NAME "BTT BTT002 V1.0" diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_X.h b/Marlin/src/pins/stm32f4/pins_LERDGE_X.h index 075aec6e9bf8..6e0b3e14a786 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_X.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_X.h @@ -21,7 +21,7 @@ #if NOT_TARGET(STM32F4, STM32F4xx) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 - #error "LERDGE X only supports one hotend / E-steppers" + #error "LERDGE X only supports one hotend / E-stepper. Comment out this line to continue." #endif #define BOARD_INFO_NAME "Lerdge X" diff --git a/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h b/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h index f07cf824d22c..133dcd2935d3 100644 --- a/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h +++ b/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h @@ -33,7 +33,7 @@ #endif #if HOTENDS > 1 || E_STEPPERS > 1 - #error "RemRam only supports one hotend / E-stepper." + #error "RemRam only supports one hotend / E-stepper. Comment out this line to continue." #endif // From 4457f5350683d7eb662c289274b97947711c7a80 Mon Sep 17 00:00:00 2001 From: JoAnn Manges Date: Wed, 23 Dec 2020 02:37:32 -0500 Subject: [PATCH 33/44] Capabilities added to temperature.cpp Added the ability to handle frameworks with PIN values over 127. While testing the GTR V1.0 board has eleven (11) PINS that when passed to a signed int8 will over flow into negative values which in turn will then be interrupted as very large numbers by the GTR framework and get translated into NC pins. This leads to NO data and a MIN TEMP error. Added the ability to use a "-DTEMP_MODE=x" where x is 0, 1, 2, or 3 to the compile line so that when a MCU board's default hardware SPI bus is used by an SD card reader which has a pull-up resistor on the SCLK line the user can compile with a different SPI MODE to compensate for the difference in inactive clock state from LOW to HIGH for hardware SPI communications (i.e. BTT SKR mini E3 V2.0). If a TEMP_MODE is not found it will default to the appropriate settings. Fix the display of SHOW_TEMP_ADC_VALUES so that the MAX series of boards will display their appropirate values without getting their values divided by 16. No longer need max31865_fault constant. The max6675_temp variable will get processed to determine if a fault has occured with the MAX31865 board. Found during testing that the MAX31855 will sometimes send junk on the VERY FIRST temperature sample so upon startup I do two (2) reads if possible (MAX31855 and MAX6675). This was not done for the MAX31865 board. Tested all new libraries with the follwing boards: RAMPS V1.4 with mega2560, SKR mini E3 V2.0, SKR V1.3, SKR V1.4 Turbo, SKR PRO V1.x and GTR V1.0. --- Marlin/src/inc/Conditionals_post.h | 7 ++ Marlin/src/inc/SanityCheck.h | 8 +- Marlin/src/module/temperature.cpp | 114 ++++++++++------------------- 3 files changed, 51 insertions(+), 78 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index dc5547950c16..15ed130182da 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -524,6 +524,13 @@ #endif #endif +// +//Compatability Layer for MB with Large PIN Mappings +// +#if ANY(STM32F407IX) + #define LARGE_PINMAP 1 +#endif + #if TEMP_SENSOR_2 == -4 #define HEATER_2_USES_AD8495 1 #elif TEMP_SENSOR_2 == -3 diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 95c29090117e..a9b2bda608a1 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1731,8 +1731,8 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_1 requires a MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN." #elif TEMP_SENSOR_1 == 0 #error "TEMP_SENSOR_1 is required with 2 or more HOTENDS." - #elif !ANY_PIN(TEMP_1, MAX6675_CS2) && !HEATER_1_DUMMY_THERMISTOR - #error "TEMP_1_PIN or MAX6675_CS2_PIN not defined for this board." + #elif !ANY_PIN(TEMP_1, MAX6675_CS2, MAX31855_CS2, MAX31865_CS2) && !HEATER_1_DUMMY_THERMISTOR + #error "TEMP_1_PIN, MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN is not defined for this board." #elif ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) #error "HOTENDS must be 1 with TEMP_SENSOR_1_AS_REDUNDANT." #endif @@ -1901,8 +1901,8 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal */ #if !HAS_HEATER_0 && EXTRUDERS #error "HEATER_0_PIN not defined for this board." -#elif !ANY_PIN(TEMP_0, MAX6675_CS) - #error "TEMP_0_PIN or MAX6675_CS_PIN not defined for this board." +#elif !ANY_PIN(TEMP_0, MAX6675_CS, MAX31855_CS, MAX31865_CS) + #error "TEMP_0_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN is not defined for this board." #elif ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR)) #error "E0_STEP_PIN or E0_DIR_PIN not defined for this board." #elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE)) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index fe5035d0035a..c3859b358b7b 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -55,6 +55,9 @@ #if MAX31855_USES_SW_SPI , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK #endif + #if ENABLED(LARGE_PINMAP) + , HIGH + #endif ); #endif #if MAX6675_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2) @@ -63,6 +66,9 @@ #if MAX31855_USES_SW_SPI , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK #endif + #if ENABLED(LARGE_PINMAP) + , HIGH + #endif ); #endif #endif @@ -74,17 +80,23 @@ #endif #if MAX6675_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS) #define HAS_MAX31865_TEMP 1 - Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN - #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) - , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK - #endif - ); + Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN + #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) + , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK + #endif + #if ENABLED(LARGE_PINMAP) + , HIGH + #endif + ); #endif #if MAX6675_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2) #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) - , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK + , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK + #endif + #if ENABLED(LARGE_PINMAP) + , HIGH #endif ); #endif @@ -101,6 +113,9 @@ #if MAX6675_USES_SW_SPI , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif + #if ENABLED(LARGE_PINMAP) + , HIGH + #endif ); #endif #if MAX6675_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) @@ -109,25 +124,17 @@ #if MAX6675_USES_SW_SPI , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif + #if ENABLED(LARGE_PINMAP) + , HIGH + #endif ); #endif #endif -/* #if !HAS_MAX6675_TEMP && !HAS_MAX31855_TEMP && !HAS_MAX31865_TEMP #define NO_THERMO_TEMPS 1 #endif -#if (HEATER_0_USES_MAX6675 || HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS - #define MAX6675_SEPARATE_SPI 1 -#endif - - -#if MAX6675_SEPARATE_SPI - #include "../libs/private_spi.h" -#endif -*/ - #if ENABLED(PID_EXTRUSION_SCALING) #include "stepper.h" #endif @@ -1701,13 +1708,6 @@ void Temperature::updateTemperaturesFromRawValues() { raw_temps_ready = false; } -/* -#if MAX6675_SEPARATE_SPI - template SoftSPI SPIclass::softSPI; - SPIclass max6675_spi; -#endif -*/ - // Init fans according to whether they're native PWM or Software PWM #ifdef ALFAWISE_UX0 #define _INIT_SOFT_FAN(P) OUT_WRITE_OD(P, FAN_INVERTING ? LOW : HIGH) @@ -1852,8 +1852,6 @@ void Temperature::init() { INIT_FAN_PIN(CONTROLLER_FAN_PIN); #endif - //TERN_(MAX6675_SEPARATE_SPI, max6675_spi.init()); - HAL_adc_init(); #if HAS_TEMP_ADC_0 @@ -2272,8 +2270,6 @@ void Temperature::disable_all_heaters() { static uint16_t max6675_temp_previous[COUNT_6675] = { 0 }; #define MAX6675_TEMP(I) max6675_temp_previous[I] #define MAX6675_SEL(A,B) (hindex ? (B) : (A)) - //#define MAX6675_WRITE(V) do{ switch (hindex) { case 1: WRITE(MAX6675_SS2_PIN, V); break; default: WRITE(MAX6675_SS_PIN, V); } }while(0) - //#define MAX6675_SET_OUTPUT() do{ switch (hindex) { case 1: SET_OUTPUT(MAX6675_SS2_PIN); break; default: SET_OUTPUT(MAX6675_SS_PIN); } }while(0) #else constexpr uint8_t hindex = 0; #define MAX6675_TEMP(I) max6675_temp @@ -2282,15 +2278,6 @@ void Temperature::disable_all_heaters() { #else #define MAX6675_SEL(A,B) A #endif - /* - #if HEATER_0_USES_MAX6675 - #define MAX6675_WRITE(V) WRITE(MAX6675_SS_PIN, V) - #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS_PIN) - #else - #define MAX6675_WRITE(V) WRITE(MAX6675_SS2_PIN, V) - #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS2_PIN) - #endif - */ #endif static uint8_t max6675_errors[COUNT_6675] = { 0 }; @@ -2301,34 +2288,7 @@ void Temperature::disable_all_heaters() { if (PENDING(ms, next_max6675_ms[hindex])) return int(MAX6675_TEMP(hindex)); next_max6675_ms[hindex] = ms + MAX6675_HEAT_INTERVAL; - /* - // - // TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used. - // - #if !MAX6675_SEPARATE_SPI && NO_THERMO_TEMPS - spiBegin(); - spiInit(MAX6675_SPEED_BITS); - #endif - - #if NO_THERMO_TEMPS - MAX6675_WRITE(LOW); // enable TT_MAX6675 - DELAY_NS(100); // Ensure 100ns delay - #endif - */ - max6675_temp = 0; - - /* - // Read a big-endian temperature value - #if NO_THERMO_TEMPS - for (uint8_t i = sizeof(max6675_temp); i--;) { - max6675_temp |= TERN(MAX6675_SEPARATE_SPI, max6675_spi.receive(), spiRec()); - if (i > 0) max6675_temp <<= 8; // shift left if not the last byte - } - MAX6675_WRITE(HIGH); // disable TT_MAX6675 - #endif - */ - #if HAS_MAX31855_TEMP Adafruit_MAX31855 &max855ref = MAX6675_SEL(max31855_0, max31855_1); max6675_temp = max855ref.readRaw32(); @@ -2344,12 +2304,7 @@ void Temperature::disable_all_heaters() { max6675_temp = max6675ref.readRaw16(); #endif - // At the present time we do not have the ability to set the MAX31865 HIGH threshold - // or thr LOW threshold, so no need to check for them, zero these bits out - const uint8_t fault_31865 = TERN1(HAS_MAX31865_TEMP, (max865ref.readFault() & 0x3FU)); - - - if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK) && fault_31865) { + if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK)) { max6675_errors[hindex]++; if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { SERIAL_ERROR_START(); @@ -2363,10 +2318,13 @@ void Temperature::disable_all_heaters() { else if (max6675_temp & 4) SERIAL_ECHOLNPAIR("Fault : (", max6675_temp & 4 ,") >> Short to VCC"); #elif MAX6675_HAS_MAX31865 - const uint8_t fault_31865 = max865ref.readFault(); - max865ref.clearFault(); + // At the present time we do not have the ability to set the MAX31865 HIGH threshold + // or thr LOW threshold, so no need to check for them, zero these bits out + const uint8_t fault_31865 = max865ref.readFault() & 0x3FU; + max865ref.clearFault(); if (fault_31865) { - SERIAL_ECHOLNPAIR("\nMAX31865 Fault :(", fault_31865, ") >>"); + SERIAL_ECHOLN(); + SERIAL_ECHOLNPAIR("MAX31865 Fault :(", fault_31865, ") >>"); if (fault_31865 & MAX31865_FAULT_HIGHTHRESH) SERIAL_ECHOLNPGM("RTD High Threshold"); if (fault_31865 & MAX31865_FAULT_LOWTHRESH) @@ -3082,7 +3040,15 @@ void Temperature::tick() { SERIAL_ECHO(c); SERIAL_ECHOPAIR(" /" , t); #if ENABLED(SHOW_TEMP_ADC_VALUES) - SERIAL_ECHOPAIR(" (", r * RECIPROCAL(OVERSAMPLENR)); + // Temperature MAX SPI boards do not have an OVERSAMPLENR defined + #if NO_THERMO_TEMPS + SERIAL_ECHOPAIR(" (", r * RECIPROCAL(OVERSAMPLENR)); + #else + if (k == 'T') + SERIAL_ECHOPAIR(" (", r); + else + SERIAL_ECHOPAIR(" (", r * RECIPROCAL(OVERSAMPLENR)); + #endif SERIAL_CHAR(')'); #endif delay(2); From bbd3ee258636ebd723fe62ed5a9829d1b7129b8b Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Wed, 23 Dec 2020 13:23:06 -0500 Subject: [PATCH 34/44] cleanup --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 4f190e93151b..744b922f1625 100644 --- a/platformio.ini +++ b/platformio.ini @@ -224,7 +224,7 @@ HAS_TMC26X = TMC26XStepper=https://github.com/trinamic/TMC26XSteppe HAS_L64XX = Arduino-L6470@0.8.0 src_filter=+ + + NEOPIXEL_LED = Adafruit NeoPixel@1.5.0 - src_filter=+ + src_filter=+ MAX6675_HAS_MAX31865 = https://github.com/GadgetAngel/Adafruit-MAX31865-V1.1.0-Mod-M.git MAX6675_HAS_MAX31855 = https://github.com/GadgetAngel/Adafruit-MAX31855-V1.0.3-Mod-M.git MAX6675_HAS_MAX6675 = https://github.com/GadgetAngel/MAX6675-V1.1.0-Mod-M.git From bbcee273ae8460863dae3266da0cc158f22cc45d Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Wed, 30 Dec 2020 03:27:27 -0500 Subject: [PATCH 35/44] I like it better the way it was before I put back the code that was previously removed because I would rather have the option to use an external library or not to use an external library. This version of the PR allows build_flags to be used which will load a user library for MAX31855 or a user library for MAX31865 or a user library for MAX6675 or use the Adafruit MAX31865 V1.1.0 library or NOT to use a external library for MAX31855 or NOT to use an external library for MAX6675. If an external library is not used then the indivdual frameworks will minipulate the PINS like they did before (like my PR never happend). The following buid_flags have been implemented: -DLIB_MAX31865=1 means to load the external library in platformio.ini defined by LIB_USR_MAX31865 = '...' If -DLIB_MAX31865=1 is missing from the build_flags the Adafruit MAX31865 V1.1.0 library will be loaded (LIB_ADAFRUIT_MAX31865=Adafruit MAX31865 library@~1.1.0). If -DLIB_MAX31855=1 is included in the build_flags then an external user library defined in platformio.ini file with LIB_USR_MAX31855 = '...' is used for the MAX31855. If -DLIB_MAX31855 is missing from the build_flags then the pervious method of collecting the data will be used (the HAL will manipulate the SS_PIN and call max6675_spi.init() if it needs to and receive data via max6675_spi.receive(), or spiRec()). If the -DLIB_MAX6675=1 is included in the build_flags then the user library defined in platformio.ini file by LIB_USR_MAX6675='...' will be used for MAX6675. If the -DLIB_MAX6675=1 is missing from the build_flags then the previous way of collecting data for the MAX6675 sensor will be used. In addition to these build_flag for user libraries additional flags were added for handling the pin mapping bug. These additional flags are only used by the user defined library: -DLARGE_PINMAP=1 will allow the object initialization to occur with 'uint32_t' for the PIN VALUES; -DTEMP_MODE=3 will allow the hardware SPI mode to change to SPI_MODE3; -DTEMP_MODE=2 will allow the hardware SPI mode to change to SPI_MODE2; -DTEMP_MODE=1 will allow the hardware SPI mode to change to SPI_MODE1 and -DTEMP_MODE=0 will allow the hardware SPI mode to change to SPI_MODE0. To accomodate the previous method of collecting data for MAX31855 and MAX6675 a compatibility layer was added incase the CS_PIN was used. The previous method only used the SS_PIN for enabling and disabling the collection of data. Even tho this is more complex a method, at least it will be up to the user to either create their own library or use the default method that Marlin uses. At least this PR will stop the manipulation of SS_PIN only when it is really needed --- Marlin/src/inc/Conditionals_post.h | 50 ++++++++++++++- Marlin/src/module/temperature.cpp | 97 +++++++++++++++++++++++++++--- platformio.ini | 4 +- 3 files changed, 136 insertions(+), 15 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 15ed130182da..a41276db966a 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -524,11 +524,55 @@ #endif #endif +//Compatibility Layer for use when HAL manipulates PINS for MAX31855 and MAX6675 +#if PIN_EXISTS(MAX31855_CS) && !PIN_EXISTS(MAX6675_SS) + #define MAX6675_SS_PIN MAX31855_CS_PIN +#endif +#if PIN_EXISTS(MAX31855_CS2) && !PIN_EXISTS(MAX6675_SS2) + #define MAX6675_SS2_PIN MAX31855_CS2_PIN +#endif +#if PIN_EXISTS(MAX6675_CS) && !PIN_EXISTS(MAX6675_SS) + #define MAX6675_SS_PIN MAX6675_CS_PIN +#endif +#if PIN_EXISTS(MAX6675_CS2) && !PIN_EXISTS(MAX6675_SS2) + #define MAX6675_SS2_PIN MAX6675_CS2_PIN +#endif +#if PIN_EXISTS(MAX31855_MISO) && !PIN_EXISTS(MAX6675_DO) + #define MAX6675_DO_PIN MAX31855_MISO_PIN +#endif +#if PIN_EXISTS(MAX6675_MISO) && !PIN_EXISTS(MAX6675_DO) + #define MAX6675_DO_PIN MAX6675_MISO_PIN +#endif +#if PIN_EXISTS(MAX31855_SCK) && !PIN_EXISTS(MAX6675_SCK) + #define MAX6675_SCK_PIN MAX31855_SCK_PIN +#endif + + // -//Compatability Layer for MB with Large PIN Mappings +// Possibly trigger user defined libraries // -#if ANY(STM32F407IX) - #define LARGE_PINMAP 1 +//LIB_MAX31865 can be added in platformio.ini file on the build_flags line +//to turn on a USER library for MAX31865 +#if MAX6675_HAS_MAX31865 && DISABLED(LIB_MAX31865) + #undef LIB_USR_MAX31865 + #define LIB_ADAFRUIT_MAX31865 1 +#elif MAX6675_HAS_MAX31865 && ENABLED(LIB_MAX31865) + #undef LIB_ADAFRUIT_MAX31865 + #define LIB_USR_MAX31865 1 +#endif +//LIB_MAX31855 can be added in platformio.ini file on the build_flags line +//to turn on a USER library for MAX31855 +#if MAX6675_HAS_MAX31855 && DISABLED(LIB_MAX31855) + #undef LIB_USR_MAX31855 +#elif MAX6675_HAS_MAX31855 && ENABLED(LIB_MAX31855) + #define LIB_USR_MAX31855 1 +#endif +//LIB_MAX6675 can be added in platformio.ini file on the build_flags line +//to turn on a USER library for MAX6675 +#if MAX6675_HAS_MAX6675 && DISABLED(LIB_MAX6675) + #undef LIB_USR_MAX6675 +#elif MAX6675_HAS_MAX6675 && ENABLED(LIB_MAX6675) + #define LIB_USR_MAX6675 1 #endif #if TEMP_SENSOR_2 == -4 diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index c3859b358b7b..7ef1a68caf12 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -44,7 +44,8 @@ #include "../lcd/extui/ui_api.h" #endif -#if MAX6675_HAS_MAX31855 +// LIB_MAX31855 can be added in platformio.ini file on the build_flags line to use a user defined library +#if LIB_USR_MAX31855 #include #if PIN_EXISTS(MAX31855_MISO) && PIN_EXISTS(MAX31855_SCK) #define MAX31855_USES_SW_SPI 1 @@ -55,6 +56,7 @@ #if MAX31855_USES_SW_SPI , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK #endif + //LARGE_PINMAP can be added in platformio.ini file on the build_flags line #if ENABLED(LARGE_PINMAP) , HIGH #endif @@ -66,6 +68,7 @@ #if MAX31855_USES_SW_SPI , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK #endif + //LARGE_PINMAP can be added in platformio.ini file on the build_flags line #if ENABLED(LARGE_PINMAP) , HIGH #endif @@ -73,6 +76,8 @@ #endif #endif +//LIB_MAX31865 can be added in platformio.ini file on the build_flags line to use a user defined library +//if LIB_MAX31865 is not on the build_flags then the Adafruit MAX31865 V1.1.0 library is used #if MAX6675_HAS_MAX31865 #include #if PIN_EXISTS(MAX31865_MISO) && PIN_EXISTS(MAX31865_SCK) @@ -84,6 +89,7 @@ #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK #endif + //LARGE_PINMAP can be added in platformio.ini file on the build_flags line #if ENABLED(LARGE_PINMAP) , HIGH #endif @@ -95,6 +101,7 @@ #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK #endif + //LARGE_PINMAP can be added in platformio.ini file on the build_flags line #if ENABLED(LARGE_PINMAP) , HIGH #endif @@ -102,7 +109,8 @@ #endif #endif -#if MAX6675_HAS_MAX6675 +// LIB_MAX6675 can be added in platformio.ini file on the build_flags line to use a user defined library +#if LIB_USR_MAX6675 #include #if PIN_EXISTS(MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK) #define MAX6675_USES_SW_SPI 1 @@ -113,6 +121,7 @@ #if MAX6675_USES_SW_SPI , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif + //LARGE_PINMAP can be added in platformio.ini file on the build_flags line #if ENABLED(LARGE_PINMAP) , HIGH #endif @@ -124,6 +133,7 @@ #if MAX6675_USES_SW_SPI , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif + //LARGE_PINMAP can be added in platformio.ini file on the build_flags line #if ENABLED(LARGE_PINMAP) , HIGH #endif @@ -135,6 +145,14 @@ #define NO_THERMO_TEMPS 1 #endif +#if (HEATER_0_USES_MAX6675 || HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS + #define MAX6675_SEPARATE_SPI 1 +#endif + +#if MAX6675_SEPARATE_SPI + #include "../libs/private_spi.h" +#endif + #if ENABLED(PID_EXTRUSION_SCALING) #include "stepper.h" #endif @@ -1708,6 +1726,11 @@ void Temperature::updateTemperaturesFromRawValues() { raw_temps_ready = false; } +#if MAX6675_SEPARATE_SPI + template SoftSPI SPIclass::softSPI; + SPIclass max6675_spi; +#endif + // Init fans according to whether they're native PWM or Software PWM #ifdef ALFAWISE_UX0 #define _INIT_SOFT_FAN(P) OUT_WRITE_OD(P, FAN_INVERTING ? LOW : HIGH) @@ -1852,6 +1875,8 @@ void Temperature::init() { INIT_FAN_PIN(CONTROLLER_FAN_PIN); #endif + TERN_(MAX6675_SEPARATE_SPI, max6675_spi.init()); + HAL_adc_init(); #if HAS_TEMP_ADC_0 @@ -2270,6 +2295,10 @@ void Temperature::disable_all_heaters() { static uint16_t max6675_temp_previous[COUNT_6675] = { 0 }; #define MAX6675_TEMP(I) max6675_temp_previous[I] #define MAX6675_SEL(A,B) (hindex ? (B) : (A)) + #if NO_THERMO_TEMPS + #define MAX6675_WRITE(V) do{ switch (hindex) { case 1: WRITE(MAX6675_SS2_PIN, V); break; default: WRITE(MAX6675_SS_PIN, V); } }while(0) + #define MAX6675_SET_OUTPUT() do{ switch (hindex) { case 1: SET_OUTPUT(MAX6675_SS2_PIN); break; default: SET_OUTPUT(MAX6675_SS_PIN); } }while(0) + #endif #else constexpr uint8_t hindex = 0; #define MAX6675_TEMP(I) max6675_temp @@ -2278,6 +2307,17 @@ void Temperature::disable_all_heaters() { #else #define MAX6675_SEL(A,B) A #endif + + #if NO_THERMO_TEMPS + #if HEATER_0_USES_MAX6675 + #define MAX6675_WRITE(V) WRITE(MAX6675_SS_PIN, V) + #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS_PIN) + #else + #define MAX6675_WRITE(V) WRITE(MAX6675_SS2_PIN, V) + #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS2_PIN) + #endif + #endif + #endif static uint8_t max6675_errors[COUNT_6675] = { 0 }; @@ -2288,7 +2328,30 @@ void Temperature::disable_all_heaters() { if (PENDING(ms, next_max6675_ms[hindex])) return int(MAX6675_TEMP(hindex)); next_max6675_ms[hindex] = ms + MAX6675_HEAT_INTERVAL; + // + // TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used. + // + #if !MAX6675_SEPARATE_SPI && NO_THERMO_TEMPS + spiBegin(); + spiInit(MAX6675_SPEED_BITS); + #endif + + #if NO_THERMO_TEMPS + MAX6675_WRITE(LOW); // enable TT_MAX6675 + DELAY_NS(100); // Ensure 100ns delay + #endif + max6675_temp = 0; + + // Read a big-endian temperature value + #if NO_THERMO_TEMPS + for (uint8_t i = sizeof(max6675_temp); i--;) { + max6675_temp |= TERN(MAX6675_SEPARATE_SPI, max6675_spi.receive(), spiRec()); + if (i > 0) max6675_temp <<= 8; // shift left if not the last byte + } + MAX6675_WRITE(HIGH); // disable TT_MAX6675 + #endif + #if HAS_MAX31855_TEMP Adafruit_MAX31855 &max855ref = MAX6675_SEL(max31855_0, max31855_1); max6675_temp = max855ref.readRaw32(); @@ -2296,7 +2359,9 @@ void Temperature::disable_all_heaters() { #if HAS_MAX31865_TEMP Adafruit_MAX31865 &max865ref = MAX6675_SEL(max31865_0, max31865_1); - max6675_temp = max865ref.readRTD_with_Fault(); + #if ENABLED(LIB_USR_MAX31865) + max6675_temp = max865ref.readRTD_with_Fault(); + #endif #endif #if HAS_MAX6675_TEMP @@ -2304,7 +2369,15 @@ void Temperature::disable_all_heaters() { max6675_temp = max6675ref.readRaw16(); #endif - if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK)) { + #if ENABLED(LIB_ADAFRUIT_MAX31865) + const uint8_t fault_31865 = max865ref.readFault() & 0x3FU; + #endif + + #if ENABLED(LIB_ADAFRUIT_MAX31865) + if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && fault_31865) { + #else + if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK)) { + #endif max6675_errors[hindex]++; if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { SERIAL_ERROR_START(); @@ -2318,9 +2391,11 @@ void Temperature::disable_all_heaters() { else if (max6675_temp & 4) SERIAL_ECHOLNPAIR("Fault : (", max6675_temp & 4 ,") >> Short to VCC"); #elif MAX6675_HAS_MAX31865 - // At the present time we do not have the ability to set the MAX31865 HIGH threshold - // or thr LOW threshold, so no need to check for them, zero these bits out - const uint8_t fault_31865 = max865ref.readFault() & 0x3FU; + #if ENABLED(LIB_USR_MAX31865) + // At the present time we do not have the ability to set the MAX31865 HIGH threshold + // or thr LOW threshold, so no need to check for them, zero these bits out + const uint8_t fault_31865 = max865ref.readFault() & 0x3FU; + #endif max865ref.clearFault(); if (fault_31865) { SERIAL_ECHOLN(); @@ -2359,8 +2434,12 @@ void Temperature::disable_all_heaters() { #endif // Return the RTD resistance for MAX31865 for display in SHOW_TEMP_ADC_VALUES - #if MAX6675_HAS_MAX31865 - max6675_temp = (uint32_t(max6675_temp) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; + #if HAS_MAX31865_TEMP + #if ENABLED(LIB_ADAFRUIT_MAX31865) + max6675_temp = (uint32_t(max865ref.readRTD()) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; + #elif ENABLED(LIB_USR_MAX31865) + max6675_temp = (uint32_t(max6675_temp) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; + #endif #endif MAX6675_TEMP(hindex) = max6675_temp; diff --git a/platformio.ini b/platformio.ini index 9c4a3e27e513..014ce478cbc1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -225,9 +225,7 @@ HAS_L64XX = Arduino-L6470@0.8.0 src_filter=+ + + NEOPIXEL_LED = Adafruit NeoPixel@1.5.0 src_filter=+ -MAX6675_HAS_MAX31865 = https://github.com/GadgetAngel/Adafruit-MAX31865-V1.1.0-Mod-M.git -MAX6675_HAS_MAX31855 = https://github.com/GadgetAngel/Adafruit-MAX31855-V1.0.3-Mod-M.git -MAX6675_HAS_MAX6675 = https://github.com/GadgetAngel/MAX6675-V1.1.0-Mod-M.git +LIB_ADAFRUIT_MAX31865 = Adafruit MAX31865 library@~1.1.0 USES_LIQUIDCRYSTAL = LiquidCrystal@1.5.0 USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4 USES_LIQUIDTWI2 = LiquidTWI2@1.2.7 From b00aa900dc949665468f46d2a67ab9e9f7020be0 Mon Sep 17 00:00:00 2001 From: JoAnn Manges Date: Fri, 1 Jan 2021 18:11:42 -0500 Subject: [PATCH 36/44] Give a default value for MAX31865_MOSI_PIN --- Marlin/src/module/temperature.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 7ef1a68caf12..21bdd1757c49 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -80,6 +80,9 @@ //if LIB_MAX31865 is not on the build_flags then the Adafruit MAX31865 V1.1.0 library is used #if MAX6675_HAS_MAX31865 #include + #ifndef MAX31865_MOSI_PIN + #define MAX31865_MOSI_PIN SD_MOSI_PIN + #endif #if PIN_EXISTS(MAX31865_MISO) && PIN_EXISTS(MAX31865_SCK) #define MAX31865_USES_SW_SPI 1 #endif From 6ab97cff36d795438ef1b3f10802d6d664d11dc5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 6 Feb 2021 14:51:25 -0600 Subject: [PATCH 37/44] Various generalizations --- Marlin/Configuration_adv.h | 8 +- Marlin/src/HAL/LPC1768/inc/SanityCheck.h | 2 +- Marlin/src/MarlinCore.cpp | 22 - Marlin/src/inc/Conditionals_post.h | 242 ++++++----- Marlin/src/inc/SanityCheck.h | 56 +-- Marlin/src/module/temperature.cpp | 424 ++++++++++---------- Marlin/src/module/temperature.h | 33 +- Marlin/src/module/thermistor/thermistors.h | 376 ++++++++--------- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h | 1 + platformio.ini | 2 +- 10 files changed, 581 insertions(+), 585 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index a3699128b4d5..f615a5467139 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -113,6 +113,12 @@ #define CHAMBER_BETA 3950 // Beta value #endif +#if TEMP_SENSOR_PROBE == 1000 + #define PROBE_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define PROBE_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define PROBE_BETA 3950 // Beta value +#endif + // // Hephestos 2 24V heated bed upgrade kit. // https://store.bq.com/en/heated-bed-kit-hephestos2 @@ -331,7 +337,7 @@ * High Temperature Thermistor Support * * Thermistors able to support high temperature tend to have a hard time getting - * good readings at room and lower temperatures. This means HEATER_X_RAW_LO_TEMP + * good readings at room and lower temperatures. This means TEMP_SENSOR_X_RAW_LO_TEMP * will probably be caught when the heating element first turns on during the * preheating process, which will trigger a min_temp_error as a safety measure * and force stop everything. diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index 65512e23af9e..10d673771472 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -31,7 +31,7 @@ /** * Detect an old pins file by checking for old ADC pins values. */ -#define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && !(_CAT(P,_PIN) >= 0 && _CAT(P,_PIN) <= 3) +#define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && !WITHIN(_CAT(P,_PIN), TERN(LPC1768_IS_SKRV1_3, 0, 2), 3) // Include P0_00 and P0_01 for SKR V1.3 board #if _OLD_TEMP_PIN(TEMP_BED) #error "TEMP_BED_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)." #elif _OLD_TEMP_PIN(TEMP_0) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 6021b71460f6..cc3a4f819ebc 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -937,28 +937,6 @@ void setup() { SETUP_RUN(HAL_init()); - // Init and disable SPI thermocouples - #if HEATER_0_USES_MAX6675 && PIN_EXISTS(MAX6675_CS) - OUT_WRITE(MAX6675_CS_PIN, HIGH); - #endif - #if HEATER_1_USES_MAX6675 && PIN_EXISTS(MAX6675_CS2) - OUT_WRITE(MAX6675_CS2_PIN, HIGH); - #endif - - #if HEATER_0_USES_MAX6675 && PIN_EXISTS(MAX31855_CS) - OUT_WRITE(MAX31855_CS_PIN, HIGH); - #endif - #if HEATER_1_USES_MAX6675 && PIN_EXISTS(MAX31855_CS2) - OUT_WRITE(MAX31855_CS2_PIN, HIGH); - #endif - - #if HEATER_0_USES_MAX6675 && PIN_EXISTS(MAX31865_CS) - OUT_WRITE(MAX31865_CS_PIN, HIGH); - #endif - #if HEATER_1_USES_MAX6675 && PIN_EXISTS(MAX31865_CS2) - OUT_WRITE(MAX31865_CS2_PIN, HIGH); - #endif - #if HAS_L64XX SETUP_RUN(L64xxManager.init()); // Set up SPI, init drivers #endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 3d22976dffc6..f35622091b15 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -404,32 +404,33 @@ #endif #if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2 - #define HEATER_0_USES_MAX6675 1 + #define TEMP_SENSOR_0_IS_MAX_TC 1 + #define HAS_MAX_TC 1 #if TEMP_SENSOR_0 == -3 - #define HEATER_0_MAX6675_TMIN -270 - #define HEATER_0_MAX6675_TMAX 1800 + #define TEMP_SENSOR_0_MAX_TC_TMIN -270 + #define TEMP_SENSOR_0_MAX_TC_TMAX 1800 #else - #define HEATER_0_MAX6675_TMIN 0 - #define HEATER_0_MAX6675_TMAX 1024 + #define TEMP_SENSOR_0_MAX_TC_TMIN 0 + #define TEMP_SENSOR_0_MAX_TC_TMAX 1024 #endif #if TEMP_SENSOR_0 == -5 - #define MAX6675_0_IS_MAX31865 1 + #define TEMP_SENSOR_0_IS_MAX31865 1 #elif TEMP_SENSOR_0 == -3 - #define MAX6675_0_IS_MAX31855 1 + #define TEMP_SENSOR_0_IS_MAX31855 1 #elif TEMP_SENSOR_0 == -2 - #define MAX6675_0_IS_MAX6675 1 + #define TEMP_SENSOR_0_IS_MAX6675 1 #endif #elif TEMP_SENSOR_0 == -4 - #define HEATER_0_USES_AD8495 1 + #define TEMP_SENSOR_0_IS_AD8495 1 #elif TEMP_SENSOR_0 == -1 - #define HEATER_0_USES_AD595 1 + #define TEMP_SENSOR_0_IS_AD595 1 #elif TEMP_SENSOR_0 > 0 - #define THERMISTOR_HEATER_0 TEMP_SENSOR_0 - #define HEATER_0_USES_THERMISTOR 1 + #define TEMP_SENSOR_0_THERMISTOR_ID TEMP_SENSOR_0 + #define TEMP_SENSOR_0_IS_THERMISTOR 1 #if TEMP_SENSOR_0 == 1000 - #define HEATER_0_USER_THERMISTOR 1 + #define TEMP_SENSOR_0_IS_CUSTOM 1 #elif TEMP_SENSOR_0 == 998 || TEMP_SENSOR_0 == 999 - #define HEATER_0_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_0_IS_DUMMY 1 #endif #else #undef HEATER_0_MINTEMP @@ -437,20 +438,21 @@ #endif #if TEMP_SENSOR_1 == -5 || TEMP_SENSOR_1 == -3 || TEMP_SENSOR_1 == -2 - #define HEATER_1_USES_MAX6675 1 + #define TEMP_SENSOR_1_IS_MAX_TC 1 + #define HAS_MAX_TC 1 #if TEMP_SENSOR_1 == -3 - #define HEATER_1_MAX6675_TMIN -270 - #define HEATER_1_MAX6675_TMAX 1800 + #define TEMP_SENSOR_1_MAX_TC_TMIN -270 + #define TEMP_SENSOR_1_MAX_TC_TMAX 1800 #else - #define HEATER_1_MAX6675_TMIN 0 - #define HEATER_1_MAX6675_TMAX 1024 + #define TEMP_SENSOR_1_MAX_TC_TMIN 0 + #define TEMP_SENSOR_1_MAX_TC_TMAX 1024 #endif #if TEMP_SENSOR_1 == -5 - #define MAX6675_1_IS_MAX31865 1 + #define TEMP_SENSOR_1_IS_MAX31865 1 #elif TEMP_SENSOR_1 == -3 - #define MAX6675_1_IS_MAX31855 1 + #define TEMP_SENSOR_1_IS_MAX31855 1 #elif TEMP_SENSOR_1 == -2 - #define MAX6675_1_IS_MAX6675 1 + #define TEMP_SENSOR_1_IS_MAX6675 1 #endif #if TEMP_SENSOR_1 != TEMP_SENSOR_0 #if TEMP_SENSOR_1 == -5 @@ -462,74 +464,74 @@ #endif #endif #elif TEMP_SENSOR_1 == -4 - #define HEATER_1_USES_AD8495 1 + #define TEMP_SENSOR_1_IS_AD8495 1 #elif TEMP_SENSOR_1 == -1 - #define HEATER_1_USES_AD595 1 + #define TEMP_SENSOR_1_IS_AD595 1 #elif TEMP_SENSOR_1 > 0 - #define THERMISTOR_HEATER_1 TEMP_SENSOR_1 - #define HEATER_1_USES_THERMISTOR 1 + #define TEMP_SENSOR_1_THERMISTOR_ID TEMP_SENSOR_1 + #define TEMP_SENSOR_1_IS_THERMISTOR 1 #if TEMP_SENSOR_1 == 1000 - #define HEATER_1_USER_THERMISTOR 1 + #define TEMP_SENSOR_1_IS_CUSTOM 1 #elif TEMP_SENSOR_1 == 998 || TEMP_SENSOR_1 == 999 - #define HEATER_1_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_1_IS_DUMMY 1 #endif #else #undef HEATER_1_MINTEMP #undef HEATER_1_MAXTEMP #endif -#if MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855 - #define MAX6675_HAS_MAX31855 1 +#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855 + #define HAS_MAX31855 1 #endif -#if MAX6675_0_IS_MAX31865 || MAX6675_1_IS_MAX31865 - #define MAX6675_HAS_MAX31865 1 +#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865 + #define HAS_MAX31865 1 #endif -#if MAX6675_0_IS_MAX6675 || MAX6675_1_IS_MAX6675 - #define MAX6675_HAS_MAX6675 1 +#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 + #define HAS_MAX6675 1 #endif // // Compatibility layer for MAX (SPI) temp boards // #if PIN_EXISTS(MAX6675_SS) - #if MAX6675_0_IS_MAX31855 + #if TEMP_SENSOR_0_IS_MAX31855 #define MAX31855_CS_PIN MAX6675_SS_PIN - #elif MAX6675_0_IS_MAX31865 + #elif TEMP_SENSOR_0_IS_MAX31865 #define MAX31865_CS_PIN MAX6675_SS_PIN - #elif MAX6675_0_IS_MAX6675 + #elif TEMP_SENSOR_0_IS_MAX6675 #define MAX6675_CS_PIN MAX6675_SS_PIN #endif #endif #if PIN_EXISTS(MAX6675_SS2) - #if MAX6675_1_IS_MAX31855 + #if TEMP_SENSOR_1_IS_MAX31855 #define MAX31855_CS2_PIN MAX6675_SS2_PIN - #elif MAX6675_1_IS_MAX31865 + #elif TEMP_SENSOR_1_IS_MAX31865 #define MAX31865_CS2_PIN MAX6675_SS2_PIN - #elif MAX6675_1_IS_MAX6675 + #elif TEMP_SENSOR_1_IS_MAX6675 #define MAX6675_CS2_PIN MAX6675_SS2_PIN #endif #endif #if PIN_EXISTS(MAX6675_DO) - #if MAX6675_HAS_MAX31855 + #if HAS_MAX31855 #define MAX31855_MISO_PIN MAX6675_DO_PIN - #elif MAX6675_HAS_MAX31865 + #elif HAS_MAX31865 #define MAX31865_MISO_PIN MAX6675_DO_PIN - #elif MAX6675_HAS_MAX6675 + #elif HAS_MAX6675 #define MAX6675_MISO_PIN MAX6675_DO_PIN #endif #endif #if PIN_EXISTS(MAX6675_SCK) - #if MAX6675_HAS_MAX31855 + #if HAS_MAX31855 #define MAX31855_SCK_PIN MAX6675_SCK_PIN - #elif MAX6675_HAS_MAX31865 + #elif HAS_MAX31865 #define MAX31865_SCK_PIN MAX6675_SCK_PIN #endif #endif -//Compatibility Layer for use when HAL manipulates PINS for MAX31855 and MAX6675 +// Compatibility Layer for use when HAL manipulates PINS for MAX31855 and MAX6675 #if PIN_EXISTS(MAX31855_CS) && !PIN_EXISTS(MAX6675_SS) #define MAX6675_SS_PIN MAX31855_CS_PIN #endif @@ -552,49 +554,41 @@ #define MAX6675_SCK_PIN MAX31855_SCK_PIN #endif - // -// Possibly trigger user defined libraries +// User-defined thermocouple libraries +// +// Add LIB_MAX6675 / LIB_MAX31855 / LIB_MAX31865 to the build_flags +// to select a USER library for MAX6675, MAX31855, MAX31865 // -//LIB_MAX31865 can be added in platformio.ini file on the build_flags line -//to turn on a USER library for MAX31865 -#if MAX6675_HAS_MAX31865 && DISABLED(LIB_MAX31865) - #undef LIB_USR_MAX31865 - #define LIB_ADAFRUIT_MAX31865 1 -#elif MAX6675_HAS_MAX31865 && ENABLED(LIB_MAX31865) - #undef LIB_ADAFRUIT_MAX31865 - #define LIB_USR_MAX31865 1 -#endif -//LIB_MAX31855 can be added in platformio.ini file on the build_flags line -//to turn on a USER library for MAX31855 -#if MAX6675_HAS_MAX31855 && DISABLED(LIB_MAX31855) - #undef LIB_USR_MAX31855 -#elif MAX6675_HAS_MAX31855 && ENABLED(LIB_MAX31855) +#if BOTH(HAS_MAX6675, LIB_MAX6675) + #define LIB_USR_MAX6675 1 +#endif +#if BOTH(HAS_MAX31855, LIB_MAX31855) #define LIB_USR_MAX31855 1 #endif -//LIB_MAX6675 can be added in platformio.ini file on the build_flags line -//to turn on a USER library for MAX6675 -#if MAX6675_HAS_MAX6675 && DISABLED(LIB_MAX6675) - #undef LIB_USR_MAX6675 -#elif MAX6675_HAS_MAX6675 && ENABLED(LIB_MAX6675) - #define LIB_USR_MAX6675 1 +#if HAS_MAX31865 + #if ENABLED(LIB_MAX31865) + #define LIB_USR_MAX31865 1 + #else + #define LIB_ADAFRUIT_MAX31865 1 + #endif #endif #if TEMP_SENSOR_2 == -4 - #define HEATER_2_USES_AD8495 1 + #define TEMP_SENSOR_2_IS_AD8495 1 #elif TEMP_SENSOR_2 == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_2." #elif TEMP_SENSOR_2 == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_2." #elif TEMP_SENSOR_2 == -1 - #define HEATER_2_USES_AD595 1 + #define TEMP_SENSOR_2_IS_AD595 1 #elif TEMP_SENSOR_2 > 0 - #define THERMISTOR_HEATER_2 TEMP_SENSOR_2 - #define HEATER_2_USES_THERMISTOR 1 + #define TEMP_SENSOR_2_THERMISTOR_ID TEMP_SENSOR_2 + #define TEMP_SENSOR_2_IS_THERMISTOR 1 #if TEMP_SENSOR_2 == 1000 - #define HEATER_2_USER_THERMISTOR 1 + #define TEMP_SENSOR_2_IS_CUSTOM 1 #elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999 - #define HEATER_2_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_2_IS_DUMMY 1 #endif #else #undef HEATER_2_MINTEMP @@ -602,20 +596,20 @@ #endif #if TEMP_SENSOR_3 == -4 - #define HEATER_3_USES_AD8495 1 + #define TEMP_SENSOR_3_IS_AD8495 1 #elif TEMP_SENSOR_3 == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_3." #elif TEMP_SENSOR_3 == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_3." #elif TEMP_SENSOR_3 == -1 - #define HEATER_3_USES_AD595 1 + #define TEMP_SENSOR_3_IS_AD595 1 #elif TEMP_SENSOR_3 > 0 - #define THERMISTOR_HEATER_3 TEMP_SENSOR_3 - #define HEATER_3_USES_THERMISTOR 1 + #define TEMP_SENSOR_3_THERMISTOR_ID TEMP_SENSOR_3 + #define TEMP_SENSOR_3_IS_THERMISTOR 1 #if TEMP_SENSOR_3 == 1000 - #define HEATER_3_USER_THERMISTOR 1 + #define TEMP_SENSOR_3_IS_CUSTOM 1 #elif TEMP_SENSOR_3 == 998 || TEMP_SENSOR_3 == 999 - #define HEATER_3_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_3_IS_DUMMY 1 #endif #else #undef HEATER_3_MINTEMP @@ -623,20 +617,20 @@ #endif #if TEMP_SENSOR_4 == -4 - #define HEATER_4_USES_AD8495 1 + #define TEMP_SENSOR_4_IS_AD8495 1 #elif TEMP_SENSOR_4 == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_4." #elif TEMP_SENSOR_4 == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_4." #elif TEMP_SENSOR_4 == -1 - #define HEATER_4_USES_AD595 1 + #define TEMP_SENSOR_4_IS_AD595 1 #elif TEMP_SENSOR_4 > 0 - #define THERMISTOR_HEATER_4 TEMP_SENSOR_4 - #define HEATER_4_USES_THERMISTOR 1 + #define TEMP_SENSOR_4_THERMISTOR_ID TEMP_SENSOR_4 + #define TEMP_SENSOR_4_IS_THERMISTOR 1 #if TEMP_SENSOR_4 == 1000 - #define HEATER_4_USER_THERMISTOR 1 + #define TEMP_SENSOR_4_IS_CUSTOM 1 #elif TEMP_SENSOR_4 == 998 || TEMP_SENSOR_4 == 999 - #define HEATER_4_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_4_IS_DUMMY 1 #endif #else #undef HEATER_4_MINTEMP @@ -644,20 +638,20 @@ #endif #if TEMP_SENSOR_5 == -4 - #define HEATER_5_USES_AD8495 1 + #define TEMP_SENSOR_5_IS_AD8495 1 #elif TEMP_SENSOR_5 == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_5." #elif TEMP_SENSOR_5 == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_5." #elif TEMP_SENSOR_5 == -1 - #define HEATER_5_USES_AD595 1 + #define TEMP_SENSOR_5_IS_AD595 1 #elif TEMP_SENSOR_5 > 0 - #define THERMISTOR_HEATER_5 TEMP_SENSOR_5 - #define HEATER_5_USES_THERMISTOR 1 + #define TEMP_SENSOR_5_THERMISTOR_ID TEMP_SENSOR_5 + #define TEMP_SENSOR_5_IS_THERMISTOR 1 #if TEMP_SENSOR_5 == 1000 - #define HEATER_5_USER_THERMISTOR 1 + #define TEMP_SENSOR_5_IS_CUSTOM 1 #elif TEMP_SENSOR_5 == 998 || TEMP_SENSOR_5 == 999 - #define HEATER_5_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_5_IS_DUMMY 1 #endif #else #undef HEATER_5_MINTEMP @@ -665,20 +659,20 @@ #endif #if TEMP_SENSOR_6 == -4 - #define HEATER_6_USES_AD8495 1 + #define TEMP_SENSOR_6_IS_AD8495 1 #elif TEMP_SENSOR_6 == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_6." #elif TEMP_SENSOR_6 == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_6." #elif TEMP_SENSOR_6 == -1 - #define HEATER_6_USES_AD595 1 + #define TEMP_SENSOR_6_IS_AD595 1 #elif TEMP_SENSOR_6 > 0 - #define THERMISTOR_HEATER_6 TEMP_SENSOR_6 - #define HEATER_6_USES_THERMISTOR 1 + #define TEMP_SENSOR_6_THERMISTOR_ID TEMP_SENSOR_6 + #define TEMP_SENSOR_6_IS_THERMISTOR 1 #if TEMP_SENSOR_6 == 1000 - #define HEATER_6_USER_THERMISTOR 1 + #define TEMP_SENSOR_6_IS_CUSTOM 1 #elif TEMP_SENSOR_6 == 998 || TEMP_SENSOR_6 == 999 - #define HEATER_6_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_6_IS_DUMMY 1 #endif #else #undef HEATER_6_MINTEMP @@ -686,20 +680,20 @@ #endif #if TEMP_SENSOR_7 == -4 - #define HEATER_7_USES_AD8495 1 + #define TEMP_SENSOR_7_IS_AD8495 1 #elif TEMP_SENSOR_7 == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_7." #elif TEMP_SENSOR_7 == -2 #error "MAX7775 Thermocouples (-2) not supported for TEMP_SENSOR_7." #elif TEMP_SENSOR_7 == -1 - #define HEATER_7_USES_AD595 1 + #define TEMP_SENSOR_7_IS_AD595 1 #elif TEMP_SENSOR_7 > 0 - #define THERMISTOR_HEATER_7 TEMP_SENSOR_7 - #define HEATER_7_USES_THERMISTOR 1 + #define TEMP_SENSOR_7_THERMISTOR_ID TEMP_SENSOR_7 + #define TEMP_SENSOR_7_IS_THERMISTOR 1 #if TEMP_SENSOR_7 == 1000 - #define HEATER_7_USER_THERMISTOR 1 + #define TEMP_SENSOR_7_IS_CUSTOM 1 #elif TEMP_SENSOR_7 == 998 || TEMP_SENSOR_7 == 999 - #define HEATER_7_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_7_IS_DUMMY 1 #endif #else #undef HEATER_7_MINTEMP @@ -707,20 +701,20 @@ #endif #if TEMP_SENSOR_BED == -4 - #define HEATER_BED_USES_AD8495 1 + #define TEMP_SENSOR_BED_IS_AD8495 1 #elif TEMP_SENSOR_BED == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BED." #elif TEMP_SENSOR_BED == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_BED." #elif TEMP_SENSOR_BED == -1 - #define HEATER_BED_USES_AD595 1 + #define TEMP_SENSOR_BED_IS_AD595 1 #elif TEMP_SENSOR_BED > 0 - #define THERMISTORBED TEMP_SENSOR_BED - #define HEATER_BED_USES_THERMISTOR 1 + #define TEMP_SENSOR_BED_THERMISTOR_ID TEMP_SENSOR_BED + #define TEMP_SENSOR_BED_IS_THERMISTOR 1 #if TEMP_SENSOR_BED == 1000 - #define HEATER_BED_USER_THERMISTOR 1 + #define TEMP_SENSOR_BED_IS_CUSTOM 1 #elif TEMP_SENSOR_BED == 998 || TEMP_SENSOR_BED == 999 - #define HEATER_BED_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_BED_IS_DUMMY 1 #endif #else #undef BED_MINTEMP @@ -728,20 +722,20 @@ #endif #if TEMP_SENSOR_CHAMBER == -4 - #define HEATER_CHAMBER_USES_AD8495 1 + #define TEMP_SENSOR_CHAMBER_IS_AD8495 1 #elif TEMP_SENSOR_CHAMBER == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_CHAMBER." #elif TEMP_SENSOR_CHAMBER == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_CHAMBER." #elif TEMP_SENSOR_CHAMBER == -1 - #define HEATER_CHAMBER_USES_AD595 1 + #define TEMP_SENSOR_CHAMBER_IS_AD595 1 #elif TEMP_SENSOR_CHAMBER > 0 - #define THERMISTORCHAMBER TEMP_SENSOR_CHAMBER - #define HEATER_CHAMBER_USES_THERMISTOR 1 + #define TEMP_SENSOR_CHAMBER_THERMISTOR_ID TEMP_SENSOR_CHAMBER + #define TEMP_SENSOR_CHAMBER_IS_THERMISTOR 1 #if TEMP_SENSOR_CHAMBER == 1000 - #define HEATER_CHAMBER_USER_THERMISTOR 1 + #define TEMP_SENSOR_CHAMBER_IS_CUSTOM 1 #elif TEMP_SENSOR_CHAMBER == 998 || TEMP_SENSOR_CHAMBER == 999 - #define HEATER_CHAMBER_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_CHAMBER_IS_DUMMY 1 #endif #else #undef CHAMBER_MINTEMP @@ -749,20 +743,20 @@ #endif #if TEMP_SENSOR_PROBE == -4 - #define HEATER_PROBE_USES_AD8495 1 + #define TEMP_SENSOR_PROBE_IS_AD8495 1 #elif TEMP_SENSOR_PROBE == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_PROBE." #elif TEMP_SENSOR_PROBE == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_PROBE." #elif TEMP_SENSOR_PROBE == -1 - #define HEATER_PROBE_USES_AD595 1 + #define TEMP_SENSOR_PROBE_IS_AD595 1 #elif TEMP_SENSOR_PROBE > 0 - #define THERMISTORPROBE TEMP_SENSOR_PROBE - #define HEATER_PROBE_USES_THERMISTOR 1 + #define TEMP_SENSOR_PROBE_THERMISTOR_ID TEMP_SENSOR_PROBE + #define TEMP_SENSOR_PROBE_IS_THERMISTOR 1 #if TEMP_SENSOR_PROBE == 1000 - #define HEATER_PROBE_USER_THERMISTOR 1 + #define TEMP_SENSOR_PROBE_IS_CUSTOM 1 #elif TEMP_SENSOR_PROBE == 998 || TEMP_SENSOR_PROBE == 999 - #define HEATER_PROBE_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_PROBE_IS_DUMMY 1 #endif #endif @@ -1898,7 +1892,7 @@ // // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface) // -#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && NONE(HEATER_##P##_USES_MAX6675, HEATER_##P##_DUMMY_THERMISTOR)) +#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && NONE(TEMP_SENSOR_##P##_IS_MAX_TC, TEMP_SENSOR_##P##_IS_DUMMY)) #if HAS_ADC_TEST(0) #define HAS_TEMP_ADC_0 1 #endif @@ -1933,7 +1927,7 @@ #define HAS_TEMP_ADC_CHAMBER 1 #endif -#define HAS_TEMP(N) ANY(HAS_TEMP_ADC_##N, HEATER_##N##_USES_MAX6675, HEATER_##N##_DUMMY_THERMISTOR) +#define HAS_TEMP(N) ANY(HAS_TEMP_ADC_##N, TEMP_SENSOR_##N##_IS_MAX_TC, TEMP_SENSOR_##N##_IS_DUMMY) #if HAS_HOTEND && HAS_TEMP(0) #define HAS_TEMP_HOTEND 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index f77f08a925f9..2ff5293de21f 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1698,46 +1698,48 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal /** * Required custom thermistor settings */ -#if HEATER_0_USER_THERMISTOR && !(defined(HOTEND0_PULLUP_RESISTOR_OHMS) && defined(HOTEND0_RESISTANCE_25C_OHMS) && defined(HOTEND0_BETA)) +#if TEMP_SENSOR_0_IS_CUSTOM && !(defined(HOTEND0_PULLUP_RESISTOR_OHMS) && defined(HOTEND0_RESISTANCE_25C_OHMS) && defined(HOTEND0_BETA)) #error "TEMP_SENSOR_0 1000 requires HOTEND0_PULLUP_RESISTOR_OHMS, HOTEND0_RESISTANCE_25C_OHMS and HOTEND0_BETA in Configuration_adv.h." -#elif HEATER_1_USER_THERMISTOR && !(defined(HOTEND1_PULLUP_RESISTOR_OHMS) && defined(HOTEND1_RESISTANCE_25C_OHMS) && defined(HOTEND1_BETA)) +#elif TEMP_SENSOR_1_IS_CUSTOM && !(defined(HOTEND1_PULLUP_RESISTOR_OHMS) && defined(HOTEND1_RESISTANCE_25C_OHMS) && defined(HOTEND1_BETA)) #error "TEMP_SENSOR_1 1000 requires HOTEND1_PULLUP_RESISTOR_OHMS, HOTEND1_RESISTANCE_25C_OHMS and HOTEND1_BETA in Configuration_adv.h." -#elif HEATER_2_USER_THERMISTOR && !(defined(HOTEND2_PULLUP_RESISTOR_OHMS) && defined(HOTEND2_RESISTANCE_25C_OHMS) && defined(HOTEND2_BETA)) +#elif TEMP_SENSOR_2_IS_CUSTOM && !(defined(HOTEND2_PULLUP_RESISTOR_OHMS) && defined(HOTEND2_RESISTANCE_25C_OHMS) && defined(HOTEND2_BETA)) #error "TEMP_SENSOR_2 1000 requires HOTEND2_PULLUP_RESISTOR_OHMS, HOTEND2_RESISTANCE_25C_OHMS and HOTEND2_BETA in Configuration_adv.h." -#elif HEATER_3_USER_THERMISTOR && !(defined(HOTEND3_PULLUP_RESISTOR_OHMS) && defined(HOTEND3_RESISTANCE_25C_OHMS) && defined(HOTEND3_BETA)) +#elif TEMP_SENSOR_3_IS_CUSTOM && !(defined(HOTEND3_PULLUP_RESISTOR_OHMS) && defined(HOTEND3_RESISTANCE_25C_OHMS) && defined(HOTEND3_BETA)) #error "TEMP_SENSOR_3 1000 requires HOTEND3_PULLUP_RESISTOR_OHMS, HOTEND3_RESISTANCE_25C_OHMS and HOTEND3_BETA in Configuration_adv.h." -#elif HEATER_4_USER_THERMISTOR && !(defined(HOTEND4_PULLUP_RESISTOR_OHMS) && defined(HOTEND4_RESISTANCE_25C_OHMS) && defined(HOTEND4_BETA)) +#elif TEMP_SENSOR_4_IS_CUSTOM && !(defined(HOTEND4_PULLUP_RESISTOR_OHMS) && defined(HOTEND4_RESISTANCE_25C_OHMS) && defined(HOTEND4_BETA)) #error "TEMP_SENSOR_4 1000 requires HOTEND4_PULLUP_RESISTOR_OHMS, HOTEND4_RESISTANCE_25C_OHMS and HOTEND4_BETA in Configuration_adv.h." -#elif HEATER_5_USER_THERMISTOR && !(defined(HOTEND5_PULLUP_RESISTOR_OHMS) && defined(HOTEND5_RESISTANCE_25C_OHMS) && defined(HOTEND5_BETA)) +#elif TEMP_SENSOR_5_IS_CUSTOM && !(defined(HOTEND5_PULLUP_RESISTOR_OHMS) && defined(HOTEND5_RESISTANCE_25C_OHMS) && defined(HOTEND5_BETA)) #error "TEMP_SENSOR_5 1000 requires HOTEND5_PULLUP_RESISTOR_OHMS, HOTEND5_RESISTANCE_25C_OHMS and HOTEND5_BETA in Configuration_adv.h." -#elif HEATER_6_USER_THERMISTOR && !(defined(HOTEND6_PULLUP_RESISTOR_OHMS) && defined(HOTEND6_RESISTANCE_25C_OHMS) && defined(HOTEND6_BETA)) +#elif TEMP_SENSOR_6_IS_CUSTOM && !(defined(HOTEND6_PULLUP_RESISTOR_OHMS) && defined(HOTEND6_RESISTANCE_25C_OHMS) && defined(HOTEND6_BETA)) #error "TEMP_SENSOR_6 1000 requires HOTEND6_PULLUP_RESISTOR_OHMS, HOTEND6_RESISTANCE_25C_OHMS and HOTEND6_BETA in Configuration_adv.h." -#elif HEATER_7_USER_THERMISTOR && !(defined(HOTEND7_PULLUP_RESISTOR_OHMS) && defined(HOTEND7_RESISTANCE_25C_OHMS) && defined(HOTEND7_BETA)) +#elif TEMP_SENSOR_7_IS_CUSTOM && !(defined(HOTEND7_PULLUP_RESISTOR_OHMS) && defined(HOTEND7_RESISTANCE_25C_OHMS) && defined(HOTEND7_BETA)) #error "TEMP_SENSOR_7 1000 requires HOTEND7_PULLUP_RESISTOR_OHMS, HOTEND7_RESISTANCE_25C_OHMS and HOTEND7_BETA in Configuration_adv.h." -#elif HEATER_BED_USER_THERMISTOR && !(defined(BED_PULLUP_RESISTOR_OHMS) && defined(BED_RESISTANCE_25C_OHMS) && defined(BED_BETA)) +#elif TEMP_SENSOR_BED_IS_CUSTOM && !(defined(BED_PULLUP_RESISTOR_OHMS) && defined(BED_RESISTANCE_25C_OHMS) && defined(BED_BETA)) #error "TEMP_SENSOR_BED 1000 requires BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS and BED_BETA in Configuration_adv.h." -#elif HEATER_CHAMBER_USER_THERMISTOR && !(defined(CHAMBER_PULLUP_RESISTOR_OHMS) && defined(CHAMBER_RESISTANCE_25C_OHMS) && defined(CHAMBER_BETA)) +#elif TEMP_SENSOR_CHAMBER_IS_CUSTOM && !(defined(CHAMBER_PULLUP_RESISTOR_OHMS) && defined(CHAMBER_RESISTANCE_25C_OHMS) && defined(CHAMBER_BETA)) #error "TEMP_SENSOR_CHAMBER 1000 requires CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS and CHAMBER_BETA in Configuration_adv.h." +#elif TEMP_SENSOR_PROBE_IS_CUSTOM && !(defined(PROBE_PULLUP_RESISTOR_OHMS) && defined(PROBE_RESISTANCE_25C_OHMS) && defined(PROBE_BETA)) + #error "TEMP_SENSOR_PROBE 1000 requires PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS and PROBE_BETA in Configuration_adv.h." #endif /** * Pins and Sensor IDs must be set for each heater */ -#if HEATER_0_USES_MAX6675 && !ANY_PIN(MAX31855_CS, MAX31865_CS, MAX6675_CS) - #error "TEMP_SENSOR_0 requires a MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN." -#elif HAS_HOTEND && !HAS_TEMP_HOTEND && !HEATER_0_DUMMY_THERMISTOR +#if TEMP_SENSOR_0_IS_MAX6675 && !ANY_PIN(MAX6675_SS, MAX31855_CS, MAX31865_CS, MAX6675_CS) + #error "TEMP_SENSOR_0 requires a MAX6675_SS_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN." +#elif HAS_HOTEND && !HAS_TEMP_HOTEND && !TEMP_SENSOR_0_IS_DUMMY #error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board." #elif EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) && !HAS_HEATER_1 #error "HEATER_1_PIN is not defined. TEMP_SENSOR_1 might not be set, or the board (not EEB / EEF?) doesn't define a pin." #endif #if HAS_MULTI_HOTEND - #if HEATER_1_USES_MAX6675 && !ANY_PIN(MAX31855_CS2, MAX31865_CS2, MAX6675_CS2) - #error "TEMP_SENSOR_1 requires a MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN." + #if TEMP_SENSOR_1_IS_MAX6675 && !ANY_PIN(MAX6675_SS2, MAX31855_CS2, MAX31865_CS2, MAX6675_CS2) + #error "TEMP_SENSOR_1 requires a MAX6675_SS2_PIN, MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN." #elif TEMP_SENSOR_1 == 0 #error "TEMP_SENSOR_1 is required with 2 or more HOTENDS." - #elif !ANY_PIN(TEMP_1, MAX6675_CS2, MAX31855_CS2, MAX31865_CS2) && !HEATER_1_DUMMY_THERMISTOR - #error "TEMP_1_PIN, MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN is not defined for this board." + #elif !ANY_PIN(TEMP_1, MAX6675_SS2) && !TEMP_SENSOR_1_IS_DUMMY + #error "TEMP_1_PIN or MAX6675_SS2_PIN not defined for this board." #elif ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) #error "HOTENDS must be 1 with TEMP_SENSOR_1_AS_REDUNDANT." #endif @@ -1746,7 +1748,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_2 is required with 3 or more HOTENDS." #elif !HAS_HEATER_2 #error "HEATER_2_PIN not defined for this board." - #elif !PIN_EXISTS(TEMP_2) && !HEATER_2_DUMMY_THERMISTOR + #elif !PIN_EXISTS(TEMP_2) && !TEMP_SENSOR_2_IS_DUMMY #error "TEMP_2_PIN not defined for this board." #endif #if HOTENDS > 3 @@ -1754,7 +1756,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_3 is required with 4 or more HOTENDS." #elif !HAS_HEATER_3 #error "HEATER_3_PIN not defined for this board." - #elif !PIN_EXISTS(TEMP_3) && !HEATER_3_DUMMY_THERMISTOR + #elif !PIN_EXISTS(TEMP_3) && !TEMP_SENSOR_3_IS_DUMMY #error "TEMP_3_PIN not defined for this board." #endif #if HOTENDS > 4 @@ -1762,7 +1764,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_4 is required with 5 or more HOTENDS." #elif !HAS_HEATER_4 #error "HEATER_4_PIN not defined for this board." - #elif !PIN_EXISTS(TEMP_4) && !HEATER_4_DUMMY_THERMISTOR + #elif !PIN_EXISTS(TEMP_4) && !TEMP_SENSOR_4_IS_DUMMY #error "TEMP_4_PIN not defined for this board." #endif #if HOTENDS > 5 @@ -1770,7 +1772,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_5 is required with 6 HOTENDS." #elif !HAS_HEATER_5 #error "HEATER_5_PIN not defined for this board." - #elif !PIN_EXISTS(TEMP_5) && !HEATER_5_DUMMY_THERMISTOR + #elif !PIN_EXISTS(TEMP_5) && !TEMP_SENSOR_5_IS_DUMMY #error "TEMP_5_PIN not defined for this board." #endif #if HOTENDS > 6 @@ -1778,7 +1780,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_6 is required with 6 HOTENDS." #elif !HAS_HEATER_6 #error "HEATER_6_PIN not defined for this board." - #elif !PIN_EXISTS(TEMP_6) && !HEATER_6_DUMMY_THERMISTOR + #elif !PIN_EXISTS(TEMP_6) && !TEMP_SENSOR_6_IS_DUMMY #error "TEMP_6_PIN not defined for this board." #endif #if HOTENDS > 7 @@ -1786,7 +1788,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_7 is required with 7 HOTENDS." #elif !HAS_HEATER_7 #error "HEATER_7_PIN not defined for this board." - #elif !PIN_EXISTS(TEMP_7) && !HEATER_7_DUMMY_THERMISTOR + #elif !PIN_EXISTS(TEMP_7) && !TEMP_SENSOR_7_IS_DUMMY #error "TEMP_7_PIN not defined for this board." #endif #elif TEMP_SENSOR_7 != 0 @@ -1895,9 +1897,9 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT." #endif -#if MAX6675_0_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_0) && defined(MAX31865_CALIBRATION_OHMS_0)) +#if TEMP_SENSOR_0_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_0) && defined(MAX31865_CALIBRATION_OHMS_0)) #error "MAX31865_SENSOR_OHMS_0 and MAX31865_CALIBRATION_OHMS_0 must be set if TEMP_SENSOR_0 is MAX31865." -#elif MAX6675_1_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_1) && defined(MAX31865_CALIBRATION_OHMS_1)) +#elif TEMP_SENSOR_1_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_1) && defined(MAX31865_CALIBRATION_OHMS_1)) #error "MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 must be set if TEMP_SENSOR_1 is MAX31865." #endif @@ -1906,8 +1908,8 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal */ #if !HAS_HEATER_0 && EXTRUDERS #error "HEATER_0_PIN not defined for this board." -#elif !ANY_PIN(TEMP_0, MAX6675_CS, MAX31855_CS, MAX31865_CS) - #error "TEMP_0_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN is not defined for this board." +#elif !ANY_PIN(TEMP_0, MAX6675_SS) + #error "TEMP_0_PIN or MAX6675_SS not defined for this board." #elif ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR)) #error "E0_STEP_PIN or E0_DIR_PIN not defined for this board." #elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE)) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 8524f1560e87..a7bfc7ec89e9 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -47,31 +47,29 @@ #include "../lcd/extui/ui_api.h" #endif -// LIB_MAX31855 can be added in platformio.ini file on the build_flags line to use a user defined library +// LIB_MAX31855 can be added to the build_flags in platformio.ini to use a user-defined library #if LIB_USR_MAX31855 #include #if PIN_EXISTS(MAX31855_MISO) && PIN_EXISTS(MAX31855_SCK) #define MAX31855_USES_SW_SPI 1 #endif - #if MAX6675_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS) + #if TEMP_SENSOR_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS) #define HAS_MAX31855_TEMP 1 Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855(MAX31855_CS_PIN #if MAX31855_USES_SW_SPI , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK #endif - //LARGE_PINMAP can be added in platformio.ini file on the build_flags line #if ENABLED(LARGE_PINMAP) , HIGH #endif ); #endif - #if MAX6675_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2) + #if TEMP_SENSOR_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2) #define HAS_MAX31855_TEMP 1 Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855(MAX31855_CS2_PIN #if MAX31855_USES_SW_SPI , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK #endif - //LARGE_PINMAP can be added in platformio.ini file on the build_flags line #if ENABLED(LARGE_PINMAP) , HIGH #endif @@ -79,9 +77,9 @@ #endif #endif -//LIB_MAX31865 can be added in platformio.ini file on the build_flags line to use a user defined library -//if LIB_MAX31865 is not on the build_flags then the Adafruit MAX31865 V1.1.0 library is used -#if MAX6675_HAS_MAX31865 +// LIB_MAX31865 can be added to the build_flags in platformio.ini to use a user-defined library. +// If LIB_MAX31865 is not on the build_flags then the Adafruit MAX31865 V1.1.0 library is used. +#if HAS_MAX31865 #include #ifndef MAX31865_MOSI_PIN #define MAX31865_MOSI_PIN SD_MOSI_PIN @@ -92,57 +90,53 @@ #if PIN_EXISTS(MAX31865_MISO) && PIN_EXISTS(MAX31865_SCK) #define MAX31865_USES_SW_SPI 1 #endif - #if MAX6675_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS) + #if TEMP_SENSOR_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS) #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK #endif - //LARGE_PINMAP can be added in platformio.ini file on the build_flags line #if ENABLED(LARGE_PINMAP) , HIGH #endif ); #endif - #if MAX6675_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2) + #if TEMP_SENSOR_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2) #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK #endif - //LARGE_PINMAP can be added in platformio.ini file on the build_flags line #if ENABLED(LARGE_PINMAP) - , HIGH + , HIGH #endif ); #endif #endif -// LIB_MAX6675 can be added in platformio.ini file on the build_flags line to use a user defined library +// LIB_MAX6675 can be added to the build_flags in platformio.ini to use a user-defined library #if LIB_USR_MAX6675 #include #if PIN_EXISTS(MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK) #define MAX6675_USES_SW_SPI 1 #endif - #if MAX6675_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) + #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) #define HAS_MAX6675_TEMP 1 MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN #if MAX6675_USES_SW_SPI , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif - //LARGE_PINMAP can be added in platformio.ini file on the build_flags line #if ENABLED(LARGE_PINMAP) , HIGH #endif ); #endif - #if MAX6675_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) + #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) #define HAS_MAX6675_TEMP 1 MAX6675 max6675_1 = MAX6675(MAX6675_CS2_PIN #if MAX6675_USES_SW_SPI , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK #endif - //LARGE_PINMAP can be added in platformio.ini file on the build_flags line #if ENABLED(LARGE_PINMAP) , HIGH #endif @@ -154,11 +148,11 @@ #define NO_THERMO_TEMPS 1 #endif -#if (HEATER_0_USES_MAX6675 || HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS - #define MAX6675_SEPARATE_SPI 1 +#if (TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS + #define THERMO_SEPARATE_SPI 1 #endif -#if MAX6675_SEPARATE_SPI +#if THERMO_SEPARATE_SPI #include "../libs/private_spi.h" #endif @@ -204,20 +198,20 @@ #include "./servo.h" #endif -#if ANY(HEATER_0_USES_THERMISTOR, HEATER_1_USES_THERMISTOR, HEATER_2_USES_THERMISTOR, HEATER_3_USES_THERMISTOR, \ - HEATER_4_USES_THERMISTOR, HEATER_5_USES_THERMISTOR, HEATER_6_USES_THERMISTOR, HEATER_7_USES_THERMISTOR ) +#if ANY(TEMP_SENSOR_0_IS_THERMISTOR, TEMP_SENSOR_1_IS_THERMISTOR, TEMP_SENSOR_2_IS_THERMISTOR, TEMP_SENSOR_3_IS_THERMISTOR, \ + TEMP_SENSOR_4_IS_THERMISTOR, TEMP_SENSOR_5_IS_THERMISTOR, TEMP_SENSOR_6_IS_THERMISTOR, TEMP_SENSOR_7_IS_THERMISTOR ) #define HAS_HOTEND_THERMISTOR 1 #endif #if HAS_HOTEND_THERMISTOR #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - static const temp_entry_t* heater_ttbl_map[2] = { HEATER_0_TEMPTABLE, HEATER_1_TEMPTABLE }; - static constexpr uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN }; + static const temp_entry_t* heater_ttbl_map[2] = { TEMPTABLE_0, TEMPTABLE_1 }; + static constexpr uint8_t heater_ttbllen_map[2] = { TEMPTABLE_0_LEN, TEMPTABLE_1_LEN }; #else - #define NEXT_TEMPTABLE(N) ,HEATER_##N##_TEMPTABLE - #define NEXT_TEMPTABLE_LEN(N) ,HEATER_##N##_TEMPTABLE_LEN - static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE)); - static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN)); + #define NEXT_TEMPTABLE(N) ,TEMPTABLE_##N + #define NEXT_TEMPTABLE_LEN(N) ,TEMPTABLE_##N##_LEN + static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0 REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE)); + static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN)); #endif #endif @@ -357,10 +351,10 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, bed_info_t Temperature::temp_bed; // = { 0 } // Init min and max temp with extreme values to prevent false errors during startup #ifdef BED_MINTEMP - int16_t Temperature::mintemp_raw_BED = HEATER_BED_RAW_LO_TEMP; + int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP; #endif #ifdef BED_MAXTEMP - int16_t Temperature::maxtemp_raw_BED = HEATER_BED_RAW_HI_TEMP; + int16_t Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP; #endif TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 } IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms); @@ -375,10 +369,10 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, millis_t next_cool_check_ms_2 = 0; float old_temp = 9999; #ifdef CHAMBER_MINTEMP - int16_t Temperature::mintemp_raw_CHAMBER = HEATER_CHAMBER_RAW_LO_TEMP; + int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP; #endif #ifdef CHAMBER_MAXTEMP - int16_t Temperature::maxtemp_raw_CHAMBER = HEATER_CHAMBER_RAW_HI_TEMP; + int16_t Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP; #endif #if WATCH_CHAMBER chamber_watch_t Temperature::watch_chamber{0}; @@ -419,18 +413,18 @@ volatile bool Temperature::raw_temps_ready = false; lpq_ptr_t Temperature::lpq_ptr = 0; #endif -#define TEMPDIR(N) ((HEATER_##N##_RAW_LO_TEMP) < (HEATER_##N##_RAW_HI_TEMP) ? 1 : -1) +#define TEMPDIR(N) ((TEMP_SENSOR_##N##_RAW_LO_TEMP) < (TEMP_SENSOR_##N##_RAW_HI_TEMP) ? 1 : -1) #if HAS_HOTEND // Init mintemp and maxtemp with extreme values to prevent false errors during startup - constexpr temp_range_t sensor_heater_0 { HEATER_0_RAW_LO_TEMP, HEATER_0_RAW_HI_TEMP, 0, 16383 }, - sensor_heater_1 { HEATER_1_RAW_LO_TEMP, HEATER_1_RAW_HI_TEMP, 0, 16383 }, - sensor_heater_2 { HEATER_2_RAW_LO_TEMP, HEATER_2_RAW_HI_TEMP, 0, 16383 }, - sensor_heater_3 { HEATER_3_RAW_LO_TEMP, HEATER_3_RAW_HI_TEMP, 0, 16383 }, - sensor_heater_4 { HEATER_4_RAW_LO_TEMP, HEATER_4_RAW_HI_TEMP, 0, 16383 }, - sensor_heater_5 { HEATER_5_RAW_LO_TEMP, HEATER_5_RAW_HI_TEMP, 0, 16383 }, - sensor_heater_6 { HEATER_6_RAW_LO_TEMP, HEATER_6_RAW_HI_TEMP, 0, 16383 }, - sensor_heater_7 { HEATER_7_RAW_LO_TEMP, HEATER_7_RAW_HI_TEMP, 0, 16383 }; + constexpr temp_range_t sensor_heater_0 { TEMP_SENSOR_0_RAW_LO_TEMP, TEMP_SENSOR_0_RAW_HI_TEMP, 0, 16383 }, + sensor_heater_1 { TEMP_SENSOR_1_RAW_LO_TEMP, TEMP_SENSOR_1_RAW_HI_TEMP, 0, 16383 }, + sensor_heater_2 { TEMP_SENSOR_2_RAW_LO_TEMP, TEMP_SENSOR_2_RAW_HI_TEMP, 0, 16383 }, + sensor_heater_3 { TEMP_SENSOR_3_RAW_LO_TEMP, TEMP_SENSOR_3_RAW_HI_TEMP, 0, 16383 }, + sensor_heater_4 { TEMP_SENSOR_4_RAW_LO_TEMP, TEMP_SENSOR_4_RAW_HI_TEMP, 0, 16383 }, + sensor_heater_5 { TEMP_SENSOR_5_RAW_LO_TEMP, TEMP_SENSOR_5_RAW_HI_TEMP, 0, 16383 }, + sensor_heater_6 { TEMP_SENSOR_6_RAW_LO_TEMP, TEMP_SENSOR_6_RAW_HI_TEMP, 0, 16383 }, + sensor_heater_7 { TEMP_SENSOR_7_RAW_LO_TEMP, TEMP_SENSOR_7_RAW_HI_TEMP, 0, 16383 }; temp_range_t Temperature::temp_range[HOTENDS] = ARRAY_BY_HOTENDS(sensor_heater_0, sensor_heater_1, sensor_heater_2, sensor_heater_3, sensor_heater_4, sensor_heater_5, sensor_heater_6, sensor_heater_7); #endif @@ -1155,13 +1149,13 @@ void Temperature::manage_heater() { updateTemperaturesFromRawValues(); // also resets the watchdog #if DISABLED(IGNORE_THERMOCOUPLE_ERRORS) - #if HEATER_0_USES_MAX6675 - if (temp_hotend[0].celsius > _MIN(HEATER_0_MAXTEMP, HEATER_0_MAX6675_TMAX - 1.0)) max_temp_error(H_E0); - if (temp_hotend[0].celsius < _MAX(HEATER_0_MINTEMP, HEATER_0_MAX6675_TMIN + .01)) min_temp_error(H_E0); + #if TEMP_SENSOR_0_IS_MAX_TC + if (temp_hotend[0].celsius > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) max_temp_error(H_E0); + if (temp_hotend[0].celsius < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0); #endif - #if HEATER_1_USES_MAX6675 - if (temp_hotend[1].celsius > _MIN(HEATER_1_MAXTEMP, HEATER_1_MAX6675_TMAX - 1.0)) max_temp_error(H_E1); - if (temp_hotend[1].celsius < _MAX(HEATER_1_MINTEMP, HEATER_1_MAX6675_TMIN + .01)) min_temp_error(H_E1); + #if TEMP_SENSOR_1_IS_MAX_TC + if (temp_hotend[1].celsius > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1); + if (temp_hotend[1].celsius < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1); #endif #endif @@ -1445,36 +1439,39 @@ void Temperature::manage_heater() { void Temperature::reset_user_thermistors() { user_thermistor_t default_user_thermistor[USER_THERMISTORS] = { - #if HEATER_0_USER_THERMISTOR + #if TEMP_SENSOR_0_IS_CUSTOM { true, 0, 0, HOTEND0_PULLUP_RESISTOR_OHMS, HOTEND0_RESISTANCE_25C_OHMS, 0, 0, HOTEND0_BETA, 0 }, #endif - #if HEATER_1_USER_THERMISTOR + #if TEMP_SENSOR_1_IS_CUSTOM { true, 0, 0, HOTEND1_PULLUP_RESISTOR_OHMS, HOTEND1_RESISTANCE_25C_OHMS, 0, 0, HOTEND1_BETA, 0 }, #endif - #if HEATER_2_USER_THERMISTOR + #if TEMP_SENSOR_2_IS_CUSTOM { true, 0, 0, HOTEND2_PULLUP_RESISTOR_OHMS, HOTEND2_RESISTANCE_25C_OHMS, 0, 0, HOTEND2_BETA, 0 }, #endif - #if HEATER_3_USER_THERMISTOR + #if TEMP_SENSOR_3_IS_CUSTOM { true, 0, 0, HOTEND3_PULLUP_RESISTOR_OHMS, HOTEND3_RESISTANCE_25C_OHMS, 0, 0, HOTEND3_BETA, 0 }, #endif - #if HEATER_4_USER_THERMISTOR + #if TEMP_SENSOR_4_IS_CUSTOM { true, 0, 0, HOTEND4_PULLUP_RESISTOR_OHMS, HOTEND4_RESISTANCE_25C_OHMS, 0, 0, HOTEND4_BETA, 0 }, #endif - #if HEATER_5_USER_THERMISTOR + #if TEMP_SENSOR_5_IS_CUSTOM { true, 0, 0, HOTEND5_PULLUP_RESISTOR_OHMS, HOTEND5_RESISTANCE_25C_OHMS, 0, 0, HOTEND5_BETA, 0 }, #endif - #if HEATER_6_USER_THERMISTOR + #if TEMP_SENSOR_6_IS_CUSTOM { true, 0, 0, HOTEND6_PULLUP_RESISTOR_OHMS, HOTEND6_RESISTANCE_25C_OHMS, 0, 0, HOTEND6_BETA, 0 }, #endif - #if HEATER_7_USER_THERMISTOR + #if TEMP_SENSOR_7_IS_CUSTOM { true, 0, 0, HOTEND7_PULLUP_RESISTOR_OHMS, HOTEND7_RESISTANCE_25C_OHMS, 0, 0, HOTEND7_BETA, 0 }, #endif - #if HEATER_BED_USER_THERMISTOR + #if TEMP_SENSOR_BED_IS_CUSTOM { true, 0, 0, BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS, 0, 0, BED_BETA, 0 }, #endif - #if HEATER_CHAMBER_USER_THERMISTOR + #if TEMP_SENSOR_CHAMBER_IS_CUSTOM { true, 0, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 } #endif + #if TEMP_SENSOR_PROBE_IS_CUSTOM + { true, 0, 0, PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS, 0, 0, PROBE_BETA, 0 } + #endif }; COPY(user_thermistor, default_user_thermistor); } @@ -1495,16 +1492,17 @@ void Temperature::manage_heater() { SERIAL_ECHOPAIR_F_P(SP_C_STR, t.sh_c_coeff, 9); SERIAL_ECHOPGM(" ; "); serialprintPGM( - TERN_(HEATER_0_USER_THERMISTOR, t_index == CTI_HOTEND_0 ? PSTR("HOTEND 0") :) - TERN_(HEATER_1_USER_THERMISTOR, t_index == CTI_HOTEND_1 ? PSTR("HOTEND 1") :) - TERN_(HEATER_2_USER_THERMISTOR, t_index == CTI_HOTEND_2 ? PSTR("HOTEND 2") :) - TERN_(HEATER_3_USER_THERMISTOR, t_index == CTI_HOTEND_3 ? PSTR("HOTEND 3") :) - TERN_(HEATER_4_USER_THERMISTOR, t_index == CTI_HOTEND_4 ? PSTR("HOTEND 4") :) - TERN_(HEATER_5_USER_THERMISTOR, t_index == CTI_HOTEND_5 ? PSTR("HOTEND 5") :) - TERN_(HEATER_6_USER_THERMISTOR, t_index == CTI_HOTEND_6 ? PSTR("HOTEND 6") :) - TERN_(HEATER_7_USER_THERMISTOR, t_index == CTI_HOTEND_7 ? PSTR("HOTEND 7") :) - TERN_(HEATER_BED_USER_THERMISTOR, t_index == CTI_BED ? PSTR("BED") :) - TERN_(HEATER_CHAMBER_USER_THERMISTOR, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :) + TERN_(TEMP_SENSOR_0_IS_CUSTOM, t_index == CTI_HOTEND_0 ? PSTR("HOTEND 0") :) + TERN_(TEMP_SENSOR_1_IS_CUSTOM, t_index == CTI_HOTEND_1 ? PSTR("HOTEND 1") :) + TERN_(TEMP_SENSOR_2_IS_CUSTOM, t_index == CTI_HOTEND_2 ? PSTR("HOTEND 2") :) + TERN_(TEMP_SENSOR_3_IS_CUSTOM, t_index == CTI_HOTEND_3 ? PSTR("HOTEND 3") :) + TERN_(TEMP_SENSOR_4_IS_CUSTOM, t_index == CTI_HOTEND_4 ? PSTR("HOTEND 4") :) + TERN_(TEMP_SENSOR_5_IS_CUSTOM, t_index == CTI_HOTEND_5 ? PSTR("HOTEND 5") :) + TERN_(TEMP_SENSOR_6_IS_CUSTOM, t_index == CTI_HOTEND_6 ? PSTR("HOTEND 6") :) + TERN_(TEMP_SENSOR_7_IS_CUSTOM, t_index == CTI_HOTEND_7 ? PSTR("HOTEND 7") :) + TERN_(TEMP_SENSOR_BED_IS_CUSTOM, t_index == CTI_BED ? PSTR("BED") :) + TERN_(TEMP_SENSOR_CHAMBER_IS_CUSTOM, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :) + TERN_(TEMP_SENSOR_PROBE_IS_CUSTOM, t_index == CTI_PROBE ? PSTR("PROBE") :) nullptr ); SERIAL_EOL(); @@ -1570,85 +1568,85 @@ void Temperature::manage_heater() { switch (e) { case 0: - #if HEATER_0_USER_THERMISTOR + #if TEMP_SENSOR_0_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_0, raw); - #elif HEATER_0_USES_MAX6675 - return TERN(MAX6675_0_IS_MAX31865, max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0), raw * 0.25); - #elif HEATER_0_USES_AD595 + #elif TEMP_SENSOR_0_IS_MAX_TC + return TERN(TEMP_SENSOR_0_IS_MAX31865, max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0), raw * 0.25); + #elif TEMP_SENSOR_0_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_0_USES_AD8495 + #elif TEMP_SENSOR_0_IS_AD8495 return TEMP_AD8495(raw); #else break; #endif case 1: - #if HEATER_1_USER_THERMISTOR + #if TEMP_SENSOR_1_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_1, raw); - #elif HEATER_1_USES_MAX6675 - return TERN(MAX6675_1_IS_MAX31865, max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1), raw * 0.25); - #elif HEATER_1_USES_AD595 + #elif TEMP_SENSOR_1_IS_MAX_TC + return TERN(TEMP_SENSOR_1_IS_MAX31865, max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1), raw * 0.25); + #elif TEMP_SENSOR_1_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_1_USES_AD8495 + #elif TEMP_SENSOR_1_IS_AD8495 return TEMP_AD8495(raw); #else break; #endif case 2: - #if HEATER_2_USER_THERMISTOR + #if TEMP_SENSOR_2_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_2, raw); - #elif HEATER_2_USES_AD595 + #elif TEMP_SENSOR_2_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_2_USES_AD8495 + #elif TEMP_SENSOR_2_IS_AD8495 return TEMP_AD8495(raw); #else break; #endif case 3: - #if HEATER_3_USER_THERMISTOR + #if TEMP_SENSOR_3_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_3, raw); - #elif HEATER_3_USES_AD595 + #elif TEMP_SENSOR_3_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_3_USES_AD8495 + #elif TEMP_SENSOR_3_IS_AD8495 return TEMP_AD8495(raw); #else break; #endif case 4: - #if HEATER_4_USER_THERMISTOR + #if TEMP_SENSOR_4_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_4, raw); - #elif HEATER_4_USES_AD595 + #elif TEMP_SENSOR_4_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_4_USES_AD8495 + #elif TEMP_SENSOR_4_IS_AD8495 return TEMP_AD8495(raw); #else break; #endif case 5: - #if HEATER_5_USER_THERMISTOR + #if TEMP_SENSOR_5_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_5, raw); - #elif HEATER_5_USES_AD595 + #elif TEMP_SENSOR_5_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_5_USES_AD8495 + #elif TEMP_SENSOR_5_IS_AD8495 return TEMP_AD8495(raw); #else break; #endif case 6: - #if HEATER_6_USER_THERMISTOR + #if TEMP_SENSOR_6_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_6, raw); - #elif HEATER_6_USES_AD595 + #elif TEMP_SENSOR_6_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_6_USES_AD8495 + #elif TEMP_SENSOR_6_IS_AD8495 return TEMP_AD8495(raw); #else break; #endif case 7: - #if HEATER_7_USER_THERMISTOR + #if TEMP_SENSOR_7_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_7, raw); - #elif HEATER_7_USES_AD595 + #elif TEMP_SENSOR_7_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_7_USES_AD8495 + #elif TEMP_SENSOR_7_IS_AD8495 return TEMP_AD8495(raw); #else break; @@ -1670,13 +1668,13 @@ void Temperature::manage_heater() { // Derived from RepRap FiveD extruder::getTemperature() // For bed temperature measurement. float Temperature::analog_to_celsius_bed(const int raw) { - #if HEATER_BED_USER_THERMISTOR + #if TEMP_SENSOR_BED_IS_CUSTOM return user_thermistor_to_deg_c(CTI_BED, raw); - #elif HEATER_BED_USES_THERMISTOR - SCAN_THERMISTOR_TABLE(BED_TEMPTABLE, BED_TEMPTABLE_LEN); - #elif HEATER_BED_USES_AD595 + #elif TEMP_SENSOR_BED_IS_THERMISTOR + SCAN_THERMISTOR_TABLE(TEMPTABLE_BED, TEMPTABLE_BED_LEN); + #elif TEMP_SENSOR_BED_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_BED_USES_AD8495 + #elif TEMP_SENSOR_BED_IS_AD8495 return TEMP_AD8495(raw); #else UNUSED(raw); @@ -1689,13 +1687,13 @@ void Temperature::manage_heater() { // Derived from RepRap FiveD extruder::getTemperature() // For chamber temperature measurement. float Temperature::analog_to_celsius_chamber(const int raw) { - #if HEATER_CHAMBER_USER_THERMISTOR + #if TEMP_SENSOR_CHAMBER_IS_CUSTOM return user_thermistor_to_deg_c(CTI_CHAMBER, raw); - #elif HEATER_CHAMBER_USES_THERMISTOR - SCAN_THERMISTOR_TABLE(CHAMBER_TEMPTABLE, CHAMBER_TEMPTABLE_LEN); - #elif HEATER_CHAMBER_USES_AD595 + #elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR + SCAN_THERMISTOR_TABLE(TEMPTABLE_CHAMBER, TEMPTABLE_CHAMBER_LEN); + #elif TEMP_SENSOR_CHAMBER_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_CHAMBER_USES_AD8495 + #elif TEMP_SENSOR_CHAMBER_IS_AD8495 return TEMP_AD8495(raw); #else UNUSED(raw); @@ -1708,13 +1706,13 @@ void Temperature::manage_heater() { // Derived from RepRap FiveD extruder::getTemperature() // For probe temperature measurement. float Temperature::analog_to_celsius_probe(const int raw) { - #if HEATER_PROBE_USER_THERMISTOR + #if TEMP_SENSOR_PROBE_IS_CUSTOM return user_thermistor_to_deg_c(CTI_PROBE, raw); - #elif HEATER_PROBE_USES_THERMISTOR - SCAN_THERMISTOR_TABLE(PROBE_TEMPTABLE, PROBE_TEMPTABLE_LEN); - #elif HEATER_PROBE_USES_AD595 + #elif TEMP_SENSOR_PROBE_IS_THERMISTOR + SCAN_THERMISTOR_TABLE(TEMPTABLE_PROBE, TEMPTABLE_PROBE_LEN); + #elif TEMP_SENSOR_PROBE_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_PROBE_USES_AD8495 + #elif TEMP_SENSOR_PROBE_IS_AD8495 return TEMP_AD8495(raw); #else UNUSED(raw); @@ -1730,8 +1728,8 @@ void Temperature::manage_heater() { * as it would block the stepper routine. */ void Temperature::updateTemperaturesFromRawValues() { - TERN_(HEATER_0_USES_MAX6675, temp_hotend[0].raw = READ_MAX6675(0)); - TERN_(HEATER_1_USES_MAX6675, temp_hotend[1].raw = READ_MAX6675(1)); + TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].raw = READ_MAX_TC(0)); + TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].raw = READ_MAX_TC(1)); #if HAS_HOTEND HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e); #endif @@ -1748,9 +1746,9 @@ void Temperature::updateTemperaturesFromRawValues() { raw_temps_ready = false; } -#if MAX6675_SEPARATE_SPI +#if THERMO_SEPARATE_SPI template SoftSPI SPIclass::softSPI; - SPIclass max6675_spi; + SPIclass max_tc_spi; #endif // Init fans according to whether they're native PWM or Software PWM @@ -1786,18 +1784,37 @@ void Temperature::updateTemperaturesFromRawValues() { * The manager is implemented by periodic calls to manage_heater() */ void Temperature::init() { + // Init (and disable) SPI thermocouples + #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) + OUT_WRITE(MAX6675_CS_PIN, HIGH); + #endif + #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) + OUT_WRITE(MAX6675_CS2_PIN, HIGH); + #endif + #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX31855_CS) + OUT_WRITE(MAX31855_CS_PIN, HIGH); + #endif + #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX31855_CS2) + OUT_WRITE(MAX31855_CS2_PIN, HIGH); + #endif + #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX31865_CS) + OUT_WRITE(MAX31865_CS_PIN, HIGH); + #endif + #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX31865_CS2) + OUT_WRITE(MAX31865_CS2_PIN, HIGH); + #endif #if HAS_MAX31865_TEMP - TERN_(MAX6675_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE - TERN_(MAX6675_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE)); + TERN_(TEMP_SENSOR_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE + TERN_(TEMP_SENSOR_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE)); #endif #if HAS_MAX31855_TEMP - TERN_(MAX6675_0_IS_MAX31855, max31855_0.begin()); - TERN_(MAX6675_1_IS_MAX31855, max31855_1.begin()); + TERN_(TEMP_SENSOR_0_IS_MAX31855, max31855_0.begin()); + TERN_(TEMP_SENSOR_1_IS_MAX31855, max31855_1.begin()); #endif #if HAS_MAX6675_TEMP - TERN_(MAX6675_0_IS_MAX6675, max6675_0.begin()); - TERN_(MAX6675_1_IS_MAX6675, max6675_1.begin()); + TERN_(TEMP_SENSOR_0_IS_MAX6675, max6675_0.begin()); + TERN_(TEMP_SENSOR_1_IS_MAX6675, max6675_1.begin()); #endif #if EARLY_WATCHDOG @@ -1808,7 +1825,7 @@ void Temperature::init() { #if MB(RUMBA) // Disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector - #define _AD(N) (HEATER_##N##_USES_AD595 || HEATER_##N##_USES_AD8495) + #define _AD(N) (TEMP_SENSOR_##N##_IS_AD595 || TEMP_SENSOR_##N##_IS_AD8495) #if _AD(0) || _AD(1) || _AD(2) || _AD(BED) || _AD(CHAMBER) MCUCR = _BV(JTD); MCUCR = _BV(JTD); @@ -1817,10 +1834,10 @@ void Temperature::init() { // Thermistor activation by MCU pin #if PIN_EXISTS(TEMP_0_TR_ENABLE) - OUT_WRITE(TEMP_0_TR_ENABLE_PIN, ENABLED(HEATER_0_USES_MAX6675)); + OUT_WRITE(TEMP_0_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_0_IS_MAX_TC)); #endif #if PIN_EXISTS(TEMP_1_TR_ENABLE) - OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(HEATER_1_USES_MAX6675)); + OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_1_IS_MAX_TC)); #endif #if BOTH(PIDTEMP, PID_EXTRUSION_SCALING) @@ -1897,7 +1914,7 @@ void Temperature::init() { INIT_FAN_PIN(CONTROLLER_FAN_PIN); #endif - TERN_(MAX6675_SEPARATE_SPI, max6675_spi.init()); + TERN_(THERMO_SEPARATE_SPI, max_tc_spi.init()); HAL_adc_init(); @@ -1996,19 +2013,19 @@ void Temperature::init() { #if HAS_HOTEND #define _TEMP_MIN_E(NR) do{ \ - const int16_t tmin = _MAX(HEATER_ ##NR## _MINTEMP, TERN(HEATER_##NR##_USER_THERMISTOR, 0, (int16_t)pgm_read_word(&HEATER_ ##NR## _TEMPTABLE[HEATER_ ##NR## _SENSOR_MINTEMP_IND].celsius))); \ + const int16_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \ temp_range[NR].mintemp = tmin; \ while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \ temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \ }while(0) #define _TEMP_MAX_E(NR) do{ \ - const int16_t tmax = _MIN(HEATER_ ##NR## _MAXTEMP, TERN(HEATER_##NR##_USER_THERMISTOR, 2000, (int16_t)pgm_read_word(&HEATER_ ##NR## _TEMPTABLE[HEATER_ ##NR## _SENSOR_MAXTEMP_IND].celsius) - 1)); \ + const int16_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \ temp_range[NR].maxtemp = tmax; \ while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \ temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \ }while(0) - #define _MINMAX_TEST(N,M) (HOTENDS > N && THERMISTOR_HEATER_##N && THERMISTOR_HEATER_##N != 998 && THERMISTOR_HEATER_##N != 999 && defined(HEATER_##N##_##M##TEMP)) + #define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_ ##N## THERMISTOR_ID && TEMP_SENSOR_ ##N## THERMISTOR_ID != 998 && TEMP_SENSOR_ ##N## THERMISTOR_ID != 999 && defined(HEATER_##N##_##M##TEMP)) #if _MINMAX_TEST(0, MIN) _TEMP_MIN_E(0); @@ -2303,76 +2320,71 @@ void Temperature::disable_all_heaters() { #endif -#if HAS_MAX6675 +#if HAS_MAX_TC #ifndef THERMOCOUPLE_MAX_ERRORS #define THERMOCOUPLE_MAX_ERRORS 15 #endif - int Temperature::read_max6675(TERN_(HAS_MULTI_6675, const uint8_t hindex/*=0*/)) { + int Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { #define MAX6675_HEAT_INTERVAL 250UL - #if MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855 - static uint32_t max6675_temp = 2000; - #define MAX6675_ERROR_MASK 7 - #define MAX6675_DISCARD_BITS 18 - #define MAX6675_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64 + #if HAS_MAX31855_TEMP + static uint32_t max_tc_temp = 2000; + #define MAX_TC_ERROR_MASK 7 + #define MAX_TC_DISCARD_BITS 18 + #define MAX_TC_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64 #elif HAS_MAX31865_TEMP - static uint16_t max6675_temp = 2000; // From datasheet 16 bits D15-D0 - #define MAX6675_ERROR_MASK 1 // D0 Bit not used - #define MAX6675_DISCARD_BITS 1 // Data is in D15-D1 - #define MAX6675_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64 + static uint16_t max_tc_temp = 2000; // From datasheet 16 bits D15-D0 + #define MAX_TC_ERROR_MASK 1 // D0 Bit not used + #define MAX_TC_DISCARD_BITS 1 // Data is in D15-D1 + #define MAX_TC_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64 #else - static uint16_t max6675_temp = 2000; - #define MAX6675_ERROR_MASK 4 - #define MAX6675_DISCARD_BITS 3 - #define MAX6675_SPEED_BITS 2 // (_BV(SPR0)) // clock ÷ 16 + static uint16_t max_tc_temp = 2000; + #define MAX_TC_ERROR_MASK 4 + #define MAX_TC_DISCARD_BITS 3 + #define MAX_TC_SPEED_BITS 2 // (_BV(SPR0)) // clock ÷ 16 #endif - #if HAS_MULTI_6675 + #if HAS_MULTI_MAX_TC // Needed to return the correct temp when this is called between readings - static uint16_t max6675_temp_previous[COUNT_6675] = { 0 }; - #define MAX6675_TEMP(I) max6675_temp_previous[I] - #define MAX6675_SEL(A,B) (hindex ? (B) : (A)) - #if NO_THERMO_TEMPS - #define MAX6675_WRITE(V) do{ switch (hindex) { case 1: WRITE(MAX6675_SS2_PIN, V); break; default: WRITE(MAX6675_SS_PIN, V); } }while(0) - #define MAX6675_SET_OUTPUT() do{ switch (hindex) { case 1: SET_OUTPUT(MAX6675_SS2_PIN); break; default: SET_OUTPUT(MAX6675_SS_PIN); } }while(0) - #endif + static uint16_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; + #define THERMO_TEMP(I) max_tc_temp_previous[I] + #define THERMO_SEL(A,B) (hindex ? (B) : (A)) + #define MAX6675_WRITE(V) do{ switch (hindex) { case 1: WRITE(MAX6675_SS2_PIN, V); break; default: WRITE(MAX6675_SS_PIN, V); } }while(0) + #define MAX6675_SET_OUTPUT() do{ switch (hindex) { case 1: SET_OUTPUT(MAX6675_SS2_PIN); break; default: SET_OUTPUT(MAX6675_SS_PIN); } }while(0) #else constexpr uint8_t hindex = 0; - #define MAX6675_TEMP(I) max6675_temp - #if MAX6675_1_IS_MAX31865 || MAX6675_1_IS_MAX31855 || MAX6675_1_IS_MAX6675 - #define MAX6675_SEL(A,B) B + #define THERMO_TEMP(I) max_tc_temp + #if TEMP_SENSOR_1_IS_MAX31865 + #define THERMO_SEL(A,B) B #else - #define MAX6675_SEL(A,B) A + #define THERMO_SEL(A,B) A #endif - - #if NO_THERMO_TEMPS - #if HEATER_0_USES_MAX6675 - #define MAX6675_WRITE(V) WRITE(MAX6675_SS_PIN, V) - #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS_PIN) - #else - #define MAX6675_WRITE(V) WRITE(MAX6675_SS2_PIN, V) - #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS2_PIN) - #endif + #if TEMP_SENSOR_0_IS_MAX6675 + #define MAX6675_WRITE(V) WRITE(MAX6675_SS_PIN, V) + #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS_PIN) + #else + #define MAX6675_WRITE(V) WRITE(MAX6675_SS2_PIN, V) + #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS2_PIN) #endif #endif - static uint8_t max6675_errors[COUNT_6675] = { 0 }; + static uint8_t max_tc_errors[MAX_TC_COUNT] = { 0 }; // Return last-read value between readings - static millis_t next_max6675_ms[COUNT_6675] = { 0 }; + static millis_t next_max_tc_ms[MAX_TC_COUNT] = { 0 }; millis_t ms = millis(); - if (PENDING(ms, next_max6675_ms[hindex])) return int(MAX6675_TEMP(hindex)); - next_max6675_ms[hindex] = ms + MAX6675_HEAT_INTERVAL; + if (PENDING(ms, next_max_tc_ms[hindex])) return int(THERMO_TEMP(hindex)); + next_max_tc_ms[hindex] = ms + MAX6675_HEAT_INTERVAL; // // TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used. // - #if !MAX6675_SEPARATE_SPI && NO_THERMO_TEMPS + #if !THERMO_SEPARATE_SPI && NO_THERMO_TEMPS spiBegin(); - spiInit(MAX6675_SPEED_BITS); + spiInit(MAX_TC_SPEED_BITS); #endif #if NO_THERMO_TEMPS @@ -2380,32 +2392,32 @@ void Temperature::disable_all_heaters() { DELAY_NS(100); // Ensure 100ns delay #endif - max6675_temp = 0; + max_tc_temp = 0; // Read a big-endian temperature value #if NO_THERMO_TEMPS - for (uint8_t i = sizeof(max6675_temp); i--;) { - max6675_temp |= TERN(MAX6675_SEPARATE_SPI, max6675_spi.receive(), spiRec()); - if (i > 0) max6675_temp <<= 8; // shift left if not the last byte + for (uint8_t i = sizeof(max_tc_temp); i--;) { + max_tc_temp |= TERN(THERMO_SEPARATE_SPI, max6675_spi.receive(), spiRec()); + if (i > 0) max_tc_temp <<= 8; // shift left if not the last byte } MAX6675_WRITE(HIGH); // disable TT_MAX6675 #endif #if HAS_MAX31855_TEMP - Adafruit_MAX31855 &max855ref = MAX6675_SEL(max31855_0, max31855_1); - max6675_temp = max855ref.readRaw32(); + Adafruit_MAX31855 &max855ref = THERMO_SEL(max31855_0, max31855_1); + max_tc_temp = max855ref.readRaw32(); #endif #if HAS_MAX31865_TEMP - Adafruit_MAX31865 &max865ref = MAX6675_SEL(max31865_0, max31865_1); + Adafruit_MAX31865 &max865ref = THERMO_SEL(max31865_0, max31865_1); #if ENABLED(LIB_USR_MAX31865) - max6675_temp = max865ref.readRTD_with_Fault(); + max_tc_temp = max865ref.readRTD_with_Fault(); #endif #endif #if HAS_MAX6675_TEMP - MAX6675 &max6675ref = MAX6675_SEL(max6675_0, max6675_1); - max6675_temp = max6675ref.readRaw16(); + MAX6675 &max6675ref = THERMO_SEL(max6675_0, max6675_1); + max_tc_temp = max6675ref.readRaw16(); #endif #if ENABLED(LIB_ADAFRUIT_MAX31865) @@ -2415,21 +2427,21 @@ void Temperature::disable_all_heaters() { #if ENABLED(LIB_ADAFRUIT_MAX31865) if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && fault_31865) { #else - if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK)) { + if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max_tc_temp & MAX_TC_ERROR_MASK)) { #endif - max6675_errors[hindex]++; - if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { + max_tc_errors[hindex]++; + if (max_tc_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { SERIAL_ERROR_START(); SERIAL_ECHOPGM("Temp measurement error! "); - #if MAX6675_ERROR_MASK == 7 + #if MAX_TC_ERROR_MASK == 7 SERIAL_ECHOPGM("MAX31855 "); - if (max6675_temp & 1) - SERIAL_ECHOLNPAIR("Fault :(", max6675_temp & 1 ,") >> Open Circuit"); - else if (max6675_temp & 2) - SERIAL_ECHOLNPAIR("Fault : (", max6675_temp & 2 ,") >> Short to GND"); - else if (max6675_temp & 4) - SERIAL_ECHOLNPAIR("Fault : (", max6675_temp & 4 ,") >> Short to VCC"); - #elif MAX6675_HAS_MAX31865 + if (max_tc_temp & 1) + SERIAL_ECHOLNPAIR("Fault :(", max_tc_temp & 1 ,") >> Open Circuit"); + else if (max_tc_temp & 2) + SERIAL_ECHOLNPAIR("Fault : (", max_tc_temp & 2 ,") >> Short to GND"); + else if (max_tc_temp & 4) + SERIAL_ECHOLNPAIR("Fault : (", max_tc_temp & 4 ,") >> Short to VCC"); + #elif HAS_MAX31865 #if ENABLED(LIB_USR_MAX31865) // At the present time we do not have the ability to set the MAX31865 HIGH threshold // or thr LOW threshold, so no need to check for them, zero these bits out @@ -2458,49 +2470,49 @@ void Temperature::disable_all_heaters() { #endif // Thermocouple open - max6675_temp = 4 * MAX6675_SEL(HEATER_0_MAX6675_TMAX, HEATER_1_MAX6675_TMAX); + max_tc_temp = 4 * THERMO_SEL(TEMP_SENSOR_0_MAX_TC_TMAX, TEMP_SENSOR_1_MAX_TC_TMAX); } else - max6675_temp >>= MAX6675_DISCARD_BITS; + max_tc_temp >>= MAX_TC_DISCARD_BITS; } else { - max6675_temp >>= MAX6675_DISCARD_BITS; - max6675_errors[hindex] = 0; + max_tc_temp >>= MAX_TC_DISCARD_BITS; + max_tc_errors[hindex] = 0; } - #if MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855 - if (max6675_temp & 0x00002000) max6675_temp |= 0xFFFFC000; // Support negative temperature + #if HAS_MAX31855 + if (max_tc_temp & 0x00002000) max_tc_temp |= 0xFFFFC000; // Support negative temperature #endif // Return the RTD resistance for MAX31865 for display in SHOW_TEMP_ADC_VALUES #if HAS_MAX31865_TEMP #if ENABLED(LIB_ADAFRUIT_MAX31865) - max6675_temp = (uint32_t(max865ref.readRTD()) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; + max_tc_temp = (uint32_t(max865ref.readRTD()) * THERMO_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; #elif ENABLED(LIB_USR_MAX31865) - max6675_temp = (uint32_t(max6675_temp) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; + max_tc_temp = (uint32_t(max_tc_temp) * THERMO_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; #endif #endif - MAX6675_TEMP(hindex) = max6675_temp; + THERMO_TEMP(hindex) = max_tc_temp; - return int(max6675_temp); + return int(max_tc_temp); } -#endif // HAS_MAX6675 +#endif // HAS_MAX_TC /** * Update raw temperatures */ void Temperature::update_raw_temperatures() { - #if HAS_TEMP_ADC_0 && !HEATER_0_USES_MAX6675 + #if HAS_TEMP_ADC_0 && !TEMP_SENSOR_0_IS_MAX_TC temp_hotend[0].update(); #endif #if HAS_TEMP_ADC_1 #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) redundant_temperature_raw = temp_hotend[1].acc; - #elif !HEATER_1_USES_MAX6675 + #elif !TEMP_SENSOR_1_IS_MAX_TC temp_hotend[1].update(); #endif #endif @@ -2546,9 +2558,9 @@ void Temperature::readings_ready() { #if HAS_HOTEND static constexpr int8_t temp_dir[] = { - TERN(HEATER_0_USES_MAX6675, 0, TEMPDIR(0)) + TERN(TEMP_SENSOR_0_IS_MAX_TC, 0, TEMPDIR(0)) #if HAS_MULTI_HOTEND - , TERN(HEATER_1_USES_MAX6675, 0, TEMPDIR(1)) + , TERN(TEMP_SENSOR_1_IS_MAX_TC, 0, TEMPDIR(1)) #if HOTENDS > 2 #define _TEMPDIR(N) , TEMPDIR(N) REPEAT_S(2, HOTENDS, _TEMPDIR) diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 002e1cbf71f5..75da232874a6 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -257,31 +257,31 @@ typedef struct { int16_t raw_min, raw_max, mintemp, maxtemp; } temp_range_t; #if HAS_USER_THERMISTORS enum CustomThermistorIndex : uint8_t { - #if HEATER_0_USER_THERMISTOR + #if TEMP_SENSOR_0_IS_CUSTOM CTI_HOTEND_0, #endif - #if HEATER_1_USER_THERMISTOR + #if TEMP_SENSOR_1_IS_CUSTOM CTI_HOTEND_1, #endif - #if HEATER_2_USER_THERMISTOR + #if TEMP_SENSOR_2_IS_CUSTOM CTI_HOTEND_2, #endif - #if HEATER_3_USER_THERMISTOR + #if TEMP_SENSOR_3_IS_CUSTOM CTI_HOTEND_3, #endif - #if HEATER_4_USER_THERMISTOR + #if TEMP_SENSOR_4_IS_CUSTOM CTI_HOTEND_4, #endif - #if HEATER_5_USER_THERMISTOR + #if TEMP_SENSOR_5_IS_CUSTOM CTI_HOTEND_5, #endif - #if HEATER_BED_USER_THERMISTOR + #if TEMP_SENSOR_BED_IS_CUSTOM CTI_BED, #endif - #if HEATER_PROBE_USER_THERMISTOR + #if TEMP_SENSOR_PROBE_IS_CUSTOM CTI_PROBE, #endif - #if HEATER_CHAMBER_USER_THERMISTOR + #if TEMP_SENSOR_CHAMBER_IS_CUSTOM CTI_CHAMBER, #endif USER_THERMISTORS @@ -813,16 +813,15 @@ class Temperature { static void update_raw_temperatures(); static void updateTemperaturesFromRawValues(); - #define HAS_MAX6675 EITHER(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675) - #if HAS_MAX6675 - #define COUNT_6675 1 + BOTH(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675) - #if COUNT_6675 > 1 - #define HAS_MULTI_6675 1 - #define READ_MAX6675(N) read_max6675(N) + #if HAS_MAX_TC + #define MAX_TC_COUNT 1 + BOTH(TEMP_SENSOR_0_IS_MAX_TC, TEMP_SENSOR_1_IS_MAX_TC) + #if MAX_TC_COUNT > 1 + #define HAS_MULTI_MAX_TC 1 + #define READ_MAX_TC(N) read_max_tc(N) #else - #define READ_MAX6675(N) read_max6675() + #define READ_MAX_TC(N) read_max_tc() #endif - static int read_max6675(TERN_(HAS_MULTI_6675, const uint8_t hindex=0)); + static int read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex=0)); #endif static void checkExtruderAutoFans(); diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 03ed5c2a57df..77fc50c8d3f4 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -42,7 +42,7 @@ #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) +#define ANY_THERMISTOR_IS(n) (TEMP_SENSOR_0_THERMISTOR_ID == n || TEMP_SENSOR_1_THERMISTOR_ID == n || TEMP_SENSOR_2_THERMISTOR_ID == n || TEMP_SENSOR_3_THERMISTOR_ID == n || TEMP_SENSOR_4_THERMISTOR_ID == n || TEMP_SENSOR_5_THERMISTOR_ID == n || TEMP_SENSOR_6_THERMISTOR_ID == n || TEMP_SENSOR_7_THERMISTOR_ID == n || TEMP_SENSOR_BED_THERMISTOR_ID == n || TEMP_SENSOR_CHAMBER_THERMISTOR_ID == n || TEMP_SENSOR_PROBE_THERMISTOR_ID == n) typedef struct { int16_t value, celsius; } temp_entry_t; @@ -205,121 +205,121 @@ typedef struct { int16_t value, celsius; } temp_entry_t; #define TT_NAME(_N) _TT_NAME(_N) -#if THERMISTOR_HEATER_0 - #define HEATER_0_TEMPTABLE TT_NAME(THERMISTOR_HEATER_0) - #define HEATER_0_TEMPTABLE_LEN COUNT(HEATER_0_TEMPTABLE) -#elif HEATER_0_USES_THERMISTOR +#if TEMP_SENSOR_0_THERMISTOR_ID + #define TEMPTABLE_0 TT_NAME(TEMP_SENSOR_0_THERMISTOR_ID) + #define TEMPTABLE_0_LEN COUNT(TEMPTABLE_0) +#elif TEMP_SENSOR_0_IS_THERMISTOR #error "No heater 0 thermistor table specified" #else - #define HEATER_0_TEMPTABLE nullptr - #define HEATER_0_TEMPTABLE_LEN 0 + #define TEMPTABLE_0 nullptr + #define TEMPTABLE_0_LEN 0 #endif -#if THERMISTOR_HEATER_1 - #define HEATER_1_TEMPTABLE TT_NAME(THERMISTOR_HEATER_1) - #define HEATER_1_TEMPTABLE_LEN COUNT(HEATER_1_TEMPTABLE) -#elif HEATER_1_USES_THERMISTOR +#if TEMP_SENSOR_1_THERMISTOR_ID + #define TEMPTABLE_1 TT_NAME(TEMP_SENSOR_1_THERMISTOR_ID) + #define TEMPTABLE_1_LEN COUNT(TEMPTABLE_1) +#elif TEMP_SENSOR_1_IS_THERMISTOR #error "No heater 1 thermistor table specified" #else - #define HEATER_1_TEMPTABLE nullptr - #define HEATER_1_TEMPTABLE_LEN 0 + #define TEMPTABLE_1 nullptr + #define TEMPTABLE_1_LEN 0 #endif -#if THERMISTOR_HEATER_2 - #define HEATER_2_TEMPTABLE TT_NAME(THERMISTOR_HEATER_2) - #define HEATER_2_TEMPTABLE_LEN COUNT(HEATER_2_TEMPTABLE) -#elif HEATER_2_USES_THERMISTOR +#if TEMP_SENSOR_2_THERMISTOR_ID + #define TEMPTABLE_2 TT_NAME(TEMP_SENSOR_2_THERMISTOR_ID) + #define TEMPTABLE_2_LEN COUNT(TEMPTABLE_2) +#elif TEMP_SENSOR_2_IS_THERMISTOR #error "No heater 2 thermistor table specified" #else - #define HEATER_2_TEMPTABLE nullptr - #define HEATER_2_TEMPTABLE_LEN 0 + #define TEMPTABLE_2 nullptr + #define TEMPTABLE_2_LEN 0 #endif -#if THERMISTOR_HEATER_3 - #define HEATER_3_TEMPTABLE TT_NAME(THERMISTOR_HEATER_3) - #define HEATER_3_TEMPTABLE_LEN COUNT(HEATER_3_TEMPTABLE) -#elif HEATER_3_USES_THERMISTOR +#if TEMP_SENSOR_3_THERMISTOR_ID + #define TEMPTABLE_3 TT_NAME(TEMP_SENSOR_3_THERMISTOR_ID) + #define TEMPTABLE_3_LEN COUNT(TEMPTABLE_3) +#elif TEMP_SENSOR_3_IS_THERMISTOR #error "No heater 3 thermistor table specified" #else - #define HEATER_3_TEMPTABLE nullptr - #define HEATER_3_TEMPTABLE_LEN 0 + #define TEMPTABLE_3 nullptr + #define TEMPTABLE_3_LEN 0 #endif -#if THERMISTOR_HEATER_4 - #define HEATER_4_TEMPTABLE TT_NAME(THERMISTOR_HEATER_4) - #define HEATER_4_TEMPTABLE_LEN COUNT(HEATER_4_TEMPTABLE) -#elif HEATER_4_USES_THERMISTOR +#if TEMP_SENSOR_4_THERMISTOR_ID + #define TEMPTABLE_4 TT_NAME(TEMP_SENSOR_4_THERMISTOR_ID) + #define TEMPTABLE_4_LEN COUNT(TEMPTABLE_4) +#elif TEMP_SENSOR_4_IS_THERMISTOR #error "No heater 4 thermistor table specified" #else - #define HEATER_4_TEMPTABLE nullptr - #define HEATER_4_TEMPTABLE_LEN 0 + #define TEMPTABLE_4 nullptr + #define TEMPTABLE_4_LEN 0 #endif -#if THERMISTOR_HEATER_5 - #define HEATER_5_TEMPTABLE TT_NAME(THERMISTOR_HEATER_5) - #define HEATER_5_TEMPTABLE_LEN COUNT(HEATER_5_TEMPTABLE) -#elif HEATER_5_USES_THERMISTOR +#if TEMP_SENSOR_5_THERMISTOR_ID + #define TEMPTABLE_5 TT_NAME(TEMP_SENSOR_5_THERMISTOR_ID) + #define TEMPTABLE_5_LEN COUNT(TEMPTABLE_5) +#elif TEMP_SENSOR_5_IS_THERMISTOR #error "No heater 5 thermistor table specified" #else - #define HEATER_5_TEMPTABLE nullptr - #define HEATER_5_TEMPTABLE_LEN 0 + #define TEMPTABLE_5 nullptr + #define TEMPTABLE_5_LEN 0 #endif -#if THERMISTOR_HEATER_6 - #define HEATER_6_TEMPTABLE TT_NAME(THERMISTOR_HEATER_6) - #define HEATER_6_TEMPTABLE_LEN COUNT(HEATER_6_TEMPTABLE) -#elif HEATER_6_USES_THERMISTOR +#if TEMP_SENSOR_6_THERMISTOR_ID + #define TEMPTABLE_6 TT_NAME(TEMP_SENSOR_6_THERMISTOR_ID) + #define TEMPTABLE_6_LEN COUNT(TEMPTABLE_6) +#elif TEMP_SENSOR_6_IS_THERMISTOR #error "No heater 6 thermistor table specified" #else - #define HEATER_6_TEMPTABLE nullptr - #define HEATER_6_TEMPTABLE_LEN 0 + #define TEMPTABLE_6 nullptr + #define TEMPTABLE_6_LEN 0 #endif -#if THERMISTOR_HEATER_7 - #define HEATER_7_TEMPTABLE TT_NAME(THERMISTOR_HEATER_7) - #define HEATER_7_TEMPTABLE_LEN COUNT(HEATER_7_TEMPTABLE) -#elif HEATER_7_USES_THERMISTOR +#if TEMP_SENSOR_7_THERMISTOR_ID + #define TEMPTABLE_7 TT_NAME(TEMP_SENSOR_7_THERMISTOR_ID) + #define TEMPTABLE_7_LEN COUNT(TEMPTABLE_7) +#elif TEMP_SENSOR_7_IS_THERMISTOR #error "No heater 7 thermistor table specified" #else - #define HEATER_7_TEMPTABLE nullptr - #define HEATER_7_TEMPTABLE_LEN 0 + #define TEMPTABLE_7 nullptr + #define TEMPTABLE_7_LEN 0 #endif -#ifdef THERMISTORBED - #define BED_TEMPTABLE TT_NAME(THERMISTORBED) - #define BED_TEMPTABLE_LEN COUNT(BED_TEMPTABLE) -#elif HEATER_BED_USES_THERMISTOR +#ifdef TEMP_SENSOR_BED_THERMISTOR_ID + #define TEMPTABLE_BED TT_NAME(TEMP_SENSOR_BED_THERMISTOR_ID) + #define TEMPTABLE_BED_LEN COUNT(TEMPTABLE_BED) +#elif TEMP_SENSOR_BED_IS_THERMISTOR #error "No bed thermistor table specified" #else - #define BED_TEMPTABLE_LEN 0 + #define TEMPTABLE_BED_LEN 0 #endif -#ifdef THERMISTORCHAMBER - #define CHAMBER_TEMPTABLE TT_NAME(THERMISTORCHAMBER) - #define CHAMBER_TEMPTABLE_LEN COUNT(CHAMBER_TEMPTABLE) -#elif HEATER_CHAMBER_USES_THERMISTOR +#ifdef TEMP_SENSOR_CHAMBER_THERMISTOR_ID + #define TEMPTABLE_CHAMBER TT_NAME(TEMP_SENSOR_CHAMBER_THERMISTOR_ID) + #define TEMPTABLE_CHAMBER_LEN COUNT(TEMPTABLE_CHAMBER) +#elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR #error "No chamber thermistor table specified" #else - #define CHAMBER_TEMPTABLE_LEN 0 + #define TEMPTABLE_CHAMBER_LEN 0 #endif -#ifdef THERMISTORPROBE - #define PROBE_TEMPTABLE TT_NAME(THERMISTORPROBE) - #define PROBE_TEMPTABLE_LEN COUNT(PROBE_TEMPTABLE) -#elif HEATER_PROBE_USES_THERMISTOR +#ifdef TEMP_SENSOR_PROBE_THERMISTOR_ID + #define TEMPTABLE_PROBE TT_NAME(TEMP_SENSOR_PROBE_THERMISTOR_ID) + #define TEMPTABLE_PROBE_LEN COUNT(TEMPTABLE_PROBE) +#elif TEMP_SENSOR_PROBE_IS_THERMISTOR #error "No probe thermistor table specified" #else - #define PROBE_TEMPTABLE_LEN 0 + #define TEMPTABLE_PROBE_LEN 0 #endif // The SCAN_THERMISTOR_TABLE macro needs alteration? static_assert( - HEATER_0_TEMPTABLE_LEN < 256 && HEATER_1_TEMPTABLE_LEN < 256 - && HEATER_2_TEMPTABLE_LEN < 256 && HEATER_3_TEMPTABLE_LEN < 256 - && HEATER_4_TEMPTABLE_LEN < 256 && HEATER_5_TEMPTABLE_LEN < 256 - && HEATER_6_TEMPTABLE_LEN < 256 && HEATER_7_TEMPTABLE_LEN < 256 - && BED_TEMPTABLE_LEN < 256 && CHAMBER_TEMPTABLE_LEN < 256 - && PROBE_TEMPTABLE_LEN < 256, + TEMPTABLE_0_LEN < 256 && TEMPTABLE_1_LEN < 256 + && TEMPTABLE_2_LEN < 256 && TEMPTABLE_3_LEN < 256 + && TEMPTABLE_4_LEN < 256 && TEMPTABLE_5_LEN < 256 + && TEMPTABLE_6_LEN < 256 && TEMPTABLE_7_LEN < 256 + && TEMPTABLE_BED_LEN < 256 && TEMPTABLE_CHAMBER_LEN < 256 + && TEMPTABLE_PROBE_LEN < 256, "Temperature conversion tables over 255 entries need special consideration." ); @@ -327,181 +327,185 @@ static_assert( // For thermistors the highest temperature results in the lowest ADC value // For thermocouples the highest temperature results in the highest ADC value -#define _TT_REV(N) REVERSE_TEMP_SENSOR_RANGE_##N -#define TT_REV(N) _TT_REV(N) +#define _TT_REV(N) REVERSE_TEMP_SENSOR_RANGE_##N +#define TT_REV(N) _TT_REV(TEMP_SENSOR_##N##_THERMISTOR_ID) +#define _TT_REVRAW(N) !TEMP_SENSOR_##N##_IS_THERMISTOR +#define TT_REVRAW(N) (TT_REV(N) || _TT_REVRAW(N)) -#ifdef HEATER_0_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_0) - #define HEATER_0_SENSOR_MINTEMP_IND 0 - #define HEATER_0_SENSOR_MAXTEMP_IND HEATER_0_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_0 + #if TT_REV(0) + #define TEMP_SENSOR_0_MINTEMP_IND 0 + #define TEMPTABLE_0_MAXTEMP_IND HEATER_0_LEN - 1 #else - #define HEATER_0_SENSOR_MINTEMP_IND HEATER_0_TEMPTABLE_LEN - 1 - #define HEATER_0_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_0_MINTEMP_IND HEATER_0_LEN - 1 + #define TEMP_SENSOR_0_MAXTEMP_IND 0 #endif #endif -#ifdef HEATER_1_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_1) - #define HEATER_1_SENSOR_MINTEMP_IND 0 - #define HEATER_1_SENSOR_MAXTEMP_IND HEATER_1_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_1 + #if TT_REV(1) + #define TEMP_SENSOR_1_MINTEMP_IND 0 + #define TEMPTABLE_1_MAXTEMP_IND HEATER_1_LEN - 1 #else - #define HEATER_1_SENSOR_MINTEMP_IND HEATER_1_TEMPTABLE_LEN - 1 - #define HEATER_1_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_1_MINTEMP_IND HEATER_1_LEN - 1 + #define TEMP_SENSOR_1_MAXTEMP_IND 0 #endif #endif -#ifdef HEATER_2_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_2) - #define HEATER_2_SENSOR_MINTEMP_IND 0 - #define HEATER_2_SENSOR_MAXTEMP_IND HEATER_2_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_2 + #if TT_REV(2) + #define TEMP_SENSOR_2_MINTEMP_IND 0 + #define TEMPTABLE_2_MAXTEMP_IND HEATER_2_LEN - 1 #else - #define HEATER_2_SENSOR_MINTEMP_IND HEATER_2_TEMPTABLE_LEN - 1 - #define HEATER_2_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_2_MINTEMP_IND HEATER_2_LEN - 1 + #define TEMP_SENSOR_2_MAXTEMP_IND 0 #endif #endif -#ifdef HEATER_3_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_3) - #define HEATER_3_SENSOR_MINTEMP_IND 0 - #define HEATER_3_SENSOR_MAXTEMP_IND HEATER_3_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_3 + #if TT_REV(3) + #define TEMP_SENSOR_3_MINTEMP_IND 0 + #define TEMPTABLE_3_MAXTEMP_IND HEATER_3_LEN - 1 #else - #define HEATER_3_SENSOR_MINTEMP_IND HEATER_3_TEMPTABLE_LEN - 1 - #define HEATER_3_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_3_MINTEMP_IND HEATER_3_LEN - 1 + #define TEMP_SENSOR_3_MAXTEMP_IND 0 #endif #endif -#ifdef HEATER_4_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_4) - #define HEATER_4_SENSOR_MINTEMP_IND 0 - #define HEATER_4_SENSOR_MAXTEMP_IND HEATER_4_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_4 + #if TT_REV(4) + #define TEMP_SENSOR_4_MINTEMP_IND 0 + #define TEMPTABLE_4_MAXTEMP_IND HEATER_4_LEN - 1 #else - #define HEATER_4_SENSOR_MINTEMP_IND HEATER_4_TEMPTABLE_LEN - 1 - #define HEATER_4_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_4_MINTEMP_IND HEATER_4_LEN - 1 + #define TEMP_SENSOR_4_MAXTEMP_IND 0 #endif #endif -#ifdef HEATER_5_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_5) - #define HEATER_5_SENSOR_MINTEMP_IND 0 - #define HEATER_5_SENSOR_MAXTEMP_IND HEATER_5_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_5 + #if TT_REV(5) + #define TEMP_SENSOR_5_MINTEMP_IND 0 + #define TEMPTABLE_5_MAXTEMP_IND HEATER_5_LEN - 1 #else - #define HEATER_5_SENSOR_MINTEMP_IND HEATER_5_TEMPTABLE_LEN - 1 - #define HEATER_5_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_5_MINTEMP_IND HEATER_5_LEN - 1 + #define TEMP_SENSOR_5_MAXTEMP_IND 0 #endif #endif -#ifdef HEATER_6_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_6) - #define HEATER_6_SENSOR_MINTEMP_IND 0 - #define HEATER_6_SENSOR_MAXTEMP_IND HEATER_6_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_6 + #if TT_REV(6) + #define TEMP_SENSOR_6_MINTEMP_IND 0 + #define TEMPTABLE_6_MAXTEMP_IND HEATER_6_LEN - 1 #else - #define HEATER_6_SENSOR_MINTEMP_IND HEATER_6_TEMPTABLE_LEN - 1 - #define HEATER_6_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_6_MINTEMP_IND HEATER_6_LEN - 1 + #define TEMP_SENSOR_6_MAXTEMP_IND 0 #endif #endif -#ifdef HEATER_7_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_7) - #define HEATER_7_SENSOR_MINTEMP_IND 0 - #define HEATER_7_SENSOR_MAXTEMP_IND HEATER_7_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_7 + #if TT_REV(7) + #define TEMP_SENSOR_7_MINTEMP_IND 0 + #define TEMPTABLE_7_MAXTEMP_IND HEATER_7_LEN - 1 #else - #define HEATER_7_SENSOR_MINTEMP_IND HEATER_7_TEMPTABLE_LEN - 1 - #define HEATER_7_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_7_MINTEMP_IND HEATER_7_LEN - 1 + #define TEMP_SENSOR_7_MAXTEMP_IND 0 #endif #endif -#ifndef HEATER_0_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_0) || !HEATER_0_USES_THERMISTOR - #define HEATER_0_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_0_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_0_RAW_HI_TEMP + #if TT_REVRAW(0) + #define TEMP_SENSOR_0_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_0_RAW_LO_TEMP 0 #else - #define HEATER_0_RAW_HI_TEMP 0 - #define HEATER_0_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_0_RAW_HI_TEMP 0 + #define TEMP_SENSOR_0_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_1_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_1) || !HEATER_1_USES_THERMISTOR - #define HEATER_1_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_1_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_1_RAW_HI_TEMP + #if TT_REVRAW(1) + #define TEMP_SENSOR_1_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_1_RAW_LO_TEMP 0 #else - #define HEATER_1_RAW_HI_TEMP 0 - #define HEATER_1_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_1_RAW_HI_TEMP 0 + #define TEMP_SENSOR_1_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_2_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_2) || !HEATER_2_USES_THERMISTOR - #define HEATER_2_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_2_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_2_RAW_HI_TEMP + #if TT_REVRAW(2) + #define TEMP_SENSOR_2_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_2_RAW_LO_TEMP 0 #else - #define HEATER_2_RAW_HI_TEMP 0 - #define HEATER_2_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_2_RAW_HI_TEMP 0 + #define TEMP_SENSOR_2_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_3_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_3) || !HEATER_3_USES_THERMISTOR - #define HEATER_3_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_3_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_3_RAW_HI_TEMP + #if TT_REVRAW(3) + #define TEMP_SENSOR_3_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_3_RAW_LO_TEMP 0 #else - #define HEATER_3_RAW_HI_TEMP 0 - #define HEATER_3_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_3_RAW_HI_TEMP 0 + #define TEMP_SENSOR_3_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_4_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_4) || !HEATER_4_USES_THERMISTOR - #define HEATER_4_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_4_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_4_RAW_HI_TEMP + #if TT_REVRAW(4) + #define TEMP_SENSOR_4_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_4_RAW_LO_TEMP 0 #else - #define HEATER_4_RAW_HI_TEMP 0 - #define HEATER_4_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_4_RAW_HI_TEMP 0 + #define TEMP_SENSOR_4_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_5_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_5) || !HEATER_5_USES_THERMISTOR - #define HEATER_5_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_5_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_5_RAW_HI_TEMP + #if TT_REVRAW(5) + #define TEMP_SENSOR_5_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_5_RAW_LO_TEMP 0 #else - #define HEATER_5_RAW_HI_TEMP 0 - #define HEATER_5_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_5_RAW_HI_TEMP 0 + #define TEMP_SENSOR_5_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_6_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_6) || !HEATER_6_USES_THERMISTOR - #define HEATER_6_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_6_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_6_RAW_HI_TEMP + #if TT_REVRAW(6) + #define TEMP_SENSOR_6_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_6_RAW_LO_TEMP 0 #else - #define HEATER_6_RAW_HI_TEMP 0 - #define HEATER_6_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_6_RAW_HI_TEMP 0 + #define TEMP_SENSOR_6_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_7_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_7) || !HEATER_7_USES_THERMISTOR - #define HEATER_7_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_7_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_7_RAW_HI_TEMP + #if TT_REVRAW(7) + #define TEMP_SENSOR_7_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_7_RAW_LO_TEMP 0 #else - #define HEATER_7_RAW_HI_TEMP 0 - #define HEATER_7_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_7_RAW_HI_TEMP 0 + #define TEMP_SENSOR_7_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_BED_RAW_HI_TEMP - #if TT_REV(THERMISTORBED) || !HEATER_BED_USES_THERMISTOR - #define HEATER_BED_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_BED_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_BED_RAW_HI_TEMP + #if TT_REVRAW(BED) + #define TEMP_SENSOR_BED_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_BED_RAW_LO_TEMP 0 #else - #define HEATER_BED_RAW_HI_TEMP 0 - #define HEATER_BED_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_BED_RAW_HI_TEMP 0 + #define TEMP_SENSOR_BED_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_CHAMBER_RAW_HI_TEMP - #if TT_REV(THERMISTORCHAMBER) || !HEATER_CHAMBER_USES_THERMISTOR - #define HEATER_CHAMBER_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_CHAMBER_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_CHAMBER_RAW_HI_TEMP + #if TT_REVRAW(CHAMBER) + #define TEMP_SENSOR_CHAMBER_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_CHAMBER_RAW_LO_TEMP 0 #else - #define HEATER_CHAMBER_RAW_HI_TEMP 0 - #define HEATER_CHAMBER_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_CHAMBER_RAW_HI_TEMP 0 + #define TEMP_SENSOR_CHAMBER_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_PROBE_RAW_HI_TEMP - #if TT_REV(THERMISTORPROBE) || !HEATER_PROBE_USES_THERMISTOR - #define HEATER_PROBE_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_PROBE_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_PROBE_RAW_HI_TEMP + #if TT_REVRAW(PROBE) + #define TEMP_SENSOR_PROBE_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_PROBE_RAW_LO_TEMP 0 #else - #define HEATER_PROBE_RAW_HI_TEMP 0 - #define HEATER_PROBE_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_PROBE_RAW_HI_TEMP 0 + #define TEMP_SENSOR_PROBE_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif #undef _TT_REV #undef TT_REV +#undef _TT_REVRAW +#undef TT_REVRAW 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 e5b78024cbf8..db9f85c7428f 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -22,6 +22,7 @@ #pragma once #define BOARD_INFO_NAME "BTT SKR V1.3" +#define LPC1768_IS_SKRV1_3 1 // // Trinamic Stallguard pins diff --git a/platformio.ini b/platformio.ini index 6008b943ecb0..9239ace72caa 100644 --- a/platformio.ini +++ b/platformio.ini @@ -235,7 +235,7 @@ HAS_L64XX = Arduino-L6470@0.8.0 src_filter=+ + + + NEOPIXEL_LED = Adafruit NeoPixel@1.5.0 src_filter=+ -MAX6675_._IS_MAX31865 = Adafruit MAX31865 library@~1.1.0 +TEMP_.+_IS_MAX31865 = Adafruit MAX31865 library@~1.1.0 USES_LIQUIDCRYSTAL = bitbucket-fmalpartida/LiquidCrystal@1.5.0 USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4 USES_LIQUIDTWI2 = LiquidTWI2@1.2.7 From 2381d19df9c7072298fd06b01a8bf1e9e1aaa196 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 7 Feb 2021 22:50:03 -0600 Subject: [PATCH 38/44] merge followup --- Marlin/src/module/temperature.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index d71e7eb66b1f..537393ef9d30 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -84,9 +84,6 @@ #ifndef MAX31865_MOSI_PIN #define MAX31865_MOSI_PIN SD_MOSI_PIN #endif - #ifndef MAX31865_MISO_PIN - #define MAX31865_MISO_PIN MAX6675_DO_PIN - #endif #if PIN_EXISTS(MAX31865_MISO) && PIN_EXISTS(MAX31865_SCK) #define MAX31865_USES_SW_SPI 1 #endif From 88fa586b76583d6b3c737e693c247e66b0bcc580 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 7 Feb 2021 22:54:37 -0600 Subject: [PATCH 39/44] Update Conditionals_post.h --- Marlin/src/inc/Conditionals_post.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index f35622091b15..949885eab7ec 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -533,16 +533,16 @@ // Compatibility Layer for use when HAL manipulates PINS for MAX31855 and MAX6675 #if PIN_EXISTS(MAX31855_CS) && !PIN_EXISTS(MAX6675_SS) - #define MAX6675_SS_PIN MAX31855_CS_PIN + #define MAX6675_SS_PIN MAX31855_CS_PIN #endif #if PIN_EXISTS(MAX31855_CS2) && !PIN_EXISTS(MAX6675_SS2) - #define MAX6675_SS2_PIN MAX31855_CS2_PIN + #define MAX6675_SS2_PIN MAX31855_CS2_PIN #endif #if PIN_EXISTS(MAX6675_CS) && !PIN_EXISTS(MAX6675_SS) - #define MAX6675_SS_PIN MAX6675_CS_PIN + #define MAX6675_SS_PIN MAX6675_CS_PIN #endif #if PIN_EXISTS(MAX6675_CS2) && !PIN_EXISTS(MAX6675_SS2) - #define MAX6675_SS2_PIN MAX6675_CS2_PIN + #define MAX6675_SS2_PIN MAX6675_CS2_PIN #endif #if PIN_EXISTS(MAX31855_MISO) && !PIN_EXISTS(MAX6675_DO) #define MAX6675_DO_PIN MAX31855_MISO_PIN From d99d7a8ee9618b3a7a894752477ac90af7b2bb2b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 7 Feb 2021 23:08:45 -0600 Subject: [PATCH 40/44] cleanup --- Marlin/src/module/temperature.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 537393ef9d30..a47e2a85e691 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2421,23 +2421,21 @@ void Temperature::disable_all_heaters() { const uint8_t fault_31865 = max865ref.readFault() & 0x3FU; #endif - #if ENABLED(LIB_ADAFRUIT_MAX31865) - if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && fault_31865) { - #else - if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max_tc_temp & MAX_TC_ERROR_MASK)) { - #endif + if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) + && TERN(LIB_ADAFRUIT_MAX31865, fault_31865, (max_tc_temp & MAX_TC_ERROR_MASK)) + ) { max_tc_errors[hindex]++; if (max_tc_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { SERIAL_ERROR_START(); SERIAL_ECHOPGM("Temp measurement error! "); #if MAX_TC_ERROR_MASK == 7 - SERIAL_ECHOPGM("MAX31855 "); - if (max_tc_temp & 1) - SERIAL_ECHOLNPAIR("Fault :(", max_tc_temp & 1 ,") >> Open Circuit"); - else if (max_tc_temp & 2) - SERIAL_ECHOLNPAIR("Fault : (", max_tc_temp & 2 ,") >> Short to GND"); - else if (max_tc_temp & 4) - SERIAL_ECHOLNPAIR("Fault : (", max_tc_temp & 4 ,") >> Short to VCC"); + SERIAL_ECHOPGM("MAX31855 Fault : (", max_tc_temp & 0x7, ") >> "); + if (max_tc_temp & 0x1) + SERIAL_ECHOLNPGM("Open Circuit"); + else if (max_tc_temp & 0x2) + SERIAL_ECHOLNPGM("Short to GND"); + else if (max_tc_temp & 0x4) + SERIAL_ECHOLNPGM("Short to VCC"); #elif HAS_MAX31865 #if ENABLED(LIB_USR_MAX31865) // At the present time we do not have the ability to set the MAX31865 HIGH threshold @@ -2462,8 +2460,7 @@ void Temperature::disable_all_heaters() { SERIAL_ECHOLNPGM("Under/Over voltage"); } #else - SERIAL_ECHOPGM("MAX6675 "); - SERIAL_ECHOLNPGM("Open Circuit"); + SERIAL_ECHOLNPGM("MAX6675 Open Circuit"); #endif // Thermocouple open From 474fdf4bddd0173d477513bbf50315d67510400b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 7 Feb 2021 23:11:34 -0600 Subject: [PATCH 41/44] merge followup --- Marlin/src/module/temperature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index a47e2a85e691..5b6b4bcabf27 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2394,7 +2394,7 @@ void Temperature::disable_all_heaters() { // Read a big-endian temperature value #if NO_THERMO_TEMPS for (uint8_t i = sizeof(max_tc_temp); i--;) { - max_tc_temp |= TERN(THERMO_SEPARATE_SPI, max6675_spi.receive(), spiRec()); + max_tc_temp |= TERN(THERMO_SEPARATE_SPI, max_tc_spi.receive(), spiRec()); if (i > 0) max_tc_temp <<= 8; // shift left if not the last byte } MAX6675_WRITE(HIGH); // disable TT_MAX6675 From 8969cd2608ff8e1803deca299dff01fe5fd8e0a4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 8 Feb 2021 00:06:40 -0600 Subject: [PATCH 42/44] ok --- Marlin/src/module/temperature.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 5b6b4bcabf27..fd5ace98fbad 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2444,8 +2444,8 @@ void Temperature::disable_all_heaters() { #endif max865ref.clearFault(); if (fault_31865) { - SERIAL_ECHOLN(); - SERIAL_ECHOLNPAIR("MAX31865 Fault :(", fault_31865, ") >>"); + SERIAL_EOL(); + SERIAL_ECHOLNPAIR("\nMAX31865 Fault :(", fault_31865, ") >>"); if (fault_31865 & MAX31865_FAULT_HIGHTHRESH) SERIAL_ECHOLNPGM("RTD High Threshold"); if (fault_31865 & MAX31865_FAULT_LOWTHRESH) From 4ab5d68b80f32ac60193201cf9efc8679edd3c9b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 8 Feb 2021 00:31:06 -0600 Subject: [PATCH 43/44] Update temperature.cpp --- Marlin/src/module/temperature.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index fd5ace98fbad..e014c704b175 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -3172,14 +3172,7 @@ void Temperature::tick() { SERIAL_PRINT(t, SFP); #if ENABLED(SHOW_TEMP_ADC_VALUES) // Temperature MAX SPI boards do not have an OVERSAMPLENR defined - #if NO_THERMO_TEMPS - SERIAL_ECHOPAIR(" (", r * RECIPROCAL(OVERSAMPLENR)); - #else - if (k == 'T') - SERIAL_ECHOPAIR(" (", r); - else - SERIAL_ECHOPAIR(" (", r * RECIPROCAL(OVERSAMPLENR)); - #endif + SERIAL_ECHOPAIR(" (", TERN(NO_THERMO_TEMPS, false, k == 'T') ? r : r * RECIPROCAL(OVERSAMPLENR)); SERIAL_CHAR(')'); #endif delay(2); From 925ac3e38a9f5a984c520bbc4d93a905a275c694 Mon Sep 17 00:00:00 2001 From: GadgetAngel Date: Mon, 8 Feb 2021 04:53:44 -0500 Subject: [PATCH 44/44] added need st. to disable SPI TC during Startup --- Marlin/src/MarlinCore.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index cc3a4f819ebc..e75a101a7ba8 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -937,6 +937,14 @@ void setup() { SETUP_RUN(HAL_init()); + // Init and disable SPI thermocouples; this is still needed + #if TEMP_SENSOR_0_IS_MAX_TC + OUT_WRITE(MAX6675_SS_PIN, HIGH); // Disable + #endif + #if TEMP_SENSOR_1_IS_MAX_TC + OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable + #endif + #if HAS_L64XX SETUP_RUN(L64xxManager.init()); // Set up SPI, init drivers #endif