diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 3b3087e46f..e9a49b6056 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -397,70 +397,92 @@ // @section temperature /** - * --NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table + * --NORMAL IS 4.7kΩ PULLUP!-- 1kΩ pullup can be used on hotend sensor, using correct resistor and table * * Temperature sensors available: * - * -5 : PT100 / PT1000 with MAX31865 (only for sensors 0-1) - * -3 : thermocouple with MAX31855 (only for sensors 0-1) - * -2 : thermocouple with MAX6675 (only for sensors 0-1) - * -4 : thermocouple with AD8495 - * -1 : thermocouple with AD595 + * SPI RTD/Thermocouple Boards - IMPORTANT: Read the NOTE below! + * ------- + * -5 : MAX31865 with Pt100/Pt1000, 2, 3, or 4-wire (only for sensors 0-1) + * NOTE: You must uncomment/set the MAX31865_*_OHMS_n defines below. + * -3 : MAX31855 with Thermocouple, -200°C to +700°C (only for sensors 0-1) + * -2 : MAX6675 with Thermocouple, 0°C to +700°C (only for sensors 0-1) + * + * NOTE: Ensure TEMP_n_CS_PIN is set in your pins file for each TEMP_SENSOR_n using an SPI Thermocouple. By default, + * Hardware SPI on the default serial bus is used. If you have also set TEMP_n_SCK_PIN and TEMP_n_MISO_PIN, + * Software SPI will be used on those ports instead. You can force Hardware SPI on the default bus in the + * Configuration_adv.h file. At this time, separate Hardware SPI buses for sensors are not supported. + * + * Analog Themocouple Boards + * ------- + * -4 : AD8495 with Thermocouple + * -1 : AD595 with Thermocouple + * + * Analog Thermistors - 4.7kΩ pullup - Normal + * ------- + * 1 : 100kΩ EPCOS - Best choice for EPCOS thermistors + * 331 : 100kΩ Same as #1, but 3.3V scaled for MEGA + * 332 : 100kΩ Same as #1, but 3.3V scaled for DUE + * 2 : 200kΩ ATC Semitec 204GT-2 + * 202 : 200kΩ Copymaster 3D + * 3 : ???Ω Mendel-parts thermistor + * 4 : 10kΩ Generic Thermistor !! DO NOT use for a hotend - it gives bad resolution at high temp. !! + * 5 : 100kΩ ATC Semitec 104GT-2/104NT-4-R025H42G - Used in ParCan, J-Head, and E3D, SliceEngineering 300°C + * 501 : 100kΩ Zonestar - Tronxy X3A + * 502 : 100kΩ Zonestar - used by hot bed in Zonestar Průša P802M + * 512 : 100kΩ RPW-Ultra hotend + * 6 : 100kΩ EPCOS - Not as accurate as table #1 (created using a fluke thermocouple) + * 7 : 100kΩ Honeywell 135-104LAG-J01 + * 71 : 100kΩ Honeywell 135-104LAF-J01 + * 8 : 100kΩ Vishay 0603 SMD NTCS0603E3104FXT + * 9 : 100kΩ GE Sensing AL03006-58.2K-97-G1 + * 10 : 100kΩ RS PRO 198-961 + * 11 : 100kΩ Keenovo AC silicone mats, most Wanhao i3 machines - beta 3950, 1% + * 12 : 100kΩ Vishay 0603 SMD NTCS0603E3104FXT (#8) - calibrated for Makibox hot bed + * 13 : 100kΩ Hisens up to 300°C - for "Simple ONE" & "All In ONE" hotend - beta 3950, 1% + * 15 : 100kΩ Calibrated for JGAurora A5 hotend + * 18 : 200kΩ ATC Semitec 204GT-2 Dagoma.Fr - MKS_Base_DKU001327 + * 22 : 100kΩ GTM32 Pro vB - hotend - 4.7kΩ pullup to 3.3V and 220Ω to analog input + * 23 : 100kΩ GTM32 Pro vB - bed - 4.7kΩ pullup to 3.3v and 220Ω to analog input + * 30 : 100kΩ Kis3d Silicone heating mat 200W/300W with 6mm precision cast plate (EN AW 5083) NTC100K - beta 3950 + * 60 : 100kΩ Maker's Tool Works Kapton Bed Thermistor - beta 3950 + * 61 : 100kΩ Formbot/Vivedino 350°C Thermistor - beta 3950 + * 66 : 4.7MΩ Dyze Design High Temperature Thermistor + * 67 : 500kΩ SliceEngineering 450°C Thermistor + * 70 : 100kΩ bq Hephestos 2 + * 75 : 100kΩ Generic Silicon Heat Pad with NTC100K MGB18-104F39050L32 + * + * Analog Thermistors - 1kΩ pullup - Atypical, and requires changing out the 4.7kΩ pullup for 1kΩ. + * ------- (but gives greater accuracy and more stable PID) + * 51 : 100kΩ EPCOS (1kΩ pullup) + * 52 : 200kΩ ATC Semitec 204GT-2 (1kΩ pullup) + * 55 : 100kΩ ATC Semitec 104GT-2 - Used in ParCan & J-Head (1kΩ pullup) + * + * Analog Thermistors - 10kΩ pullup - Atypical + * ------- + * 99 : 100kΩ Found on some Wanhao i3 machines with a 10kΩ pull-up resistor + * + * Analog RTDs (Pt100/Pt1000) + * ------- + * 110 : Pt100 with 1kΩ pullup (atypical) + * 147 : Pt100 with 4.7kΩ pullup + * 1010 : Pt1000 with 1kΩ pullup (atypical) + * 1047 : Pt1000 with 4.7kΩ pullup (E3D) + * 20 : Pt100 with circuit in the Ultimainboard V2.x with mainboard ADC reference voltage = INA826 amplifier-board supply voltage. + * NOTE: (1) Must use an ADC input with no pullup. (2) Some INA826 amplifiers are unreliable at 3.3V so consider using sensor 147, 110, or 21. + * 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v ADC reference voltage (STM32, LPC176x....) and 5V INA826 amplifier board supply. + * NOTE: ADC pins are not 5V tolerant. Not recommended because it's possible to damage the CPU by going over 500°C. + * 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x + * + * Custom/Dummy/Other Thermos + * ------ * 0 : not used - * 1 : 100k thermistor - best choice for EPCOS 100k (4.7k pullup) - * 331 : (3.3V scaled thermistor 1 table for MEGA) - * 332 : (3.3V scaled thermistor 1 table for DUE) - * 2 : 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup) - * 202 : 200k thermistor - Copymaster 3D - * 3 : Mendel-parts thermistor (4.7k pullup) - * 4 : 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !! - * 5 : 100K thermistor - ATC Semitec 104GT-2/104NT-4-R025H42G (Used in ParCan, J-Head, and E3D) (4.7k pullup) - * 501 : 100K Zonestar (Tronxy X3A) Thermistor - * 502 : 100K Zonestar Thermistor used by hot bed in Zonestar Průša P802M - * 512 : 100k RPW-Ultra hotend thermistor (4.7k pullup) - * 6 : 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup) - * 7 : 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup) - * 71 : 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup) - * 8 : 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) - * 9 : 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup) - * 10 : 100k RS thermistor 198-961 (4.7k pullup) - * 11 : 100k beta 3950 1% thermistor (Used in Keenovo AC silicone mats and most Wanhao i3 machines) (4.7k pullup) - * 12 : 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) - * 13 : 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" - * 15 : 100k thermistor calibration for JGAurora A5 hotend - * 18 : ATC Semitec 204GT-2 (4.7k pullup) Dagoma.Fr - MKS_Base_DKU001327 - * 20 : Pt100 with circuit in the Ultimainboard V2.x with mainboard ADC reference voltage = INA826 amplifier-board supply voltage. - * NOTES: (1) Must use an ADC input with no pullup. (2) Some INA826 amplifiers are unreliable at 3.3V so consider using sensor 147, 110, or 21. - * 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v ADC reference voltage (STM32, LPC176x....) and 5V INA826 amplifier board supply. - * NOTE: ADC pins are not 5V tolerant. Not recommended because it's possible to damage the CPU by going over 500°C. - * 22 : 100k (hotend) with 4.7k pullup to 3.3V and 220R to analog input (as in GTM32 Pro vB) - * 23 : 100k (bed) with 4.7k pullup to 3.3v and 220R to analog input (as in GTM32 Pro vB) - * 30 : Kis3d Silicone heating mat 200W/300W with 6mm precision cast plate (EN AW 5083) NTC100K / B3950 (4.7k pullup) - * 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x - * 60 : 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 - * 61 : 100k Formbot / Vivedino 3950 350C thermistor 4.7k pullup - * 66 : 4.7M High Temperature thermistor from Dyze Design - * 67 : 450C thermistor from SliceEngineering - * 70 : the 100K thermistor found in the bq Hephestos 2 - * 75 : 100k Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor - * 99 : 100k thermistor with a 10K pull-up resistor (found on some Wanhao i3 machines) - * - * 1k ohm pullup tables - This is atypical, and requires changing out the 4.7k pullup for 1k. - * (but gives greater accuracy and more stable PID) - * 51 : 100k thermistor - EPCOS (1k pullup) - * 52 : 200k thermistor - ATC Semitec 204GT-2 (1k pullup) - * 55 : 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup) - * - * 1047 : Pt1000 with 4k7 pullup (E3D) - * 1010 : Pt1000 with 1k pullup (non standard) - * 147 : Pt100 with 4k7 pullup - * 110 : Pt100 with 1k pullup (non standard) - * * 1000 : Custom - Specify parameters in Configuration_adv.h * - * Use these for Testing or Development purposes. NEVER for production machine. + * !!! 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 #define TEMP_SENSOR_1 0 @@ -482,7 +504,7 @@ // 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_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 diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 818edecea2..6a7219383b 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -131,10 +131,21 @@ #define REDUNDANT_BETA 3950 // Beta value #endif -// -// Hephestos 2 24V heated bed upgrade kit. -// https://store.bq.com/en/heated-bed-kit-hephestos2 -// +/** + * Configuration options for MAX Thermocouples (-2, -3, -5). + * FORCE_HW_SPI: Ignore SCK/MOSI/MISO pins and just use the CS pin & default SPI bus. + * MAX31865_WIRES: Set the number of wires for the probe connected to a MAX31865 board, 2-4. Default: 2 + * MAX31865_50HZ: Enable 50Hz filter instead of the default 60Hz. + */ +//#define TEMP_SENSOR_FORCE_HW_SPI +//#define MAX31865_SENSOR_WIRES_0 2 +//#define MAX31865_SENSOR_WIRES_1 2 +//#define MAX31865_50HZ_FILTER + +/** + * Hephestos 2 24V heated bed upgrade kit. + * https://store.bq.com/en/heated-bed-kit-hephestos2 + */ //#define HEPHESTOS2_HEATED_BED_KIT #if ENABLED(HEPHESTOS2_HEATED_BED_KIT) #undef TEMP_SENSOR_BED diff --git a/Marlin/src/HAL/SAMD51/inc/SanityCheck.h b/Marlin/src/HAL/SAMD51/inc/SanityCheck.h index 2a4bde98e6..38c6dd9e08 100644 --- a/Marlin/src/HAL/SAMD51/inc/SanityCheck.h +++ b/Marlin/src/HAL/SAMD51/inc/SanityCheck.h @@ -31,7 +31,8 @@ #error "No custom SD drive cable defined for this board." #endif -#if defined(MAX6675_SCK_PIN) && defined(MAX6675_DO_PIN) && (MAX6675_SCK_PIN == SCK1 || MAX6675_DO_PIN == MISO1) +#if (defined(TEMP_0_SCK_PIN) && defined(TEMP_0_MISO_PIN) && (TEMP_0_SCK_PIN == SCK1 || TEMP_0_MISO_PIN == MISO1)) || \ + (defined(TEMP_1_SCK_PIN) && defined(TEMP_1_MISO_PIN) && (TEMP_1_SCK_PIN == SCK1 || TEMP_1_MISO_PIN == MISO1)) #error "OnBoard SPI BUS can't be shared with other devices." #endif diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 254283da5b..dc9fbb2ba7 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1169,10 +1169,10 @@ void setup() { // Init and disable SPI thermocouples; this is still needed #if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 0) - OUT_WRITE(MAX6675_SS_PIN, HIGH); // Disable + OUT_WRITE(TEMP_0_CS_PIN, HIGH); // Disable #endif #if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1) - OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable + OUT_WRITE(TEMP_1_CS_PIN, HIGH); #endif #if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 295eee9bcf..05640bce87 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -204,8 +204,8 @@ #define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1' #define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B. -#define _OPTARG(A) , A -#define OPTARG(O,A) TERN_(O,DEFER4(_OPTARG)(A)) +#define _OPTARG(A...) , A +#define OPTARG(O,A...) TERN_(O,DEFER4(_OPTARG)(A)) #define _OPTCODE(A) A; #define OPTCODE(O,A) TERN_(O,DEFER4(_OPTCODE)(A)) diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 6869962028..50f3419c89 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -314,11 +314,13 @@ void GcodeSuite::G34() { sprintf_P(msg, PSTR("1:2=%s" TERN_(TRIPLE_Z, " 3-2=%s 3-1=%s") TERN_(QUAD_Z, " 4-3=%s 4-2=%s 4-1=%s")), dtostrf(ABS(z_measured[1] - z_measured[0]), 1, 3, fstr1) - OPTARG(TRIPLE_Z, dtostrf(ABS(z_measured[2] - z_measured[1]), 1, 3, fstr2)) - OPTARG(TRIPLE_Z, dtostrf(ABS(z_measured[2] - z_measured[0]), 1, 3, fstr3)) - OPTARG(QUAD_Z, dtostrf(ABS(z_measured[3] - z_measured[2]), 1, 3, fstr4)) - OPTARG(QUAD_Z, dtostrf(ABS(z_measured[3] - z_measured[1]), 1, 3, fstr5)) - OPTARG(QUAD_Z, dtostrf(ABS(z_measured[3] - z_measured[0]), 1, 3, fstr6)) + OPTARG(TRIPLE_Z, + dtostrf(ABS(z_measured[2] - z_measured[1]), 1, 3, fstr2), + dtostrf(ABS(z_measured[2] - z_measured[0]), 1, 3, fstr3)) + OPTARG(QUAD_Z, + dtostrf(ABS(z_measured[3] - z_measured[2]), 1, 3, fstr4), + dtostrf(ABS(z_measured[3] - z_measured[1]), 1, 3, fstr5), + dtostrf(ABS(z_measured[3] - z_measured[0]), 1, 3, fstr6)) ); ui.set_status(msg); #endif diff --git a/Marlin/src/gcode/sd/M20.cpp b/Marlin/src/gcode/sd/M20.cpp index 7ac4affdae..5731838338 100644 --- a/Marlin/src/gcode/sd/M20.cpp +++ b/Marlin/src/gcode/sd/M20.cpp @@ -33,7 +33,7 @@ void GcodeSuite::M20() { if (card.flag.mounted) { SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST); - card.ls(); + card.ls(TERN_(LONG_FILENAME_HOST_SUPPORT, parser.boolval('L'))); SERIAL_ECHOLNPGM(STR_END_FILE_LIST); } else diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 833fe0d227..a9ad5018e8 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1078,7 +1078,11 @@ #if ENABLED(DWIN_CREALITY_LCD) #define SERIAL_CATCHALL 0 #ifndef LCD_SERIAL_PORT - #define LCD_SERIAL_PORT 3 // Creality 4.x board + #if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_E3_TURBO) + #define LCD_SERIAL_PORT 1 + #else + #define LCD_SERIAL_PORT 3 // Creality 4.x board + #endif #endif #endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 45271bca72..2f5af2b700 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -615,20 +615,21 @@ #if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2 #define TEMP_SENSOR_0_IS_MAX_TC 1 - #define HAS_MAX_TC 1 - #if TEMP_SENSOR_0 == -3 - #define TEMP_SENSOR_0_MAX_TC_TMIN -270 - #define TEMP_SENSOR_0_MAX_TC_TMAX 1800 - #else - #define TEMP_SENSOR_0_MAX_TC_TMIN 0 - #define TEMP_SENSOR_0_MAX_TC_TMAX 1024 - #endif #if TEMP_SENSOR_0 == -5 #define TEMP_SENSOR_0_IS_MAX31865 1 + #define TEMP_SENSOR_0_MAX_TC_TMIN 0 + #define TEMP_SENSOR_0_MAX_TC_TMAX 1024 + #ifndef MAX31865_SENSOR_WIRES_0 + #define MAX31865_SENSOR_WIRES_0 2 + #endif #elif TEMP_SENSOR_0 == -3 #define TEMP_SENSOR_0_IS_MAX31855 1 + #define TEMP_SENSOR_0_MAX_TC_TMIN -270 + #define TEMP_SENSOR_0_MAX_TC_TMAX 1800 #elif TEMP_SENSOR_0 == -2 #define TEMP_SENSOR_0_IS_MAX6675 1 + #define TEMP_SENSOR_0_MAX_TC_TMIN 0 + #define TEMP_SENSOR_0_MAX_TC_TMAX 1024 #endif #elif TEMP_SENSOR_0 == -4 #define TEMP_SENSOR_0_IS_AD8495 1 @@ -648,21 +649,23 @@ #if TEMP_SENSOR_1 == -5 || TEMP_SENSOR_1 == -3 || TEMP_SENSOR_1 == -2 #define TEMP_SENSOR_1_IS_MAX_TC 1 - #define HAS_MAX_TC 1 - #if TEMP_SENSOR_1 == -3 + #if TEMP_SENSOR_1 == -5 + #define TEMP_SENSOR_1_IS_MAX31865 1 + #define TEMP_SENSOR_1_MAX_TC_TMIN 0 + #define TEMP_SENSOR_1_MAX_TC_TMAX 1024 + #ifndef MAX31865_SENSOR_WIRES_1 + #define MAX31865_SENSOR_WIRES_1 2 + #endif + #elif TEMP_SENSOR_1 == -3 + #define TEMP_SENSOR_1_IS_MAX31855 1 #define TEMP_SENSOR_1_MAX_TC_TMIN -270 #define TEMP_SENSOR_1_MAX_TC_TMAX 1800 - #else + #elif TEMP_SENSOR_1 == -2 + #define TEMP_SENSOR_1_IS_MAX6675 1 #define TEMP_SENSOR_1_MAX_TC_TMIN 0 #define TEMP_SENSOR_1_MAX_TC_TMAX 1024 #endif - #if TEMP_SENSOR_1 == -5 - #define TEMP_SENSOR_1_IS_MAX31865 1 - #elif TEMP_SENSOR_1 == -3 - #define TEMP_SENSOR_1_IS_MAX31855 1 - #elif TEMP_SENSOR_1 == -2 - #define TEMP_SENSOR_1_IS_MAX6675 1 - #endif + #if TEMP_SENSOR_1 != TEMP_SENSOR_0 #if TEMP_SENSOR_1 == -5 #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_1 then TEMP_SENSOR_0 must match." @@ -690,37 +693,48 @@ #if TEMP_SENSOR_REDUNDANT == -5 || TEMP_SENSOR_REDUNDANT == -3 || TEMP_SENSOR_REDUNDANT == -2 #define TEMP_SENSOR_REDUNDANT_IS_MAX_TC 1 - #define HAS_MAX_TC 1 - #if TEMP_SENSOR_REDUNDANT == -3 - #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN -270 - #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1800 - #else - #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN 0 - #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1024 - #endif - #if TEMP_SENSOR_REDUNDANT_SOURCE == 0 - #define TEMP_SENSOR_0_MAX_TC_TMIN TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN - #define TEMP_SENSOR_0_MAX_TC_TMAX TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - #elif TEMP_SENSOR_REDUNDANT_SOURCE == 1 - #define TEMP_SENSOR_1_MAX_TC_TMIN TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN - #define TEMP_SENSOR_1_MAX_TC_TMAX TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - #endif + #if TEMP_SENSOR_REDUNDANT == -5 #if TEMP_SENSOR_REDUNDANT_SOURCE != 0 && TEMP_SENSOR_REDUNDANT_SOURCE != 1 #error "MAX31865 Thermocouples (-5) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)." #endif - #define TEMP_SENSOR_REDUNDANT_IS_MAX31865 1 + + #define TEMP_SENSOR_REDUNDANT_IS_MAX31865 1 + #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN 0 + #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1024 #elif TEMP_SENSOR_REDUNDANT == -3 #if TEMP_SENSOR_REDUNDANT_SOURCE != 0 && TEMP_SENSOR_REDUNDANT_SOURCE != 1 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)." #endif - #define TEMP_SENSOR_REDUNDANT_IS_MAX31855 1 + + #define TEMP_SENSOR_REDUNDANT_IS_MAX31855 1 + #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN -270 + #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1800 #elif TEMP_SENSOR_REDUNDANT == -2 #if TEMP_SENSOR_REDUNDANT_SOURCE != 0 && TEMP_SENSOR_REDUNDANT_SOURCE != 1 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)." #endif - #define TEMP_SENSOR_REDUNDANT_IS_MAX6675 1 + + #define TEMP_SENSOR_REDUNDANT_IS_MAX6675 1 + #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN 0 + #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1024 #endif + + // mimic setting up the source TEMP_SENSOR + #if TEMP_SENSOR_REDUNDANT_SOURCE == 0 + #define TEMP_SENSOR_0_MAX_TC_TMIN TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + #define TEMP_SENSOR_0_MAX_TC_TMAX TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX + #ifndef MAX31865_SENSOR_WIRES_0 + #define MAX31865_SENSOR_WIRES_0 2 + #endif + #elif TEMP_SENSOR_REDUNDANT_SOURCE == 1 + #define TEMP_SENSOR_1_MAX_TC_TMIN TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + #define TEMP_SENSOR_1_MAX_TC_TMAX TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX + #ifndef MAX31865_SENSOR_WIRES_1 + #define MAX31865_SENSOR_WIRES_1 2 + #endif + #endif + #if (TEMP_SENSOR_0_IS_MAX_TC && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_0) || (TEMP_SENSOR_1_IS_MAX_TC && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_1) #if TEMP_SENSOR_REDUNDANT == -5 #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match." @@ -743,101 +757,182 @@ #endif #endif +#if TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC || TEMP_SENSOR_REDUNDANT_IS_MAX_TC + #define HAS_MAX_TC 1 +#endif +#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 || TEMP_SENSOR_REDUNDANT_IS_MAX6675 + #define HAS_MAX6675 1 +#endif #if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855 || TEMP_SENSOR_REDUNDANT_IS_MAX31855 #define HAS_MAX31855 1 #endif #if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865 || TEMP_SENSOR_REDUNDANT_IS_MAX31865 #define HAS_MAX31865 1 #endif -#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 || TEMP_SENSOR_REDUNDANT_IS_MAX6675 - #define HAS_MAX6675 1 -#endif // // Compatibility layer for MAX (SPI) temp boards // -#define TEMP_SENSOR_IS_MAX(n, M) (ENABLED(TEMP_SENSOR_##n##_IS_##M) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_##M) && TEMP_SENSOR_REDUNDANT_SOURCE == (n))) +#if HAS_MAX_TC -#if PIN_EXISTS(MAX6675_SS) - #if TEMP_SENSOR_IS_MAX(0, MAX31855) - #define MAX31855_CS_PIN MAX6675_SS_PIN - #elif TEMP_SENSOR_IS_MAX(0, MAX31865) - #define MAX31865_CS_PIN MAX6675_SS_PIN - #elif TEMP_SENSOR_IS_MAX(0, MAX6675) - #define MAX6675_CS_PIN MAX6675_SS_PIN + // Translate old _SS, _CS, _SCK, _DO, _DI, _MISO, and _MOSI PIN defines. + #if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1) + + #if !PIN_EXISTS(TEMP_0_CS) // SS, CS + #if PIN_EXISTS(MAX6675_SS) + #define TEMP_0_CS_PIN MAX6675_SS_PIN + #elif PIN_EXISTS(MAX6675_CS) + #define TEMP_0_CS_PIN MAX6675_CS_PIN + #elif PIN_EXISTS(MAX31855_SS) + #define TEMP_0_CS_PIN MAX31855_SS_PIN + #elif PIN_EXISTS(MAX31855_CS) + #define TEMP_0_CS_PIN MAX31855_CS_PIN + #elif PIN_EXISTS(MAX31865_SS) + #define TEMP_0_CS_PIN MAX31865_SS_PIN + #elif PIN_EXISTS(MAX31865_CS) + #define TEMP_0_CS_PIN MAX31865_CS_PIN + #endif + #endif + + #if TEMP_SENSOR_0_IS_MAX6675 + #if !PIN_EXISTS(TEMP_0_MISO) // DO + #if PIN_EXISTS(MAX6675_MISO) + #define TEMP_0_MISO_PIN MAX6675_MISO_PIN + #elif PIN_EXISTS(MAX6675_DO) + #define TEMP_0_MISO_PIN MAX6675_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_0_SCK) && PIN_EXISTS(MAX6675_SCK) + #define TEMP_0_SCK_PIN MAX6675_SCK_PIN + #endif + + #elif TEMP_SENSOR_0_IS_MAX31855 + #if !PIN_EXISTS(TEMP_0_MISO) // DO + #if PIN_EXISTS(MAX31855_MISO) + #define TEMP_0_MISO_PIN MAX31855_MISO_PIN + #elif PIN_EXISTS(MAX31855_DO) + #define TEMP_0_MISO_PIN MAX31855_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_0_SCK) && PIN_EXISTS(MAX31855_SCK) + #define TEMP_0_SCK_PIN MAX31855_SCK_PIN + #endif + + #elif TEMP_SENSOR_1_IS_MAX31865 + #if !PIN_EXISTS(TEMP_1_MISO) // DO + #if PIN_EXISTS(MAX31865_MISO) + #define TEMP_1_MISO_PIN MAX31865_MISO_PIN + #elif PIN_EXISTS(MAX31865_DO) + #define TEMP_1_MISO_PIN MAX31865_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_1_SCK) && PIN_EXISTS(MAX31865_SCK) + #define TEMP_1_SCK_PIN MAX31865_SCK_PIN + #endif + #if !PIN_EXISTS(TEMP_1_MOSI) && PIN_EXISTS(MAX31865_MOSI) // MOSI for '65 only + #define TEMP_1_MOSI_PIN MAX31865_MOSI_PIN + #endif + #endif + + // Software SPI - enable if MISO/SCK are defined. + #if PIN_EXISTS(TEMP_0_MISO) && PIN_EXISTS(TEMP_0_SCK) && DISABLED(TEMP_SENSOR_0_FORCE_HW_SPI) + #if TEMP_SENSOR_0_IS_MAX31865 && !PIN_EXISTS(TEMP_0_MOSI) + #error "TEMP_SENSOR_0 MAX31865 requires TEMP_0_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_0_FORCE_HW_SPI." + #else + #define TEMP_SENSOR_0_HAS_SPI_PINS 1 + #endif + #endif + + #endif // TEMP_SENSOR_0_IS_MAX_TC + + #if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1) + + #if !PIN_EXISTS(TEMP_1_CS) // SS2, CS2 + #if PIN_EXISTS(MAX6675_SS2) + #define TEMP_1_CS_PIN MAX6675_SS2_PIN + #elif PIN_EXISTS(MAX6675_CS) + #define TEMP_1_CS_PIN MAX6675_CS2_PIN + #elif PIN_EXISTS(MAX31855_SS2) + #define TEMP_1_CS_PIN MAX31855_SS2_PIN + #elif PIN_EXISTS(MAX31855_CS2) + #define TEMP_1_CS_PIN MAX31855_CS2_PIN + #elif PIN_EXISTS(MAX31865_SS2) + #define TEMP_1_CS_PIN MAX31865_SS2_PIN + #elif PIN_EXISTS(MAX31865_CS2) + #define TEMP_1_CS_PIN MAX31865_CS2_PIN + #endif + #endif + + #if TEMP_SENSOR_1_IS_MAX6675 + #if !PIN_EXISTS(TEMP_1_MISO) // DO + #if PIN_EXISTS(MAX6675_MISO) + #define TEMP_1_MISO_PIN MAX6675_MISO_PIN + #elif PIN_EXISTS(MAX6675_DO) + #define TEMP_1_MISO_PIN MAX6675_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_1_SCK) && PIN_EXISTS(MAX6675_SCK) + #define TEMP_1_SCK_PIN MAX6675_SCK_PIN + #endif + + #elif TEMP_SENSOR_1_IS_MAX31855 + #if !PIN_EXISTS(TEMP_1_MISO) // DO + #if PIN_EXISTS(MAX31855_MISO) + #define TEMP_1_MISO_PIN MAX31855_MISO_PIN + #elif PIN_EXISTS(MAX31855_DO) + #define TEMP_1_MISO_PIN MAX31855_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_1_SCK) && PIN_EXISTS(MAX31855_SCK) + #define TEMP_1_SCK_PIN MAX31855_SCK_PIN + #endif + + #elif TEMP_SENSOR_1_IS_MAX31865 + #if !PIN_EXISTS(TEMP_1_MISO) // DO + #if PIN_EXISTS(MAX31865_MISO) + #define TEMP_1_MISO_PIN MAX31865_MISO_PIN + #elif PIN_EXISTS(MAX31865_DO) + #define TEMP_1_MISO_PIN MAX31865_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_1_SCK) && PIN_EXISTS(MAX31865_SCK) + #define TEMP_1_SCK_PIN MAX31865_SCK_PIN + #endif + #if !PIN_EXISTS(TEMP_1_MOSI) && PIN_EXISTS(MAX31865_MOSI) // MOSI for '65 only + #define TEMP_1_MOSI_PIN MAX31865_MOSI_PIN + #endif + #endif + + // Software SPI - enable if MISO/SCK are defined. + #if PIN_EXISTS(TEMP_1_MISO) && PIN_EXISTS(TEMP_1_SCK) && DISABLED(TEMP_SENSOR_1_FORCE_HW_SPI) + #if TEMP_SENSOR_1_IS_MAX31865 && !PIN_EXISTS(TEMP_1_MOSI) + #error "TEMP_SENSOR_1 MAX31865 requires TEMP_1_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_1_FORCE_HW_SPI." + #else + #define TEMP_SENSOR_1_HAS_SPI_PINS 1 + #endif + #endif + + #endif // TEMP_SENSOR_1_IS_MAX_TC + + // + // User-defined thermocouple libraries + // + // Add LIB_MAX6675 / LIB_MAX31855 / LIB_MAX31865 to the build_flags + // to select a USER library for MAX6675, MAX31855, MAX31865 + // + #if BOTH(HAS_MAX6675, LIB_MAX6675) + #define LIB_USR_MAX6675 1 #endif -#endif - -#if PIN_EXISTS(MAX6675_SS2) - #if TEMP_SENSOR_IS_MAX(1, MAX31855) - #define MAX31855_CS2_PIN MAX6675_SS2_PIN - #elif TEMP_SENSOR_IS_MAX(1, MAX31865) - #define MAX31865_CS2_PIN MAX6675_SS2_PIN - #elif TEMP_SENSOR_IS_MAX(1, MAX6675) - #define MAX6675_CS2_PIN MAX6675_SS2_PIN + #if BOTH(HAS_MAX31855, LIB_MAX31855) + #define LIB_USR_MAX31855 1 #endif -#endif - -#if PIN_EXISTS(MAX6675_DO) - #if HAS_MAX31855 - #define MAX31855_MISO_PIN MAX6675_DO_PIN - #elif HAS_MAX31865 - #define MAX31865_MISO_PIN MAX6675_DO_PIN - #elif HAS_MAX6675 - #define MAX6675_MISO_PIN MAX6675_DO_PIN - #endif -#endif - -#if PIN_EXISTS(MAX6675_SCK) - #if HAS_MAX31855 - #define MAX31855_SCK_PIN MAX6675_SCK_PIN - #elif HAS_MAX31865 - #define MAX31865_SCK_PIN MAX6675_SCK_PIN - #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 - -// -// User-defined thermocouple libraries -// -// Add LIB_MAX6675 / LIB_MAX31855 / LIB_MAX31865 to the build_flags -// to select a USER library for MAX6675, MAX31855, MAX31865 -// -#if BOTH(HAS_MAX6675, LIB_MAX6675) - #define LIB_USR_MAX6675 1 -#endif -#if BOTH(HAS_MAX31855, LIB_MAX31855) - #define LIB_USR_MAX31855 1 -#endif -#if HAS_MAX31865 - #if ENABLED(LIB_MAX31865) + #if BOTH(HAS_MAX31865, LIB_MAX31865) #define LIB_USR_MAX31865 1 - #else - #define LIB_ADAFRUIT_MAX31865 1 + #elif HAS_MAX31865 + #define LIB_INTERNAL_MAX31865 1 #endif -#endif + +#endif //HAS_MAX_TC #if TEMP_SENSOR_2 == -4 #define TEMP_SENSOR_2_IS_AD8495 1 @@ -2722,6 +2817,77 @@ #define BED_OR_CHAMBER_OR_FAN 1 #endif +/** + * Up to 3 PWM fans + */ +#ifndef FAN_INVERTING + #define FAN_INVERTING false +#endif + +#if HAS_FAN7 + #define FAN_COUNT 8 +#elif HAS_FAN6 + #define FAN_COUNT 7 +#elif HAS_FAN5 + #define FAN_COUNT 6 +#elif HAS_FAN4 + #define FAN_COUNT 5 +#elif HAS_FAN3 + #define FAN_COUNT 4 +#elif HAS_FAN2 + #define FAN_COUNT 3 +#elif HAS_FAN1 + #define FAN_COUNT 2 +#elif HAS_FAN0 + #define FAN_COUNT 1 +#else + #define FAN_COUNT 0 +#endif + +#if FAN_COUNT > 0 + #define HAS_FAN 1 +#endif + +/** + * Part Cooling fan multipliexer + */ +#if PIN_EXISTS(FANMUX0) + #define HAS_FANMUX 1 +#endif + +/** + * MIN/MAX fan PWM scaling + */ +#ifndef FAN_OFF_PWM + #define FAN_OFF_PWM 0 +#endif +#ifndef FAN_MIN_PWM + #if FAN_OFF_PWM > 0 + #define FAN_MIN_PWM (FAN_OFF_PWM + 1) + #else + #define FAN_MIN_PWM 0 + #endif +#endif +#ifndef FAN_MAX_PWM + #define FAN_MAX_PWM 255 +#endif +#if FAN_MIN_PWM < 0 || FAN_MIN_PWM > 255 + #error "FAN_MIN_PWM must be a value from 0 to 255." +#elif FAN_MAX_PWM < 0 || FAN_MAX_PWM > 255 + #error "FAN_MAX_PWM must be a value from 0 to 255." +#elif FAN_MIN_PWM > FAN_MAX_PWM + #error "FAN_MIN_PWM must be less than or equal to FAN_MAX_PWM." +#elif FAN_OFF_PWM > FAN_MIN_PWM + #error "FAN_OFF_PWM must be less than or equal to FAN_MIN_PWM." +#endif + +/** + * FAST PWM FAN Settings + */ +#if ENABLED(FAST_PWM_FAN) && !defined(FAST_PWM_FAN_FREQUENCY) + #define FAST_PWM_FAN_FREQUENCY ((F_CPU) / (2 * 255 * 1)) // Fan frequency default +#endif + // Servos #if PIN_EXISTS(SERVO0) && NUM_SERVOS > 0 #define HAS_SERVO_0 1 @@ -2996,77 +3162,6 @@ #undef PREHEAT_SHORTCUT_MENU_ITEM #endif -/** - * Up to 3 PWM fans - */ -#ifndef FAN_INVERTING - #define FAN_INVERTING false -#endif - -#if HAS_FAN7 - #define FAN_COUNT 8 -#elif HAS_FAN6 - #define FAN_COUNT 7 -#elif HAS_FAN5 - #define FAN_COUNT 6 -#elif HAS_FAN4 - #define FAN_COUNT 5 -#elif HAS_FAN3 - #define FAN_COUNT 4 -#elif HAS_FAN2 - #define FAN_COUNT 3 -#elif HAS_FAN1 - #define FAN_COUNT 2 -#elif HAS_FAN0 - #define FAN_COUNT 1 -#else - #define FAN_COUNT 0 -#endif - -#if FAN_COUNT > 0 - #define HAS_FAN 1 -#endif - -/** - * Part Cooling fan multipliexer - */ -#if PIN_EXISTS(FANMUX0) - #define HAS_FANMUX 1 -#endif - -/** - * MIN/MAX fan PWM scaling - */ -#ifndef FAN_OFF_PWM - #define FAN_OFF_PWM 0 -#endif -#ifndef FAN_MIN_PWM - #if FAN_OFF_PWM > 0 - #define FAN_MIN_PWM (FAN_OFF_PWM + 1) - #else - #define FAN_MIN_PWM 0 - #endif -#endif -#ifndef FAN_MAX_PWM - #define FAN_MAX_PWM 255 -#endif -#if FAN_MIN_PWM < 0 || FAN_MIN_PWM > 255 - #error "FAN_MIN_PWM must be a value from 0 to 255." -#elif FAN_MAX_PWM < 0 || FAN_MAX_PWM > 255 - #error "FAN_MAX_PWM must be a value from 0 to 255." -#elif FAN_MIN_PWM > FAN_MAX_PWM - #error "FAN_MIN_PWM must be less than or equal to FAN_MAX_PWM." -#elif FAN_OFF_PWM > FAN_MIN_PWM - #error "FAN_OFF_PWM must be less than or equal to FAN_MIN_PWM." -#endif - -/** - * FAST PWM FAN Settings - */ -#if ENABLED(FAST_PWM_FAN) && !defined(FAST_PWM_FAN_FREQUENCY) - #define FAST_PWM_FAN_FREQUENCY ((F_CPU) / (2 * 255 * 1)) // Fan frequency default -#endif - /** * MIN/MAX case light PWM scaling */ diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 36ccbee9b9..f416ca88bd 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -416,8 +416,19 @@ #error "MBL_Z_STEP is now MESH_EDIT_Z_STEP." #elif defined(CHDK) #error "CHDK is now CHDK_PIN." -#elif defined(MAX6675_SS) || defined(MAX6675_SS2) - #error "MAX6675_SS / MAX6675_SS2 is now MAX6675_SS_PIN / MAX6675_SS2_PIN." +#elif ANY_PIN( \ + MAX6675_SS, MAX6675_SS2, MAX6675_CS, MAX6675_CS2, \ + MAX31855_SS, MAX31855_SS2, MAX31855_CS, MAX31855_CS2, \ + MAX31865_SS, MAX31865_SS2, MAX31865_CS, MAX31865_CS2) + #warning "MAX*_SS_PIN, MAX*_SS2_PIN, MAX*_CS_PIN, and MAX*_CS2_PIN are deprecated and will be removed in a future version. Please use TEMP_0_CS_PIN/TEMP_1_CS_PIN instead." +#elif ANY_PIN(MAX6675_SCK, MAX31855_SCK, MAX31865_SCK) + #warning "MAX*_SCK_PIN is deprecated and will be removed in a future version. Please use TEMP_0_SCK_PIN/TEMP_1_SCK_PIN instead." +#elif ANY_PIN(MAX6675_MISO, MAX6675_DO, MAX31855_MISO, MAX31855_DO, MAX31865_MISO, MAX31865_DO) + #warning "MAX*_MISO_PIN and MAX*_DO_PIN are deprecated and will be removed in a future version. Please use TEMP_0_MISO_PIN/TEMP_1_MISO_PIN instead." +#elif PIN_EXISTS(MAX31865_MOSI) + #warning "MAX31865_MOSI_PIN is deprecated and will be removed in a future version. Please use TEMP_0_MOSI_PIN/TEMP_1_MOSI_PIN instead." +#elif ANY_PIN(THERMO_CS1_PIN, THERMO_CS2_PIN, THERMO_DO_PIN, THERMO_SCK_PIN) + #error "THERMO_*_PIN is now TEMP_n_CS_PIN, TEMP_n_SCK_PIN, TEMP_n_MOSI_PIN, TEMP_n_MISO_PIN." #elif defined(MAX31865_SENSOR_OHMS) #error "MAX31865_SENSOR_OHMS is now MAX31865_SENSOR_OHMS_0." #elif defined(MAX31865_CALIBRATION_OHMS) @@ -1953,14 +1964,21 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif /** - * Pins and Sensor IDs must be set for each heater + * Required MAX31865 settings */ -#if TEMP_SENSOR_0_IS_MAX6675 && !ANY_PIN(MAX6675_SS, MAX31855_CS, MAX31865_CS, MAX6675_CS) - #error "TEMP_SENSOR_0 -2 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." +#if TEMP_SENSOR_0_IS_MAX31865 || (TEMP_SENSOR_REDUNDANT_IS_MAX31865 && TEMP_SENSOR_REDUNDANT_SOURCE == 0) + #if !defined(MAX31865_SENSOR_WIRES_0) || !WITHIN(MAX31865_SENSOR_WIRES_0, 2, 4) + #error "MAX31865_SENSOR_WIRES_0 must be defined as an integer between 2 and 4." + #elif !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/TEMP_SENSOR_REDUNDANT is MAX31865." + #endif +#endif +#if TEMP_SENSOR_1_IS_MAX31865 || (TEMP_SENSOR_REDUNDANT_IS_MAX31865 && TEMP_SENSOR_REDUNDANT_SOURCE == 1) + #if !defined(MAX31865_SENSOR_WIRES_1) || !WITHIN(MAX31865_SENSOR_WIRES_1, 2, 4) + #error "MAX31865_SENSOR_WIRES_1 must be defined as an integer between 2 and 4." + #elif !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/TEMP_SENSOR_REDUNDANT is MAX31865." + #endif #endif /** @@ -2023,20 +2041,36 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TEMP_SENSOR_REDUNDANT_TARGET can't be Cooler (-5): requires TEMP_COOLER_PIN" #endif - #if TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 0 && !PIN_EXISTS(MAX6675_SS) - #error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE 0 requires a MAX6675_SS_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN." - #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1 && !PIN_EXISTS(MAX6675_SS2) - #error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE 1 requires a MAX6675_SS2_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN." + #if TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 0 && !PIN_EXISTS(TEMP_0_CS) + #error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE 0 requires TEMP_0_CS_PIN." + #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1 && !PIN_EXISTS(TEMP_1_CS) + #error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE 1 requires TEMP_1_CS_PIN." #endif #endif +/** + * Test Sensor & Heater pin combos. + * Pins and Sensor IDs must be set for each heater + */ +#if !ANY_PIN(TEMP_0, TEMP_0_CS) + #error "TEMP_0_PIN or TEMP_0_CS_PIN not defined for this board." +#elif !HAS_HEATER_0 && EXTRUDERS + #error "HEATER_0_PIN not defined for this board." +#elif TEMP_SENSOR_0_IS_MAX_TC && !PIN_EXISTS(TEMP_0_CS) + #error "TEMP_SENSOR_0 MAX thermocouple requires TEMP_0_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 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." + #if TEMP_SENSOR_1_IS_MAX_TC && !PIN_EXISTS(TEMP_1_CS) + #error "TEMP_SENSOR_1 MAX thermocouple requires TEMP_1_CS_PIN." #elif TEMP_SENSOR_1 == 0 #error "TEMP_SENSOR_1 is required with 2 or more HOTENDS." - #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 !ANY_PIN(TEMP_1, TEMP_1_CS) && !TEMP_SENSOR_1_IS_DUMMY + #error "TEMP_1_PIN or TEMP_1_CS_PIN not defined for this board." #endif #if HOTENDS > 2 #if TEMP_SENSOR_2 == 0 @@ -2148,14 +2182,31 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TEMP_SENSOR_6 shouldn't be set with only 1 HOTEND." #elif TEMP_SENSOR_7 != 0 #error "TEMP_SENSOR_7 shouldn't be set with only 1 HOTEND." -#endif +#endif // HAS_MULTI_HOTEND +/** + * Pins must be set for temp sensors, with some other feature requirements. + */ #if TEMP_SENSOR_CHAMBER && !PIN_EXISTS(TEMP_CHAMBER) #error "TEMP_SENSOR_CHAMBER requires TEMP_CHAMBER_PIN." #endif -#if TEMP_SENSOR_COOLER && !(PIN_EXISTS(TEMP_COOLER) && ENABLED(LASER_FEATURE)) - #error "TEMP_SENSOR_COOLER requires LASER_FEATURE and TEMP_COOLER_PIN." +#if TEMP_SENSOR_COOLER + #if !PIN_EXISTS(TEMP_COOLER) + #error "TEMP_SENSOR_COOLER requires TEMP_COOLER_PIN." + #elif DISABLED(LASER_FEATURE) + #error "TEMP_SENSOR_COOLER requires LASER_FEATURE." + #endif +#endif + +#if TEMP_SENSOR_PROBE + #if !PIN_EXISTS(TEMP_PROBE) + #error "TEMP_SENSOR_PROBE requires TEMP_PROBE_PIN." + #elif !HAS_TEMP_ADC_PROBE + #error "TEMP_PROBE_PIN must be an ADC pin." + #elif DISABLED(FIX_MOUNTED_PROBE) + #error "TEMP_SENSOR_PROBE shouldn't be set without FIX_MOUNTED_PROBE." + #endif #endif #if ENABLED(LASER_COOLANT_FLOW_METER) && !(PIN_EXISTS(FLOWMETER) && ENABLED(LASER_FEATURE)) @@ -2186,41 +2237,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif -#if TEMP_SENSOR_PROBE - #if !PIN_EXISTS(TEMP_PROBE) - #error "TEMP_SENSOR_PROBE requires TEMP_PROBE_PIN." - #elif !HAS_TEMP_ADC_PROBE - #error "TEMP_PROBE_PIN must be an ADC pin." - #elif DISABLED(FIX_MOUNTED_PROBE) - #error "TEMP_SENSOR_PROBE shouldn't be set without FIX_MOUNTED_PROBE." - #endif -#endif - -#if TEMP_SENSOR_IS_MAX(0, 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/TEMP_SENSOR_REDUNDANT is MAX31865." -#elif TEMP_SENSOR_IS_MAX(1, 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/TEMP_SENSOR_REDUNDANT is MAX31865." -#endif - -/** - * Test Heater, Temp Sensor, and Extruder Pins - */ -#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." -#endif - -#if HAS_EXTRUDERS - #if ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR)) - #error "E0_STEP_PIN or E0_DIR_PIN not defined for this board." - #elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE)) - #error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board." - #elif EXTRUDERS && TEMP_SENSOR_0 == 0 - #error "TEMP_SENSOR_0 is required if there are any extruders." - #endif -#endif - /** * Temperature status LEDs */ @@ -2262,6 +2278,16 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Test Extruder Stepper Pins */ +#if HAS_EXTRUDERS + #if ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR)) + #error "E0_STEP_PIN or E0_DIR_PIN not defined for this board." + #elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE)) + #error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board." + #elif EXTRUDERS && TEMP_SENSOR_0 == 0 + #error "TEMP_SENSOR_0 is required if there are any extruders." + #endif +#endif + #if E_STEPPERS #if !(PINS_EXIST(E0_STEP, E0_DIR) && HAS_E0_ENABLE) #error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board." diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 5fdcc7c728..9c9e2d3ee2 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-07-05" + #define STRING_DISTRIBUTION_DATE "2021-07-07" #endif /** diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h index 249c57b9c6..eb76bb9b2b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h @@ -32,9 +32,7 @@ class MediaFileReader { private: #if ENABLED(SDSUPPORT) - DiskIODriver_SPI_SD card; - SdVolume volume; - SdFile root, file; + SdFile root, file; #endif public: diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/screens.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/screens.h index 3a47d6bee4..87d31da6f6 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/screens.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/screens.h @@ -118,7 +118,6 @@ enum { #include "../generic/files_screen.h" #include "../generic/move_axis_screen.h" #include "../generic/flow_percent_screen.h" -#include "../generic/tune_menu.h" #if HAS_JUNCTION_DEVIATION #include "../generic/junction_deviation_screen.h" #else diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp index 38fdc2bb26..467d3b9119 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp @@ -294,4 +294,14 @@ void StatusScreen::onIdle() { } } +void StatusScreen::onMediaInserted() { + if (AT_SCREEN(StatusScreen)) + setStatusMessage(GET_TEXT_F(MSG_MEDIA_INSERTED)); +} + +void StatusScreen::onMediaRemoved() { + if (AT_SCREEN(StatusScreen) || ExtUI::isPrintingFromMedia()) + setStatusMessage(GET_TEXT_F(MSG_MEDIA_REMOVED)); +} + #endif // COCOA_STATUS_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.h index 1cddfa0896..75b4333351 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.h @@ -52,4 +52,6 @@ class StatusScreen : public BaseScreen, public CachedScreen static bool onTouchHeld(uint8_t tag); static bool onTouchEnd(uint8_t tag); static void onIdle(); + static void onMediaInserted(); + static void onMediaRemoved(); }; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/poly_ui.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/poly_ui.h index ba41650f2f..2e74ec3a47 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/poly_ui.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/poly_ui.h @@ -239,9 +239,11 @@ class DeduplicatedPolyReader : public POLY_READER { */ template> class GenericPolyUI { - private: + protected: CommandProcessor &cmd; + draw_mode_t mode; + private: // Attributes used to paint buttons uint32_t btn_fill_color = 0x000000; @@ -250,8 +252,6 @@ class GenericPolyUI { uint32_t btn_stroke_color = 0x000000; uint8_t btn_stroke_width = 28; - draw_mode_t mode; - public: enum ButtonStyle : uint8_t { FILL = 1, diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/file2cpp.py b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/file2cpp.py new file mode 100755 index 0000000000..25919c3c4d --- /dev/null +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/file2cpp.py @@ -0,0 +1,47 @@ +#!/usr/bin/python + +# Written By Marcio Teixeira 2021 - SynDaver Labs, Inc. +# +# 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. +# +# To view a copy of the GNU General Public License, go to the following +# location: . + +from __future__ import print_function +import argparse +import textwrap +import os +import zlib + +def deflate(data): + return zlib.compress(data) + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Converts a file into a packed C array for use as data') + parser.add_argument("input") + parser.add_argument("-d", "--deflate", action="store_true", help="Packs the data using the deflate algorithm") + args = parser.parse_args() + + varname = os.path.splitext(os.path.basename(args.input))[0]; + + with open(args.input, "rb") as in_file: + data = in_file.read() + if args.deflate: + data = deflate(data) + data = bytearray(data) + data = list(map(lambda a: "0x" + format(a, '02x'), data)) + nElements = len(data) + data = ', '.join(data) + data = textwrap.fill(data, 75, initial_indent = ' ', subsequent_indent = ' ') + + print("const unsigned char " + varname + "[" + format(nElements) + "] PROGMEM = {") + print(data) + print("};") diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/font2cpp.py b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/font2cpp.py new file mode 100755 index 0000000000..0c4499e9aa --- /dev/null +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/font2cpp.py @@ -0,0 +1,108 @@ +#!/usr/bin/python + +# Written By Marcio Teixeira 2019 - Aleph Objects, Inc. +# +# 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. +# +# To view a copy of the GNU General Public License, go to the following +# location: . + +from __future__ import print_function +from PIL import Image +import argparse +import textwrap + +def pack_rle(data): + """Use run-length encoding to pack the bytes""" + rle = [] + value = data[0] + count = 0 + for i in data: + if i != value or count == 255: + rle.append(count) + rle.append(value) + value = i + count = 1 + else: + count += 1 + rle.append(count) + rle.append(value) + return rle + +class WriteSource: + def __init__(self, lines_in_blocks): + self.blocks = [] + self.values = [] + self.block_size = lines_in_blocks + self.rows = 0 + + def add_pixel(self, value): + self.values.append(value) + + def convert_to_4bpp(self, data, chunk_size = 0): + # Invert the image + data = list(map(lambda i: 255 - i, data)) + # Quanitize 8-bit values into 4-bits + data = list(map(lambda i: i >> 4, data)) + # Make sure there is an even number of elements + if (len(data) & 1) == 1: + data.append(0) + # Combine each two adjacent values into one + i = iter(data) + data = list(map(lambda a, b: a << 4 | b, i ,i)) + # Pack the data + data = pack_rle(data) + # Convert values into hex strings + return list(map(lambda a: "0x" + format(a, '02x'), data)) + + def end_row(self, y): + # Pad each row into even number of values + if len(self.values) & 1: + self.values.append(0) + + self.rows += 1 + if self.block_size and (self.rows % self.block_size) == 0: + self.blocks.append(self.values) + self.values = [] + + def write(self): + if len(self.values): + self.blocks.append(self.values) + + block_strs = []; + for b in self.blocks: + data = self.convert_to_4bpp(b) + data = ', '.join(data) + data = textwrap.fill(data, 75, initial_indent = ' ', subsequent_indent = ' ') + block_strs.append(data) + + print("const unsigned char font[] PROGMEM = {") + for i, b in enumerate(block_strs): + if i: + print(',') + print('\n /* {} */'.format(i)) + print(b, end='') + print("\n};") + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Converts a grayscale bitmap into a 16-level RLE packed C array for use as font data') + parser.add_argument("input") + parser.add_argument('--char_height', help='Adds a separator every so many lines', type=int) + args = parser.parse_args() + + writer = WriteSource(args.char_height) + + img = Image.open(args.input).convert('L') + for y in range(img.height): + for x in range(img.width): + writer.add_pixel(img.getpixel((x,y))) + writer.end_row(y) + writer.write() diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/img2cpp.py b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/img2cpp.py new file mode 100755 index 0000000000..5908f5bf17 --- /dev/null +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/img2cpp.py @@ -0,0 +1,113 @@ +#!/usr/bin/python + +# Written By Marcio Teixeira 2021 - SynDaver Labs, Inc. +# +# 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. +# +# To view a copy of the GNU General Public License, go to the following +# location: . + +from __future__ import print_function +from PIL import Image +import argparse +import textwrap +import os +import sys +import zlib + +class WriteSource: + def __init__(self, mode): + self.values = [] + self.mode = mode + self.offset = 8 + self.byte = 0 + + def finish_byte(self): + if self.offset != 8: + self.values.append(self.byte) + self.offset = 8 + self.byte = 0 + + def add_bits_to_byte(self, value, size = 1): + self.offset -= size + self.byte = self.byte | value << self.offset + if self.offset == 0: + self.finish_byte() + + def append_rgb565(self, color): + value = ((color[0] & 0xF8) << 8) + ((color[1] & 0xFC) << 3) + ((color[2] & 0xF8) >> 3) + self.values.append((value & 0x00FF) >> 0); + self.values.append((value & 0xFF00) >> 8); + + def append_rgb332(self, color): + value = (color[0] & 0xE0) + ((color[1] & 0xE0) >> 3) + ((color[2] & 0xC0) >> 6) + self.values.append(value); + + def append_grayscale(self, color, bits): + luminance = int(0.2126 * color[0] + 0.7152 * color[1] + 0.0722 * color[2]) + self.add_bits_to_byte(luminance >> (8 - bits), bits) + + def deflate(self, data): + return zlib.compress(data) + + def add_pixel(self, color): + if self.mode == "l1": + self.append_grayscale(color, 1) + elif self.mode == "l2": + self.append_grayscale(color, 2) + elif self.mode == "l4": + self.append_grayscale(color, 4) + elif self.mode == "l8": + self.append_grayscale(color, 8) + elif self.mode == "rgb565": + self.append_rgb565(color) + elif self.mode == "rgb332": + self.append_rgb332(color) + + def end_row(self, y): + if self.mode in ["l1", "l2", "l3"]: + self.finish_byte() + + def write(self, varname, deflate): + print("Length of uncompressed data: ", len(self.values), file=sys.stderr) + data = bytes(bytearray(self.values)) + if deflate: + data = self.deflate(data) + print("Length of data after compression: ", len(data), file=sys.stderr) + data = bytearray(data) + data = list(map(lambda a: "0x" + format(a, '02x'), data)) + nElements = len(data) + data = ', '.join(data) + data = textwrap.fill(data, 75, initial_indent = ' ', subsequent_indent = ' ') + + print("const unsigned char " + varname + "[" + format(nElements) + "] PROGMEM = {") + print(data) + print("};") + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Converts a bitmap into a C array') + parser.add_argument("input") + parser.add_argument("-d", "--deflate", action="store_true", help="Packs the data using the deflate algorithm") + parser.add_argument("-m", "--mode", default="l1", help="Mode, can be l1, l2, l4, l8, rgb332 or rgb565") + args = parser.parse_args() + + varname = os.path.splitext(os.path.basename(args.input))[0]; + + writer = WriteSource(args.mode) + + img = Image.open(args.input) + print("Image height: ", img.height, file=sys.stderr) + print("Image width: ", img.width, file=sys.stderr) + for y in range(img.height): + for x in range(img.width): + writer.add_pixel(img.getpixel((x,y))) + writer.end_row(y) + writer.write(varname, args.deflate) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp index e06fb52773..3dfcd429a5 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp @@ -190,17 +190,11 @@ bool BedMeshEditScreen::onTouchEnd(uint8_t tag) { } void BedMeshEditScreen::show() { - // On entry, home if needed and save current mesh - if (!ExtUI::isMachineHomed()) { - SpinnerDialogBox::enqueueAndWait_P(F("G28\nG29 S1")); - // After the spinner, go to this screen. - current_screen.forget(); - PUSH_SCREEN(BedMeshEditScreen); - } - else { - injectCommands_P(PSTR("G29 S1")); - GOTO_SCREEN(BedMeshEditScreen); - } + // On entry, always home (to account for possible Z offset changes) and save current mesh + SpinnerDialogBox::enqueueAndWait_P(F("G28\nG29 S1")); + // After the spinner, go to this screen. + current_screen.forget(); + PUSH_SCREEN(BedMeshEditScreen); } #endif // FTDI_BED_MESH_EDIT_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp index 75b15828a2..552cd831ea 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp @@ -132,7 +132,6 @@ void BedMeshViewScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI mydata.count = GRID_MAX_POINTS; break; case ExtUI::G26_START: - GOTO_SCREEN(BedMeshViewScreen); mydata.message = nullptr; mydata.count = 0; break; @@ -161,7 +160,7 @@ void BedMeshViewScreen::doProbe() { void BedMeshViewScreen::doMeshValidation() { mydata.count = 0; GOTO_SCREEN(StatusScreen); - injectCommands_P(PSTR("M75\nG28 O\nM117 Heating...\nG26 R X0 Y0\nG27\nM77")); + injectCommands_P(PSTR("G28\nM117 Heating...\nG26 R X0 Y0\nG27")); } void BedMeshViewScreen::show() { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/boot_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/boot_screen.cpp index d2a2269295..c0940bed5c 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/boot_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/boot_screen.cpp @@ -83,8 +83,10 @@ void BootScreen::onIdle() { if (UIData::animations_enabled()) { // If there is a startup video in the flash SPI, play // that, otherwise show a static splash screen. - if (!MediaPlayerScreen::playBootMedia()) - showSplashScreen(); + #ifdef FTDI_MEDIA_PLAYER_SCREEN + if (!MediaPlayerScreen::playBootMedia()) + #endif + showSplashScreen(); } #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_user_request_alert_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_user_request_alert_box.cpp index 4aabbaab59..c10d372743 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_user_request_alert_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_user_request_alert_box.cpp @@ -35,12 +35,15 @@ void ConfirmUserRequestAlertBox::onRedraw(draw_mode_t mode) { bool ConfirmUserRequestAlertBox::onTouchEnd(uint8_t tag) { switch (tag) { case 1: - if (ExtUI::isPrintingPaused()) { - // The TuneMenu will call ExtUI::setUserConfirmed() - GOTO_SCREEN(TuneMenu); - current_screen.forget(); - } - else { + #ifdef FTDI_TUNE_MENU + if (ExtUI::isPrintingPaused()) { + // The TuneMenu will call ExtUI::setUserConfirmed() + GOTO_SCREEN(TuneMenu); + current_screen.forget(); + } + else + #endif + { ExtUI::setUserConfirmed(); GOTO_PREVIOUS(); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp index 826e01a9cf..797bb37996 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp @@ -83,6 +83,7 @@ void LevelingMenu::onRedraw(draw_mode_t what) { .font(font_medium).colors(normal_btn) .enabled(EITHER(Z_STEPPER_AUTO_ALIGN,MECHANICAL_GANTRY_CALIBRATION)) .tag(2).button(LEVEL_AXIS_POS, GET_TEXT_F(MSG_LEVEL_X_AXIS)) + .enabled(ENABLED(HAS_BED_PROBE)) .tag(3).button(PROBE_BED_POS, GET_TEXT_F(MSG_PROBE_BED)) .enabled(ENABLED(HAS_MESH)) .tag(4).button(SHOW_MESH_POS, GET_TEXT_F(MSG_SHOW_MESH)) @@ -101,30 +102,32 @@ void LevelingMenu::onRedraw(draw_mode_t what) { bool LevelingMenu::onTouchEnd(uint8_t tag) { switch (tag) { - case 1: GOTO_PREVIOUS(); break; + case 1: GOTO_PREVIOUS(); break; #if EITHER(Z_STEPPER_AUTO_ALIGN,MECHANICAL_GANTRY_CALIBRATION) - case 2: SpinnerDialogBox::enqueueAndWait_P(F("G34")); break; + case 2: SpinnerDialogBox::enqueueAndWait_P(F("G34")); break; #endif - case 3: - #ifndef BED_LEVELING_COMMANDS - #define BED_LEVELING_COMMANDS "G29" + #if ENABLED(HAS_BED_PROBE) + case 3: + #ifndef BED_LEVELING_COMMANDS + #define BED_LEVELING_COMMANDS "G29" + #endif + #if ENABLED(AUTO_BED_LEVELING_UBL) + BedMeshViewScreen::doProbe(); + #else + SpinnerDialogBox::enqueueAndWait_P(F(BED_LEVELING_COMMANDS)); + #endif + break; #endif #if ENABLED(AUTO_BED_LEVELING_UBL) - BedMeshViewScreen::doProbe(); - #else - SpinnerDialogBox::enqueueAndWait_P(F(BED_LEVELING_COMMANDS)); - #endif - break; - #if ENABLED(AUTO_BED_LEVELING_UBL) - case 4: BedMeshViewScreen::show(); break; - case 5: BedMeshEditScreen::show(); break; + case 4: BedMeshViewScreen::show(); break; + case 5: BedMeshEditScreen::show(); break; #endif #if ENABLED(G26_MESH_VALIDATION) - case 6: BedMeshViewScreen::doMeshValidation(); break; + case 6: BedMeshViewScreen::doMeshValidation(); break; #endif #if ENABLED(BLTOUCH) - case 7: injectCommands_P(PSTR("M280 P0 S60")); break; - case 8: SpinnerDialogBox::enqueueAndWait_P(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break; + case 7: injectCommands_P(PSTR("M280 P0 S60")); break; + case 8: SpinnerDialogBox::enqueueAndWait_P(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break; #endif default: return false; } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/tune_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/tune_menu.cpp index b4afae9f17..a5e2460631 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/tune_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/tune_menu.cpp @@ -77,8 +77,11 @@ void TuneMenu::onRedraw(draw_mode_t what) { .tag(3).button(FIL_CHANGE_POS, GET_TEXT_F(MSG_FILAMENTCHANGE)) .enabled(EITHER(LIN_ADVANCE, FILAMENT_RUNOUT_SENSOR)) .tag(9).button(FILAMENT_POS, GET_TEXT_F(MSG_FILAMENT)) - .enabled(BOTH(HAS_LEVELING, HAS_BED_PROBE) || ENABLED(BABYSTEPPING)) - .tag(4).button(NUDGE_NOZ_POS, GET_TEXT_F(TERN(BABYSTEPPING, MSG_NUDGE_NOZZLE, MSG_ZPROBE_ZOFFSET))) + #if ENABLED(BABYSTEPPING) && HAS_MULTI_HOTEND + .tag(4).button(NUDGE_NOZ_POS, GET_TEXT_F(MSG_NUDGE_NOZZLE)) + #elif BOTH(HAS_LEVELING, HAS_BED_PROBE) + .tag(4).button(NUDGE_NOZ_POS, GET_TEXT_F(MSG_ZPROBE_ZOFFSET)) + #endif .tag(5).button(SPEED_POS, GET_TEXT_F(MSG_PRINT_SPEED)) .enabled(sdOrHostPrinting) .tag(sdOrHostPaused ? 7 : 6) @@ -99,11 +102,11 @@ bool TuneMenu::onTouchEnd(uint8_t tag) { using namespace Theme; using namespace ExtUI; switch (tag) { - case 1: GOTO_PREVIOUS(); break; + case 1: SaveSettingsDialogBox::promptToSaveSettings(); break; case 2: GOTO_SCREEN(TemperatureScreen); break; case 3: GOTO_SCREEN(ChangeFilamentScreen); break; case 4: - #if ENABLED(BABYSTEPPING) + #if ENABLED(BABYSTEPPING) && HAS_MULTI_HOTEND GOTO_SCREEN(NudgeNozzleScreen); #elif BOTH(HAS_LEVELING, HAS_BED_PROBE) GOTO_SCREEN(ZOffsetScreen); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp index 073665e586..2a75596a03 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp @@ -53,7 +53,7 @@ void ZOffsetScreen::onRedraw(draw_mode_t what) { w.heading( GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); w.color(z_axis).adjuster(4, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), getZOffset_mm()); w.increments(); - w.button(2, GET_TEXT_F(MSG_PROBE_WIZARD), !isPrinting()); + w.button(2, GET_TEXT_F(MSG_PROBE_WIZARD), !isPrinting() && !wizardRunning()); } void ZOffsetScreen::move(float mm, int16_t steps) { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h index 4ac44501d5..0d883d8d02 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h @@ -130,7 +130,7 @@ namespace Language_en { PROGMEM Language_Str MSG_EEPROM_RESTORED = u8"Settings restored from backup"; PROGMEM Language_Str MSG_EEPROM_RESET = u8"Settings restored to default"; PROGMEM Language_Str MSG_EEPROM_SAVED = u8"Settings saved!"; - PROGMEM Language_Str MSG_EEPROM_SAVE_PROMPT = u8"Do you wish to save these settings for next power-on?"; + PROGMEM Language_Str MSG_EEPROM_SAVE_PROMPT = u8"Settings applied. Save these settings for next power-on?"; PROGMEM Language_Str MSG_EEPROM_RESET_WARNING = u8"Are you sure? Customizations will be lost."; PROGMEM Language_Str MSG_PASSCODE_REJECTED = u8"Wrong passcode!"; @@ -146,7 +146,7 @@ namespace Language_en { PROGMEM Language_Str MSG_AXIS_LEVELING = u8"Axis Leveling"; PROGMEM Language_Str MSG_PROBE_BED = u8"Probe Mesh"; PROGMEM Language_Str MSG_SHOW_MESH = u8"View Mesh"; - PROGMEM Language_Str MSG_PRINT_TEST = u8"Print Test"; + PROGMEM Language_Str MSG_PRINT_TEST = u8"Print Test (PLA)"; PROGMEM Language_Str MSG_MOVE_Z_TO_TOP = u8"Raise Z to Top"; #if ENABLED(TOUCH_UI_LULZBOT_BIO) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.h index 4fe4cb938a..fb3e909d2f 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.h @@ -40,7 +40,7 @@ extern tiny_timer_t refresh_timer; #if ENABLED(TOUCH_UI_LULZBOT_BIO) #include "bioprinter/screens.h" #elif ENABLED(TOUCH_UI_COCOA_PRESS) - #include "cocoapress/screens.h" + #include "cocoa_press/screens.h" #elif ENABLED(TOUCH_UI_SYNDAVER_LEVEL) #include "syndaver_level/screens.h" #else diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/bitmaps.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/bitmaps.h index 8c0366ebeb..f7cb63125f 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/bitmaps.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/bitmaps.h @@ -36,7 +36,7 @@ namespace Theme { .height = 23, }; - constexpr PROGMEM unsigned char Extruder_Icon[] = { + constexpr PROGMEM unsigned char Extruder_Icon[69] = { 0x3F, 0xFF, 0xFC, 0x7F, 0xFF, 0xFE, 0xC0, 0x00, 0x03, @@ -68,12 +68,12 @@ namespace Theme { .filter = BILINEAR, .wrapx = BORDER, .wrapy = BORDER, - .RAMG_offset = 8100, + .RAMG_offset = 8069, .width = 32, .height = 23, }; - constexpr PROGMEM unsigned char Bed_Heat_Icon[] = { + constexpr PROGMEM unsigned char Bed_Heat_Icon[92] = { 0x01, 0x81, 0x81, 0x80, 0x01, 0x81, 0x81, 0x80, 0x00, 0xC0, 0xC0, 0xC0, @@ -105,12 +105,12 @@ namespace Theme { .filter = BILINEAR, .wrapx = BORDER, .wrapy = BORDER, - .RAMG_offset = 8300, + .RAMG_offset = 8161, .width = 32, .height = 32, }; - constexpr PROGMEM unsigned char Fan_Icon[] = { + constexpr PROGMEM unsigned char Fan_Icon[128] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x1F, @@ -151,12 +151,12 @@ namespace Theme { .filter = BILINEAR, .wrapx = BORDER, .wrapy = BORDER, - .RAMG_offset = 9000, + .RAMG_offset = 8289, .width = 50, .height = 20, }; - constexpr PROGMEM unsigned char TD_Icon[] = { + constexpr PROGMEM unsigned char TD_Icon[140] = { 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, // Thumb Drive Widget 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x03, 0x80, @@ -179,5 +179,55 @@ namespace Theme { 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFC, 0x00 }; - constexpr PROGMEM uint32_t UTF8_FONT_OFFSET = 10000; + constexpr PROGMEM bitmap_info_t File_Icon_Info = { + .format = L1, + .linestride = 4, + .filter = BILINEAR, + .wrapx = BORDER, + .wrapy = BORDER, + .RAMG_offset = 8429, + .width = 25, + .height = 32, + }; + + const unsigned char File_Icon[128] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x00, 0x00, 0x40, 0x03, 0x00, 0x00, + 0x40, 0x02, 0x80, 0x00, 0x40, 0x02, 0x40, 0x00, 0x40, 0x02, 0x20, 0x00, + 0x40, 0x02, 0x10, 0x00, 0x40, 0x02, 0x08, 0x00, 0x40, 0x02, 0x04, 0x00, + 0x40, 0x02, 0x02, 0x00, 0x40, 0x03, 0xFF, 0x00, 0x40, 0x00, 0x01, 0x00, + 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, + 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, + 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, + 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, + 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, + 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x01, 0x00, + 0x7F, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + constexpr PROGMEM bitmap_info_t Clock_Icon_Info = { + .format = L1, + .linestride = 4, + .filter = BILINEAR, + .wrapx = BORDER, + .wrapy = BORDER, + .RAMG_offset = 8557, + .width = 32, + .height = 32, + }; + + const unsigned char Clock_Icon[128] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x7E, 0x7E, 0x00, + 0x00, 0xE0, 0x07, 0x00, 0x03, 0x80, 0x01, 0xC0, 0x07, 0x01, 0x00, 0xE0, + 0x0C, 0x01, 0x80, 0x70, 0x0C, 0x01, 0x80, 0x30, 0x18, 0x01, 0x80, 0x18, + 0x30, 0x01, 0x80, 0x08, 0x30, 0x01, 0x80, 0x0C, 0x20, 0x01, 0x80, 0x0C, + 0x60, 0x01, 0x80, 0x04, 0x60, 0x01, 0x80, 0x06, 0x60, 0x01, 0x80, 0x06, + 0x60, 0x01, 0xFF, 0x06, 0x60, 0x01, 0xFF, 0x06, 0x60, 0x00, 0x00, 0x06, + 0x60, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x0C, + 0x30, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x08, 0x18, 0x00, 0x00, 0x18, + 0x0C, 0x00, 0x00, 0x30, 0x0E, 0x00, 0x00, 0x70, 0x07, 0x00, 0x00, 0xE0, + 0x03, 0x80, 0x01, 0xC0, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x7F, 0xFE, 0x00, + 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + constexpr PROGMEM uint32_t UTF8_FONT_OFFSET = 10000; }; // namespace Theme diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 8d8b0e59e4..5efd74b8df 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -190,7 +190,11 @@ namespace ExtUI { void setHostResponse(const uint8_t); #endif - inline void simulateUserClick() { ui.lcd_clicked = true; } + inline void simulateUserClick() { + #if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) + ui.lcd_clicked = true; + #endif + } #if ENABLED(PRINTCOUNTER) char* getFailedPrints_str(char buffer[21]); diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index 4240ecbec3..bf2bb02ba3 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -127,23 +127,28 @@ namespace Language_ru { PROGMEM Language_Str MSG_COOLDOWN = _UxGT("Охлаждение"); PROGMEM Language_Str MSG_CUTTER_FREQUENCY = _UxGT("Частота"); PROGMEM Language_Str MSG_LASER_MENU = _UxGT("Управление лазером"); - PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Переключить лазер"); - PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Управление шпинделем"); - PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Переключить шпиндель"); #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Управление шпинделем"); + PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Переключить лазер"); + PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Переключ.шпиндель"); PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Мощность шпинделя"); PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Мощность лазера"); PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Тестовый импульс мс"); + PROGMEM Language_Str MSG_LASER_EVAC_TOGGLE = _UxGT("Переключить обдув"); + PROGMEM Language_Str MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Переключить вакуум"); #else + PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Управление шпинд."); + PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Переключ.лазер"); + PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Переключ.шпинд"); PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Мощн.шпинделя"); PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Мощн. лазера"); PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Тест. имп. мс"); + PROGMEM Language_Str MSG_LASER_EVAC_TOGGLE = _UxGT("Переключ. обдув"); + PROGMEM Language_Str MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Переключ. вакуум"); #endif - PROGMEM Language_Str MSG_LASER_EVAC_TOGGLE = _UxGT("Переключить обдув"); PROGMEM Language_Str MSG_LASER_ASSIST_TOGGLE = _UxGT("Управление обдувом"); PROGMEM Language_Str MSG_FLOWMETER_FAULT = _UxGT("Ошибка обдува"); PROGMEM Language_Str MSG_LASER_FIRE_PULSE = _UxGT("Импульс лазера"); - PROGMEM Language_Str MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Переключить вакуум"); PROGMEM Language_Str MSG_SPINDLE_FORWARD = _UxGT("Шпиндель вперёд"); PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Инверсия шпинделя"); @@ -356,13 +361,14 @@ namespace Language_ru { PROGMEM Language_Str MSG_NOZZLE_STANDBY = _UxGT("Сопло ожидает"); PROGMEM Language_Str MSG_BED = _UxGT("Стол, ") LCD_STR_DEGREE "C"; PROGMEM Language_Str MSG_CHAMBER = _UxGT("Камера,") LCD_STR_DEGREE "C"; - PROGMEM Language_Str MSG_COOLER = _UxGT("Охлаждение лазера"); #if LCD_WIDTH > 21 - PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Переключить охлаждение"); - PROGMEM Language_Str MSG_FLOWMETER_SAFETY = _UxGT("Безопасность потока"); - #else - PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Переключить охлажд."); + PROGMEM Language_Str MSG_COOLER = _UxGT("Охлаждение лазера"); + PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Переключ. охлажд."); PROGMEM Language_Str MSG_FLOWMETER_SAFETY = _UxGT("Безопасн. потока"); + #else + PROGMEM Language_Str MSG_COOLER = _UxGT("Охлажд. лазера"); + PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Переключ. охл."); + PROGMEM Language_Str MSG_FLOWMETER_SAFETY = _UxGT("Безопас.потока"); #endif PROGMEM Language_Str MSG_LASER = _UxGT("Лазер"); PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Кулер"); diff --git a/Marlin/src/lcd/language/language_uk.h b/Marlin/src/lcd/language/language_uk.h index 86d0e01fe6..cee795745c 100644 --- a/Marlin/src/lcd/language/language_uk.h +++ b/Marlin/src/lcd/language/language_uk.h @@ -34,7 +34,7 @@ namespace Language_uk { using namespace Language_en; // Inherit undefined strings from English constexpr uint8_t CHARSIZE = 2; - PROGMEM Language_Str LANGUAGE = _UxGT("Ukranian"); + PROGMEM Language_Str LANGUAGE = _UxGT("Ukrainian"); PROGMEM Language_Str WELCOME_MSG = MACHINE_NAME _UxGT(" Готовий."); PROGMEM Language_Str MSG_YES = _UxGT("ТАК"); @@ -133,23 +133,24 @@ namespace Language_uk { PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Керування шпінделем"); #if LCD_WIDTH > 21 PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Потужність лазера"); - #else - PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Потуж.лазера"); - #endif - PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Перемкнути шпіндель"); - PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Перемкнути лазер"); - #if LCD_WIDTH > 21 - PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Потуж. шпінделя"); + PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Перемкн. шпіндель"); + PROGMEM Language_Str MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Перемкнути вакуум"); + PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Перемкнути лазер"); + PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Потужн. шпінделя"); PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Тестовий імпульс мс"); + PROGMEM Language_Str MSG_LASER_EVAC_TOGGLE = _UxGT("Перемкнути обдув"); #else - PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Потуж. шпінд."); - PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Тест. імп. мс"); + PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Потужн. лазера"); + PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Перемк. шпінд."); + PROGMEM Language_Str MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Перемк. вакуум"); + PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Перемкн. лазер"); + PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Потужн. шпінд."); + PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Тест. імп., мс"); + PROGMEM Language_Str MSG_LASER_EVAC_TOGGLE = _UxGT("Перемкн. обдув"); #endif - PROGMEM Language_Str MSG_LASER_EVAC_TOGGLE = _UxGT("Перемкнути обдув"); PROGMEM Language_Str MSG_LASER_ASSIST_TOGGLE = _UxGT("Керування обдувом"); PROGMEM Language_Str MSG_FLOWMETER_FAULT = _UxGT("Помилка обдуву"); PROGMEM Language_Str MSG_LASER_FIRE_PULSE = _UxGT("Імпульс лазеру"); - PROGMEM Language_Str MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Перемкнути вакуум"); PROGMEM Language_Str MSG_SPINDLE_FORWARD = _UxGT("Шпіндель вперед"); PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Шпіндель назад"); @@ -361,18 +362,19 @@ namespace Language_uk { PROGMEM Language_Str MSG_NOZZLE_STANDBY = _UxGT("Сопло очікує"); PROGMEM Language_Str MSG_BED = _UxGT("Стіл, ") LCD_STR_DEGREE "C"; PROGMEM Language_Str MSG_CHAMBER = _UxGT("Камера,") LCD_STR_DEGREE "C"; - PROGMEM Language_Str MSG_COOLER = _UxGT("Охолодження лазеру"); #if LCD_WIDTH > 21 - PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Перемкнути охолодження"); + PROGMEM Language_Str MSG_COOLER = _UxGT("Охолодження лазеру"); + PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Перемк. охолодж."); #else - PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Перемкнути охолодж."); + PROGMEM Language_Str MSG_COOLER = _UxGT("Охолодж. лазеру"); + PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Перемк.охолод"); #endif PROGMEM Language_Str MSG_FLOWMETER_SAFETY = _UxGT("Безпека потоку"); PROGMEM Language_Str MSG_LASER = _UxGT("Лазер"); PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Швидк. вент."); PROGMEM Language_Str MSG_FAN_SPEED_N = _UxGT("Швидк. вент. ~"); #if LCD_WIDTH > 21 - PROGMEM Language_Str MSG_STORED_FAN_N = _UxGT("Збереж. швидк. вент. ~"); + PROGMEM Language_Str MSG_STORED_FAN_N = _UxGT("Збереж.швидк.вент. ~"); PROGMEM Language_Str MSG_EXTRA_FAN_SPEED_N = _UxGT("Дод. швидк. вент. ~"); #else PROGMEM Language_Str MSG_STORED_FAN_N = _UxGT("Збереж. вент. ~"); @@ -391,8 +393,8 @@ namespace Language_uk { PROGMEM Language_Str MSG_MAX = " " LCD_STR_THERMOMETER ", " LCD_STR_DEGREE _UxGT("С макс"); PROGMEM Language_Str MSG_FACTOR = " " LCD_STR_THERMOMETER _UxGT(" Фактор"); PROGMEM Language_Str MSG_AUTOTEMP = _UxGT("Автотемпер."); - PROGMEM Language_Str MSG_LCD_ON = _UxGT("Увімк"); - PROGMEM Language_Str MSG_LCD_OFF = _UxGT("Вимк."); + PROGMEM Language_Str MSG_LCD_ON = _UxGT("Увім"); + PROGMEM Language_Str MSG_LCD_OFF = _UxGT("Вимк"); PROGMEM Language_Str MSG_PID_AUTOTUNE = _UxGT("Автопідбір PID"); PROGMEM Language_Str MSG_PID_AUTOTUNE_E = _UxGT("Автопідбір PID *"); @@ -426,8 +428,12 @@ namespace Language_uk { PROGMEM Language_Str MSG_VMAX_K = _UxGT("Швидк.макс ") LCD_STR_K; PROGMEM Language_Str MSG_VMAX_E = _UxGT("Швидк.макс ") LCD_STR_E; PROGMEM Language_Str MSG_VMAX_EN = _UxGT("Швидк.макс *"); - PROGMEM Language_Str MSG_VMIN = _UxGT("Швидк.мін"); - PROGMEM Language_Str MSG_VTRAV_MIN = _UxGT("Переміщення мін"); + PROGMEM Language_Str MSG_VMIN = _UxGT("Швидк. мін"); + #if LCD_WIDTH > 21 + PROGMEM Language_Str MSG_VTRAV_MIN = _UxGT("Переміщення мін"); + #else + PROGMEM Language_Str MSG_VTRAV_MIN = _UxGT("Переміщ. мін"); + #endif PROGMEM Language_Str MSG_ACCELERATION = _UxGT("Прискорення, мм/с2"); PROGMEM Language_Str MSG_AMAX_A = _UxGT("Приск.макс ") LCD_STR_A; PROGMEM Language_Str MSG_AMAX_B = _UxGT("Приск.макс ") LCD_STR_B; diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index 0f2bd3cb1f..0a4f4bb7d1 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -434,23 +434,23 @@ class MenuItem_bool : public MenuEditItemBase { }while(0) // Indexed items set a global index value -#define _CONFIRM_ITEM_N_P(N, V...) _CONFIRM_ITEM_N_S_P(N, nullptr, V) +#define _CONFIRM_ITEM_N_P(N, V...) _CONFIRM_ITEM_N_S_P(N, nullptr, V) -#define CONFIRM_ITEM_P(PLABEL,A,B,V...) _CONFIRM_ITEM_P(PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) -#define CONFIRM_ITEM(LABEL, V...) CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V) +#define CONFIRM_ITEM_P(PLABEL,A,B,V...) _CONFIRM_ITEM_P(PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) +#define CONFIRM_ITEM(LABEL, V...) CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V) -#define YESNO_ITEM_P(PLABEL, V...) _CONFIRM_ITEM_P(PLABEL, ##V) -#define YESNO_ITEM(LABEL, V...) YESNO_ITEM_P(GET_TEXT(LABEL), ##V) +#define YESNO_ITEM_P(PLABEL, V...) CONFIRM_ITEM_P(PLABEL, MSG_YES, MSG_NO, ##V) +#define YESNO_ITEM(LABEL, V...) YESNO_ITEM_P(GET_TEXT(LABEL), ##V) #define CONFIRM_ITEM_N_S_P(N,S,PLABEL,A,B,V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) #define CONFIRM_ITEM_N_S(N,S,LABEL,V...) CONFIRM_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V) #define CONFIRM_ITEM_N_P(N,PLABEL,A,B,V...) _CONFIRM_ITEM_N_P(N, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) #define CONFIRM_ITEM_N(N,LABEL, V...) CONFIRM_ITEM_N_P(N, GET_TEXT(LABEL), ##V) -#define YESNO_ITEM_N_S_P(N,S,PLABEL, V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, ##V) -#define YESNO_ITEM_N_S(N,S,LABEL, V...) YESNO_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V) -#define YESNO_ITEM_N_P(N,PLABEL, V...) _CONFIRM_ITEM_N_P(N, PLABEL, ##V) -#define YESNO_ITEM_N(N,LABEL, V...) YESNO_ITEM_N_P(N, GET_TEXT(LABEL), ##V) +#define YESNO_ITEM_N_S_P(N,S,PLABEL, V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, MSG_YES, MSG_NO, ##V) +#define YESNO_ITEM_N_S(N,S,LABEL, V...) YESNO_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V) +#define YESNO_ITEM_N_P(N,PLABEL, V...) CONFIRM_ITEM_N_P(N, PLABEL, MSG_YES, MSG_NO, ##V) +#define YESNO_ITEM_N(N,LABEL, V...) YESNO_ITEM_N_P(N, GET_TEXT(LABEL), ##V) #if ENABLED(LEVEL_BED_CORNERS) void _lcd_level_bed_corners(); diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 4e3310f238..6f32ef1d60 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -364,8 +364,7 @@ void menu_main() { #if ENABLED(ADVANCED_PAUSE_FEATURE) #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES) - CONFIRM_ITEM(MSG_FILAMENTCHANGE, - MSG_YES, MSG_NO, + YESNO_ITEM(MSG_FILAMENTCHANGE, menu_change_filament, ui.goto_previous_screen, GET_TEXT(MSG_FILAMENTCHANGE), (const char *)nullptr, PSTR("?") ); diff --git a/Marlin/src/libs/MAX31865.cpp b/Marlin/src/libs/MAX31865.cpp new file mode 100644 index 0000000000..590dea5ca5 --- /dev/null +++ b/Marlin/src/libs/MAX31865.cpp @@ -0,0 +1,500 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Based on Based on Adafruit MAX31865 library: + * + * This is a library for the Adafruit PT100/P1000 RTD Sensor w/MAX31865 + * Designed specifically to work with the Adafruit RTD Sensor + * https://www.adafruit.com/products/3328 + * + * This sensor uses SPI to communicate, 4 pins are required to interface. + * + * Adafruit invests time and resources providing this open source code, + * please support Adafruit and open-source hardware by purchasing + * products from Adafruit! + * + * Written by Limor Fried/Ladyada for Adafruit Industries. + * + * Modifications by JoAnn Manges (@GadgetAngel) + * Copyright (c) 2020, JoAnn Manges + * All rights reserved. + */ + +// Useful for RTD debugging. +//#define MAX31865_DEBUG +//#define MAX31865_DEBUG_SPI + +//TODO: switch to SPIclass/SoftSPI + +#include "../inc/MarlinConfig.h" + +#if HAS_MAX31865 && !LIB_USR_MAX31865 + +#include "MAX31865.h" + +// The maximum speed the MAX31865 can do is 5 MHz +SPISettings MAX31865::spiConfig = SPISettings( + #if defined(TARGET_LPC1768) + SPI_QUARTER_SPEED + #elif defined(ARDUINO_ARCH_STM32) + SPI_CLOCK_DIV4 + #else + 500000 + #endif + , MSBFIRST + , SPI_MODE_1 // CPOL0 CPHA1 +); + +#ifndef LARGE_PINMAP + + /** + * Create the interface object using software (bitbang) SPI for PIN values + * less than or equal to 127. + * + * @param spi_cs the SPI CS pin to use + * @param spi_mosi the SPI MOSI pin to use + * @param spi_miso the SPI MISO pin to use + * @param spi_clk the SPI clock pin to use + */ + MAX31865::MAX31865(int8_t spi_cs, int8_t spi_mosi, int8_t spi_miso, int8_t spi_clk) { + _cs = spi_cs; + _mosi = spi_mosi; + _miso = spi_miso; + _sclk = spi_clk; + } + + /** + * Create the interface object using hardware SPI for PIN for PIN values less + * than or equal to 127. + * + * @param spi_cs the SPI CS pin to use along with the default SPI device + */ + MAX31865::MAX31865(int8_t spi_cs) { + _cs = spi_cs; + _sclk = _miso = _mosi = -1; + } + +#else + + /** + * Create the interface object using software (bitbang) SPI for PIN values + * which are larger than 127. If you have PIN values less than or equal to + * 127 use the other call for SW SPI. + * + * @param spi_cs the SPI CS pin to use + * @param spi_mosi the SPI MOSI pin to use + * @param spi_miso the SPI MISO pin to use + * @param spi_clk the SPI clock pin to use + * @param pin_mapping set to 1 for positive pin values + */ + MAX31865::MAX31865(uint32_t spi_cs, uint32_t spi_mosi, + uint32_t spi_miso, uint32_t spi_clk, + uint8_t pin_mapping) { + _cs = spi_cs; + _mosi = spi_mosi; + _miso = spi_miso; + _sclk = spi_clk; + } + + /** + * Create the interface object using hardware SPI for PIN values which are + * larger than 127. If you have PIN values less than or equal to 127 use + * the other call for HW SPI. + * + * @param spi_cs the SPI CS pin to use along with the default SPI device + * @param pin_mapping set to 1 for positive pin values + */ + MAX31865::MAX31865(uint32_t spi_cs, uint8_t pin_mapping) { + _cs = spi_cs; + _sclk = _miso = _mosi = -1UL; //-1UL or 0xFFFFFFFF or 4294967295 + } + +#endif // LARGE_PINMAP + + +/** + * + * Instance & Class methods + * + */ + + +/** + * Initialize the SPI interface and set the number of RTD wires used + * + * @param wires The number of wires in enum format. Can be MAX31865_2WIRE, MAX31865_3WIRE, or MAX31865_4WIRE. + * @param zero The resistance of the RTD at 0 degC, in ohms. + * @param ref The resistance of the reference resistor, in ohms. + */ +void MAX31865::begin(max31865_numwires_t wires, float zero, float ref) { + Rzero = zero; + Rref = ref; + + OUT_WRITE(_cs, HIGH); + + if (_sclk != TERN(LARGE_PINMAP, -1UL, -1)) { + // define pin modes for Software SPI + #ifdef MAX31865_DEBUG + SERIAL_ECHOLN("Initializing MAX31865 Software SPI"); + #endif + + OUT_WRITE(_sclk, LOW); + SET_OUTPUT(_mosi); + SET_INPUT(_miso); + } else { + // start and configure hardware SPI + #ifdef MAX31865_DEBUG + SERIAL_ECHOLN("Initializing MAX31865 Hardware SPI"); + #endif + + SPI.begin(); + } + + setWires(wires); + enableBias(false); + autoConvert(false); + clearFault(); + + #ifdef MAX31865_DEBUG_SPI + #ifndef LARGE_PINMAP + SERIAL_ECHOLNPAIR( + "Regular begin call with _cs: ", _cs, + " _miso: ", _miso, + " _sclk: ", _sclk, + " _mosi: ", _mosi + ); + #else + SERIAL_ECHOLNPAIR( + "LARGE_PINMAP begin call with _cs: ", _cs, + " _miso: ", _miso, + " _sclk: ", _sclk, + " _mosi: ", _mosi + ); + #endif // LARGE_PINMAP + + SERIAL_ECHOLNPAIR("config: ", readRegister8(MAX31856_CONFIG_REG)); + SERIAL_EOL(); + #endif // MAX31865_DEBUG_SPI +} + +/** + * Read the raw 8-bit FAULTSTAT register + * + * @return The raw unsigned 8-bit FAULT status register + */ +uint8_t MAX31865::readFault() { + return readRegister8(MAX31856_FAULTSTAT_REG); +} + +/** + * Clear all faults in FAULTSTAT. + */ +void MAX31865::clearFault() { + setConfig(MAX31856_CONFIG_FAULTSTAT, 1); +} + +/** + * Whether we want to have continuous conversions (50/60 Hz) + * + * @param b If true, auto conversion is enabled + */ +void MAX31865::autoConvert(bool b) { + setConfig(MAX31856_CONFIG_MODEAUTO, b); +} + +/** + * Whether we want filter out 50Hz noise or 60Hz noise + * + * @param b If true, 50Hz noise is filtered, else 60Hz(default) + */ +void MAX31865::enable50HzFilter(bool b) { + setConfig(MAX31856_CONFIG_FILT50HZ, b); +} + +/** + * Enable the bias voltage on the RTD sensor + * + * @param b If true bias is enabled, else disabled + */ +void MAX31865::enableBias(bool b) { + setConfig(MAX31856_CONFIG_BIAS, b); + + // From the datasheet: + // Note that if VBIAS is off (to reduce supply current between conversions), any filter + // capacitors at the RTDIN inputs need to charge before an accurate conversion can be + // performed. Therefore, enable VBIAS and wait at least 10.5 time constants of the input + // RC network plus an additional 1ms before initiating the conversion. + if (b) + DELAY_US(11500); //11.5ms +} + +/** + * Start a one-shot temperature reading. + */ +void MAX31865::oneShot() { + setConfig(MAX31856_CONFIG_1SHOT, 1); + + // From the datasheet: + // Note that a single conversion requires approximately 52ms in 60Hz filter + // mode or 62.5ms in 50Hz filter mode to complete. 1-Shot is a self-clearing bit. + // TODO: switch this out depeding on the filter mode. + DELAY_US(65000); // 65ms +} + +/** + * How many wires we have in our RTD setup, can be MAX31865_2WIRE, + * MAX31865_3WIRE, or MAX31865_4WIRE + * + * @param wires The number of wires in enum format + */ +void MAX31865::setWires(max31865_numwires_t wires) { + uint8_t t = readRegister8(MAX31856_CONFIG_REG); + if (wires == MAX31865_3WIRE) + t |= MAX31856_CONFIG_3WIRE; + else // 2 or 4 wire + t &= ~MAX31856_CONFIG_3WIRE; + writeRegister8(MAX31856_CONFIG_REG, t); +} + +/** + * Read the raw 16-bit value from the RTD_REG in one shot mode. This will include + * the fault bit, D0. + * + * @return The raw unsigned 16-bit register value with ERROR bit attached, NOT temperature! + */ +uint16_t MAX31865::readRaw() { + clearFault(); + enableBias(true); + + oneShot(); + uint16_t rtd = readRegister16(MAX31856_RTDMSB_REG); + + #ifdef MAX31865_DEBUG + SERIAL_ECHOLNPAIR("RTD MSB:", (rtd >> 8), " RTD LSB:", (rtd & 0x00FF)); + #endif + + // Disable the bias to lower power dissipation between reads. + // If the ref resistor heats up, the temperature reading will be skewed. + enableBias(false); + + return rtd; +} + +/** + * Calulate and return the resistance value of the connected RTD. + * + * @param refResistor The value of the matching reference resistor, usually 430 or 4300 + * @return The raw RTD resistance value, NOT temperature! + */ +float MAX31865::readResistance() { + // Strip the error bit (D0) and convert to a float ratio. + // less precise method: (readRaw() * Rref) >> 16 + return (((readRaw() >> 1) / 32768.0f) * Rref); +} + +/** + * Read the RTD and pass it to temperature(float) for calculation. + * + * @return Temperature in C + */ +float MAX31865::temperature() { + return temperature(readResistance()); +} + +/** + * Given the 15-bit ADC value, calculate the resistance and pass it to temperature(float) for calculation. + * + * @return Temperature in C + */ +float MAX31865::temperature(uint16_t adcVal) { + return temperature(((adcVal) / 32768.0f) * Rref); +} + +/** + * Calculate the temperature in C from the RTD resistance. + * Uses the technique outlined in this PDF: + * http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf + * + * @param Rrtd the resistance value in ohms + * @return the temperature in degC + */ +float MAX31865::temperature(float Rrtd) { + float temp = (RTD_Z1 + sqrt(RTD_Z2 + (RTD_Z3 * Rrtd))) / RTD_Z4; + + // From the PDF... + // + // The previous equation is valid only for temperatures of 0°C and above. + // The equation for RRTD(t) that defines negative temperature behavior is a + // fourth-order polynomial (after expanding the third term) and is quite + // impractical to solve for a single expression of temperature as a function + // of resistance. + // + if (temp < 0) { + Rrtd = (Rrtd / Rzero) * 100; // normalize to 100 ohm + float rpoly = Rrtd; + + temp = -242.02 + (2.2228 * rpoly); + rpoly *= Rrtd; // square + temp += 2.5859e-3 * rpoly; + rpoly *= Rrtd; // ^3 + temp -= 4.8260e-6 * rpoly; + rpoly *= Rrtd; // ^4 + temp -= 2.8183e-8 * rpoly; + rpoly *= Rrtd; // ^5 + temp += 1.5243e-10 * rpoly; + } + + return temp; +} + +// +// private: +// + + +/** + * Set a value in the configuration register. + * + * @param config 8-bit value for the config item + * @param enable whether to enable or disable the value + */ +void MAX31865::setConfig(uint8_t config, bool enable) { + uint8_t t = readRegister8(MAX31856_CONFIG_REG); + if (enable) + t |= config; + else + t &= ~config; // disable + writeRegister8(MAX31856_CONFIG_REG, t); +} + +/** + * Read a single byte from the specified register address. + * + * @param addr the register address + * @return the register contents + */ +uint8_t MAX31865::readRegister8(uint8_t addr) { + uint8_t ret = 0; + readRegisterN(addr, &ret, 1); + + return ret; +} + +/** + * Read two bytes: 1 from the specified register address, and 1 from the next address. + * + * @param addr the first register address + * @return both register contents as a single 16-bit int + */ +uint16_t MAX31865::readRegister16(uint8_t addr) { + uint8_t buffer[2] = {0, 0}; + readRegisterN(addr, buffer, 2); + + uint16_t ret = buffer[0]; + ret <<= 8; + ret |= buffer[1]; + + return ret; +} + +/** + * Read +n+ bytes from a specified address into +buffer+. Set D7 to 0 to specify a read. + * + * @param addr the first register address + * @param buffer storage for the read bytes + * @param n the number of bytes to read + */ +void MAX31865::readRegisterN(uint8_t addr, uint8_t buffer[], uint8_t n) { + addr &= 0x7F; // make sure top bit is not set + if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) + SPI.beginTransaction(spiConfig); + else + WRITE(_sclk, LOW); + + WRITE(_cs, LOW); + spixfer(addr); + + while (n--) { + buffer[0] = spixfer(0xFF); + #ifdef MAX31865_DEBUG_SPI + SERIAL_ECHOLNPAIR("buffer read ", n, " data: ", buffer[0]); + #endif + buffer++; + } + + if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) + SPI.endTransaction(); + + WRITE(_cs, HIGH); +} + +/** + * Write an 8-bit value to a register. Set D7 to 1 to specify a write. + * + * @param addr the address to write to + * @param data the data to write + */ +void MAX31865::writeRegister8(uint8_t addr, uint8_t data) { + if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) + SPI.beginTransaction(spiConfig); + else + WRITE(_sclk, LOW); + + WRITE(_cs, LOW); + + spixfer(addr | 0x80); // make sure top bit is set + spixfer(data); + + if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) + SPI.endTransaction(); + + WRITE(_cs, HIGH); +} + +/** + * Transfer SPI data +x+ and read the response. From the datasheet... + * Input data (SDI) is latched on the internal strobe edge and output data (SDO) is + * shifted out on the shift edge. There is one clock for each bit transferred. + * Address and data bits are transferred in groups of eight, MSB first. + * + * @param x an 8-bit chunk of data to write + * @return the 8-bit response + */ +uint8_t MAX31865::spixfer(uint8_t x) { + if (_sclk == TERN(LARGE_PINMAP, -1UL, -1)) + return SPI.transfer(x); + + uint8_t reply = 0; + for (int i = 7; i >= 0; i--) { + reply <<= 1; + WRITE(_sclk, HIGH); + WRITE(_mosi, x & (1 << i)); + WRITE(_sclk, LOW); + if (READ(_miso)) + reply |= 1; + } + + return reply; +} + +#endif // HAS_MAX31865 && !LIB_USR_MAX31865 diff --git a/Marlin/src/libs/MAX31865.h b/Marlin/src/libs/MAX31865.h new file mode 100644 index 0000000000..2ab78ecbe8 --- /dev/null +++ b/Marlin/src/libs/MAX31865.h @@ -0,0 +1,131 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Based on Adafruit MAX31865 library: + * + * This is a library for the Adafruit PT100/P1000 RTD Sensor w/MAX31865 + * Designed specifically to work with the Adafruit RTD Sensor + * https://www.adafruit.com/products/3328 + * + * This sensor uses SPI to communicate, 4 pins are required to interface. + * + * Adafruit invests time and resources providing this open source code, + * please support Adafruit and open-source hardware by purchasing + * products from Adafruit! + * + * Written by Limor Fried/Ladyada for Adafruit Industries. + * + * Modifications by JoAnn Manges (@GadgetAngel) + * Copyright (c) 2020, JoAnn Manges + * All rights reserved. + */ +#pragma once + +#include "../inc/MarlinConfig.h" +#include "../HAL/shared/Delay.h" +#include HAL_PATH(../HAL, MarlinSPI.h) + +#define MAX31856_CONFIG_REG 0x00 +#define MAX31856_CONFIG_BIAS 0x80 +#define MAX31856_CONFIG_MODEAUTO 0x40 +#define MAX31856_CONFIG_MODEOFF 0x00 +#define MAX31856_CONFIG_1SHOT 0x20 +#define MAX31856_CONFIG_3WIRE 0x10 +#define MAX31856_CONFIG_24WIRE 0x00 +#define MAX31856_CONFIG_FAULTSTAT 0x02 +#define MAX31856_CONFIG_FILT50HZ 0x01 +#define MAX31856_CONFIG_FILT60HZ 0x00 + +#define MAX31856_RTDMSB_REG 0x01 +#define MAX31856_RTDLSB_REG 0x02 +#define MAX31856_HFAULTMSB_REG 0x03 +#define MAX31856_HFAULTLSB_REG 0x04 +#define MAX31856_LFAULTMSB_REG 0x05 +#define MAX31856_LFAULTLSB_REG 0x06 +#define MAX31856_FAULTSTAT_REG 0x07 + +#define MAX31865_FAULT_HIGHTHRESH 0x80 // D7 +#define MAX31865_FAULT_LOWTHRESH 0x40 // D6 +#define MAX31865_FAULT_REFINLOW 0x20 // D5 +#define MAX31865_FAULT_REFINHIGH 0x10 // D4 +#define MAX31865_FAULT_RTDINLOW 0x08 // D3 +#define MAX31865_FAULT_OVUV 0x04 // D2 + +// http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf +// constants for calulating temperature from the measured RTD resistance. +#define RTD_Z1 -0.0039083 +#define RTD_Z2 0.00001758480889 +#define RTD_Z3 -0.0000000231 +#define RTD_Z4 -0.000001155 + +typedef enum max31865_numwires { + MAX31865_2WIRE = 0, + MAX31865_3WIRE = 1, + MAX31865_4WIRE = 0 +} max31865_numwires_t; + +/* Interface class for the MAX31865 RTD Sensor reader */ +class MAX31865 { +private: + static SPISettings spiConfig; + + TERN(LARGE_PINMAP, uint32_t, uint8_t) _sclk, _miso, _mosi, _cs; + float Rzero, Rref; + + void setConfig(uint8_t config, bool enable); + + void readRegisterN(uint8_t addr, uint8_t buffer[], uint8_t n); + uint8_t readRegister8(uint8_t addr); + uint16_t readRegister16(uint8_t addr); + + void writeRegister8(uint8_t addr, uint8_t reg); + uint8_t spixfer(uint8_t addr); + +public: + #ifdef LARGE_PINMAP + MAX31865(uint32_t spi_cs, uint8_t pin_mapping); + MAX31865(uint32_t spi_cs, uint32_t spi_mosi, uint32_t spi_miso, + uint32_t spi_clk, uint8_t pin_mapping); + #else + MAX31865(int8_t spi_cs); + MAX31865(int8_t spi_cs, int8_t spi_mosi, int8_t spi_miso, + int8_t spi_clk); + #endif + + void begin(max31865_numwires_t wires, float zero, float ref); + + uint8_t readFault(); + void clearFault(); + + void setWires(max31865_numwires_t wires); + void autoConvert(bool b); + void enable50HzFilter(bool b); + void enableBias(bool b); + void oneShot(); + + uint16_t readRaw(); + float readResistance(); + float temperature(); + float temperature(uint16_t adcVal); + float temperature(float Rrtd); +}; diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 63fdd5afc3..eb6dc6597c 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -703,8 +703,7 @@ void restore_feedrate_and_scaling() { * at the same positions relative to the machine. */ void update_software_endstops(const AxisEnum axis - OPTARG(HAS_HOTEND_OFFSET, const uint8_t old_tool_index/*=0*/) - OPTARG(HAS_HOTEND_OFFSET, const uint8_t new_tool_index/*=0*/) + OPTARG(HAS_HOTEND_OFFSET, const uint8_t old_tool_index/*=0*/, const uint8_t new_tool_index/*=0*/) ) { #if ENABLED(DUAL_X_CARRIAGE) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 9f32ce933b..83187259ff 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -34,6 +34,7 @@ #include "temperature.h" #include "endstops.h" #include "planner.h" +#include "printcounter.h" #if EITHER(HAS_COOLER, LASER_COOLANT_FLOW_METER) #include "../feature/cooler.h" @@ -56,112 +57,56 @@ #include "../feature/host_actions.h" #endif -#define TEMP_SENSOR_IS_ANY_MAX_TC(n) (ENABLED(TEMP_SENSOR_##n##_IS_MAX_TC) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX_TC) && ENABLED(TEMP_SENSOR_REDUNDANT_SOURCE) && TEMP_SENSOR_REDUNDANT_SOURCE == n)) - -// 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 TEMP_SENSOR_IS_MAX(0, 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 - #if ENABLED(LARGE_PINMAP) - , HIGH - #endif - ); - #endif - #if TEMP_SENSOR_IS_MAX(1, 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 - #if ENABLED(LARGE_PINMAP) - , HIGH - #endif - ); - #endif -#endif - -// 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 - #endif - #if PIN_EXISTS(MAX31865_MISO) && PIN_EXISTS(MAX31865_SCK) - #define MAX31865_USES_SW_SPI 1 - #endif - #if TEMP_SENSOR_IS_MAX(0, 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 - #if ENABLED(LARGE_PINMAP) - , HIGH - #endif - ); - #endif - #if TEMP_SENSOR_IS_MAX(1, 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 - #if ENABLED(LARGE_PINMAP) - , HIGH - #endif - ); - #endif -#endif +// MAX TC related macros +#define TEMP_SENSOR_IS_MAX(n, M) (ENABLED(TEMP_SENSOR_##n##_IS_MAX##M) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX##M) && TEMP_SENSOR_REDUNDANT_SOURCE == (n))) +#define TEMP_SENSOR_IS_ANY_MAX_TC(n) (ENABLED(TEMP_SENSOR_##n##_IS_MAX_TC) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX_TC) && TEMP_SENSOR_REDUNDANT_SOURCE == n)) // LIB_MAX6675 can be added to the build_flags in platformio.ini to use a user-defined library -#if LIB_USR_MAX6675 +// If LIB_MAX6675 is not on the build_flags then raw SPI reads will be used. +#if HAS_MAX6675 && LIB_USR_MAX6675 #include - #if PIN_EXISTS(MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK) - #define MAX6675_USES_SW_SPI 1 - #endif - #if TEMP_SENSOR_IS_MAX(0, 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 - #if ENABLED(LARGE_PINMAP) - , HIGH - #endif - ); - #endif - #if TEMP_SENSOR_IS_MAX(1, 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 - #if ENABLED(LARGE_PINMAP) - , HIGH - #endif - ); + #define HAS_MAX6675_LIBRARY 1 +#endif + +// LIB_MAX31855 can be added to the build_flags in platformio.ini to use a user-defined library. +// If LIB_MAX31855 is not on the build_flags then raw SPI reads will be used. +#if HAS_MAX31855 && LIB_USR_MAX31855 + #include + #define HAS_MAX31855_LIBRARY 1 + typedef Adafruit_MAX31855 MAX31855; +#endif + +#if HAS_MAX31865 + #if LIB_USR_MAX31865 + #include + typedef Adafruit_MAX31865 MAX31865; + #else + #include "../libs/MAX31865.h" #endif #endif -#if !HAS_MAX6675_TEMP && !HAS_MAX31855_TEMP && !HAS_MAX31865_TEMP - #define NO_THERMO_TEMPS 1 +#if HAS_MAX6675_LIBRARY || HAS_MAX31855_LIBRARY || HAS_MAX31865 + #define HAS_MAXTC_LIBRARIES 1 #endif -#if (TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC || TEMP_SENSOR_REDUNDANT_IS_MAX_TC) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS - #define THERMO_SEPARATE_SPI 1 +// If we have a MAX TC with SCK and MISO pins defined, it's either on a separate/dedicated Hardware +// SPI bus, or some pins for Software SPI. Alternate Hardware SPI buses are not supported yet, so +// your SPI options are: +// +// 1. Only CS pin(s) defined: Hardware SPI on the default bus (usually the SD card SPI). +// 2. CS, MISO, and SCK pins defined: Software SPI on a separate bus, as defined by MISO, SCK. +// 3. CS, MISO, and SCK pins w/ FORCE_HW_SPI: Hardware SPI on the default bus, ignoring MISO, SCK. +// +#if TEMP_SENSOR_IS_ANY_MAX_TC(0) && TEMP_SENSOR_0_HAS_SPI_PINS && DISABLED(TEMP_SENSOR_FORCE_HW_SPI) + #define TEMP_SENSOR_0_USES_SW_SPI 1 +#endif +#if TEMP_SENSOR_IS_ANY_MAX_TC(1) && TEMP_SENSOR_1_HAS_SPI_PINS && DISABLED(TEMP_SENSOR_FORCE_HW_SPI) + #define TEMP_SENSOR_1_USES_SW_SPI 1 #endif -#if THERMO_SEPARATE_SPI +#if (TEMP_SENSOR_0_USES_SW_SPI || TEMP_SENSOR_1_USES_SW_SPI) && !HAS_MAXTC_LIBRARIES #include "../libs/private_spi.h" + #define HAS_MAXTC_SW_SPI 1 #endif #if ENABLED(PID_EXTRUSION_SCALING) @@ -172,8 +117,6 @@ #include "../feature/babystep.h" #endif -#include "printcounter.h" - #if ENABLED(FILAMENT_WIDTH_SENSOR) #include "../feature/filwidth.h" #endif @@ -246,7 +189,67 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #define _E_PSTR(h,N) ((HOTENDS) > N && (h) == N) ? PSTR(LCD_STR_E##N) : #define HEATER_PSTR(h) _BED_PSTR(h) _CHAMBER_PSTR(h) _COOLER_PSTR(h) _E_PSTR(h,1) _E_PSTR(h,2) _E_PSTR(h,3) _E_PSTR(h,4) _E_PSTR(h,5) PSTR(LCD_STR_E0) -// public: +// +// Initialize MAX TC objects/SPI +// +#if HAS_MAX_TC + + #if HAS_MAXTC_SW_SPI + // Initialize SoftSPI for non-lib Software SPI; Libraries take care of it themselves. + template + SoftSPI SPIclass::softSPI; + SPIclass max_tc_spi; + #endif + + #define MAXTC_INIT(n, M) \ + MAX##M max##M##_##n = MAX##M( \ + TEMP_##n##_CS_PIN \ + OPTARG(_MAX31865_##n##_SW, TEMP_##n##_MOSI_PIN) \ + OPTARG(TEMP_SENSOR_##n##_USES_SW_SPI, TEMP_##n##_MISO_PIN, TEMP_##n##_SCK_PIN) \ + OPTARG(LARGE_PINMAP, HIGH) \ + ) + + #if HAS_MAX6675_LIBRARY + #if TEMP_SENSOR_IS_MAX(0, 6675) + MAXTC_INIT(0, 6675); + #endif + #if TEMP_SENSOR_IS_MAX(1, 6675) + MAXTC_INIT(1, 6675); + #endif + #endif + + #if HAS_MAX31855_LIBRARY + #if TEMP_SENSOR_IS_MAX(0, 31855) + MAXTC_INIT(0, 31855); + #endif + #if TEMP_SENSOR_IS_MAX(1, 31855) + MAXTC_INIT(1, 31855); + #endif + #endif + + // MAX31865 always uses a library, unlike '55 & 6675 + #if HAS_MAX31865 + #define _MAX31865_0_SW TEMP_SENSOR_0_USES_SW_SPI + #define _MAX31865_1_SW TEMP_SENSOR_1_USES_SW_SPI + + #if TEMP_SENSOR_IS_MAX(0, 31865) + MAXTC_INIT(0, 31865); + #endif + #if TEMP_SENSOR_IS_MAX(1, 31865) + MAXTC_INIT(1, 31865); + #endif + + #undef _MAX31865_0_SW + #undef _MAX31865_1_SW + #endif + + #undef MAXTC_INIT + +#endif + +/** + * public: + */ #if ENABLED(NO_FAN_SLOWING_IN_PID_TUNING) bool Temperature::adaptive_fan_slowing = true; @@ -274,6 +277,25 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, uint8_t Temperature::coolerfan_speed; // = 0 #endif +// Init fans according to whether they're native PWM or Software PWM +#ifdef BOARD_OPENDRAIN_MOSFETS + #define _INIT_SOFT_FAN(P) OUT_WRITE_OD(P, FAN_INVERTING ? LOW : HIGH) +#else + #define _INIT_SOFT_FAN(P) OUT_WRITE(P, FAN_INVERTING ? LOW : HIGH) +#endif +#if ENABLED(FAN_SOFT_PWM) + #define _INIT_FAN_PIN(P) _INIT_SOFT_FAN(P) +#else + #define _INIT_FAN_PIN(P) do{ if (PWM_PIN(P)) SET_PWM(P); else _INIT_SOFT_FAN(P); }while(0) +#endif +#if ENABLED(FAST_PWM_FAN) + #define SET_FAST_PWM_FREQ(P) set_pwm_frequency(P, FAST_PWM_FAN_FREQUENCY) +#else + #define SET_FAST_PWM_FREQ(P) NOOP +#endif +#define INIT_FAN_PIN(P) do{ _INIT_FAN_PIN(P); SET_FAST_PWM_FREQ(P); }while(0) + +// HAS_FAN does not include CONTROLLER_FAN #if HAS_FAN uint8_t Temperature::fan_speed[FAN_COUNT]; // = { 0 } @@ -419,7 +441,18 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, celsius_t Temperature::extrude_min_temp = EXTRUDE_MINTEMP; #endif -// private: +#if HAS_ADC_BUTTONS + uint32_t Temperature::current_ADCKey_raw = HAL_ADC_RANGE; + uint16_t Temperature::ADCKey_count = 0; +#endif + +#if ENABLED(PID_EXTRUSION_SCALING) + int16_t Temperature::lpq_len; // Initialized in settings.cpp +#endif + +/** + * private: + */ volatile bool Temperature::raw_temps_ready = false; @@ -472,16 +505,10 @@ volatile bool Temperature::raw_temps_ready = false; bool Temperature::paused_for_probing; #endif -// public: - -#if HAS_ADC_BUTTONS - uint32_t Temperature::current_ADCKey_raw = HAL_ADC_RANGE; - uint16_t Temperature::ADCKey_count = 0; -#endif - -#if ENABLED(PID_EXTRUSION_SCALING) - int16_t Temperature::lpq_len; // Initialized in settings.cpp -#endif +/** + * public: + * Class and Instance Methods + */ #if HAS_PID_HEATING @@ -758,10 +785,6 @@ volatile bool Temperature::raw_temps_ready = false; #endif // HAS_PID_HEATING -/** - * Class and Instance Methods - */ - int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { switch (heater_id) { #if HAS_HEATED_BED @@ -781,6 +804,16 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { #define _EFANOVERLAP(A,B) _FANOVERLAP(E##A,B) #if HAS_AUTO_FAN + #if EXTRUDER_AUTO_FAN_SPEED != 255 + #define INIT_E_AUTO_FAN_PIN(P) do{ if (P == FAN1_PIN || P == FAN2_PIN) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0) + #else + #define INIT_E_AUTO_FAN_PIN(P) SET_OUTPUT(P) + #endif + #if CHAMBER_AUTO_FAN_SPEED != 255 + #define INIT_CHAMBER_AUTO_FAN_PIN(P) do{ if (P == FAN1_PIN || P == FAN2_PIN) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0) + #else + #define INIT_CHAMBER_AUTO_FAN_PIN(P) SET_OUTPUT(P) + #endif #define CHAMBER_FAN_INDEX HOTENDS @@ -1668,11 +1701,6 @@ void Temperature::manage_heater() { } celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int16_t raw) { - //#if (MOTHERBOARD == BOARD_RAMPS_14_EFB) - // static uint32_t clocks_total = 0; - // static uint32_t calls = 0; - // uint32_t tcnt5 = TCNT5; - //#endif if (!WITHIN(t_index, 0, COUNT(user_thermistor) - 1)) return 25; @@ -1700,14 +1728,6 @@ void Temperature::manage_heater() { value += t.sh_c_coeff * cu(log_resistance); value = 1.0f / value; - //#if (MOTHERBOARD == BOARD_RAMPS_14_EFB) - // int32_t clocks = TCNT5 - tcnt5; - // if (clocks >= 0) { - // clocks_total += clocks; - // calls++; - // } - //#endif - // Return degrees C (up to 999, as the LCD only displays 3 digits) return _MIN(value + THERMISTOR_ABS_ZERO_C, 999); } @@ -1730,7 +1750,14 @@ void Temperature::manage_heater() { #if TEMP_SENSOR_0_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_0, raw); #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); + #if TEMP_SENSOR_0_IS_MAX31865 + return TERN(LIB_INTERNAL_MAX31865, + max31865_0.temperature((uint16_t)raw), + max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0) + ); + #else + return raw * 0.25; + #endif #elif TEMP_SENSOR_0_IS_AD595 return TEMP_AD595(raw); #elif TEMP_SENSOR_0_IS_AD8495 @@ -1742,7 +1769,14 @@ void Temperature::manage_heater() { #if TEMP_SENSOR_1_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_1, raw); #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); + #if TEMP_SENSOR_0_IS_MAX31865 + return TERN(LIB_INTERNAL_MAX31865, + max31865_1.temperature((uint16_t)raw), + max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1) + ); + #else + return raw * 0.25; + #endif #elif TEMP_SENSOR_1_IS_AD595 return TEMP_AD595(raw); #elif TEMP_SENSOR_1_IS_AD8495 @@ -1901,9 +1935,9 @@ void Temperature::manage_heater() { #if TEMP_SENSOR_REDUNDANT_IS_CUSTOM return user_thermistor_to_deg_c(CTI_REDUNDANT, raw); #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 0 - return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0), raw * 0.25); + return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature((uint16_t)raw), raw * 0.25); #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1 - return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1), raw * 0.25); + return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature((uint16_t)raw), raw * 0.25); #elif TEMP_SENSOR_REDUNDANT_IS_THERMISTOR SCAN_THERMISTOR_TABLE(TEMPTABLE_REDUNDANT, TEMPTABLE_REDUNDANT_LEN); #elif TEMP_SENSOR_REDUNDANT_IS_AD595 @@ -1936,6 +1970,7 @@ void Temperature::updateTemperaturesFromRawValues() { 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)); TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.raw = READ_MAX_TC(TEMP_SENSOR_REDUNDANT_SOURCE)); + #if HAS_HOTEND HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e); #endif @@ -2008,40 +2043,7 @@ void Temperature::updateTemperaturesFromRawValues() { if (cutter.unitPower > 0 && COOLERCMP(temp_cooler.raw, maxtemp_raw_COOLER)) max_temp_error(H_COOLER); if (COOLERCMP(mintemp_raw_COOLER, temp_cooler.raw)) min_temp_error(H_COOLER); #endif -} - -#if THERMO_SEPARATE_SPI - template SoftSPI SPIclass::softSPI; - SPIclass max_tc_spi; -#endif - -// Init fans according to whether they're native PWM or Software PWM -#ifdef BOARD_OPENDRAIN_MOSFETS - #define _INIT_SOFT_FAN(P) OUT_WRITE_OD(P, FAN_INVERTING ? LOW : HIGH) -#else - #define _INIT_SOFT_FAN(P) OUT_WRITE(P, FAN_INVERTING ? LOW : HIGH) -#endif -#if ENABLED(FAN_SOFT_PWM) - #define _INIT_FAN_PIN(P) _INIT_SOFT_FAN(P) -#else - #define _INIT_FAN_PIN(P) do{ if (PWM_PIN(P)) SET_PWM(P); else _INIT_SOFT_FAN(P); }while(0) -#endif -#if ENABLED(FAST_PWM_FAN) - #define SET_FAST_PWM_FREQ(P) set_pwm_frequency(P, FAST_PWM_FAN_FREQUENCY) -#else - #define SET_FAST_PWM_FREQ(P) NOOP -#endif -#define INIT_FAN_PIN(P) do{ _INIT_FAN_PIN(P); SET_FAST_PWM_FREQ(P); }while(0) -#if EXTRUDER_AUTO_FAN_SPEED != 255 - #define INIT_E_AUTO_FAN_PIN(P) do{ if (P == FAN1_PIN || P == FAN2_PIN) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0) -#else - #define INIT_E_AUTO_FAN_PIN(P) SET_OUTPUT(P) -#endif -#if CHAMBER_AUTO_FAN_SPEED != 255 - #define INIT_CHAMBER_AUTO_FAN_PIN(P) do{ if (P == FAN1_PIN || P == FAN2_PIN) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0) -#else - #define INIT_CHAMBER_AUTO_FAN_PIN(P) SET_OUTPUT(P) -#endif +} // Temperature::updateTemperaturesFromRawValues /** * Initialize the temperature manager @@ -2070,50 +2072,47 @@ void Temperature::init() { #endif // Init (and disable) SPI thermocouples - #if TEMP_SENSOR_IS_MAX(0, MAX6675) && PIN_EXISTS(MAX6675_CS) - OUT_WRITE(MAX6675_CS_PIN, HIGH); + #if TEMP_SENSOR_IS_ANY_MAX_TC(0) && PIN_EXISTS(TEMP_0_CS) + OUT_WRITE(TEMP_0_CS_PIN, HIGH); #endif - #if TEMP_SENSOR_IS_MAX(1, MAX6675) && PIN_EXISTS(MAX6675_CS2) - OUT_WRITE(MAX6675_CS2_PIN, HIGH); - #endif - #if TEMP_SENSOR_IS_MAX(0, MAX6675) && PIN_EXISTS(MAX31855_CS) - OUT_WRITE(MAX31855_CS_PIN, HIGH); - #endif - #if TEMP_SENSOR_IS_MAX(1, MAX6675) && PIN_EXISTS(MAX31855_CS2) - OUT_WRITE(MAX31855_CS2_PIN, HIGH); - #endif - #if TEMP_SENSOR_IS_MAX(0, MAX6675) && PIN_EXISTS(MAX31865_CS) - OUT_WRITE(MAX31865_CS_PIN, HIGH); - #endif - #if TEMP_SENSOR_IS_MAX(1, MAX6675) && PIN_EXISTS(MAX31865_CS2) - OUT_WRITE(MAX31865_CS2_PIN, HIGH); + #if TEMP_SENSOR_IS_ANY_MAX_TC(1) && PIN_EXISTS(TEMP_1_CS) + OUT_WRITE(TEMP_1_CS_PIN, HIGH); #endif - #if HAS_MAX31865_TEMP - #if TEMP_SENSOR_IS_MAX(0, MAX31865) - max31865_0.begin(MAX31865_2WIRE); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE - #endif - #if TEMP_SENSOR_IS_MAX(1, MAX31865) - max31865_1.begin(MAX31865_2WIRE); - #endif - #endif + // Setup objects for library-based polling of MAX TCs + #if HAS_MAXTC_LIBRARIES + #define _MAX31865_WIRES(n) MAX31865_##n##WIRE + #define MAX31865_WIRES(n) _MAX31865_WIRES(n) - #if HAS_MAX31855_TEMP - #if TEMP_SENSOR_IS_MAX(0, MAX31855) - max31855_0.begin(MAX31855); + #if TEMP_SENSOR_IS_MAX(0, 6675) && HAS_MAX6675_LIBRARY + max6675_0.begin(); + #elif TEMP_SENSOR_IS_MAX(0, 31855) && HAS_MAX31855_LIBRARY + max31855_0.begin(); + #elif TEMP_SENSOR_IS_MAX(0, 31865) + max31865_0.begin( + MAX31865_WIRES(MAX31865_SENSOR_WIRES_0) // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE + OPTARG(LIB_INTERNAL_MAX31865, MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0) + ); + #if defined(LIB_INTERNAL_MAX31865) && ENABLED(MAX31865_50HZ_FILTER) + max31865_0.enable50HzFilter(1); + #endif #endif - #if TEMP_SENSOR_IS_MAX(1, MAX31855) - max31855_1.begin(MAX31855); - #endif - #endif - #if HAS_MAX6675_TEMP - #if TEMP_SENSOR_IS_MAX(0, MAX6675) - max6675_0.begin(MAX6675); - #endif - #if TEMP_SENSOR_IS_MAX(1, MAX6675) - max6675_1.begin(MAX6675); + #if TEMP_SENSOR_IS_MAX(1, 6675) && HAS_MAX6675_LIBRARY + max6675_1.begin(); + #elif TEMP_SENSOR_IS_MAX(1, 31855) && HAS_MAX31855_LIBRARY + max31855_1.begin(); + #elif TEMP_SENSOR_IS_MAX(1, 31865) + max31865_1.begin( + MAX31865_WIRES(MAX31865_SENSOR_WIRES_1) // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE + OPTARG(LIB_INTERNAL_MAX31865, MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1) + ); + #if defined(LIB_INTERNAL_MAX31865) && ENABLED(MAX31865_50HZ_FILTER) + max31865_1.enable50HzFilter(1); + #endif #endif + #undef MAX31865_WIRES + #undef _MAX31865_WIRES #endif #if MB(RUMBA) @@ -2152,7 +2151,6 @@ void Temperature::init() { OUT_WRITE(HEATER_0_PIN, HEATER_0_INVERTING); #endif #endif - #if HAS_HEATER_1 OUT_WRITE(HEATER_1_PIN, HEATER_1_INVERTING); #endif @@ -2219,7 +2217,9 @@ void Temperature::init() { INIT_FAN_PIN(CONTROLLER_FAN_PIN); #endif - TERN_(THERMO_SEPARATE_SPI, max_tc_spi.init()); + #if HAS_MAXTC_SW_SPI + max_tc_spi.init(); + #endif HAL_adc_init(); @@ -2318,11 +2318,7 @@ void Temperature::init() { INIT_CHAMBER_AUTO_FAN_PIN(CHAMBER_AUTO_FAN_PIN); #endif - // Wait for temperature measurement to settle - //delay(250); - #if HAS_HOTEND - #define _TEMP_MIN_E(NR) do{ \ const celsius_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, (int)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \ temp_range[NR].mintemp = tmin; \ @@ -2386,7 +2382,6 @@ void Temperature::init() { #if _MINMAX_TEST(7, MAX) _TEMP_MAX_E(7); #endif - #endif // HAS_HOTEND #if HAS_HEATED_BED @@ -2520,9 +2515,8 @@ void Temperature::init() { void Temperature::disable_all_heaters() { + // Disable autotemp, unpause and reset everything TERN_(AUTOTEMP, planner.autotemp_enabled = false); - - // Unpause and reset everything TERN_(PROBING_HEATERS_OFF, pause_heaters(false)); #if HAS_HOTEND @@ -2558,8 +2552,6 @@ void Temperature::disable_all_heaters() { #if ENABLED(PRINTJOB_TIMER_AUTOSTART) - #include "printcounter.h" - bool Temperature::auto_job_over_threshold() { #if HAS_HOTEND HOTEND_LOOP() if (degTargetHotend(e) > (EXTRUDE_MINTEMP) / 2) return true; @@ -2578,7 +2570,7 @@ void Temperature::disable_all_heaters() { } } -#endif +#endif // PRINTJOB_TIMER_AUTOSTART #if ENABLED(PROBING_HEATERS_OFF) @@ -2616,7 +2608,7 @@ void Temperature::disable_all_heaters() { #endif } -#endif +#endif // SINGLENOZZLE_STANDBY_TEMP || SINGLENOZZLE_STANDBY_FAN #if HAS_MAX_TC @@ -2624,113 +2616,114 @@ void Temperature::disable_all_heaters() { #define THERMOCOUPLE_MAX_ERRORS 15 #endif - int Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { - #define MAX6675_HEAT_INTERVAL 250UL + /** + * @brief Read MAX Thermocouple temperature. + * + * Reads the thermocouple board via HW or SW SPI, using a library (LIB_USR_x) or raw SPI reads. + * Doesn't strictly return a temperature; returns an "ADC Value" (i.e. raw register content). + * + * @param hindex the hotend we're referencing (if MULTI_MAX_TC) + * @return integer representing the board's buffer, to be converted later if needed + */ + int16_t Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { + #define MAXTC_HEAT_INTERVAL 250UL - #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 max_tc_temp = 2000; // From datasheet 16 bits D15-D0 - #define MAX_TC_ERROR_MASK 1 // D0 Bit not used + #if HAS_MAX31855 + #define MAX_TC_ERROR_MASK 7 // D2-0: SCV, SCG, OC + #define MAX_TC_DISCARD_BITS 18 // Data D31-18; sign bit D31 + #define MAX_TC_SPEED_BITS 3 // ~1MHz + #elif HAS_MAX31865 + #define MAX_TC_ERROR_MASK 1 // D0 Bit on fault only #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 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 + #define MAX_TC_SPEED_BITS 3 // ~1MHz + #else // MAX6675 + #define MAX_TC_ERROR_MASK 3 // D2 only; 1 = open circuit + #define MAX_TC_DISCARD_BITS 3 // Data D15-D1 + #define MAX_TC_SPEED_BITS 2 // ~2MHz #endif #if HAS_MULTI_MAX_TC // Needed to return the correct temp when this is called between readings - static celsius_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; + static int16_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) + #define MAXTC_CS_WRITE(V) do{ switch (hindex) { case 1: WRITE(TEMP_1_CS_PIN, V); break; default: WRITE(TEMP_0_CS_PIN, V); } }while(0) #else + // When we have only 1 max tc, THERMO_SEL will pick the appropriate sensor + // variable, and MAXTC_*() macros will be hardcoded to the correct CS pin. constexpr uint8_t hindex = 0; #define THERMO_TEMP(I) max_tc_temp - #if TEMP_SENSOR_IS_ANY_MAX_TC(1) - #define THERMO_SEL(A,B) B - #else + #if TEMP_SENSOR_IS_ANY_MAX_TC(0) #define THERMO_SEL(A,B) A - #endif - #if TEMP_SENSOR_IS_MAX(0, MAX6675) - #define MAX6675_WRITE(V) WRITE(MAX6675_SS_PIN, V) - #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS_PIN) + #define MAXTC_CS_WRITE(V) WRITE(TEMP_0_CS_PIN, V) #else - #define MAX6675_WRITE(V) WRITE(MAX6675_SS2_PIN, V) - #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS2_PIN) + #define THERMO_SEL(A,B) B + #define MAXTC_CS_WRITE(V) WRITE(TEMP_1_CS_PIN, V) #endif - #endif + static TERN(HAS_MAX31855, uint32_t, uint16_t) max_tc_temp = THERMO_SEL( + TEMP_SENSOR_0_MAX_TC_TMAX, + TEMP_SENSOR_1_MAX_TC_TMAX + ); + static uint8_t max_tc_errors[MAX_TC_COUNT] = { 0 }; + static millis_t next_max_tc_ms[MAX_TC_COUNT] = { 0 }; // Return last-read value between readings - static millis_t next_max_tc_ms[MAX_TC_COUNT] = { 0 }; millis_t ms = millis(); - if (PENDING(ms, next_max_tc_ms[hindex])) return int(THERMO_TEMP(hindex)); - next_max_tc_ms[hindex] = ms + MAX6675_HEAT_INTERVAL; + if (PENDING(ms, next_max_tc_ms[hindex])) + return (int16_t)THERMO_TEMP(hindex); - // - // TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used. - // - #if !THERMO_SEPARATE_SPI && NO_THERMO_TEMPS - spiBegin(); - spiInit(MAX_TC_SPEED_BITS); - #endif + next_max_tc_ms[hindex] = ms + MAXTC_HEAT_INTERVAL; - #if NO_THERMO_TEMPS - MAX6675_WRITE(LOW); // enable TT_MAX6675 - DELAY_NS(100); // Ensure 100ns delay - #endif + #if !HAS_MAXTC_LIBRARIES + max_tc_temp = 0; - max_tc_temp = 0; + #if !HAS_MAXTC_SW_SPI + // Initialize SPI using the default Hardware SPI bus. + // FIXME: spiBegin, spiRec and spiInit doesn't work when soft spi is used. + spiBegin(); + spiInit(MAX_TC_SPEED_BITS); + #endif - // Read a big-endian temperature value - #if NO_THERMO_TEMPS + MAXTC_CS_WRITE(LOW); // enable MAXTC + DELAY_NS(100); // Ensure 100ns delay + + // Read a big-endian temperature value without using a library for (uint8_t i = sizeof(max_tc_temp); i--;) { - max_tc_temp |= TERN(THERMO_SEPARATE_SPI, max_tc_spi.receive(), spiRec()); + max_tc_temp |= TERN(HAS_MAXTC_SW_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 - #endif - #if HAS_MAX31855_TEMP - Adafruit_MAX31855 &max855ref = THERMO_SEL(max31855_0, max31855_1); - max_tc_temp = max855ref.readRaw32(); - #endif + MAXTC_CS_WRITE(HIGH); // disable MAXTC + #else + #if HAS_MAX6675_LIBRARY + MAX6675 &max6675ref = THERMO_SEL(max6675_0, max6675_1); + max_tc_temp = max6675ref.readRaw16(); + #endif - #if HAS_MAX31865_TEMP - Adafruit_MAX31865 &max865ref = THERMO_SEL(max31865_0, max31865_1); - #if ENABLED(LIB_USR_MAX31865) - max_tc_temp = max865ref.readRTD_with_Fault(); + #if HAS_MAX31855_LIBRARY + MAX31855 &max855ref = THERMO_SEL(max31855_0, max31855_1); + max_tc_temp = max855ref.readRaw32(); + #endif + + #if HAS_MAX31865 + MAX31865 &max865ref = THERMO_SEL(max31865_0, max31865_1); + max_tc_temp = TERN(LIB_INTERNAL_MAX31865, max865ref.readRaw(), max865ref.readRTD_with_Fault()); #endif #endif - #if HAS_MAX6675_TEMP - MAX6675 &max6675ref = THERMO_SEL(max6675_0, max6675_1); - max_tc_temp = max6675ref.readRaw16(); - #endif - - #if ENABLED(LIB_ADAFRUIT_MAX31865) - const uint8_t fault_31865 = max865ref.readFault() & 0x3FU; - #endif - - if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) - && TERN(LIB_ADAFRUIT_MAX31865, fault_31865, (max_tc_temp & MAX_TC_ERROR_MASK)) - ) { + // Handle an error. If there have been more than THERMOCOUPLE_MAX_ERRORS, send an error over serial. + // Either way, return the TMAX for the thermocouple to trigger a max_temp_error() + if (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 Fault : (", max_tc_temp & 0x7, ") >> "); + #if HAS_MAX31855 + SERIAL_ECHOPAIR("MAX31855 Fault: (", max_tc_temp & 0x7, ") >> "); if (max_tc_temp & 0x1) SERIAL_ECHOLNPGM("Open Circuit"); else if (max_tc_temp & 0x2) @@ -2738,59 +2731,46 @@ void Temperature::disable_all_heaters() { 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 - // or thr LOW threshold, so no need to check for them, zero these bits out - const uint8_t fault_31865 = max865ref.readFault() & 0x3FU; - #endif + const uint8_t fault_31865 = max865ref.readFault(); max865ref.clearFault(); if (fault_31865) { SERIAL_EOL(); - SERIAL_ECHOLNPAIR("\nMAX31865 Fault :(", 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"); + SERIAL_ECHOLNPGM("REFIN- > 0.85 x V bias"); if (fault_31865 & MAX31865_FAULT_REFINHIGH) - SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); + SERIAL_ECHOLNPGM("REFIN- < 0.85 x V bias (FORCE- open)"); if (fault_31865 & MAX31865_FAULT_RTDINLOW) - SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); + SERIAL_ECHOLNPGM("REFIN- < 0.85 x V bias (FORCE- open)"); if (fault_31865 & MAX31865_FAULT_OVUV) SERIAL_ECHOLNPGM("Under/Over voltage"); } - #else - SERIAL_ECHOLNPGM("MAX6675 Open Circuit"); + #else // MAX6675 + SERIAL_ECHOLNPGM("MAX6675 Fault: Open Circuit"); #endif - // Thermocouple open - max_tc_temp = 4 * THERMO_SEL(TEMP_SENSOR_0_MAX_TC_TMAX, TEMP_SENSOR_1_MAX_TC_TMAX); + // Set thermocouple above max temperature (TMAX) + max_tc_temp = THERMO_SEL(TEMP_SENSOR_0_MAX_TC_TMAX, TEMP_SENSOR_1_MAX_TC_TMAX) << (MAX_TC_DISCARD_BITS + 1); } - else - max_tc_temp >>= MAX_TC_DISCARD_BITS; } else { - max_tc_temp >>= MAX_TC_DISCARD_BITS; - max_tc_errors[hindex] = 0; + max_tc_errors[hindex] = 0; // No error bit, reset error count } - #if HAS_MAX31855 - if (max_tc_temp & 0x00002000) max_tc_temp |= 0xFFFFC000; // Support negative temperature - #endif + max_tc_temp >>= MAX_TC_DISCARD_BITS; - // Return the RTD resistance for MAX31865 for display in SHOW_TEMP_ADC_VALUES - #if HAS_MAX31865_TEMP - #if ENABLED(LIB_ADAFRUIT_MAX31865) - max_tc_temp = (uint32_t(max865ref.readRTD()) * THERMO_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; - #elif ENABLED(LIB_USR_MAX31865) - max_tc_temp = (uint32_t(max_tc_temp) * THERMO_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; - #endif + #if HAS_MAX31855 + // Support negative temperature for MAX38155 + if (max_tc_temp & 0x00002000) max_tc_temp |= 0xFFFFC000; #endif THERMO_TEMP(hindex) = max_tc_temp; - return int(max_tc_temp); + return (int16_t)max_tc_temp; } #endif // HAS_MAX_TC @@ -2815,16 +2795,16 @@ void Temperature::update_raw_temperatures() { temp_redundant.update(); #endif - TERN_(HAS_TEMP_ADC_2, temp_hotend[2].update()); - TERN_(HAS_TEMP_ADC_3, temp_hotend[3].update()); - TERN_(HAS_TEMP_ADC_4, temp_hotend[4].update()); - TERN_(HAS_TEMP_ADC_5, temp_hotend[5].update()); - TERN_(HAS_TEMP_ADC_6, temp_hotend[6].update()); - TERN_(HAS_TEMP_ADC_7, temp_hotend[7].update()); - TERN_(HAS_TEMP_ADC_BED, temp_bed.update()); + TERN_(HAS_TEMP_ADC_2, temp_hotend[2].update()); + TERN_(HAS_TEMP_ADC_3, temp_hotend[3].update()); + TERN_(HAS_TEMP_ADC_4, temp_hotend[4].update()); + TERN_(HAS_TEMP_ADC_5, temp_hotend[5].update()); + TERN_(HAS_TEMP_ADC_6, temp_hotend[6].update()); + TERN_(HAS_TEMP_ADC_7, temp_hotend[7].update()); + TERN_(HAS_TEMP_ADC_BED, temp_bed.update()); TERN_(HAS_TEMP_ADC_CHAMBER, temp_chamber.update()); - TERN_(HAS_TEMP_ADC_PROBE, temp_probe.update()); - TERN_(HAS_TEMP_ADC_COOLER, temp_cooler.update()); + TERN_(HAS_TEMP_ADC_PROBE, temp_probe.update()); + TERN_(HAS_TEMP_ADC_COOLER, temp_cooler.update()); TERN_(HAS_JOY_ADC_X, joystick.x.update()); TERN_(HAS_JOY_ADC_Y, joystick.y.update()); @@ -3465,7 +3445,7 @@ void Temperature::isr() { SERIAL_PRINT(t, SFP); #if ENABLED(SHOW_TEMP_ADC_VALUES) // Temperature MAX SPI boards do not have an OVERSAMPLENR defined - SERIAL_ECHOPAIR(" (", TERN(NO_THERMO_TEMPS, false, k == 'T') ? r : r * RECIPROCAL(OVERSAMPLENR)); + SERIAL_ECHOPAIR(" (", TERN(HAS_MAXTC_LIBRARIES, k == 'T', false) ? r : r * RECIPROCAL(OVERSAMPLENR)); SERIAL_CHAR(')'); #endif delay(2); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 3a8c506a5d..26c1dca8af 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -428,6 +428,15 @@ class Temperature { static heater_idle_t heater_idle[NR_HEATER_IDLE]; + #endif // HEATER_IDLE_TIMER + + #if HAS_ADC_BUTTONS + static uint32_t current_ADCKey_raw; + static uint16_t ADCKey_count; + #endif + + #if ENABLED(PID_EXTRUSION_SCALING) + static int16_t lpq_len; #endif private: @@ -486,15 +495,6 @@ class Temperature { #endif public: - #if HAS_ADC_BUTTONS - static uint32_t current_ADCKey_raw; - static uint16_t ADCKey_count; - #endif - - #if ENABLED(PID_EXTRUSION_SCALING) - static int16_t lpq_len; - #endif - /** * Instance Methods */ @@ -915,7 +915,7 @@ class Temperature { #else #define READ_MAX_TC(N) read_max_tc() #endif - static int read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex=0)); + static int16_t read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex=0)); #endif static void checkExtruderAutoFans(); diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index ab1446f07c..568086e066 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -133,11 +133,11 @@ #define TEMP_1_PIN 1 // Analog Input #define TEMP_BED_PIN 2 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h index 066c65be3a..f7e566e2d6 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -73,6 +73,19 @@ #endif #endif +// CS, MISO, MOSI, and SCK for MAX Thermocouple SPI +#if HAS_MAX_TC + //#define TEMP_0_CS_PIN P... + //#define TEMP_0_MISO_PIN P... + //#define TEMP_0_MOSI_PIN P... + //#define TEMP_0_SCK_PIN P... + + //#define TEMP_1_CS_PIN P... + //#define TEMP_1_MISO_PIN P... + //#define TEMP_1_MOSI_PIN P... + //#define TEMP_1_SCK_PIN P... +#endif + // // Heaters / Fans // diff --git a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h index 83fcf36e4e..c25f676a08 100644 --- a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h +++ b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h @@ -248,8 +248,8 @@ #define PS_ON_PIN P2_12 // (12) -#if !defined(MAX6675_SS_PIN) && DISABLED(USE_ZMAX_PLUG) - #define MAX6675_SS_PIN P1_28 +#if !defined(TEMP_0_CS_PIN) && DISABLED(USE_ZMAX_PLUG) + #define TEMP_0_CS_PIN P1_28 #endif #if ENABLED(CASE_LIGHT_ENABLE) && !PIN_EXISTS(CASE_LIGHT) && !defined(SPINDLE_LASER_ENA_PIN) diff --git a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h index 4719dd8111..970a402b30 100644 --- a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h +++ b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h @@ -202,7 +202,7 @@ #define EXP1_10_PIN P2_08 #if ENABLED(DWIN_CREALITY_LCD) - #error "DWIN_CREALITY_LCD requires a custom cable with TX = P0_15, RX = P0_16, and LCD_SERIAL_PORT 1. Comment out this line to continue." + #error "DWIN_CREALITY_LCD requires a custom cable with TX = P0_15, RX = P0_16. Comment out this line to continue." #define BEEPER_PIN EXP1_10_PIN #define BTN_EN1 EXP1_03_PIN diff --git a/Marlin/src/pins/mega/pins_MALYAN_M180.h b/Marlin/src/pins/mega/pins_MALYAN_M180.h index e244d294f1..19095a5379 100644 --- a/Marlin/src/pins/mega/pins_MALYAN_M180.h +++ b/Marlin/src/pins/mega/pins_MALYAN_M180.h @@ -72,17 +72,17 @@ #define TEMP_BED_PIN 15 // Analog Input // Extruder thermocouples 0 and 1 are read out by two separate ICs using -// SPI for Max6675 Thermocouple +// SPI for MAX Thermocouple // Uses a separate SPI bus -#define THERMO_SCK_PIN 78 // E2 - SCK -#define THERMO_DO_PIN 3 // E5 - DO -#define THERMO_CS1_PIN 5 // E3 - CS0 -#define THERMO_CS2_PIN 2 // E4 - CS1 +#define TEMP_0_CS_PIN 5 // E3 - CS0 +#define TEMP_0_SCK_PIN 78 // E2 - SCK +#define TEMP_0_MISO_PIN 3 // E5 - MISO +//#define TEMP_0_MOSI_PIN ... // For MAX31865 -#define MAX6675_SS_PIN THERMO_CS1_PIN -#define MAX6675_SS2_PIN THERMO_CS2_PIN -#define MAX6675_SCK_PIN THERMO_SCK_PIN -#define MAX6675_DO_PIN THERMO_DO_PIN +#define TEMP_1_CS_PIN 2 // E4 - CS1 +#define TEMP_1_SCK_PIN TEMP_0_SCK_PIN +#define TEMP_1_MISO_PIN TEMP_0_MISO_PIN +//#define TEMP_1_MOSI_PIN TEMP_0_MOSI_PIN // // Heaters / Fans diff --git a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h index 2531f10a7a..aea05134a8 100644 --- a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h +++ b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h @@ -125,7 +125,7 @@ // K7 - 69 / ADC15 - 15 #define TEMP_BED_PIN 15 -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple // Uses a separate SPI bus // // 3 E5 DO (SO) @@ -133,15 +133,15 @@ // 2 E4 CS2 // 78 E2 SCK // -#define THERMO_SCK_PIN 78 // E2 -#define THERMO_DO_PIN 3 // E5 -#define THERMO_CS1_PIN 5 // E3 -#define THERMO_CS2_PIN 2 // E4 +#define TEMP_0_CS_PIN 5 // E3 +#define TEMP_0_SCK_PIN 78 // E2 +#define TEMP_0_MISO_PIN 3 // E5 +//#define TEMP_0_MOSI_PIN ... // For MAX31865 -#define MAX6675_SS_PIN THERMO_CS1_PIN -#define MAX6675_SS2_PIN THERMO_CS2_PIN -#define MAX6675_SCK_PIN THERMO_SCK_PIN -#define MAX6675_DO_PIN THERMO_DO_PIN +#define TEMP_1_CS_PIN 2 // E4 +#define TEMP_1_SCK_PIN TEMP_0_SCK_PIN +#define TEMP_1_MISO_PIN TEMP_0_MISO_PIN +//#define TEMP_1_MOSI_PIN TEMP_0_MOSI_PIN // // Augmentation for auto-assigning plugs diff --git a/Marlin/src/pins/mega/pins_PICA.h b/Marlin/src/pins/mega/pins_PICA.h index 41afe5d891..47c101711c 100644 --- a/Marlin/src/pins/mega/pins_PICA.h +++ b/Marlin/src/pins/mega/pins_PICA.h @@ -118,11 +118,11 @@ #define SSR_PIN 6 -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 88dd170a9e..1f53227553 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -610,11 +610,11 @@ #elif MB(VAKE403D) #include "stm32f4/pins_VAKE403D.h" // STM32F4 #elif MB(FYSETC_S6) - #include "stm32f4/pins_FYSETC_S6.h" // STM32F4 env:FYSETC_S6 + #include "stm32f4/pins_FYSETC_S6.h" // STM32F4 env:FYSETC_S6 env:FYSETC_S6_8000 #elif MB(FYSETC_S6_V2_0) - #include "stm32f4/pins_FYSETC_S6_V2_0.h" // STM32F4 env:FYSETC_S6 + #include "stm32f4/pins_FYSETC_S6_V2_0.h" // STM32F4 env:FYSETC_S6 env:FYSETC_S6_8000 #elif MB(FYSETC_SPIDER) - #include "stm32f4/pins_FYSETC_SPIDER.h" // STM32F4 env:FYSETC_S6 + #include "stm32f4/pins_FYSETC_SPIDER.h" // STM32F4 env:FYSETC_S6 env:FYSETC_S6_8000 #elif MB(FLYF407ZG) #include "stm32f4/pins_FLYF407ZG.h" // STM32F4 env:FLYF407ZG #elif MB(MKS_ROBIN2) diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index 1ab7188b70..8b1cad3a7c 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -760,17 +760,29 @@ #if PIN_EXISTS(LED_RED) REPORT_NAME_DIGITAL(__LINE__, LED_RED_PIN) #endif -#if PIN_EXISTS(MAX6675_DO) - REPORT_NAME_DIGITAL(__LINE__, MAX6675_DO_PIN) +#if PIN_EXISTS(TEMP_0_CS) + REPORT_NAME_DIGITAL(__LINE__, TEMP_0_CS_PIN) #endif -#if PIN_EXISTS(MAX6675_SCK) - REPORT_NAME_DIGITAL(__LINE__, MAX6675_SCK_PIN) +#if PIN_EXISTS(TEMP_0_SCK) + REPORT_NAME_DIGITAL(__LINE__, TEMP_0_SCK_PIN) #endif -#if PIN_EXISTS(MAX6675_SS) - REPORT_NAME_DIGITAL(__LINE__, MAX6675_SS_PIN) +#if PIN_EXISTS(TEMP_0_MOSI) + REPORT_NAME_DIGITAL(__LINE__, TEMP_0_MOSI_PIN) #endif -#if PIN_EXISTS(MAX6675_SS2) - REPORT_NAME_DIGITAL(__LINE__, MAX6675_SS2_PIN) +#if PIN_EXISTS(TEMP_0_MISO) + REPORT_NAME_DIGITAL(__LINE__, TEMP_0_MISO_PIN) +#endif +#if PIN_EXISTS(TEMP_1_CS) + REPORT_NAME_DIGITAL(__LINE__, TEMP_1_CS_PIN) +#endif +#if PIN_EXISTS(TEMP_1_SCK) + REPORT_NAME_DIGITAL(__LINE__, TEMP_1_SCK_PIN) +#endif +#if PIN_EXISTS(TEMP_1_MOSI) + REPORT_NAME_DIGITAL(__LINE__, TEMP_1_MOSI_PIN) +#endif +#if PIN_EXISTS(TEMP_1_MISO) + REPORT_NAME_DIGITAL(__LINE__, TEMP_1_MISO_PIN) #endif #if PIN_EXISTS(MAX7219_CLK) REPORT_NAME_DIGITAL(__LINE__, MAX7219_CLK_PIN) @@ -1010,18 +1022,6 @@ #if PIN_EXISTS(SUICIDE) REPORT_NAME_DIGITAL(__LINE__, SUICIDE_PIN) #endif -#if PIN_EXISTS(THERMO_CS1) - REPORT_NAME_DIGITAL(__LINE__, THERMO_CS1_PIN) -#endif -#if PIN_EXISTS(THERMO_CS2) - REPORT_NAME_DIGITAL(__LINE__, THERMO_CS2_PIN) -#endif -#if PIN_EXISTS(THERMO_DO) - REPORT_NAME_DIGITAL(__LINE__, THERMO_DO_PIN) -#endif -#if PIN_EXISTS(THERMO_SCK) - REPORT_NAME_DIGITAL(__LINE__, THERMO_SCK_PIN) -#endif #if PIN_EXISTS(TLC_BLANK) REPORT_NAME_DIGITAL(__LINE__, TLC_BLANK_PIN) #endif diff --git a/Marlin/src/pins/rambo/pins_RAMBO.h b/Marlin/src/pins/rambo/pins_RAMBO.h index 5d6f9c1fd0..f2d34dc00d 100644 --- a/Marlin/src/pins/rambo/pins_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_RAMBO.h @@ -171,10 +171,10 @@ #define SPINDLE_DIR_PIN 32 // -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple // -#ifndef MAX6675_SS_PIN - #define MAX6675_SS_PIN 32 // SPINDLE_DIR_PIN / STAT_LED_BLUE_PIN +#ifndef TEMP_0_CS_PIN + #define TEMP_0_CS_PIN 32 // SPINDLE_DIR_PIN / STAT_LED_BLUE_PIN #endif // diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h index 383501caaa..34a4ceb27d 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h @@ -114,11 +114,11 @@ #define TEMP_1_PIN 15 // Analog Input #define TEMP_BED_PIN 14 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h b/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h index ac0b7428f4..5f645e5d95 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h @@ -111,11 +111,11 @@ #define TEMP_1_PIN 15 // Analog Input #define TEMP_BED_PIN 3 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h index 76a9fbe628..c953cff3d0 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h @@ -111,11 +111,11 @@ #define TEMP_1_PIN 15 // Analog Input #define TEMP_BED_PIN 14 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index c2d4dbeb3f..b13b5e72a0 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -167,10 +167,10 @@ #endif // -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple // -#ifndef MAX6675_SS_PIN - #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card (SDSS) or 49 (SD_DETECT_PIN) +#ifndef TEMP_0_CS_PIN + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card (SDSS) or 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/ramps/pins_RAMPS_OLD.h b/Marlin/src/pins/ramps/pins_RAMPS_OLD.h index a43ee3c6ca..9747666235 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_OLD.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_OLD.h @@ -74,11 +74,11 @@ #define TEMP_0_PIN 2 // Analog Input #define TEMP_BED_PIN 1 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/ramps/pins_RIGIDBOARD.h b/Marlin/src/pins/ramps/pins_RIGIDBOARD.h index 345c51d5de..203af5e081 100644 --- a/Marlin/src/pins/ramps/pins_RIGIDBOARD.h +++ b/Marlin/src/pins/ramps/pins_RIGIDBOARD.h @@ -75,12 +75,12 @@ #define TEMP_1_PIN 13 // Analog Input #define TEMP_BED_PIN 15 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple -#undef MAX6675_SS_PIN +// SPI for MAX Thermocouple +#undef TEMP_0_CS_PIN #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 53 // Don't use pin 53 if there is even the remote possibility of using Display/SD card + #define TEMP_0_CS_PIN 53 // Don't use pin 53 if there is even the remote possibility of using Display/SD card #else - #define MAX6675_SS_PIN 49 // Don't use pin 49 as this is tied to the switch inside the SD card socket to detect if there is an SD card present + #define TEMP_0_CS_PIN 49 // Don't use pin 49 as this is tied to the switch inside the SD card socket to detect if there is an SD card present #endif // diff --git a/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h b/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h index 53e419af00..de8db60847 100644 --- a/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h +++ b/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h @@ -123,11 +123,11 @@ #define TEMP_1_PIN 15 // Analog Input #define TEMP_BED_PIN 14 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN -1 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN -1 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN -1 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN -1 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/ramps/pins_TT_OSCAR.h b/Marlin/src/pins/ramps/pins_TT_OSCAR.h index aba8f80e61..57a9a560d3 100644 --- a/Marlin/src/pins/ramps/pins_TT_OSCAR.h +++ b/Marlin/src/pins/ramps/pins_TT_OSCAR.h @@ -181,11 +181,11 @@ #define TEMP_4_PIN 12 #endif -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple //#if DISABLED(SDSUPPORT) -// #define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card +// #define TEMP_0_CS_PIN 66 // Don't use 53 if using Display/SD card //#else -// #define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN) +// #define TEMP_0_CS_PIN 66 // Don't use 49 (SD_DETECT_PIN) //#endif // diff --git a/Marlin/src/pins/sam/pins_DUE3DOM.h b/Marlin/src/pins/sam/pins_DUE3DOM.h index de3cb33e8d..81eca3e4b1 100644 --- a/Marlin/src/pins/sam/pins_DUE3DOM.h +++ b/Marlin/src/pins/sam/pins_DUE3DOM.h @@ -82,11 +82,11 @@ #define TEMP_2_PIN 5 // Analog Input (unused) #define TEMP_BED_PIN 1 // Analog Input (BED thermistor) -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN -1 + #define TEMP_0_CS_PIN -1 #else - #define MAX6675_SS_PIN -1 + #define TEMP_0_CS_PIN -1 #endif // diff --git a/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h b/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h index c52199a54d..bc0d29b00a 100644 --- a/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h +++ b/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h @@ -71,11 +71,11 @@ #define TEMP_2_PIN 5 // Analog Input (OnBoard thermistor beta 3950) #define TEMP_BED_PIN 1 // Analog Input (BED thermistor) -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 53 + #define TEMP_0_CS_PIN 53 #else - #define MAX6675_SS_PIN 53 + #define TEMP_0_CS_PIN 53 #endif // diff --git a/Marlin/src/pins/sam/pins_RADDS.h b/Marlin/src/pins/sam/pins_RADDS.h index 7b0ec5ab68..7a865b4ad8 100644 --- a/Marlin/src/pins/sam/pins_RADDS.h +++ b/Marlin/src/pins/sam/pins_RADDS.h @@ -179,11 +179,11 @@ #define TEMP_4_PIN 5 // dummy so will compile when PINS_DEBUGGING is enabled #define TEMP_BED_PIN 4 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 53 + #define TEMP_0_CS_PIN 53 #else - #define MAX6675_SS_PIN 49 + #define TEMP_0_CS_PIN 49 #endif // diff --git a/Marlin/src/pins/sam/pins_RAMPS_DUO.h b/Marlin/src/pins/sam/pins_RAMPS_DUO.h index b1a6680c50..5b2b2f0b66 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_DUO.h +++ b/Marlin/src/pins/sam/pins_RAMPS_DUO.h @@ -60,12 +60,12 @@ #undef TEMP_BED_PIN #define TEMP_BED_PIN 10 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple -#undef MAX6675_SS_PIN +// SPI for MAX Thermocouple +#undef TEMP_0_CS_PIN #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 69 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 69 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 69 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 69 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h index e4c53530f7..30f209ad37 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h +++ b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h @@ -109,11 +109,11 @@ #define TEMP_2_PIN 3 // Analog Input #define TEMP_BED_PIN 0 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 53 + #define TEMP_0_CS_PIN 53 #else - #define MAX6675_SS_PIN 49 + #define TEMP_0_CS_PIN 49 #endif // diff --git a/Marlin/src/pins/sam/pins_RAMPS_SMART.h b/Marlin/src/pins/sam/pins_RAMPS_SMART.h index 3882dfb944..96d0c9e1cc 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_SMART.h +++ b/Marlin/src/pins/sam/pins_RAMPS_SMART.h @@ -94,12 +94,12 @@ #undef TEMP_BED_PIN #define TEMP_BED_PIN 11 // Analog Input -// SPI for Max6675 or Max31855 Thermocouple -#undef MAX6675_SS_PIN +// SPI for MAX Thermocouple +#undef TEMP_0_CS_PIN #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 67 // Don't use 53 if using Display/SD card + #define TEMP_0_CS_PIN 67 // Don't use 53 if using Display/SD card #else - #define MAX6675_SS_PIN 67 // Don't use 49 (SD_DETECT_PIN) + #define TEMP_0_CS_PIN 67 // Don't use 49 (SD_DETECT_PIN) #endif // diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h index a52af48e11..b217428911 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h @@ -156,12 +156,12 @@ #define TEMP_5_PIN 6 // A6 (Marlin 2.0 not support) #endif -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple /* #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 53 + #define TEMP_0_CS_PIN 53 #else - #define MAX6675_SS_PIN 49 + #define TEMP_0_CS_PIN 49 #endif */ diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h index 37ebb567a6..7002886908 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h @@ -142,12 +142,12 @@ #define TEMP_5_PIN 6 // A6 (Marlin 2.0 not support) #endif -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple /* #if DISABLED(SDSUPPORT) - #define MAX6675_SS_PIN 53 + #define TEMP_0_CS_PIN 53 #else - #define MAX6675_SS_PIN 49 + #define TEMP_0_CS_PIN 49 #endif */ diff --git a/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h b/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h index e567b0f5e1..a655d0121c 100644 --- a/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h +++ b/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h @@ -149,12 +149,11 @@ #define SD_MISO_PIN 74 #define SD_MOSI_PIN 75 -// SPI for Max6675 or Max31855 Thermocouple -#define MAX6675_SS_PIN 65 -#define MAX31855_SS0 65 -#define MAX31855_SS1 52 -#define MAX31855_SS2 50 -#define MAX31855_SS3 51 +// SPI for MAX Thermocouple +#define TEMP_0_CS_PIN 65 +#define TEMP_1_CS_PIN 52 +#define TEMP_2_CS_PIN 50 +#define TEMP_3_CS_PIN 51 #define ENC424_SS 61 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 5850f11ef0..8f305542a9 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 @@ -117,14 +117,14 @@ /** * SKR Mini E3 V1.0, V1.2 SKR Mini E3 V2.0 - * _____ _____ - * 5V | 1 2 | GND 5V | 1 2 | GND - * (LCD_EN) PB7 | 3 4 | PB8 (LCD_RS) (LCD_EN) PB15 | 3 4 | PB8 (LCD_RS) - * (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) - * RESET | 7 8 | PA9 (BTN_EN1) RESET | 7 8 | PA9 (BTN_EN1) - * (BTN_ENC) PB6 | 9 10| PB5 (BEEPER) (BTN_ENC) PA15 | 9 10| PB5 (BEEPER) - * ----- ----- - * EXP1 EXP1 + * ______ ______ + * 5V | 1 2 | GND 5V | 1 2 | GND + * (LCD_EN) PB7 | 3 4 | PB8 (LCD_RS) (LCD_EN) PB15 | 3 4 | PB8 (LCD_RS) + * (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) + * RESET | 7 8 | PA9 (BTN_EN1) RESET | 7 8 | PA9 (BTN_EN1) + * (BTN_ENC) PB6 | 9 10 | PB5 (BEEPER) (BTN_ENC) PA15 | 9 10 | PB5 (BEEPER) + * ------ ------ + * EXP1 EXP1 */ #ifdef SKR_MINI_E3_V2 #define EXP1_9 PA15 @@ -134,7 +134,28 @@ #define EXP1_3 PB7 #endif -#if HAS_WIRED_LCD +#if ENABLED(DWIN_CREALITY_LCD) + /** + * ------ ------ ------ + * VCC | 1 2 | GND VCC | 1 2 | GND GND | 2 1 | VCC + * A | 3 4 | B A | 3 4 | B B | 4 3 | A + * | 5 6 TX BEEP | 5 6 ENT ENT | 6 5 | BEEP + * | 7 8 | RX TX | 7 8 | RX RX | 8 7 | TX + * BEEP | 9 10 | ENT | 9 10 | | 10 9 | + * ------ ------ ------ + * EXP1 DWIN DWIN (plug) + * + * All pins are labeled as printed on DWIN PCB. Connect TX-TX, A-A and so on. + */ + + #error "DWIN_CREALITY_LCD requires a custom cable, see diagram above this line. Comment out this line to continue." + + #define BEEPER_PIN EXP1_9 + #define BTN_EN1 EXP1_3 + #define BTN_EN2 PB8 + #define BTN_ENC PB5 + +#elif HAS_WIRED_LCD #if ENABLED(CR10_STOCKDISPLAY) @@ -184,19 +205,19 @@ * TFTGLCD_PANEL_SPI display pinout * * Board Display - * _____ _____ - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) LCD_CS | 3 4 | SD_CS (PA10) - * (FREE) PB9 | 5 6 | PA10 (SD_CS) (FREE) | 5 6 | MOSI (SPI1-MOSI) - * RESET | 7 8 | PA9 (MOD_RESET) (PB5) SD_DET | 7 8 | (FREE) - * (BEEPER) PB6 | 9 10| PB5 (SD_DET) GND | 9 10| 5V - * ----- ----- - * EXP1 EXP1 + * ______ ______ + * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) + * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) LCD_CS | 3 4 | SD_CS (PA10) + * (FREE) PB9 | 5 6 | PA10 (SD_CS) (FREE) | 5 6 | MOSI (SPI1-MOSI) + * RESET | 7 8 | PA9 (MOD_RESET) (PB5) SD_DET | 7 8 | (FREE) + * (BEEPER) PB6 | 9 10 | PB5 (SD_DET) GND | 9 10 | 5V + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * - * Board Adapter Display - * _________ + * Board Display + * * EXP1-1 ----------- EXP1-10 * EXP1-2 ----------- EXP1-9 * SPI1-4 ----------- EXP1-6 @@ -223,17 +244,18 @@ #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. Comment out this line to continue." - /** FYSETC TFT TFT81050 display pinout + /** + * FYSETC TFT TFT81050 display pinout * * Board Display - * _____ _____ - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) MOD_RESET | 3 4 | SD_CS (PA10) - * (FREE) PB9 | 5 6 | PA10 (SD_CS) (PB8) LCD_CS | 5 6 | MOSI (SPI1-MOSI) - * RESET | 7 8 | PA9 (MOD_RESET) (PB5) SD_DET | 7 8 | RESET - * (BEEPER) PB6 | 9 10| PB5 (SD_DET) GND | 9 10| 5V - * ----- ----- - * EXP1 EXP1 + * ______ ______ + * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) + * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) MOD_RESET | 3 4 | SD_CS (PA10) + * (FREE) PB9 | 5 6 | PA10 (SD_CS) (PB8) LCD_CS | 5 6 | MOSI (SPI1-MOSI) + * RESET | 7 8 | PA9 (MOD_RESET) (PB5) SD_DET | 7 8 | RESET + * (BEEPER) PB6 | 9 10 | PB5 (SD_DET) GND | 9 10 | 5V + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * diff --git a/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h b/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h index 429cf14ac5..179c04a304 100644 --- a/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h @@ -100,10 +100,10 @@ //#define TEMP_0_PIN PB3 // E0 K+ #define TEMP_BED_PIN PF7 // THERM_BED -#define MAX6675_SS_PIN PB5 -#define MAX6675_SCK_PIN PB3 -#define MAX6675_DO_PIN PB4 -#define MAX6675_MOSI_PIN PA14 +#define TEMP_0_CS_PIN PB5 +#define TEMP_0_SCK_PIN PB3 +#define TEMP_0_MISO_PIN PB4 +#define TEMP_0_MOSI_PIN PA14 // // Heaters / Fans diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h index b9f1074c7a..8da4dcc9de 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h @@ -121,8 +121,8 @@ // // Thermocouples // -//#define MAX6675_SS_PIN PE5 // TC1 - CS1 -//#define MAX6675_SS_PIN PE6 // TC2 - CS2 +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PE6 // TC2 - CS2 // // Filament runout sensor diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h index ea3a7a1eea..0e2aee9e99 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h @@ -124,8 +124,8 @@ // // Thermocouples // -//#define MAX6675_SS_PIN PE5 // TC1 - CS1 -//#define MAX6675_SS_PIN PE6 // TC2 - CS2 +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PE6 // TC2 - CS2 // // Misc. Functions diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h index 6ef3a08043..3a203aab49 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -188,8 +188,8 @@ // // Thermocouples // -//#define MAX6675_SS_PIN PE5 // TC1 - CS1 -//#define MAX6675_SS_PIN PE6 // TC2 - CS2 +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PE6 // TC2 - CS2 // // Misc. Functions diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h index b56971c7a3..129b640d97 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -175,8 +175,8 @@ /** * Note: MKS Robin Pro board is using SPI2 interface. Make sure your stm32duino library is configured accordingly */ -//#define MAX6675_SS_PIN PE5 // TC1 - CS1 -//#define MAX6675_SS_PIN PF11 // TC2 - CS2 +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PF11 // TC2 - CS2 #define POWER_LOSS_PIN PA2 // PW_DET #define PS_ON_PIN PG11 // PW_OFF 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 4438ed63ac..3151a38ae8 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -298,19 +298,19 @@ #define TEMP_BED_PIN PC0 // T0 <-> Bed -// SPI for Max6675 or Max31855 Thermocouple +// SPI for MAX Thermocouple // Uses a separate SPI bus -// If you have a two-way thermocouple, you can customize two THERMO_CSx_PIN pins (x:1~2) +// If you have a two-way thermocouple, you can customize two TEMP_x_CS_PIN pins (x:0~1) -#define THERMO_SCK_PIN PI1 // SCK -#define THERMO_DO_PIN PI2 // MISO -#define THERMO_CS1_PIN PH9 // GTR K-TEMP -#define THERMO_CS2_PIN PH2 // M5 K-TEMP +#define TEMP_0_CS_PIN PH9 // GTR K-TEMP +#define TEMP_0_SCK_PIN PI1 // SCK +#define TEMP_0_MISO_PIN PI2 // MISO +//#define TEMP_0_MOSI_PIN ... // For MAX31865 -#define MAX6675_SS_PIN THERMO_CS1_PIN -#define MAX6675_SS2_PIN THERMO_CS2_PIN -#define MAX6675_SCK_PIN THERMO_SCK_PIN -#define MAX6675_DO_PIN THERMO_DO_PIN +#define TEMP_1_CS_PIN PH2 // M5 K-TEMP +#define TEMP_1_SCK_PIN TEMP_0_SCK_PIN +#define TEMP_1_MISO_PIN TEMP_0_MISO_PIN +//#define TEMP_1_MOSI_PIN TEMP_0_MOSI_PIN // // Heaters / Fans diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h index 7aeab0196a..504a86d7d0 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h @@ -56,7 +56,9 @@ // // Servos // -#define SERVO0_PIN PA3 +#ifndef SERVO0_PIN + #define SERVO0_PIN PA3 +#endif // // Limit Switches diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h b/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h index a33f35bd55..e90ac552ae 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h @@ -68,6 +68,12 @@ // #define X_ENABLE_PIN PE9 +// +// Servos +// Z_MAX_PIN only works in input mode +// +#define SERVO0_PIN PA2 + #if HAS_TMC_UART #define X_SERIAL_TX_PIN PE7 #define X_SERIAL_RX_PIN PE7 diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h index 105d0d6f60..65db99025c 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h @@ -104,16 +104,16 @@ // MAX6675 Cold-Junction-Compensated K-Thermocouple to Digital Converter (0°C to +1024°C) // https://datasheets.maximintegrated.com/en/ds/MAX6675.pdf -#define MAX6675_SCK_PIN PB3 // max6675 datasheet: SCK pin, found with multimeter, not tested -#define MAX6675_DO_PIN PB4 // max6675 datasheet: SO pin, found with multimeter, not tested -#define MAX6675_SS_PIN PC4 // max6675 datasheet: /CS pin, found with multimeter, not tested and likely wrong +#define TEMP_0_CS_PIN PC4 // max6675 datasheet: /CS pin, found with multimeter, not tested and likely wrong +#define TEMP_0_SCK_PIN PB3 // max6675 datasheet: SCK pin, found with multimeter, not tested +#define TEMP_0_MISO_PIN PB4 // max6675 datasheet: SO pin, found with multimeter, not tested // Expansion board with second max6675 // Warning: Some boards leave the slot unpopulated. -//#define MAX6675_SCK2_PIN PB3 // max6675 datasheet: SCK pin, found with multimeter, not tested -//#define MAX6675_DO2_PIN PB4 // max6675 datasheet: SO pin, found with multimeter, not tested -//#define MAX6675_SS2_PIN PF1 // max6675 datasheet: /CS pin, found with multimeter, not tested +//#define TEMP_1_CS_PIN PF1 // max6675 datasheet: /CS pin, found with multimeter, not tested +//#define TEMP_1_SCK_PIN PB3 // max6675 datasheet: SCK pin, found with multimeter, not tested +//#define TEMP_1_MISO_PIN PB4 // max6675 datasheet: SO pin, found with multimeter, not tested // // Heaters / Fans diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h index 5a056b97cd..9ae2870a40 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h @@ -172,8 +172,8 @@ // // Thermocouples // -//#define MAX6675_SS_PIN HEATER_0_PIN // TC1 - CS1 -//#define MAX6675_SS_PIN HEATER_1_PIN // TC2 - CS2 +//#define TEMP_0_CS_PIN HEATER_0_PIN // TC1 - CS1 +//#define TEMP_0_CS_PIN HEATER_1_PIN // TC2 - CS2 // // Misc. Functions diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h index 2b0df002d3..0b9512a1cb 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -189,8 +189,8 @@ // // Thermocouples // -//#define MAX6675_SS_PIN PE5 // TC1 - CS1 -//#define MAX6675_SS_PIN PE6 // TC2 - CS2 +//#define TEMP_0_CS_PIN PE5 // TC1 - CS1 +//#define TEMP_0_CS_PIN PE6 // TC2 - CS2 // // Misc. Functions diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 19b2f04bfd..bcb0317990 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -258,54 +258,82 @@ void CardReader::selectByName(SdFile dir, const char * const match) { } } -// -// Recursive method to print all files within a folder in flat -// DOS 8.3 format. This style of listing is the most compatible -// with legacy hosts. -// -// This method recurses to unlimited depth and lists every -// G-code file within the given parent. If the hierarchy is -// very deep this can blow up the stack, so a 'depth' parameter -// (as with printListingJSON) would be a good addition. -// -void CardReader::printListing(SdFile parent, const char * const prepend/*=nullptr*/) { +/** + * Recursive method to print all files within a folder in flat + * DOS 8.3 format. This style of listing is the most compatible + * with legacy hosts. + * + * This method recurses to unlimited depth and lists all G-code + * files within the given parent. If the hierarchy is very deep + * this can blow up the stack, so a 'depth' parameter would be a + * good addition. + */ +void CardReader::printListing( + SdFile parent + OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames/*=false*/) + , const char * const prepend/*=nullptr*/ + OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong/*=nullptr*/) +) { dir_t p; while (parent.readDir(&p, longFilename) > 0) { if (DIR_IS_SUBDIR(&p)) { - // Get the short name for the item, which we know is a folder - char dosFilename[FILENAME_LENGTH]; + size_t lenPrepend = prepend ? strlen(prepend) + 1 : 0; + // Allocate enough stack space for the full path including / separator + char path[lenPrepend + FILENAME_LENGTH]; + if (prepend) { + strcpy(path, prepend); + path[lenPrepend - 1] = '/'; + } + char* dosFilename = path + lenPrepend; createFilename(dosFilename, p); - // Allocate enough stack space for the full path to a folder, trailing slash, and nul - const bool prepend_is_empty = (!prepend || prepend[0] == '\0'); - const int len = (prepend_is_empty ? 1 : strlen(prepend)) + strlen(dosFilename) + 1 + 1; - char path[len]; - - // Append the FOLDERNAME12/ to the passed string. - // It contains the full path to the "parent" argument. - // We now have the full path to the item in this folder. - strcpy(path, prepend_is_empty ? "/" : prepend); // root slash if prepend is empty - strcat(path, dosFilename); // FILENAME_LENGTH characters maximum - strcat(path, "/"); // 1 character - - // Serial.print(path); - // Get a new directory object using the full path // and dive recursively into it. SdFile child; // child.close() in destructor if (child.open(&parent, dosFilename, O_READ)) - printListing(child, path); + #if ENABLED(LONG_FILENAME_HOST_SUPPORT) + if (includeLongNames) { + size_t lenPrependLong = prependLong ? strlen(prependLong) + 1 : 0; + // Allocate enough stack space for the full long path including / separator + char pathLong[lenPrependLong + strlen(longFilename) + 1]; + if (prependLong) { + strcpy(pathLong, prependLong); + pathLong[lenPrependLong - 1] = '/'; + } + strcpy(pathLong + lenPrependLong, longFilename); + printListing(child, /*includeLongNames=*/true, path, pathLong); + } + else + #endif + printListing(child, path); else { SERIAL_ECHO_MSG(STR_SD_CANT_OPEN_SUBDIR, dosFilename); return; } } else if (is_dir_or_gcode(p)) { - if (prepend) SERIAL_ECHO(prepend); + if (prepend) { + SERIAL_ECHO(prepend); + SERIAL_CHAR('/'); + } SERIAL_ECHO(createFilename(filename, p)); SERIAL_CHAR(' '); - SERIAL_ECHOLN(p.fileSize); + #if ENABLED(LONG_FILENAME_HOST_SUPPORT) + if (!includeLongNames) + #endif + SERIAL_ECHOLN(p.fileSize); + #if ENABLED(LONG_FILENAME_HOST_SUPPORT) + else { + SERIAL_ECHO(p.fileSize); + SERIAL_CHAR(' '); + if (prependLong) { + SERIAL_ECHO(prependLong); + SERIAL_CHAR('/'); + } + SERIAL_ECHOLN(longFilename[0] ? longFilename : "???"); + } + #endif } } } @@ -313,10 +341,10 @@ void CardReader::printListing(SdFile parent, const char * const prepend/*=nullpt // // List all files on the SD card // -void CardReader::ls() { +void CardReader::ls(TERN_(LONG_FILENAME_HOST_SUPPORT, bool includeLongNames/*=false*/)) { if (flag.mounted) { root.rewind(); - printListing(root); + printListing(root OPTARG(LONG_FILENAME_HOST_SUPPORT, includeLongNames)); } } diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 943cdae741..66cb97baeb 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -199,7 +199,7 @@ public: FORCE_INLINE static void getfilename_sorted(const uint16_t nr) { selectFileByIndex(nr); } #endif - static void ls(); + static void ls(TERN_(LONG_FILENAME_HOST_SUPPORT, bool includeLongNames=false)); #if ENABLED(POWER_LOSS_RECOVERY) static bool jobRecoverFileExists(); @@ -330,7 +330,12 @@ private: static int countItems(SdFile dir); static void selectByIndex(SdFile dir, const uint8_t index); static void selectByName(SdFile dir, const char * const match); - static void printListing(SdFile parent, const char * const prepend=nullptr); + static void printListing( + SdFile parent + OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames=false) + , const char * const prepend=nullptr + OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong=nullptr) + ); #if ENABLED(SDCARD_SORT_ALPHA) static void flush_presort(); diff --git a/buildroot/share/PlatformIO/boards/marlin_fysetc_s6.json b/buildroot/share/PlatformIO/boards/marlin_fysetc_s6.json index 286e46ffbd..42a203786d 100644 --- a/buildroot/share/PlatformIO/boards/marlin_fysetc_s6.json +++ b/buildroot/share/PlatformIO/boards/marlin_fysetc_s6.json @@ -21,7 +21,7 @@ "name": "3D Printer control board", "upload": { "maximum_ram_size": 131072, - "maximum_size": 524288, + "maximum_size": 458752, "protocol": "stlink", "protocols": [ "jlink", diff --git a/buildroot/share/PlatformIO/boards/marlin_fysetc_s6_8000.json b/buildroot/share/PlatformIO/boards/marlin_fysetc_s6_8000.json new file mode 100644 index 0000000000..1d808a23d7 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_fysetc_s6_8000.json @@ -0,0 +1,35 @@ +{ + "build": { + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F446xx", + "f_cpu": "180000000L", + "mcu": "stm32f446ret6", + "variant": "MARLIN_FYSETC_S6" + }, + "connectivity": [ + "can" + ], + "debug": { + "jlink_device": "STM32F446RE", + "openocd_target": "stm32f4x", + "svd_path": "STM32F446x.svd" + }, + "frameworks": [ + "arduino", + "stm32cube" + ], + "name": "3D Printer control board", + "upload": { + "maximum_ram_size": 131072, + "maximum_size": 491520, + "protocol": "stlink", + "protocols": [ + "jlink", + "stlink", + "blackmagic", + "serial" + ] + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f446.html", + "vendor": "FYSETC" +} diff --git a/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py b/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py index 29705de442..fa91b7bb70 100644 --- a/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py +++ b/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py @@ -30,15 +30,3 @@ if env.MarlinFeatureIsEnabled("POSTMORTEM_DEBUGGING"): print("Done patching exception handler") print("Libmaple modified and ready for post mortem debugging") - -mf = env["MARLIN_FEATURES"] -rxBuf = mf["RX_BUFFER_SIZE"] if "RX_BUFFER_SIZE" in mf else "0" -txBuf = mf["TX_BUFFER_SIZE"] if "TX_BUFFER_SIZE" in mf else "0" -if int(rxBuf) < 64: - rxBuf = "64" -if int(txBuf) < 64: - txBuf = "64" - -build_flags = env.get('BUILD_FLAGS') -build_flags.append("-DUSART_RX_BUF_SIZE=" + rxBuf + " -DUSART_TX_BUF_SIZE=" + txBuf) -env.Replace(BUILD_FLAGS=build_flags) diff --git a/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py b/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py index 2be5a202ef..fecce47db3 100644 --- a/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py +++ b/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py @@ -13,11 +13,16 @@ Import("env") # # The script will set the value as the default one (64 bytes) # or the user-configured one, whichever is higher. +# +# Marlin has 128 and 32 as default values for RX_BUFFER_SIZE and +# TX_BUFFER_SIZE respectively. We use the highest value. mf = env["MARLIN_FEATURES"] -rxBuf = str(max(64, int(mf["RX_BUFFER_SIZE"]) if "RX_BUFFER_SIZE" in mf else 0)) +rxBuf = str(max(128, int(mf["RX_BUFFER_SIZE"]) if "RX_BUFFER_SIZE" in mf else 0)) txBuf = str(max(64, int(mf["TX_BUFFER_SIZE"]) if "TX_BUFFER_SIZE" in mf else 0)) build_flags = env.get('BUILD_FLAGS') build_flags.append("-DSERIAL_RX_BUFFER_SIZE=" + rxBuf) build_flags.append("-DSERIAL_TX_BUFFER_SIZE=" + txBuf) +build_flags.append("-DUSART_RX_BUF_SIZE=" + rxBuf) +build_flags.append("-DUSART_TX_BUF_SIZE=" + txBuf) env.Replace(BUILD_FLAGS=build_flags) diff --git a/ini/features.ini b/ini/features.ini index a1e9688447..5a1b48804d 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -27,9 +27,9 @@ HAS_TMC26X = TMC26XStepper=https://github.com/trinam src_filter=+ HAS_L64XX = Arduino-L6470@0.8.0 src_filter=+ + + + +LIB_INTERNAL_MAX31865 = src_filter=+ NEOPIXEL_LED = adafruit/Adafruit NeoPixel@~1.8.0 src_filter=+ -TEMP_.+_IS_MAX31865 = Adafruit MAX31865 library@~1.1.0 I2C_AMMETER = peterus/INA226Lib@1.1.2 USES_LIQUIDCRYSTAL = fmalpartida/LiquidCrystal@1.5.0 USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4 diff --git a/ini/stm32f1-maple.ini b/ini/stm32f1-maple.ini index 25ebfb64b6..2580c4700c 100644 --- a/ini/stm32f1-maple.ini +++ b/ini/stm32f1-maple.ini @@ -36,6 +36,7 @@ lib_deps = ${common.lib_deps} platform_packages = tool-stm32duino extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/fix_framework_weakness.py + pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py # # STM32F103RC @@ -325,7 +326,8 @@ lib_ignore = ${common_stm32f1.lib_ignore} platform = ${common_stm32f1.platform} extends = common_stm32f1 board = marlin_CHITU_F103 -extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-dependencies.py +extra_scripts = ${common_stm32f1.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/common-dependencies.py pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py buildroot/share/PlatformIO/scripts/chitu_crypt.py build_flags = ${common_stm32f1.build_flags} diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index 0b394d1730..6c39d0b6fa 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -150,7 +150,7 @@ board_build.variant = MARLIN_F103Rx board_build.offset = 0x7000 board_upload.offset_address = 0x08007000 build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -extra_scripts = ${common.extra_scripts} +extra_scripts = ${common_stm32.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py pre:buildroot/share/PlatformIO/scripts/random-bin.py buildroot/share/PlatformIO/scripts/stm32_bootloader.py @@ -174,7 +174,7 @@ board_build.variant = MARLIN_F103Rx board_build.offset = 0x7000 board_upload.offset_address = 0x08007000 build_unflags = ${common_stm32.build_unflags} -extra_scripts = ${common.extra_scripts} +extra_scripts = ${common_stm32.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py buildroot/share/PlatformIO/scripts/stm32_bootloader.py debug_tool = jlink diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index e7695dcc7a..6067bbc3b8 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -76,15 +76,28 @@ platform = ${common_stm32.platform} extends = common_stm32 platform_packages = tool-stm32duino board = marlin_fysetc_s6 -build_flags = ${common_stm32.build_flags} - -DVECT_TAB_OFFSET=0x10000 - -DHAL_PCD_MODULE_ENABLED +build_flags = ${common_stm32.build_flags} -DVECT_TAB_OFFSET=0x10000 -DHAL_PCD_MODULE_ENABLED extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py debug_tool = stlink upload_protocol = dfu upload_command = dfu-util -a 0 -s 0x08010000:leave -D "$SOURCE" +# +# FYSETC S6 new bootloader +# +[env:FYSETC_S6_8000] +platform = ${common_stm32.platform} +extends = env:FYSETC_S6 +board = marlin_fysetc_s6_8000 +board_build.offset = 0x8000 +board_upload.offset_address = 0x08008000 +build_flags = ${common_stm32.build_flags} -DHAL_PCD_MODULE_ENABLED +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/stm32_bootloader.py +upload_command = dfu-util -a 0 -s 0x08008000:leave -D "$SOURCE" + # # STM32F407VET6 with RAMPS-like shield # 'Black' STM32F407VET6 board - https://wiki.stm32duino.com/index.php?title=STM32F407 diff --git a/platformio.ini b/platformio.ini index f55f5f5a93..afdd823f9e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -230,6 +230,7 @@ default_src_filter = + - - + - - - - - - + - - - - -