diff --git a/.gitignore b/.gitignore index bc603ba38b..a83bfa4265 100755 --- a/.gitignore +++ b/.gitignore @@ -27,7 +27,7 @@ bdf2u8g # OS # applet/ -*.DS_Store +.DS_Store # # Misc @@ -167,7 +167,3 @@ __pycache__ # IOLogger logs *_log.csv - -# Simulation / Native -eeprom.dat -imgui.ini diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index d8ced232b4..8ab3929c41 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -35,7 +35,7 @@ * * Advanced settings can be found in Configuration_adv.h */ -#define CONFIGURATION_H_VERSION 02000902 +#define CONFIGURATION_H_VERSION 02000903 //=========================================================================== //============================= Getting Started ============================= @@ -2770,23 +2770,11 @@ // // Ender-3 v2 OEM display. A DWIN display with Rotary Encoder. // -//#define DWIN_CREALITY_LCD - -// -// Ender-3 v2 OEM display, enhanced. -// -//#define DWIN_CREALITY_LCD_ENHANCED - -// -// Ender-3 v2 OEM display with enhancements by Jacob Myers -// -//#define DWIN_CREALITY_LCD_JYERSUI - -// -// MarlinUI for Creality's DWIN display (and others) -// -//#define DWIN_MARLINUI_PORTRAIT -//#define DWIN_MARLINUI_LANDSCAPE +//#define DWIN_CREALITY_LCD // Creality UI +//#define DWIN_CREALITY_LCD_ENHANCED // Enhanced UI +//#define DWIN_CREALITY_LCD_JYERSUI // Jyers UI by Jacob Myers +//#define DWIN_MARLINUI_PORTRAIT // MarlinUI (portrait orientation) +//#define DWIN_MARLINUI_LANDSCAPE // MarlinUI (landscape orientation) // // Touch Screen Settings diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index fbf2c41943..fc495a6ea6 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -30,7 +30,7 @@ * * Basic settings can be found in Configuration.h */ -#define CONFIGURATION_ADV_H_VERSION 02000902 +#define CONFIGURATION_ADV_H_VERSION 02000903 //=========================================================================== //============================= Thermal Settings ============================ @@ -414,7 +414,7 @@ */ #define AUTOTEMP #if ENABLED(AUTOTEMP) - #define AUTOTEMP_OLDWEIGHT 0.98 + #define AUTOTEMP_OLDWEIGHT 0.98 // Factor used to weight previous readings (0.0 < value < 1.0) // Turn on AUTOTEMP on M104/M109 by default using proportions set here //#define AUTOTEMP_PROPORTIONAL #if ENABLED(AUTOTEMP_PROPORTIONAL) @@ -1913,6 +1913,7 @@ #define LIN_ADVANCE_K 0.22 // Unit: mm compression per 1mm/s extruder speed //#define LA_DEBUG // If enabled, this will generate debug information output over USB. //#define EXPERIMENTAL_SCURVE // Enable this option to permit S-Curve Acceleration + //#define ALLOW_LOW_EJERK // Allow a DEFAULT_EJERK value of <10. Recommended for direct drive hotends. #endif // @section leveling @@ -1988,65 +1989,69 @@ /** * Thermal Probe Compensation - * Probe measurements are adjusted to compensate for temperature distortion. - * Use G76 to calibrate this feature. Use M871 to set values manually. - * For a more detailed explanation of the process see G76_M871.cpp. + * + * Adjust probe measurements to compensate for distortion associated with the temperature + * of the probe, bed, and/or hotend. + * Use G76 to automatically calibrate this feature for probe and bed temperatures. + * (Extruder temperature/offset values must be calibrated manually.) + * Use M871 to set temperature/offset values manually. + * For more details see https://marlinfw.org/docs/features/probe_temp_compensation.html */ -#if HAS_BED_PROBE && TEMP_SENSOR_PROBE && TEMP_SENSOR_BED - // Enable thermal first layer compensation using bed and probe temperatures - #define PROBE_TEMP_COMPENSATION +//#define PTC_PROBE // Compensate based on probe temperature +//#define PTC_BED // Compensate based on bed temperature +//#define PTC_HOTEND // Compensate based on hotend temperature - // Add additional compensation depending on hotend temperature - // Note: this values cannot be calibrated and have to be set manually - #if ENABLED(PROBE_TEMP_COMPENSATION) +#if ANY(PTC_PROBE, PTC_BED, PTC_HOTEND) + /** + * If the probe is outside the defined range, use linear extrapolation with the closest + * point and the point with index PTC_LINEAR_EXTRAPOLATION. e.g., If set to 4 it will use the + * linear extrapolation between data[0] and data[4] for values below PTC_PROBE_START. + */ + //#define PTC_LINEAR_EXTRAPOLATION 4 + + #if ENABLED(PTC_PROBE) + // Probe temperature calibration generates a table of values starting at PTC_PROBE_START + // (e.g., 30), in steps of PTC_PROBE_RES (e.g., 5) with PTC_PROBE_COUNT (e.g., 10) samples. + #define PTC_PROBE_START 30 // (°C) + #define PTC_PROBE_RES 5 // (°C) + #define PTC_PROBE_COUNT 10 + #define PTC_PROBE_ZOFFS { 0 } // (µm) Z adjustments per sample + #endif + + #if ENABLED(PTC_BED) + // Bed temperature calibration builds a similar table. + #define PTC_BED_START 60 // (°C) + #define PTC_BED_RES 5 // (°C) + #define PTC_BED_COUNT 10 + #define PTC_BED_ZOFFS { 0 } // (µm) Z adjustments per sample + #endif + + #if ENABLED(PTC_HOTEND) + // Note: There is no automatic calibration for the hotend. Use M871. + #define PTC_HOTEND_START 180 // (°C) + #define PTC_HOTEND_RES 5 // (°C) + #define PTC_HOTEND_COUNT 20 + #define PTC_HOTEND_ZOFFS { 0 } // (µm) Z adjustments per sample + #endif + + // G76 options + #if BOTH(PTC_PROBE, PTC_BED) // Park position to wait for probe cooldown #define PTC_PARK_POS { 0, 0, 100 } // Probe position to probe and wait for probe to reach target temperature + //#define PTC_PROBE_POS { 12.0f, 7.3f } // Example: MK52 magnetic heatbed #define PTC_PROBE_POS { 90, 100 } - // Enable additional compensation using hotend temperature - // Note: this values cannot be calibrated automatically but have to be set manually via M871. - //#define USE_TEMP_EXT_COMPENSATION - - // Probe temperature calibration generates a table of values starting at PTC_SAMPLE_START - // (e.g., 30), in steps of PTC_SAMPLE_RES (e.g., 5) with PTC_SAMPLE_COUNT (e.g., 10) samples. - - //#define PTC_SAMPLE_START 30 // (°C) - //#define PTC_SAMPLE_RES 5 // (°C) - //#define PTC_SAMPLE_COUNT 10 - - // Bed temperature calibration builds a similar table. - - //#define BTC_SAMPLE_START 60 // (°C) - //#define BTC_SAMPLE_RES 5 // (°C) - //#define BTC_SAMPLE_COUNT 10 - - #if ENABLED(USE_TEMP_EXT_COMPENSATION) - //#define ETC_SAMPLE_START 180 // (°C) - //#define ETC_SAMPLE_RES 5 // (°C) - //#define ETC_SAMPLE_COUNT 20 - #endif - - // The temperature the probe should be at while taking measurements during bed temperature - // calibration. - //#define BTC_PROBE_TEMP 30 // (°C) + // The temperature the probe should be at while taking measurements during + // bed temperature calibration. + #define PTC_PROBE_TEMP 30 // (°C) // Height above Z=0.0 to raise the nozzle. Lowering this can help the probe to heat faster. - // Note: the Z=0.0 offset is determined by the probe offset which can be set using M851. - //#define PTC_PROBE_HEATING_OFFSET 0.5 - - // Height to raise the Z-probe between heating and taking the next measurement. Some probes - // may fail to untrigger if they have been triggered for a long time, which can be solved by - // increasing the height the probe is raised to. - //#define PTC_PROBE_RAISE 15 - - // If the probe is outside of the defined range, use linear extrapolation using the closest - // point and the PTC_LINEAR_EXTRAPOLATION'th next point. E.g. if set to 4 it will use data[0] - // and data[4] to perform linear extrapolation for values below PTC_SAMPLE_START. - //#define PTC_LINEAR_EXTRAPOLATION 4 + // Note: The Z=0.0 offset is determined by the probe Z offset (e.g., as set with M851 Z). + #define PTC_PROBE_HEATING_OFFSET 0.5 #endif -#endif +#endif // PTC_PROBE || PTC_BED || PTC_HOTEND // @section extras @@ -3844,7 +3849,8 @@ #if ENABLED(HOST_ACTION_COMMANDS) //#define HOST_PAUSE_M76 //#define HOST_PROMPT_SUPPORT - //#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start + //#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start + //#define HOST_SHUTDOWN_MENU_ITEM // Add a menu item that tells the host to shut down #endif /** @@ -4218,3 +4224,6 @@ */ //#define SOFT_RESET_VIA_SERIAL // 'KILL' and '^X' commands will soft-reset the controller //#define SOFT_RESET_ON_KILL // Use a digital button to soft-reset the controller after KILL + +// Report uncleaned reset reason from register r2 instead of MCUSR. Supported by Optiboot on AVR. +//#define OPTIBOOT_RESET_REASON diff --git a/Marlin/Version.h b/Marlin/Version.h index c158f2732e..e562730ae3 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2021-10-25" +//#define STRING_DISTRIBUTION_DATE "2021-11-04" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/HAL/AVR/HAL.cpp b/Marlin/src/HAL/AVR/HAL.cpp index 708583b262..d7bf2a6f6f 100644 --- a/Marlin/src/HAL/AVR/HAL.cpp +++ b/Marlin/src/HAL/AVR/HAL.cpp @@ -35,12 +35,31 @@ // Public Variables // ------------------------ -//uint8_t MCUSR; +// Don't initialize/override variable (which would happen in .init4) +uint8_t reset_reason __attribute__((section(".noinit"))); // ------------------------ // Public functions // ------------------------ +__attribute__((naked)) // Don't output function pro- and epilogue +__attribute__((used)) // Output the function, even if "not used" +__attribute__((section(".init3"))) // Put in an early user definable section +void HAL_save_reset_reason() { + #if ENABLED(OPTIBOOT_RESET_REASON) + __asm__ __volatile__( + A("STS %0, r2") + : "=m"(reset_reason) + ); + #else + reset_reason = MCUSR; + #endif + + // Clear within 16ms since WDRF bit enables a 16ms watchdog timer -> Boot loop + MCUSR = 0; + wdt_disable(); +} + void HAL_init() { // Init Servo Pins #define INIT_SERVO(N) OUT_WRITE(SERVO##N##_PIN, LOW) diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index ecb566ed46..2217f239d6 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -91,7 +91,7 @@ typedef int8_t pin_t; // Public Variables // ------------------------ -//extern uint8_t MCUSR; +extern uint8_t reset_reason; // Serial ports #ifdef USBCON @@ -152,8 +152,8 @@ void HAL_init(); //void _delay_ms(const int delay); -inline void HAL_clear_reset_source() { MCUSR = 0; } -inline uint8_t HAL_get_reset_source() { return MCUSR; } +inline void HAL_clear_reset_source() { } +inline uint8_t HAL_get_reset_source() { return reset_reason; } void HAL_reboot(); @@ -221,7 +221,7 @@ void set_pwm_frequency(const pin_t pin, int f_desired); /** * set_pwm_duty - * Sets the PWM duty cycle of the provided pin to the provided value + * Set the PWM duty cycle of the provided pin to the provided value * Optionally allows inverting the duty cycle [default = false] * Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255] */ diff --git a/Marlin/src/HAL/AVR/fast_pwm.cpp b/Marlin/src/HAL/AVR/fast_pwm.cpp index 238c1124ad..2556fa0441 100644 --- a/Marlin/src/HAL/AVR/fast_pwm.cpp +++ b/Marlin/src/HAL/AVR/fast_pwm.cpp @@ -22,11 +22,10 @@ #ifdef __AVR__ #include "../../inc/MarlinConfigPre.h" +#include "HAL.h" #if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM -#include "HAL.h" - struct Timer { volatile uint8_t* TCCRnQ[3]; // max 3 TCCR registers per timer volatile uint16_t* OCRnQ[3]; // max 3 OCR registers per timer @@ -153,7 +152,7 @@ Timer get_pwm_timer(const pin_t pin) { void set_pwm_frequency(const pin_t pin, int f_desired) { Timer timer = get_pwm_timer(pin); - if (timer.n == 0) return; // Don't proceed if protected timer or not recognised + if (timer.n == 0) return; // Don't proceed if protected timer or not recognized uint16_t size; if (timer.n == 2) size = 255; else size = 65535; @@ -243,40 +242,39 @@ void set_pwm_frequency(const pin_t pin, int f_desired) { _SET_ICRn(timer.ICRn, res); // Set ICRn value (TOP) = res } +#endif // NEEDS_HARDWARE_PWM + void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { - // If v is 0 or v_size (max), digitalWrite to LOW or HIGH. - // Note that digitalWrite also disables pwm output for us (sets COM bit to 0) - if (v == 0) - digitalWrite(pin, invert); - else if (v == v_size) - digitalWrite(pin, !invert); - else { - Timer timer = get_pwm_timer(pin); - if (timer.n == 0) return; // Don't proceed if protected timer or not recognised - // Set compare output mode to CLEAR -> SET or SET -> CLEAR (if inverted) - _SET_COMnQ(timer.TCCRnQ, (timer.q - #ifdef TCCR2 - + (timer.q == 2) // COM20 is on bit 4 of TCCR2, thus requires q + 1 in the macro - #endif - ), COM_CLEAR_SET + invert - ); + #if NEEDS_HARDWARE_PWM - uint16_t top; - if (timer.n == 2) { // if TIMER2 - top = ( - #if ENABLED(USE_OCR2A_AS_TOP) - *timer.OCRnQ[0] // top = OCR2A - #else - 255 // top = 0xFF (max) - #endif + // If v is 0 or v_size (max), digitalWrite to LOW or HIGH. + // Note that digitalWrite also disables pwm output for us (sets COM bit to 0) + if (v == 0) + digitalWrite(pin, invert); + else if (v == v_size) + digitalWrite(pin, !invert); + else { + Timer timer = get_pwm_timer(pin); + if (timer.n == 0) return; // Don't proceed if protected timer or not recognized + // Set compare output mode to CLEAR -> SET or SET -> CLEAR (if inverted) + _SET_COMnQ(timer.TCCRnQ, (timer.q + #ifdef TCCR2 + + (timer.q == 2) // COM20 is on bit 4 of TCCR2, thus requires q + 1 in the macro + #endif + ), COM_CLEAR_SET + invert ); - } - else - top = *timer.ICRn; // top = ICRn - _SET_OCRnQ(timer.OCRnQ, timer.q, v * float(top) / float(v_size)); // Scale 8/16-bit v to top value - } + uint16_t top = (timer.n == 2) ? TERN(USE_OCR2A_AS_TOP, *timer.OCRnQ[0], 255) : *timer.ICRn; + _SET_OCRnQ(timer.OCRnQ, timer.q, (v * top + v_size / 2) / v_size); // Scale 8/16-bit v to top value + } + + #else + + analogWrite(pin, v); + UNUSED(v_size); + UNUSED(invert); + + #endif } -#endif // NEEDS_HARDWARE_PWM #endif // __AVR__ diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index fb90c40aa7..96ab5d9808 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -144,6 +144,11 @@ inline void HAL_adc_init() {}//todo void HAL_adc_start_conversion(const uint8_t ch); uint16_t HAL_adc_get_result(); +// +// PWM +// +inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + // // Pin Map // diff --git a/Marlin/src/HAL/DUE/upload_extra_script.py b/Marlin/src/HAL/DUE/upload_extra_script.py index d52a0a3642..4f7a494512 100644 --- a/Marlin/src/HAL/DUE/upload_extra_script.py +++ b/Marlin/src/HAL/DUE/upload_extra_script.py @@ -4,15 +4,16 @@ # Windows: bossac.exe # Other: leave unchanged # +import pioutil +if pioutil.is_pio_build(): + import platform + current_OS = platform.system() -import platform -current_OS = platform.system() + if current_OS == 'Windows': -if current_OS == 'Windows': + Import("env") - Import("env") - - # Use bossac.exe on Windows - env.Replace( - UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot $SOURCE" - ) + # Use bossac.exe on Windows + env.Replace( + UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot $SOURCE" + ) diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index 8a8f6df640..8473e3c4e4 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -129,6 +129,10 @@ void HAL_adc_init(); void HAL_adc_start_conversion(const uint8_t adc_pin); +// PWM +inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + +// Pin Map #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) diff --git a/Marlin/src/HAL/ESP32/i2s.cpp b/Marlin/src/HAL/ESP32/i2s.cpp index 557ea319e6..3e77b65836 100644 --- a/Marlin/src/HAL/ESP32/i2s.cpp +++ b/Marlin/src/HAL/ESP32/i2s.cpp @@ -64,12 +64,9 @@ uint32_t i2s_port_data = 0; #define I2S_EXIT_CRITICAL() portEXIT_CRITICAL(&i2s_spinlock[i2s_num]) static inline void gpio_matrix_out_check(uint32_t gpio, uint32_t signal_idx, bool out_inv, bool oen_inv) { - //if pin = -1, do not need to configure - if (gpio != -1) { - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[gpio], PIN_FUNC_GPIO); - gpio_set_direction((gpio_num_t)gpio, (gpio_mode_t)GPIO_MODE_DEF_OUTPUT); - gpio_matrix_out(gpio, signal_idx, out_inv, oen_inv); - } + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[gpio], PIN_FUNC_GPIO); + gpio_set_direction((gpio_num_t)gpio, (gpio_mode_t)GPIO_MODE_DEF_OUTPUT); + gpio_matrix_out(gpio, signal_idx, out_inv, oen_inv); } static esp_err_t i2s_reset_fifo(i2s_port_t i2s_num) { @@ -256,13 +253,7 @@ int i2s_init() { I2S0.fifo_conf.dscr_en = 0; - I2S0.conf_chan.tx_chan_mod = ( - #if ENABLED(I2S_STEPPER_SPLIT_STREAM) - 4 - #else - 0 - #endif - ); + I2S0.conf_chan.tx_chan_mod = TERN(I2S_STEPPER_SPLIT_STREAM, 4, 0); I2S0.fifo_conf.tx_fifo_mod = 0; I2S0.conf.tx_mono = 0; @@ -313,9 +304,16 @@ int i2s_init() { xTaskCreatePinnedToCore(stepperTask, "StepperTask", 10000, nullptr, 1, nullptr, CONFIG_ARDUINO_RUNNING_CORE); // run I2S stepper task on same core as rest of Marlin // Route the i2s pins to the appropriate GPIO - gpio_matrix_out_check(I2S_DATA, I2S0O_DATA_OUT23_IDX, 0, 0); - gpio_matrix_out_check(I2S_BCK, I2S0O_BCK_OUT_IDX, 0, 0); - gpio_matrix_out_check(I2S_WS, I2S0O_WS_OUT_IDX, 0, 0); + // If a pin is not defined, no need to configure + #if defined(I2S_DATA) && I2S_DATA >= 0 + gpio_matrix_out_check(I2S_DATA, I2S0O_DATA_OUT23_IDX, 0, 0); + #endif + #if defined(I2S_BCK) && I2S_BCK >= 0 + gpio_matrix_out_check(I2S_BCK, I2S0O_BCK_OUT_IDX, 0, 0); + #endif + #if defined(I2S_WS) && I2S_WS >= 0 + gpio_matrix_out_check(I2S_WS, I2S0O_WS_OUT_IDX, 0, 0); + #endif // Start the I2S peripheral return i2s_start(I2S_NUM_0); diff --git a/Marlin/src/HAL/LINUX/HAL.h b/Marlin/src/HAL/LINUX/HAL.h index b80fe210f8..d7d3a92b73 100644 --- a/Marlin/src/HAL/LINUX/HAL.h +++ b/Marlin/src/HAL/LINUX/HAL.h @@ -101,6 +101,9 @@ void HAL_adc_enable_channel(const uint8_t ch); void HAL_adc_start_conversion(const uint8_t ch); uint16_t HAL_adc_get_result(); +// PWM +inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + // Reset source inline void HAL_clear_reset_source(void) {} inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; } diff --git a/Marlin/src/HAL/LPC1768/fast_pwm.cpp b/Marlin/src/HAL/LPC1768/fast_pwm.cpp index dd440b5e77..70fc0e333d 100644 --- a/Marlin/src/HAL/LPC1768/fast_pwm.cpp +++ b/Marlin/src/HAL/LPC1768/fast_pwm.cpp @@ -22,18 +22,18 @@ #ifdef TARGET_LPC1768 #include "../../inc/MarlinConfigPre.h" - -#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM - #include -void set_pwm_frequency(const pin_t pin, int f_desired) { - LPC176x::pwm_set_frequency(pin, f_desired); -} - void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); } -#endif // NEEDS_HARDWARE_PWM +#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM + + void set_pwm_frequency(const pin_t pin, int f_desired) { + LPC176x::pwm_set_frequency(pin, f_desired); + } + +#endif + #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/LPC1768/upload_extra_script.py b/Marlin/src/HAL/LPC1768/upload_extra_script.py index fb3aaef7cd..7975f151f7 100755 --- a/Marlin/src/HAL/LPC1768/upload_extra_script.py +++ b/Marlin/src/HAL/LPC1768/upload_extra_script.py @@ -1,123 +1,127 @@ # -# sets output_port +# upload_extra_script.py +# set the output_port # if target_filename is found then that drive is used # else if target_drive is found then that drive is used # from __future__ import print_function -target_filename = "FIRMWARE.CUR" -target_drive = "REARM" +import pioutil +if pioutil.is_pio_build(): -import os,getpass,platform + target_filename = "FIRMWARE.CUR" + target_drive = "REARM" -current_OS = platform.system() -Import("env") + import os,getpass,platform -def print_error(e): - print('\nUnable to find destination disk (%s)\n' \ - 'Please select it in platformio.ini using the upload_port keyword ' \ - '(https://docs.platformio.org/en/latest/projectconf/section_env_upload.html) ' \ - 'or copy the firmware (.pio/build/%s/firmware.bin) manually to the appropriate disk\n' \ - %(e, env.get('PIOENV'))) + current_OS = platform.system() + Import("env") -def before_upload(source, target, env): - try: - # - # Find a disk for upload - # - upload_disk = 'Disk not found' - target_file_found = False - target_drive_found = False - if current_OS == 'Windows': + def print_error(e): + print('\nUnable to find destination disk (%s)\n' \ + 'Please select it in platformio.ini using the upload_port keyword ' \ + '(https://docs.platformio.org/en/latest/projectconf/section_env_upload.html) ' \ + 'or copy the firmware (.pio/build/%s/firmware.bin) manually to the appropriate disk\n' \ + %(e, env.get('PIOENV'))) + + def before_upload(source, target, env): + try: # - # platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:' - # Windows - doesn't care about the disk's name, only cares about the drive letter - import subprocess,string - from ctypes import windll + # Find a disk for upload + # + upload_disk = 'Disk not found' + target_file_found = False + target_drive_found = False + if current_OS == 'Windows': + # + # platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:' + # Windows - doesn't care about the disk's name, only cares about the drive letter + import subprocess,string + from ctypes import windll - # getting list of drives - # https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python - drives = [] - bitmask = windll.kernel32.GetLogicalDrives() - for letter in string.ascii_uppercase: - if bitmask & 1: - drives.append(letter) - bitmask >>= 1 + # getting list of drives + # https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python + drives = [] + bitmask = windll.kernel32.GetLogicalDrives() + for letter in string.ascii_uppercase: + if bitmask & 1: + drives.append(letter) + bitmask >>= 1 - for drive in drives: - final_drive_name = drive + ':\\' - # print ('disc check: {}'.format(final_drive_name)) - try: - volume_info = str(subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT)) - except Exception as e: - print ('error:{}'.format(e)) - continue - else: - if target_drive in volume_info and not target_file_found: # set upload if not found target file yet - target_drive_found = True - upload_disk = final_drive_name - if target_filename in volume_info: - if not target_file_found: + for drive in drives: + final_drive_name = drive + ':\\' + # print ('disc check: {}'.format(final_drive_name)) + try: + volume_info = str(subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT)) + except Exception as e: + print ('error:{}'.format(e)) + continue + else: + if target_drive in volume_info and not target_file_found: # set upload if not found target file yet + target_drive_found = True upload_disk = final_drive_name - target_file_found = True + if target_filename in volume_info: + if not target_file_found: + upload_disk = final_drive_name + target_file_found = True - elif current_OS == 'Linux': - # - # platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive' - # - drives = os.listdir(os.path.join(os.sep, 'media', getpass.getuser())) - if target_drive in drives: # If target drive is found, use it. - target_drive_found = True - upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), target_drive) + os.sep - else: + elif current_OS == 'Linux': + # + # platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive' + # + drives = os.listdir(os.path.join(os.sep, 'media', getpass.getuser())) + if target_drive in drives: # If target drive is found, use it. + target_drive_found = True + upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), target_drive) + os.sep + else: + for drive in drives: + try: + files = os.listdir(os.path.join(os.sep, 'media', getpass.getuser(), drive)) + except: + continue + else: + if target_filename in files: + upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), drive) + os.sep + target_file_found = True + break + # + # set upload_port to drive if found + # + + if target_file_found or target_drive_found: + env.Replace( + UPLOAD_FLAGS="-P$UPLOAD_PORT" + ) + + elif current_OS == 'Darwin': # MAC + # + # platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive' + # + drives = os.listdir('/Volumes') # human readable names + if target_drive in drives and not target_file_found: # set upload if not found target file yet + target_drive_found = True + upload_disk = '/Volumes/' + target_drive + '/' for drive in drives: try: - files = os.listdir(os.path.join(os.sep, 'media', getpass.getuser(), drive)) + filenames = os.listdir('/Volumes/' + drive + '/') # will get an error if the drive is protected except: continue else: - if target_filename in files: - upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), drive) + os.sep + if target_filename in filenames: + if not target_file_found: + upload_disk = '/Volumes/' + drive + '/' target_file_found = True - break - # - # set upload_port to drive if found - # + # + # Set upload_port to drive if found + # if target_file_found or target_drive_found: - env.Replace( - UPLOAD_FLAGS="-P$UPLOAD_PORT" - ) + env.Replace(UPLOAD_PORT=upload_disk) + print('\nUpload disk: ', upload_disk, '\n') + else: + print_error('Autodetect Error') - elif current_OS == 'Darwin': # MAC - # - # platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive' - # - drives = os.listdir('/Volumes') # human readable names - if target_drive in drives and not target_file_found: # set upload if not found target file yet - target_drive_found = True - upload_disk = '/Volumes/' + target_drive + '/' - for drive in drives: - try: - filenames = os.listdir('/Volumes/' + drive + '/') # will get an error if the drive is protected - except: - continue - else: - if target_filename in filenames: - if not target_file_found: - upload_disk = '/Volumes/' + drive + '/' - target_file_found = True + except Exception as e: + print_error(str(e)) - # - # Set upload_port to drive if found - # - if target_file_found or target_drive_found: - env.Replace(UPLOAD_PORT=upload_disk) - print('\nUpload disk: ', upload_disk, '\n') - else: - print_error('Autodetect Error') - - except Exception as e: - print_error(str(e)) - -env.AddPreAction("upload", before_upload) + env.AddPreAction("upload", before_upload) diff --git a/Marlin/src/HAL/NATIVE_SIM/HAL.h b/Marlin/src/HAL/NATIVE_SIM/HAL.h index 235c24808c..915339468b 100644 --- a/Marlin/src/HAL/NATIVE_SIM/HAL.h +++ b/Marlin/src/HAL/NATIVE_SIM/HAL.h @@ -133,6 +133,9 @@ void HAL_adc_enable_channel(const uint8_t ch); void HAL_adc_start_conversion(const uint8_t ch); uint16_t HAL_adc_get_result(); +// PWM +inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + // Reset source inline void HAL_clear_reset_source(void) {} inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; } diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index 775a9240e1..c262752a8d 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -127,6 +127,11 @@ void HAL_adc_init(); void HAL_adc_start_conversion(const uint8_t adc_pin); +// +// PWM +// +inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + // // Pin Map // diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index a04a24c112..0920a72ec1 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -154,7 +154,7 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRe uint16_t HAL_adc_get_result() { return HAL_adc_result; } // Reset the system to initiate a firmware flash -void flashFirmware(const int16_t) { HAL_reboot(); } +WEAK void flashFirmware(const int16_t) { HAL_reboot(); } // Maple Compatibility volatile uint32_t systick_uptime_millis = 0; diff --git a/Marlin/src/HAL/STM32/fast_pwm.cpp b/Marlin/src/HAL/STM32/fast_pwm.cpp index 917e12615f..4d450374d3 100644 --- a/Marlin/src/HAL/STM32/fast_pwm.cpp +++ b/Marlin/src/HAL/STM32/fast_pwm.cpp @@ -24,32 +24,17 @@ #ifdef HAL_STM32 -#include "../../inc/MarlinConfigPre.h" - -#if NEEDS_HARDWARE_PWM - -#include "HAL.h" +#include "../../inc/MarlinConfig.h" #include "timers.h" -void set_pwm_frequency(const pin_t pin, int f_desired) { +void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer - PinName pin_name = digitalPinToPinName(pin); - TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); // Get HAL timer instance - - LOOP_S_L_N(i, 0, NUM_HARDWARE_TIMERS) // Protect used timers - if (timer_instance[i] && timer_instance[i]->getHandle()->Instance == Instance) - return; - - pwm_start(pin_name, f_desired, 0, RESOLUTION_8B_COMPARE_FORMAT); -} - -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { PinName pin_name = digitalPinToPinName(pin); TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); + uint16_t adj_val = Instance->ARR * v / v_size; if (invert) adj_val = Instance->ARR - adj_val; - switch (get_pwm_channel(pin_name)) { case TIM_CHANNEL_1: LL_TIM_OC_SetCompareCH1(Instance, adj_val); break; case TIM_CHANNEL_2: LL_TIM_OC_SetCompareCH2(Instance, adj_val); break; @@ -58,5 +43,21 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255 } } -#endif // NEEDS_HARDWARE_PWM +#if NEEDS_HARDWARE_PWM + + void set_pwm_frequency(const pin_t pin, int f_desired) { + if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer + + PinName pin_name = digitalPinToPinName(pin); + TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); // Get HAL timer instance + + LOOP_S_L_N(i, 0, NUM_HARDWARE_TIMERS) // Protect used timers + if (timer_instance[i] && timer_instance[i]->getHandle()->Instance == Instance) + return; + + pwm_start(pin_name, f_desired, 0, RESOLUTION_8B_COMPARE_FORMAT); + } + +#endif + #endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index df1ba33d4a..f29b305361 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -449,8 +449,7 @@ uint16_t analogRead(pin_t pin) { // Wrapper to maple unprotected analogWrite void analogWrite(pin_t pin, int pwm_val8) { - if (PWM_PIN(pin)) - analogWrite(uint8_t(pin), pwm_val8); + if (PWM_PIN(pin)) analogWrite(uint8_t(pin), pwm_val8); } void HAL_reboot() { nvic_sys_reset(); } diff --git a/Marlin/src/HAL/STM32F1/build_flags.py b/Marlin/src/HAL/STM32F1/build_flags.py index d0848d1c64..970ca8b767 100755 --- a/Marlin/src/HAL/STM32F1/build_flags.py +++ b/Marlin/src/HAL/STM32F1/build_flags.py @@ -30,25 +30,27 @@ if __name__ == "__main__": # extra script for linker options else: - from SCons.Script import DefaultEnvironment - env = DefaultEnvironment() - env.Append( + import pioutil + if pioutil.is_pio_build(): + from SCons.Script import DefaultEnvironment + env = DefaultEnvironment() + env.Append( ARFLAGS=["rcs"], ASFLAGS=["-x", "assembler-with-cpp"], CXXFLAGS=[ - "-fabi-version=0", - "-fno-use-cxa-atexit", - "-fno-threadsafe-statics" + "-fabi-version=0", + "-fno-use-cxa-atexit", + "-fno-threadsafe-statics" ], LINKFLAGS=[ - "-Os", - "-mcpu=cortex-m3", - "-ffreestanding", - "-mthumb", - "--specs=nano.specs", - "--specs=nosys.specs", - "-u_printf_float", + "-Os", + "-mcpu=cortex-m3", + "-ffreestanding", + "-mthumb", + "--specs=nano.specs", + "--specs=nosys.specs", + "-u_printf_float", ], - ) + ) diff --git a/Marlin/src/HAL/STM32F1/fast_pwm.cpp b/Marlin/src/HAL/STM32F1/fast_pwm.cpp index 884d482af5..5171c11545 100644 --- a/Marlin/src/HAL/STM32F1/fast_pwm.cpp +++ b/Marlin/src/HAL/STM32F1/fast_pwm.cpp @@ -23,46 +23,47 @@ #include "../../inc/MarlinConfigPre.h" -#if NEEDS_HARDWARE_PWM - #include #include "HAL.h" #include "timers.h" -void set_pwm_frequency(const pin_t pin, int f_desired) { - if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer - - timer_dev *timer = PIN_MAP[pin].timer_device; - uint8_t channel = PIN_MAP[pin].timer_channel; - - // Protect used timers - if (timer == get_timer_dev(TEMP_TIMER_NUM)) return; - if (timer == get_timer_dev(STEP_TIMER_NUM)) return; - #if PULSE_TIMER_NUM != STEP_TIMER_NUM - if (timer == get_timer_dev(PULSE_TIMER_NUM)) return; - #endif - - if (!(timer->regs.bas->SR & TIMER_CR1_CEN)) // Ensure the timer is enabled - timer_init(timer); - - timer_set_mode(timer, channel, TIMER_PWM); - uint16_t preload = 255; // Lock 255 PWM resolution for high frequencies - int32_t prescaler = (HAL_TIMER_RATE) / (preload + 1) / f_desired - 1; - if (prescaler > 65535) { // For low frequencies increase prescaler - prescaler = 65535; - preload = (HAL_TIMER_RATE) / (prescaler + 1) / f_desired - 1; - } - if (prescaler < 0) return; // Too high frequency - timer_set_reload(timer, preload); - timer_set_prescaler(timer, prescaler); -} - void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { + if (!PWM_PIN(pin)) return; timer_dev *timer = PIN_MAP[pin].timer_device; uint16_t max_val = timer->regs.bas->ARR * v / v_size; if (invert) max_val = v_size - max_val; pwmWrite(pin, max_val); } +#if NEEDS_HARDWARE_PWM + + void set_pwm_frequency(const pin_t pin, int f_desired) { + if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer + + timer_dev *timer = PIN_MAP[pin].timer_device; + uint8_t channel = PIN_MAP[pin].timer_channel; + + // Protect used timers + if (timer == get_timer_dev(TEMP_TIMER_NUM)) return; + if (timer == get_timer_dev(STEP_TIMER_NUM)) return; + #if PULSE_TIMER_NUM != STEP_TIMER_NUM + if (timer == get_timer_dev(PULSE_TIMER_NUM)) return; + #endif + + if (!(timer->regs.bas->SR & TIMER_CR1_CEN)) // Ensure the timer is enabled + timer_init(timer); + + timer_set_mode(timer, channel, TIMER_PWM); + uint16_t preload = 255; // Lock 255 PWM resolution for high frequencies + int32_t prescaler = (HAL_TIMER_RATE) / (preload + 1) / f_desired - 1; + if (prescaler > 65535) { // For low frequencies increase prescaler + prescaler = 65535; + preload = (HAL_TIMER_RATE) / (prescaler + 1) / f_desired - 1; + } + if (prescaler < 0) return; // Too high frequency + timer_set_reload(timer, preload); + timer_set_prescaler(timer, prescaler); + } + #endif // NEEDS_HARDWARE_PWM #endif // __STM32F1__ diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.h b/Marlin/src/HAL/TEENSY31_32/HAL.h index 7235f5ef0e..61d8b34604 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/TEENSY31_32/HAL.h @@ -122,6 +122,12 @@ void HAL_adc_init(); void HAL_adc_start_conversion(const uint8_t adc_pin); uint16_t HAL_adc_get_result(); +// PWM + +inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + +// Pin Map + #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index 8892ffec45..892eb2d3c5 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -129,6 +129,12 @@ void HAL_adc_init(); void HAL_adc_start_conversion(const uint8_t adc_pin); uint16_t HAL_adc_get_result(); +// PWM + +inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + +// Pin Map + #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.cpp b/Marlin/src/HAL/TEENSY40_41/HAL.cpp index ccc8c2659c..270bee0dc9 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.cpp +++ b/Marlin/src/HAL/TEENSY40_41/HAL.cpp @@ -106,17 +106,17 @@ void HAL_adc_init() { void HAL_clear_reset_source() { uint32_t reset_source = SRC_SRSR; SRC_SRSR = reset_source; - } +} uint8_t HAL_get_reset_source() { switch (SRC_SRSR & 0xFF) { case 1: return RST_POWER_ON; break; case 2: return RST_SOFTWARE; break; case 4: return RST_EXTERNAL; break; - // case 8: return RST_BROWN_OUT; break; + //case 8: return RST_BROWN_OUT; break; case 16: return RST_WATCHDOG; break; - case 64: return RST_JTAG; break; - // case 128: return RST_OVERTEMP; break; + case 64: return RST_JTAG; break; + //case 128: return RST_OVERTEMP; break; } return 0; } @@ -168,7 +168,7 @@ uint16_t HAL_adc_get_result() { return 0; } -bool is_output(uint8_t pin) { +bool is_output(pin_t pin) { const struct digital_pin_bitband_and_config_table_struct *p; p = digital_pin_to_info_PGM + pin; return (*(p->reg + 1) & p->mask); diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.h b/Marlin/src/HAL/TEENSY40_41/HAL.h index c9716eacde..2b730768a8 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.h +++ b/Marlin/src/HAL/TEENSY40_41/HAL.h @@ -150,8 +150,14 @@ void HAL_adc_init(); void HAL_adc_start_conversion(const uint8_t adc_pin); uint16_t HAL_adc_get_result(); +// PWM + +inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + +// Pin Map + #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) -bool is_output(uint8_t pin); +bool is_output(pin_t pin); diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index eb57835f96..5e8881d1c6 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1104,6 +1104,10 @@ void setup() { tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable + // Check startup - does nothing if bootloader sets MCUSR to 0 + const byte mcu = HAL_get_reset_source(); + HAL_clear_reset_source(); + #if ENABLED(MARLIN_DEV_MODE) auto log_current_ms = [&](PGM_P const msg) { SERIAL_ECHO_START(); @@ -1232,15 +1236,14 @@ void setup() { SETUP_RUN(esp_wifi_init()); - // Check startup - does nothing if bootloader sets MCUSR to 0 - const byte mcu = HAL_get_reset_source(); + // Report Reset Reason if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP); if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET); if (mcu & RST_BROWN_OUT) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET); if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET); if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET); - HAL_clear_reset_source(); + // Identify myself as Marlin x.x.x SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION); #if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR) SERIAL_ECHO_MSG( diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 82c68f3171..789512c4ef 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -402,10 +402,11 @@ #define BOARD_ANET_ET4 4230 // ANET ET4 V1.x (STM32F407VGT6) #define BOARD_ANET_ET4P 4231 // ANET ET4P V1.x (STM32F407VGT6) #define BOARD_FYSETC_CHEETAH_V20 4232 // FYSETC Cheetah V2.0 -#define BOARD_TH3D_EZBOARD_LITE_V2 4233 // TH3D EZBoard Lite v2.0 +#define BOARD_TH3D_EZBOARD_V2 4233 // TH3D EZBoard v2.0 #define BOARD_INDEX_REV03 4234 // Index PnP Controller REV03 (STM32F407VET6/VGT6) #define BOARD_MKS_ROBIN_NANO_V1_3_F4 4235 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VET6) #define BOARD_MKS_EAGLE 4236 // MKS Eagle (STM32F407VET6) +#define BOARD_ARTILLERY_RUBY 4237 // Artillery Ruby (STM32F401RCT6) // // ARM Cortex M7 @@ -425,9 +426,10 @@ #define BOARD_MRR_ESPA 6001 // MRR ESPA based on ESP32 (native pins only) #define BOARD_MRR_ESPE 6002 // MRR ESPE based on ESP32 (with I2S stepper stream) #define BOARD_E4D_BOX 6003 // E4d@BOX -#define BOARD_FYSETC_E4 6004 // FYSETC E4 -#define BOARD_PANDA_ZHU 6005 // Panda_ZHU -#define BOARD_PANDA_M4 6006 // Panda_M4 +#define BOARD_RESP32_CUSTOM 6004 // Rutilea ESP32 custom board +#define BOARD_FYSETC_E4 6005 // FYSETC E4 +#define BOARD_PANDA_ZHU 6006 // Panda_ZHU +#define BOARD_PANDA_M4 6007 // Panda_M4 // // SAMD51 ARM Cortex M4 diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index d8a15b910d..62675d1319 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -33,6 +33,12 @@ #define _AXIS(A) (A##_AXIS) +#define _XSTOP_ 0x01 +#define _YSTOP_ 0x02 +#define _ZSTOP_ 0x03 +#define _ISTOP_ 0x04 +#define _JSTOP_ 0x05 +#define _KSTOP_ 0x06 #define _XMIN_ 0x11 #define _YMIN_ 0x12 #define _ZMIN_ 0x13 diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index e058f1e5cd..aee4d4d43d 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -87,7 +87,7 @@ extern uint8_t marlin_debug_flags; // interface with the ability to output to multiple serial ports. #if HAS_MULTI_SERIAL #define _PORT_REDIRECT(n,p) REMEMBER(n,multiSerial.portMask,p) - #define _PORT_RESTORE(n,p) RESTORE(n) + #define _PORT_RESTORE(n) RESTORE(n) #define SERIAL_ASSERT(P) if (multiSerial.portMask!=(P)) { debugger(); } // If we have a catchall, use that directly #ifdef SERIAL_CATCHALL diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index d78a5e2578..df83923fef 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -346,13 +346,14 @@ void unified_bed_leveling::G29() { if (parser.seen('Q')) { const int16_t test_pattern = parser.has_value() ? parser.value_int() : -99; - if (!WITHIN(test_pattern, -1, 2)) { - SERIAL_ECHOLNPGM("Invalid test_pattern value. (-1 to 2)\n"); + if (!WITHIN(test_pattern, TERN0(UBL_DEVEL_DEBUGGING, -1), 2)) { + SERIAL_ECHOLNPGM("?Invalid (Q) test pattern. (" TERN(UBL_DEVEL_DEBUGGING, "-1", "0") " to 2)\n"); return; } - SERIAL_ECHOLNPGM("Loading test_pattern values.\n"); + SERIAL_ECHOLNPGM("Applying test pattern.\n"); switch (test_pattern) { + default: case -1: TERN_(UBL_DEVEL_DEBUGGING, g29_eeprom_dump()); break; case 0: diff --git a/Marlin/src/feature/caselight.cpp b/Marlin/src/feature/caselight.cpp index 1baef6d468..7c4755d0b5 100644 --- a/Marlin/src/feature/caselight.cpp +++ b/Marlin/src/feature/caselight.cpp @@ -70,7 +70,7 @@ void CaseLight::update(const bool sflag) { #if CASELIGHT_USES_BRIGHTNESS if (pin_is_pwm()) - analogWrite(pin_t(CASE_LIGHT_PIN), ( + set_pwm_duty(pin_t(CASE_LIGHT_PIN), ( #if CASE_LIGHT_MAX_PWM == 255 n10ct #else diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp index 03ef31e414..330f3914f6 100644 --- a/Marlin/src/feature/controllerfan.cpp +++ b/Marlin/src/feature/controllerfan.cpp @@ -72,9 +72,10 @@ void ControllerFan::update() { ? settings.active_speed : settings.idle_speed ); - // Allow digital or PWM fan output (see M42 handling) - WRITE(CONTROLLER_FAN_PIN, speed); - analogWrite(pin_t(CONTROLLER_FAN_PIN), speed); + if (PWM_PIN(CONTROLLER_FAN_PIN)) + set_pwm_duty(pin_t(CONTROLLER_FAN_PIN), speed); + else + WRITE(CONTROLLER_FAN_PIN, speed); } } diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index 6a1faf81c0..be7b055b55 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -80,6 +80,10 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { #endif #endif +#ifdef SHUTDOWN_ACTION + void HostUI::shutdown() { action(F(SHUTDOWN_ACTION)); } +#endif + #if ENABLED(HOST_PROMPT_SUPPORT) PromptReason HostUI::host_prompt_reason = PROMPT_NOT_DEFINED; diff --git a/Marlin/src/feature/host_actions.h b/Marlin/src/feature/host_actions.h index 6671072139..45379afc29 100644 --- a/Marlin/src/feature/host_actions.h +++ b/Marlin/src/feature/host_actions.h @@ -71,6 +71,9 @@ class HostUI { #ifdef ACTION_ON_START static void start(); #endif + #ifdef SHUTDOWN_ACTION + static void shutdown(); + #endif #if ENABLED(G29_RETRY_AND_RECOVER) #ifdef ACTION_ON_G29_RECOVER diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 328daa626d..17d790b8cc 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -121,11 +121,11 @@ void LEDLights::set_color(const LEDColor &incol // This variant uses 3-4 separate pins for the RGB(W) components. // If the pins can do PWM then their intensity will be set. - #define _UPDATE_RGBW(C,c) do { \ - if (PWM_PIN(RGB_LED_##C##_PIN)) \ - analogWrite(pin_t(RGB_LED_##C##_PIN), c); \ - else \ - WRITE(RGB_LED_##C##_PIN, c ? HIGH : LOW); \ + #define _UPDATE_RGBW(C,c) do { \ + if (PWM_PIN(RGB_LED_##C##_PIN)) \ + set_pwm_duty(pin_t(RGB_LED_##C##_PIN), c); \ + else \ + WRITE(RGB_LED_##C##_PIN, c ? HIGH : LOW); \ }while(0) #define UPDATE_RGBW(C,c) _UPDATE_RGBW(C, TERN1(CASE_LIGHT_USE_RGB_LED, caselight.on) ? incol.c : 0) UPDATE_RGBW(R,r); UPDATE_RGBW(G,g); UPDATE_RGBW(B,b); @@ -170,9 +170,9 @@ void LEDLights::set_color(const LEDColor &incol #if ENABLED(NEO2_COLOR_PRESETS) const LEDColor LEDLights2::defaultLEDColor = LEDColor( - LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE - OPTARG(HAS_WHITE_LED2, LED_USER_PRESET_WHITE) - OPTARG(NEOPIXEL_LED, LED_USER_PRESET_BRIGHTNESS) + NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE + OPTARG(HAS_WHITE_LED2, NEO2_USER_PRESET_WHITE) + OPTARG(NEOPIXEL_LED, NEO2_USER_PRESET_BRIGHTNESS) ); #endif diff --git a/Marlin/src/feature/probe_temp_comp.cpp b/Marlin/src/feature/probe_temp_comp.cpp index 5f3bc985e6..9a975d6763 100644 --- a/Marlin/src/feature/probe_temp_comp.cpp +++ b/Marlin/src/feature/probe_temp_comp.cpp @@ -22,39 +22,53 @@ #include "../inc/MarlinConfigPre.h" -#if ENABLED(PROBE_TEMP_COMPENSATION) +#if HAS_PTC //#define DEBUG_PTC // Print extra debug output with 'M871' #include "probe_temp_comp.h" #include -ProbeTempComp temp_comp; +ProbeTempComp ptc; -int16_t ProbeTempComp::z_offsets_probe[cali_info_init[TSI_PROBE].measurements], // = {0} - ProbeTempComp::z_offsets_bed[cali_info_init[TSI_BED].measurements]; // = {0} +#if ENABLED(PTC_PROBE) + constexpr int16_t z_offsets_probe_default[PTC_PROBE_COUNT] = PTC_PROBE_ZOFFS; + int16_t ProbeTempComp::z_offsets_probe[PTC_PROBE_COUNT] = PTC_PROBE_ZOFFS; +#endif -#if ENABLED(USE_TEMP_EXT_COMPENSATION) - int16_t ProbeTempComp::z_offsets_ext[cali_info_init[TSI_EXT].measurements]; // = {0} +#if ENABLED(PTC_BED) + constexpr int16_t z_offsets_bed_default[PTC_BED_COUNT] = PTC_BED_ZOFFS; + int16_t ProbeTempComp::z_offsets_bed[PTC_BED_COUNT] = PTC_BED_ZOFFS; +#endif + +#if ENABLED(PTC_HOTEND) + constexpr int16_t z_offsets_hotend_default[PTC_HOTEND_COUNT] = PTC_HOTEND_ZOFFS; + int16_t ProbeTempComp::z_offsets_hotend[PTC_HOTEND_COUNT] = PTC_HOTEND_ZOFFS; #endif int16_t *ProbeTempComp::sensor_z_offsets[TSI_COUNT] = { - ProbeTempComp::z_offsets_probe, ProbeTempComp::z_offsets_bed - OPTARG(USE_TEMP_EXT_COMPENSATION, ProbeTempComp::z_offsets_ext) + #if ENABLED(PTC_PROBE) + ProbeTempComp::z_offsets_probe, + #endif + #if ENABLED(PTC_BED) + ProbeTempComp::z_offsets_bed, + #endif + #if ENABLED(PTC_HOTEND) + ProbeTempComp::z_offsets_hotend, + #endif }; -const temp_calib_t ProbeTempComp::cali_info[TSI_COUNT] = { - cali_info_init[TSI_PROBE], cali_info_init[TSI_BED] - OPTARG(USE_TEMP_EXT_COMPENSATION, cali_info_init[TSI_EXT]) -}; - -constexpr xyz_pos_t ProbeTempComp::park_point; -constexpr xy_pos_t ProbeTempComp::measure_point; -constexpr celsius_t ProbeTempComp::probe_calib_bed_temp; +constexpr temp_calib_t ProbeTempComp::cali_info[TSI_COUNT]; uint8_t ProbeTempComp::calib_idx; // = 0 float ProbeTempComp::init_measurement; // = 0.0 +void ProbeTempComp::reset() { + TERN_(PTC_PROBE, LOOP_L_N(i, PTC_PROBE_COUNT) z_offsets_probe[i] = z_offsets_probe_default[i]); + TERN_(PTC_BED, LOOP_L_N(i, PTC_BED_COUNT) z_offsets_bed[i] = z_offsets_bed_default[i]); + TERN_(PTC_HOTEND, LOOP_L_N(i, PTC_HOTEND_COUNT) z_offsets_hotend[i] = z_offsets_hotend_default[i]); +} + void ProbeTempComp::clear_offsets(const TempSensorID tsi) { LOOP_L_N(i, cali_info[tsi].measurements) sensor_z_offsets[tsi][i] = 0; @@ -71,10 +85,9 @@ void ProbeTempComp::print_offsets() { LOOP_L_N(s, TSI_COUNT) { celsius_t temp = cali_info[s].start_temp; for (int16_t i = -1; i < cali_info[s].measurements; ++i) { - SERIAL_ECHOF(s == TSI_BED ? F("Bed") : - #if ENABLED(USE_TEMP_EXT_COMPENSATION) - s == TSI_EXT ? F("Extruder") : - #endif + SERIAL_ECHOF( + TERN_(PTC_BED, s == TSI_BED ? F("Bed") :) + TERN_(PTC_HOTEND, s == TSI_EXT ? F("Extruder") :) F("Probe") ); SERIAL_ECHOLNPGM( @@ -100,21 +113,13 @@ void ProbeTempComp::prepare_new_calibration(const_float_t init_meas_z) { } void ProbeTempComp::push_back_new_measurement(const TempSensorID tsi, const_float_t meas_z) { - switch (tsi) { - case TSI_PROBE: - case TSI_BED: - //case TSI_EXT: - if (calib_idx >= cali_info[tsi].measurements) return; - sensor_z_offsets[tsi][calib_idx++] = static_cast(meas_z * 1000.0f - init_measurement * 1000.0f); - default: break; - } + if (calib_idx >= cali_info[tsi].measurements) return; + sensor_z_offsets[tsi][calib_idx++] = static_cast((meas_z - init_measurement) * 1000.0f); } bool ProbeTempComp::finish_calibration(const TempSensorID tsi) { - if (tsi != TSI_PROBE && tsi != TSI_BED) return false; - - if (calib_idx < 3) { - SERIAL_ECHOLNPGM("!Insufficient measurements (min. 3)."); + if (!calib_idx) { + SERIAL_ECHOLNPGM("!No measurements."); clear_offsets(tsi); return false; } @@ -130,16 +135,15 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) { SERIAL_ECHOLNPGM("Got ", calib_idx, " measurements. "); if (linear_regression(tsi, k, d)) { SERIAL_ECHOPGM("Applying linear extrapolation"); - calib_idx--; for (; calib_idx < measurements; ++calib_idx) { - const celsius_float_t temp = start_temp + float(calib_idx) * res_temp; + const celsius_float_t temp = start_temp + float(calib_idx + 1) * res_temp; data[calib_idx] = static_cast(k * temp + d); } } else { // Simply use the last measured value for higher temperatures SERIAL_ECHOPGM("Failed to extrapolate"); - const int16_t last_val = data[calib_idx]; + const int16_t last_val = data[calib_idx-1]; for (; calib_idx < measurements; ++calib_idx) data[calib_idx] = last_val; } @@ -157,7 +161,7 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) { // Restrict the max. offset difference between two probings if (calib_idx > 0 && ABS(data[calib_idx - 1] - data[calib_idx]) > 800) { SERIAL_ECHOLNPGM("!Invalid Z-offset between two probings detected (0-0.8)."); - clear_offsets(TSI_PROBE); + clear_offsets(tsi); return false; } } @@ -168,8 +172,8 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) { void ProbeTempComp::compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z) { const uint8_t measurements = cali_info[tsi].measurements; const celsius_t start_temp = cali_info[tsi].start_temp, - end_temp = cali_info[tsi].end_temp, - res_temp = cali_info[tsi].temp_resolution; + res_temp = cali_info[tsi].temp_resolution, + end_temp = start_temp + measurements * res_temp; const int16_t * const data = sensor_z_offsets[tsi]; // Given a data index, return { celsius, zoffset } in the form { x, y } @@ -208,9 +212,7 @@ void ProbeTempComp::compensate_measurement(const TempSensorID tsi, const celsius } bool ProbeTempComp::linear_regression(const TempSensorID tsi, float &k, float &d) { - if (tsi != TSI_PROBE && tsi != TSI_BED) return false; - - if (!WITHIN(calib_idx, 2, cali_info[tsi].measurements)) return false; + if (!WITHIN(calib_idx, 1, cali_info[tsi].measurements)) return false; const celsius_t start_temp = cali_info[tsi].start_temp, res_temp = cali_info[tsi].temp_resolution; @@ -243,4 +245,4 @@ bool ProbeTempComp::linear_regression(const TempSensorID tsi, float &k, float &d return true; } -#endif // PROBE_TEMP_COMPENSATION +#endif // HAS_PTC diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index e5d459b8e8..4579f2187c 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -24,9 +24,13 @@ #include "../inc/MarlinConfig.h" enum TempSensorID : uint8_t { - TSI_PROBE, - TSI_BED, - #if ENABLED(USE_TEMP_EXT_COMPENSATION) + #if ENABLED(PTC_PROBE) + TSI_PROBE, + #endif + #if ENABLED(PTC_BED) + TSI_BED, + #endif + #if ENABLED(PTC_HOTEND) TSI_EXT, #endif TSI_COUNT @@ -35,8 +39,7 @@ enum TempSensorID : uint8_t { typedef struct { uint8_t measurements; // Max. number of measurements to be stored (35 - 80°C) celsius_t temp_resolution, // Resolution in °C between measurements - start_temp, // Base measurement; z-offset == 0 - end_temp; + start_temp; // Base measurement; z-offset == 0 } temp_calib_t; /** @@ -45,93 +48,40 @@ typedef struct { * measurement errors/shifts due to changed temperature. */ -// Probe temperature calibration constants -#ifndef PTC_SAMPLE_COUNT - #define PTC_SAMPLE_COUNT 10 -#endif -#ifndef PTC_SAMPLE_RES - #define PTC_SAMPLE_RES 5 -#endif -#ifndef PTC_SAMPLE_START - #define PTC_SAMPLE_START 30 -#endif -#define PTC_SAMPLE_END (PTC_SAMPLE_START + (PTC_SAMPLE_COUNT) * PTC_SAMPLE_RES) - -// Bed temperature calibration constants -#ifndef BTC_PROBE_TEMP - #define BTC_PROBE_TEMP 30 -#endif -#ifndef BTC_SAMPLE_COUNT - #define BTC_SAMPLE_COUNT 10 -#endif -#ifndef BTC_SAMPLE_RES - #define BTC_SAMPLE_RES 5 -#endif -#ifndef BTC_SAMPLE_START - #define BTC_SAMPLE_START 60 -#endif -#define BTC_SAMPLE_END (BTC_SAMPLE_START + (BTC_SAMPLE_COUNT) * BTC_SAMPLE_RES) - -// Extruder temperature calibration constants -#if ENABLED(USE_TEMP_EXT_COMPENSATION) - #ifndef ETC_SAMPLE_COUNT - #define ETC_SAMPLE_COUNT 20 - #endif - #ifndef ETC_SAMPLE_RES - #define ETC_SAMPLE_RES 5 - #endif - #ifndef ETC_SAMPLE_START - #define ETC_SAMPLE_START 180 - #endif - #define ETC_SAMPLE_END (ETC_SAMPLE_START + (ETC_SAMPLE_COUNT) * ETC_SAMPLE_RES) -#endif - -#ifndef PTC_PROBE_HEATING_OFFSET - #define PTC_PROBE_HEATING_OFFSET 0.5f -#endif - -#ifndef PTC_PROBE_RAISE - #define PTC_PROBE_RAISE 10 -#endif - -static constexpr temp_calib_t cali_info_init[TSI_COUNT] = { - { PTC_SAMPLE_COUNT, PTC_SAMPLE_RES, PTC_SAMPLE_START, PTC_SAMPLE_END }, // Probe - { BTC_SAMPLE_COUNT, BTC_SAMPLE_RES, BTC_SAMPLE_START, BTC_SAMPLE_END }, // Bed - #if ENABLED(USE_TEMP_EXT_COMPENSATION) - { ETC_SAMPLE_COUNT, ETC_SAMPLE_RES, ETC_SAMPLE_START, ETC_SAMPLE_END }, // Extruder - #endif -}; - class ProbeTempComp { public: - static const temp_calib_t cali_info[TSI_COUNT]; + static constexpr temp_calib_t cali_info[TSI_COUNT] = { + #if ENABLED(PTC_PROBE) + { PTC_PROBE_COUNT, PTC_PROBE_RES, PTC_PROBE_START }, // Probe + #endif + #if ENABLED(PTC_BED) + { PTC_BED_COUNT, PTC_BED_RES, PTC_BED_START }, // Bed + #endif + #if ENABLED(PTC_HOTEND) + { PTC_HOTEND_COUNT, PTC_HOTEND_RES, PTC_HOTEND_START }, // Extruder + #endif + }; - // Where to park nozzle to wait for probe cooldown - static constexpr xyz_pos_t park_point = PTC_PARK_POS; - - // XY coordinates of nozzle for probing the bed - static constexpr xy_pos_t measure_point = PTC_PROBE_POS; // Coordinates to probe - //measure_point = { 12.0f, 7.3f }; // Coordinates for the MK52 magnetic heatbed - - static constexpr celsius_t probe_calib_bed_temp = BED_MAX_TARGET, // Bed temperature while calibrating probe - bed_calib_probe_temp = BTC_PROBE_TEMP; // Probe temperature while calibrating bed - - static int16_t *sensor_z_offsets[TSI_COUNT], - z_offsets_probe[cali_info_init[TSI_PROBE].measurements], // (µm) - z_offsets_bed[cali_info_init[TSI_BED].measurements]; // (µm) - - #if ENABLED(USE_TEMP_EXT_COMPENSATION) - static int16_t z_offsets_ext[cali_info_init[TSI_EXT].measurements]; // (µm) + static int16_t *sensor_z_offsets[TSI_COUNT]; + #if ENABLED(PTC_PROBE) + static int16_t z_offsets_probe[PTC_PROBE_COUNT]; // (µm) + #endif + #if ENABLED(PTC_BED) + static int16_t z_offsets_bed[PTC_BED_COUNT]; // (µm) + #endif + #if ENABLED(PTC_HOTEND) + static int16_t z_offsets_hotend[PTC_HOTEND_COUNT]; // (µm) #endif static inline void reset_index() { calib_idx = 0; }; static inline uint8_t get_index() { return calib_idx; } + static void reset(); static void clear_offsets(const TempSensorID tsi); static inline void clear_all_offsets() { - clear_offsets(TSI_BED); - clear_offsets(TSI_PROBE); - TERN_(USE_TEMP_EXT_COMPENSATION, clear_offsets(TSI_EXT)); + TERN_(PTC_PROBE, clear_offsets(TSI_PROBE)); + TERN_(PTC_BED, clear_offsets(TSI_BED)); + TERN_(PTC_HOTEND, clear_offsets(TSI_EXT)); } static bool set_offset(const TempSensorID tsi, const uint8_t idx, const int16_t offset); static void print_offsets(); @@ -156,4 +106,4 @@ class ProbeTempComp { static bool linear_regression(const TempSensorID tsi, float &k, float &d); }; -extern ProbeTempComp temp_comp; +extern ProbeTempComp ptc; diff --git a/Marlin/src/feature/spindle_laser.cpp b/Marlin/src/feature/spindle_laser.cpp index ea6fc4990e..9297e9b95c 100644 --- a/Marlin/src/feature/spindle_laser.cpp +++ b/Marlin/src/feature/spindle_laser.cpp @@ -66,7 +66,7 @@ void SpindleLaser::init() { #endif #if ENABLED(SPINDLE_LASER_USE_PWM) SET_PWM(SPINDLE_LASER_PWM_PIN); - analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed + set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed #endif #if ENABLED(HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY) set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); @@ -92,10 +92,8 @@ void SpindleLaser::init() { void SpindleLaser::_set_ocr(const uint8_t ocr) { #if NEEDS_HARDWARE_PWM && SPINDLE_LASER_FREQUENCY set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), TERN(MARLIN_DEV_MODE, frequency, SPINDLE_LASER_FREQUENCY)); - set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); - #else - analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); #endif + set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); } void SpindleLaser::set_ocr(const uint8_t ocr) { diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index e111bcd8aa..728771d580 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -520,7 +520,7 @@ void GcodeSuite::G26() { g26.keep_heaters_on = parser.boolval('K'); // Accept 'I' if temperature presets are defined - #if PREHEAT_COUNT + #if HAS_PREHEAT const uint8_t preset_index = parser.seenval('I') ? _MIN(parser.value_byte(), PREHEAT_COUNT - 1) + 1 : 0; #endif @@ -530,7 +530,7 @@ void GcodeSuite::G26() { celsius_t bedtemp = 0; // Use the 'I' index if temperature presets are defined - #if PREHEAT_COUNT + #if HAS_PREHEAT if (preset_index) bedtemp = ui.material_preset[preset_index - 1].bed_temp; #endif @@ -613,7 +613,7 @@ void GcodeSuite::G26() { celsius_t noztemp = 0; // Accept 'I' if temperature presets are defined - #if PREHEAT_COUNT + #if HAS_PREHEAT if (preset_index) noztemp = ui.material_preset[preset_index - 1].hotend_temp; #endif diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 5d94797f16..14da38c8fe 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -36,7 +36,7 @@ #include "../../../module/probe.h" #include "../../queue.h" -#if ENABLED(PROBE_TEMP_COMPENSATION) +#if HAS_PTC #include "../../../feature/probe_temp_comp.h" #include "../../../module/temperature.h" #endif @@ -645,11 +645,9 @@ G29_TYPE GcodeSuite::G29() { break; // Breaks out of both loops } - #if ENABLED(PROBE_TEMP_COMPENSATION) - temp_comp.compensate_measurement(TSI_BED, thermalManager.degBed(), abl.measured_z); - temp_comp.compensate_measurement(TSI_PROBE, thermalManager.degProbe(), abl.measured_z); - TERN_(USE_TEMP_EXT_COMPENSATION, temp_comp.compensate_measurement(TSI_EXT, thermalManager.degHotend(0), abl.measured_z)); - #endif + TERN_(PTC_BED, ptc.compensate_measurement(TSI_BED, thermalManager.degBed(), abl.measured_z)); + TERN_(PTC_PROBE, ptc.compensate_measurement(TSI_PROBE, thermalManager.degProbe(), abl.measured_z)); + TERN_(PTC_HOTEND, ptc.compensate_measurement(TSI_EXT, thermalManager.degHotend(0), abl.measured_z)); #if ENABLED(AUTO_BED_LEVELING_LINEAR) diff --git a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp deleted file mode 100644 index 0fc41ed929..0000000000 --- a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp +++ /dev/null @@ -1,358 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * G76_M871.cpp - Temperature calibration/compensation for z-probing - */ - -#include "../../inc/MarlinConfig.h" - -#if ENABLED(PROBE_TEMP_COMPENSATION) - -#include "../gcode.h" -#include "../../module/motion.h" -#include "../../module/planner.h" -#include "../../module/probe.h" -#include "../../feature/bedlevel/bedlevel.h" -#include "../../module/temperature.h" -#include "../../module/probe.h" -#include "../../feature/probe_temp_comp.h" -#include "../../lcd/marlinui.h" - -/** - * G76: calibrate probe and/or bed temperature offsets - * Notes: - * - When calibrating probe, bed temperature is held constant. - * Compensation values are deltas to first probe measurement at probe temp. = 30°C. - * - When calibrating bed, probe temperature is held constant. - * Compensation values are deltas to first probe measurement at bed temp. = 60°C. - * - The hotend will not be heated at any time. - * - On my Průša MK3S clone I put a piece of paper between the probe and the hotend - * so the hotend fan would not cool my probe constantly. Alternatively you could just - * make sure the fan is not running while running the calibration process. - * - * Probe calibration: - * - Moves probe to cooldown point. - * - Heats up bed to 100°C. - * - Moves probe to probing point (1mm above heatbed). - * - Waits until probe reaches target temperature (30°C). - * - Does a z-probing (=base value) and increases target temperature by 5°C. - * - Waits until probe reaches increased target temperature. - * - Does a z-probing (delta to base value will be a compensation value) and increases target temperature by 5°C. - * - Repeats last two steps until max. temperature reached or timeout (i.e. probe does not heat up any further). - * - Compensation values of higher temperatures will be extrapolated (using linear regression first). - * While this is not exact by any means it is still better than simply using the last compensation value. - * - * Bed calibration: - * - Moves probe to cooldown point. - * - Heats up bed to 60°C. - * - Moves probe to probing point (1mm above heatbed). - * - Waits until probe reaches target temperature (30°C). - * - Does a z-probing (=base value) and increases bed temperature by 5°C. - * - Moves probe to cooldown point. - * - Waits until probe is below 30°C and bed has reached target temperature. - * - Moves probe to probing point and waits until it reaches target temperature (30°C). - * - Does a z-probing (delta to base value will be a compensation value) and increases bed temperature by 5°C. - * - Repeats last four points until max. bed temperature reached (110°C) or timeout. - * - Compensation values of higher temperatures will be extrapolated (using linear regression first). - * While this is not exact by any means it is still better than simply using the last compensation value. - * - * G76 [B | P] - * - no flag - Both calibration procedures will be run. - * - `B` - Run bed temperature calibration. - * - `P` - Run probe temperature calibration. - */ - -static void say_waiting_for() { SERIAL_ECHOPGM("Waiting for "); } -static void say_waiting_for_probe_heating() { say_waiting_for(); SERIAL_ECHOLNPGM("probe heating."); } -static void say_successfully_calibrated() { SERIAL_ECHOPGM("Successfully calibrated"); } -static void say_failed_to_calibrate() { SERIAL_ECHOPGM("!Failed to calibrate"); } - -void GcodeSuite::G76() { - // Check if heated bed is available and z-homing is done with probe - #if TEMP_SENSOR_BED == 0 || !(HOMING_Z_WITH_PROBE) - return; - #endif - - auto report_temps = [](millis_t &ntr, millis_t timeout=0) { - idle_no_sleep(); - const millis_t ms = millis(); - if (ELAPSED(ms, ntr)) { - ntr = ms + 1000; - thermalManager.print_heater_states(active_extruder); - } - return (timeout && ELAPSED(ms, timeout)); - }; - - auto wait_for_temps = [&](const celsius_t tb, const celsius_t tp, millis_t &ntr, const millis_t timeout=0) { - say_waiting_for(); SERIAL_ECHOLNPGM("bed and probe temperature."); - while (thermalManager.wholeDegBed() != tb || thermalManager.wholeDegProbe() > tp) - if (report_temps(ntr, timeout)) return true; - return false; - }; - - auto g76_probe = [](const TempSensorID sid, celsius_t &targ, const xy_pos_t &nozpos) { - do_z_clearance(5.0); // Raise nozzle before probing - const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false); // verbose=0, probe_relative=false - if (isnan(measured_z)) - SERIAL_ECHOLNPGM("!Received NAN. Aborting."); - else { - SERIAL_ECHOLNPAIR_F("Measured: ", measured_z); - if (targ == cali_info_init[sid].start_temp) - temp_comp.prepare_new_calibration(measured_z); - else - temp_comp.push_back_new_measurement(sid, measured_z); - targ += cali_info_init[sid].temp_resolution; - } - return measured_z; - }; - - #if ENABLED(BLTOUCH) - // Make sure any BLTouch error condition is cleared - bltouch_command(BLTOUCH_RESET, BLTOUCH_RESET_DELAY); - set_bltouch_deployed(false); - #endif - - bool do_bed_cal = parser.boolval('B'), do_probe_cal = parser.boolval('P'); - if (!do_bed_cal && !do_probe_cal) do_bed_cal = do_probe_cal = true; - - // Synchronize with planner - planner.synchronize(); - - const xyz_pos_t parkpos = temp_comp.park_point, - probe_pos_xyz = xyz_pos_t(temp_comp.measure_point) + xyz_pos_t({ 0.0f, 0.0f, PTC_PROBE_HEATING_OFFSET }), - noz_pos_xyz = probe_pos_xyz - probe.offset_xy; // Nozzle position based on probe position - - if (do_bed_cal || do_probe_cal) { - // Ensure park position is reachable - bool reachable = position_is_reachable(parkpos) || WITHIN(parkpos.z, Z_MIN_POS - fslop, Z_MAX_POS + fslop); - if (!reachable) - SERIAL_ECHOLNPGM("!Park"); - else { - // Ensure probe position is reachable - reachable = probe.can_reach(probe_pos_xyz); - if (!reachable) SERIAL_ECHOLNPGM("!Probe"); - } - - if (!reachable) { - SERIAL_ECHOLNPGM(" position unreachable - aborting."); - return; - } - - process_subcommands_now(FPSTR(G28_STR)); - } - - remember_feedrate_scaling_off(); - - /****************************************** - * Calibrate bed temperature offsets - ******************************************/ - - // Report temperatures every second and handle heating timeouts - millis_t next_temp_report = millis() + 1000; - - auto report_targets = [&](const celsius_t tb, const celsius_t tp) { - SERIAL_ECHOLNPGM("Target Bed:", tb, " Probe:", tp); - }; - - if (do_bed_cal) { - - celsius_t target_bed = cali_info_init[TSI_BED].start_temp, - target_probe = temp_comp.bed_calib_probe_temp; - - say_waiting_for(); SERIAL_ECHOLNPGM(" cooling."); - while (thermalManager.wholeDegBed() > target_bed || thermalManager.wholeDegProbe() > target_probe) - report_temps(next_temp_report); - - // Disable leveling so it won't mess with us - TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); - - for (;;) { - thermalManager.setTargetBed(target_bed); - - report_targets(target_bed, target_probe); - - // Park nozzle - do_blocking_move_to(parkpos); - - // Wait for heatbed to reach target temp and probe to cool below target temp - if (wait_for_temps(target_bed, target_probe, next_temp_report, millis() + MIN_TO_MS(15))) { - SERIAL_ECHOLNPGM("!Bed heating timeout."); - break; - } - - // Move the nozzle to the probing point and wait for the probe to reach target temp - do_blocking_move_to(noz_pos_xyz); - say_waiting_for_probe_heating(); - SERIAL_EOL(); - while (thermalManager.wholeDegProbe() < target_probe) - report_temps(next_temp_report); - - const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz); - if (isnan(measured_z) || target_bed > (BED_MAX_TARGET)) break; - } - - SERIAL_ECHOLNPGM("Retrieved measurements: ", temp_comp.get_index()); - if (temp_comp.finish_calibration(TSI_BED)) { - say_successfully_calibrated(); - SERIAL_ECHOLNPGM(" bed."); - } - else { - say_failed_to_calibrate(); - SERIAL_ECHOLNPGM(" bed. Values reset."); - } - - // Cleanup - thermalManager.setTargetBed(0); - TERN_(HAS_LEVELING, set_bed_leveling_enabled(true)); - } // do_bed_cal - - /******************************************** - * Calibrate probe temperature offsets - ********************************************/ - - if (do_probe_cal) { - - // Park nozzle - do_blocking_move_to(parkpos); - - // Initialize temperatures - const celsius_t target_bed = temp_comp.probe_calib_bed_temp; - thermalManager.setTargetBed(target_bed); - - celsius_t target_probe = cali_info_init[TSI_PROBE].start_temp; - - report_targets(target_bed, target_probe); - - // Wait for heatbed to reach target temp and probe to cool below target temp - wait_for_temps(target_bed, target_probe, next_temp_report); - - // Disable leveling so it won't mess with us - TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); - - bool timeout = false; - for (;;) { - // Move probe to probing point and wait for it to reach target temperature - do_blocking_move_to(noz_pos_xyz); - - say_waiting_for_probe_heating(); - SERIAL_ECHOLNPGM(" Bed:", target_bed, " Probe:", target_probe); - const millis_t probe_timeout_ms = millis() + SEC_TO_MS(900UL); - while (thermalManager.degProbe() < target_probe) { - if (report_temps(next_temp_report, probe_timeout_ms)) { - SERIAL_ECHOLNPGM("!Probe heating timed out."); - timeout = true; - break; - } - } - if (timeout) break; - - const float measured_z = g76_probe(TSI_PROBE, target_probe, noz_pos_xyz); - if (isnan(measured_z) || target_probe > cali_info_init[TSI_PROBE].end_temp) break; - } - - SERIAL_ECHOLNPGM("Retrieved measurements: ", temp_comp.get_index()); - if (temp_comp.finish_calibration(TSI_PROBE)) - say_successfully_calibrated(); - else - say_failed_to_calibrate(); - SERIAL_ECHOLNPGM(" probe."); - - // Cleanup - thermalManager.setTargetBed(0); - TERN_(HAS_LEVELING, set_bed_leveling_enabled(true)); - - SERIAL_ECHOLNPGM("Final compensation values:"); - temp_comp.print_offsets(); - } // do_probe_cal - - restore_feedrate_and_scaling(); -} - -/** - * M871: Report / reset temperature compensation offsets. - * Note: This does not affect values in EEPROM until M500. - * - * M871 [ R | B | P | E ] - * - * No Parameters - Print current offset values. - * - * Select only one of these flags: - * R - Reset all offsets to zero (i.e., disable compensation). - * B - Manually set offset for bed - * P - Manually set offset for probe - * E - Manually set offset for extruder - * - * With B, P, or E: - * I[index] - Index in the array - * V[value] - Adjustment in µm - */ -void GcodeSuite::M871() { - - if (parser.seen('R')) { - // Reset z-probe offsets to factory defaults - temp_comp.clear_all_offsets(); - SERIAL_ECHOLNPGM("Offsets reset to default."); - } - else if (parser.seen("BPE")) { - if (!parser.seenval('V')) return; - const int16_t offset_val = parser.value_int(); - if (!parser.seenval('I')) return; - const int16_t idx = parser.value_int(); - const TempSensorID mod = (parser.seen('B') ? TSI_BED : - #if ENABLED(USE_TEMP_EXT_COMPENSATION) - parser.seen('E') ? TSI_EXT : - #endif - TSI_PROBE - ); - if (idx > 0 && temp_comp.set_offset(mod, idx - 1, offset_val)) - SERIAL_ECHOLNPGM("Set value: ", offset_val); - else - SERIAL_ECHOLNPGM("!Invalid index. Failed to set value (note: value at index 0 is constant)."); - - } - else // Print current Z-probe adjustments. Note: Values in EEPROM might differ. - temp_comp.print_offsets(); -} - -/** - * M192: Wait for probe temperature sensor to reach a target - * - * Select only one of these flags: - * R - Wait for heating or cooling - * S - Wait only for heating - */ -void GcodeSuite::M192() { - if (DEBUGGING(DRYRUN)) return; - - const bool no_wait_for_cooling = parser.seenval('S'); - if (!no_wait_for_cooling && ! parser.seenval('R')) { - SERIAL_ERROR_MSG("No target temperature set."); - return; - } - - const celsius_t target_temp = parser.value_celsius(); - ui.set_status(thermalManager.isProbeBelowTemp(target_temp) ? GET_TEXT_F(MSG_PROBE_HEATING) : GET_TEXT_F(MSG_PROBE_COOLING)); - thermalManager.wait_for_probe(target_temp, no_wait_for_cooling); -} - -#endif // PROBE_TEMP_COMPENSATION diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp new file mode 100644 index 0000000000..21bb2c7590 --- /dev/null +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -0,0 +1,337 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * G76_M871.cpp - Temperature calibration/compensation for z-probing + */ + +#include "../../inc/MarlinConfig.h" + +#if HAS_PTC + +#include "../gcode.h" +#include "../../module/motion.h" +#include "../../module/planner.h" +#include "../../module/probe.h" +#include "../../feature/bedlevel/bedlevel.h" +#include "../../module/temperature.h" +#include "../../module/probe.h" +#include "../../feature/probe_temp_comp.h" +#include "../../lcd/marlinui.h" + +/** + * G76: calibrate probe and/or bed temperature offsets + * Notes: + * - When calibrating probe, bed temperature is held constant. + * Compensation values are deltas to first probe measurement at probe temp. = 30°C. + * - When calibrating bed, probe temperature is held constant. + * Compensation values are deltas to first probe measurement at bed temp. = 60°C. + * - The hotend will not be heated at any time. + * - On my Průša MK3S clone I put a piece of paper between the probe and the hotend + * so the hotend fan would not cool my probe constantly. Alternatively you could just + * make sure the fan is not running while running the calibration process. + * + * Probe calibration: + * - Moves probe to cooldown point. + * - Heats up bed to 100°C. + * - Moves probe to probing point (1mm above heatbed). + * - Waits until probe reaches target temperature (30°C). + * - Does a z-probing (=base value) and increases target temperature by 5°C. + * - Waits until probe reaches increased target temperature. + * - Does a z-probing (delta to base value will be a compensation value) and increases target temperature by 5°C. + * - Repeats last two steps until max. temperature reached or timeout (i.e. probe does not heat up any further). + * - Compensation values of higher temperatures will be extrapolated (using linear regression first). + * While this is not exact by any means it is still better than simply using the last compensation value. + * + * Bed calibration: + * - Moves probe to cooldown point. + * - Heats up bed to 60°C. + * - Moves probe to probing point (1mm above heatbed). + * - Waits until probe reaches target temperature (30°C). + * - Does a z-probing (=base value) and increases bed temperature by 5°C. + * - Moves probe to cooldown point. + * - Waits until probe is below 30°C and bed has reached target temperature. + * - Moves probe to probing point and waits until it reaches target temperature (30°C). + * - Does a z-probing (delta to base value will be a compensation value) and increases bed temperature by 5°C. + * - Repeats last four points until max. bed temperature reached (110°C) or timeout. + * - Compensation values of higher temperatures will be extrapolated (using linear regression first). + * While this is not exact by any means it is still better than simply using the last compensation value. + * + * G76 [B | P] + * - no flag - Both calibration procedures will be run. + * - `B` - Run bed temperature calibration. + * - `P` - Run probe temperature calibration. + */ + +static void say_waiting_for() { SERIAL_ECHOPGM("Waiting for "); } +static void say_waiting_for_probe_heating() { say_waiting_for(); SERIAL_ECHOLNPGM("probe heating."); } +static void say_successfully_calibrated() { SERIAL_ECHOPGM("Successfully calibrated"); } +static void say_failed_to_calibrate() { SERIAL_ECHOPGM("!Failed to calibrate"); } + +#if BOTH(PTC_PROBE, PTC_BED) + + void GcodeSuite::G76() { + auto report_temps = [](millis_t &ntr, millis_t timeout=0) { + idle_no_sleep(); + const millis_t ms = millis(); + if (ELAPSED(ms, ntr)) { + ntr = ms + 1000; + thermalManager.print_heater_states(active_extruder); + } + return (timeout && ELAPSED(ms, timeout)); + }; + + auto wait_for_temps = [&](const celsius_t tb, const celsius_t tp, millis_t &ntr, const millis_t timeout=0) { + say_waiting_for(); SERIAL_ECHOLNPGM("bed and probe temperature."); + while (thermalManager.wholeDegBed() != tb || thermalManager.wholeDegProbe() > tp) + if (report_temps(ntr, timeout)) return true; + return false; + }; + + auto g76_probe = [](const TempSensorID sid, celsius_t &targ, const xy_pos_t &nozpos) { + do_z_clearance(5.0); // Raise nozzle before probing + const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false); // verbose=0, probe_relative=false + if (isnan(measured_z)) + SERIAL_ECHOLNPGM("!Received NAN. Aborting."); + else { + SERIAL_ECHOLNPAIR_F("Measured: ", measured_z); + if (targ == ProbeTempComp::cali_info[sid].start_temp) + ptc.prepare_new_calibration(measured_z); + else + ptc.push_back_new_measurement(sid, measured_z); + targ += ProbeTempComp::cali_info[sid].temp_resolution; + } + return measured_z; + }; + + #if ENABLED(BLTOUCH) + // Make sure any BLTouch error condition is cleared + bltouch_command(BLTOUCH_RESET, BLTOUCH_RESET_DELAY); + set_bltouch_deployed(false); + #endif + + bool do_bed_cal = parser.boolval('B'), do_probe_cal = parser.boolval('P'); + if (!do_bed_cal && !do_probe_cal) do_bed_cal = do_probe_cal = true; + + // Synchronize with planner + planner.synchronize(); + + #ifndef PTC_PROBE_HEATING_OFFSET + #define PTC_PROBE_HEATING_OFFSET 0 + #endif + const xyz_pos_t parkpos = PTC_PARK_POS, + probe_pos_xyz = xyz_pos_t(PTC_PROBE_POS) + xyz_pos_t({ 0.0f, 0.0f, PTC_PROBE_HEATING_OFFSET }), + noz_pos_xyz = probe_pos_xyz - probe.offset_xy; // Nozzle position based on probe position + + if (do_bed_cal || do_probe_cal) { + // Ensure park position is reachable + bool reachable = position_is_reachable(parkpos) || WITHIN(parkpos.z, Z_MIN_POS - fslop, Z_MAX_POS + fslop); + if (!reachable) + SERIAL_ECHOLNPGM("!Park"); + else { + // Ensure probe position is reachable + reachable = probe.can_reach(probe_pos_xyz); + if (!reachable) SERIAL_ECHOLNPGM("!Probe"); + } + + if (!reachable) { + SERIAL_ECHOLNPGM(" position unreachable - aborting."); + return; + } + + process_subcommands_now(FPSTR(G28_STR)); + } + + remember_feedrate_scaling_off(); + + /****************************************** + * Calibrate bed temperature offsets + ******************************************/ + + // Report temperatures every second and handle heating timeouts + millis_t next_temp_report = millis() + 1000; + + auto report_targets = [&](const celsius_t tb, const celsius_t tp) { + SERIAL_ECHOLNPGM("Target Bed:", tb, " Probe:", tp); + }; + + if (do_bed_cal) { + + celsius_t target_bed = PTC_BED_START, + target_probe = PTC_PROBE_TEMP; + + say_waiting_for(); SERIAL_ECHOLNPGM(" cooling."); + while (thermalManager.wholeDegBed() > target_bed || thermalManager.wholeDegProbe() > target_probe) + report_temps(next_temp_report); + + // Disable leveling so it won't mess with us + TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); + + for (uint8_t idx = 0; idx <= PTC_BED_COUNT; idx++) { + thermalManager.setTargetBed(target_bed); + + report_targets(target_bed, target_probe); + + // Park nozzle + do_blocking_move_to(parkpos); + + // Wait for heatbed to reach target temp and probe to cool below target temp + if (wait_for_temps(target_bed, target_probe, next_temp_report, millis() + MIN_TO_MS(15))) { + SERIAL_ECHOLNPGM("!Bed heating timeout."); + break; + } + + // Move the nozzle to the probing point and wait for the probe to reach target temp + do_blocking_move_to(noz_pos_xyz); + say_waiting_for_probe_heating(); + SERIAL_EOL(); + while (thermalManager.wholeDegProbe() < target_probe) + report_temps(next_temp_report); + + const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz); + if (isnan(measured_z) || target_bed > (BED_MAX_TARGET)) break; + } + + SERIAL_ECHOLNPGM("Retrieved measurements: ", ptc.get_index()); + if (ptc.finish_calibration(TSI_BED)) { + say_successfully_calibrated(); + SERIAL_ECHOLNPGM(" bed."); + } + else { + say_failed_to_calibrate(); + SERIAL_ECHOLNPGM(" bed. Values reset."); + } + + // Cleanup + thermalManager.setTargetBed(0); + TERN_(HAS_LEVELING, set_bed_leveling_enabled(true)); + } // do_bed_cal + + /******************************************** + * Calibrate probe temperature offsets + ********************************************/ + + if (do_probe_cal) { + + // Park nozzle + do_blocking_move_to(parkpos); + + // Initialize temperatures + const celsius_t target_bed = BED_MAX_TARGET; + thermalManager.setTargetBed(target_bed); + + celsius_t target_probe = PTC_PROBE_START; + + report_targets(target_bed, target_probe); + + // Wait for heatbed to reach target temp and probe to cool below target temp + wait_for_temps(target_bed, target_probe, next_temp_report); + + // Disable leveling so it won't mess with us + TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); + + bool timeout = false; + for (uint8_t idx = 0; idx <= PTC_PROBE_COUNT; idx++) { + // Move probe to probing point and wait for it to reach target temperature + do_blocking_move_to(noz_pos_xyz); + + say_waiting_for_probe_heating(); + SERIAL_ECHOLNPGM(" Bed:", target_bed, " Probe:", target_probe); + const millis_t probe_timeout_ms = millis() + SEC_TO_MS(900UL); + while (thermalManager.degProbe() < target_probe) { + if (report_temps(next_temp_report, probe_timeout_ms)) { + SERIAL_ECHOLNPGM("!Probe heating timed out."); + timeout = true; + break; + } + } + if (timeout) break; + + const float measured_z = g76_probe(TSI_PROBE, target_probe, noz_pos_xyz); + if (isnan(measured_z)) break; + } + + SERIAL_ECHOLNPGM("Retrieved measurements: ", ptc.get_index()); + if (ptc.finish_calibration(TSI_PROBE)) + say_successfully_calibrated(); + else + say_failed_to_calibrate(); + SERIAL_ECHOLNPGM(" probe."); + + // Cleanup + thermalManager.setTargetBed(0); + TERN_(HAS_LEVELING, set_bed_leveling_enabled(true)); + + SERIAL_ECHOLNPGM("Final compensation values:"); + ptc.print_offsets(); + } // do_probe_cal + + restore_feedrate_and_scaling(); + } + +#endif // PTC_PROBE && PTC_BED + +/** + * M871: Report / reset temperature compensation offsets. + * Note: This does not affect values in EEPROM until M500. + * + * M871 [ R | B | P | E ] + * + * No Parameters - Print current offset values. + * + * Select only one of these flags: + * R - Reset all offsets to zero (i.e., disable compensation). + * B - Manually set offset for bed + * P - Manually set offset for probe + * E - Manually set offset for extruder + * + * With B, P, or E: + * I[index] - Index in the array + * V[value] - Adjustment in µm + */ +void GcodeSuite::M871() { + + if (parser.seen('R')) { + // Reset z-probe offsets to factory defaults + ptc.clear_all_offsets(); + SERIAL_ECHOLNPGM("Offsets reset to default."); + } + else if (parser.seen("BPE")) { + if (!parser.seenval('V')) return; + const int16_t offset_val = parser.value_int(); + if (!parser.seenval('I')) return; + const int16_t idx = parser.value_int(); + const TempSensorID mod = TERN_(PTC_BED, parser.seen_test('B') ? TSI_BED :) + TERN_(PTC_HOTEND, parser.seen_test('E') ? TSI_EXT :) + TERN_(PTC_PROBE, parser.seen_test('P') ? TSI_PROBE :) TSI_COUNT; + if (mod == TSI_COUNT) + SERIAL_ECHOLNPGM("!Invalid sensor."); + else if (idx > 0 && ptc.set_offset(mod, idx - 1, offset_val)) + SERIAL_ECHOLNPGM("Set value: ", offset_val); + else + SERIAL_ECHOLNPGM("!Invalid index. Failed to set value (note: value at index 0 is constant)."); + } + else // Print current Z-probe adjustments. Note: Values in EEPROM might differ. + ptc.print_offsets(); +} + +#endif // HAS_PTC diff --git a/Marlin/src/gcode/control/M42.cpp b/Marlin/src/gcode/control/M42.cpp index eead971a01..77c0ccc49b 100644 --- a/Marlin/src/gcode/control/M42.cpp +++ b/Marlin/src/gcode/control/M42.cpp @@ -126,10 +126,10 @@ void GcodeSuite::M42() { extDigitalWrite(pin, pin_status); #ifdef ARDUINO_ARCH_STM32 - // A simple I/O will be set to 0 by analogWrite() + // A simple I/O will be set to 0 by set_pwm_duty() if (pin_status <= 1 && !PWM_PIN(pin)) return; #endif - analogWrite(pin, pin_status); + set_pwm_duty(pin, pin_status); } #endif // DIRECT_PIN_CONTROL diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index 2a1b3b34b9..b8be9daa40 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -74,13 +74,12 @@ * This code should ALWAYS be available for FULL SHUTDOWN! */ void GcodeSuite::M81() { - thermalManager.disable_all_heaters(); planner.finish_and_disable(); + thermalManager.cooldown(); print_job_timer.stop(); #if HAS_FAN - thermalManager.zero_fan_speeds(); #if ENABLED(PROBING_FANS_OFF) thermalManager.fans_paused = false; ZERO(thermalManager.saved_fan_speed); diff --git a/Marlin/src/gcode/feature/L6470/M906.cpp b/Marlin/src/gcode/feature/L6470/M906.cpp index a74365e84d..d058ce5501 100644 --- a/Marlin/src/gcode/feature/L6470/M906.cpp +++ b/Marlin/src/gcode/feature/L6470/M906.cpp @@ -280,7 +280,7 @@ void GcodeSuite::M906() { #if E_STEPPERS case E_AXIS: { - const int8_t target_e_stepper = get_target_e_stepper_from_command(); + const int8_t target_e_stepper = get_target_e_stepper_from_command(0); if (target_e_stepper < 0) return; switch (target_e_stepper) { #if AXIS_IS_L64XX(E0) diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp index 2803c44592..cb33d46d25 100644 --- a/Marlin/src/gcode/feature/trinamic/M569.cpp +++ b/Marlin/src/gcode/feature/trinamic/M569.cpp @@ -133,7 +133,7 @@ static void say_stealth_status() { */ void GcodeSuite::M569() { if (parser.seen('S')) - set_stealth_status(parser.value_bool(), get_target_e_stepper_from_command()); + set_stealth_status(parser.value_bool(), get_target_e_stepper_from_command(0)); else say_stealth_status(); } diff --git a/Marlin/src/gcode/feature/trinamic/M906.cpp b/Marlin/src/gcode/feature/trinamic/M906.cpp index 74596831d3..f28718c831 100644 --- a/Marlin/src/gcode/feature/trinamic/M906.cpp +++ b/Marlin/src/gcode/feature/trinamic/M906.cpp @@ -104,7 +104,7 @@ void GcodeSuite::M906() { #if E_STEPPERS case E_AXIS: { - const int8_t target_e_stepper = get_target_e_stepper_from_command(); + const int8_t target_e_stepper = get_target_e_stepper_from_command(0); if (target_e_stepper < 0) return; switch (target_e_stepper) { #if AXIS_IS_TMC(E0) diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index 6e177960ef..3f83558fd4 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -268,7 +268,7 @@ break; #if E_STEPPERS case E_AXIS: { - const int8_t target_e_stepper = get_target_e_stepper_from_command(); + const int8_t target_e_stepper = get_target_e_stepper_from_command(0); if (target_e_stepper < 0) return; switch (target_e_stepper) { TERN_(E0_HAS_STEALTHCHOP, case 0: TMC_SET_PWMTHRS_E(0); break;) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index ef21935185..b2cb26122f 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -137,11 +137,12 @@ int8_t GcodeSuite::get_target_extruder_from_command() { } /** - * Get the target e stepper from the T parameter - * Return -1 if the T parameter is out of range or unspecified + * Get the target E stepper from the 'T' parameter. + * If there is no 'T' parameter then dval will be substituted. + * Returns -1 if the resulting E stepper index is out of range. */ -int8_t GcodeSuite::get_target_e_stepper_from_command() { - const int8_t e = parser.intval('T', -1); +int8_t GcodeSuite::get_target_e_stepper_from_command(const int8_t dval/*=-1*/) { + const int8_t e = parser.intval('T', dval); if (WITHIN(e, 0, E_STEPPERS - 1)) return e; SERIAL_ECHO_START(); @@ -423,7 +424,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 61: G61(); break; // G61: Apply/restore saved coordinates. #endif - #if ENABLED(PROBE_TEMP_COMPENSATION) + #if BOTH(PTC_PROBE, PTC_BED) case 76: G76(); break; // G76: Calibrate first layer compensation values #endif @@ -586,6 +587,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 191: M191(); break; // M191: Wait for chamber temperature to reach target #endif + #if HAS_TEMP_PROBE + case 192: M192(); break; // M192: Wait for probe temp + #endif + #if HAS_COOLER case 143: M143(); break; // M143: Set cooler temperature case 193: M193(); break; // M193: Wait for cooler temperature to reach target @@ -639,7 +644,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 120: M120(); break; // M120: Enable endstops case 121: M121(); break; // M121: Disable endstops - #if PREHEAT_COUNT + #if HAS_PREHEAT case 145: M145(); break; // M145: Set material heatup parameters #endif @@ -920,8 +925,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 852: M852(); break; // M852: Set Skew factors #endif - #if ENABLED(PROBE_TEMP_COMPENSATION) - case 192: M192(); break; // M192: Wait for probe temp + #if HAS_PTC case 871: M871(); break; // M871: Print/reset/clear first layer temperature offset values #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 21f0d3942f..d7bacaef32 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -66,7 +66,7 @@ * G42 - Coordinated move to a mesh point (Requires MESH_BED_LEVELING, AUTO_BED_LEVELING_BLINEAR, or AUTO_BED_LEVELING_UBL) * G60 - Save current position. (Requires SAVED_POSITIONS) * G61 - Apply/restore saved coordinates. (Requires SAVED_POSITIONS) - * G76 - Calibrate first layer temperature offsets. (Requires PROBE_TEMP_COMPENSATION) + * G76 - Calibrate first layer temperature offsets. (Requires PTC_PROBE and PTC_BED) * G80 - Cancel current motion mode (Requires GCODE_MOTION_MODES) * G90 - Use Absolute Coordinates * G91 - Use Relative Coordinates @@ -88,6 +88,8 @@ * M16 - Expected printer check. (Requires EXPECTED_PRINTER_CHECK) * M17 - Enable/Power all stepper motors * M18 - Disable all stepper motors; same as M84 + * + *** Print from Media (SDSUPPORT) *** * M20 - List SD card. (Requires SDSUPPORT) * M21 - Init SD card. (Requires SDSUPPORT) * M22 - Release SD card. (Requires SDSUPPORT) @@ -100,30 +102,36 @@ * OR, with 'C' get the current filename. * M28 - Start SD write: "M28 /path/file.gco". (Requires SDSUPPORT) * M29 - Stop SD write. (Requires SDSUPPORT) - * M30 - Delete file from SD: "M30 /path/file.gco" + * M30 - Delete file from SD: "M30 /path/file.gco" (Requires SDSUPPORT) * M31 - Report time since last M109 or SD card start to serial. * M32 - Select file and start SD print: "M32 [S] !/path/file.gco#". (Requires SDSUPPORT) * Use P to run other files as sub-programs: "M32 P !filename#" * The '#' is necessary when calling from within sd files, as it stops buffer prereading * M33 - Get the longname version of a path. (Requires LONG_FILENAME_HOST_SUPPORT) * M34 - Set SD Card sorting options. (Requires SDCARD_SORT_ALPHA) + * * M42 - Change pin status via gcode: M42 P S. LED pin assumed if P is omitted. (Requires DIRECT_PIN_CONTROL) - * M43 - Display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins + * M43 - Display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins (Requires PINS_DEBUGGING) * M48 - Measure Z Probe repeatability: M48 P X Y V E L S. (Requires Z_MIN_PROBE_REPEATABILITY_TEST) + * * M73 - Set the progress percentage. (Requires LCD_SET_PROGRESS_MANUALLY) * M75 - Start the print job timer. * M76 - Pause the print job timer. * M77 - Stop the print job timer. * M78 - Show statistical information about the print jobs. (Requires PRINTCOUNTER) + * * M80 - Turn on Power Supply. (Requires PSU_CONTROL) * M81 - Turn off Power Supply. (Requires PSU_CONTROL) + * * M82 - Set E codes absolute (default). * M83 - Set E codes relative while in Absolute (G90) mode. * M84 - Disable steppers until next move, or use S to specify an idle * duration after which steppers should turn off. S0 disables the timeout. * M85 - Set inactivity shutdown timer with parameter S. To disable set zero (default) * M92 - Set planner.settings.axis_steps_per_mm for one or more axes. + * * M100 - Watch Free Memory (for debugging) (Requires M100_FREE_MEMORY_WATCHER) + * * M104 - Set extruder target temp. * M105 - Report current temperatures. * M106 - Set print fan speed. @@ -132,23 +140,29 @@ * M109 - S Wait for extruder current temp to reach target temp. ** Wait only when heating! ** * R Wait for extruder current temp to reach target temp. ** Wait for heating or cooling. ** * If AUTOTEMP is enabled, S B F. Exit autotemp by any M109 without F + * * M110 - Set the current line number. (Used by host printing) * M111 - Set debug flags: "M111 S". See flag bits defined in enum.h. * M112 - Full Shutdown. + * * M113 - Get or set the timeout interval for Host Keepalive "busy" messages. (Requires HOST_KEEPALIVE_FEATURE) * M114 - Report current position. * M115 - Report capabilities. (Extended capabilities requires EXTENDED_CAPABILITIES_REPORT) * M117 - Display a message on the controller screen. (Requires an LCD) * M118 - Display a message in the host console. + * * M119 - Report endstops status. * M120 - Enable endstops detection. * M121 - Disable endstops detection. + * * M122 - Debug stepper (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470) * M125 - Save current position and move to filament change position. (Requires PARK_HEAD_ON_PAUSE) + * * M126 - Solenoid Air Valve Open. (Requires BARICUDA) * M127 - Solenoid Air Valve Closed. (Requires BARICUDA) * M128 - EtoP Open. (Requires BARICUDA) * M129 - EtoP Closed. (Requires BARICUDA) + * * M140 - Set bed target temp. S * M141 - Set heated chamber target temp. S (Requires a chamber heater) * M143 - Set cooler target temp. S (Requires a laser cooling device) @@ -161,9 +175,9 @@ * M164 - Commit the mix and save to a virtual tool (current, or as specified by 'S'). (Requires MIXING_EXTRUDER) * M165 - Set the mix for the mixing extruder (and current virtual tool) with parameters ABCDHI. (Requires MIXING_EXTRUDER and DIRECT_MIXING_IN_G1) * M166 - Set the Gradient Mix for the mixing extruder. (Requires GRADIENT_MIX) - * M190 - S Wait for bed current temp to reach target temp. ** Wait only when heating! ** - * R Wait for bed current temp to reach target temp. ** Wait for heating or cooling. ** - * M193 - R Wait for cooler temp to reach target temp. ** Wait for cooling. ** + * M190 - Set bed target temperature and wait. R Set target temperature and wait. S Set, but only wait when heating. (Requires TEMP_SENSOR_BED) + * M192 - Wait for probe to reach target temperature. (Requires TEMP_SENSOR_PROBE) + * M193 - R Wait for cooler to reach target temp. ** Wait for cooling. ** * M200 - Set filament diameter, D, setting E axis units to cubic. (Use S0 to revert to linear units.) * M201 - Set max acceleration in units/s^2 for print moves: "M201 X Y Z E" * M202 - Set max acceleration in units/s^2 for travel moves: "M202 X Y Z E" ** UNUSED IN MARLIN! ** @@ -183,7 +197,7 @@ * M218 - Set/get a tool offset: "M218 T X Y". (Requires 2 or more extruders) * M220 - Set Feedrate Percentage: "M220 S" (i.e., "FR" on the LCD) * Use "M220 B" to back up the Feedrate Percentage and "M220 R" to restore it. (Requires an MMU_MODEL version 2 or 2S) - * M221 - Set Flow Percentage: "M221 S" + * M221 - Set Flow Percentage: "M221 S" (Requires an extruder) * M226 - Wait until a pin is in a given state: "M226 P S" (Requires DIRECT_PIN_CONTROL) * M240 - Trigger a camera to take a photograph. (Requires PHOTO_GCODE) * M250 - Set LCD contrast: "M250 C" (0-63). (Requires LCD support) @@ -230,9 +244,9 @@ * M502 - Revert to the default "factory settings". ** Does not write them to EEPROM! ** * M503 - Print the current settings (in memory): "M503 S". S0 specifies compact output. * M504 - Validate EEPROM contents. (Requires EEPROM_SETTINGS) - * M510 - Lock Printer - * M511 - Unlock Printer - * M512 - Set/Change/Remove Password + * M510 - Lock Printer (Requires PASSWORD_FEATURE) + * M511 - Unlock Printer (Requires PASSWORD_UNLOCK_GCODE) + * M512 - Set/Change/Remove Password (Requires PASSWORD_CHANGE_GCODE) * M524 - Abort the current SD print job started with M24. (Requires SDSUPPORT) * M540 - Enable/disable SD card abort on endstop hit: "M540 S". (Requires SD_ABORT_ON_ENDSTOP_HIT) * M552 - Get or set IP address. Enable/disable network interface. (Requires enabled Ethernet port) @@ -252,7 +266,9 @@ * M808 - Set or Goto a Repeat Marker (Requires GCODE_REPEAT_MARKERS) * M810-M819 - Define/execute a G-code macro (Requires GCODE_MACROS) * M851 - Set Z probe's XYZ offsets in current units. (Negative values: X=left, Y=front, Z=below) - * M852 - Set skew factors: "M852 [I] [J] [K]". (Requires SKEW_CORRECTION_GCODE, and SKEW_CORRECTION_FOR_Z for IJ) + * M852 - Set skew factors: "M852 [I] [J] [K]". (Requires SKEW_CORRECTION_GCODE, plus SKEW_CORRECTION_FOR_Z for IJ) + * + *** I2C_POSITION_ENCODERS *** * M860 - Report the position of position encoder modules. * M861 - Report the status of position encoder modules. * M862 - Perform an axis continuity test for position encoder modules. @@ -263,8 +279,8 @@ * M867 - Enable/disable or toggle error correction for position encoder modules. * M868 - Report or set position encoder module error correction threshold. * M869 - Report position encoder module error. - * M871 - Print/reset/clear first layer temperature offset values. (Requires PROBE_TEMP_COMPENSATION) - * M192 - Wait for probe temp (Requires PROBE_TEMP_COMPENSATION) + * + * M871 - Print/reset/clear first layer temperature offset values. (Requires PTC_PROBE, PTC_BED, or PTC_HOTEND) * M876 - Handle Prompt Response. (Requires HOST_PROMPT_SUPPORT and not EMERGENCY_PARSER) * M900 - Get or Set Linear Advance K-factor. (Requires LIN_ADVANCE) * M906 - Set or get motor current in milliamps using axis codes X, Y, Z, E. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470) @@ -282,13 +298,14 @@ * M951 - Set Magnetic Parking Extruder parameters. (Requires MAGNETIC_PARKING_EXTRUDER) * M7219 - Control Max7219 Matrix LEDs. (Requires MAX7219_GCODE) * + *** SCARA *** * M360 - SCARA calibration: Move to cal-position ThetaA (0 deg calibration) * M361 - SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree) * M362 - SCARA calibration: Move to cal-position PsiA (0 deg calibration) * M363 - SCARA calibration: Move to cal-position PsiB (90 deg calibration - steps per degree) * M364 - SCARA calibration: Move to cal-position PSIC (90 deg to Theta calibration position) * - * ************ Custom codes - This can change to suit future G-code regulations + *** Custom codes (can be changed to suit future G-code standards) *** * G425 - Calibrate using a conductive object. (Requires CALIBRATION_GCODE) * M928 - Start SD logging: "M928 filename.gco". Stop with M29. (Requires SDSUPPORT) * M993 - Backup SPI Flash to SD @@ -296,10 +313,11 @@ * M995 - Touch screen calibration for TFT display * M997 - Perform in-application firmware update * M999 - Restart after being stopped by error + * * D... - Custom Development G-code. Add hooks to 'gcode_D.cpp' for developers to test features. (Requires MARLIN_DEV_MODE) * D576 - Set buffer monitoring options. (Requires BUFFER_MONITORING) * - * "T" Codes + *** "T" Codes *** * * T0-T3 - Select an extruder (tool) by index: "T F" */ @@ -390,7 +408,7 @@ public: static void say_units(); static int8_t get_target_extruder_from_command(); - static int8_t get_target_e_stepper_from_command(); + static int8_t get_target_e_stepper_from_command(const int8_t dval=-1); static void get_destination_from_command(); static void process_parsed_command(const bool no_ok=false); @@ -551,7 +569,7 @@ private: static void G59(); #endif - #if ENABLED(PROBE_TEMP_COMPENSATION) + #if BOTH(PTC_PROBE, PTC_BED) static void G76(); #endif @@ -744,12 +762,16 @@ private: static void M191(); #endif + #if HAS_TEMP_PROBE + static void M192(); + #endif + #if HAS_COOLER static void M143(); static void M193(); #endif - #if PREHEAT_COUNT + #if HAS_PREHEAT static void M145(); static void M145_report(const bool forReplay=true); #endif @@ -1087,8 +1109,7 @@ private: FORCE_INLINE static void M869() { I2CPEM.M869(); } #endif - #if ENABLED(PROBE_TEMP_COMPENSATION) - static void M192(); + #if HAS_PTC static void M871(); #endif @@ -1109,7 +1130,7 @@ private: static void M913(); static void M913_report(const bool forReplay=true); #endif - #if ENABLED(USE_SENSORLESS) + #if USE_SENSORLESS static void M914(); static void M914_report(const bool forReplay=true); #endif diff --git a/Marlin/src/gcode/lcd/M145.cpp b/Marlin/src/gcode/lcd/M145.cpp index 2dba238d3f..8dbe2fb07e 100644 --- a/Marlin/src/gcode/lcd/M145.cpp +++ b/Marlin/src/gcode/lcd/M145.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if PREHEAT_COUNT +#if HAS_PREHEAT #include "../gcode.h" #include "../../lcd/marlinui.h" @@ -79,4 +79,4 @@ void GcodeSuite::M145_report(const bool forReplay/*=true*/) { } } -#endif // PREHEAT_COUNT +#endif // HAS_PREHEAT diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index cc072e51a1..fd98a39cd6 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -719,7 +719,7 @@ void GCodeQueue::advance() { if (auto_buffer_report_interval && ELAPSED(ms, next_buffer_report_ms)) { next_buffer_report_ms = ms + 1000UL * auto_buffer_report_interval; - PORT_REDIRECT(SERIAL_BOTH); + PORT_REDIRECT(SerialMask::All); report_buffer_statistics(); PORT_RESTORE(); } diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index efda04def5..baaac02100 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -88,7 +88,7 @@ void GcodeSuite::M104_M109(const bool isM109) { celsius_t temp = 0; // Accept 'I' if temperature presets are defined - #if PREHEAT_COUNT + #if HAS_PREHEAT got_temp = parser.seenval('I'); if (got_temp) { const uint8_t index = parser.value_byte(); diff --git a/Marlin/src/gcode/temp/M106_M107.cpp b/Marlin/src/gcode/temp/M106_M107.cpp index 3f85c53d78..98e87c415d 100644 --- a/Marlin/src/gcode/temp/M106_M107.cpp +++ b/Marlin/src/gcode/temp/M106_M107.cpp @@ -32,7 +32,7 @@ #include "../../module/planner.h" #endif -#if PREHEAT_COUNT +#if HAS_PREHEAT #include "../../lcd/marlinui.h" #endif @@ -75,7 +75,7 @@ void GcodeSuite::M106() { uint16_t speed = dspeed; // Accept 'I' if temperature presets are defined - #if PREHEAT_COUNT + #if HAS_PREHEAT const bool got_preset = parser.seenval('I'); if (got_preset) speed = ui.material_preset[_MIN(parser.value_byte(), PREHEAT_COUNT - 1)].fan_speed; #else diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index edc15b9cba..7532defccd 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -63,7 +63,7 @@ void GcodeSuite::M140_M190(const bool isM190) { celsius_t temp = 0; // Accept 'I' if temperature presets are defined - #if PREHEAT_COUNT + #if HAS_PREHEAT got_temp = parser.seenval('I'); if (got_temp) { const uint8_t index = parser.value_byte(); diff --git a/Marlin/src/gcode/temp/M192.cpp b/Marlin/src/gcode/temp/M192.cpp new file mode 100644 index 0000000000..a96e2d34a4 --- /dev/null +++ b/Marlin/src/gcode/temp/M192.cpp @@ -0,0 +1,56 @@ +/** + * 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 . + * + */ + +/** + * M192.cpp - Wait for probe to reach temperature + */ + +#include "../../inc/MarlinConfig.h" + +#if HAS_TEMP_PROBE + +#include "../gcode.h" +#include "../../module/temperature.h" +#include "../../lcd/marlinui.h" + +/** + * M192: Wait for probe temperature sensor to reach a target + * + * Select only one of these flags: + * R - Wait for heating or cooling + * S - Wait only for heating + */ +void GcodeSuite::M192() { + if (DEBUGGING(DRYRUN)) return; + + const bool no_wait_for_cooling = parser.seenval('S'); + if (!no_wait_for_cooling && !parser.seenval('R')) { + SERIAL_ERROR_MSG("No target temperature set."); + return; + } + + const celsius_t target_temp = parser.value_celsius(); + ui.set_status(thermalManager.isProbeBelowTemp(target_temp) ? GET_TEXT_F(MSG_PROBE_HEATING) : GET_TEXT_F(MSG_PROBE_COOLING)); + thermalManager.wait_for_probe(target_temp, no_wait_for_cooling); +} + +#endif // HAS_TEMP_PROBE diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index dd2d6ed748..49067a5606 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -550,6 +550,20 @@ #endif #endif +// Probe Temperature Compensation +#if !TEMP_SENSOR_PROBE + #undef PTC_PROBE +#endif +#if !TEMP_SENSOR_BED + #undef PTC_BED +#endif +#if !HAS_EXTRUDERS + #undef PTC_HOTEND +#endif +#if ANY(PTC_PROBE, PTC_BED, PTC_HOTEND) + #define HAS_PTC 1 +#endif + // Let SD_FINISHED_RELEASECOMMAND stand in for SD_FINISHED_STEPPERRELEASE #if ENABLED(SD_FINISHED_STEPPERRELEASE) #ifndef SD_FINISHED_RELEASECOMMAND @@ -701,6 +715,9 @@ #ifndef ACTION_ON_KILL #define ACTION_ON_KILL "poweroff" #endif + #ifndef SHUTDOWN_ACTION + #define SHUTDOWN_ACTION "shutdown" + #endif #if HAS_FILAMENT_SENSOR #ifndef ACTION_ON_FILAMENT_RUNOUT #define ACTION_ON_FILAMENT_RUNOUT "filament_runout" diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 6a70a5ce54..8008461547 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -769,19 +769,25 @@ #define X2_MAX_ENDSTOP_INVERTING false #endif #endif - #ifndef X2_MAX_PIN + #if !defined(X2_MAX_PIN) && !defined(X2_STOP_PIN) #if X2_USE_ENDSTOP == _XMIN_ #define X2_MAX_PIN X_MIN_PIN #elif X2_USE_ENDSTOP == _XMAX_ #define X2_MAX_PIN X_MAX_PIN + #elif X2_USE_ENDSTOP == _XSTOP_ + #define X2_MAX_PIN X_STOP_PIN #elif X2_USE_ENDSTOP == _YMIN_ #define X2_MAX_PIN Y_MIN_PIN #elif X2_USE_ENDSTOP == _YMAX_ #define X2_MAX_PIN Y_MAX_PIN + #elif X2_USE_ENDSTOP == _YSTOP_ + #define X2_MAX_PIN Y_STOP_PIN #elif X2_USE_ENDSTOP == _ZMIN_ #define X2_MAX_PIN Z_MIN_PIN #elif X2_USE_ENDSTOP == _ZMAX_ #define X2_MAX_PIN Z_MAX_PIN + #elif X2_USE_ENDSTOP == _ZSTOP_ + #define X2_MAX_PIN Z_STOP_PIN #elif X2_USE_ENDSTOP == _XDIAG_ #define X2_MAX_PIN X_DIAG_PIN #elif X2_USE_ENDSTOP == _YDIAG_ @@ -827,19 +833,25 @@ #define X2_MIN_ENDSTOP_INVERTING false #endif #endif - #ifndef X2_MIN_PIN + #if !defined(X2_MIN_PIN) && !defined(X2_STOP_PIN) #if X2_USE_ENDSTOP == _XMIN_ #define X2_MIN_PIN X_MIN_PIN #elif X2_USE_ENDSTOP == _XMAX_ #define X2_MIN_PIN X_MAX_PIN + #elif X2_USE_ENDSTOP == _XSTOP_ + #define X2_MIN_PIN X_STOP_PIN #elif X2_USE_ENDSTOP == _YMIN_ #define X2_MIN_PIN Y_MIN_PIN #elif X2_USE_ENDSTOP == _YMAX_ #define X2_MIN_PIN Y_MAX_PIN + #elif X2_USE_ENDSTOP == _YSTOP_ + #define X2_MIN_PIN Y_STOP_PIN #elif X2_USE_ENDSTOP == _ZMIN_ #define X2_MIN_PIN Z_MIN_PIN #elif X2_USE_ENDSTOP == _ZMAX_ #define X2_MIN_PIN Z_MAX_PIN + #elif X2_USE_ENDSTOP == _ZSTOP_ + #define X2_MIN_PIN Z_STOP_PIN #elif X2_USE_ENDSTOP == _XDIAG_ #define X2_MIN_PIN X_DIAG_PIN #elif X2_USE_ENDSTOP == _YDIAG_ @@ -892,19 +904,25 @@ #define Y2_MAX_ENDSTOP_INVERTING false #endif #endif - #ifndef Y2_MAX_PIN + #if !defined(Y2_MAX_PIN) && !defined(Y2_STOP_PIN) #if Y2_USE_ENDSTOP == _XMIN_ #define Y2_MAX_PIN X_MIN_PIN #elif Y2_USE_ENDSTOP == _XMAX_ #define Y2_MAX_PIN X_MAX_PIN + #elif Y2_USE_ENDSTOP == _XSTOP_ + #define Y2_MAX_PIN X_STOP_PIN #elif Y2_USE_ENDSTOP == _YMIN_ #define Y2_MAX_PIN Y_MIN_PIN #elif Y2_USE_ENDSTOP == _YMAX_ #define Y2_MAX_PIN Y_MAX_PIN + #elif Y2_USE_ENDSTOP == _YSTOP_ + #define Y2_MAX_PIN Y_STOP_PIN #elif Y2_USE_ENDSTOP == _ZMIN_ #define Y2_MAX_PIN Z_MIN_PIN #elif Y2_USE_ENDSTOP == _ZMAX_ #define Y2_MAX_PIN Z_MAX_PIN + #elif Y2_USE_ENDSTOP == _ZSTOP_ + #define Y2_MAX_PIN Z_STOP_PIN #elif Y2_USE_ENDSTOP == _XDIAG_ #define Y2_MAX_PIN X_DIAG_PIN #elif Y2_USE_ENDSTOP == _YDIAG_ @@ -950,19 +968,25 @@ #define Y2_MIN_ENDSTOP_INVERTING false #endif #endif - #ifndef Y2_MIN_PIN + #if !defined(Y2_MIN_PIN) && !defined(Y2_STOP_PIN) #if Y2_USE_ENDSTOP == _XMIN_ #define Y2_MIN_PIN X_MIN_PIN #elif Y2_USE_ENDSTOP == _XMAX_ #define Y2_MIN_PIN X_MAX_PIN + #elif Y2_USE_ENDSTOP == _XSTOP_ + #define Y2_MIN_PIN X_STOP_PIN #elif Y2_USE_ENDSTOP == _YMIN_ #define Y2_MIN_PIN Y_MIN_PIN #elif Y2_USE_ENDSTOP == _YMAX_ #define Y2_MIN_PIN Y_MAX_PIN + #elif Y2_USE_ENDSTOP == _YSTOP_ + #define Y2_MIN_PIN Y_STOP_PIN #elif Y2_USE_ENDSTOP == _ZMIN_ #define Y2_MIN_PIN Z_MIN_PIN #elif Y2_USE_ENDSTOP == _ZMAX_ #define Y2_MIN_PIN Z_MAX_PIN + #elif Y2_USE_ENDSTOP == _ZSTOP_ + #define Y2_MIN_PIN Z_STOP_PIN #elif Y2_USE_ENDSTOP == _XDIAG_ #define Y2_MIN_PIN X_DIAG_PIN #elif Y2_USE_ENDSTOP == _YDIAG_ @@ -1016,19 +1040,25 @@ #define Z2_MAX_ENDSTOP_INVERTING false #endif #endif - #ifndef Z2_MAX_PIN + #if !defined(Z2_MAX_PIN) && !defined(Z2_STOP_PIN) #if Z2_USE_ENDSTOP == _XMIN_ #define Z2_MAX_PIN X_MIN_PIN #elif Z2_USE_ENDSTOP == _XMAX_ #define Z2_MAX_PIN X_MAX_PIN + #elif Z2_USE_ENDSTOP == _XSTOP_ + #define Z2_MAX_PIN X_STOP_PIN #elif Z2_USE_ENDSTOP == _YMIN_ #define Z2_MAX_PIN Y_MIN_PIN #elif Z2_USE_ENDSTOP == _YMAX_ #define Z2_MAX_PIN Y_MAX_PIN + #elif Z2_USE_ENDSTOP == _YSTOP_ + #define Z2_MAX_PIN Y_STOP_PIN #elif Z2_USE_ENDSTOP == _ZMIN_ #define Z2_MAX_PIN Z_MIN_PIN #elif Z2_USE_ENDSTOP == _ZMAX_ #define Z2_MAX_PIN Z_MAX_PIN + #elif Z2_USE_ENDSTOP == _ZSTOP_ + #define Z2_MAX_PIN Z_STOP_PIN #elif Z2_USE_ENDSTOP == _XDIAG_ #define Z2_MAX_PIN X_DIAG_PIN #elif Z2_USE_ENDSTOP == _YDIAG_ @@ -1079,14 +1109,20 @@ #define Z2_MIN_PIN X_MIN_PIN #elif Z2_USE_ENDSTOP == _XMAX_ #define Z2_MIN_PIN X_MAX_PIN + #elif Z2_USE_ENDSTOP == _XSTOP_ + #define Z2_MIN_PIN X_STOP_PIN #elif Z2_USE_ENDSTOP == _YMIN_ #define Z2_MIN_PIN Y_MIN_PIN #elif Z2_USE_ENDSTOP == _YMAX_ #define Z2_MIN_PIN Y_MAX_PIN + #elif Z2_USE_ENDSTOP == _YSTOP_ + #define Z2_MIN_PIN Y_STOP_PIN #elif Z2_USE_ENDSTOP == _ZMIN_ #define Z2_MIN_PIN Z_MIN_PIN #elif Z2_USE_ENDSTOP == _ZMAX_ #define Z2_MIN_PIN Z_MAX_PIN + #elif Z2_USE_ENDSTOP == _ZSTOP_ + #define Z2_MIN_PIN Z_STOP_PIN #elif Z2_USE_ENDSTOP == _XDIAG_ #define Z2_MIN_PIN X_DIAG_PIN #elif Z2_USE_ENDSTOP == _YDIAG_ @@ -1140,14 +1176,20 @@ #define Z3_MAX_PIN X_MIN_PIN #elif Z3_USE_ENDSTOP == _XMAX_ #define Z3_MAX_PIN X_MAX_PIN + #elif Z3_USE_ENDSTOP == _XSTOP_ + #define Z3_MAX_PIN X_STOP_PIN #elif Z3_USE_ENDSTOP == _YMIN_ #define Z3_MAX_PIN Y_MIN_PIN #elif Z3_USE_ENDSTOP == _YMAX_ #define Z3_MAX_PIN Y_MAX_PIN + #elif Z3_USE_ENDSTOP == _YSTOP_ + #define Z3_MAX_PIN Y_STOP_PIN #elif Z3_USE_ENDSTOP == _ZMIN_ #define Z3_MAX_PIN Z_MIN_PIN #elif Z3_USE_ENDSTOP == _ZMAX_ #define Z3_MAX_PIN Z_MAX_PIN + #elif Z3_USE_ENDSTOP == _ZSTOP_ + #define Z3_MAX_PIN Z_STOP_PIN #elif Z3_USE_ENDSTOP == _XDIAG_ #define Z3_MAX_PIN X_DIAG_PIN #elif Z3_USE_ENDSTOP == _YDIAG_ @@ -1198,14 +1240,20 @@ #define Z3_MIN_PIN X_MIN_PIN #elif Z3_USE_ENDSTOP == _XMAX_ #define Z3_MIN_PIN X_MAX_PIN + #elif Z3_USE_ENDSTOP == _XSTOP_ + #define Z3_MIN_PIN X_STOP_PIN #elif Z3_USE_ENDSTOP == _YMIN_ #define Z3_MIN_PIN Y_MIN_PIN #elif Z3_USE_ENDSTOP == _YMAX_ #define Z3_MIN_PIN Y_MAX_PIN + #elif Z3_USE_ENDSTOP == _YSTOP_ + #define Z3_MIN_PIN Y_STOP_PIN #elif Z3_USE_ENDSTOP == _ZMIN_ #define Z3_MIN_PIN Z_MIN_PIN #elif Z3_USE_ENDSTOP == _ZMAX_ #define Z3_MIN_PIN Z_MAX_PIN + #elif Z3_USE_ENDSTOP == _ZSTOP_ + #define Z3_MIN_PIN Z_STOP_PIN #elif Z3_USE_ENDSTOP == _XDIAG_ #define Z3_MIN_PIN X_DIAG_PIN #elif Z3_USE_ENDSTOP == _YDIAG_ @@ -1260,14 +1308,20 @@ #define Z4_MAX_PIN X_MIN_PIN #elif Z4_USE_ENDSTOP == _XMAX_ #define Z4_MAX_PIN X_MAX_PIN + #elif Z4_USE_ENDSTOP == _XSTOP_ + #define Z4_MAX_PIN X_STOP_PIN #elif Z4_USE_ENDSTOP == _YMIN_ #define Z4_MAX_PIN Y_MIN_PIN #elif Z4_USE_ENDSTOP == _YMAX_ #define Z4_MAX_PIN Y_MAX_PIN + #elif Z4_USE_ENDSTOP == _YSTOP_ + #define Z4_MAX_PIN Y_STOP_PIN #elif Z4_USE_ENDSTOP == _ZMIN_ #define Z4_MAX_PIN Z_MIN_PIN #elif Z4_USE_ENDSTOP == _ZMAX_ #define Z4_MAX_PIN Z_MAX_PIN + #elif Z4_USE_ENDSTOP == _ZSTOP_ + #define Z4_MAX_PIN Z_STOP_PIN #elif Z4_USE_ENDSTOP == _XDIAG_ #define Z4_MAX_PIN X_DIAG_PIN #elif Z4_USE_ENDSTOP == _YDIAG_ @@ -1318,14 +1372,20 @@ #define Z4_MIN_PIN X_MIN_PIN #elif Z4_USE_ENDSTOP == _XMAX_ #define Z4_MIN_PIN X_MAX_PIN + #elif Z4_USE_ENDSTOP == _XSTOP_ + #define Z4_MIN_PIN X_STOP_PIN #elif Z4_USE_ENDSTOP == _YMIN_ #define Z4_MIN_PIN Y_MIN_PIN #elif Z4_USE_ENDSTOP == _YMAX_ #define Z4_MIN_PIN Y_MAX_PIN + #elif Z4_USE_ENDSTOP == _YSTOP_ + #define Z4_MIN_PIN Y_STOP_PIN #elif Z4_USE_ENDSTOP == _ZMIN_ #define Z4_MIN_PIN Z_MIN_PIN #elif Z4_USE_ENDSTOP == _ZMAX_ #define Z4_MIN_PIN Z_MAX_PIN + #elif Z4_USE_ENDSTOP == _ZSTOP_ + #define Z4_MIN_PIN Z_STOP_PIN #elif Z4_USE_ENDSTOP == _XDIAG_ #define Z4_MIN_PIN X_DIAG_PIN #elif Z4_USE_ENDSTOP == _YDIAG_ @@ -2876,10 +2936,14 @@ #elif defined(PREHEAT_1_LABEL) #define PREHEAT_COUNT 1 #endif + #if PREHEAT_COUNT && ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) + #define HAS_PREHEAT 1 + #endif #endif -#if !PREHEAT_COUNT +#if !HAS_PREHEAT #undef PREHEAT_SHORTCUT_MENU_ITEM + #undef DGUS_PREHEAT_UI #endif /** diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 60238e6c80..fbdda2c127 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -597,6 +597,10 @@ #error "SPINDLE_LASER_PWM (true) is now set with SPINDLE_LASER_USE_PWM (enabled)." #elif ANY(IS_RAMPS_EEB, IS_RAMPS_EEF, IS_RAMPS_EFB, IS_RAMPS_EFF, IS_RAMPS_SF) #error "The IS_RAMPS_* conditionals (for heater/fan/bed pins) are now called FET_ORDER_*." +#elif defined(PROBE_TEMP_COMPENSATION) + #error "PROBE_TEMP_COMPENSATION is now set using the PTC_PROBE, PTC_BED, PTC_HOTEND options." +#elif defined(BTC_PROBE_TEMP) + #error "BTC_PROBE_TEMP is now PTC_PROBE_TEMP." #endif #if MB(DUE3DOM_MINI) && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD) @@ -611,60 +615,60 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L /** * Probe temp compensation requirements */ - -#if ENABLED(PROBE_TEMP_COMPENSATION) - #if defined(PTC_PARK_POS_X) || defined(PTC_PARK_POS_Y) || defined(PTC_PARK_POS_Z) - #error "PTC_PARK_POS_[XYZ] is now PTC_PARK_POS (array)." - #elif !defined(PTC_PARK_POS) - #error "PROBE_TEMP_COMPENSATION requires PTC_PARK_POS." - #elif defined(PTC_PROBE_POS_X) || defined(PTC_PROBE_POS_Y) - #error "PTC_PROBE_POS_[XY] is now PTC_PROBE_POS (array)." - #elif !defined(PTC_PROBE_POS) - #error "PROBE_TEMP_COMPENSATION requires PTC_PROBE_POS." +#if HAS_PTC + #if TEMP_SENSOR_PROBE && TEMP_SENSOR_BED + #if defined(PTC_PARK_POS_X) || defined(PTC_PARK_POS_Y) || defined(PTC_PARK_POS_Z) + #error "PTC_PARK_POS_[XYZ] is now PTC_PARK_POS (array)." + #elif !defined(PTC_PARK_POS) + #error "PTC_PARK_POS is required for Probe Temperature Compensation." + #elif defined(PTC_PROBE_POS_X) || defined(PTC_PROBE_POS_Y) + #error "PTC_PROBE_POS_[XY] is now PTC_PROBE_POS (array)." + #elif !defined(PTC_PROBE_POS) + #error "PTC_PROBE_POS is required for Probe Temperature Compensation." + #endif #endif - #ifdef PTC_SAMPLE_START - constexpr auto _ptc_sample_start = PTC_SAMPLE_START; + #ifdef PTC_PROBE_START + constexpr auto _ptc_sample_start = PTC_PROBE_START; constexpr decltype(_ptc_sample_start) _test_ptc_sample_start = 12.3f; - static_assert(_test_ptc_sample_start != 12.3f, "PTC_SAMPLE_START must be a whole number."); + static_assert(_test_ptc_sample_start != 12.3f, "PTC_PROBE_START must be a whole number."); #endif - #ifdef PTC_SAMPLE_RES - constexpr auto _ptc_sample_res = PTC_SAMPLE_RES; + #ifdef PTC_PROBE_RES + constexpr auto _ptc_sample_res = PTC_PROBE_RES; constexpr decltype(_ptc_sample_res) _test_ptc_sample_res = 12.3f; - static_assert(_test_ptc_sample_res != 12.3f, "PTC_SAMPLE_RES must be a whole number."); + static_assert(_test_ptc_sample_res != 12.3f, "PTC_PROBE_RES must be a whole number."); #endif - #ifdef BTC_SAMPLE_START - constexpr auto _btc_sample_start = BTC_SAMPLE_START; + #ifdef PTC_BED_START + constexpr auto _btc_sample_start = PTC_BED_START; constexpr decltype(_btc_sample_start) _test_btc_sample_start = 12.3f; - static_assert(_test_btc_sample_start != 12.3f, "BTC_SAMPLE_START must be a whole number."); + static_assert(_test_btc_sample_start != 12.3f, "PTC_BED_START must be a whole number."); #endif - #ifdef BTC_SAMPLE_RES - constexpr auto _btc_sample_res = BTC_SAMPLE_RES; + #ifdef PTC_BED_RES + constexpr auto _btc_sample_res = PTC_BED_RES; constexpr decltype(_btc_sample_res) _test_btc_sample_res = 12.3f; - static_assert(_test_btc_sample_res != 12.3f, "BTC_SAMPLE_RES must be a whole number."); + static_assert(_test_btc_sample_res != 12.3f, "PTC_BED_RES must be a whole number."); #endif - #ifdef BTC_PROBE_TEMP - constexpr auto _btc_probe_temp = BTC_PROBE_TEMP; + #ifdef PTC_PROBE_TEMP + constexpr auto _btc_probe_temp = PTC_PROBE_TEMP; constexpr decltype(_btc_probe_temp) _test_btc_probe_temp = 12.3f; - static_assert(_test_btc_probe_temp != 12.3f, "BTC_PROBE_TEMP must be a whole number."); + static_assert(_test_btc_probe_temp != 12.3f, "PTC_PROBE_TEMP must be a whole number."); #endif - #if ENABLED(USE_TEMP_EXT_COMPENSATION) - #ifdef ETC_SAMPLE_START - constexpr auto _etc_sample_start = ETC_SAMPLE_START; + #if ENABLED(PTC_HOTEND) + #if EXTRUDERS != 1 + #error "PTC_HOTEND only works with a single extruder." + #endif + #ifdef PTC_HOTEND_START + constexpr auto _etc_sample_start = PTC_HOTEND_START; constexpr decltype(_etc_sample_start) _test_etc_sample_start = 12.3f; - static_assert(_test_etc_sample_start != 12.3f, "ETC_SAMPLE_START must be a whole number."); + static_assert(_test_etc_sample_start != 12.3f, "PTC_HOTEND_START must be a whole number."); #endif - #ifdef ETC_SAMPLE_RES - constexpr auto _etc_sample_res = ETC_SAMPLE_RES; + #ifdef PTC_HOTEND_RES + constexpr auto _etc_sample_res = PTC_HOTEND_RES; constexpr decltype(_etc_sample_res) _test_etc_sample_res = 12.3f; - static_assert(_test_etc_sample_res != 12.3f, "ETC_SAMPLE_RES must be a whole number."); + static_assert(_test_etc_sample_res != 12.3f, "PTC_HOTEND_RES must be a whole number."); #endif #endif - - #if ENABLED(USE_TEMP_EXT_COMPENSATION) && EXTRUDERS != 1 - #error "USE_TEMP_EXT_COMPENSATION only works with a single extruder." - #endif -#endif +#endif // HAS_PTC /** * Marlin release, version and default string @@ -1242,8 +1246,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "LIN_ADVANCE and S_CURVE_ACCELERATION may not play well together! Enable EXPERIMENTAL_SCURVE to continue." #elif ENABLED(DIRECT_STEPPING) #error "DIRECT_STEPPING is incompatible with LIN_ADVANCE. Enable in external planner if possible." - #elif !HAS_JUNCTION_DEVIATION && defined(DEFAULT_EJERK) - static_assert(DEFAULT_EJERK >= 10, "It is strongly recommended to set DEFAULT_EJERK >= 10 when using LIN_ADVANCE."); + #elif NONE(HAS_JUNCTION_DEVIATION, ALLOW_LOW_EJERK) && defined(DEFAULT_EJERK) + static_assert(DEFAULT_EJERK >= 10, "It is strongly recommended to set DEFAULT_EJERK >= 10 when using LIN_ADVANCE. Enable ALLOW_LOW_EJERK to bypass this alert (e.g., for direct drive)."); #endif #endif @@ -2485,6 +2489,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "An encoder button is required or SOFT_RESET_ON_KILL will reset the printer without notice!" #endif +// Reset reason for AVR +#if ENABLED(OPTIBOOT_RESET_REASON) && !defined(__AVR__) + #error "OPTIBOOT_RESET_REASON only applies to AVR." +#endif + /** * I2C bus */ diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 5dea5c709c..f695d0a1b2 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-10-25" + #define STRING_DISTRIBUTION_DATE "2021-11-04" #endif /** @@ -52,7 +52,7 @@ * to alert users to major changes. */ -#define MARLIN_HEX_VERSION 02000902 +#define MARLIN_HEX_VERSION 02000903 #ifndef REQUIRED_CONFIGURATION_H_VERSION #define REQUIRED_CONFIGURATION_H_VERSION MARLIN_HEX_VERSION #endif diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index d258aefd82..1976c09581 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -79,14 +79,20 @@ #warning "Auto-assigned X2_DIAG_PIN to X_MIN_PIN." #elif X2_USE_ENDSTOP == _XMAX_ #warning "Auto-assigned X2_DIAG_PIN to X_MAX_PIN." + #elif X2_USE_ENDSTOP == _XSTOP_ + #warning "Auto-assigned X2_DIAG_PIN to X_STOP_PIN." #elif X2_USE_ENDSTOP == _YMIN_ #warning "Auto-assigned X2_DIAG_PIN to Y_MIN_PIN." #elif X2_USE_ENDSTOP == _YMAX_ #warning "Auto-assigned X2_DIAG_PIN to Y_MAX_PIN." + #elif X2_USE_ENDSTOP == _YSTOP_ + #warning "Auto-assigned X2_DIAG_PIN to Y_STOP_PIN." #elif X2_USE_ENDSTOP == _ZMIN_ #warning "Auto-assigned X2_DIAG_PIN to Z_MIN_PIN." #elif X2_USE_ENDSTOP == _ZMAX_ #warning "Auto-assigned X2_DIAG_PIN to Z_MAX_PIN." + #elif X2_USE_ENDSTOP == _ZSTOP_ + #warning "Auto-assigned X2_DIAG_PIN to Z_STOP_PIN." #elif X2_USE_ENDSTOP == _XDIAG_ #warning "Auto-assigned X2_DIAG_PIN to X_DIAG_PIN." #elif X2_USE_ENDSTOP == _YDIAG_ @@ -131,14 +137,20 @@ #warning "Auto-assigned Y2_DIAG_PIN to X_MIN_PIN." #elif Y2_USE_ENDSTOP == _XMAX_ #warning "Auto-assigned Y2_DIAG_PIN to X_MAX_PIN." + #elif Y2_USE_ENDSTOP == _XSTOP_ + #warning "Auto-assigned Y2_DIAG_PIN to X_STOP_PIN." #elif Y2_USE_ENDSTOP == _YMIN_ #warning "Auto-assigned Y2_DIAG_PIN to Y_MIN_PIN." #elif Y2_USE_ENDSTOP == _YMAX_ #warning "Auto-assigned Y2_DIAG_PIN to Y_MAX_PIN." + #elif Y2_USE_ENDSTOP == _YSTOP_ + #warning "Auto-assigned Y2_DIAG_PIN to Y_STOP_PIN." #elif Y2_USE_ENDSTOP == _ZMIN_ #warning "Auto-assigned Y2_DIAG_PIN to Z_MIN_PIN." #elif Y2_USE_ENDSTOP == _ZMAX_ #warning "Auto-assigned Y2_DIAG_PIN to Z_MAX_PIN." + #elif Y2_USE_ENDSTOP == _ZSTOP_ + #warning "Auto-assigned Y2_DIAG_PIN to Z_STOP_PIN." #elif Y2_USE_ENDSTOP == _XDIAG_ #warning "Auto-assigned Y2_DIAG_PIN to X_DIAG_PIN." #elif Y2_USE_ENDSTOP == _YDIAG_ @@ -183,14 +195,20 @@ #warning "Auto-assigned Z2_DIAG_PIN to X_MIN_PIN." #elif Z2_USE_ENDSTOP == _XMAX_ #warning "Auto-assigned Z2_DIAG_PIN to X_MAX_PIN." + #elif Z2_USE_ENDSTOP == _XSTOP_ + #warning "Auto-assigned Z2_DIAG_PIN to X_STOP_PIN." #elif Z2_USE_ENDSTOP == _YMIN_ #warning "Auto-assigned Z2_DIAG_PIN to Y_MIN_PIN." #elif Z2_USE_ENDSTOP == _YMAX_ #warning "Auto-assigned Z2_DIAG_PIN to Y_MAX_PIN." + #elif Z2_USE_ENDSTOP == _YSTOP_ + #warning "Auto-assigned Z2_DIAG_PIN to Y_STOP_PIN." #elif Z2_USE_ENDSTOP == _ZMIN_ #warning "Auto-assigned Z2_DIAG_PIN to Z_MIN_PIN." #elif Z2_USE_ENDSTOP == _ZMAX_ #warning "Auto-assigned Z2_DIAG_PIN to Z_MAX_PIN." + #elif Z2_USE_ENDSTOP == _ZSTOP_ + #warning "Auto-assigned Z2_DIAG_PIN to Z_STOP_PIN." #elif Z2_USE_ENDSTOP == _XDIAG_ #warning "Auto-assigned Z2_DIAG_PIN to X_DIAG_PIN." #elif Z2_USE_ENDSTOP == _YDIAG_ @@ -235,14 +253,20 @@ #warning "Auto-assigned Z3_DIAG_PIN to X_MIN_PIN." #elif Z3_USE_ENDSTOP == _XMAX_ #warning "Auto-assigned Z3_DIAG_PIN to X_MAX_PIN." + #elif Z3_USE_ENDSTOP == _XSTOP_ + #warning "Auto-assigned Z3_DIAG_PIN to X_STOP_PIN." #elif Z3_USE_ENDSTOP == _YMIN_ #warning "Auto-assigned Z3_DIAG_PIN to Y_MIN_PIN." #elif Z3_USE_ENDSTOP == _YMAX_ #warning "Auto-assigned Z3_DIAG_PIN to Y_MAX_PIN." + #elif Z3_USE_ENDSTOP == _YSTOP_ + #warning "Auto-assigned Z3_DIAG_PIN to Y_STOP_PIN." #elif Z3_USE_ENDSTOP == _ZMIN_ #warning "Auto-assigned Z3_DIAG_PIN to Z_MIN_PIN." #elif Z3_USE_ENDSTOP == _ZMAX_ #warning "Auto-assigned Z3_DIAG_PIN to Z_MAX_PIN." + #elif Z3_USE_ENDSTOP == _ZSTOP_ + #warning "Auto-assigned Z3_DIAG_PIN to Z_STOP_PIN." #elif Z3_USE_ENDSTOP == _XDIAG_ #warning "Auto-assigned Z3_DIAG_PIN to X_DIAG_PIN." #elif Z3_USE_ENDSTOP == _YDIAG_ @@ -287,14 +311,20 @@ #warning "Auto-assigned Z4_DIAG_PIN to X_MIN_PIN." #elif Z4_USE_ENDSTOP == _XMAX_ #warning "Auto-assigned Z4_DIAG_PIN to X_MAX_PIN." + #elif Z4_USE_ENDSTOP == _XSTOP_ + #warning "Auto-assigned Z4_DIAG_PIN to X_STOP_PIN." #elif Z4_USE_ENDSTOP == _YMIN_ #warning "Auto-assigned Z4_DIAG_PIN to Y_MIN_PIN." #elif Z4_USE_ENDSTOP == _YMAX_ #warning "Auto-assigned Z4_DIAG_PIN to Y_MAX_PIN." + #elif Z4_USE_ENDSTOP == _YSTOP_ + #warning "Auto-assigned Z4_DIAG_PIN to Y_STOP_PIN." #elif Z4_USE_ENDSTOP == _ZMIN_ #warning "Auto-assigned Z4_DIAG_PIN to Z_MIN_PIN." #elif Z4_USE_ENDSTOP == _ZMAX_ #warning "Auto-assigned Z4_DIAG_PIN to Z_MAX_PIN." + #elif Z4_USE_ENDSTOP == _ZSTOP_ + #warning "Auto-assigned Z4_DIAG_PIN to Z_STOP_PIN." #elif Z4_USE_ENDSTOP == _XDIAG_ #warning "Auto-assigned Z4_DIAG_PIN to X_DIAG_PIN." #elif Z4_USE_ENDSTOP == _YDIAG_ @@ -339,14 +369,20 @@ #warning "Auto-assigned I_DIAG_PIN to X_MIN_PIN." #elif I_USE_ENDSTOP == _XMAX_ #warning "Auto-assigned I_DIAG_PIN to X_MAX_PIN." + #elif I_USE_ENDSTOP == _XSTOP_ + #warning "Auto-assigned I_DIAG_PIN to X_STOP_PIN." #elif I_USE_ENDSTOP == _YMIN_ #warning "Auto-assigned I_DIAG_PIN to Y_MIN_PIN." #elif I_USE_ENDSTOP == _YMAX_ #warning "Auto-assigned I_DIAG_PIN to Y_MAX_PIN." + #elif I_USE_ENDSTOP == _YSTOP_ + #warning "Auto-assigned I_DIAG_PIN to Y_STOP_PIN." #elif I_USE_ENDSTOP == _ZMIN_ #warning "Auto-assigned I_DIAG_PIN to Z_MIN_PIN." #elif I_USE_ENDSTOP == _ZMAX_ #warning "Auto-assigned I_DIAG_PIN to Z_MAX_PIN." + #elif I_USE_ENDSTOP == _ZSTOP_ + #warning "Auto-assigned I_DIAG_PIN to Z_STOP_PIN." #elif I_USE_ENDSTOP == _XDIAG_ #warning "Auto-assigned I_DIAG_PIN to X_DIAG_PIN." #elif I_USE_ENDSTOP == _YDIAG_ @@ -391,14 +427,20 @@ #warning "Auto-assigned J_DIAG_PIN to X_MIN_PIN." #elif J_USE_ENDSTOP == _XMAX_ #warning "Auto-assigned J_DIAG_PIN to X_MAX_PIN." + #elif J_USE_ENDSTOP == _XSTOP_ + #warning "Auto-assigned J_DIAG_PIN to X_STOP_PIN." #elif J_USE_ENDSTOP == _YMIN_ #warning "Auto-assigned J_DIAG_PIN to Y_MIN_PIN." #elif J_USE_ENDSTOP == _YMAX_ #warning "Auto-assigned J_DIAG_PIN to Y_MAX_PIN." + #elif J_USE_ENDSTOP == _YSTOP_ + #warning "Auto-assigned J_DIAG_PIN to Y_STOP_PIN." #elif J_USE_ENDSTOP == _ZMIN_ #warning "Auto-assigned J_DIAG_PIN to Z_MIN_PIN." #elif J_USE_ENDSTOP == _ZMAX_ #warning "Auto-assigned J_DIAG_PIN to Z_MAX_PIN." + #elif J_USE_ENDSTOP == _ZSTOP_ + #warning "Auto-assigned J_DIAG_PIN to Z_STOP_PIN." #elif J_USE_ENDSTOP == _XDIAG_ #warning "Auto-assigned J_DIAG_PIN to X_DIAG_PIN." #elif J_USE_ENDSTOP == _YDIAG_ @@ -443,14 +485,20 @@ #warning "Auto-assigned K_DIAG_PIN to X_MIN_PIN." #elif K_USE_ENDSTOP == _XMAX_ #warning "Auto-assigned K_DIAG_PIN to X_MAX_PIN." + #elif K_USE_ENDSTOP == _XSTOP_ + #warning "Auto-assigned K_DIAG_PIN to X_STOP_PIN." #elif K_USE_ENDSTOP == _YMIN_ #warning "Auto-assigned K_DIAG_PIN to Y_MIN_PIN." #elif K_USE_ENDSTOP == _YMAX_ #warning "Auto-assigned K_DIAG_PIN to Y_MAX_PIN." + #elif K_USE_ENDSTOP == _YSTOP_ + #warning "Auto-assigned K_DIAG_PIN to Y_STOP_PIN." #elif K_USE_ENDSTOP == _ZMIN_ #warning "Auto-assigned K_DIAG_PIN to Z_MIN_PIN." #elif K_USE_ENDSTOP == _ZMAX_ #warning "Auto-assigned K_DIAG_PIN to Z_MAX_PIN." + #elif K_USE_ENDSTOP == _ZSTOP_ + #warning "Auto-assigned K_DIAG_PIN to Z_STOP_PIN." #elif K_USE_ENDSTOP == _XDIAG_ #warning "Auto-assigned K_DIAG_PIN to X_DIAG_PIN." #elif K_USE_ENDSTOP == _YDIAG_ @@ -488,3 +536,12 @@ #if HOMING_Z_WITH_PROBE && IS_CARTESIAN && DISABLED(Z_SAFE_HOMING) #error "Z_SAFE_HOMING is recommended when homing with a probe. Enable Z_SAFE_HOMING or comment out this line to continue." #endif + +// +// Warn users of potential endstop/DIAG pin conflicts to prevent homing issues when not using sensorless homing +// +#if !USE_SENSORLESS && ENABLED(USES_DIAG_JUMPERS) + #warning "Motherboard DIAG jumpers must be removed when SENSORLESS_HOMING is disabled." +#elif !USE_SENSORLESS && ENABLED(USES_DIAG_PINS) + #warning "Driver DIAG pins must be physically removed unless SENSORLESS_HOMING is enabled. (See https://bit.ly/2ZPRlt0)" +#endif diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index 5d4c30bbb4..59c74148ad 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -339,12 +339,14 @@ void MarlinUI::draw_kill_screen() { void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop #if HAS_LCD_BRIGHTNESS + void MarlinUI::_set_brightness() { #if PIN_EXISTS(TFT_BACKLIGHT) if (PWM_PIN(TFT_BACKLIGHT_PIN)) - analogWrite(pin_t(TFT_BACKLIGHT_PIN), brightness); + analogWrite(pin_t(TFT_BACKLIGHT_PIN), backlight ? brightness : 0); #endif } + #endif #if HAS_LCD_MENU diff --git a/Marlin/src/lcd/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index 3326ccb1f3..adf8f3771f 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -165,14 +165,15 @@ typedef struct { } select_t; select_t select_page{0}, select_file{0}, select_print{0}, select_prepare{0} - , select_control{0}, select_axis{0}, select_temp{0}, select_motion{0}, select_tune{0} - , select_advset{0}, select_PLA{0}, select_ABS{0} - , select_speed{0} - , select_acc{0} - , select_jerk{0} - , select_step{0} - , select_item{0} - ; + , select_control{0}, select_axis{0}, select_temp{0}, select_motion{0}, select_tune{0} + , select_advset{0}, select_speed{0}, select_acc{0}, select_jerk{0}, select_step{0}, select_item{0}; + +#if HAS_PREHEAT + select_t select_PLA{0}; + #if PREHEAT_COUNT > 1 + select_t select_ABS{0}; + #endif +#endif uint8_t index_file = MROWS, index_prepare = MROWS, @@ -497,8 +498,8 @@ inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) { #define PREPARE_CASE_DISA 2 #define PREPARE_CASE_HOME 3 #define PREPARE_CASE_ZOFF (PREPARE_CASE_HOME + ENABLED(HAS_ZOFFSET_ITEM)) -#define PREPARE_CASE_PLA (PREPARE_CASE_ZOFF + ENABLED(HAS_HOTEND)) -#define PREPARE_CASE_ABS (PREPARE_CASE_PLA + ENABLED(HAS_HOTEND)) +#define PREPARE_CASE_PLA (PREPARE_CASE_ZOFF + ENABLED(HAS_PREHEAT)) +#define PREPARE_CASE_ABS (PREPARE_CASE_PLA + (TERN0(HAS_PREHEAT, PREHEAT_COUNT > 1))) #define PREPARE_CASE_COOL (PREPARE_CASE_ABS + EITHER(HAS_HOTEND, HAS_HEATED_BED)) #define PREPARE_CASE_LANG (PREPARE_CASE_COOL + 1) #define PREPARE_CASE_TOTAL PREPARE_CASE_LANG @@ -522,8 +523,8 @@ inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) { #define TEMP_CASE_TEMP (0 + ENABLED(HAS_HOTEND)) #define TEMP_CASE_BED (TEMP_CASE_TEMP + ENABLED(HAS_HEATED_BED)) #define TEMP_CASE_FAN (TEMP_CASE_BED + ENABLED(HAS_FAN)) -#define TEMP_CASE_PLA (TEMP_CASE_FAN + ENABLED(HAS_HOTEND)) -#define TEMP_CASE_ABS (TEMP_CASE_PLA + ENABLED(HAS_HOTEND)) +#define TEMP_CASE_PLA (TEMP_CASE_FAN + ENABLED(HAS_PREHEAT)) +#define TEMP_CASE_ABS (TEMP_CASE_PLA + (TERN0(HAS_PREHEAT, PREHEAT_COUNT > 1))) #define TEMP_CASE_TOTAL TEMP_CASE_ABS #define PREHEAT_CASE_TEMP (0 + ENABLED(HAS_HOTEND)) @@ -615,7 +616,7 @@ void Draw_Edit_Float3(const uint8_t row, const uint16_t value, const bool active } void Draw_Edit_Signed_Float2(const uint8_t row, const float value, const bool active=false) { - DWIN_Draw_Signed_Float(font8x16, active ? Select_Color : Color_Bg_Black, 2, UNITFDIGITS, 220 + 8 - UNITFDIGITS * 8, EBASE(row), value); + DWIN_Draw_Signed_Float(font8x16, active ? Select_Color : Color_Bg_Black, 2, UNITFDIGITS + 1, 220 + 8 - UNITFDIGITS * 8, EBASE(row), value); } void Draw_Edit_Signed_Float3(const uint8_t row, const float value, const bool active=false) { @@ -700,7 +701,7 @@ void Item_Prepare_Home(const uint8_t row) { #endif -#if HAS_HOTEND +#if HAS_PREHEAT void Item_Prepare_PLA(const uint8_t row) { if (HMI_IsChinese()) Item_AreaCopy(100, 89, 151, 101, row); @@ -715,22 +716,22 @@ void Item_Prepare_Home(const uint8_t row) { Draw_Menu_Line(row, ICON_PLAPreheat); } - void Item_Prepare_ABS(const uint8_t row) { - if (HMI_IsChinese()) - Item_AreaCopy(180, 89, 233, 100, row); - else { - #ifdef USE_STRING_TITLES - DWIN_Draw_Label(row, F("Preheat " PREHEAT_2_LABEL)); - #else - Item_AreaCopy(108, 76, 155, 87, row); // "Preheat" - say_abs_en(52, row); // "ABS" - #endif + #if PREHEAT_COUNT > 1 + void Item_Prepare_ABS(const uint8_t row) { + if (HMI_IsChinese()) + Item_AreaCopy(180, 89, 233, 100, row); + else { + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(row, F("Preheat " PREHEAT_2_LABEL)); + #else + Item_AreaCopy(108, 76, 155, 87, row); // "Preheat" + say_abs_en(52, row); // "ABS" + #endif + } + Draw_Menu_Line(row, ICON_ABSPreheat); } - Draw_Menu_Line(row, ICON_ABSPreheat); - } -#endif + #endif -#if HAS_PREHEAT void Item_Prepare_Cool(const uint8_t row) { if (HMI_IsChinese()) Item_AreaCopy(1, 104, 56, 117, row); @@ -785,11 +786,13 @@ void Draw_Prepare_Menu() { #if HAS_ZOFFSET_ITEM if (PVISI(PREPARE_CASE_ZOFF)) Item_Prepare_Offset(PSCROL(PREPARE_CASE_ZOFF)); // Edit Z-Offset / Babystep / Set Home Offset #endif - #if HAS_HOTEND - if (PVISI(PREPARE_CASE_PLA)) Item_Prepare_PLA(PSCROL(PREPARE_CASE_PLA)); // Preheat PLA - if (PVISI(PREPARE_CASE_ABS)) Item_Prepare_ABS(PSCROL(PREPARE_CASE_ABS)); // Preheat ABS - #endif #if HAS_PREHEAT + if (PVISI(PREPARE_CASE_PLA)) Item_Prepare_PLA(PSCROL(PREPARE_CASE_PLA)); // Preheat PLA + #if PREHEAT_COUNT > 1 + if (PVISI(PREPARE_CASE_ABS)) Item_Prepare_ABS(PSCROL(PREPARE_CASE_ABS)); // Preheat ABS + #endif + #endif + #if HAS_HOTEND || HAS_HEATED_BED if (PVISI(PREPARE_CASE_COOL)) Item_Prepare_Cool(PSCROL(PREPARE_CASE_COOL)); // Cooldown #endif if (PVISI(PREPARE_CASE_LANG)) Item_Prepare_Lang(PSCROL(PREPARE_CASE_LANG)); // Language CN/EN @@ -1425,25 +1428,34 @@ void HMI_Move_Z() { uint8_t temp_line; switch (HMI_ValueStruct.show_mode) { case -1: temp_line = TEMP_CASE_TEMP; break; - case -2: temp_line = PREHEAT_CASE_TEMP; break; - case -3: temp_line = PREHEAT_CASE_TEMP; break; + #if HAS_PREHEAT + case -2: temp_line = PREHEAT_CASE_TEMP; break; + #if PREHEAT_COUNT > 1 + case -3: temp_line = PREHEAT_CASE_TEMP; break; + #endif + #endif default: temp_line = TUNE_CASE_TEMP + MROWS - index_tune; } if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.E_Temp)) { EncoderRate.enabled = false; - if (HMI_ValueStruct.show_mode == -2) { - checkkey = PLAPreheat; - ui.material_preset[0].hotend_temp = HMI_ValueStruct.E_Temp; - Draw_Edit_Integer3(temp_line, ui.material_preset[0].hotend_temp); - return; - } - else if (HMI_ValueStruct.show_mode == -3) { - checkkey = ABSPreheat; - ui.material_preset[1].hotend_temp = HMI_ValueStruct.E_Temp; - Draw_Edit_Integer3(temp_line, ui.material_preset[1].hotend_temp); - return; - } - else if (HMI_ValueStruct.show_mode == -1) // Temperature + #if HAS_PREHEAT + if (HMI_ValueStruct.show_mode == -2) { + checkkey = PLAPreheat; + ui.material_preset[0].hotend_temp = HMI_ValueStruct.E_Temp; + Draw_Edit_Integer3(temp_line, ui.material_preset[0].hotend_temp); + return; + } + #if PREHEAT_COUNT > 1 + if (HMI_ValueStruct.show_mode == -3) { + checkkey = ABSPreheat; + ui.material_preset[1].hotend_temp = HMI_ValueStruct.E_Temp; + Draw_Edit_Integer3(temp_line, ui.material_preset[1].hotend_temp); + return; + } + #endif + #endif + + if (HMI_ValueStruct.show_mode == -1) // Temperature checkkey = TemperatureID; else checkkey = Tune; @@ -1467,28 +1479,33 @@ void HMI_Move_Z() { uint8_t bed_line; switch (HMI_ValueStruct.show_mode) { case -1: bed_line = TEMP_CASE_BED; break; - case -2: bed_line = PREHEAT_CASE_BED; break; - case -3: bed_line = PREHEAT_CASE_BED; break; + #if HAS_PREHEAT + case -2: bed_line = PREHEAT_CASE_BED; break; + #if PREHEAT_COUNT > 1 + case -3: bed_line = PREHEAT_CASE_BED; break; + #endif + #endif default: bed_line = TUNE_CASE_BED + MROWS - index_tune; } if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Bed_Temp)) { EncoderRate.enabled = false; - if (HMI_ValueStruct.show_mode == -2) { - checkkey = PLAPreheat; - ui.material_preset[0].bed_temp = HMI_ValueStruct.Bed_Temp; - Draw_Edit_Integer3(bed_line, ui.material_preset[0].bed_temp); - return; - } - else if (HMI_ValueStruct.show_mode == -3) { - checkkey = ABSPreheat; - ui.material_preset[1].bed_temp = HMI_ValueStruct.Bed_Temp; - Draw_Edit_Integer3(bed_line, ui.material_preset[1].bed_temp); - return; - } - else if (HMI_ValueStruct.show_mode == -1) - checkkey = TemperatureID; - else - checkkey = Tune; + #if HAS_PREHEAT + if (HMI_ValueStruct.show_mode == -2) { + checkkey = PLAPreheat; + ui.material_preset[0].bed_temp = HMI_ValueStruct.Bed_Temp; + Draw_Edit_Integer3(bed_line, ui.material_preset[0].bed_temp); + return; + } + #if PREHEAT_COUNT > 1 + if (HMI_ValueStruct.show_mode == -3) { + checkkey = ABSPreheat; + ui.material_preset[1].bed_temp = HMI_ValueStruct.Bed_Temp; + Draw_Edit_Integer3(bed_line, ui.material_preset[1].bed_temp); + return; + } + #endif + #endif + checkkey = HMI_ValueStruct.show_mode == -1 ? TemperatureID : Tune; Draw_Edit_Integer3(bed_line, HMI_ValueStruct.Bed_Temp); thermalManager.setTargetBed(HMI_ValueStruct.Bed_Temp); return; @@ -1522,16 +1539,15 @@ void HMI_Move_Z() { Draw_Edit_Integer3(fan_line, ui.material_preset[0].fan_speed); return; } - else if (HMI_ValueStruct.show_mode == -3) { - checkkey = ABSPreheat; - ui.material_preset[1].fan_speed = HMI_ValueStruct.Fan_speed; - Draw_Edit_Integer3(fan_line, ui.material_preset[1].fan_speed); - return; - } - else if (HMI_ValueStruct.show_mode == -1) - checkkey = TemperatureID; - else - checkkey = Tune; + #if PREHEAT_COUNT > 1 + if (HMI_ValueStruct.show_mode == -3) { + checkkey = ABSPreheat; + ui.material_preset[1].fan_speed = HMI_ValueStruct.Fan_speed; + Draw_Edit_Integer3(fan_line, ui.material_preset[1].fan_speed); + return; + } + #endif + checkkey = HMI_ValueStruct.show_mode == -1 ? TemperatureID : Tune; Draw_Edit_Integer3(fan_line, HMI_ValueStruct.Fan_speed); thermalManager.set_fan_speed(0, HMI_ValueStruct.Fan_speed); return; @@ -1659,7 +1675,7 @@ void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, else if (blink && draw_empty) DWIN_Draw_String(true, font8x16, Color_White, Color_Bg_Black, x, y, F(" ")); else - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, x, y, p * 10); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, x, y, p); } } @@ -1769,11 +1785,11 @@ void update_variable() { if (BABY_Z_VAR != _offset) { _offset = BABY_Z_VAR; if (BABY_Z_VAR < 0) { - Draw_Stat_Float(207, 417, -_offset * 100); + Draw_Stat_Float(207, 417, -_offset); DWIN_Draw_String(true, font8x16, Color_White, Color_Bg_Black, 205, 419, F("-")); } else { - Draw_Stat_Float(207, 417, _offset * 100); + Draw_Stat_Float(207, 417, _offset); DWIN_Draw_String(true, font8x16, Color_White, Color_Bg_Black, 205, 419, F(" ")); } } @@ -2656,10 +2672,10 @@ void HMI_Prepare() { // Draw "More" icon for sub-menus if (index_prepare < 7) Draw_More_Icon(MROWS - index_prepare + 1); - #if HAS_HOTEND + #if PREHEAT_COUNT > 1 if (index_prepare == PREPARE_CASE_ABS) Item_Prepare_ABS(MROWS); #endif - #if HAS_PREHEAT + #if HAS_HOTEND || HAS_HEATED_BED if (index_prepare == PREPARE_CASE_COOL) Item_Prepare_Cool(MROWS); #endif if (index_prepare == PREPARE_CASE_LANG) Item_Prepare_Lang(MROWS); @@ -2719,6 +2735,7 @@ void HMI_Prepare() { queue.inject_P(G28_STR); // G28 will set home_flag Popup_Window_Home(); break; + #if HAS_ZOFFSET_ITEM case PREPARE_CASE_ZOFF: #if EITHER(HAS_BED_PROBE, BABYSTEPPING) @@ -2734,28 +2751,23 @@ void HMI_Prepare() { #endif break; #endif + #if HAS_PREHEAT - case PREPARE_CASE_PLA: - TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0)); - TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(ui.material_preset[0].bed_temp)); - TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed)); - break; - case PREPARE_CASE_ABS: - TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0)); - TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(ui.material_preset[1].bed_temp)); - TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed)); - break; - case PREPARE_CASE_COOL: - TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); - #if HAS_HOTEND || HAS_HEATED_BED - thermalManager.disable_all_heaters(); - #endif - break; + case PREPARE_CASE_PLA: ui.preheat_all(0); break; + #if PREHEAT_COUNT > 1 + case PREPARE_CASE_ABS: ui.preheat_all(1); break; + #endif #endif + + #if HAS_HOTEND || HAS_HEATED_BED + case PREPARE_CASE_COOL: thermalManager.cooldown(); break; + #endif + case PREPARE_CASE_LANG: HMI_ToggleLanguage(); Draw_Prepare_Menu(); break; + default: break; } } @@ -2776,9 +2788,11 @@ void Draw_Temperature_Menu() { #if HAS_FAN Item_AreaCopy(115, 134, 170, 146, TEMP_CASE_FAN); #endif - #if HAS_HOTEND + #if HAS_PREHEAT Item_AreaCopy(100, 89, 178, 101, TEMP_CASE_PLA); - Item_AreaCopy(180, 89, 260, 100, TEMP_CASE_ABS); + #if PREHEAT_COUNT > 1 + Item_AreaCopy(180, 89, 260, 100, TEMP_CASE_ABS); + #endif #endif } else { @@ -2797,30 +2811,33 @@ void Draw_Temperature_Menu() { #if HAS_FAN DWIN_Draw_Label(TEMP_CASE_FAN, GET_TEXT_F(MSG_FAN_SPEED)); #endif - #if HAS_HOTEND + #if HAS_PREHEAT DWIN_Draw_Label(TEMP_CASE_PLA, F(PREHEAT_1_LABEL " Preheat Settings")); - DWIN_Draw_Label(TEMP_CASE_ABS, F(PREHEAT_2_LABEL " Preheat Settings")); + #if PREHEAT_COUNT > 1 + DWIN_Draw_Label(TEMP_CASE_ABS, F(PREHEAT_2_LABEL " Preheat Settings")); + #endif #endif #else #if HAS_HOTEND - Item_AreaCopy(197, 104, 238, 114, TEMP_CASE_TEMP); // "Nozzle" - Item_AreaCopy(1, 89, 83, 101, TEMP_CASE_TEMP, 44); // "Temperature" + Item_AreaCopy(197, 104, 238, 114, TEMP_CASE_TEMP); // "Nozzle" + Item_AreaCopy(1, 89, 83, 101, TEMP_CASE_TEMP, 44); // "Temperature" #endif #if HAS_HEATED_BED - Item_AreaCopy(240, 104, 264, 114, TEMP_CASE_BED); // "Bed" - Item_AreaCopy(1, 89, 83, 101, TEMP_CASE_BED, 27); // "Temperature" + Item_AreaCopy(240, 104, 264, 114, TEMP_CASE_BED); // "Bed" + Item_AreaCopy(1, 89, 83, 101, TEMP_CASE_BED, 27); // "Temperature" #endif #if HAS_FAN - Item_AreaCopy( 1, 119, 61, 132, TEMP_CASE_FAN); // "Fan speed" + Item_AreaCopy( 1, 119, 61, 132, TEMP_CASE_FAN); // "Fan speed" #endif - #if HAS_HOTEND - Item_AreaCopy(107, 76, 156, 86, TEMP_CASE_PLA); // "Preheat" - say_pla_en(52, TEMP_CASE_PLA); // "PLA" - Item_AreaCopy(150, 135, 202, 148, TEMP_CASE_PLA, 79); // "Settings" - - Item_AreaCopy(107, 76, 156, 86, TEMP_CASE_ABS); // "Preheat" - say_abs_en(52, TEMP_CASE_ABS); // "ABS" - Item_AreaCopy(150, 135, 202, 148, TEMP_CASE_ABS, 81); // "Settings" + #if HAS_PREHEAT + Item_AreaCopy(107, 76, 156, 86, TEMP_CASE_PLA); // "Preheat" + say_pla_en(52, TEMP_CASE_PLA); // "PLA" + Item_AreaCopy(150, 135, 202, 148, TEMP_CASE_PLA, 79); // "Settings" + #if PREHEAT_COUNT > 1 + Item_AreaCopy(107, 76, 156, 86, TEMP_CASE_ABS); // "Preheat" + say_abs_en(52, TEMP_CASE_ABS); // "ABS" + Item_AreaCopy(150, 135, 202, 148, TEMP_CASE_ABS, 81); // "Settings" + #endif #endif #endif } @@ -2843,12 +2860,12 @@ void Draw_Temperature_Menu() { _TMENU_ICON(TEMP_CASE_FAN); Draw_Edit_Integer3(i, thermalManager.fan_speed[0]); #endif - #if HAS_HOTEND + #if HAS_PREHEAT // PLA/ABS items have submenus - _TMENU_ICON(TEMP_CASE_PLA); - Draw_More_Icon(i); - _TMENU_ICON(TEMP_CASE_ABS); - Draw_More_Icon(i); + _TMENU_ICON(TEMP_CASE_PLA); Draw_More_Icon(i); + #if PREHEAT_COUNT > 1 + _TMENU_ICON(TEMP_CASE_ABS); Draw_More_Icon(i); + #endif #endif } @@ -3068,7 +3085,8 @@ void HMI_Temperature() { EncoderRate.enabled = true; break; #endif - #if HAS_HOTEND + + #if HAS_PREHEAT case TEMP_CASE_PLA: { checkkey = PLAPreheat; select_PLA.reset(); @@ -3145,7 +3163,9 @@ void HMI_Temperature() { Draw_Menu_Line(++i, ICON_WriteEEPROM); #endif } break; + #endif // HAS_PREHEAT + #if PREHEAT_COUNT > 1 case TEMP_CASE_ABS: { // ABS preheat setting checkkey = ABSPreheat; select_ABS.reset(); @@ -3227,7 +3247,7 @@ void HMI_Temperature() { } break; - #endif // HAS_HOTEND + #endif // PREHEAT_COUNT > 1 } } DWIN_UpdateLCD(); @@ -3570,14 +3590,12 @@ void HMI_AdvSet() { #if HAS_HOTEND case ADVSET_CASE_HEPID: - thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0); thermalManager.PID_autotune(ui.material_preset[0].hotend_temp, H_E0, 10, true); break; #endif #if HAS_HEATED_BED case ADVSET_CASE_BEDPID: - thermalManager.setTargetBed(ui.material_preset[0].bed_temp); thermalManager.PID_autotune(ui.material_preset[0].bed_temp, H_BED, 10, true); break; #endif @@ -3872,63 +3890,65 @@ void HMI_Tune() { DWIN_UpdateLCD(); } - // ABS Preheat - void HMI_ABSPreheatSetting() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; + #if PREHEAT_COUNT > 1 + // ABS Preheat + void HMI_ABSPreheatSetting() { + EncoderState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; - // Avoid flicker by updating only the previous menu - if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_ABS.inc(1 + PREHEAT_CASE_TOTAL)) Move_Highlight(1, select_ABS.now); - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - if (select_ABS.dec()) Move_Highlight(-1, select_ABS.now); - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - switch (select_ABS.now) { - case CASE_BACK: - checkkey = TemperatureID; - select_temp.now = TEMP_CASE_ABS; - HMI_ValueStruct.show_mode = -1; - Draw_Temperature_Menu(); - break; - #if HAS_HOTEND - case PREHEAT_CASE_TEMP: - checkkey = ETemp; - HMI_ValueStruct.E_Temp = ui.material_preset[1].hotend_temp; - Draw_Edit_Integer3(PREHEAT_CASE_TEMP, ui.material_preset[1].hotend_temp, true); - EncoderRate.enabled = true; - break; - #endif - #if HAS_HEATED_BED - case PREHEAT_CASE_BED: - checkkey = BedTemp; - HMI_ValueStruct.Bed_Temp = ui.material_preset[1].bed_temp; - Draw_Edit_Integer3(PREHEAT_CASE_BED, ui.material_preset[1].bed_temp, true); - EncoderRate.enabled = true; - break; - #endif - #if HAS_FAN - case PREHEAT_CASE_FAN: - checkkey = FanSpeed; - HMI_ValueStruct.Fan_speed = ui.material_preset[1].fan_speed; - Draw_Edit_Integer3(PREHEAT_CASE_FAN, ui.material_preset[1].fan_speed, true); - EncoderRate.enabled = true; - break; - #endif - #if ENABLED(EEPROM_SETTINGS) - case PREHEAT_CASE_SAVE: { - const bool success = settings.save(); - HMI_AudioFeedback(success); - } break; - #endif - default: break; + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_ABS.inc(1 + PREHEAT_CASE_TOTAL)) Move_Highlight(1, select_ABS.now); } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_ABS.dec()) Move_Highlight(-1, select_ABS.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_ABS.now) { + case CASE_BACK: + checkkey = TemperatureID; + select_temp.now = TEMP_CASE_ABS; + HMI_ValueStruct.show_mode = -1; + Draw_Temperature_Menu(); + break; + #if HAS_HOTEND + case PREHEAT_CASE_TEMP: + checkkey = ETemp; + HMI_ValueStruct.E_Temp = ui.material_preset[1].hotend_temp; + Draw_Edit_Integer3(PREHEAT_CASE_TEMP, ui.material_preset[1].hotend_temp, true); + EncoderRate.enabled = true; + break; + #endif + #if HAS_HEATED_BED + case PREHEAT_CASE_BED: + checkkey = BedTemp; + HMI_ValueStruct.Bed_Temp = ui.material_preset[1].bed_temp; + Draw_Edit_Integer3(PREHEAT_CASE_BED, ui.material_preset[1].bed_temp, true); + EncoderRate.enabled = true; + break; + #endif + #if HAS_FAN + case PREHEAT_CASE_FAN: + checkkey = FanSpeed; + HMI_ValueStruct.Fan_speed = ui.material_preset[1].fan_speed; + Draw_Edit_Integer3(PREHEAT_CASE_FAN, ui.material_preset[1].fan_speed, true); + EncoderRate.enabled = true; + break; + #endif + #if ENABLED(EEPROM_SETTINGS) + case PREHEAT_CASE_SAVE: { + const bool success = settings.save(); + HMI_AudioFeedback(success); + } break; + #endif + default: break; + } + } + DWIN_UpdateLCD(); } - DWIN_UpdateLCD(); - } + #endif // PREHEAT_COUNT > 1 -#endif +#endif // HAS_PREHEAT // Max Speed void HMI_MaxSpeed() { @@ -4232,7 +4252,9 @@ void DWIN_HandleScreen() { case Tune: HMI_Tune(); break; #if HAS_PREHEAT case PLAPreheat: HMI_PLAPreheatSetting(); break; - case ABSPreheat: HMI_ABSPreheatSetting(); break; + #if PREHEAT_COUNT > 1 + case ABSPreheat: HMI_ABSPreheatSetting(); break; + #endif #endif case MaxSpeed: HMI_MaxSpeed(); break; case MaxAcceleration: HMI_MaxAcceleration(); break; diff --git a/Marlin/src/lcd/e3v2/creality/dwin.h b/Marlin/src/lcd/e3v2/creality/dwin.h index d9ac0aa5fa..3122a6fcba 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.h +++ b/Marlin/src/lcd/e3v2/creality/dwin.h @@ -31,13 +31,6 @@ #include "../../../inc/MarlinConfigPre.h" -#if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) && PREHEAT_COUNT - #define HAS_PREHEAT 1 - #if PREHEAT_COUNT < 2 - #error "Creality DWIN requires two material preheat presets." - #endif -#endif - enum processID : uint8_t { // Process ID MainMenu, @@ -53,7 +46,9 @@ enum processID : uint8_t { Tune, #if HAS_PREHEAT PLAPreheat, - ABSPreheat, + #if PREHEAT_COUNT > 1 + ABSPreheat, + #endif #endif MaxSpeed, MaxSpeed_value, diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp b/Marlin/src/lcd/e3v2/enhanced/dwin.cpp index b861b0274a..787cf717eb 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp +++ b/Marlin/src/lcd/e3v2/enhanced/dwin.cpp @@ -1787,8 +1787,7 @@ void DWIN_Print_Started(const bool sd) { // Ended print job void DWIN_Print_Finished() { if (checkkey == PrintProcess || printingIsActive()) { - thermalManager.disable_all_heaters(); - thermalManager.zero_fan_speeds(); + thermalManager.cooldown(); HMI_flag.print_finish = true; } } @@ -2116,23 +2115,13 @@ void SetHome() { #endif #if HAS_PREHEAT - void SetPreheat(const uint8_t i) { - TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[i].hotend_temp, 0)); - TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(ui.material_preset[i].bed_temp)); - TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[i].fan_speed)); - } - void SetPreheat0() { SetPreheat(0); } - void SetPreheat1() { SetPreheat(1); } - void SetPreheat2() { SetPreheat(2); } - - void SetCoolDown() { - TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); - #if HAS_HOTEND || HAS_HEATED_BED - thermalManager.disable_all_heaters(); - #endif - } + void DoPreheat0() { ui.preheat_all(0); } + void DoPreheat1() { ui.preheat_all(1); } + void DoPreheat2() { ui.preheat_all(2); } #endif +void DoCoolDown() { thermalManager.cooldown(); } + void SetLanguage() { HMI_ToggleLanguage(); CurrentMenu = nullptr; // Invalidate menu to full redraw @@ -3124,14 +3113,16 @@ void Draw_Prepare_Menu() { ADDMENUITEM(ICON_SetHome, GET_TEXT_F(MSG_SET_HOME_OFFSETS), onDrawHomeOffset, SetHome); #endif #endif - #if HAS_HOTEND - ADDMENUITEM(ICON_PLAPreheat, GET_TEXT_F(MSG_PREHEAT_1), onDrawPreheat1, SetPreheat0); - ADDMENUITEM(ICON_ABSPreheat, PSTR("Preheat " PREHEAT_2_LABEL), onDrawPreheat2, SetPreheat1); - ADDMENUITEM(ICON_CustomPreheat, GET_TEXT_F(MSG_PREHEAT_CUSTOM), onDrawMenuItem, SetPreheat2); - #endif #if HAS_PREHEAT - ADDMENUITEM(ICON_Cool, GET_TEXT_F(MSG_COOLDOWN), onDrawCooldown, SetCoolDown); + ADDMENUITEM(ICON_PLAPreheat, GET_TEXT_F(MSG_PREHEAT_1), onDrawPreheat1, DoPreheat0); + #if PREHEAT_COUNT > 1 + ADDMENUITEM(ICON_ABSPreheat, PSTR("Preheat " PREHEAT_2_LABEL), onDrawPreheat2, DoPreheat1); + #endif + #if PREHEAT_COUNT > 2 + ADDMENUITEM(ICON_CustomPreheat, GET_TEXT_F(MSG_PREHEAT_CUSTOM), onDrawMenuItem, DoPreheat2); + #endif #endif + ADDMENUITEM(ICON_Cool, GET_TEXT_F(MSG_COOLDOWN), onDrawCooldown, DoCoolDown); ADDMENUITEM(ICON_Language, PSTR("UI Language"), onDrawLanguage, SetLanguage); } CurrentMenu->draw(); diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin.h b/Marlin/src/lcd/e3v2/enhanced/dwin.h index 0908417117..c2220c68a8 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin.h +++ b/Marlin/src/lcd/e3v2/enhanced/dwin.h @@ -33,13 +33,6 @@ #include "../common/encoder.h" #include "../../../libs/BL24CXX.h" -#if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) && PREHEAT_COUNT - #define HAS_PREHEAT 1 - #if PREHEAT_COUNT < 2 - #error "Creality DWIN requires two material preheat presets." - #endif -#endif - #if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) && DISABLED(PROBE_MANUALLY) #define HAS_ONESTEP_LEVELING 1 #endif @@ -123,12 +116,14 @@ typedef struct { uint16_t Barfill_Color = Def_Barfill_Color; uint16_t Indicator_Color = Def_Indicator_Color; uint16_t Coordinate_Color = Def_Coordinate_Color; - #if HAS_HOTEND - int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND; - int16_t PidCycles = 10; - #endif - #ifdef PREHEAT_1_TEMP_BED - int16_t BedPidT = PREHEAT_1_TEMP_BED; + #if HAS_PREHEAT + #ifdef PREHEAT_1_TEMP_HOTEND + int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND; + int16_t PidCycles = 10; + #endif + #ifdef PREHEAT_1_TEMP_BED + int16_t BedPidT = PREHEAT_1_TEMP_BED; + #endif #endif #if ENABLED(PREVENT_COLD_EXTRUSION) int16_t ExtMinT = EXTRUDE_MINTEMP; diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 691c03af0d..80ef88d0b2 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -76,10 +76,6 @@ #include "../../../module/probe.h" #endif -#if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) && PREHEAT_COUNT - #define HAS_PREHEAT 1 -#endif - #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../feature/powerloss.h" #endif @@ -1034,7 +1030,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define PREPARE_MANUALLEVEL (PREPARE_HOME + 1) #define PREPARE_ZOFFSET (PREPARE_MANUALLEVEL + ENABLED(HAS_ZOFFSET_ITEM)) #define PREPARE_PREHEAT (PREPARE_ZOFFSET + ENABLED(HAS_PREHEAT)) - #define PREPARE_COOLDOWN (PREPARE_PREHEAT + ENABLED(HAS_PREHEAT)) + #define PREPARE_COOLDOWN (PREPARE_PREHEAT + EITHER(HAS_HOTEND, HAS_HEATED_BED)) #define PREPARE_CHANGEFIL (PREPARE_COOLDOWN + ENABLED(ADVANCED_PAUSE_FEATURE)) #define PREPARE_TOTAL PREPARE_CHANGEFIL @@ -1100,13 +1096,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ else Draw_Menu(Preheat); break; + #endif + + #if HAS_HOTEND || HAS_HEATED_BED case PREPARE_COOLDOWN: if (draw) Draw_Menu_Item(row, ICON_Cool, F("Cooldown")); - else { - TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); - thermalManager.disable_all_heaters(); - } + else + thermalManager.cooldown(); break; #endif @@ -1588,18 +1585,24 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } break; #endif - #if HAS_PREHEAT - case Preheat: + #if HAS_PREHEAT + case Preheat: { #define PREHEAT_BACK 0 #define PREHEAT_MODE (PREHEAT_BACK + 1) - #define PREHEAT_1 (PREHEAT_MODE + (PREHEAT_COUNT >= 1)) + #define PREHEAT_1 (PREHEAT_MODE + 1) #define PREHEAT_2 (PREHEAT_1 + (PREHEAT_COUNT >= 2)) #define PREHEAT_3 (PREHEAT_2 + (PREHEAT_COUNT >= 3)) #define PREHEAT_4 (PREHEAT_3 + (PREHEAT_COUNT >= 4)) #define PREHEAT_5 (PREHEAT_4 + (PREHEAT_COUNT >= 5)) #define PREHEAT_TOTAL PREHEAT_5 + auto do_preheat = [](const uint8_t m) { + thermalManager.cooldown(); + if (preheatmode == 0 || preheatmode == 1) { ui.preheat_hotend_and_fan(m); } + if (preheatmode == 0 || preheatmode == 2) ui.preheat_bed(m); + }; + switch (item) { case PREHEAT_BACK: if (draw) @@ -1620,17 +1623,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case PREHEAT_1: if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_1_LABEL)); - else { - thermalManager.disable_all_heaters(); - TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); - if (preheatmode == 0 || preheatmode == 1) { - TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0)); - TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed)); - } - #if HAS_HEATED_BED - if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[0].bed_temp); - #endif - } + else + do_preheat(0); break; #endif @@ -1638,17 +1632,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case PREHEAT_2: if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_2_LABEL)); - else { - thermalManager.disable_all_heaters(); - TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); - if (preheatmode == 0 || preheatmode == 1) { - TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0)); - TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed)); - } - #if HAS_HEATED_BED - if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[1].bed_temp); - #endif - } + else + do_preheat(1); break; #endif @@ -1656,17 +1641,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case PREHEAT_3: if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_3_LABEL)); - else { - thermalManager.disable_all_heaters(); - TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); - if (preheatmode == 0 || preheatmode == 1) { - TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[2].hotend_temp, 0)); - TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[2].fan_speed)); - } - #if HAS_HEATED_BED - if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[2].bed_temp); - #endif - } + else + do_preheat(2); break; #endif @@ -1674,17 +1650,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case PREHEAT_4: if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_4_LABEL)); - else { - thermalManager.disable_all_heaters(); - TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); - if (preheatmode == 0 || preheatmode == 1) { - TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[3].hotend_temp, 0)); - TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[3].fan_speed)); - } - #if HAS_HEATED_BED - if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[3].bed_temp); - #endif - } + else + do_preheat(3); break; #endif @@ -1692,22 +1659,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case PREHEAT_5: if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_5_LABEL)); - else { - thermalManager.disable_all_heaters(); - TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); - if (preheatmode == 0 || preheatmode == 1) { - TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[4].hotend_temp, 0)); - TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[4].fan_speed)); - } - #if HAS_HEATED_BED - if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[4].bed_temp); - #endif - } + else + do_preheat(4); break; #endif } - break; - #endif + } break; + #endif // HAS_PREHEAT #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) case ChangeFilament: @@ -3968,50 +3926,40 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case PREHEATHOTEND_1: if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_1_LABEL)); - else { - thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0); - thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed); - } + else + ui.preheat_hotend_and_fan(0); break; #endif #if PREHEAT_COUNT >= 2 case PREHEATHOTEND_2: if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_2_LABEL)); - else { - thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0); - thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed); - } + else + ui.preheat_hotend_and_fan(1); break; #endif #if PREHEAT_COUNT >= 3 case PREHEATHOTEND_3: if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_3_LABEL)); - else { - thermalManager.setTargetHotend(ui.material_preset[2].hotend_temp, 0); - thermalManager.set_fan_speed(0, ui.material_preset[2].fan_speed); - } + else + ui.preheat_hotend_and_fan(2); break; #endif #if PREHEAT_COUNT >= 4 case PREHEATHOTEND_4: if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_4_LABEL)); - else { - thermalManager.setTargetHotend(ui.material_preset[3].hotend_temp, 0); - thermalManager.set_fan_speed(0, ui.material_preset[3].fan_speed); - } + else + ui.preheat_hotend_and_fan(3); break; #endif #if PREHEAT_COUNT >= 5 case PREHEATHOTEND_5: if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_5_LABEL)); - else { - thermalManager.setTargetHotend(ui.material_preset[4].hotend_temp, 0); - thermalManager.set_fan_speed(0, ui.material_preset[4].fan_speed); - } + else + ui.preheat_hotend_and_fan(4); break; #endif case PREHEATHOTEND_CUSTOM: @@ -4548,8 +4496,7 @@ void CrealityDWINClass::Popup_Control() { TERN_(HAS_HOTEND, pausetemp = thermalManager.temp_hotend[0].target); TERN_(HAS_HEATED_BED, pausebed = thermalManager.temp_bed.target); TERN_(HAS_FAN, pausefan = thermalManager.fan_speed[0]); - thermalManager.disable_all_heaters(); - TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); + thermalManager.cooldown(); #endif } else { @@ -4562,8 +4509,7 @@ void CrealityDWINClass::Popup_Control() { if (selection == 0) { if (sdprint) { ui.abort_print(); - TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); - thermalManager.disable_all_heaters(); + thermalManager.cooldown(); } else { TERN_(HOST_ACTION_COMMANDS, hostui.cancel()); @@ -4793,8 +4739,7 @@ void CrealityDWINClass::Start_Print(bool sd) { void CrealityDWINClass::Stop_Print() { printing = false; sdprint = false; - TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); - thermalManager.disable_all_heaters(); + thermalManager.cooldown(); TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(100 * (PROGRESS_SCALE))); TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0)); Draw_Print_confirm(); diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index 703db2ee45..306e9044f7 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -132,20 +132,19 @@ FORCE_INLINE void _draw_fan_status(const uint16_t x, const uint16_t y) { } } -#if HOTENDS > 2 - #define HOTEND_STATS 3 -#elif HOTENDS > 1 - #define HOTEND_STATS 2 -#elif HAS_HOTEND - #define HOTEND_STATS 1 -#endif - /** * Draw a single heater icon with current and target temperature, at the given XY */ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x, const uint16_t y) { #if HAS_HOTEND + #if HOTENDS > 2 + #define HOTEND_STATS 3 + #elif HOTENDS > 1 + #define HOTEND_STATS 2 + #elif HAS_HOTEND + #define HOTEND_STATS 1 + #endif static celsius_t old_temp[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500), old_target[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500); static bool old_on[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, false); diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp index c9e7268f04..2b00fd16f8 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp @@ -185,7 +185,7 @@ void DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var) { case VP_E0_PID_I: valuesend = unscalePID_i(value); break; case VP_E0_PID_D: valuesend = unscalePID_d(value); break; #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND case VP_E1_PID_P: valuesend = value; break; case VP_E1_PID_I: valuesend = unscalePID_i(value); break; case VP_E1_PID_D: valuesend = unscalePID_d(value); break; @@ -400,7 +400,7 @@ void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *va acceptedvalue = thermalManager.degTargetHotend(0); break; #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND case VP_T_E1_Set: NOMORE(newvalue, HEATER_1_MAXTEMP); thermalManager.setTargetHotend(newvalue, 1); @@ -551,7 +551,7 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo sprintf_P(buf, PSTR("M303 E%d C5 S210 U1"), ExtUI::extruder_t::E0); break; #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND case VP_PID_AUTOTUNE_E1: sprintf_P(buf, PSTR("M303 E%d C5 S210 U1"), ExtUI::extruder_t::E1); break; @@ -598,7 +598,7 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr switch (var.VP) { #if HAS_HOTEND case VP_E0_CONTROL: - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND case VP_E1_CONTROL: #if HOTENDS >= 3 case VP_E2_CONTROL: @@ -621,55 +621,16 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr void DGUSScreenHandler::HandlePreheat(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandlePreheat"); - uint8_t e_temp = 0; - #if HAS_HEATED_BED - uint8_t bed_temp = 0; - #endif const uint16_t preheat_option = swap16(*(uint16_t*)val_ptr); switch (preheat_option) { default: - case 0: // Preheat PLA - #if defined(PREHEAT_1_TEMP_HOTEND) && defined(PREHEAT_1_TEMP_BED) - e_temp = PREHEAT_1_TEMP_HOTEND; - TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_1_TEMP_BED); - #endif - break; - case 1: // Preheat ABS - #if defined(PREHEAT_2_TEMP_HOTEND) && defined(PREHEAT_2_TEMP_BED) - e_temp = PREHEAT_2_TEMP_HOTEND; - TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_2_TEMP_BED); - #endif - break; - case 2: // Preheat PET - #if defined(PREHEAT_3_TEMP_HOTEND) && defined(PREHEAT_3_TEMP_BED) - e_temp = PREHEAT_3_TEMP_HOTEND; - TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_3_TEMP_BED); - #endif - break; - case 3: // Preheat FLEX - #if defined(PREHEAT_4_TEMP_HOTEND) && defined(PREHEAT_4_TEMP_BED) - e_temp = PREHEAT_4_TEMP_HOTEND; - TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_4_TEMP_BED); - #endif - break; + switch (var.VP) { + default: return; + case VP_E0_BED_PREHEAT: TERN_(HAS_HOTEND, ui.preheat_all(0)); break; + case VP_E1_BED_PREHEAT: TERN_(HAS_MULTI_HOTEND, ui.preheat_all(1)); break; + } case 7: break; // Custom preheat - case 9: break; // Cool down - } - - switch (var.VP) { - default: return; - #if HAS_HOTEND - case VP_E0_BED_PREHEAT: - thermalManager.setTargetHotend(e_temp, 0); - TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp)); - break; - #endif - #if HOTENDS >= 2 - case VP_E1_BED_PREHEAT: - thermalManager.setTargetHotend(e_temp, 1); - TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp)); - break; - #endif + case 9: thermalManager.cooldown(); break; // Cool down } // Go to the preheat screen to show the heating progress diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp index d73a7ea552..a4c0997bf8 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp @@ -51,7 +51,7 @@ const uint16_t VPList_Main[] PROGMEM = { #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, VP_E0_STATUS, #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #if HAS_HEATED_BED @@ -73,7 +73,7 @@ const uint16_t VPList_Temp[] PROGMEM = { #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #if HAS_HEATED_BED @@ -87,7 +87,7 @@ const uint16_t VPList_Status[] PROGMEM = { #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #if HAS_HEATED_BED @@ -120,7 +120,7 @@ const uint16_t VPList_Preheat[] PROGMEM = { #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #if HAS_HEATED_BED @@ -187,7 +187,7 @@ const uint16_t VPList_SD_PrintManipulation[] PROGMEM = { #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #if HAS_HEATED_BED @@ -379,7 +379,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, ScreenHandler.HandleFilamentOption, ScreenHandler.HandleFilamentLoadUnload), #endif #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), // ERROR: Flow is per-extruder, not per-hotend diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp index 2f08136cbb..750acece1c 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp @@ -256,7 +256,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { case VP_E0_PID_I: newvalue = scalePID_i(value); break; case VP_E0_PID_D: newvalue = scalePID_d(value); break; #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND case VP_E1_PID_P: newvalue = value; break; case VP_E1_PID_I: newvalue = scalePID_i(value); break; case VP_E1_PID_D: newvalue = scalePID_d(value); break; @@ -334,7 +334,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { #if HAS_HOTEND thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0); #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1); #endif GotoScreen(DGUSLCD_SCREEN_UTILITY); diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp index bdcff47ae8..f3f361f84e 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp @@ -50,7 +50,7 @@ const uint16_t VPList_Main[] PROGMEM = { // VP_M117, for completeness, but it cannot be auto-uploaded. #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, VP_E0_STATUS, - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #endif @@ -72,7 +72,7 @@ const uint16_t VPList_Main[] PROGMEM = { const uint16_t VPList_Temp[] PROGMEM = { #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #endif @@ -86,7 +86,7 @@ const uint16_t VPList_Status[] PROGMEM = { // VP_M117, for completeness, but it cannot be auto-uploaded #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #endif @@ -107,7 +107,7 @@ const uint16_t VPList_Status2[] PROGMEM = { // VP_M117, for completeness, but it cannot be auto-uploaded #if HAS_HOTEND VP_Flowrate_E0, - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_Flowrate_E1, #endif #endif @@ -119,7 +119,7 @@ const uint16_t VPList_Status2[] PROGMEM = { const uint16_t VPList_Preheat[] PROGMEM = { #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #endif @@ -137,7 +137,7 @@ const uint16_t VPList_ManualMove[] PROGMEM = { const uint16_t VPList_ManualExtrude[] PROGMEM = { #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #endif @@ -159,7 +159,7 @@ const uint16_t VPList_Filament_heating[] PROGMEM = { #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, VP_E0_FILAMENT_LOAD_UNLOAD, - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #endif @@ -169,7 +169,7 @@ const uint16_t VPList_Filament_heating[] PROGMEM = { const uint16_t VPList_Filament_load_unload[] PROGMEM = { #if HAS_HOTEND VP_E0_FILAMENT_LOAD_UNLOAD, - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_E1_FILAMENT_LOAD_UNLOAD, #endif #endif @@ -185,7 +185,7 @@ const uint16_t VPList_SD_PrintManipulation[] PROGMEM = { VP_PrintProgress_Percentage, VP_PrintTime, #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #endif @@ -205,7 +205,7 @@ const uint16_t VPList_SD_PrintManipulation[] PROGMEM = { const uint16_t VPList_SDPrintTune[] PROGMEM = { #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #endif @@ -222,23 +222,17 @@ const uint16_t VPList_SDPrintTune[] PROGMEM = { }; const uint16_t VPList_StepPerMM[] PROGMEM = { - VP_X_STEP_PER_MM, - VP_Y_STEP_PER_MM, - VP_Z_STEP_PER_MM, - #if HAS_HOTEND - VP_E0_STEP_PER_MM, - #if HOTENDS >= 2 - VP_E1_STEP_PER_MM, - #endif - #endif - 0x0000 + VP_X_STEP_PER_MM + , VP_Y_STEP_PER_MM + , VP_Z_STEP_PER_MM + OPTARG(HAS_HOTEND, VP_E0_STEP_PER_MM) + OPTARG(HAS_MULTI_HOTEND, VP_E1_STEP_PER_MM) + , 0x0000 }; const uint16_t VPList_PIDE0[] PROGMEM = { #if ENABLED(PIDTEMP) - VP_E0_PID_P, - VP_E0_PID_I, - VP_E0_PID_D, + VP_E0_PID_P, VP_E0_PID_I, VP_E0_PID_D, #endif 0x0000 }; @@ -382,7 +376,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, ScreenHandler.HandlePIDAutotune, nullptr), #endif #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), @@ -435,7 +429,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), #if HAS_HOTEND VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), #endif #endif diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp index f72a9f439d..79a3cb9103 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp @@ -256,7 +256,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { case VP_E0_PID_I: newvalue = scalePID_i(value); break; case VP_E0_PID_D: newvalue = scalePID_d(value); break; #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND case VP_E1_PID_P: newvalue = value; break; case VP_E1_PID_I: newvalue = scalePID_i(value); break; case VP_E1_PID_D: newvalue = scalePID_d(value); break; @@ -333,7 +333,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { if (filament_data.action == 0) { // Go back to utility screen #if HAS_HOTEND thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0); - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1); #endif #endif @@ -348,7 +348,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { thermalManager.setTargetHotend(e_temp, filament_data.extruder); break; #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND case VP_E1_FILAMENT_LOAD_UNLOAD: filament_data.extruder = ExtUI::extruder_t::E1; thermalManager.setTargetHotend(e_temp, filament_data.extruder); diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp index 9ecfb57397..ff013967c0 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp @@ -122,7 +122,7 @@ const uint16_t VPList_Main[] PROGMEM = { // VP_M117, for completeness, but it cannot be auto-uploaded. #if HAS_HOTEND MKSLIST_E_ITEM(0) VP_E0_STATUS, - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND MKSLIST_E_ITEM(1) VP_E1_STATUS, #endif #endif @@ -567,7 +567,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), @@ -656,7 +656,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #if HAS_HOTEND VPHELPER(VP_E0_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(0)], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VPHELPER(VP_E1_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), #endif #endif @@ -667,7 +667,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #if HAS_HOTEND VPHELPER(VP_E0_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(0)], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VPHELPER(VP_E1_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #endif #endif @@ -744,7 +744,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #if HAS_HOTEND VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), #endif #endif diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.cpp index 2f5e2787d6..0115d3b8c1 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.cpp @@ -57,7 +57,7 @@ const uint16_t VPList_Main[] PROGMEM = { const uint16_t VPList_Temp[] PROGMEM = { #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #endif @@ -71,7 +71,7 @@ const uint16_t VPList_Status[] PROGMEM = { // VP_M117, for completeness, but it cannot be auto-uploaded #if HAS_HOTEND VP_T_E0_Is, VP_T_E0_Set, - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_T_E1_Is, VP_T_E1_Set, #endif #endif @@ -92,7 +92,7 @@ const uint16_t VPList_Status2[] PROGMEM = { // VP_M117, for completeness, but it cannot be auto-uploaded #if HAS_HOTEND VP_Flowrate_E0, - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VP_Flowrate_E1, #endif #endif @@ -182,7 +182,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, ScreenHandler.HandleFilamentOption, ScreenHandler.HandleFilamentLoadUnload), #endif #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), @@ -237,7 +237,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), #if HAS_HOTEND VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), #endif #endif diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp index 82404ead94..b77c92b7eb 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp @@ -256,7 +256,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { case VP_E0_PID_I: newvalue = scalePID_i(value); break; case VP_E0_PID_D: newvalue = scalePID_d(value); break; #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND case VP_E1_PID_P: newvalue = value; break; case VP_E1_PID_I: newvalue = scalePID_i(value); break; case VP_E1_PID_D: newvalue = scalePID_d(value); break; @@ -333,7 +333,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { if (filament_data.action == 0) { // Go back to utility screen #if HAS_HOTEND thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0); - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1); #endif #endif @@ -348,7 +348,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { thermalManager.setTargetHotend(e_temp, filament_data.extruder); break; #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND case VP_E1_FILAMENT_LOAD_UNLOAD: filament_data.extruder = ExtUI::extruder_t::E1; thermalManager.setTargetHotend(e_temp, filament_data.extruder); diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp index f0844dc785..cf95bb1d76 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp @@ -327,7 +327,7 @@ void DGUSRxHandler::TempTarget(DGUS_VP &vp, void *data_ptr) { case DGUS_Addr::TEMP_SetTarget_H0: ExtUI::setTargetTemp_celsius(temp, ExtUI::H0); break; - #if HOTENDS > 1 + #if HAS_MULTI_HOTEND case DGUS_Addr::TEMP_SetTarget_H1: ExtUI::setTargetTemp_celsius(temp, ExtUI::H1); break; @@ -347,7 +347,7 @@ void DGUSRxHandler::TempCool(DGUS_VP &vp, void *data_ptr) { case DGUS_Data::Heater::ALL: ExtUI::setTargetTemp_celsius(0, ExtUI::BED); ExtUI::setTargetTemp_celsius(0, ExtUI::H0); - #if HOTENDS > 1 + #if HAS_MULTI_HOTEND ExtUI::setTargetTemp_celsius(0, ExtUI::H1); #endif break; @@ -357,7 +357,7 @@ void DGUSRxHandler::TempCool(DGUS_VP &vp, void *data_ptr) { case DGUS_Data::Heater::H0: ExtUI::setTargetTemp_celsius(0, ExtUI::H0); break; - #if HOTENDS > 1 + #if HAS_MULTI_HOTEND case DGUS_Data::Heater::H1: ExtUI::setTargetTemp_celsius(0, ExtUI::H1); break; @@ -827,7 +827,7 @@ void DGUSRxHandler::PIDSelect(DGUS_VP &vp, void *data_ptr) { dgus_screen_handler.pid_heater = heater; break; case DGUS_Data::Heater::H0: - #if HOTENDS > 1 + #if HAS_MULTI_HOTEND case DGUS_Data::Heater::H1: #endif dgus_screen_handler.pid_temp = DGUS_PLA_TEMP_HOTEND; @@ -858,7 +858,7 @@ void DGUSRxHandler::PIDSetTemp(DGUS_VP &vp, void *data_ptr) { case DGUS_Data::Heater::H0: temp = constrain(temp, HEATER_0_MINTEMP, (HEATER_0_MAXTEMP - HOTEND_OVERSHOOT)); break; - #if HOTENDS > 1 + #if HAS_MULTI_HOTEND case DGUS_Data::Heater::H1: temp = constrain(temp, HEATER_1_MINTEMP, (HEATER_1_MAXTEMP - HOTEND_OVERSHOOT)); break; @@ -900,7 +900,7 @@ void DGUSRxHandler::PIDRun(DGUS_VP &vp, void *data_ptr) { dgus_screen_handler.SetStatusMessage(F("PID disabled")); return; #endif - #if HOTENDS > 1 + #if HAS_MULTI_HOTEND case DGUS_Data::Heater::H1: #if ENABLED(PIDTEMP) heater = H_E1; diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp index 3fc48d2ebb..8d57038765 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp @@ -275,7 +275,7 @@ void DGUSTxHandler::TempMax(DGUS_VP &vp) { case DGUS_Addr::TEMP_Max_H0: temp = HEATER_0_MAXTEMP - HOTEND_OVERSHOOT; break; - #if HOTENDS > 1 + #if HAS_MULTI_HOTEND case DGUS_Addr::TEMP_Max_H1: temp = HEATER_1_MAXTEMP - HOTEND_OVERSHOOT; break; @@ -428,7 +428,7 @@ void DGUSTxHandler::PIDKp(DGUS_VP &vp) { case DGUS_Data::Heater::H0: value = ExtUI::getPIDValues_Kp(ExtUI::E0); break; - #if HOTENDS > 1 + #if HAS_MULTI_HOTEND case DGUS_Data::Heater::H1: value = ExtUI::getPIDValues_Kp(ExtUI::E1); break; @@ -454,7 +454,7 @@ void DGUSTxHandler::PIDKi(DGUS_VP &vp) { case DGUS_Data::Heater::H0: value = ExtUI::getPIDValues_Ki(ExtUI::E0); break; - #if HOTENDS > 1 + #if HAS_MULTI_HOTEND case DGUS_Data::Heater::H1: value = ExtUI::getPIDValues_Ki(ExtUI::E1); break; @@ -480,7 +480,7 @@ void DGUSTxHandler::PIDKd(DGUS_VP &vp) { case DGUS_Data::Heater::H0: value = ExtUI::getPIDValues_Kd(ExtUI::E0); break; - #if HOTENDS > 1 + #if HAS_MULTI_HOTEND case DGUS_Data::Heater::H1: value = ExtUI::getPIDValues_Kd(ExtUI::E1); break; diff --git a/Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Addr.h b/Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Addr.h index 4207119c87..39e97156d0 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Addr.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Addr.h @@ -64,7 +64,7 @@ enum class DGUS_Addr : uint16_t { TEMP_Preset = 0x2010, // Popup / Data: DGUS_Data::TempPreset TEMP_SetTarget_Bed = 0x2011, // Type: Integer (16 bits signed) TEMP_SetTarget_H0 = 0x2012, // Type: Integer (16 bits signed) - #if HOTENDS > 1 + #if HAS_MULTI_HOTEND TEMP_SetTarget_H1 = 0x2013, // Type: Integer (16 bits signed) #endif TEMP_Cool = 0x2014, // Data: DGUS_Data::Heater @@ -123,7 +123,7 @@ enum class DGUS_Addr : uint16_t { TEMP_Current_H0 = 0x30FF, // Type: Integer (16 bits signed) TEMP_Target_H0 = 0x3100, // Type: Integer (16 bits signed) TEMP_Max_H0 = 0x3101, // Type: Integer (16 bits unsigned) - #if HOTENDS > 1 + #if HAS_MULTI_HOTEND TEMP_Current_H1 = 0x3102, // Type: Integer (16 bits signed) TEMP_Target_H1 = 0x3103, // Type: Integer (16 bits signed) TEMP_Max_H1 = 0x3104, // Type: Integer (16 bits unsigned) diff --git a/Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_VPList.cpp b/Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_VPList.cpp index 27b6d9036c..e77aa45011 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_VPList.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_VPList.cpp @@ -102,7 +102,7 @@ const struct DGUS_VP vp_list[] PROGMEM = { VP_HELPER_RX(DGUS_Addr::TEMP_Preset, &DGUSRxHandler::TempPreset), VP_HELPER_RX(DGUS_Addr::TEMP_SetTarget_Bed, &DGUSRxHandler::TempTarget), VP_HELPER_RX(DGUS_Addr::TEMP_SetTarget_H0, &DGUSRxHandler::TempTarget), - #if HOTENDS > 1 + #if HAS_MULTI_HOTEND VP_HELPER_RX(DGUS_Addr::TEMP_SetTarget_H1, &DGUSRxHandler::TempTarget), #endif VP_HELPER_RX(DGUS_Addr::TEMP_Cool, &DGUSRxHandler::TempCool), @@ -217,7 +217,7 @@ const struct DGUS_VP vp_list[] PROGMEM = { &thermalManager.temp_hotend[ExtUI::heater_t::H0].target, &DGUSTxHandler::ExtraToInteger), VP_HELPER_TX(DGUS_Addr::TEMP_Max_H0, &DGUSTxHandler::TempMax), - #if HOTENDS > 1 + #if HAS_MULTI_HOTEND VP_HELPER_TX_AUTO(DGUS_Addr::TEMP_Current_H1, &thermalManager.temp_hotend[ExtUI::heater_t::H1].celsius, &DGUSTxHandler::ExtraToInteger), diff --git a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp index 99211a220c..2c1bde245c 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp @@ -335,7 +335,7 @@ void NextionTFT::PanelInfo(uint8_t req) { break; case 29: // Preheat - #if PREHEAT_COUNT + #if HAS_PREHEAT if (!isPrinting()) { // Preheat PLA if (nextion_command[4] == 'P') { @@ -560,7 +560,7 @@ void NextionTFT::PanelAction(uint8_t req) { break; case 63: // Preheat // Temps defined in configuration.h - #if PREHEAT_COUNT + #if HAS_PREHEAT if (!isPrinting()) switch (nextion_command[4]) { // Preheat PLA case 'P': diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 72dab6f35e..54e7db55c2 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -705,7 +705,7 @@ namespace ExtUI { uint8_t getIDEX_Mode() { return dual_x_carriage_mode; } #endif - #if PREHEAT_COUNT + #if HAS_PREHEAT uint16_t getMaterial_preset_E(const uint16_t index) { return ui.material_preset[index].hotend_temp; } #if HAS_HEATED_BED uint16_t getMaterial_preset_B(const uint16_t index) { return ui.material_preset[index].bed_temp; } @@ -1034,13 +1034,7 @@ namespace ExtUI { void setFeedrate_percent(const_float_t value) { feedrate_percentage = constrain(value, 10, 500); } - void coolDown() { - #if HAS_HOTEND - HOTEND_LOOP() thermalManager.setTargetHotend(0, e); - #endif - TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(0)); - TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); - } + void coolDown() { thermalManager.cooldown(); } bool awaitingUserConfirm() { return TERN0(HAS_RESUME_CONTINUE, wait_for_user) || getHostKeepaliveIsPaused(); diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 7e899221ad..04a298ba58 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -148,7 +148,7 @@ namespace ExtUI { uint32_t getProgress_seconds_elapsed(); - #if PREHEAT_COUNT + #if HAS_PREHEAT uint16_t getMaterial_preset_E(const uint16_t); #if HAS_HEATED_BED uint16_t getMaterial_preset_B(const uint16_t); diff --git a/Marlin/src/lcd/language/language_an.h b/Marlin/src/lcd/language/language_an.h index 4669f0c233..8e4ff0e95c 100644 --- a/Marlin/src/lcd/language/language_an.h +++ b/Marlin/src/lcd/language/language_an.h @@ -56,7 +56,7 @@ namespace Language_an { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Achustar desfases"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Desfase aplicau"); LSTR MSG_SET_ORIGIN = _UxGT("Establir orichen"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Precalentar ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Precalentar ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Precal. ") PREHEAT_1_LABEL _UxGT(" Boquilla"); diff --git a/Marlin/src/lcd/language/language_bg.h b/Marlin/src/lcd/language/language_bg.h index 3d332ca058..05209f7718 100644 --- a/Marlin/src/lcd/language/language_bg.h +++ b/Marlin/src/lcd/language/language_bg.h @@ -45,7 +45,7 @@ namespace Language_bg { LSTR MSG_AUTO_HOME = _UxGT("Паркиране"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Задай Начало"); LSTR MSG_SET_ORIGIN = _UxGT("Изходна точка"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Подгряване ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Подгряване ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Подгряване ") PREHEAT_1_LABEL _UxGT(" Дюза"); diff --git a/Marlin/src/lcd/language/language_ca.h b/Marlin/src/lcd/language/language_ca.h index c8f0d26a32..6fba76a552 100644 --- a/Marlin/src/lcd/language/language_ca.h +++ b/Marlin/src/lcd/language/language_ca.h @@ -54,7 +54,7 @@ namespace Language_ca { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Ajusta decalatge"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Decalatge aplicat"); LSTR MSG_SET_ORIGIN = _UxGT("Estableix origen"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Preescalfa ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Preescalfa ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Preescalfa ") PREHEAT_1_LABEL _UxGT(" End"); diff --git a/Marlin/src/lcd/language/language_cz.h b/Marlin/src/lcd/language/language_cz.h index fd064b0834..596591e0f6 100644 --- a/Marlin/src/lcd/language/language_cz.h +++ b/Marlin/src/lcd/language/language_cz.h @@ -78,7 +78,7 @@ namespace Language_cz { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Nastavit ofsety"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Ofsety nastaveny"); LSTR MSG_SET_ORIGIN = _UxGT("Nastavit počátek"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Zahřát ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Zahřát ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Zahřát ") PREHEAT_1_LABEL _UxGT(" end"); @@ -153,7 +153,7 @@ namespace Language_cz { LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Konec úprav sítě"); LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Vlastní síť"); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Vytvořit síť"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_UBL_BUILD_MESH_M = _UxGT("Síť bodů $"); LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("Kontrola sítě $"); #endif diff --git a/Marlin/src/lcd/language/language_da.h b/Marlin/src/lcd/language/language_da.h index ef11906ed6..e032605578 100644 --- a/Marlin/src/lcd/language/language_da.h +++ b/Marlin/src/lcd/language/language_da.h @@ -48,7 +48,7 @@ namespace Language_da { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Sæt forsk. af home"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Forsk. er nu aktiv"); LSTR MSG_SET_ORIGIN = _UxGT("Sæt origin"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Forvarm ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Forvarm ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Forvarm ") PREHEAT_1_LABEL _UxGT(" end"); diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 8160ad4724..613880caa6 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -69,7 +69,7 @@ namespace Language_de { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Setze Homeversatz"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Homeversatz aktiv"); LSTR MSG_SET_ORIGIN = _UxGT("Setze Nullpunkte"); //"G92 X0 Y0 Z0" commented out in marlinui.cpp - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = PREHEAT_1_LABEL _UxGT(" Vorwärmen"); LSTR MSG_PREHEAT_1_H = PREHEAT_1_LABEL _UxGT(" Vorwärmen ~"); LSTR MSG_PREHEAT_1_END = PREHEAT_1_LABEL _UxGT(" Extr. Vorwärmen"); @@ -144,7 +144,7 @@ namespace Language_de { LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Bearbeitung beendet"); LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Eigenes Netz erst."); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Netz erstellen"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_UBL_BUILD_MESH_M = _UxGT("$ Netz erstellen"); LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("$ Netz validieren"); #endif diff --git a/Marlin/src/lcd/language/language_el.h b/Marlin/src/lcd/language/language_el.h index 21f5ca6503..3d1a79ea92 100644 --- a/Marlin/src/lcd/language/language_el.h +++ b/Marlin/src/lcd/language/language_el.h @@ -65,7 +65,7 @@ namespace Language_el { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Ορισμός μετατοπίσεων"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Εφαρμογή μετατοπίσεων"); LSTR MSG_SET_ORIGIN = _UxGT("Ορισμός προέλευσης"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Προθέρμανση ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Προθέρμανση ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Προθέρμανση ") PREHEAT_1_LABEL _UxGT(" End"); diff --git a/Marlin/src/lcd/language/language_el_gr.h b/Marlin/src/lcd/language/language_el_gr.h index 5259962f02..53e3ee3b94 100644 --- a/Marlin/src/lcd/language/language_el_gr.h +++ b/Marlin/src/lcd/language/language_el_gr.h @@ -54,7 +54,7 @@ namespace Language_el_gr { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Ορισμός βασικών μετατοπίσεων"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Εφαρμόστηκαν οι μετατοπίσεις"); LSTR MSG_SET_ORIGIN = _UxGT("Ορισμός προέλευσης"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Προθέρμανση ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Προθέρμανση ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Προθέρμανση ") PREHEAT_1_LABEL _UxGT(" End"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index c9413d3cea..9a92a7e268 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -104,7 +104,7 @@ namespace Language_en { LSTR MSG_TRAMMING_WIZARD = _UxGT("Tramming Wizard"); LSTR MSG_SELECT_ORIGIN = _UxGT("Select Origin"); LSTR MSG_LAST_VALUE_SP = _UxGT("Last value "); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Preheat ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Preheat ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Preheat ") PREHEAT_1_LABEL _UxGT(" End"); @@ -745,6 +745,8 @@ namespace Language_en { LSTR MSG_SD_CARD = _UxGT("SD Card"); LSTR MSG_USB_DISK = _UxGT("USB Disk"); + LSTR MSG_HOST_SHUTDOWN = _UxGT("Host Shutdown"); + // These strings can be the same in all languages LSTR MSG_MARLIN = _UxGT("Marlin"); LSTR MSG_SHORT_DAY = _UxGT("d"); // One character only diff --git a/Marlin/src/lcd/language/language_es.h b/Marlin/src/lcd/language/language_es.h index 62dd69b526..38f21985ec 100644 --- a/Marlin/src/lcd/language/language_es.h +++ b/Marlin/src/lcd/language/language_es.h @@ -73,7 +73,7 @@ namespace Language_es { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Ajustar desfases"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Desfase aplicada"); LSTR MSG_SET_ORIGIN = _UxGT("Establecer origen"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Precal. ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Precal. ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Precal. ") PREHEAT_1_LABEL _UxGT(" Fusor"); @@ -147,7 +147,7 @@ namespace Language_es { LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Term. edici. Mallado"); LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Crear Mallado Pers."); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Crear Mallado"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_UBL_BUILD_MESH_M = _UxGT("Crear Mallado ($)"); LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("Valid. Mall. ($)"); #endif diff --git a/Marlin/src/lcd/language/language_eu.h b/Marlin/src/lcd/language/language_eu.h index fc8f2e0f62..adc812f6ff 100644 --- a/Marlin/src/lcd/language/language_eu.h +++ b/Marlin/src/lcd/language/language_eu.h @@ -57,7 +57,7 @@ namespace Language_eu { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Etxe. offset eza."); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offsetak ezarrita"); LSTR MSG_SET_ORIGIN = _UxGT("Hasiera ipini"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Berotu ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Berotu ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Berotu ") PREHEAT_1_LABEL _UxGT(" Amaia"); @@ -100,7 +100,7 @@ namespace Language_eu { LSTR MSG_UBL_MESH_EDIT = _UxGT("Sarea editatu"); LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Sarea editatzea eginda"); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Sarea sortu"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_UBL_BUILD_MESH_M = _UxGT("$ sarea sortu"); LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("$ sarea balioetsi"); #endif diff --git a/Marlin/src/lcd/language/language_fi.h b/Marlin/src/lcd/language/language_fi.h index 075b5b2744..62f3aae807 100644 --- a/Marlin/src/lcd/language/language_fi.h +++ b/Marlin/src/lcd/language/language_fi.h @@ -44,7 +44,7 @@ namespace Language_fi { LSTR MSG_DISABLE_STEPPERS = _UxGT("Vapauta moottorit"); LSTR MSG_AUTO_HOME = _UxGT("Aja referenssiin"); LSTR MSG_SET_ORIGIN = _UxGT("Aseta origo"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Esilämmitä ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Esilämmitä ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Esilä. ") PREHEAT_1_LABEL _UxGT("Suutin"); diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index 77472e4fbb..e9c55ed401 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -82,7 +82,7 @@ namespace Language_fr { LSTR MSG_TRAMMING_WIZARD = _UxGT("Assistant Molettes"); LSTR MSG_SELECT_ORIGIN = _UxGT("Molette du lit"); // Not a selection of the origin LSTR MSG_LAST_VALUE_SP = _UxGT("Ecart origine "); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Préchauffage ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Préchauffage ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Préch. ") PREHEAT_1_LABEL _UxGT(" buse"); @@ -162,7 +162,7 @@ namespace Language_fr { LSTR MSG_UBL_FINE_TUNE_MESH = _UxGT("Réglage fin"); LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Terminer"); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Créer la grille"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_UBL_BUILD_MESH_M = _UxGT("Créer grille $"); LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("Impr. grille $"); #endif diff --git a/Marlin/src/lcd/language/language_gl.h b/Marlin/src/lcd/language/language_gl.h index 0252cf30ec..c17faa7014 100644 --- a/Marlin/src/lcd/language/language_gl.h +++ b/Marlin/src/lcd/language/language_gl.h @@ -70,7 +70,7 @@ namespace Language_gl { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Axustar Desfases"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Desfases aplicados"); LSTR MSG_SET_ORIGIN = _UxGT("Fixar orixe"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Prequentar ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Prequentar ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Preque. ") PREHEAT_1_LABEL _UxGT(" Bico"); @@ -144,7 +144,7 @@ namespace Language_gl { LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Fin Edición da Malla"); LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Crear Malla Person."); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Crear Malla"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_UBL_BUILD_MESH_M = _UxGT("Crear Malla ($)"); LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("Validar Malla ($)"); #endif diff --git a/Marlin/src/lcd/language/language_hr.h b/Marlin/src/lcd/language/language_hr.h index e828b489f6..23be8abbb1 100644 --- a/Marlin/src/lcd/language/language_hr.h +++ b/Marlin/src/lcd/language/language_hr.h @@ -54,7 +54,7 @@ namespace Language_hr { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Postavi home offsete"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offsets postavljeni"); LSTR MSG_SET_ORIGIN = _UxGT("Postavi ishodište"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Predgrij ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Predgrij ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Predgrij ") PREHEAT_1_LABEL _UxGT(" Dizna"); diff --git a/Marlin/src/lcd/language/language_hu.h b/Marlin/src/lcd/language/language_hu.h index 4028ab10cd..faa313e48a 100644 --- a/Marlin/src/lcd/language/language_hu.h +++ b/Marlin/src/lcd/language/language_hu.h @@ -89,7 +89,7 @@ namespace Language_hu { LSTR MSG_TRAMMING_WIZARD = _UxGT("Elektromos varázsló"); LSTR MSG_SELECT_ORIGIN = _UxGT("Eredeti választása"); LSTR MSG_LAST_VALUE_SP = _UxGT("Utolsó érték "); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Fütés ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Fütés ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Fütés ") PREHEAT_1_LABEL _UxGT(" Fej"); diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index 2e2529a845..44ae49b519 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -95,7 +95,7 @@ namespace Language_it { LSTR MSG_TRAMMING_WIZARD = _UxGT("Wizard Tramming"); LSTR MSG_SELECT_ORIGIN = _UxGT("Selez. origine"); LSTR MSG_LAST_VALUE_SP = _UxGT("Ultimo valore "); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Preriscalda ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Preriscalda ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Preris.") PREHEAT_1_LABEL _UxGT(" Ugello"); @@ -186,7 +186,7 @@ namespace Language_it { LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Modif.Mesh fatta"); LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Crea Mesh personal."); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Crea Mesh"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_UBL_BUILD_MESH_M = _UxGT("Crea Mesh ($)"); LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("Valida Mesh ($)"); #endif diff --git a/Marlin/src/lcd/language/language_jp_kana.h b/Marlin/src/lcd/language/language_jp_kana.h index 1d291ed3ad..16e605cc25 100644 --- a/Marlin/src/lcd/language/language_jp_kana.h +++ b/Marlin/src/lcd/language/language_jp_kana.h @@ -62,7 +62,7 @@ namespace Language_jp_kana { LSTR MSG_SET_HOME_OFFSETS = _UxGT("キジュンオフセットセッテイ"); // "Set home offsets" LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("オフセットガテキヨウサレマシタ"); // "Offsets applied" LSTR MSG_SET_ORIGIN = _UxGT("キジュンセット"); // "Set origin" - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = PREHEAT_1_LABEL _UxGT(" ヨネツ"); // "Preheat " PREHEAT_1_LABEL LSTR MSG_PREHEAT_1_H = PREHEAT_1_LABEL _UxGT(" ヨネツ ~"); // "Preheat " PREHEAT_1_LABEL LSTR MSG_PREHEAT_1_END = PREHEAT_1_LABEL _UxGT(" ヨネツノズル"); // " Nozzle" diff --git a/Marlin/src/lcd/language/language_ko_KR.h b/Marlin/src/lcd/language/language_ko_KR.h index 4ecdd5bb2d..50c73f69e9 100644 --- a/Marlin/src/lcd/language/language_ko_KR.h +++ b/Marlin/src/lcd/language/language_ko_KR.h @@ -54,7 +54,7 @@ namespace Language_ko_KR { LSTR MSG_LEVEL_BED_WAITING = _UxGT("누르면 시작합니다"); LSTR MSG_LEVEL_BED_NEXT_POINT = _UxGT("다음 Point"); LSTR MSG_LEVEL_BED_DONE = _UxGT("레벨링 완료!"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("예열하기 - ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("예열하기 - ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("예열하기 - ") PREHEAT_1_LABEL _UxGT(" 노즐"); diff --git a/Marlin/src/lcd/language/language_nl.h b/Marlin/src/lcd/language/language_nl.h index b44d09d07c..42df92b880 100644 --- a/Marlin/src/lcd/language/language_nl.h +++ b/Marlin/src/lcd/language/language_nl.h @@ -54,7 +54,7 @@ namespace Language_nl { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Zet home offsets"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("H offset toegep."); LSTR MSG_SET_ORIGIN = _UxGT("Nulpunt instellen"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = PREHEAT_1_LABEL _UxGT(" voorverwarmen"); LSTR MSG_PREHEAT_1_H = PREHEAT_1_LABEL _UxGT(" voorverw. ~"); LSTR MSG_PREHEAT_1_END = PREHEAT_1_LABEL _UxGT(" voorverw. Einde"); diff --git a/Marlin/src/lcd/language/language_pl.h b/Marlin/src/lcd/language/language_pl.h index 2dde747378..9105f58bdb 100644 --- a/Marlin/src/lcd/language/language_pl.h +++ b/Marlin/src/lcd/language/language_pl.h @@ -83,7 +83,7 @@ namespace Language_pl { LSTR MSG_SET_ORIGIN = _UxGT("Ustaw punkt zero"); LSTR MSG_SELECT_ORIGIN = _UxGT("Wybierz punkt zero"); LSTR MSG_LAST_VALUE_SP = _UxGT("Poprzednia wartość "); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Rozgrzej ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Rozgrzej ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Rozgrzej ") PREHEAT_1_LABEL _UxGT(" Dysza"); diff --git a/Marlin/src/lcd/language/language_pt.h b/Marlin/src/lcd/language/language_pt.h index 13f62f693b..524c2c97d8 100644 --- a/Marlin/src/lcd/language/language_pt.h +++ b/Marlin/src/lcd/language/language_pt.h @@ -53,7 +53,7 @@ namespace Language_pt { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Definir desvio"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offsets aplicados"); LSTR MSG_SET_ORIGIN = _UxGT("Definir origem"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Pre-aquecer ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Pre-aquecer ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Pre-aquecer ") PREHEAT_1_LABEL _UxGT(" Bico"); diff --git a/Marlin/src/lcd/language/language_pt_br.h b/Marlin/src/lcd/language/language_pt_br.h index 7d97d48336..c66f717f9d 100644 --- a/Marlin/src/lcd/language/language_pt_br.h +++ b/Marlin/src/lcd/language/language_pt_br.h @@ -68,7 +68,7 @@ namespace Language_pt_br { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Compensar origem"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Alteração aplicada"); LSTR MSG_SET_ORIGIN = _UxGT("Ajustar Origem"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Pre-aquecer ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Pre-aquecer ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Extrusora ") PREHEAT_1_LABEL; @@ -133,7 +133,7 @@ namespace Language_pt_br { LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Fim da Edição"); LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Montar Malha Custom"); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Montar "); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_UBL_BUILD_MESH_M = _UxGT("Montar $"); LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("Checar $"); #endif diff --git a/Marlin/src/lcd/language/language_ro.h b/Marlin/src/lcd/language/language_ro.h index 2eb4c0b996..fee63dc2ad 100644 --- a/Marlin/src/lcd/language/language_ro.h +++ b/Marlin/src/lcd/language/language_ro.h @@ -69,7 +69,7 @@ namespace Language_ro { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Seteaza Offseturile Acasa"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offseturi Aplicate"); LSTR MSG_SET_ORIGIN = _UxGT("Seteaza Originea"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Preincalzeste ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Preincalzeste ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Preincalzeste ") PREHEAT_1_LABEL _UxGT(" Capatul"); @@ -143,7 +143,7 @@ namespace Language_ro { LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Done Editing Mesh"); LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Build Custom Mesh"); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Build Mesh"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_UBL_BUILD_MESH_M = _UxGT("Build Mesh ($)"); LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("Validate Mesh ($)"); #endif diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index 2de45e7d8d..e33018b034 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -106,7 +106,7 @@ namespace Language_ru { #else LSTR MSG_LAST_VALUE_SP = _UxGT("Послед. знач. "); #endif - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Преднагрев ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Нагрев ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Нагрев ") PREHEAT_1_LABEL _UxGT(" сопло"); diff --git a/Marlin/src/lcd/language/language_sk.h b/Marlin/src/lcd/language/language_sk.h index 81fb9a3d01..76e7f7fbd7 100644 --- a/Marlin/src/lcd/language/language_sk.h +++ b/Marlin/src/lcd/language/language_sk.h @@ -107,7 +107,7 @@ namespace Language_sk { LSTR MSG_TRAMMING_WIZARD = _UxGT("Spriev. vyrovn."); LSTR MSG_SELECT_ORIGIN = _UxGT("Vyberte začiatok"); LSTR MSG_LAST_VALUE_SP = _UxGT("Posl. hodnota "); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Zahriať ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Zahriať ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Zahriať ") PREHEAT_1_LABEL _UxGT(" hotend"); diff --git a/Marlin/src/lcd/language/language_sv.h b/Marlin/src/lcd/language/language_sv.h index 3b4d6c24c1..cdb902aef0 100644 --- a/Marlin/src/lcd/language/language_sv.h +++ b/Marlin/src/lcd/language/language_sv.h @@ -78,7 +78,7 @@ namespace Language_sv { LSTR MSG_SELECT_ORIGIN = _UxGT("Välj Origo"); LSTR MSG_LAST_VALUE_SP = _UxGT("Senaste värde "); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Förvärmning ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Förvärmning ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Förvärmning ") PREHEAT_1_LABEL _UxGT(" Stoppa"); diff --git a/Marlin/src/lcd/language/language_tr.h b/Marlin/src/lcd/language/language_tr.h index d6f2f52a0c..4c2bbfa0dc 100644 --- a/Marlin/src/lcd/language/language_tr.h +++ b/Marlin/src/lcd/language/language_tr.h @@ -73,7 +73,7 @@ namespace Language_tr { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Ofset Ayarla"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Ofset Tamam"); LSTR MSG_SET_ORIGIN = _UxGT("Sıfır Belirle"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Ön Isınma ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Ön Isınma ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Ön Isınma ") PREHEAT_1_LABEL _UxGT(" Nozul"); @@ -146,7 +146,7 @@ namespace Language_tr { LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Mesh Düzenleme Tamam"); LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Özel Mesh Oluştur"); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Mesh Oluştur"); - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_UBL_BUILD_MESH_M = _UxGT("Mesh Oluştur ($)"); LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("Doğrulama Mesh ($)"); #endif diff --git a/Marlin/src/lcd/language/language_uk.h b/Marlin/src/lcd/language/language_uk.h index 581a501b49..afba537008 100644 --- a/Marlin/src/lcd/language/language_uk.h +++ b/Marlin/src/lcd/language/language_uk.h @@ -108,7 +108,7 @@ namespace Language_uk { #else LSTR MSG_LAST_VALUE_SP = _UxGT("Останнє знач. "); #endif - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Нагрів ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Нагрів ") PREHEAT_1_LABEL " ~"; LSTR MSG_PREHEAT_1_END = _UxGT("Нагрів ") PREHEAT_1_LABEL _UxGT(" сопло"); diff --git a/Marlin/src/lcd/language/language_vi.h b/Marlin/src/lcd/language/language_vi.h index 9a4ef464b5..ae0babbf8b 100644 --- a/Marlin/src/lcd/language/language_vi.h +++ b/Marlin/src/lcd/language/language_vi.h @@ -64,7 +64,7 @@ namespace Language_vi { LSTR MSG_SET_HOME_OFFSETS = _UxGT("Đặt bù đắp nhà"); // Set home offsets LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Bù đắp được áp dụng"); // Offsets applied LSTR MSG_SET_ORIGIN = _UxGT("Đặt nguồn gốc"); // Set origin - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Làm nóng ") PREHEAT_1_LABEL _UxGT(" trước"); // Preheat LSTR MSG_PREHEAT_1_H = _UxGT("Làm nóng ") PREHEAT_1_LABEL _UxGT(" trước ~"); // Preheat LSTR MSG_PREHEAT_1_END = _UxGT("Làm nóng ") PREHEAT_1_LABEL _UxGT(" Đầu"); @@ -126,7 +126,7 @@ namespace Language_vi { LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Chỉnh sửa xong lưới"); // Done Editing Mesh LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Xây dựng lưới tự chọn"); // Build Custom Mesh LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Xây dựng lưới"); // Build Mesh - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_UBL_BUILD_MESH_M = _UxGT("Xây dựng lưới ($)"); LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("Thẩm tra lưới ($)"); #endif diff --git a/Marlin/src/lcd/language/language_zh_CN.h b/Marlin/src/lcd/language/language_zh_CN.h index afa51689cf..d61634e431 100644 --- a/Marlin/src/lcd/language/language_zh_CN.h +++ b/Marlin/src/lcd/language/language_zh_CN.h @@ -68,7 +68,7 @@ namespace Language_zh_CN { LSTR MSG_SET_HOME_OFFSETS = _UxGT("设置原点偏移"); // "Set home offsets" LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("偏移已启用"); // "Offsets applied" LSTR MSG_SET_ORIGIN = _UxGT("设置原点"); // "Set origin" - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("预热 ") PREHEAT_1_LABEL; // "Preheat PREHEAT_2_LABEL" LSTR MSG_PREHEAT_1_H = _UxGT("预热 ") PREHEAT_1_LABEL " ~"; // "Preheat PREHEAT_2_LABEL" LSTR MSG_PREHEAT_1_END = _UxGT("预热 ") PREHEAT_1_LABEL _UxGT(" 喷嘴"); //MSG_PREHEAT_1 " " @@ -142,7 +142,7 @@ namespace Language_zh_CN { LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("完成编辑网格"); // "Done Editing Mesh" LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("创设客户网格"); // "Build Custom Mesh" LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("创设网格"); // "Build Mesh" - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_UBL_BUILD_MESH_M = _UxGT("创设 $ 网格"); // "Build PREHEAT_1_LABEL Mesh" LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("批准 $ 网格"); // "Validate PREHEAT_1_LABEL Mesh" #endif diff --git a/Marlin/src/lcd/language/language_zh_TW.h b/Marlin/src/lcd/language/language_zh_TW.h index 01b11225e3..7680721b00 100644 --- a/Marlin/src/lcd/language/language_zh_TW.h +++ b/Marlin/src/lcd/language/language_zh_TW.h @@ -66,7 +66,7 @@ namespace Language_zh_TW { LSTR MSG_SET_HOME_OFFSETS = _UxGT("設置原點偏移"); // "Set home offsets" LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("偏移已啟用"); // "Offsets applied" LSTR MSG_SET_ORIGIN = _UxGT("設置原點"); // "Set origin" - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("預熱 ") PREHEAT_1_LABEL; // "Preheat PREHEAT_1_LABEL" LSTR MSG_PREHEAT_1_H = _UxGT("預熱 ") PREHEAT_1_LABEL " ~"; // "Preheat PREHEAT_1_LABEL" LSTR MSG_PREHEAT_1_END = _UxGT("預熱 ") PREHEAT_1_LABEL _UxGT(" 噴嘴"); //MSG_PREHEAT_1 " " @@ -139,7 +139,7 @@ namespace Language_zh_TW { LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("完成編輯網格"); // "Done Editing Mesh" LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("創設客戶網格"); // "Build Custom Mesh" LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("創設網格"); // "Build Mesh" - #if PREHEAT_COUNT + #if HAS_PREHEAT LSTR MSG_UBL_BUILD_MESH_M = _UxGT("創設 $ 網格"); // "Build PREHEAT_1_LABEL Mesh" LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("批准 $ 網格"); // "Validate PREHEAT_1_LABEL Mesh" #endif diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index ae169cdab6..925e1c1618 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -134,8 +134,11 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; } #endif -#if PREHEAT_COUNT +#if HAS_PREHEAT + #include "../module/temperature.h" + preheat_t MarlinUI::material_preset[PREHEAT_COUNT]; // Initialized by settings.load() + PGM_P MarlinUI::get_preheat_label(const uint8_t m) { #define _PDEF(N) static PGMSTR(preheat_##N##_label, PREHEAT_##N##_LABEL); #define _PLBL(N) preheat_##N##_label, @@ -143,6 +146,14 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; static PGM_P const preheat_labels[PREHEAT_COUNT] PROGMEM = { REPEAT_1(PREHEAT_COUNT, _PLBL) }; return (PGM_P)pgm_read_ptr(&preheat_labels[m]); } + + void MarlinUI::apply_preheat(const uint8_t m, const uint8_t pmask, const uint8_t e/*=active_extruder*/) { + const preheat_t &pre = material_preset[m]; + TERN_(HAS_HOTEND, if (TEST(pmask, PM_HOTEND)) thermalManager.setTargetHotend(pre.hotend_temp, e)); + TERN_(HAS_HEATED_BED, if (TEST(pmask, PM_BED)) thermalManager.setTargetBed(pre.bed_temp)); + //TERN_(HAS_HEATED_CHAMBER, if (TEST(pmask, PM_CHAMBER)) thermalManager.setTargetBed(pre.chamber_temp)); + TERN_(HAS_FAN, if (TEST(pmask, PM_FAN)) thermalManager.set_fan_speed(0, pre.fan_speed)); + } #endif #if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 883850d6e0..4f797d899d 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -56,7 +56,6 @@ #if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_LCD_MENU, EXTENSIBLE_UI, HAS_DWIN_E3V2) #include "../feature/pause.h" - #include "../module/motion.h" // for active_extruder #endif #if ENABLED(DWIN_CREALITY_LCD) @@ -116,7 +115,7 @@ }; #endif -#if PREHEAT_COUNT +#if HAS_PREHEAT typedef struct { #if HAS_HOTEND celsius_t hotend_temp; @@ -497,9 +496,16 @@ public: static const char * scrolled_filename(CardReader &theCard, const uint8_t maxlen, uint8_t hash, const bool doScroll); #endif - #if PREHEAT_COUNT + #if HAS_PREHEAT + enum PreheatMask : uint8_t { PM_HOTEND = _BV(0), PM_BED = _BV(1), PM_FAN = _BV(2), PM_CHAMBER = _BV(3) }; static preheat_t material_preset[PREHEAT_COUNT]; static PGM_P get_preheat_label(const uint8_t m); + static void apply_preheat(const uint8_t m, const uint8_t pmask, const uint8_t e=active_extruder); + static inline void preheat_set_fan(const uint8_t m) { TERN_(HAS_FAN, apply_preheat(m, PM_FAN)); } + static inline void preheat_hotend(const uint8_t m, const uint8_t e=active_extruder) { TERN_(HAS_HOTEND, apply_preheat(m, PM_HOTEND)); } + static inline void preheat_hotend_and_fan(const uint8_t m, const uint8_t e=active_extruder) { preheat_hotend(m, e); preheat_set_fan(m); } + static inline void preheat_bed(const uint8_t m) { TERN_(HAS_HEATED_BED, apply_preheat(m, PM_BED)); } + static inline void preheat_all(const uint8_t m) { apply_preheat(m, 0xFF); } #endif #if SCREENS_CAN_TIME_OUT diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 79193fbef3..872b9b3840 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -213,7 +213,7 @@ static void _lcd_level_bed_corners_get_next_position() { if (!ui.should_draw()) return; MenuItem_confirm::confirm_screen( []{ queue.inject(TERN(HAS_LEVELING, F("G29N"), FPSTR(G28_STR))); ui.return_to_status(); } - , []{ ui.goto_previous_screen_no_defer(); } + , ui.goto_previous_screen_no_defer , GET_TEXT(MSG_BED_TRAMMING_IN_RANGE) , (const char*)nullptr, PSTR("?") ); diff --git a/Marlin/src/lcd/menu/menu_cancelobject.cpp b/Marlin/src/lcd/menu/menu_cancelobject.cpp index a8ced05759..f2a06ecf6a 100644 --- a/Marlin/src/lcd/menu/menu_cancelobject.cpp +++ b/Marlin/src/lcd/menu/menu_cancelobject.cpp @@ -47,7 +47,7 @@ static void lcd_cancel_object_confirm() { ui.completion_feedback(); ui.goto_previous_screen(); }, - ui.goto_previous_screen, + nullptr, GET_TEXT(MSG_CANCEL_OBJECT), item_num, PSTR("?") ); } diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 0e11cd211a..6d6b0228fb 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -64,9 +64,7 @@ void menu_advanced_settings(); static int8_t bar_percent = 0; if (ui.use_click()) { ui.goto_previous_screen(); - #if HAS_MARLINUI_HD44780 - ui.set_custom_characters(CHARSET_MENU); - #endif + TERN_(HAS_MARLINUI_HD44780, ui.set_custom_characters(CHARSET_MENU)); return; } bar_percent += (int8_t)ui.encoderPosition; @@ -79,9 +77,7 @@ void menu_advanced_settings(); void _progress_bar_test() { ui.goto_screen(progress_bar_test); - #if HAS_MARLINUI_HD44780 - ui.set_custom_characters(CHARSET_INFO); - #endif + TERN_(HAS_MARLINUI_HD44780, ui.set_custom_characters(CHARSET_INFO)); } #endif // LCD_PROGRESS_BAR_TEST @@ -310,7 +306,7 @@ void menu_advanced_settings(); #endif -#if PREHEAT_COUNT && DISABLED(SLIM_LCD_MENUS) +#if HAS_PREHEAT && DISABLED(SLIM_LCD_MENUS) void _menu_configuration_preheat_settings() { #define _MINTEMP_ITEM(N) HEATER_##N##_MINTEMP, @@ -363,8 +359,7 @@ void menu_advanced_settings(); #define _CUSTOM_ITEM_CONF_CONFIRM(N) \ SUBMENU_P(PSTR(CONFIG_MENU_ITEM_##N##_DESC), []{ \ MenuItem_confirm::confirm_screen( \ - GCODE_LAMBDA_CONF(N), \ - ui.goto_previous_screen, \ + GCODE_LAMBDA_CONF(N), nullptr, \ PSTR(CONFIG_MENU_ITEM_##N##_DESC "?") \ ); \ }) @@ -547,7 +542,7 @@ void menu_configuration() { #endif // Preheat configurations - #if PREHEAT_COUNT && DISABLED(SLIM_LCD_MENUS) + #if HAS_PREHEAT && DISABLED(SLIM_LCD_MENUS) LOOP_L_N(m, PREHEAT_COUNT) SUBMENU_N_S(m, ui.get_preheat_label(m), MSG_PREHEAT_M_SETTINGS, _menu_configuration_preheat_settings); #endif diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index 7d0d2dc72c..e7365744e9 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -90,7 +90,7 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) { START_MENU(); if (LCD_HEIGHT >= 4) STATIC_ITEM_P(change_filament_header(mode), SS_DEFAULT|SS_INVERT); BACK_ITEM(MSG_BACK); - #if PREHEAT_COUNT + #if HAS_PREHEAT LOOP_L_N(m, PREHEAT_COUNT) ACTION_ITEM_N_S(m, ui.get_preheat_label(m), MSG_PREHEAT_M, _change_filament_with_preset); #endif diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 172f9daf7a..aca10edc6a 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -58,7 +58,7 @@ #include "../../feature/password/password.h" #endif -#if ENABLED(HOST_START_MENU_ITEM) && defined(ACTION_ON_START) +#if (ENABLED(HOST_START_MENU_ITEM) && defined(ACTION_ON_START)) || (ENABLED(HOST_SHUTDOWN_MENU_ITEM) && defined(SHUTDOWN_ACTION)) #include "../../feature/host_actions.h" #endif @@ -128,8 +128,7 @@ void menu_configuration(); #define _CUSTOM_ITEM_MAIN_CONFIRM(N) \ SUBMENU_P(PSTR(MAIN_MENU_ITEM_##N##_DESC), []{ \ MenuItem_confirm::confirm_screen( \ - GCODE_LAMBDA_MAIN(N), \ - ui.goto_previous_screen, \ + GCODE_LAMBDA_MAIN(N), nullptr, \ PSTR(MAIN_MENU_ITEM_##N##_DESC "?") \ ); \ }) @@ -274,7 +273,7 @@ void menu_main() { SUBMENU(MSG_STOP_PRINT, []{ MenuItem_confirm::select_screen( GET_TEXT(MSG_BUTTON_STOP), GET_TEXT(MSG_BACK), - ui.abort_print, ui.goto_previous_screen, + ui.abort_print, nullptr, GET_TEXT(MSG_STOP_PRINT), (const char *)nullptr, PSTR("?") ); }); @@ -346,7 +345,7 @@ void menu_main() { #if ENABLED(ADVANCED_PAUSE_FEATURE) #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES) YESNO_ITEM(MSG_FILAMENTCHANGE, - menu_change_filament, ui.goto_previous_screen, + menu_change_filament, nullptr, GET_TEXT(MSG_FILAMENTCHANGE), (const char *)nullptr, PSTR("?") ); #else @@ -370,7 +369,7 @@ void menu_main() { #if ENABLED(PS_OFF_CONFIRM) CONFIRM_ITEM(MSG_SWITCH_PS_OFF, MSG_YES, MSG_NO, - ui.poweroff, ui.goto_previous_screen, + ui.poweroff, nullptr, GET_TEXT(MSG_SWITCH_PS_OFF), (const char *)nullptr, PSTR("?") ); #else @@ -394,21 +393,21 @@ void menu_main() { #if SERVICE_INTERVAL_1 > 0 CONFIRM_ITEM_P(PSTR(SERVICE_NAME_1), MSG_BUTTON_RESET, MSG_BUTTON_CANCEL, - []{ _service_reset(1); }, ui.goto_previous_screen, + []{ _service_reset(1); }, nullptr, GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_1), PSTR("?") ); #endif #if SERVICE_INTERVAL_2 > 0 CONFIRM_ITEM_P(PSTR(SERVICE_NAME_2), MSG_BUTTON_RESET, MSG_BUTTON_CANCEL, - []{ _service_reset(2); }, ui.goto_previous_screen, + []{ _service_reset(2); }, nullptr, GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_2), PSTR("?") ); #endif #if SERVICE_INTERVAL_3 > 0 CONFIRM_ITEM_P(PSTR(SERVICE_NAME_3), MSG_BUTTON_RESET, MSG_BUTTON_CANCEL, - []{ _service_reset(3); }, ui.goto_previous_screen, + []{ _service_reset(3); }, nullptr, GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_3), PSTR("?") ); #endif @@ -442,6 +441,16 @@ void menu_main() { SUBMENU(LANGUAGE, menu_language); #endif + #if ENABLED(HOST_SHUTDOWN_MENU_ITEM) && defined(SHUTDOWN_ACTION) + SUBMENU(MSG_HOST_SHUTDOWN, []{ + MenuItem_confirm::select_screen( + GET_TEXT(MSG_BUTTON_PROCEED), GET_TEXT(MSG_BUTTON_CANCEL), + []{ ui.return_to_status(); hostui.shutdown(); }, nullptr, + GET_TEXT(MSG_HOST_SHUTDOWN), (const char *)nullptr, PSTR("?") + ); + }); + #endif + END_MENU(); } diff --git a/Marlin/src/lcd/menu/menu_media.cpp b/Marlin/src/lcd/menu/menu_media.cpp index 213ad257b8..4ce0a396d4 100644 --- a/Marlin/src/lcd/menu/menu_media.cpp +++ b/Marlin/src/lcd/menu/menu_media.cpp @@ -79,7 +79,7 @@ class MenuItem_sdfile : public MenuItem_sdbase { strcpy(buffer + 1, longest); MenuItem_confirm::select_screen( GET_TEXT(MSG_BUTTON_PRINT), GET_TEXT(MSG_BUTTON_CANCEL), - sdcard_start_selected_file, ui.goto_previous_screen, + sdcard_start_selected_file, nullptr, GET_TEXT(MSG_START_PRINT), buffer, PSTR("?") ); }); diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 7191e637d1..cddb7ede74 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -210,7 +210,7 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int ui.goto_screen([]{ MenuItem_confirm::select_screen( GET_TEXT(MSG_BUTTON_PROCEED), GET_TEXT(MSG_BACK), - _goto_menu_move_distance_e, ui.goto_previous_screen, + _goto_menu_move_distance_e, nullptr, GET_TEXT(MSG_HOTEND_TOO_COLD), (const char *)nullptr, PSTR("!") ); }); diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 65cef5b76d..0e36884858 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -69,7 +69,7 @@ void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t i ui.return_to_status(); } -#if PREHEAT_COUNT +#if HAS_PREHEAT #if HAS_TEMP_HOTEND inline void _preheat_end(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); } @@ -122,7 +122,8 @@ void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t i HOTEND_LOOP() PREHEAT_ITEMS(editable.int8, e); ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M_ALL, []() { - HOTEND_LOOP() thermalManager.setTargetHotend(ui.material_preset[editable.int8].hotend_temp, e); + const celsius_t t = ui.material_preset[editable.int8].hotend_temp; + HOTEND_LOOP() thermalManager.setTargetHotend(t, e); TERN(HAS_HEATED_BED, _preheat_bed(editable.int8), ui.return_to_status()); }); @@ -137,13 +138,12 @@ void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t i #endif // HAS_MULTI_HOTEND || HAS_HEATED_BED -#endif // PREHEAT_COUNT +#endif // HAS_PREHEAT #if HAS_TEMP_HOTEND || HAS_HEATED_BED void lcd_cooldown() { - thermalManager.zero_fan_speeds(); - thermalManager.disable_all_heaters(); + thermalManager.cooldown(); ui.return_to_status(); } @@ -262,13 +262,13 @@ void menu_temperature() { #endif // HAS_FAN - #if PREHEAT_COUNT + #if HAS_PREHEAT // // Preheat for all Materials // LOOP_L_N(m, PREHEAT_COUNT) { editable.int8 = m; - #if HOTENDS > 1 || HAS_HEATED_BED + #if HAS_MULTI_HOTEND || HAS_HEATED_BED SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m); #elif HAS_HOTEND ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m); @@ -295,7 +295,7 @@ void menu_temperature() { LOOP_L_N(m, PREHEAT_COUNT) { editable.int8 = m; - #if HOTENDS > 1 || HAS_HEATED_BED + #if HAS_MULTI_HOTEND || HAS_HEATED_BED SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m); #else ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m); diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index 5cdcf75c1e..8e9d4b3942 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -66,7 +66,7 @@ static void _menu_single_probe() { STATIC_ITEM(MSG_BED_TRAMMING, SS_LEFT); STATIC_ITEM(MSG_LAST_VALUE_SP, SS_LEFT, z_isvalid[tram_index] ? ftostr42_52(z_measured[reference_index] - z_measured[tram_index]) : "---"); ACTION_ITEM(MSG_UBL_BC_INSERT2, []{ if (probe_single_point()) ui.refresh(); }); - ACTION_ITEM(MSG_BUTTON_DONE, []{ ui.goto_previous_screen(); }); + ACTION_ITEM(MSG_BUTTON_DONE, ui.goto_previous_screen); END_MENU(); } diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index 8dea7d943d..a08eceed77 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -208,7 +208,7 @@ void _lcd_ubl_edit_mesh() { void _lcd_ubl_validate_mesh() { START_MENU(); BACK_ITEM(MSG_UBL_TOOLS); - #if PREHEAT_COUNT + #if HAS_PREHEAT #if HAS_HEATED_BED #define VALIDATE_MESH_GCODE_ITEM(M) \ GCODES_ITEM_N_S(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, PSTR("G28\nG26CPI" STRINGIFY(M))) @@ -230,7 +230,7 @@ void _lcd_ubl_edit_mesh() { #endif #endif #endif - #endif // PREHEAT_COUNT + #endif // HAS_PREHEAT ACTION_ITEM(MSG_UBL_VALIDATE_CUSTOM_MESH, _lcd_ubl_validate_custom_mesh); ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status); END_MENU(); @@ -324,7 +324,7 @@ void _lcd_ubl_invalidate() { void _lcd_ubl_build_mesh() { START_MENU(); BACK_ITEM(MSG_UBL_TOOLS); - #if PREHEAT_COUNT + #if HAS_PREHEAT #if HAS_HEATED_BED #define PREHEAT_BED_GCODE(M) "M190I" STRINGIFY(M) "\n" #else @@ -352,7 +352,7 @@ void _lcd_ubl_build_mesh() { #endif #endif #endif - #endif // PREHEAT_COUNT + #endif // HAS_PREHEAT SUBMENU(MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_custom_mesh); GCODES_ITEM(MSG_UBL_BUILD_COLD_MESH, PSTR("G29NP1")); diff --git a/Marlin/src/lcd/tft/ui_common.cpp b/Marlin/src/lcd/tft/ui_common.cpp index e152ceab50..acc91f51fa 100644 --- a/Marlin/src/lcd/tft/ui_common.cpp +++ b/Marlin/src/lcd/tft/ui_common.cpp @@ -167,8 +167,7 @@ void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, void MenuItem_static::draw(const uint8_t row, PGM_P const pstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) { menu_item(row); tft_string.set(pstr, itemIndex, itemString); - if (vstr) - tft_string.add(vstr); + if (vstr) tft_string.add(vstr); tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_YELLOW, tft_string); } @@ -176,9 +175,9 @@ void MenuItem_static::draw(const uint8_t row, PGM_P const pstr, const uint8_t st void MenuItem_sdbase::draw(const bool sel, const uint8_t row, PGM_P const, CardReader &theCard, const bool isDir) { menu_item(row, sel); - if (isDir) - tft.add_image(MENU_ITEM_ICON_X, MENU_ITEM_ICON_Y, imgDirectory, COLOR_MENU_TEXT, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND); - tft.add_text(MENU_ITEM_ICON_SPACE, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, theCard.longest_filename()); + if (isDir) tft.add_image(MENU_ITEM_ICON_X, MENU_ITEM_ICON_Y, imgDirectory, COLOR_MENU_TEXT, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND); + constexpr uint8_t maxlen = (MENU_ITEM_HEIGHT) - (MENU_TEXT_Y_OFFSET) + 1; + tft.add_text(MENU_ITEM_ICON_SPACE, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, ui.scrolled_filename(theCard, maxlen, row, sel)); } #endif @@ -211,12 +210,14 @@ void MarlinUI::clear_lcd() { } #if HAS_LCD_BRIGHTNESS + void MarlinUI::_set_brightness() { #if PIN_EXISTS(TFT_BACKLIGHT) if (PWM_PIN(TFT_BACKLIGHT_PIN)) - analogWrite(pin_t(TFT_BACKLIGHT_PIN), brightness); + analogWrite(pin_t(TFT_BACKLIGHT_PIN), backlight ? brightness : 0); #endif } + #endif #if ENABLED(TOUCH_SCREEN_CALIBRATION) diff --git a/Marlin/src/lcd/tft/ui_common.h b/Marlin/src/lcd/tft/ui_common.h index d3ffd4bc31..7329c31a52 100644 --- a/Marlin/src/lcd/tft/ui_common.h +++ b/Marlin/src/lcd/tft/ui_common.h @@ -57,7 +57,7 @@ void menu_item(const uint8_t row, bool sel = false); #define ABSOLUTE_ZERO -273.15 -#if HAS_TEMP_CHAMBER && HOTENDS > 1 +#if HAS_TEMP_CHAMBER && HAS_MULTI_HOTEND #define ITEM_E0 0 #define ITEM_E1 1 #define ITEM_BED 2 @@ -74,7 +74,7 @@ void menu_item(const uint8_t row, bool sel = false); #define ITEM_COOLER 0 #define ITEM_FAN 1 #define ITEMS_COUNT 2 -#elif HOTENDS > 1 +#elif HAS_MULTI_HOTEND #define ITEM_E0 0 #define ITEM_E1 1 #define ITEM_BED 2 diff --git a/Marlin/src/lcd/tft_io/tft_io.cpp b/Marlin/src/lcd/tft_io/tft_io.cpp index 6ec3bedcdf..acb78c3e6e 100644 --- a/Marlin/src/lcd/tft_io/tft_io.cpp +++ b/Marlin/src/lcd/tft_io/tft_io.cpp @@ -152,8 +152,7 @@ if (lcd_id != 0xFFFFFFFF) return; #endif #if PIN_EXISTS(TFT_BACKLIGHT) && ENABLED(DELAYED_BACKLIGHT_INIT) - WRITE(TFT_BACKLIGHT_PIN, HIGH); - TERN_(HAS_LCD_BRIGHTNESS, ui._set_brightness()); + TERN(HAS_LCD_BRIGHTNESS, ui._set_brightness(), WRITE(TFT_BACKLIGHT_PIN, HIGH)); #endif } diff --git a/Marlin/src/libs/autoreport.h b/Marlin/src/libs/autoreport.h index a6bc5adbf7..9aa74ab81e 100644 --- a/Marlin/src/libs/autoreport.h +++ b/Marlin/src/libs/autoreport.h @@ -44,7 +44,7 @@ struct AutoReporter { next_report_ms = ms + SEC_TO_MS(report_interval); PORT_REDIRECT(report_port_mask); Helper::report(); - //PORT_RESTORE(); + PORT_RESTORE(); } } }; diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 332becfb73..04f20ca3a4 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -1342,7 +1342,7 @@ void Endstops::update() { ES_REPORT_CHANGE(K_MAX); #endif SERIAL_ECHOLNPGM("\n"); - analogWrite(pin_t(LED_PIN), local_LED_status); + set_pwm_duty(pin_t(LED_PIN), local_LED_status); local_LED_status ^= 255; old_live_state_local = live_state_local; } diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index b89a313f2b..11460fa67a 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1270,7 +1270,7 @@ void Planner::recalculate() { #elif ENABLED(FAST_PWM_FAN) #define _FAN_SET(F) set_pwm_duty(FAN##F##_PIN, CALC_FAN_SPEED(F)); #else - #define _FAN_SET(F) analogWrite(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(F)); + #define _FAN_SET(F) set_pwm_duty(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(F)); #endif #define FAN_SET(F) do{ kickstart_fan(fan_speed, ms, F); _FAN_SET(F); }while(0) @@ -1393,8 +1393,8 @@ void Planner::check_axes_activity() { TERN_(AUTOTEMP, autotemp_task()); #if ENABLED(BARICUDA) - TERN_(HAS_HEATER_1, analogWrite(pin_t(HEATER_1_PIN), tail_valve_pressure)); - TERN_(HAS_HEATER_2, analogWrite(pin_t(HEATER_2_PIN), tail_e_to_p_pressure)); + TERN_(HAS_HEATER_1, set_pwm_duty(pin_t(HEATER_1_PIN), tail_valve_pressure)); + TERN_(HAS_HEATER_2, set_pwm_duty(pin_t(HEATER_2_PIN), tail_e_to_p_pressure)); #endif } @@ -1457,7 +1457,7 @@ void Planner::check_axes_activity() { float t = autotemp_min + high * autotemp_factor; LIMIT(t, autotemp_min, autotemp_max); - if (t < oldt) t *= (1.0f - (AUTOTEMP_OLDWEIGHT)) + oldt * (AUTOTEMP_OLDWEIGHT); + if (t < oldt) t = t * (1.0f - (AUTOTEMP_OLDWEIGHT)) + oldt * (AUTOTEMP_OLDWEIGHT); oldt = t; thermalManager.setTargetHotend(t, active_extruder); } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 6b7143e82a..01a5c47fd5 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -128,7 +128,7 @@ #include "../feature/tmc_util.h" #endif -#if ENABLED(PROBE_TEMP_COMPENSATION) +#if HAS_PTC #include "../feature/probe_temp_comp.h" #endif @@ -264,13 +264,16 @@ typedef struct SettingsDataStruct { // // Temperature first layer compensation values // - #if ENABLED(PROBE_TEMP_COMPENSATION) - int16_t z_offsets_probe[COUNT(temp_comp.z_offsets_probe)], // M871 P I V - z_offsets_bed[COUNT(temp_comp.z_offsets_bed)] // M871 B I V - #if ENABLED(USE_TEMP_EXT_COMPENSATION) - , z_offsets_ext[COUNT(temp_comp.z_offsets_ext)] // M871 E I V - #endif - ; + #if HAS_PTC + #if ENABLED(PTC_PROBE) + int16_t z_offsets_probe[COUNT(ptc.z_offsets_probe)]; // M871 P I V + #endif + #if ENABLED(PTC_BED) + int16_t z_offsets_bed[COUNT(ptc.z_offsets_bed)]; // M871 B I V + #endif + #if ENABLED(PTC_HOTEND) + int16_t z_offsets_hotend[COUNT(ptc.z_offsets_hotend)]; // M871 E I V + #endif #endif // @@ -317,7 +320,7 @@ typedef struct SettingsDataStruct { // // Material Presets // - #if PREHEAT_COUNT + #if HAS_PREHEAT preheat_t ui_material_preset[PREHEAT_COUNT]; // M145 S0 H B F #endif @@ -844,11 +847,15 @@ void MarlinSettings::postprocess() { // // Thermal first layer compensation values // - #if ENABLED(PROBE_TEMP_COMPENSATION) - EEPROM_WRITE(temp_comp.z_offsets_probe); - EEPROM_WRITE(temp_comp.z_offsets_bed); - #if ENABLED(USE_TEMP_EXT_COMPENSATION) - EEPROM_WRITE(temp_comp.z_offsets_ext); + #if HAS_PTC + #if ENABLED(PTC_PROBE) + EEPROM_WRITE(ptc.z_offsets_probe); + #endif + #if ENABLED(PTC_BED) + EEPROM_WRITE(ptc.z_offsets_bed); + #endif + #if ENABLED(PTC_HOTEND) + EEPROM_WRITE(ptc.z_offsets_hotend); #endif #else // No placeholder data for this feature @@ -918,7 +925,7 @@ void MarlinSettings::postprocess() { // // LCD Preheat settings // - #if PREHEAT_COUNT + #if HAS_PREHEAT _FIELD_TEST(ui_material_preset); EEPROM_WRITE(ui.material_preset); #endif @@ -1710,13 +1717,17 @@ void MarlinSettings::postprocess() { // // Thermal first layer compensation values // - #if ENABLED(PROBE_TEMP_COMPENSATION) - EEPROM_READ(temp_comp.z_offsets_probe); - EEPROM_READ(temp_comp.z_offsets_bed); - #if ENABLED(USE_TEMP_EXT_COMPENSATION) - EEPROM_READ(temp_comp.z_offsets_ext); + #if HAS_PTC + #if ENABLED(PTC_PROBE) + EEPROM_READ(ptc.z_offsets_probe); #endif - temp_comp.reset_index(); + # if ENABLED(PTC_BED) + EEPROM_READ(ptc.z_offsets_bed); + #endif + #if ENABLED(PTC_HOTEND) + EEPROM_READ(ptc.z_offsets_hotend); + #endif + ptc.reset_index(); #else // No placeholder data for this feature #endif @@ -1786,7 +1797,7 @@ void MarlinSettings::postprocess() { // // LCD Preheat settings // - #if PREHEAT_COUNT + #if HAS_PREHEAT _FIELD_TEST(ui_material_preset); EEPROM_READ(ui.material_preset); #endif @@ -2728,6 +2739,11 @@ void MarlinSettings::reset() { // TERN_(EDITABLE_SERVO_ANGLES, COPY(servo_angles, base_servo_angles)); // When not editable only one copy of servo angles exists + // + // Probe Temperature Compensation + // + TERN_(HAS_PTC, ptc.reset()); + // // BLTOUCH // @@ -2796,7 +2812,7 @@ void MarlinSettings::reset() { // // Preheat parameters // - #if PREHEAT_COUNT + #if HAS_PREHEAT #define _PITEM(N,T) PREHEAT_##N##_##T, #if HAS_HOTEND constexpr uint16_t hpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, TEMP_HOTEND) }; @@ -3181,7 +3197,7 @@ void MarlinSettings::reset() { // // LCD Preheat Settings // - #if PREHEAT_COUNT + #if HAS_PREHEAT gcode.M145_report(forReplay); #endif diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index a54bf53c49..2c8933266f 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -3253,7 +3253,7 @@ void Stepper::report_positions() { #elif HAS_MOTOR_CURRENT_PWM - #define _WRITE_CURRENT_PWM(P) analogWrite(pin_t(MOTOR_CURRENT_PWM_## P ##_PIN), 255L * current / (MOTOR_CURRENT_PWM_RANGE)) + #define _WRITE_CURRENT_PWM(P) set_pwm_duty(pin_t(MOTOR_CURRENT_PWM_## P ##_PIN), 255L * current / (MOTOR_CURRENT_PWM_RANGE)) switch (driver) { case 0: #if PIN_EXISTS(MOTOR_CURRENT_PWM_X) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 5e8f4c9d95..cef348c5f9 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -887,11 +887,11 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { SBI(fanState, pgm_read_byte(&fanBit[COOLER_FAN_INDEX])); #endif - #define _UPDATE_AUTO_FAN(P,D,A) do{ \ - if (PWM_PIN(P##_AUTO_FAN_PIN) && A < 255) \ - analogWrite(pin_t(P##_AUTO_FAN_PIN), D ? A : 0); \ - else \ - WRITE(P##_AUTO_FAN_PIN, D); \ + #define _UPDATE_AUTO_FAN(P,D,A) do{ \ + if (PWM_PIN(P##_AUTO_FAN_PIN) && A < 255) \ + set_pwm_duty(pin_t(P##_AUTO_FAN_PIN), D ? A : 0); \ + else \ + WRITE(P##_AUTO_FAN_PIN, D); \ }while(0) uint8_t fanDone = 0; diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 5579f71172..0e66f23110 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -848,6 +848,14 @@ class Temperature { */ static void disable_all_heaters(); + /** + * Cooldown, as from the LCD. Disables all heaters and fans. + */ + static inline void cooldown() { + zero_fan_speeds(); + disable_all_heaters(); + } + #if ENABLED(PRINTJOB_TIMER_AUTOSTART) /** * Methods to check if heaters are enabled, indicating an active job diff --git a/Marlin/src/pins/esp32/pins_E4D.h b/Marlin/src/pins/esp32/pins_E4D.h index 54621f36c1..02a5fe4e33 100644 --- a/Marlin/src/pins/esp32/pins_E4D.h +++ b/Marlin/src/pins/esp32/pins_E4D.h @@ -32,7 +32,7 @@ #if EXTRUDERS > 1 || E_STEPPERS > 1 #error "E4d@box only supports one E Stepper. Comment out this line to continue." -#elif HOTENDS > 1 +#elif HAS_MULTI_HOTEND #error "E4d@box only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/esp32/pins_ESPA_common.h b/Marlin/src/pins/esp32/pins_ESPA_common.h new file mode 100644 index 0000000000..2fcacb3002 --- /dev/null +++ b/Marlin/src/pins/esp32/pins_ESPA_common.h @@ -0,0 +1,89 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * ESPA-like pin assignments + * Supports 4 stepper drivers, heated bed, single hotend. + */ + +#include "env_validate.h" + +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME +#endif + +// +// Disable I2S stepper stream, by default +// +#undef I2S_STEPPER_STREAM +#undef I2S_WS +#undef I2S_BCK +#undef I2S_DATA + +// +// Limit Switches +// +#define X_STOP_PIN 34 +#define Y_STOP_PIN 35 +#define Z_STOP_PIN 15 + +// +// Steppers +// +#define X_STEP_PIN 27 +#define X_DIR_PIN 26 +#define X_ENABLE_PIN 25 + +#define Y_STEP_PIN 33 +#define Y_DIR_PIN 32 +#define Y_ENABLE_PIN X_ENABLE_PIN + +#define Z_STEP_PIN 14 +#define Z_DIR_PIN 12 +#define Z_ENABLE_PIN X_ENABLE_PIN + +#define E0_STEP_PIN 16 +#define E0_DIR_PIN 17 +#define E0_ENABLE_PIN X_ENABLE_PIN + +// +// Temperature Sensors +// +#define TEMP_0_PIN 36 // Analog Input +#define TEMP_BED_PIN 39 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 2 +#define FAN_PIN 13 +#define HEATER_BED_PIN 4 + +// +// MicroSD card +// +#define SD_MOSI_PIN 23 +#define SD_MISO_PIN 19 +#define SD_SCK_PIN 18 +#define SDSS 5 +#define USES_SHARED_SPI // SPI is shared by SD card with TMC SPI drivers diff --git a/Marlin/src/pins/esp32/pins_FYSETC_E4.h b/Marlin/src/pins/esp32/pins_FYSETC_E4.h index 2b2fe40c4a..e75b6ece28 100644 --- a/Marlin/src/pins/esp32/pins_FYSETC_E4.h +++ b/Marlin/src/pins/esp32/pins_FYSETC_E4.h @@ -32,46 +32,13 @@ #if EXTRUDERS > 1 || E_STEPPERS > 1 #error "FYSETC E4 only supports one E Stepper. Comment out this line to continue." -#elif HOTENDS > 1 +#elif HAS_MULTI_HOTEND #error "FYSETC E4 only supports one hotend / E-stepper. Comment out this line to continue." #endif #define BOARD_INFO_NAME "FYSETC_E4" -#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME -// -// Disable I2S stepper stream -// -#undef I2S_STEPPER_STREAM -#define I2S_WS -1 -#define I2S_BCK -1 -#define I2S_DATA -1 - -// -// Limit Switches -// -#define X_STOP_PIN 34 -#define Y_STOP_PIN 35 -#define Z_STOP_PIN 15 - -// -// Steppers -// -#define X_STEP_PIN 27 -#define X_DIR_PIN 26 -#define X_ENABLE_PIN 25 - -#define Y_STEP_PIN 33 -#define Y_DIR_PIN 32 -#define Y_ENABLE_PIN X_ENABLE_PIN - -#define Z_STEP_PIN 14 -#define Z_DIR_PIN 12 -#define Z_ENABLE_PIN X_ENABLE_PIN - -#define E0_STEP_PIN 16 -#define E0_DIR_PIN 17 -#define E0_ENABLE_PIN X_ENABLE_PIN +#include "pins_ESPA_common.h" #if HAS_TMC_UART // @@ -89,28 +56,6 @@ #define TMC_BAUD_RATE 115200 #endif -// -// Temperature Sensors -// -#define TEMP_0_PIN 36 // Analog Input -#define TEMP_BED_PIN 39 // Analog Input - -// -// Heaters / Fans -// -#define HEATER_0_PIN 2 -#define FAN_PIN 13 -#define HEATER_BED_PIN 4 - -// -// MicroSD card -// -#define SD_MOSI_PIN 23 -#define SD_MISO_PIN 19 -#define SD_SCK_PIN 18 -#define SDSS 5 -#define USES_SHARED_SPI // SPI is shared by SD card with TMC SPI drivers - /** * Hardware serial pins * diff --git a/Marlin/src/pins/esp32/pins_MRR_ESPA.h b/Marlin/src/pins/esp32/pins_MRR_ESPA.h index ab4f401f26..cc67bc025c 100644 --- a/Marlin/src/pins/esp32/pins_MRR_ESPA.h +++ b/Marlin/src/pins/esp32/pins_MRR_ESPA.h @@ -32,74 +32,23 @@ #if EXTRUDERS > 1 || E_STEPPERS > 1 #error "MRR ESPA only supports one E Stepper. Comment out this line to continue." -#elif HOTENDS > 1 +#elif HAS_MULTI_HOTEND #error "MRR ESPA only supports one hotend / E-stepper. Comment out this line to continue." #endif #define BOARD_INFO_NAME "MRR ESPA" #define BOARD_WEBSITE_URL "github.com/maplerainresearch/MRR_ESPA" -#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME -// -// Disable I2S stepper stream -// -#undef I2S_STEPPER_STREAM -#undef I2S_WS -#undef I2S_BCK -#undef I2S_DATA - -// -// Limit Switches -// -#define X_STOP_PIN 34 -#define Y_STOP_PIN 35 -#define Z_STOP_PIN 15 +#include "pins_ESPA_common.h" // // Steppers // -#define X_STEP_PIN 27 -#define X_DIR_PIN 26 -#define X_ENABLE_PIN 25 //#define X_CS_PIN 21 - -#define Y_STEP_PIN 33 -#define Y_DIR_PIN 32 -#define Y_ENABLE_PIN X_ENABLE_PIN //#define Y_CS_PIN 22 - -#define Z_STEP_PIN 14 -#define Z_DIR_PIN 12 -#define Z_ENABLE_PIN X_ENABLE_PIN //#define Z_CS_PIN 5 // SS_PIN - -#define E0_STEP_PIN 16 -#define E0_DIR_PIN 17 -#define E0_ENABLE_PIN X_ENABLE_PIN //#define E0_CS_PIN 21 -// -// Temperature Sensors -// -#define TEMP_0_PIN 36 // Analog Input -#define TEMP_BED_PIN 39 // Analog Input - -// -// Heaters / Fans -// -#define HEATER_0_PIN 2 -#define FAN_PIN 13 -#define HEATER_BED_PIN 4 - -// -// MicroSD card -// -#define SD_MOSI_PIN 23 -#define SD_MISO_PIN 19 -#define SD_SCK_PIN 18 -#define SDSS 5 -#define USES_SHARED_SPI // SPI is shared by SD card with TMC SPI drivers - // Hardware serial pins // Add the following to Configuration.h or Configuration_adv.h to assign // specific pins to hardware Serial1. diff --git a/Marlin/src/pins/esp32/pins_MRR_ESPE.h b/Marlin/src/pins/esp32/pins_MRR_ESPE.h index 1f829b7755..60c8405dfe 100644 --- a/Marlin/src/pins/esp32/pins_MRR_ESPE.h +++ b/Marlin/src/pins/esp32/pins_MRR_ESPE.h @@ -33,7 +33,7 @@ #if EXTRUDERS > 2 || E_STEPPERS > 2 #error "MRR ESPE only supports two E Steppers. Comment out this line to continue." -#elif HOTENDS > 1 +#elif HAS_MULTI_HOTEND #error "MRR ESPE only supports one hotend / E-stepper. Comment out this line to continue." #endif @@ -51,7 +51,6 @@ // // Enable I2S stepper stream // -#undef I2S_STEPPER_STREAM #define I2S_STEPPER_STREAM #define I2S_WS 26 #define I2S_BCK 25 diff --git a/Marlin/src/pins/esp32/pins_RESP32_CUSTOM.h b/Marlin/src/pins/esp32/pins_RESP32_CUSTOM.h new file mode 100644 index 0000000000..5d3f75574d --- /dev/null +++ b/Marlin/src/pins/esp32/pins_RESP32_CUSTOM.h @@ -0,0 +1,37 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Rutilea ESP32 (Tensilica Xtensa LX6) pin assignments + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "Rutilea ESP32" + +#include "pins_ESPA_common.h" + +// +// I2S (steppers & other output-only pins) +// +#define I2S_STEPPER_STREAM diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h index ec8f31b854..97d78c0d24 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -26,7 +26,9 @@ */ #define BOARD_INFO_NAME "BTT SKR V1.3" -#define LPC1768_IS_SKRV1_3 1 + +#define LPC1768_IS_SKRV1_3 +#define USES_DIAG_JUMPERS // // Trinamic Stallguard pins diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h index dc82a2857f..b9dc845c5b 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -35,6 +35,8 @@ #define BOARD_CUSTOM_BUILD_FLAGS -DLPC_PINCFG_UART3_P4_28 #endif +#define USES_DIAG_PINS + // // EEPROM // @@ -281,7 +283,7 @@ #define BEEPER_PIN EXP1_05_PIN #endif -#elif HAS_WIRED_LCD && !BTT_MOTOR_EXPANSION +#elif HAS_WIRED_LCD #if ENABLED(ANET_FULL_GRAPHICS_LCD_ALT_WIRING) #error "CAUTION! ANET_FULL_GRAPHICS_LCD_ALT_WIRING requires wiring modifications. See 'pins_BTT_SKR_V1_4.h' for details. Comment out this line to continue." diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h index d6b1eeab46..15afe7e238 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h @@ -30,6 +30,8 @@ #define BOARD_INFO_NAME "MKS SGen-L" #define BOARD_WEBSITE_URL "github.com/makerbase-mks/MKS-SGEN_L" +#define USES_DIAG_JUMPERS + // // Servos // 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 9c514f8ca3..bdc49fc236 100644 --- a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h +++ b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h @@ -31,6 +31,8 @@ #define BOARD_INFO_NAME "BTT SKR E3 Turbo" #endif +#define USES_DIAG_JUMPERS + // Onboard I2C EEPROM #define I2C_EEPROM #define MARLIN_EEPROM_SIZE 0x1000 // 4KB (AT24C32) diff --git a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h index bb39009f09..8107f11937 100644 --- a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h @@ -30,6 +30,8 @@ #define BOARD_INFO_NAME "MKS SGEN_L V2" #define BOARD_WEBSITE_URL "github.com/makerbase-mks" +#define USES_DIAG_JUMPERS + // // EEPROM, MKS SGEN_L V2.0 hardware has 4K EEPROM on the board // diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 3b83e14d62..369a78be7a 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -620,9 +620,9 @@ #elif MB(BTT_E3_RRF) #include "stm32f4/pins_BTT_E3_RRF.h" // STM32F4 env:BIGTREE_E3_RRF #elif MB(BTT_SKR_V2_0_REV_A) - #include "stm32f4/pins_BTT_SKR_V2_0_REV_A.h" // STM32F4 env:BIGTREE_SKR_2 env:BIGTREE_SKR_2_USB + #include "stm32f4/pins_BTT_SKR_V2_0_REV_A.h" // STM32F4 env:BIGTREE_SKR_2 env:BIGTREE_SKR_2_USB env:BIGTREE_SKR_2_USB_debug #elif MB(BTT_SKR_V2_0_REV_B) - #include "stm32f4/pins_BTT_SKR_V2_0_REV_B.h" // STM32F4 env:BIGTREE_SKR_2 env:BIGTREE_SKR_2_USB + #include "stm32f4/pins_BTT_SKR_V2_0_REV_B.h" // STM32F4 env:BIGTREE_SKR_2 env:BIGTREE_SKR_2_USB env:BIGTREE_SKR_2_USB_debug #elif MB(BTT_OCTOPUS_V1_0) #include "stm32f4/pins_BTT_OCTOPUS_V1_0.h" // STM32F4 env:BIGTREE_OCTOPUS_V1 env:BIGTREE_OCTOPUS_V1_USB #elif MB(BTT_OCTOPUS_V1_1) @@ -659,14 +659,16 @@ #include "stm32f4/pins_FYSETC_CHEETAH_V20.h" // STM32F4 env:FYSETC_CHEETAH_V20 #elif MB(MKS_MONSTER8) #include "stm32f4/pins_MKS_MONSTER8.h" // STM32F4 env:mks_monster8 env:mks_monster8_usb_flash_drive env:mks_monster8_usb_flash_drive_msc -#elif MB(TH3D_EZBOARD_LITE_V2) - #include "stm32f4/pins_TH3D_EZBOARD_LITE_V2.h" // STM32F4 env:TH3D_EZBoard_Lite_V2 +#elif MB(TH3D_EZBOARD_V2) + #include "stm32f4/pins_TH3D_EZBOARD_V2.h" // STM32F4 env:TH3D_EZBoard_V2 #elif MB(INDEX_REV03) #include "stm32f4/pins_INDEX_REV03.h" // STM32F4 env:Index_Mobo_Rev03 #elif MB(MKS_ROBIN_NANO_V1_3_F4) #include "stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h" // STM32F4 env:mks_robin_nano_v1_3_f4 #elif MB(MKS_EAGLE) #include "stm32f4/pins_MKS_EAGLE.h" // STM32F4 env:mks_eagle +#elif MB(ARTILLERY_RUBY) + #include "stm32f4/pins_ARTILLERY_RUBY.h" // STM32F4 env:Artillery_Ruby // // ARM Cortex M7 @@ -695,6 +697,8 @@ #include "esp32/pins_MRR_ESPE.h" // ESP32 env:esp32 #elif MB(E4D_BOX) #include "esp32/pins_E4D.h" // ESP32 env:esp32 +#elif MB(RESP32_CUSTOM) + #include "esp32/pins_RESP32_CUSTOM.h" // ESP32 env:esp32 #elif MB(FYSETC_E4) #include "esp32/pins_FYSETC_E4.h" // ESP32 env:FYSETC_E4 #elif MB(PANDA_ZHU) @@ -752,6 +756,7 @@ #define BOARD_RAMPS_DAGOMA -1020 #define BOARD_RAMPS_LONGER3D_LK4PRO -1021 #define BOARD_BTT_SKR_V2_0 -1022 + #define BOARD_TH3D_EZBOARD_LITE_V2 -1023 #if MB(MKS_13) #error "BOARD_MKS_13 has been renamed BOARD_MKS_GEN_13. Please update your configuration." @@ -801,6 +806,8 @@ #error "BOARD_RAMPS_LONGER3D_LK4PRO is now BOARD_LONGER3D_LKx_PRO. Please update your configuration." #elif MB(BTT_SKR_V2_0) #error "BTT_SKR_V2_0 is now BTT_SKR_V2_0_REV_A or BTT_SKR_V2_0_REV_B. See https://bit.ly/3t5d9JQ for more information. Please update your configuration." + #elif MB(BOARD_TH3D_EZBOARD_LITE_V2) + #error "BOARD_TH3D_EZBOARD_LITE_V2 is now BOARD_TH3D_EZBOARD_V2. Please update your configuration." #elif defined(MOTHERBOARD) #error "Unknown MOTHERBOARD value set in Configuration.h." #else diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index f07b1cf025..05756d6004 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -74,6 +74,16 @@ REPORT_NAME_ANALOG(__LINE__, MAIN_VOLTAGE_MEASURE_PIN) #endif #endif +#if PIN_EXISTS(POWER_MONITOR_CURRENT) + #if ANALOG_OK(POWER_MONITOR_CURRENT_PIN) + REPORT_NAME_ANALOG(__LINE__, POWER_MONITOR_CURRENT_PIN) + #endif +#endif +#if PIN_EXISTS(POWER_MONITOR_VOLTAGE) + #if ANALOG_OK(POWER_MONITOR_VOLTAGE_PIN) + REPORT_NAME_ANALOG(__LINE__, POWER_MONITOR_VOLTAGE_PIN) + #endif +#endif #if !defined(ARDUINO_ARCH_SAM) && !defined(ARDUINO_ARCH_SAMD) // TC1 & TC2 are macros in the SAM/SAMD tool chain #if _EXISTS(TC1) #if ANALOG_OK(TC1) @@ -131,6 +141,11 @@ REPORT_NAME_ANALOG(__LINE__, TEMP_BED_PIN) #endif #endif +#if PIN_EXISTS(TEMP_BOARD) + #if ANALOG_OK(TEMP_BOARD_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_BOARD_PIN) + #endif +#endif #if PIN_EXISTS(TEMP_CHAMBER) #if ANALOG_OK(TEMP_CHAMBER_PIN) REPORT_NAME_ANALOG(__LINE__, TEMP_CHAMBER_PIN) @@ -141,6 +156,11 @@ REPORT_NAME_ANALOG(__LINE__, TEMP_COOLER_PIN) #endif #endif +#if PIN_EXISTS(TEMP_PROBE) + #if ANALOG_OK(TEMP_PROBE_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_PROBE_PIN) + #endif +#endif #if PIN_EXISTS(ADC_KEYPAD) #if ANALOG_OK(ADC_KEYPAD_PIN) REPORT_NAME_ANALOG(__LINE__, ADC_KEYPAD_PIN) @@ -370,6 +390,9 @@ #if PIN_EXISTS(DIGIPOTSS) REPORT_NAME_DIGITAL(__LINE__, DIGIPOTSS_PIN) #endif +#if PIN_EXISTS(LCD_RESET) + REPORT_NAME_DIGITAL(__LINE__, LCD_RESET_PIN) +#endif #if _EXISTS(DOGLCD_A0) REPORT_NAME_DIGITAL(__LINE__, DOGLCD_A0) #endif @@ -433,6 +456,9 @@ #if PIN_EXISTS(E0_STEP) REPORT_NAME_DIGITAL(__LINE__, E0_STEP_PIN) #endif +#if PIN_EXISTS(E0_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E0_STDBY_PIN) +#endif #if PIN_EXISTS(E1_AUTO_FAN) REPORT_NAME_DIGITAL(__LINE__, E1_AUTO_FAN_PIN) #endif @@ -457,6 +483,9 @@ #if PIN_EXISTS(E1_STEP) REPORT_NAME_DIGITAL(__LINE__, E1_STEP_PIN) #endif +#if PIN_EXISTS(E1_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E1_STDBY_PIN) +#endif #if PIN_EXISTS(E2_AUTO_FAN) REPORT_NAME_DIGITAL(__LINE__, E2_AUTO_FAN_PIN) #endif @@ -481,6 +510,9 @@ #if PIN_EXISTS(E2_STEP) REPORT_NAME_DIGITAL(__LINE__, E2_STEP_PIN) #endif +#if PIN_EXISTS(E2_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E2_STDBY_PIN) +#endif #if PIN_EXISTS(E3_AUTO_FAN) REPORT_NAME_DIGITAL(__LINE__, E3_AUTO_FAN_PIN) #endif @@ -505,6 +537,9 @@ #if PIN_EXISTS(E3_STEP) REPORT_NAME_DIGITAL(__LINE__, E3_STEP_PIN) #endif +#if PIN_EXISTS(E3_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E3_STDBY_PIN) +#endif #if PIN_EXISTS(E4_AUTO_FAN) REPORT_NAME_DIGITAL(__LINE__, E4_AUTO_FAN_PIN) #endif @@ -529,6 +564,9 @@ #if PIN_EXISTS(E4_STEP) REPORT_NAME_DIGITAL(__LINE__, E4_STEP_PIN) #endif +#if PIN_EXISTS(E4_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E4_STDBY_PIN) +#endif #if PIN_EXISTS(E5_AUTO_FAN) REPORT_NAME_DIGITAL(__LINE__, E5_AUTO_FAN_PIN) #endif @@ -553,6 +591,9 @@ #if PIN_EXISTS(E5_STEP) REPORT_NAME_DIGITAL(__LINE__, E5_STEP_PIN) #endif +#if PIN_EXISTS(E5_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E5_STDBY_PIN) +#endif #if PIN_EXISTS(E6_AUTO_FAN) REPORT_NAME_DIGITAL(__LINE__, E6_AUTO_FAN_PIN) #endif @@ -577,6 +618,9 @@ #if PIN_EXISTS(E6_STEP) REPORT_NAME_DIGITAL(__LINE__, E6_STEP_PIN) #endif +#if PIN_EXISTS(E6_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E6_STDBY_PIN) +#endif #if PIN_EXISTS(E7_AUTO_FAN) REPORT_NAME_DIGITAL(__LINE__, E7_AUTO_FAN_PIN) #endif @@ -601,6 +645,9 @@ #if PIN_EXISTS(E7_STEP) REPORT_NAME_DIGITAL(__LINE__, E7_STEP_PIN) #endif +#if PIN_EXISTS(E7_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E7_STDBY_PIN) +#endif #if _EXISTS(ENET_CRS) REPORT_NAME_DIGITAL(__LINE__, ENET_CRS) #endif @@ -704,6 +751,9 @@ #if PIN_EXISTS(POWER_LOSS) REPORT_NAME_DIGITAL(__LINE__, POWER_LOSS_PIN) #endif +#if PIN_EXISTS(SAFE_POWER) + REPORT_NAME_DIGITAL(__LINE__, SAFE_POWER_PIN) +#endif #if PIN_EXISTS(FIL_RUNOUT) REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT_PIN) #endif @@ -806,6 +856,15 @@ #if PIN_EXISTS(LED) REPORT_NAME_DIGITAL(__LINE__, LED_PIN) #endif +#if PIN_EXISTS(LED2) + REPORT_NAME_DIGITAL(__LINE__, LED2_PIN) +#endif +#if PIN_EXISTS(LED3) + REPORT_NAME_DIGITAL(__LINE__, LED3_PIN) +#endif +#if PIN_EXISTS(LED4) + REPORT_NAME_DIGITAL(__LINE__, LED4_PIN) +#endif #if PIN_EXISTS(LED_RED) REPORT_NAME_DIGITAL(__LINE__, LED_RED_PIN) #endif @@ -870,6 +929,12 @@ #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E_PIN) #endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E0_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_E1) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E1_PIN) +#endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_X) REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_X_PIN) #endif @@ -1146,6 +1211,9 @@ #if PIN_EXISTS(X_STEP) REPORT_NAME_DIGITAL(__LINE__, X_STEP_PIN) #endif +#if PIN_EXISTS(X_STDBY) + REPORT_NAME_DIGITAL(__LINE__, X_STDBY_PIN) +#endif #if PIN_EXISTS(X_STOP) REPORT_NAME_DIGITAL(__LINE__, X_STOP_PIN) #endif @@ -1209,6 +1277,9 @@ #if PIN_EXISTS(Y_STEP) REPORT_NAME_DIGITAL(__LINE__, Y_STEP_PIN) #endif +#if PIN_EXISTS(Y_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Y_STDBY_PIN) +#endif #if PIN_EXISTS(Y_STOP) REPORT_NAME_DIGITAL(__LINE__, Y_STOP_PIN) #endif @@ -1272,6 +1343,9 @@ #if PIN_EXISTS(Z_STEP) REPORT_NAME_DIGITAL(__LINE__, Z_STEP_PIN) #endif +#if PIN_EXISTS(Z_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Z_STDBY_PIN) +#endif #if PIN_EXISTS(Z_STOP) REPORT_NAME_DIGITAL(__LINE__, Z_STOP_PIN) #endif @@ -1290,6 +1364,9 @@ #if PIN_EXISTS(Z2_MIN) REPORT_NAME_DIGITAL(__LINE__, Z2_MIN_PIN) #endif +#if PIN_EXISTS(Z2_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Z2_DIAG_PIN) +#endif #if PIN_EXISTS(Z2_MS1) REPORT_NAME_DIGITAL(__LINE__, Z2_MS1_PIN) #endif @@ -1302,6 +1379,9 @@ #if PIN_EXISTS(Z2_STEP) REPORT_NAME_DIGITAL(__LINE__, Z2_STEP_PIN) #endif +#if PIN_EXISTS(Z2_STOP) + REPORT_NAME_DIGITAL(__LINE__, Z2_STOP_PIN) +#endif #if PIN_EXISTS(Z3_CS) REPORT_NAME_DIGITAL(__LINE__, Z3_CS_PIN) #endif @@ -1584,6 +1664,24 @@ #if PIN_EXISTS(E7_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E7_SERIAL_RX_PIN) #endif +#if PIN_EXISTS(I_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, I_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(I_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, I_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(J_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, J_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(J_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, J_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(K_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, K_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(K_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, K_SERIAL_RX_PIN) +#endif #if PIN_EXISTS(L6470_CHAIN_SCK) REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_SCK_PIN) #endif diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index a2fe2b9af3..1e6703fd4a 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -419,6 +419,9 @@ #else #define X_STOP_PIN X_MAX_PIN #endif +#if !defined(X2_USE_ENDSTOP) && ENABLED(X_DUAL_ENDSTOPS) && PIN_EXISTS(X_STOP) + #define X2_USE_ENDSTOP _XSTOP_ +#endif #if HAS_Y_AXIS #ifdef Y_STOP_PIN @@ -438,6 +441,9 @@ #else #define Y_STOP_PIN Y_MAX_PIN #endif + #if !defined(Y2_USE_ENDSTOP) && ENABLED(Y_DUAL_ENDSTOPS) && PIN_EXISTS(Y_STOP) + #define Y2_USE_ENDSTOP _YSTOP_ + #endif #endif #if HAS_Z_AXIS @@ -458,6 +464,17 @@ #else #define Z_STOP_PIN Z_MAX_PIN #endif + #if ENABLED(Z_MULTI_ENDSTOPS) && PIN_EXISTS(Z_STOP) + #ifndef Z2_USE_ENDSTOP + #define Z2_USE_ENDSTOP _ZSTOP_ + #endif + #if NUM_Z_STEPPER_DRIVERS >= 3 && !defined(Z3_USE_ENDSTOP) + #define Z3_USE_ENDSTOP _ZSTOP_ + #endif + #if NUM_Z_STEPPER_DRIVERS >= 4 && !defined(Z4_USE_ENDSTOP) + #define Z4_USE_ENDSTOP _ZSTOP_ + #endif + #endif #endif #if LINEAR_AXES >= 4 @@ -801,7 +818,7 @@ #endif #endif // Auto-assign pins for stallGuard sensorless homing - #if !defined(Z2_DIAG_PIN) && !defined(Z2_USE_ENDSTOP) && defined(Z2_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 2 && _PEXI(Z2_E_INDEX, DIAG) + #if !defined(Z2_DIAG_PIN) && !defined(Z2_USE_ENDSTOP) && defined(Z2_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && _PEXI(Z2_E_INDEX, DIAG) #define Z2_DIAG_PIN _EPIN(Z2_E_INDEX, DIAG) #if DIAG_REMAPPED(Z2, X_MIN) #define Z2_USE_ENDSTOP _XMIN_ @@ -886,7 +903,7 @@ #endif #endif // Auto-assign pins for stallGuard sensorless homing - #if !defined(Z3_DIAG_PIN) && !defined(Z3_USE_ENDSTOP) && defined(Z3_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 && _PEXI(Z3_E_INDEX, DIAG) + #if !defined(Z3_DIAG_PIN) && !defined(Z3_USE_ENDSTOP) && defined(Z3_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && _PEXI(Z3_E_INDEX, DIAG) #define Z3_DIAG_PIN _EPIN(Z3_E_INDEX, DIAG) #if DIAG_REMAPPED(Z3, X_MIN) #define Z3_USE_ENDSTOP _XMIN_ @@ -971,7 +988,7 @@ #endif #endif // Auto-assign pins for stallGuard sensorless homing - #if !defined(Z4_DIAG_PIN) && !defined(Z4_USE_ENDSTOP) && defined(Z4_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 && _PEXI(Z4_E_INDEX, DIAG) + #if !defined(Z4_DIAG_PIN) && !defined(Z4_USE_ENDSTOP) && defined(Z4_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && _PEXI(Z4_E_INDEX, DIAG) #define Z4_DIAG_PIN _EPIN(Z4_E_INDEX, DIAG) #if DIAG_REMAPPED(Z4, X_MIN) #define Z4_USE_ENDSTOP _XMIN_ @@ -1260,22 +1277,22 @@ // Disable unused endstop / probe pins // #define _STOP_IN_USE(N) (X2_USE_ENDSTOP == N || Y2_USE_ENDSTOP == N || Z2_USE_ENDSTOP == N || Z3_USE_ENDSTOP == N || Z4_USE_ENDSTOP == N) -#if _STOP_IN_USE(_XMAX_) +#if !defined(USE_XMAX_PLUG) && _STOP_IN_USE(_XMAX_) #define USE_XMAX_PLUG #endif -#if _STOP_IN_USE(_YMAX_) +#if !defined(USE_YMAX_PLUG) && _STOP_IN_USE(_YMAX_) #define USE_YMAX_PLUG #endif -#if _STOP_IN_USE(_ZMAX_) +#if !defined(USE_ZMAX_PLUG) && _STOP_IN_USE(_ZMAX_) #define USE_ZMAX_PLUG #endif -#if _STOP_IN_USE(_XMIN_) +#if !defined(USE_XMIN_PLUG) && _STOP_IN_USE(_XMIN_) #define USE_XMIN_PLUG #endif -#if _STOP_IN_USE(_YMIN_) +#if !defined(USE_YMIN_PLUG) && _STOP_IN_USE(_YMIN_) #define USE_YMIN_PLUG #endif -#if _STOP_IN_USE(_ZMIN_) +#if !defined(USE_ZMIN_PLUG) && _STOP_IN_USE(_ZMIN_) #define USE_ZMIN_PLUG #endif #undef _STOP_IN_USE diff --git a/Marlin/src/pins/ramps/pins_K8600.h b/Marlin/src/pins/ramps/pins_K8600.h index f37516b710..0155129927 100644 --- a/Marlin/src/pins/ramps/pins_K8600.h +++ b/Marlin/src/pins/ramps/pins_K8600.h @@ -25,7 +25,7 @@ * VERTEX NANO Arduino Mega with RAMPS EFB v1.4 pin assignments. */ -#if HOTENDS > 1 +#if HAS_MULTI_HOTEND #error "Only 1 hotend is supported for Vertex Nano." #endif diff --git a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h index 3b2639b431..75ee01946a 100644 --- a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h +++ b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h @@ -28,7 +28,7 @@ #define REQUIRE_MEGA2560 #include "env_validate.h" -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "Longer3D LGT KIT V1.0 board only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h b/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h index ebd0bdc0c6..3583958906 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h @@ -21,7 +21,7 @@ */ #pragma once -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "Ender-4 only supports one hotend / E-stepper. Comment out this line to continue." #endif 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 48d38e2213..c132691c20 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 @@ -26,6 +26,8 @@ // Release PB3/PB4 (E0 STP/DIR) from JTAG pins #define DISABLE_JTAG +#define USES_DIAG_JUMPERS + // Ignore temp readings during development. //#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 diff --git a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h index f8e3e76ada..b0b201f1d5 100644 --- a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h +++ b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h @@ -23,7 +23,7 @@ #include "env_validate.h" -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "CCROBOT-ONLINE MEEB_3DP only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_V9.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_V9.h index eb7f91deab..0d02e1d5d9 100755 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_V9.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V9.h @@ -28,7 +28,11 @@ #define Z2_ENABLE_PIN PF3 #define Z2_STEP_PIN PF5 #define Z2_DIR_PIN PF1 +#define Z2_STOP_PIN PA13 +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PG9 +#endif #ifndef FIL_RUNOUT2_PIN #define FIL_RUNOUT2_PIN PF13 #endif diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index ea58b5b3a9..bf2a55fc7b 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -27,7 +27,7 @@ #include "env_validate.h" -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "Creality V4 only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h index 52ebdecc35..ae54805a94 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h @@ -27,7 +27,7 @@ #include "env_validate.h" -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "CREALITY supports up to 1 hotends / E-steppers. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h index 64e07a0bc8..a2add81c8b 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h @@ -25,7 +25,7 @@ * Creality v4.5.2 (STM32F103RET6) board pin assignments */ -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "Creality v4.5.2 only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h index ca437312c8..7b8c3280d2 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h @@ -25,7 +25,7 @@ * Creality v4.5.3 (STM32F103RET6) board pin assignments */ -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "Creality v4.5.3 only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h index 3b7a4e4402..e19d330092 100644 --- a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h +++ b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h @@ -31,7 +31,7 @@ #if NOT_TARGET(__STM32F1__, STM32F1xx) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" -#elif HOTENDS > 1 || E_STEPPERS > 1 +#elif HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "FLSUN HiSpeedV1 only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h index 98465a8607..beae0a3bf0 100644 --- a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h +++ b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h @@ -32,7 +32,7 @@ #include "env_validate.h" -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "JGAurora A5S A1 only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index 34fbdaf02f..3a8019a27e 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -27,7 +27,7 @@ #if NOT_TARGET(__STM32F1__, STM32F1xx) #error "Oops! Select a STM32F1 board in 'Tools > Board.'" -#elif HOTENDS > 1 || E_STEPPERS > 1 +#elif HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "Longer3D only supports one hotend / E-stepper. Comment out this line to continue." #endif @@ -89,9 +89,17 @@ #define HEATER_BED_PIN PA8 // pin 67 (Hot Bed Mosfet) #define FAN_PIN PA15 // pin 77 (4cm Fan) -#define FAN_SOFT_PWM // Required to avoid issues with heating or STLink -#define FAN_MIN_PWM 35 // Fan will not start in 1-30 range -#define FAN_MAX_PWM 255 +#ifdef MAPLE_STM32F1 + #define FAN_SOFT_PWM // Required to avoid issues with heating or STLink + #define FAN_MIN_PWM 35 // Fan will not start in 1-30 range + #define FAN_MAX_PWM 255 +#else + #define FAST_PWM_FAN // STM32 Variant allow TIMER2 Hardware PWM + #define FAST_PWM_FAN_FREQUENCY 31400 // This frequency allow a good range, fan starts at 3%, half noise at 50% + #define NEEDS_HARDWARE_PWM 1 + #define FAN_MIN_PWM 5 + #define FAN_MAX_PWM 255 +#endif //#define BEEPER_PIN PD13 // pin 60 (Servo PWM output 5V/GND on Board V0G+) made for BL-Touch sensor // Can drive a PC Buzzer, if connected between PWM and 5V pins diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3.h index 89ace3493f..6b05bb7a74 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3.h @@ -25,7 +25,7 @@ * MKS Robin E3 (STM32F103RCT6) board pin assignments */ -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "MKS Robin E3 only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3D.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3D.h index a629bce9f3..9d11af43ef 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3D.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3D.h @@ -25,7 +25,7 @@ * MKS Robin E3D (STM32F103RCT6) board pin assignments */ -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "MKS Robin E3D only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3D_V1_1.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3D_V1_1.h index 718f9dc27a..930ef9722d 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3D_V1_1.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3D_V1_1.h @@ -25,7 +25,7 @@ * MKS Robin E3D v1.1 (STM32F103RCT6) board pin assignments */ -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "MKS Robin E3D v1.1 only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h index c5080b5227..06b9721403 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h @@ -27,7 +27,7 @@ #include "env_validate.h" -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "MKS Robin E3P only supports one hotend / E-stepper. Comment out this line to continue." #elif HAS_FSMC_TFT #error "MKS Robin E3P doesn't support FSMC-based TFT displays." diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1.h index 30720e0c7f..7a38507c76 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1.h @@ -25,7 +25,7 @@ * MKS Robin E3 v1.1 (STM32F103RCT6) board pin assignments */ -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "MKS Robin E3 v1.1 only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h index dd1008ee3a..025c65a38b 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h @@ -27,10 +27,11 @@ #include "env_validate.h" -#define BOARD_NO_NATIVE_USB - #define BOARD_WEBSITE_URL "github.com/makerbase-mks" +#define BOARD_NO_NATIVE_USB +#define USES_DIAG_JUMPERS + //#define DISABLE_DEBUG #define DISABLE_JTAG @@ -54,8 +55,19 @@ // #define X_STOP_PIN PA12 #define Y_STOP_PIN PA11 -#define Z_MIN_PIN PC6 -#define Z_MAX_PIN PB1 +#define Z_STOP_PIN PC6 + +// +// Z Probe +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB1 +#endif + +// LED driving pin +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PA2 +#endif // // Steppers diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h index 3767748e53..94f7313996 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h @@ -23,7 +23,7 @@ #include "env_validate.h" -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "MKS Robin Lite only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h index ae45d8b6d1..c981fdc00a 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h @@ -27,7 +27,7 @@ #include "env_validate.h" -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "MKS Robin mini only supports one hotend / E-stepper. Comment out this line to continue." #endif 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 3df6727d03..1cdee92b08 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -36,6 +36,7 @@ #define BOARD_INFO_NAME "MKS Robin nano V2.0" #define BOARD_NO_NATIVE_USB +#define USES_DIAG_PINS // Avoid conflict with TIMER_SERVO when using the STM32 HAL #define TEMP_TIMER 5 diff --git a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h index 8343010432..eb3af65f32 100644 --- a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h +++ b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h @@ -23,7 +23,7 @@ #include "env_validate.h" -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "Anet ET4 only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h b/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h new file mode 100644 index 0000000000..4cf9768fbe --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h @@ -0,0 +1,182 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "env_validate.h" + +#if HOTENDS > 1 || E_STEPPERS > 1 + #error "Artillery Ruby supports up to 1 hotends / E-steppers." +#endif + +#define BOARD_INFO_NAME "Artillery Ruby" + +#define FLASH_EEPROM_EMULATION +//#define I2C_EEPROM +//#define E2END 0xFFF // 4KB + +#define HAL_TIMER_RATE F_CPU + +// +// Limit Switches +// +#if (X_HOME_DIR == 1) + #define X_MIN_PIN -1 + #define X_MAX_PIN PA2 +#else + #define X_MIN_PIN PA2 + #define X_MAX_PIN -1 +#endif +#if (Y_HOME_DIR == 1) + #define Y_MIN_PIN -1 + #define Y_MAX_PIN PA1 +#else + #define Y_MIN_PIN PA1 + #define Y_MAX_PIN -1 +#endif +#if (Z_HOME_DIR == 1) + #define Z_MIN_PIN PC2 + #define Z_MAX_PIN PA0 +#else + #define Z_MIN_PIN PA0 + #define Z_MAX_PIN PC2 +#endif + +// +// Steppers +// +#define X_STEP_PIN PB14 +#define X_DIR_PIN PB13 +#define X_ENABLE_PIN PB15 + +#define Y_STEP_PIN PB10 +#define Y_DIR_PIN PB2 +#define Y_ENABLE_PIN PB12 + +#define Z_STEP_PIN PB0 +#define Z_DIR_PIN PC5 +#define Z_ENABLE_PIN PB1 + +#define E0_STEP_PIN PA7 +#define E0_DIR_PIN PA6 +#define E0_ENABLE_PIN PC4 + +#define E1_STEP_PIN PA4 +#define E1_DIR_PIN PA3 +#define E1_ENABLE_PIN PA5 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC0 +#define TEMP_BED_PIN PC1 + +// +// Heaters / Fans +// +#ifndef HEATER_0_PIN + #define HEATER_0_PIN PC9 // Heater0 +#endif +#ifndef HEATER_BED_PIN + #define HEATER_BED_PIN PA8 // Hotbed +#endif +#ifndef FAN_PIN + #define FAN_PIN PC8 // Fan0 +#endif +#ifndef FAN1_PIN + #define FAN1_PIN PC7 // Fan1 +#endif +#ifndef FAN2_PIN + #define FAN2_PIN PC6 // Fan2 +#endif + +// +// Servos +// +#define SERVO0_PIN PC3 + +// +// SPI +// +#define SCK_PIN PC10 +#define MISO_PIN PC11 +#define MOSI_PIN PC12 + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) + #define LCD_PINS_DC PB8 // Set as output on init + #define LCD_PINS_RS PB9 // Pull low for 1s to init + // DOGM SPI LCD Support + #define DOGLCD_CS PC15 + #define DOGLCD_MOSI PB6 + #define DOGLCD_SCK PB5 + #define DOGLCD_A0 LCD_PINS_DC + #elif ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS PB6 + #define DOGLCD_A0 PC15 + + //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #define LCD_RESET_PIN PB5 // Must be high or open for LCD to operate normally. + + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN PB9 + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN PB8 + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN PB7 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN PB9 + #endif + + #define DEFAULT_LCD_CONTRAST 255 + #else + #define LCD_PINS_RS PC15 + #define LCD_PINS_ENABLE PB6 + #define LCD_PINS_D4 PB5 + #define LCD_PINS_D5 PB9 + #define LCD_PINS_D6 PB8 + #endif + + #define LCD_PINS_D7 PB7 + + // + // Beeper, SD Card, Encoder + // + #define BEEPER_PIN PC13 + + #if ENABLED(SDSUPPORT) + #define SDSS PA15 + #define SD_DETECT_PIN PD2 + #endif + + #define BTN_EN1 PB4 + #define BTN_EN2 PB3 + #define BTN_ENC PC14 +#endif diff --git a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h index d054e354f7..b7ffcce4a8 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -23,12 +23,17 @@ #include "env_validate.h" -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "BIGTREE BTT002 V1.0 only supports one hotend / E-stepper. Comment out this line to continue." #endif #define BOARD_INFO_NAME "BTT BTT002 V1.0" +#define USES_DIAG_PINS + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + // Use one of these or SDCard-based Emulation will be used #if NO_EEPROM_SELECTED //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation @@ -41,9 +46,6 @@ #define FLASH_EEPROM_LEVELING #endif -// Ignore temp readings during development. -//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 - // // Limit Switches // diff --git a/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h b/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h index bd483ecf0a..d1f38f5c80 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h @@ -29,6 +29,8 @@ #define BOARD_INFO_NAME "BTT E3 RRF" #endif +#define USES_DIAG_JUMPERS + // Add-on board for IDEX conversion //#define BTT_E3_RRF_IDEX_BOARD 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 95f74efe84..dfa9d8a7b9 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -31,15 +31,14 @@ #define BOARD_INFO_NAME "BTT GTR V1.0" +#define USES_DIAG_JUMPERS +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support +#define M5_EXTENDER // The M5 extender is attached + // Onboard I2C EEPROM #define I2C_EEPROM #define MARLIN_EEPROM_SIZE 0x2000 // 8KB (24C64 ... 64Kb = 8KB) -// USB Flash Drive support -#define HAS_OTG_USB_HOST_SUPPORT - -#define M5_EXTENDER // The M5 extender is attached - // // Servos // diff --git a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h index a93ed68201..fd367e87c0 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h @@ -32,6 +32,7 @@ #define TEMP_0_MISO_PIN PA6 #define TEMP_0_MOSI_PIN PA7 #define SOFTWARE_SPI // Max31865 and LCD SD share a set of SPIs, Set SD to softwareSPI for Max31865 + #define FORCE_SOFT_SPI #else #define TEMP_0_PIN PF4 // TH0 #endif diff --git a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h index 655e65da47..efeff04f25 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h @@ -23,15 +23,15 @@ #include "env_validate.h" +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support +#define USES_DIAG_JUMPERS + // Onboard I2C EEPROM #define I2C_EEPROM #define MARLIN_EEPROM_SIZE 0x8000 // 32KB (24C32A) #define I2C_SCL_PIN PB8 #define I2C_SDA_PIN PB9 -// USB Flash Drive support -#define HAS_OTG_USB_HOST_SUPPORT - // Avoid conflict with TIMER_TONE #define STEP_TIMER 10 @@ -168,13 +168,6 @@ #define POWER_LOSS_PIN PC0 // PWRDET #endif -// -// NeoPixel LED -// -#ifndef NEOPIXEL_PIN - #define NEOPIXEL_PIN PB0 -#endif - // // Steppers // @@ -524,6 +517,13 @@ #define BTN_ENC EXP1_09_PIN #endif +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PB0 +#endif + // // WIFI // diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h index 3314d0154d..ac049baa21 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -23,6 +23,8 @@ #include "env_validate.h" +#define USES_DIAG_JUMPERS + // If you have the BigTreeTech driver expansion module, enable BTT_MOTOR_EXPANSION // https://github.com/bigtreetech/BTT-Expansion-module/tree/master/BTT%20EXP-MOT //#define BTT_MOTOR_EXPANSION @@ -47,8 +49,7 @@ #define FLASH_EEPROM_LEVELING #endif -// USB Flash Drive support -#define HAS_OTG_USB_HOST_SUPPORT +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support // // Servos diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h index d3b59e03b8..9a280eac16 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h @@ -47,8 +47,7 @@ #define FLASH_EEPROM_LEVELING #endif -// USB Flash Drive support -#define HAS_OTG_USB_HOST_SUPPORT +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support // Avoid conflict with TIMER_TONE #define STEP_TIMER 10 @@ -294,14 +293,14 @@ #endif /** - * ----- ----- - * NC | 1 2 | GND 5V | 1 2 | GND - * RESET | 3 4 | PC4 (SD_DETECT) (LCD_D7) PE13 | 3 4 | PE12 (LCD_D6) - * (MOSI) PA7 | 5 6 PB2 (BTN_EN2) (LCD_D5) PE11 | 5 6 PE10 (LCD_D4) - * (SD_SS) PA4 | 7 8 | PE7 (BTN_EN1) (LCD_RS) PE9 | 7 8 | PB1 (LCD_EN) - * (SCK) PA5 | 9 10| PA6 (MISO) (BTN_ENC) PB0 | 9 10| PC5 (BEEPER) - * ----- ----- - * EXP2 EXP1 + * ------ ------ + * NC | 1 2 | GND 5V | 1 2 | GND + * RESET | 3 4 | PC4 (SD_DETECT) (LCD_D7) PE13 | 3 4 | PE12 (LCD_D6) + * (MOSI) PA7 | 5 6 PB2 (BTN_EN2) (LCD_D5) PE11 | 5 6 PE10 (LCD_D4) + * (SD_SS) PA4 | 7 8 | PE7 (BTN_EN1) (LCD_RS) PE9 | 7 8 | PB1 (LCD_EN) + * (SCK) PA5 | 9 10 | PA6 (MISO) (BTN_ENC) PB0 | 9 10 | PC5 (BEEPER) + * ------ ------ + * EXP2 EXP1 */ #define EXP1_03_PIN PE13 #define EXP1_04_PIN PE12 diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h index e2454b578d..37a48cab7f 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h @@ -128,7 +128,7 @@ #define Y_SERIAL_TX_PIN PE14 #endif #ifndef Y_SERIAL_RX_PIN - #define Y_SERIAL_RX_PIN PE13 + #define Y_SERIAL_RX_PIN PC4 #endif #ifndef Z_SERIAL_TX_PIN #define Z_SERIAL_TX_PIN PD11 diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_K.h b/Marlin/src/pins/stm32f4/pins_LERDGE_K.h index 6ad3849d11..099b3b79a4 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_K.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_K.h @@ -40,8 +40,7 @@ #define MARLIN_EEPROM_SIZE 0x10000 #endif -// USB Flash Drive support -#define HAS_OTG_USB_HOST_SUPPORT +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support // // Servos diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h index 68e5636955..c686e19ccb 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h @@ -34,8 +34,7 @@ #define STEP_TIMER 4 #define TEMP_TIMER 2 -// USB Flash Drive support -#define HAS_OTG_USB_HOST_SUPPORT +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support // // Servos diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_X.h b/Marlin/src/pins/stm32f4/pins_LERDGE_X.h index 12e47e35cc..93526db442 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_X.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_X.h @@ -24,7 +24,7 @@ #define ALLOW_STM32DUINO #include "env_validate.h" -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "LERDGE X only supports one hotend / E-stepper. Comment out this line to continue." #endif @@ -39,8 +39,7 @@ #define I2C_SDA_PIN PB9 #define MARLIN_EEPROM_SIZE 0x10000 // FM24CL64 F-RAM 64K (8Kx8) -// USB Flash Drive support -#define HAS_OTG_USB_HOST_SUPPORT +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support // // Servos diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h index 8fa211dc95..a7f853185e 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h @@ -32,8 +32,8 @@ #define BOARD_INFO_NAME "MKS Monster8 V1.x" -// USB Flash Drive support -#define HAS_OTG_USB_HOST_SUPPORT +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support +#define USES_DIAG_JUMPERS //#define DISABLE_DEBUG 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 4dc73e0312..02140865f9 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h @@ -32,22 +32,20 @@ #define BOARD_INFO_NAME "MKS Robin Nano V3" +#define USES_DIAG_JUMPERS + #ifndef X_CS_PIN #define X_CS_PIN PD5 #endif - #ifndef Y_CS_PIN #define Y_CS_PIN PD7 #endif - #ifndef Z_CS_PIN #define Z_CS_PIN PD4 #endif - #ifndef E0_CS_PIN #define E0_CS_PIN PD9 #endif - #ifndef E1_CS_PIN #define E1_CS_PIN PD8 #endif diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h index c3e3963b55..256439e654 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h @@ -26,8 +26,7 @@ // MKS Robin Nano V3, MKS Eagle pinmap // -// USB Flash Drive support -#define HAS_OTG_USB_HOST_SUPPORT +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support // Avoid conflict with TIMER_TONE #define STEP_TIMER 10 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 46dec71c11..68b2385254 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -39,8 +39,7 @@ #define I2C_EEPROM #define MARLIN_EEPROM_SIZE 0x1000 // 4KB -// USB Flash Drive support -#define HAS_OTG_USB_HOST_SUPPORT +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role diff --git a/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_LITE_V2.h b/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h similarity index 99% rename from Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_LITE_V2.h rename to Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h index bff3f5b6ee..6368142c34 100644 --- a/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_LITE_V2.h +++ b/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h @@ -24,7 +24,7 @@ #define ALLOW_STM32DUINO #include "env_validate.h" -#define BOARD_INFO_NAME "TH3D EZBoard Lite V2" +#define BOARD_INFO_NAME "TH3D EZBoard V2" #define BOARD_WEBSITE_URL "th3dstudio.com" //#define V3_EZABL_ON_SERVO // As in TH3D Firmware Config diff --git a/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h b/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h index 133dcd2935..dbf2593c48 100644 --- a/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h +++ b/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h @@ -32,7 +32,7 @@ #define SRAM_EEPROM_EMULATION // Emulate the EEPROM using Backup SRAM #endif -#if HOTENDS > 1 || E_STEPPERS > 1 +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "RemRam only supports one hotend / E-stepper. Comment out this line to continue." #endif diff --git a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h index 991c611a89..9eb0acf144 100644 --- a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h @@ -32,8 +32,7 @@ #define I2C_EEPROM #define MARLIN_EEPROM_SIZE 0x1000 // 4KB (24C32 ... 32Kb = 4KB) -// USB Flash Drive support -#define HAS_OTG_USB_HOST_SUPPORT +#define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support // // Limit Switches diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 1ab6dcc7c6..513d682de6 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -72,8 +72,8 @@ char CardReader::filename[FILENAME_LENGTH], CardReader::longFilename[LONG_FILENA IF_DISABLED(NO_SD_AUTOSTART, uint8_t CardReader::autofile_index); // = 0 -#if BOTH(HAS_MULTI_SERIAL, BINARY_FILE_TRANSFER) - serial_index_t CardReader::transfer_port_index; +#if ENABLED(BINARY_FILE_TRANSFER) + serial_index_t IF_DISABLED(HAS_MULTI_SERIAL, constexpr) CardReader::transfer_port_index; #endif // private: diff --git a/buildroot/share/PlatformIO/boards/marlin_Artillery_Ruby.json b/buildroot/share/PlatformIO/boards/marlin_Artillery_Ruby.json new file mode 100644 index 0000000000..e1c8333800 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_Artillery_Ruby.json @@ -0,0 +1,60 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F401xx", + "f_cpu": "84000000L", + "hwids": [ + [ + "0x0483", + "0xDF11" + ] + ], + "mcu": "stm32f401rct6", + "variant": "MARLIN_ARTILLERY_RUBY" + }, + "debug": { + "jlink_device": "STM32F401RC", + "openocd_target": "stm32f4x", + "svd_path": "STM32F40x.svd", + "tools": { + "stlink": { + "server": { + "arguments": [ + "-f", + "scripts/interface/stlink.cfg", + "-c", + "transport select hla_swd", + "-f", + "scripts/target/stm32f4x.cfg", + "-c", + "reset_config none" + ], + "executable": "bin/openocd", + "package": "tool-openocd" + } + } + } + }, + "frameworks": [ + "arduino", + "stm32cube" + ], + "name": "STM32F401RC (64k RAM. 256k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 65536, + "maximum_size": 262144, + "protocol": "stlink", + "protocols": [ + "stlink", + "dfu", + "jlink" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.st.com/en/evaluation-tools/steval-3dp001v1.html", + "vendor": "Generic" +} diff --git a/buildroot/share/PlatformIO/debugging/launch.json b/buildroot/share/PlatformIO/debugging/launch.json new file mode 100644 index 0000000000..335c4c663e --- /dev/null +++ b/buildroot/share/PlatformIO/debugging/launch.json @@ -0,0 +1,48 @@ +/** + * Remote debugging on STM32 using the "Cortex Debug" extension. + * + * Copy one or more of the configurations items below into .vscode/launch.json + * to add those debug options to the PlatformIO IDE "Run & Debug" panel. + * + * Examples for BigTreeTech SKR 2 (USB) and Native Simulator. Modify for your own build. + * + * NOTE: The PlatformIO extension will remove items when regenerating launch.json. + */ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug STM32 (launch)", + "request": "launch", + "type": "cortex-debug", + "servertype": "openocd", + "cwd": "${workspaceRoot}", + "showDevDebugOutput": false, + "configFiles": [ "interface/stlink.cfg", "target/stm32f4x.cfg" ], + "device": "STM32F407", + "executable": ".pio/build/BIGTREE_SKR_2_USB_debug/firmware.elf", + }, + { + "name": "Debug STM32 (attach)", + "request": "attach", + "type": "cortex-debug", + "servertype": "openocd", + "cwd": "${workspaceRoot}", + "showDevDebugOutput": false, + "configFiles": [ "interface/stlink.cfg", "target/stm32f4x.cfg" ], + "device": "STM32F407", + "executable": ".pio/build/BIGTREE_SKR_2_USB_debug/firmware.elf", + }, + { + "name": "Debug Sim", + "request": "launch", + "type": "cppdbg", + "cwd": "${workspaceRoot}", + //"program": ".pio/build/simulator_linux_debug/MarlinSimulator", + //"program": ".pio/build/simulator_windows/MarlinSimulator", + "program": ".pio/build/simulator_macos_debug/MarlinSimulator", + "miDebuggerPath": "/opt/local/bin/ggdb", + "MIMode": "gdb" + } + ] +} diff --git a/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py b/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py index 9e37024d11..be2c87266a 100644 --- a/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py +++ b/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py @@ -2,18 +2,20 @@ # SAMD51_grandcentral_m4.py # Customizations for env:SAMD51_grandcentral_m4 # -from os.path import join, isfile -import shutil -from pprint import pprint +import pioutil +if pioutil.is_pio_build(): + from os.path import join, isfile + import shutil + from pprint import pprint -Import("env") + Import("env") -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" + 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" -serialBuf = str(max(int(rxBuf), int(txBuf), 350)) + serialBuf = str(max(int(rxBuf), int(txBuf), 350)) -build_flags = env.get('BUILD_FLAGS') -build_flags.append("-DSERIAL_BUFFER_SIZE=" + serialBuf) -env.Replace(BUILD_FLAGS=build_flags) + build_flags = env.get('BUILD_FLAGS') + build_flags.append("-DSERIAL_BUFFER_SIZE=" + serialBuf) + env.Replace(BUILD_FLAGS=build_flags) diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py b/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py index 03e121c435..eccee76068 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py @@ -1,58 +1,43 @@ # -# buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py +# STM32F103RC_MEEB_3DP.py # -try: - import configparser -except ImportError: - import ConfigParser as configparser +import pioutil +if pioutil.is_pio_build(): -import os -Import("env", "projenv") -# access to global build environment -print(env) -# access to project build environment (is used source files in "src" folder) -print(projenv) + try: + import configparser + except ImportError: + import ConfigParser as configparser -config = configparser.ConfigParser() -config.read("platformio.ini") + import os + Import("env", "projenv") -#com_port = config.get("env:STM32F103RC_meeb", "upload_port") -#print('Use the {0:s} to reboot the board to dfu mode.'.format(com_port)) + config = configparser.ConfigParser() + config.read("platformio.ini") -# -# Upload actions -# + # + # Upload actions + # + def before_upload(source, target, env): + env.Execute("pwd") -def before_upload(source, target, env): - print("before_upload") - # do some actions - # use com_port - # - env.Execute("pwd") + def after_upload(source, target, env): + env.Execute("pwd") -def after_upload(source, target, env): - print("after_upload") - # do some actions - # - # - env.Execute("pwd") + env.AddPreAction("upload", before_upload) + env.AddPostAction("upload", after_upload) -print("Current build targets", map(str, BUILD_TARGETS)) + flash_size = 0 + vect_tab_addr = 0 -env.AddPreAction("upload", before_upload) -env.AddPostAction("upload", after_upload) + for define in env['CPPDEFINES']: + if define[0] == "VECT_TAB_ADDR": + vect_tab_addr = define[1] + if define[0] == "STM32_FLASH_SIZE": + flash_size = define[1] -flash_size = 0 -vect_tab_addr = 0 + print('Use the {0:s} address as the marlin app entry point.'.format(vect_tab_addr)) + print('Use the {0:d}KB flash version of stm32f103rct6 chip.'.format(flash_size)) -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - vect_tab_addr = define[1] - if define[0] == "STM32_FLASH_SIZE": - flash_size = define[1] - -print('Use the {0:s} address as the marlin app entry point.'.format(vect_tab_addr)) -print('Use the {0:d}KB flash version of stm32f103rct6 chip.'.format(flash_size)) - -import marlin -marlin.custom_ld_script("STM32F103RC_MEEB_3DP.ld") + import marlin + marlin.custom_ld_script("STM32F103RC_MEEB_3DP.ld") diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py b/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py index 668475dc01..c9794702c3 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py @@ -1,26 +1,28 @@ # -# buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py +# STM32F103RC_fysetc.py # -import os -from os.path import join -from os.path import expandvars -Import("env") +import pioutil +if pioutil.is_pio_build(): + import os + from os.path import join + from os.path import expandvars + Import("env") -# Custom HEX from ELF -env.AddPostAction( - join("$BUILD_DIR", "${PROGNAME}.elf"), - env.VerboseAction(" ".join([ - "$OBJCOPY", "-O ihex", "$TARGET", - "\"" + join("$BUILD_DIR", "${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path - ]), "Building $TARGET")) + # Custom HEX from ELF + env.AddPostAction( + join("$BUILD_DIR", "${PROGNAME}.elf"), + env.VerboseAction(" ".join([ + "$OBJCOPY", "-O ihex", "$TARGET", + "\"" + join("$BUILD_DIR", "${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path + ]), "Building $TARGET")) -# In-line command with arguments -UPLOAD_TOOL="stm32flash" -platform = env.PioPlatform() -if platform.get_package_dir("tool-stm32duino") != None: - UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"") + # In-line command with arguments + UPLOAD_TOOL="stm32flash" + platform = env.PioPlatform() + if platform.get_package_dir("tool-stm32duino") != None: + UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"") -env.Replace( - UPLOADER=UPLOAD_TOOL, - UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr -R -b 115200 -g 0x8000000 -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"" + " $UPLOAD_PORT") -) + env.Replace( + UPLOADER=UPLOAD_TOOL, + UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr -R -b 115200 -g 0x8000000 -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"" + " $UPLOAD_PORT") + ) diff --git a/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py b/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py index 0a38e1ceee..592fa50e5e 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py @@ -1,30 +1,32 @@ # # STM32F1_create_variant.py # -import os,shutil,marlin -from SCons.Script import DefaultEnvironment -from platformio import util +import pioutil +if pioutil.is_pio_build(): + import os,shutil,marlin + from SCons.Script import DefaultEnvironment + from platformio import util -env = DefaultEnvironment() -platform = env.PioPlatform() -board = env.BoardConfig() + env = DefaultEnvironment() + platform = env.PioPlatform() + board = env.BoardConfig() -FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32-maple") -assert os.path.isdir(FRAMEWORK_DIR) + FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32-maple") + assert os.path.isdir(FRAMEWORK_DIR) -source_root = os.path.join("buildroot", "share", "PlatformIO", "variants") -assert os.path.isdir(source_root) + source_root = os.path.join("buildroot", "share", "PlatformIO", "variants") + assert os.path.isdir(source_root) -variant = board.get("build.variant") -variant_dir = os.path.join(FRAMEWORK_DIR, "STM32F1", "variants", variant) + variant = board.get("build.variant") + variant_dir = os.path.join(FRAMEWORK_DIR, "STM32F1", "variants", variant) -source_dir = os.path.join(source_root, variant) -assert os.path.isdir(source_dir) + source_dir = os.path.join(source_root, variant) + assert os.path.isdir(source_dir) -if os.path.isdir(variant_dir): - shutil.rmtree(variant_dir) + if os.path.isdir(variant_dir): + shutil.rmtree(variant_dir) -if not os.path.isdir(variant_dir): - os.mkdir(variant_dir) + if not os.path.isdir(variant_dir): + os.mkdir(variant_dir) -marlin.copytree(source_dir, variant_dir) + marlin.copytree(source_dir, variant_dir) diff --git a/buildroot/share/PlatformIO/scripts/add_nanolib.py b/buildroot/share/PlatformIO/scripts/add_nanolib.py index 3b74b0d271..f5166d7d84 100644 --- a/buildroot/share/PlatformIO/scripts/add_nanolib.py +++ b/buildroot/share/PlatformIO/scripts/add_nanolib.py @@ -2,4 +2,5 @@ # add_nanolib.py # Import("env") + env.Append(LINKFLAGS=["--specs=nano.specs"]) diff --git a/buildroot/share/PlatformIO/scripts/chitu_crypt.py b/buildroot/share/PlatformIO/scripts/chitu_crypt.py index 23d81c1721..b28156bfb9 100644 --- a/buildroot/share/PlatformIO/scripts/chitu_crypt.py +++ b/buildroot/share/PlatformIO/scripts/chitu_crypt.py @@ -1,116 +1,117 @@ # -# buildroot/share/PlatformIO/scripts/chitu_crypt.py +# chitu_crypt.py # Customizations for Chitu boards # -import os,random,struct,uuid,marlin +import pioutil +if pioutil.is_pio_build(): + import os,random,struct,uuid,marlin + # Relocate firmware from 0x08000000 to 0x08008800 + marlin.relocate_firmware("0x08008800") -# Relocate firmware from 0x08000000 to 0x08008800 -marlin.relocate_firmware("0x08008800") + def calculate_crc(contents, seed): + accumulating_xor_value = seed; -def calculate_crc(contents, seed): - accumulating_xor_value = seed; + for i in range(0, len(contents), 4): + value = struct.unpack('> ip - # shift the xor_seed left by the bits in IP. - xor_seed = xor_seed >> ip + # load a byte into IP + ip = r0[loop_counter] - # load a byte into IP - ip = r0[loop_counter] + # XOR the seed with r7 + xor_seed = xor_seed ^ r7 - # XOR the seed with r7 - xor_seed = xor_seed ^ r7 + # and then with IP + xor_seed = xor_seed ^ ip - # and then with IP - xor_seed = xor_seed ^ ip + #Now store the byte back + r1[loop_counter] = xor_seed & 0xFF - #Now store the byte back - r1[loop_counter] = xor_seed & 0xFF + #increment the loop_counter + loop_counter = loop_counter + 1 - #increment the loop_counter - loop_counter = loop_counter + 1 + def encrypt_file(input, output_file, file_length): + input_file = bytearray(input.read()) + block_size = 0x800 + key_length = 0x18 -def encrypt_file(input, output_file, file_length): - input_file = bytearray(input.read()) - block_size = 0x800 - key_length = 0x18 + uid_value = uuid.uuid4() + file_key = int(uid_value.hex[0:8], 16) - uid_value = uuid.uuid4() - file_key = int(uid_value.hex[0:8], 16) + xor_crc = 0xEF3D4323; - xor_crc = 0xEF3D4323; + # the input file is exepcted to be in chunks of 0x800 + # so round the size + while len(input_file) % block_size != 0: + input_file.extend(b'0x0') - # the input file is exepcted to be in chunks of 0x800 - # so round the size - while len(input_file) % block_size != 0: - input_file.extend(b'0x0') + # write the file header + output_file.write(struct.pack(">I", 0x443D2D3F)) + # encrypt the contents using a known file header key - # write the file header - output_file.write(struct.pack(">I", 0x443D2D3F)) - # encrypt the contents using a known file header key + # write the file_key + output_file.write(struct.pack("= level: - print("[deps] %s" % str) + def validate_pio(): + PIO_VERSION_MIN = (5, 0, 3) + try: + from platformio import VERSION as PIO_VERSION + weights = (1000, 100, 1) + version_min = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION_MIN)]) + version_cur = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION)]) + if version_cur < version_min: + print() + print("**************************************************") + print("****** An update to PlatformIO is ******") + print("****** required to build Marlin Firmware. ******") + print("****** ******") + print("****** Minimum version: ", PIO_VERSION_MIN, " ******") + print("****** Current Version: ", PIO_VERSION, " ******") + print("****** ******") + print("****** Update PlatformIO and try again. ******") + print("**************************************************") + print() + exit(1) + except SystemExit: + exit(1) + except: + print("Can't detect PlatformIO Version") -FEATURE_CONFIG = {} + def blab(str,level=1): + if verbose >= level: + print("[deps] %s" % str) -def add_to_feat_cnf(feature, flines): + def add_to_feat_cnf(feature, flines): - try: - feat = FEATURE_CONFIG[feature] - except: - FEATURE_CONFIG[feature] = {} - - # Get a reference to the FEATURE_CONFIG under construction - feat = FEATURE_CONFIG[feature] - - # Split up passed lines on commas or newlines and iterate - # Add common options to the features config under construction - # For lib_deps replace a previous instance of the same library - atoms = re.sub(r',\\s*', '\n', flines).strip().split('\n') - for line in atoms: - parts = line.split('=') - name = parts.pop(0) - if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']: - feat[name] = '='.join(parts) - blab("[%s] %s=%s" % (feature, name, feat[name]), 3) - else: - for dep in re.split(r",\s*", line): - lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0) - lib_re = re.compile('(?!^' + lib_name + '\\b)') - feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep] - blab("[%s] lib_deps = %s" % (feature, dep), 3) - -def load_config(): - blab("========== Gather [features] entries...") - items = ProjectConfig().items('features') - for key in items: - feature = key[0].upper() - if not feature in FEATURE_CONFIG: - FEATURE_CONFIG[feature] = { 'lib_deps': [] } - add_to_feat_cnf(feature, key[1]) - - # Add options matching custom_marlin.MY_OPTION to the pile - blab("========== Gather custom_marlin entries...") - all_opts = env.GetProjectOptions() - for n in all_opts: - key = n[0] - mat = re.match(r'custom_marlin\.(.+)', key) - if mat: - try: - val = env.GetProjectOption(key) - except: - val = None - if val: - opt = mat.group(1).upper() - blab("%s.custom_marlin.%s = '%s'" % ( env['PIOENV'], opt, val )) - add_to_feat_cnf(opt, val) - -def get_all_known_libs(): - known_libs = [] - for feature in FEATURE_CONFIG: - feat = FEATURE_CONFIG[feature] - if not 'lib_deps' in feat: - continue - for dep in feat['lib_deps']: - known_libs.append(PackageSpec(dep).name) - return known_libs - -def get_all_env_libs(): - env_libs = [] - lib_deps = env.GetProjectOption('lib_deps') - for dep in lib_deps: - env_libs.append(PackageSpec(dep).name) - return env_libs - -def set_env_field(field, value): - proj = env.GetProjectConfig() - proj.set("env:" + env['PIOENV'], field, value) - -# All unused libs should be ignored so that if a library -# exists in .pio/lib_deps it will not break compilation. -def force_ignore_unused_libs(): - env_libs = get_all_env_libs() - known_libs = get_all_known_libs() - diff = (list(set(known_libs) - set(env_libs))) - lib_ignore = env.GetProjectOption('lib_ignore') + diff - blab("Ignore libraries: %s" % lib_ignore) - set_env_field('lib_ignore', lib_ignore) - -def apply_features_config(): - load_config() - blab("========== Apply enabled features...") - for feature in FEATURE_CONFIG: - if not env.MarlinFeatureIsEnabled(feature): - continue + try: + feat = FEATURE_CONFIG[feature] + except: + FEATURE_CONFIG[feature] = {} + # Get a reference to the FEATURE_CONFIG under construction feat = FEATURE_CONFIG[feature] - if 'lib_deps' in feat and len(feat['lib_deps']): - blab("========== Adding lib_deps for %s... " % feature, 2) + # Split up passed lines on commas or newlines and iterate + # Add common options to the features config under construction + # For lib_deps replace a previous instance of the same library + atoms = re.sub(r',\\s*', '\n', flines).strip().split('\n') + for line in atoms: + parts = line.split('=') + name = parts.pop(0) + if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']: + feat[name] = '='.join(parts) + blab("[%s] %s=%s" % (feature, name, feat[name]), 3) + else: + for dep in re.split(r",\s*", line): + lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0) + lib_re = re.compile('(?!^' + lib_name + '\\b)') + feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep] + blab("[%s] lib_deps = %s" % (feature, dep), 3) - # feat to add - deps_to_add = {} + def load_config(): + blab("========== Gather [features] entries...") + items = ProjectConfig().items('features') + for key in items: + feature = key[0].upper() + if not feature in FEATURE_CONFIG: + FEATURE_CONFIG[feature] = { 'lib_deps': [] } + add_to_feat_cnf(feature, key[1]) + + # Add options matching custom_marlin.MY_OPTION to the pile + blab("========== Gather custom_marlin entries...") + all_opts = env.GetProjectOptions() + for n in all_opts: + key = n[0] + mat = re.match(r'custom_marlin\.(.+)', key) + if mat: + try: + val = env.GetProjectOption(key) + except: + val = None + if val: + opt = mat.group(1).upper() + blab("%s.custom_marlin.%s = '%s'" % ( env['PIOENV'], opt, val )) + add_to_feat_cnf(opt, val) + + def get_all_known_libs(): + known_libs = [] + for feature in FEATURE_CONFIG: + feat = FEATURE_CONFIG[feature] + if not 'lib_deps' in feat: + continue for dep in feat['lib_deps']: - deps_to_add[PackageSpec(dep).name] = dep - blab("==================== %s... " % dep, 2) + known_libs.append(PackageSpec(dep).name) + return known_libs - # Does the env already have the dependency? - deps = env.GetProjectOption('lib_deps') - for dep in deps: - name = PackageSpec(dep).name - if name in deps_to_add: - del deps_to_add[name] + def get_all_env_libs(): + env_libs = [] + lib_deps = env.GetProjectOption('lib_deps') + for dep in lib_deps: + env_libs.append(PackageSpec(dep).name) + return env_libs - # Are there any libraries that should be ignored? - lib_ignore = env.GetProjectOption('lib_ignore') - for dep in deps: - name = PackageSpec(dep).name - if name in deps_to_add: - del deps_to_add[name] + def set_env_field(field, value): + proj = env.GetProjectConfig() + proj.set("env:" + env['PIOENV'], field, value) - # Is there anything left? - if len(deps_to_add) > 0: - # Only add the missing dependencies - set_env_field('lib_deps', deps + list(deps_to_add.values())) + # All unused libs should be ignored so that if a library + # exists in .pio/lib_deps it will not break compilation. + def force_ignore_unused_libs(): + env_libs = get_all_env_libs() + known_libs = get_all_known_libs() + diff = (list(set(known_libs) - set(env_libs))) + lib_ignore = env.GetProjectOption('lib_ignore') + diff + blab("Ignore libraries: %s" % lib_ignore) + set_env_field('lib_ignore', lib_ignore) - if 'build_flags' in feat: - f = feat['build_flags'] - blab("========== Adding build_flags for %s: %s" % (feature, f), 2) - new_flags = env.GetProjectOption('build_flags') + [ f ] - env.Replace(BUILD_FLAGS=new_flags) + def apply_features_config(): + load_config() + blab("========== Apply enabled features...") + for feature in FEATURE_CONFIG: + if not env.MarlinFeatureIsEnabled(feature): + continue - if 'extra_scripts' in feat: - blab("Running extra_scripts for %s... " % feature, 2) - env.SConscript(feat['extra_scripts'], exports="env") + feat = FEATURE_CONFIG[feature] - if 'src_filter' in feat: - blab("========== Adding src_filter for %s... " % feature, 2) - src_filter = ' '.join(env.GetProjectOption('src_filter')) - # first we need to remove the references to the same folder - my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter']) - cur_srcs = re.findall(r'[+-](<.*?>)', src_filter) - for d in my_srcs: - if d in cur_srcs: - src_filter = re.sub(r'[+-]' + d, '', src_filter) + if 'lib_deps' in feat and len(feat['lib_deps']): + blab("========== Adding lib_deps for %s... " % feature, 2) - src_filter = feat['src_filter'] + ' ' + src_filter - set_env_field('src_filter', [src_filter]) - env.Replace(SRC_FILTER=src_filter) + # feat to add + deps_to_add = {} + for dep in feat['lib_deps']: + deps_to_add[PackageSpec(dep).name] = dep + blab("==================== %s... " % dep, 2) - if 'lib_ignore' in feat: - blab("========== Adding lib_ignore for %s... " % feature, 2) - lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']] - set_env_field('lib_ignore', lib_ignore) + # Does the env already have the dependency? + deps = env.GetProjectOption('lib_deps') + for dep in deps: + name = PackageSpec(dep).name + if name in deps_to_add: + del deps_to_add[name] -# -# Find a compiler, considering the OS -# -ENV_BUILD_PATH = os.path.join(env.Dictionary('PROJECT_BUILD_DIR'), env['PIOENV']) -GCC_PATH_CACHE = os.path.join(ENV_BUILD_PATH, ".gcc_path") -def search_compiler(): - try: - filepath = env.GetProjectOption('custom_gcc') - blab("Getting compiler from env") + # Are there any libraries that should be ignored? + lib_ignore = env.GetProjectOption('lib_ignore') + for dep in deps: + name = PackageSpec(dep).name + if name in deps_to_add: + del deps_to_add[name] + + # Is there anything left? + if len(deps_to_add) > 0: + # Only add the missing dependencies + set_env_field('lib_deps', deps + list(deps_to_add.values())) + + if 'build_flags' in feat: + f = feat['build_flags'] + blab("========== Adding build_flags for %s: %s" % (feature, f), 2) + new_flags = env.GetProjectOption('build_flags') + [ f ] + env.Replace(BUILD_FLAGS=new_flags) + + if 'extra_scripts' in feat: + blab("Running extra_scripts for %s... " % feature, 2) + env.SConscript(feat['extra_scripts'], exports="env") + + if 'src_filter' in feat: + blab("========== Adding src_filter for %s... " % feature, 2) + src_filter = ' '.join(env.GetProjectOption('src_filter')) + # first we need to remove the references to the same folder + my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter']) + cur_srcs = re.findall(r'[+-](<.*?>)', src_filter) + for d in my_srcs: + if d in cur_srcs: + src_filter = re.sub(r'[+-]' + d, '', src_filter) + + src_filter = feat['src_filter'] + ' ' + src_filter + set_env_field('src_filter', [src_filter]) + env.Replace(SRC_FILTER=src_filter) + + if 'lib_ignore' in feat: + blab("========== Adding lib_ignore for %s... " % feature, 2) + lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']] + set_env_field('lib_ignore', lib_ignore) + + # + # Find a compiler, considering the OS + # + ENV_BUILD_PATH = os.path.join(env.Dictionary('PROJECT_BUILD_DIR'), env['PIOENV']) + GCC_PATH_CACHE = os.path.join(ENV_BUILD_PATH, ".gcc_path") + def search_compiler(): + try: + filepath = env.GetProjectOption('custom_gcc') + blab("Getting compiler from env") + return filepath + except: + pass + + if os.path.exists(GCC_PATH_CACHE): + with open(GCC_PATH_CACHE, 'r') as f: + return f.read() + + # Find the current platform compiler by searching the $PATH + # which will be in a platformio toolchain bin folder + path_regex = re.escape(env['PROJECT_PACKAGES_DIR']) + + # See if the environment provides a default compiler + try: + gcc = env.GetProjectOption('custom_deps_gcc') + except: + gcc = "g++" + + if env['PLATFORM'] == 'win32': + path_separator = ';' + path_regex += r'.*\\bin' + gcc += ".exe" + else: + path_separator = ':' + path_regex += r'/.+/bin' + + # Search for the compiler + for pathdir in env['ENV']['PATH'].split(path_separator): + if not re.search(path_regex, pathdir, re.IGNORECASE): + continue + for filepath in os.listdir(pathdir): + if not filepath.endswith(gcc): + continue + # Use entire path to not rely on env PATH + filepath = os.path.sep.join([pathdir, filepath]) + # Cache the g++ path to no search always + if os.path.exists(ENV_BUILD_PATH): + with open(GCC_PATH_CACHE, 'w+') as f: + f.write(filepath) + + return filepath + + filepath = env.get('CXX') + if filepath == 'CC': + filepath = gcc + blab("Couldn't find a compiler! Fallback to %s" % filepath) return filepath + + # + # Use the compiler to get a list of all enabled features + # + def load_marlin_features(): + if 'MARLIN_FEATURES' in env: + return + + # Process defines + build_flags = env.get('BUILD_FLAGS') + build_flags = env.ParseFlagsExtended(build_flags) + + cxx = search_compiler() + cmd = ['"' + cxx + '"'] + + # Build flags from board.json + #if 'BOARD' in env: + # cmd += [env.BoardConfig().get("build.extra_flags")] + for s in build_flags['CPPDEFINES']: + if isinstance(s, tuple): + cmd += ['-D' + s[0] + '=' + str(s[1])] + else: + cmd += ['-D' + s] + + cmd += ['-D__MARLIN_DEPS__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h'] + cmd = ' '.join(cmd) + blab(cmd, 4) + define_list = subprocess.check_output(cmd, shell=True).splitlines() + marlin_features = {} + for define in define_list: + feature = define[8:].strip().decode().split(' ') + feature, definition = feature[0], ' '.join(feature[1:]) + marlin_features[feature] = definition + env['MARLIN_FEATURES'] = marlin_features + + # + # Return True if a matching feature is enabled + # + def MarlinFeatureIsEnabled(env, feature): + load_marlin_features() + r = re.compile('^' + feature + '$') + found = list(filter(r.match, env['MARLIN_FEATURES'])) + + # Defines could still be 'false' or '0', so check + some_on = False + if len(found): + for f in found: + val = env['MARLIN_FEATURES'][f] + if val in [ '', '1', 'true' ]: + some_on = True + elif val in env['MARLIN_FEATURES']: + some_on = env.MarlinFeatureIsEnabled(val) + + return some_on + + validate_pio() + + try: + verbose = int(env.GetProjectOption('custom_verbose')) except: pass - if os.path.exists(GCC_PATH_CACHE): - with open(GCC_PATH_CACHE, 'r') as f: - return f.read() + # Add a method for other PIO scripts to query enabled features + env.AddMethod(MarlinFeatureIsEnabled) - # Find the current platform compiler by searching the $PATH - # which will be in a platformio toolchain bin folder - path_regex = re.escape(env['PROJECT_PACKAGES_DIR']) - - # See if the environment provides a default compiler - try: - gcc = env.GetProjectOption('custom_deps_gcc') - except: - gcc = "g++" - - if env['PLATFORM'] == 'win32': - path_separator = ';' - path_regex += r'.*\\bin' - gcc += ".exe" - else: - path_separator = ':' - path_regex += r'/.+/bin' - - # Search for the compiler - for pathdir in env['ENV']['PATH'].split(path_separator): - if not re.search(path_regex, pathdir, re.IGNORECASE): - continue - for filepath in os.listdir(pathdir): - if not filepath.endswith(gcc): - continue - # Use entire path to not rely on env PATH - filepath = os.path.sep.join([pathdir, filepath]) - # Cache the g++ path to no search always - if os.path.exists(ENV_BUILD_PATH): - with open(GCC_PATH_CACHE, 'w+') as f: - f.write(filepath) - - return filepath - - filepath = env.get('CXX') - if filepath == 'CC': - filepath = gcc - blab("Couldn't find a compiler! Fallback to %s" % filepath) - return filepath - -# -# Use the compiler to get a list of all enabled features -# -def load_marlin_features(): - if 'MARLIN_FEATURES' in env: - return - - # Process defines - build_flags = env.get('BUILD_FLAGS') - build_flags = env.ParseFlagsExtended(build_flags) - - cxx = search_compiler() - cmd = ['"' + cxx + '"'] - - # Build flags from board.json - #if 'BOARD' in env: - # cmd += [env.BoardConfig().get("build.extra_flags")] - for s in build_flags['CPPDEFINES']: - if isinstance(s, tuple): - cmd += ['-D' + s[0] + '=' + str(s[1])] - else: - cmd += ['-D' + s] - - cmd += ['-D__MARLIN_DEPS__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h'] - cmd = ' '.join(cmd) - blab(cmd, 4) - define_list = subprocess.check_output(cmd, shell=True).splitlines() - marlin_features = {} - for define in define_list: - feature = define[8:].strip().decode().split(' ') - feature, definition = feature[0], ' '.join(feature[1:]) - marlin_features[feature] = definition - env['MARLIN_FEATURES'] = marlin_features - -# -# Return True if a matching feature is enabled -# -def MarlinFeatureIsEnabled(env, feature): - load_marlin_features() - r = re.compile('^' + feature + '$') - found = list(filter(r.match, env['MARLIN_FEATURES'])) - - # Defines could still be 'false' or '0', so check - some_on = False - if len(found): - for f in found: - val = env['MARLIN_FEATURES'][f] - if val in [ '', '1', 'true' ]: - some_on = True - elif val in env['MARLIN_FEATURES']: - some_on = env.MarlinFeatureIsEnabled(val) - - return some_on - -# -# Add a method for other PIO scripts to query enabled features -# -env.AddMethod(MarlinFeatureIsEnabled) - -# -# Add dependencies for enabled Marlin features -# -apply_features_config() -force_ignore_unused_libs() + # Add dependencies for enabled Marlin features + apply_features_config() + force_ignore_unused_libs() diff --git a/buildroot/share/PlatformIO/scripts/custom_board.py b/buildroot/share/PlatformIO/scripts/custom_board.py index e462738190..da3bdca0bb 100644 --- a/buildroot/share/PlatformIO/scripts/custom_board.py +++ b/buildroot/share/PlatformIO/scripts/custom_board.py @@ -1,16 +1,18 @@ # -# buildroot/share/PlatformIO/scripts/custom_board.py +# custom_board.py # # - For build.address replace VECT_TAB_ADDR to relocate the firmware # - For build.ldscript use one of the linker scripts in buildroot/share/PlatformIO/ldscripts # -import marlin -board = marlin.env.BoardConfig() +import pioutil +if pioutil.is_pio_build(): + import marlin + board = marlin.env.BoardConfig() -address = board.get("build.address", "") -if address: - marlin.relocate_firmware(address) + address = board.get("build.address", "") + if address: + marlin.relocate_firmware(address) -ldscript = board.get("build.ldscript", "") -if ldscript: - marlin.custom_ld_script(ldscript) + ldscript = board.get("build.ldscript", "") + if ldscript: + marlin.custom_ld_script(ldscript) diff --git a/buildroot/share/PlatformIO/scripts/download_mks_assets.py b/buildroot/share/PlatformIO/scripts/download_mks_assets.py index 251a74a4cc..1990400222 100644 --- a/buildroot/share/PlatformIO/scripts/download_mks_assets.py +++ b/buildroot/share/PlatformIO/scripts/download_mks_assets.py @@ -1,51 +1,49 @@ # -# buildroot/share/PlatformIO/scripts/download_mks_assets.py +# download_mks_assets.py # Added by HAS_TFT_LVGL_UI to download assets from Makerbase repo # -Import("env") -import os,requests,zipfile,tempfile,shutil,pioutil +import pioutil +if pioutil.is_pio_build(): + Import("env") + import os,requests,zipfile,tempfile,shutil -# Detect that 'vscode init' is running -if pioutil.is_vscode_init(): - env.Exit(0) + url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/0263cdaccf.zip" + deps_path = env.Dictionary("PROJECT_LIBDEPS_DIR") + zip_path = os.path.join(deps_path, "mks-assets.zip") + assets_path = os.path.join(env.Dictionary("PROJECT_BUILD_DIR"), env.Dictionary("PIOENV"), "assets") -url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/0263cdaccf.zip" -deps_path = env.Dictionary("PROJECT_LIBDEPS_DIR") -zip_path = os.path.join(deps_path, "mks-assets.zip") -assets_path = os.path.join(env.Dictionary("PROJECT_BUILD_DIR"), env.Dictionary("PIOENV"), "assets") + def download_mks_assets(): + print("Downloading MKS Assets") + r = requests.get(url, stream=True) + # the user may have a very clean workspace, + # so create the PROJECT_LIBDEPS_DIR directory if not exits + if os.path.exists(deps_path) == False: + os.mkdir(deps_path) + with open(zip_path, 'wb') as fd: + for chunk in r.iter_content(chunk_size=128): + fd.write(chunk) -def download_mks_assets(): - print("Downloading MKS Assets") - r = requests.get(url, stream=True) - # the user may have a very clean workspace, - # so create the PROJECT_LIBDEPS_DIR directory if not exits - if os.path.exists(deps_path) == False: - os.mkdir(deps_path) - with open(zip_path, 'wb') as fd: - for chunk in r.iter_content(chunk_size=128): - fd.write(chunk) + def copy_mks_assets(): + print("Copying MKS Assets") + output_path = tempfile.mkdtemp() + zip_obj = zipfile.ZipFile(zip_path, 'r') + zip_obj.extractall(output_path) + zip_obj.close() + if os.path.exists(assets_path) == True and os.path.isdir(assets_path) == False: + os.unlink(assets_path) + if os.path.exists(assets_path) == False: + os.mkdir(assets_path) + base_path = '' + for filename in os.listdir(output_path): + base_path = filename + for filename in os.listdir(os.path.join(output_path, base_path, 'Firmware', 'mks_font')): + shutil.copy(os.path.join(output_path, base_path, 'Firmware', 'mks_font', filename), assets_path) + for filename in os.listdir(os.path.join(output_path, base_path, 'Firmware', 'mks_pic')): + shutil.copy(os.path.join(output_path, base_path, 'Firmware', 'mks_pic', filename), assets_path) + shutil.rmtree(output_path, ignore_errors=True) + + if os.path.exists(zip_path) == False: + download_mks_assets() -def copy_mks_assets(): - print("Copying MKS Assets") - output_path = tempfile.mkdtemp() - zip_obj = zipfile.ZipFile(zip_path, 'r') - zip_obj.extractall(output_path) - zip_obj.close() - if os.path.exists(assets_path) == True and os.path.isdir(assets_path) == False: - os.unlink(assets_path) if os.path.exists(assets_path) == False: - os.mkdir(assets_path) - base_path = '' - for filename in os.listdir(output_path): - base_path = filename - for filename in os.listdir(os.path.join(output_path, base_path, 'Firmware', 'mks_font')): - shutil.copy(os.path.join(output_path, base_path, 'Firmware', 'mks_font', filename), assets_path) - for filename in os.listdir(os.path.join(output_path, base_path, 'Firmware', 'mks_pic')): - shutil.copy(os.path.join(output_path, base_path, 'Firmware', 'mks_pic', filename), assets_path) - shutil.rmtree(output_path, ignore_errors=True) - -if os.path.exists(zip_path) == False: - download_mks_assets() - -if os.path.exists(assets_path) == False: - copy_mks_assets() + copy_mks_assets() diff --git a/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py b/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py index fa91b7bb70..663e7c76d9 100644 --- a/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py +++ b/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py @@ -1,32 +1,35 @@ # # fix_framework_weakness.py # -from os.path import join, isfile -import shutil -from pprint import pprint +import pioutil +if pioutil.is_pio_build(): -Import("env") + import shutil + from os.path import join, isfile + from pprint import pprint -if env.MarlinFeatureIsEnabled("POSTMORTEM_DEBUGGING"): - FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoststm32-maple") - patchflag_path = join(FRAMEWORK_DIR, ".exc-patching-done") + Import("env") - # patch file only if we didn't do it before - if not isfile(patchflag_path): - print("Patching libmaple exception handlers") - original_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S") - backup_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S.bak") - src_file = join("buildroot", "share", "PlatformIO", "scripts", "exc.S") + if env.MarlinFeatureIsEnabled("POSTMORTEM_DEBUGGING"): + FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoststm32-maple") + patchflag_path = join(FRAMEWORK_DIR, ".exc-patching-done") - assert isfile(original_file) and isfile(src_file) - shutil.copyfile(original_file, backup_file) - shutil.copyfile(src_file, original_file); + # patch file only if we didn't do it before + if not isfile(patchflag_path): + print("Patching libmaple exception handlers") + original_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S") + backup_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S.bak") + src_file = join("buildroot", "share", "PlatformIO", "scripts", "exc.S") - def _touch(path): - with open(path, "w") as fp: - fp.write("") + assert isfile(original_file) and isfile(src_file) + shutil.copyfile(original_file, backup_file) + shutil.copyfile(src_file, original_file); - env.Execute(lambda *args, **kwargs: _touch(patchflag_path)) - print("Done patching exception handler") + def _touch(path): + with open(path, "w") as fp: + fp.write("") - print("Libmaple modified and ready for post mortem debugging") + env.Execute(lambda *args, **kwargs: _touch(patchflag_path)) + print("Done patching exception handler") + + print("Libmaple modified and ready for post mortem debugging") diff --git a/buildroot/share/PlatformIO/scripts/generic_create_variant.py b/buildroot/share/PlatformIO/scripts/generic_create_variant.py index 7f76ef9426..52473c752a 100644 --- a/buildroot/share/PlatformIO/scripts/generic_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/generic_create_variant.py @@ -5,50 +5,52 @@ # the appropriate framework variants folder, so that its contents # will be picked up by PlatformIO just like any other variant. # -import os,shutil,marlin -from SCons.Script import DefaultEnvironment -from platformio import util +import pioutil +if pioutil.is_pio_build(): + import os,shutil,marlin + from SCons.Script import DefaultEnvironment + from platformio import util -env = DefaultEnvironment() + env = DefaultEnvironment() -# -# Get the platform name from the 'platform_packages' option, -# or look it up by the platform.class.name. -# -platform = env.PioPlatform() + # + # Get the platform name from the 'platform_packages' option, + # or look it up by the platform.class.name. + # + platform = env.PioPlatform() -from platformio.package.meta import PackageSpec -platform_packages = env.GetProjectOption('platform_packages') -if len(platform_packages) == 0: - framewords = { - "Ststm32Platform": "framework-arduinoststm32", - "AtmelavrPlatform": "framework-arduino-avr" - } - platform_name = framewords[platform.__class__.__name__] -else: - platform_name = PackageSpec(platform_packages[0]).name + from platformio.package.meta import PackageSpec + platform_packages = env.GetProjectOption('platform_packages') + if len(platform_packages) == 0: + framewords = { + "Ststm32Platform": "framework-arduinoststm32", + "AtmelavrPlatform": "framework-arduino-avr" + } + platform_name = framewords[platform.__class__.__name__] + else: + platform_name = PackageSpec(platform_packages[0]).name -if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "usb-host-msc-cdc-msc-3", "tool-stm32duino" ]: - platform_name = "framework-arduinoststm32" + if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "usb-host-msc-cdc-msc-3", "tool-stm32duino" ]: + platform_name = "framework-arduinoststm32" -FRAMEWORK_DIR = platform.get_package_dir(platform_name) -assert os.path.isdir(FRAMEWORK_DIR) + FRAMEWORK_DIR = platform.get_package_dir(platform_name) + assert os.path.isdir(FRAMEWORK_DIR) -board = env.BoardConfig() + board = env.BoardConfig() -#mcu_type = board.get("build.mcu")[:-2] -variant = board.get("build.variant") -#series = mcu_type[:7].upper() + "xx" + #mcu_type = board.get("build.mcu")[:-2] + variant = board.get("build.variant") + #series = mcu_type[:7].upper() + "xx" -# Prepare a new empty folder at the destination -variant_dir = os.path.join(FRAMEWORK_DIR, "variants", variant) -if os.path.isdir(variant_dir): - shutil.rmtree(variant_dir) -if not os.path.isdir(variant_dir): - os.mkdir(variant_dir) + # Prepare a new empty folder at the destination + variant_dir = os.path.join(FRAMEWORK_DIR, "variants", variant) + if os.path.isdir(variant_dir): + shutil.rmtree(variant_dir) + if not os.path.isdir(variant_dir): + os.mkdir(variant_dir) -# Source dir is a local variant sub-folder -source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant) -assert os.path.isdir(source_dir) + # Source dir is a local variant sub-folder + source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant) + assert os.path.isdir(source_dir) -marlin.copytree(source_dir, variant_dir) + marlin.copytree(source_dir, variant_dir) diff --git a/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py b/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py index a4001a240c..0af9c1046d 100644 --- a/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py +++ b/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py @@ -1,39 +1,40 @@ # -# buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py +# jgaurora_a5s_a1_with_bootloader.py # Customizations for env:jgaurora_a5s_a1 # -import os,marlin +import pioutil +if pioutil.is_pio_build(): + import os,marlin + # Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin' + def addboot(source, target, env): + firmware = open(target[0].path, "rb") + lengthfirmware = os.path.getsize(target[0].path) + bootloader_bin = "buildroot/share/PlatformIO/scripts/" + "jgaurora_bootloader.bin" + bootloader = open(bootloader_bin, "rb") + lengthbootloader = os.path.getsize(bootloader_bin) -# Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin' -def addboot(source, target, env): - firmware = open(target[0].path, "rb") - lengthfirmware = os.path.getsize(target[0].path) - bootloader_bin = "buildroot/share/PlatformIO/scripts/" + "jgaurora_bootloader.bin" - bootloader = open(bootloader_bin, "rb") - lengthbootloader = os.path.getsize(bootloader_bin) + firmware_with_boothloader_bin = target[0].dir.path + '/firmware_with_bootloader.bin' + if os.path.exists(firmware_with_boothloader_bin): + os.remove(firmware_with_boothloader_bin) + firmwareimage = open(firmware_with_boothloader_bin, "wb") + position = 0 + while position < lengthbootloader: + byte = bootloader.read(1) + firmwareimage.write(byte) + position += 1 + position = 0 + while position < lengthfirmware: + byte = firmware.read(1) + firmwareimage.write(byte) + position += 1 + bootloader.close() + firmware.close() + firmwareimage.close() - firmware_with_boothloader_bin = target[0].dir.path + '/firmware_with_bootloader.bin' - if os.path.exists(firmware_with_boothloader_bin): - os.remove(firmware_with_boothloader_bin) - firmwareimage = open(firmware_with_boothloader_bin, "wb") - position = 0 - while position < lengthbootloader: - byte = bootloader.read(1) - firmwareimage.write(byte) - position += 1 - position = 0 - while position < lengthfirmware: - byte = firmware.read(1) - firmwareimage.write(byte) - position += 1 - bootloader.close() - firmware.close() - firmwareimage.close() + firmware_without_bootloader_bin = target[0].dir.path + '/firmware_for_sd_upload.bin' + if os.path.exists(firmware_without_bootloader_bin): + os.remove(firmware_without_bootloader_bin) + os.rename(target[0].path, firmware_without_bootloader_bin) + #os.rename(target[0].dir.path+'/firmware_with_bootloader.bin', target[0].dir.path+'/firmware.bin') - firmware_without_bootloader_bin = target[0].dir.path + '/firmware_for_sd_upload.bin' - if os.path.exists(firmware_without_bootloader_bin): - os.remove(firmware_without_bootloader_bin) - os.rename(target[0].path, firmware_without_bootloader_bin) - #os.rename(target[0].dir.path+'/firmware_with_bootloader.bin', target[0].dir.path+'/firmware.bin') - -marlin.add_post_action(addboot); + marlin.add_post_action(addboot); diff --git a/buildroot/share/PlatformIO/scripts/lerdge.py b/buildroot/share/PlatformIO/scripts/lerdge.py index 144ab64a9a..505a935560 100644 --- a/buildroot/share/PlatformIO/scripts/lerdge.py +++ b/buildroot/share/PlatformIO/scripts/lerdge.py @@ -1,47 +1,49 @@ # -# buildroot/share/PlatformIO/scripts/lerdge.py +# lerdge.py # Customizations for Lerdge build environments: # env:LERDGEX env:LERDGEX_usb_flash_drive # env:LERDGES env:LERDGES_usb_flash_drive # env:LERDGEK env:LERDGEK_usb_flash_drive # -import os,marlin -Import("env") +import pioutil +if pioutil.is_pio_build(): + import os,marlin + Import("env") -from SCons.Script import DefaultEnvironment -board = DefaultEnvironment().BoardConfig() + from SCons.Script import DefaultEnvironment + board = DefaultEnvironment().BoardConfig() -def encryptByte(byte): - byte = 0xFF & ((byte << 6) | (byte >> 2)) - i = 0x58 + byte - j = 0x05 + byte + (i >> 8) - byte = (0xF8 & i) | (0x07 & j) - return byte + def encryptByte(byte): + byte = 0xFF & ((byte << 6) | (byte >> 2)) + i = 0x58 + byte + j = 0x05 + byte + (i >> 8) + byte = (0xF8 & i) | (0x07 & j) + return byte -def encrypt_file(input, output_file, file_length): - input_file = bytearray(input.read()) - for i in range(len(input_file)): - input_file[i] = encryptByte(input_file[i]) - output_file.write(input_file) + def encrypt_file(input, output_file, file_length): + input_file = bytearray(input.read()) + for i in range(len(input_file)): + input_file[i] = encryptByte(input_file[i]) + output_file.write(input_file) -# Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt -def encrypt(source, target, env): - fwpath = target[0].path - enname = board.get("build.encrypt") - print("Encrypting %s to %s" % (fwpath, enname)) - fwfile = open(fwpath, "rb") - enfile = open(target[0].dir.path + "/" + enname, "wb") - length = os.path.getsize(fwpath) + # Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt + def encrypt(source, target, env): + fwpath = target[0].path + enname = board.get("build.encrypt") + print("Encrypting %s to %s" % (fwpath, enname)) + fwfile = open(fwpath, "rb") + enfile = open(target[0].dir.path + "/" + enname, "wb") + length = os.path.getsize(fwpath) - encrypt_file(fwfile, enfile, length) + encrypt_file(fwfile, enfile, length) - fwfile.close() - enfile.close() - os.remove(fwpath) + fwfile.close() + enfile.close() + os.remove(fwpath) -if 'encrypt' in board.get("build").keys(): - if board.get("build.encrypt") != "": - marlin.add_post_action(encrypt) -else: - print("LERDGE builds require output file via board_build.encrypt = 'filename' parameter") - exit(1) + if 'encrypt' in board.get("build").keys(): + if board.get("build.encrypt") != "": + marlin.add_post_action(encrypt) + else: + print("LERDGE builds require output file via board_build.encrypt = 'filename' parameter") + exit(1) diff --git a/buildroot/share/PlatformIO/scripts/marlin.py b/buildroot/share/PlatformIO/scripts/marlin.py index caa0c89749..b8a6283ced 100644 --- a/buildroot/share/PlatformIO/scripts/marlin.py +++ b/buildroot/share/PlatformIO/scripts/marlin.py @@ -1,5 +1,5 @@ # -# buildroot/share/PlatformIO/scripts/marlin.py +# marlin.py # Helper module with some commonly-used functions # import os,shutil @@ -10,13 +10,13 @@ env = DefaultEnvironment() from os.path import join def copytree(src, dst, symlinks=False, ignore=None): - for item in os.listdir(src): - s = join(src, item) - d = join(dst, item) - if os.path.isdir(s): - shutil.copytree(s, d, symlinks, ignore) - else: - shutil.copy2(s, d) + for item in os.listdir(src): + s = join(src, item) + d = join(dst, item) + if os.path.isdir(s): + shutil.copytree(s, d, symlinks, ignore) + else: + shutil.copy2(s, d) def replace_define(field, value): for define in env['CPPDEFINES']: diff --git a/buildroot/share/PlatformIO/scripts/mks_robin.py b/buildroot/share/PlatformIO/scripts/mks_robin.py index 2dea7c615f..7b423bedab 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin.py @@ -1,5 +1,5 @@ # -# buildroot/share/PlatformIO/scripts/mks_robin.py +# mks_robin.py # import robin robin.prepare("0x08007000", "mks_robin.ld", "Robin.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_e3.py b/buildroot/share/PlatformIO/scripts/mks_robin_e3.py index 6ddeccbf80..645230c625 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_e3.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_e3.py @@ -1,5 +1,5 @@ # -# buildroot/share/PlatformIO/scripts/mks_robin_e3.py +# mks_robin_e3.py # import robin robin.prepare("0x08005000", "mks_robin_e3.ld", "Robin_e3.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py b/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py index 5eeb93c096..bb15cb5a70 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py @@ -1,5 +1,5 @@ # -# buildroot/share/PlatformIO/scripts/mks_robin_e3p.py +# mks_robin_e3p.py # import robin robin.prepare("0x08007000", "mks_robin_e3p.ld", "Robin_e3p.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_lite.py b/buildroot/share/PlatformIO/scripts/mks_robin_lite.py index c2018336fd..123b043f7c 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_lite.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_lite.py @@ -1,5 +1,5 @@ # -# buildroot/share/PlatformIO/scripts/mks_robin_lite.py +# mks_robin_lite.py # import robin robin.prepare("0x08005000", "mks_robin_lite.ld", "mksLite.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py b/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py index 42c8fb18b6..092231eae8 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py @@ -1,5 +1,5 @@ # -# buildroot/share/PlatformIO/scripts/mks_robin_lite3.py +# mks_robin_lite3.py # import robin robin.prepare("0x08005000", "mks_robin_lite.ld", "mksLite3.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_mini.py b/buildroot/share/PlatformIO/scripts/mks_robin_mini.py index b0d8388653..d1d175dd1c 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_mini.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_mini.py @@ -1,5 +1,5 @@ # -# buildroot/share/PlatformIO/scripts/mks_robin_mini.py +# mks_robin_mini.py # import robin robin.prepare("0x08007000", "mks_robin_mini.ld", "Robin_mini.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_nano.py b/buildroot/share/PlatformIO/scripts/mks_robin_nano.py index 35e99830c4..32d1af2366 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_nano.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_nano.py @@ -1,5 +1,5 @@ # -# buildroot/share/PlatformIO/scripts/mks_robin_nano.py +# mks_robin_nano.py # import robin robin.prepare("0x08007000", "mks_robin_nano.ld", "Robin_nano.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py b/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py index 4a5726ad5b..7e635bd6ec 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py @@ -1,5 +1,5 @@ # -# buildroot/share/PlatformIO/scripts/mks_robin_nano35.py +# mks_robin_nano35.py # import robin robin.prepare("0x08007000", "mks_robin_nano.ld", "Robin_nano35.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_pro.py b/buildroot/share/PlatformIO/scripts/mks_robin_pro.py index 60e2482bb0..54526aeaef 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_pro.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_pro.py @@ -1,5 +1,5 @@ # -# buildroot/share/PlatformIO/scripts/mks_robin_pro.py +# mks_robin_pro.py # import robin robin.prepare("0x08007000", "mks_robin_pro.ld", "Robin_pro.bin") diff --git a/buildroot/share/PlatformIO/scripts/offset_and_rename.py b/buildroot/share/PlatformIO/scripts/offset_and_rename.py index 9caed298e4..00803b722e 100644 --- a/buildroot/share/PlatformIO/scripts/offset_and_rename.py +++ b/buildroot/share/PlatformIO/scripts/offset_and_rename.py @@ -8,54 +8,56 @@ # # - For 'board_build.rename' add a post-action to rename the firmware file. # -import os,sys,marlin -Import("env") +import pioutil +if pioutil.is_pio_build(): + import os,sys,marlin + Import("env") -from SCons.Script import DefaultEnvironment -board = DefaultEnvironment().BoardConfig() + from SCons.Script import DefaultEnvironment + board = DefaultEnvironment().BoardConfig() -board_keys = board.get("build").keys() + board_keys = board.get("build").keys() -# -# For build.offset define LD_FLASH_OFFSET, used by ldscript.ld -# -if 'offset' in board_keys: - LD_FLASH_OFFSET = board.get("build.offset") - marlin.relocate_vtab(LD_FLASH_OFFSET) + # + # For build.offset define LD_FLASH_OFFSET, used by ldscript.ld + # + if 'offset' in board_keys: + LD_FLASH_OFFSET = board.get("build.offset") + marlin.relocate_vtab(LD_FLASH_OFFSET) - # Flash size - maximum_flash_size = int(board.get("upload.maximum_size") / 1024) - marlin.replace_define('STM32_FLASH_SIZE', maximum_flash_size) + # Flash size + maximum_flash_size = int(board.get("upload.maximum_size") / 1024) + marlin.replace_define('STM32_FLASH_SIZE', maximum_flash_size) - # Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json) - maximum_ram_size = board.get("upload.maximum_ram_size") + # Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json) + maximum_ram_size = board.get("upload.maximum_ram_size") - for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,--defsym=LD_FLASH_OFFSET" in flag: - env["LINKFLAGS"][i] = "-Wl,--defsym=LD_FLASH_OFFSET=" + LD_FLASH_OFFSET - if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag: - env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40) + for i, flag in enumerate(env["LINKFLAGS"]): + if "-Wl,--defsym=LD_FLASH_OFFSET" in flag: + env["LINKFLAGS"][i] = "-Wl,--defsym=LD_FLASH_OFFSET=" + LD_FLASH_OFFSET + if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag: + env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40) -# -# For build.encrypt rename and encode the firmware file. -# -if 'encrypt' in board_keys: + # + # For build.encrypt rename and encode the firmware file. + # + if 'encrypt' in board_keys: - # Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt - def encrypt(source, target, env): - marlin.encrypt_mks(source, target, env, board.get("build.encrypt")) + # Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt + def encrypt(source, target, env): + marlin.encrypt_mks(source, target, env, board.get("build.encrypt")) - if board.get("build.encrypt") != "": - marlin.add_post_action(encrypt) + if board.get("build.encrypt") != "": + marlin.add_post_action(encrypt) -# -# For build.rename simply rename the firmware file. -# -if 'rename' in board_keys: + # + # For build.rename simply rename the firmware file. + # + if 'rename' in board_keys: - def rename_target(source, target, env): - firmware = os.path.join(target[0].dir.path, board.get("build.rename")) - import shutil - shutil.copy(target[0].path, firmware) + def rename_target(source, target, env): + firmware = os.path.join(target[0].dir.path, board.get("build.rename")) + import shutil + shutil.copy(target[0].path, firmware) - marlin.add_post_action(rename_target) + marlin.add_post_action(rename_target) diff --git a/buildroot/share/PlatformIO/scripts/openblt.py b/buildroot/share/PlatformIO/scripts/openblt.py index 6e71ca9eb8..61b38a5e87 100644 --- a/buildroot/share/PlatformIO/scripts/openblt.py +++ b/buildroot/share/PlatformIO/scripts/openblt.py @@ -1,18 +1,20 @@ # # Convert the ELF to an SREC file suitable for some bootloaders # -import os,sys -from os.path import join +import pioutil +if pioutil.is_pio_build(): + import os,sys + from os.path import join -Import("env") + Import("env") -board = env.BoardConfig() -board_keys = board.get("build").keys() -if 'encrypt' in board_keys: - env.AddPostAction( - join("$BUILD_DIR", "${PROGNAME}.bin"), - env.VerboseAction(" ".join([ - "$OBJCOPY", "-O", "srec", - "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"" + join("$BUILD_DIR", board.get("build.encrypt")) + "\"" - ]), "Building $TARGET") - ) + board = env.BoardConfig() + board_keys = board.get("build").keys() + if 'encrypt' in board_keys: + env.AddPostAction( + join("$BUILD_DIR", "${PROGNAME}.bin"), + env.VerboseAction(" ".join([ + "$OBJCOPY", "-O", "srec", + "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"" + join("$BUILD_DIR", board.get("build.encrypt")) + "\"" + ]), "Building $TARGET") + ) diff --git a/buildroot/share/PlatformIO/scripts/pioutil.py b/buildroot/share/PlatformIO/scripts/pioutil.py index f0c021fca7..b8c1e9cfca 100644 --- a/buildroot/share/PlatformIO/scripts/pioutil.py +++ b/buildroot/share/PlatformIO/scripts/pioutil.py @@ -1,8 +1,8 @@ # -# buildroot/share/PlatformIO/scripts/pioutil.py +# pioutil.py # -# Detect that 'vscode init' is running -def is_vscode_init(): +# Make sure 'vscode init' is not the current command +def is_pio_build(): from SCons.Script import COMMAND_LINE_TARGETS - return "idedata" in COMMAND_LINE_TARGETS or "_idedata" in COMMAND_LINE_TARGETS + return "idedata" not in COMMAND_LINE_TARGETS and "_idedata" not in COMMAND_LINE_TARGETS diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index 0dab3e4b1f..1837a7580d 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -2,100 +2,99 @@ # preflight-checks.py # Check for common issues prior to compiling # -import os,re,sys,pioutil -Import("env") +import pioutil +if pioutil.is_pio_build(): -# Detect that 'vscode init' is running -if pioutil.is_vscode_init(): - env.Exit(0) + import os,re,sys + Import("env") -def get_envs_for_board(board): - with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file: + def get_envs_for_board(board): + with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file: - if sys.platform == 'win32': - envregex = r"(?:env|win):" - elif sys.platform == 'darwin': - envregex = r"(?:env|mac|uni):" - elif sys.platform == 'linux': - envregex = r"(?:env|lin|uni):" - else: - envregex = r"(?:env):" + if sys.platform == 'win32': + envregex = r"(?:env|win):" + elif sys.platform == 'darwin': + envregex = r"(?:env|mac|uni):" + elif sys.platform == 'linux': + envregex = r"(?:env|lin|uni):" + else: + envregex = r"(?:env):" - r = re.compile(r"if\s+MB\((.+)\)") - if board.startswith("BOARD_"): - board = board[6:] + r = re.compile(r"if\s+MB\((.+)\)") + if board.startswith("BOARD_"): + board = board[6:] - for line in file: - mbs = r.findall(line) - if mbs and board in re.split(r",\s*", mbs[0]): - line = file.readline() - found_envs = re.match(r"\s*#include .+" + envregex, line) - if found_envs: - envlist = re.findall(envregex + r"(\w+)", line) - return [ "env:"+s for s in envlist ] - return [] + for line in file: + mbs = r.findall(line) + if mbs and board in re.split(r",\s*", mbs[0]): + line = file.readline() + found_envs = re.match(r"\s*#include .+" + envregex, line) + if found_envs: + envlist = re.findall(envregex + r"(\w+)", line) + return [ "env:"+s for s in envlist ] + return [] -def check_envs(build_env, board_envs, config): - if build_env in board_envs: - return True - ext = config.get(build_env, 'extends', default=None) - if ext: - if isinstance(ext, str): - return check_envs(ext, board_envs, config) - elif isinstance(ext, list): - for ext_env in ext: - if check_envs(ext_env, board_envs, config): - return True - return False + def check_envs(build_env, board_envs, config): + if build_env in board_envs: + return True + ext = config.get(build_env, 'extends', default=None) + if ext: + if isinstance(ext, str): + return check_envs(ext, board_envs, config) + elif isinstance(ext, list): + for ext_env in ext: + if check_envs(ext_env, board_envs, config): + return True + return False -def sanity_check_target(): - # Sanity checks: - if 'PIOENV' not in env: - raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO") + def sanity_check_target(): + # Sanity checks: + if 'PIOENV' not in env: + raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO") - if 'MARLIN_FEATURES' not in env: - raise SystemExit("Error: this script should be used after common Marlin scripts") + if 'MARLIN_FEATURES' not in env: + raise SystemExit("Error: this script should be used after common Marlin scripts") - if 'MOTHERBOARD' not in env['MARLIN_FEATURES']: - raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h") + if 'MOTHERBOARD' not in env['MARLIN_FEATURES']: + raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h") - build_env = env['PIOENV'] - motherboard = env['MARLIN_FEATURES']['MOTHERBOARD'] - board_envs = get_envs_for_board(motherboard) - config = env.GetProjectConfig() - result = check_envs("env:"+build_env, board_envs, config) + build_env = env['PIOENV'] + motherboard = env['MARLIN_FEATURES']['MOTHERBOARD'] + board_envs = get_envs_for_board(motherboard) + config = env.GetProjectConfig() + result = check_envs("env:"+build_env, board_envs, config) - if not result: - err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \ - ( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) ) - raise SystemExit(err) + if not result: + err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \ + ( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) ) + raise SystemExit(err) - # - # Check for Config files in two common incorrect places - # - for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]: - for f in [ "Configuration.h", "Configuration_adv.h" ]: + # + # Check for Config files in two common incorrect places + # + for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]: + for f in [ "Configuration.h", "Configuration_adv.h" ]: + if os.path.isfile(os.path.join(p, f)): + err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p + raise SystemExit(err) + + # + # Give warnings on every build + # + warnfile = os.path.join(env['PROJECT_BUILD_DIR'], build_env, "src", "src", "inc", "Warnings.cpp.o") + if os.path.exists(warnfile): + os.remove(warnfile) + + # + # Check for old files indicating an entangled Marlin (mixing old and new code) + # + mixedin = [] + p = os.path.join(env['PROJECT_DIR'], "Marlin", "src", "lcd", "dogm") + for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]: if os.path.isfile(os.path.join(p, f)): - err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p - raise SystemExit(err) + mixedin += [ f ] + if mixedin: + err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin) + raise SystemExit(err) - # - # Give warnings on every build - # - warnfile = os.path.join(env['PROJECT_BUILD_DIR'], build_env, "src", "src", "inc", "Warnings.cpp.o") - if os.path.exists(warnfile): - os.remove(warnfile) - - # - # Check for old files indicating an entangled Marlin (mixing old and new code) - # - mixedin = [] - p = os.path.join(env['PROJECT_DIR'], "Marlin", "src", "lcd", "dogm") - for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]: - if os.path.isfile(os.path.join(p, f)): - mixedin += [ f ] - if mixedin: - err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin) - raise SystemExit(err) - -sanity_check_target() + sanity_check_target() diff --git a/buildroot/share/PlatformIO/scripts/random-bin.py b/buildroot/share/PlatformIO/scripts/random-bin.py index c03b863448..5a88906c30 100644 --- a/buildroot/share/PlatformIO/scripts/random-bin.py +++ b/buildroot/share/PlatformIO/scripts/random-bin.py @@ -2,8 +2,8 @@ # random-bin.py # Set a unique firmware name based on current date and time # -Import("env") - -from datetime import datetime - -env['PROGNAME'] = datetime.now().strftime("firmware-%Y%m%d-%H%M%S") +import pioutil +if pioutil.is_pio_build(): + from datetime import datetime + Import("env") + env['PROGNAME'] = datetime.now().strftime("firmware-%Y%m%d-%H%M%S") diff --git a/buildroot/share/PlatformIO/scripts/robin.py b/buildroot/share/PlatformIO/scripts/robin.py index 50d0d92d2f..ffc9a43b90 100644 --- a/buildroot/share/PlatformIO/scripts/robin.py +++ b/buildroot/share/PlatformIO/scripts/robin.py @@ -1,12 +1,14 @@ # -# buildroot/share/PlatformIO/scripts/robin.py +# robin.py # -import marlin # Apply customizations for a MKS Robin def prepare(address, ldname, fwname): - def encrypt(source, target, env): - marlin.encrypt_mks(source, target, env, fwname) - marlin.relocate_firmware(address) - marlin.custom_ld_script(ldname) - marlin.add_post_action(encrypt); + import pioutil + if pioutil.is_pio_build(): + import marlin + def encrypt(source, target, env): + marlin.encrypt_mks(source, target, env, fwname) + marlin.relocate_firmware(address) + marlin.custom_ld_script(ldname) + marlin.add_post_action(encrypt); diff --git a/buildroot/share/PlatformIO/scripts/simulator.py b/buildroot/share/PlatformIO/scripts/simulator.py index fb9d93cceb..c6a5277b92 100644 --- a/buildroot/share/PlatformIO/scripts/simulator.py +++ b/buildroot/share/PlatformIO/scripts/simulator.py @@ -1,52 +1,54 @@ # +# simulator.py # PlatformIO pre: script for simulator builds # +import pioutil +if pioutil.is_pio_build(): + # Get the environment thus far for the build + Import("env") -# Get the environment thus far for the build -Import("env") + #print(env.Dump()) -#print(env.Dump()) + # + # Give the binary a distinctive name + # -# -# Give the binary a distinctive name -# + env['PROGNAME'] = "MarlinSimulator" -env['PROGNAME'] = "MarlinSimulator" + # + # If Xcode is installed add the path to its Frameworks folder, + # or if Mesa is installed try to use its GL/gl.h. + # -# -# If Xcode is installed add the path to its Frameworks folder, -# or if Mesa is installed try to use its GL/gl.h. -# + import sys + if sys.platform == 'darwin': -import sys -if sys.platform == 'darwin': + # + # Silence half of the ranlib warnings. (No equivalent for 'ARFLAGS') + # + env['RANLIBFLAGS'] += [ "-no_warning_for_no_symbols" ] - # - # Silence half of the ranlib warnings. (No equivalent for 'ARFLAGS') - # - env['RANLIBFLAGS'] += [ "-no_warning_for_no_symbols" ] + # Default paths for Xcode and a lucky GL/gl.h dropped by Mesa + xcode_path = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" + mesa_path = "/opt/local/include/GL/gl.h" - # Default paths for Xcode and a lucky GL/gl.h dropped by Mesa - xcode_path = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" - mesa_path = "/opt/local/include/GL/gl.h" + import os.path - import os.path + if os.path.exists(xcode_path): - if os.path.exists(xcode_path): + env['BUILD_FLAGS'] += [ "-F" + xcode_path ] + print("Using OpenGL framework headers from Xcode.app") - env['BUILD_FLAGS'] += [ "-F" + xcode_path ] - print("Using OpenGL framework headers from Xcode.app") + elif os.path.exists(mesa_path): - elif os.path.exists(mesa_path): + env['BUILD_FLAGS'] += [ '-D__MESA__' ] + print("Using OpenGL header from", mesa_path) - env['BUILD_FLAGS'] += [ '-D__MESA__' ] - print("Using OpenGL header from", mesa_path) + else: - else: + print("\n\nNo OpenGL headers found. Install Xcode for matching headers, or use 'sudo port install mesa' to get a GL/gl.h.\n\n") - print("\n\nNo OpenGL headers found. Install Xcode for matching headers, or use 'sudo port install mesa' to get a GL/gl.h.\n\n") + # Break out of the PIO build immediately + sys.exit(1) - # Break out of the PIO build immediately - sys.exit(1) - -env.AddCustomTarget("upload", "$BUILD_DIR/${PROGNAME}", "$BUILD_DIR/${PROGNAME}") + env.AddCustomTarget("upload", "$BUILD_DIR/${PROGNAME}", "$BUILD_DIR/${PROGNAME}") diff --git a/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py b/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py index c3779289e0..033803009e 100644 --- a/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py +++ b/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py @@ -1,59 +1,61 @@ # # stm32_serialbuffer.py # -Import("env") +import pioutil +if pioutil.is_pio_build(): + Import("env") -# Marlin uses the `RX_BUFFER_SIZE` \ `TX_BUFFER_SIZE` options to -# configure buffer sizes for receiving \ transmitting serial data. -# Stm32duino uses another set of defines for the same purpose, so this -# script gets the values from the configuration and uses them to define -# `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE` as global build -# flags so they are available for use by the platform. -# -# The script will set the value as the default one (64 bytes) -# or the user-configured one, whichever is higher. -# -# Marlin's default buffer sizes are 128 for RX and 32 for TX. -# The highest value is taken (128/64). -# -# If MF_*_BUFFER_SIZE, SERIAL_*_BUFFER_SIZE, USART_*_BUF_SIZE, are -# defined, the first of these values will be used as the minimum. -build_flags = env.ParseFlags(env.get('BUILD_FLAGS'))["CPPDEFINES"] -mf = env["MARLIN_FEATURES"] + # Get a build flag's value or None + def getBuildFlagValue(name): + for flag in build_flags: + if isinstance(flag, list) and flag[0] == name: + return flag[1] -# Get a build flag's value or None -def getBuildFlagValue(name): - for flag in build_flags: - if isinstance(flag, list) and flag[0] == name: - return flag[1] + return None - return None + # Get an overriding buffer size for RX or TX from the build flags + def getInternalSize(side): + return getBuildFlagValue(f"MF_{side}_BUFFER_SIZE") or \ + getBuildFlagValue(f"SERIAL_{side}_BUFFER_SIZE") or \ + getBuildFlagValue(f"USART_{side}_BUF_SIZE") -# Get an overriding buffer size for RX or TX from the build flags -def getInternalSize(side): - return getBuildFlagValue(f"MF_{side}_BUFFER_SIZE") or \ - getBuildFlagValue(f"SERIAL_{side}_BUFFER_SIZE") or \ - getBuildFlagValue(f"USART_{side}_BUF_SIZE") + # Get the largest defined buffer size for RX or TX + def getBufferSize(side, default): + # Get a build flag value or fall back to the given default + internal = int(getInternalSize(side) or default) + flag = side + "_BUFFER_SIZE" + # Return the largest value + return max(int(mf[flag]), internal) if flag in mf else internal -# Get the largest defined buffer size for RX or TX -def getBufferSize(side, default): - # Get a build flag value or fall back to the given default - internal = int(getInternalSize(side) or default) - flag = side + "_BUFFER_SIZE" - # Return the largest value - return max(int(mf[flag]), internal) if flag in mf else internal + # Add a build flag if it's not already defined + def tryAddFlag(name, value): + if getBuildFlagValue(name) is None: + env.Append(BUILD_FLAGS=[f"-D{name}={value}"]) -# Add a build flag if it's not already defined -def tryAddFlag(name, value): - if getBuildFlagValue(name) is None: - env.Append(BUILD_FLAGS=[f"-D{name}={value}"]) + # Marlin uses the `RX_BUFFER_SIZE` \ `TX_BUFFER_SIZE` options to + # configure buffer sizes for receiving \ transmitting serial data. + # Stm32duino uses another set of defines for the same purpose, so this + # script gets the values from the configuration and uses them to define + # `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE` as global build + # flags so they are available for use by the platform. + # + # The script will set the value as the default one (64 bytes) + # or the user-configured one, whichever is higher. + # + # Marlin's default buffer sizes are 128 for RX and 32 for TX. + # The highest value is taken (128/64). + # + # If MF_*_BUFFER_SIZE, SERIAL_*_BUFFER_SIZE, USART_*_BUF_SIZE, are + # defined, the first of these values will be used as the minimum. + build_flags = env.ParseFlags(env.get('BUILD_FLAGS'))["CPPDEFINES"] + mf = env["MARLIN_FEATURES"] -# Get the largest defined buffer sizes for RX or TX, using defaults for undefined -rxBuf = getBufferSize("RX", 128) -txBuf = getBufferSize("TX", 64) + # Get the largest defined buffer sizes for RX or TX, using defaults for undefined + rxBuf = getBufferSize("RX", 128) + txBuf = getBufferSize("TX", 64) -# Provide serial buffer sizes to the stm32duino platform -tryAddFlag("SERIAL_RX_BUFFER_SIZE", rxBuf) -tryAddFlag("SERIAL_TX_BUFFER_SIZE", txBuf) -tryAddFlag("USART_RX_BUF_SIZE", rxBuf) -tryAddFlag("USART_TX_BUF_SIZE", txBuf) + # Provide serial buffer sizes to the stm32duino platform + tryAddFlag("SERIAL_RX_BUFFER_SIZE", rxBuf) + tryAddFlag("SERIAL_TX_BUFFER_SIZE", txBuf) + tryAddFlag("USART_RX_BUF_SIZE", rxBuf) + tryAddFlag("USART_TX_BUF_SIZE", txBuf) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/PeripheralPins.c new file mode 100644 index 0000000000..b2783d8c31 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/PeripheralPins.c @@ -0,0 +1,247 @@ +/* + ******************************************************************************* + * Copyright (c) 2019, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + * Automatically generated from STM32F401R(B-C)Tx.xml + */ +#include "Arduino.h" +#include "PeripheralPins.h" + +/* ===== + * Note: Commented lines are alternative possibilities which are not used per default. + * If you change them, you will have to know what you do + * ===== + */ + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +WEAK const PinMap PinMap_ADC[] = { + {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 + {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + {NC, NP, 0} +}; +#endif + +//*** No DAC *** + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C2)}, + {PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, + {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SCL[] = { + {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {NC, NP, 0} +}; +#endif + +//*** PWM *** + +#ifdef HAL_TIM_MODULE_ENABLED +WEAK const PinMap PinMap_PWM[] = { + {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 + {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {NC, NP, 0} +}; +#endif + +//*** SERIAL *** + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_TX[] = { + {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PA_11, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RX[] = { + {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PA_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RTS[] = { + {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_CTS[] = { + {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {NC, NP, 0} +}; +#endif + +//*** No CAN *** + +//*** No ETHERNET *** + +//*** No QUADSPI *** + +//*** USB *** + +#ifdef HAL_PCD_MODULE_ENABLED +WEAK const PinMap PinMap_USB_OTG_FS[] = { + {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF + {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS + {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; +#endif + +//*** No USB_OTG_HS *** + +//*** SD *** + +#ifdef HAL_SD_MODULE_ENABLED +WEAK const PinMap PinMap_SD[] = { + {PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4 + {PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5 + {PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6 + {PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7 + {PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0 + {PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 + {PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 + {PC_11, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D3 + {PC_12, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK + {PD_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CMD + {NC, NP, 0} +}; +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/PinNamesVar.h new file mode 100644 index 0000000000..3082f8842a --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/PinNamesVar.h @@ -0,0 +1,33 @@ +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 +SYS_WKUP1 = PA_0, +#endif +#ifdef PWR_WAKEUP_PIN2 +SYS_WKUP2 = NC, +#endif +#ifdef PWR_WAKEUP_PIN3 +SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 +SYS_WKUP4 = NC, +#endif +#ifdef PWR_WAKEUP_PIN5 +SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 +SYS_WKUP6 = NC, +#endif +#ifdef PWR_WAKEUP_PIN7 +SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 +SYS_WKUP8 = NC, +#endif +/* USB */ +#ifdef USBCON +USB_OTG_FS_SOF = PA_8, +USB_OTG_FS_VBUS = PA_9, +USB_OTG_FS_ID = PA_10, +USB_OTG_FS_DM = PA_11, +USB_OTG_FS_DP = PA_12, +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/hal_conf_custom.h new file mode 100644 index 0000000000..9fa98807d6 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/hal_conf_custom.h @@ -0,0 +1,496 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf.h + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_CUSTOM +#define __STM32F4xx_HAL_CONF_CUSTOM + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ + /** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +//#define HAL_DAC_MODULE_ENABLED +/* #define HAL_DCMI_MODULE_ENABLED */ +#define HAL_DMA_MODULE_ENABLED +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +#define HAL_FLASH_MODULE_ENABLED +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +/* #define HAL_SDRAM_MODULE_ENABLED */ +/* #define HAL_HASH_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +/* #define HAL_SMBUS_MODULE_ENABLED */ +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +#define HAL_PWR_MODULE_ENABLED +/* #define HAL_QSPI_MODULE_ENABLED */ +#define HAL_RCC_MODULE_ENABLED +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SAI_MODULE_ENABLED */ +/* #define HAL_SD_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +/* #define HAL_UART_MODULE_ENABLED */ +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_CORTEX_MODULE_ENABLED +#ifndef HAL_PCD_MODULE_ENABLED + #define HAL_PCD_MODULE_ENABLED //Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE) +#endif +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#ifndef HSE_VALUE +#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#ifndef HSE_STARTUP_TIMEOUT +#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#ifndef HSI_VALUE +#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#ifndef LSI_VALUE +#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations +in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#ifndef LSE_VALUE +#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#ifndef LSE_STARTUP_TIMEOUT +#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#ifndef EXTERNAL_CLOCK_VALUE +#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#if !defined (VDD_VALUE) +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#endif +#if !defined (TICK_INT_PRIORITY) +#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ +#endif +#if !defined (USE_RTOS) +#define USE_RTOS 0U +#endif +#if !defined (PREFETCH_ENABLE) +#define PREFETCH_ENABLE 1U +#endif +#if !defined (INSTRUCTION_CACHE_ENABLE) +#define INSTRUCTION_CACHE_ENABLE 1U +#endif +#if !defined (DATA_CACHE_ENABLE) +#define DATA_CACHE_ENABLE 1U +#endif + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver + * Activated: CRC code is present inside driver + * Deactivated: CRC code cleaned from driver + */ +#ifndef USE_SPI_CRC +#define USE_SPI_CRC 0U +#endif + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED +#include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED +#include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED +#include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED +#include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED +#include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED +#include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED +#include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED +#include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED +#include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED +#include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED +#include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED +#include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED +#include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED +#include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED +#include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED +#include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED +#include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED +#include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED +#include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED +#include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED +#include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED +#include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_CUSTOM_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/ldscript.ld new file mode 100644 index 0000000000..57c01c8df8 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/ldscript.ld @@ -0,0 +1,196 @@ +/* +***************************************************************************** +** +** File : ldscript.ld +** +** Abstract : Linker script for STM32F401RETx Device with +** 512KByte FLASH, 96KByte RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** +** Distribution: The file is distributed as is, without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

© COPYRIGHT(c) 2014 Ac6

+** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of Ac6 nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20010000; /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +BOOT (rx) : ORIGIN = 0x08000000, LENGTH = 16K +EMULATED_EEPROM (rx) : ORIGIN = 0x08004000, LENGTH = 16K +FLASH (rx) : ORIGIN = 0x08008000, LENGTH = 256K - 16K * 2 +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >BOOT + + .boot : + { + . = ALIGN(4); + *(.text.Reset_Handler) + . = ALIGN(4); + } >BOOT + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(4); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(4); + } >RAM + + + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + + diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.cpp new file mode 100644 index 0000000000..8f24d68e2f --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.cpp @@ -0,0 +1,172 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "pins_arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Pin number +const PinName digitalPin[] = { + PA_0, //D0 + PA_1, //D1 + PA_2, //D2 + PA_3, //D3 + PA_4, //D4 + PA_5, //D5 + PA_6, //D6 + PA_7, //D7 + PA_8, //D8 + PA_9, //D9 + PA_10, //D10 + PA_11, //D11 + PA_12, //D12 + PA_13, //D13 + PA_14, //D14 + PA_15, //D15 + PB_0, //D16 + PB_1, //D17 + PB_2, //D18 + PB_3, //D19 + PB_4, //D20 + PB_5, //D21 + PB_6, //D22 + PB_7, //D23 + PB_8, //D24 + PB_9, //D25 + PB_10, //D26 + PB_12, //D27 + PB_13, //D28 + PB_14, //D29 + PB_15, //D30 + PC_0, //D31 + PC_1, //D32 + PC_2, //D33 + PC_3, //D34 + PC_4, //D35 + PC_5, //D36 + PC_6, //D37 + PC_7, //D38 + PC_8, //D39 + PC_9, //D40 + PC_10, //D41 + PC_11, //D42 + PC_12, //D43 + PC_13, //D44 + PC_14, //D45 + PC_15, //D46 + PD_2, //D47 + PH_0, //D48 + PH_1, //D49 + + //Duplicated ADC Pins + PA_0, //D50/A0 + PA_1, //D51/A1 + PA_2, //D52/A2 + PA_3, //D53/A3 + PA_4, //D54/A4 + PA_5, //D55/A5 + PA_6, //D56/A6 + PA_7, //D57/A7 + PB_0, //D58/A8 + PB_1, //D59/A9 + PC_0, //D60/A10 + PC_1, //D61/A11 + PC_2, //D62/A12 + PC_3, //D63/A13 + PC_4, //D64/A14 + PC_5 //D65/A15 +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif +/** + * @brief System Clock Configuration + * The system Clock is configured as follow : + * System Clock source = PLL (HSE) + * SYSCLK(Hz) = 84000000 + * HCLK(Hz) = 84000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 2 + * APB2 Prescaler = 1 + * HSE Frequency(Hz) = 8000000 + * PLL_M = 8 + * PLL_N = 336 + * PLL_P = 4 + * PLL_Q = 7 + * VDD(V) = 3.3 + * Main regulator output voltage = Scale2 mode + * Flash Latency(WS) = 2 + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + + /* Enable Power Control clock */ + __HAL_RCC_PWR_CLK_ENABLE(); + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); + + /* Enable HSI Oscillator and activate PLL with HSI as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLN = 336; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; + RCC_OscInitStruct.PLL.PLLQ = 7; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + /* Initialization Error */ + while (1); + } + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { + /* Initialization Error */ + while (1); + } +} + +#ifdef __cplusplus +} +#endif + +void flashFirmware(const int16_t) { + *((unsigned long *)0x2000FFF0) = 0xDEADBEEF; // End of RAM + NVIC_SystemReset(); +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.h new file mode 100644 index 0000000000..0c66ae89b8 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.h @@ -0,0 +1,148 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_ARDUINO_STM32_ +#define _VARIANT_ARDUINO_STM32_ + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + + +#define PA0 0 //D0 +#define PA1 1 //D1 +#define PA2 2 //D2 +#define PA3 3 //D3 +#define PA4 4 //D4 +#define PA5 5 //D5 +#define PA6 6 //D6 +#define PA7 7 //D7 +#define PA8 8 //D8 +#define PA9 9 //D9 +#define PA10 10 //D10 +#define PA11 11 //D11 +#define PA12 12 //D12 +#define PA13 13 //D13 +#define PA14 14 //D14 +#define PA15 15 //D15 +#define PB0 16 //D16 +#define PB1 17 //D17 +#define PB2 18 //D18 +#define PB3 19 //D19 +#define PB4 20 //D20 +#define PB5 21 //D21 +#define PB6 22 //D22 +#define PB7 23 //D23 +#define PB8 24 //D24 +#define PB9 25 //D25 +#define PB10 26 //D26 +#define PB12 27 //D27 +#define PB13 28 //D28 +#define PB14 29 //D29 +#define PB15 30 //D30 +#define PC0 31 //D31 +#define PC1 32 //D32 +#define PC2 33 //D33 +#define PC3 34 //D34 +#define PC4 35 //D35 +#define PC5 36 //D36 +#define PC6 37 //D37 +#define PC7 38 //D38 +#define PC8 39 //D39 +#define PC9 40 //D40 +#define PC10 41 //D41 +#define PC11 42 //D42 +#define PC12 43 //D43 +#define PC13 44 //D44 +#define PC14 45 //D45 +#define PC15 46 //D46 +#define PD2 47 //D47 +#define PH0 48 //D48 +#define PH1 49 //D49 + +// This must be a literal +#define NUM_DIGITAL_PINS 66 +// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 16 +#define NUM_ANALOG_FIRST 50 + +/* +// PWM resolution +#define PWM_RESOLUTION 8 +#define PWM_FREQUENCY 20000 // >= 20 Khz => inaudible noise for fans +#define PWM_MAX_DUTY_CYCLE 255 +*/ + +// SPI Definitions +#define PIN_SPI_MOSI PC12 +#define PIN_SPI_MISO PC11 +#define PIN_SPI_SCK PC10 +#define PIN_SPI_SS PA15 + +// Timer Definitions +// TIM1 - Hardware PWM (HB) +// TIM2 - TIMER_SERVO +// TIM3 - Hardware PWM (FAN0/1/2, HE0) +// TIM4 - Hardware PWM (LED_R/G/B) +// TIM5 - TIMER_TONE +// TIM9 - STEP_TIMER +// TIM10 - TEMP_TIMER +// TIM11 - +#define TIMER_SERVO TIM2 +#define TIMER_TONE TIM5 + +// UART Definitions +#define SERIAL_UART_INSTANCE 1 + +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX PA10 +#define PIN_SERIAL_TX PA9 + +#ifdef __cplusplus +} // extern "C" +#endif +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial +#endif + +#endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MEGA_EXTENDED/pins_arduino.h b/buildroot/share/PlatformIO/variants/MARLIN_MEGA_EXTENDED/pins_arduino.h index dbbb7b4832..1129f8edae 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_MEGA_EXTENDED/pins_arduino.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_MEGA_EXTENDED/pins_arduino.h @@ -85,19 +85,23 @@ static const uint8_t A15 = PIN_A15; // A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins) // Only pins available for RECEIVE (TRANSMIT can be on any pin): // (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me) -// Pins: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 +// Pins: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69, 72, 73, 75, 76, 77 #define digitalPinToPCICR(p) ( (((p) >= 10) && ((p) <= 13)) || \ (((p) >= 50) && ((p) <= 53)) || \ - (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : nullptr ) + (((p) >= 62) && ((p) <= 69)) || \ + (((p) >= 72) && ((p) <= 73)) || \ + (((p) >= 75) && ((p) <= 77)) ? (&PCICR) : nullptr ) #define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \ ( (((p) >= 62) && ((p) <= 69)) ? 2 : \ - 0 ) ) + ( (((p) >= 72) && ((p) <= 73)) || (((p) >= 75) && ((p) <= 77)) ? 1 : \ + 0 ) ) ) #define digitalPinToPCMSK(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \ ( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \ - nullptr ) ) + ( (((p) >= 72) && ((p) <= 73)) || (((p) >= 75) && ((p) <= 77)) ? (&PCMSK1) : \ + nullptr ) ) ) #define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \ ( ((p) == 50) ? 3 : \ @@ -105,7 +109,9 @@ static const uint8_t A15 = PIN_A15; ( ((p) == 52) ? 1 : \ ( ((p) == 53) ? 0 : \ ( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \ - 0 ) ) ) ) ) ) + ( (((p) >= 72) && ((p) <= 73)) ? ((p) - 69) : \ + ( (((p) >= 75) && ((p) <= 77)) ? ((p) - 70) : \ + 0 ) ) ) ) ) ) ) ) #define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : ((p) >= 18 && (p) <= 21 ? 23 - (p) : NOT_AN_INTERRUPT))) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_LITE_V2/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/PeripheralPins.c similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_LITE_V2/PeripheralPins.c rename to buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/PeripheralPins.c diff --git a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_LITE_V2/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/PinNamesVar.h similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_LITE_V2/PinNamesVar.h rename to buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/PinNamesVar.h diff --git a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_LITE_V2/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_LITE_V2/hal_conf_extra.h rename to buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h diff --git a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_LITE_V2/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/ldscript.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_LITE_V2/ldscript.ld rename to buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/ldscript.ld diff --git a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_LITE_V2/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/variant.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_LITE_V2/variant.cpp rename to buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/variant.cpp diff --git a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_LITE_V2/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_LITE_V2/variant.h rename to buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/variant.h diff --git a/buildroot/share/git/mffp b/buildroot/share/git/mffp index 2663a4a137..0680b3dba5 100755 --- a/buildroot/share/git/mffp +++ b/buildroot/share/git/mffp @@ -1,19 +1,23 @@ #!/usr/bin/env bash # -# mffp [1|2|3] [commit-id] +# mffp [1|2] [ref] # # Push the given commit (or HEAD) upstream immediately. -# By default: `git push upstream HEAD:bugfix-1.1.x` +# By default: `git push upstream HEAD:bugfix-2.0.x` # -[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2|3] [commit-id]" 1>&2 ; exit 1; } +usage() { echo "usage: `basename $0` [1|2] [ref]" 1>&2 } -if [[ $1 == '1' || $1 == '2' || $1 == '3' ]]; then +[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage ; exit 1; } + +if [[ $1 == '1' || $1 == '2' ]]; then MFINFO=$(mfinfo "$1") || exit 1 REF=${2:-HEAD} -else +elif [[ $# == 1 ]]; then MFINFO=$(mfinfo) || exit 1 REF=${1:-HEAD} +else + usage fi IFS=' ' read -a INFO <<< "$MFINFO" diff --git a/buildroot/share/git/mfinfo b/buildroot/share/git/mfinfo index e17138e456..0c2113d922 100755 --- a/buildroot/share/git/mfinfo +++ b/buildroot/share/git/mfinfo @@ -2,15 +2,19 @@ # # mfinfo # -# Provide the following info about the working directory: +# Print the following info about the working copy: # # - Remote (upstream) Org name (MarlinFirmware) # - Remote (origin) Org name (your Github username) # - Repo Name (Marlin, MarlinDocumentation) -# - PR Target branch (bugfix-1.1.x, bugfix-2.0.x, dev-2.1.x, etc.) +# - PR Target branch (e.g., bugfix-2.0.x) # - Branch Arg (the branch argument or current branch) # - Current Branch # +# Example output +# > mfinfo -q ongoing +# MarlinFirmware john.doe Marlin bugfix-2.0.x ongoing bugfix-2.0.x -q +# CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g') [[ -z $CURR ]] && { echo "No git repository here!" 1>&2 ; exit 1; } @@ -26,36 +30,37 @@ FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/') # Defaults if no arguments given BRANCH=$CURR -INDEX=1 +MORE="" +INDEX=2 +# Loop through arguments while [[ $# -gt 0 ]]; do + # Get an arg and maybe a val to go with it opt="$1" ; shift ; val="$1" + # Split up an arg containing = IFS='=' read -a PARTS <<<"$opt" [[ "${PARTS[1]}" != "" ]] && { EQUALS=1 ; opt="${PARTS[0]}" ; val="${PARTS[1]}" ; } - GOODVAL=1 if [[ "$val" =~ ^-{1,2}.* || ! "$opt" =~ ^-{1,2}.* ]]; then - GOODVAL=0 val="" fi case "$opt" in - -*|--*) MORE="$MORE$opt " ; [[ $EQUALS == 1 ]] && MORE="$MORE=$val" ;; - 1|2|3) INDEX=$opt ;; + -*|--*) MORE=" $MORE$opt" ; ((EQUALS)) && MORE="$MORE=$val" ;; + 1|2) INDEX=$opt ;; *) BRANCH="$opt" ;; esac done case "$REPO" in - Marlin ) TARG=bugfix-2.0.x ; [[ $INDEX == 1 ]] && TARG=bugfix-1.1.x ; [[ $INDEX == 3 ]] && TARG=dev-2.1.x ;; + Marlin ) TARG=bugfix-2.0.x ; ((INDEX == 1)) && TARG=bugfix-1.1.x ; [[ $BRANCH =~ ^[12]$ ]] && USAGE=1 ;; Configurations ) TARG=import-2.0.x ;; MarlinDocumentation ) TARG=master ;; + AutoBuildMarlin ) TARG=master ;; esac -[[ $BRANCH =~ ^[123]$ ]] && USAGE=1 +[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2] [branch]" 1>&2 ; exit 1 ; } -[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3] [branch]" 1>&2 ; exit 1 ; } - -echo "$ORG $FORK $REPO $TARG $BRANCH $CURR $MORE" +echo "$ORG $FORK $REPO $TARG $BRANCH $CURR$MORE" diff --git a/buildroot/share/git/mfnew b/buildroot/share/git/mfnew index e491fea191..6d067a7f08 100755 --- a/buildroot/share/git/mfnew +++ b/buildroot/share/git/mfnew @@ -6,7 +6,7 @@ # usage() { - echo "usage: `basename $0` [1|2|3] [name]" 1>&2 + echo "usage: `basename $0` [1|2] [name]" 1>&2 } [[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; } @@ -19,12 +19,12 @@ BRANCH=pr_for_$TARG-$(date +"%G-%m-%d_%H.%M.%S") # BRANCH can be given as the last argument case "$#" in 1 ) case "$1" in - 1|2|3) ;; + 1|2) ;; *) BRANCH=$1 ;; esac ;; 2 ) case "$1" in - 1|2|3) BRANCH=$2 ;; + 1|2) BRANCH=$2 ;; *) usage ; exit 1 ;; esac ;; diff --git a/buildroot/share/git/mfpr b/buildroot/share/git/mfpr index b853c6929e..230bd2886c 100755 --- a/buildroot/share/git/mfpr +++ b/buildroot/share/git/mfpr @@ -1,11 +1,11 @@ #!/usr/bin/env bash # -# mfpr [1|2|3] +# mfpr [1|2] # -# Make a PR against bugfix-1.1.x or bugfix-2.0.x +# Make a PR targeted to MarlinFirmware/[repo] # -[[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2|3] [branch]" 1>&2 ; exit 1; } +[[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2] [branch]" 1>&2 ; exit 1; } MFINFO=$(mfinfo "$@") || exit 1 IFS=' ' read -a INFO <<< "$MFINFO" diff --git a/buildroot/share/git/mfprep b/buildroot/share/git/mfprep new file mode 100755 index 0000000000..7a8e05ee31 --- /dev/null +++ b/buildroot/share/git/mfprep @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +# +# mfprep tag1 [tag2] +# +# Find commits in bugfix-2.0.x not yet in 2.0.x +# + +SED=$(which gsed sed | head -n1) +SELF=`basename "$0"` + +[[ $# < 1 || $# > 2 ]] && { echo "Usage $SELF tag1 [tag2]" ; exit 1 ; } + +TAG1=$1 +TAG2=${2:-"HEAD"} + +# Validate that the required tags exist + +MTAG=`git tag | grep -e "^bf-$TAG1\$"` +[[ -n $MTAG ]] || { echo "Can't find tag bf-$TAG1" ; exit 1 ; } +MTAG=`git tag | grep -e "^$TAG1\$"` +[[ -n $MTAG ]] || { echo "Can't find tag $TAG1" ; exit 1 ; } + +# Generate log of recent commits for bugfix-2.0.x and 2.0.x + +TMPDIR=`mktemp -d` +LOGB="$TMPDIR/log-bf.txt" +LOG2="$TMPDIR/log-20x.txt" +TMPF="$TMPDIR/tmp.txt" +SCRF="$TMPDIR/update-20x.sh" + +git checkout bugfix-2.0.x +git log --pretty="[%h] %s" bf-$TAG1..$TAG2 | grep -v '\[cron\]' | $SED '1!G;h;$!d' >"$LOGB" + +git checkout 2.0.x +git log --pretty="[%h] %s" $TAG1..$TAG2 | $SED '1!G;h;$!d' >"$LOG2" || { echo "Can't find tag bf-$TAG1" ; exit 1 ; } + +# Go through commit text from 2.0.x removing all matches from the bugfix log + +cat "$LOG2" | while read line; do + #echo "... $line" + if [[ $line =~ (\(#[0-9]{5}\))$ ]]; then + PATT=${BASH_REMATCH[1]} + #echo "... $PATT" + else + PATT=$( $SED -E 's/^\[[0-9a-f]{10}\]( . )?(.+)$/\2/' <<<"$line" ) + fi + [[ -n $PATT ]] && { grep -v "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; } +done + +# Convert remaining commits into git commands + +echo -e "#!/usr/bin/env bash\nset -e\ngit checkout 2.0.x\n" >"$TMPF" +cat "$LOGB" | while read line; do + if [[ $line =~ ^\[([0-9a-f]{10})\]\ *(.*)$ ]]; then + CID=${BASH_REMATCH[1]} + REST=${BASH_REMATCH[2]} + echo "git cherry-pick $CID ;# $REST" >>"$TMPF" + else + echo ";# $line" >>"$TMPF" + fi +done +mv "$TMPF" "$SCRF" + +open "$TMPDIR" diff --git a/buildroot/share/git/mfqp b/buildroot/share/git/mfqp index f0c4446a21..6e36e6113a 100755 --- a/buildroot/share/git/mfqp +++ b/buildroot/share/git/mfqp @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# mfqp [1|2|3] +# mfqp [1|2] # # - git add . # - git commit --amend @@ -24,7 +24,7 @@ while [ $IND -lt ${#INFO[@]} ]; do let IND+=1 done -[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3]" 1>&2 ; exit 1 ; } +[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2]" 1>&2 ; exit 1 ; } [[ $FORCE != 1 && $CURR == $TARG && $REPO != "MarlinDocumentation" ]] && { echo "Don't alter the PR Target branch."; exit 1 ; } diff --git a/buildroot/share/git/mfrb b/buildroot/share/git/mfrb index 071b0b3d59..b55a34e010 100755 --- a/buildroot/share/git/mfrb +++ b/buildroot/share/git/mfrb @@ -2,7 +2,7 @@ # # mfrb # -# Do "git rebase -i" against the "target" branch (bugfix-1.1.x, bugfix-2.0.x, dev-2.1.x, or master) +# Do "git rebase -i" against the repo's "target" branch # MFINFO=$(mfinfo "$@") || exit 1 @@ -21,7 +21,7 @@ while [ $IND -lt ${#INFO[@]} ]; do let IND+=1 done -[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3]" 1>&2 ; exit 1 ; } +[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2]" 1>&2 ; exit 1 ; } [[ $QUICK ]] || git fetch upstream git rebase upstream/$TARG && git rebase -i upstream/$TARG diff --git a/buildroot/tests/STM32F103RET6_creality b/buildroot/tests/STM32F103RET6_creality index d530f7b851..ca7573cf16 100755 --- a/buildroot/tests/STM32F103RET6_creality +++ b/buildroot/tests/STM32F103RET6_creality @@ -9,21 +9,21 @@ set -e # # Build with configs included in the PR # -use_example_configs "Creality/Ender-3 V2/CrealityUI" +use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_enable MARLIN_DEV_MODE BUFFER_MONITORING BLTOUCH AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING exec_test $1 $2 "Ender 3 v2 with CrealityUI" "$3" -use_example_configs "Creality/Ender-3 V2/CrealityUI" +use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_disable DWIN_CREALITY_LCD opt_enable DWIN_CREALITY_LCD_ENHANCED BLTOUCH AUTO_BED_LEVELING_UBL Z_SAFE_HOMING exec_test $1 $2 "Ender 3 v2 with Enhanced UI" "$3" -use_example_configs "Creality/Ender-3 V2/CrealityUI" +use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_disable DWIN_CREALITY_LCD opt_enable DWIN_CREALITY_LCD_JYERSUI AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY exec_test $1 $2 "Ender 3 v2 with JyersUI" "$3" -use_example_configs "Creality/Ender-3 V2/MarlinUI" +use_example_configs "Creality/Ender-3 V2/CrealityV422/MarlinUI" opt_add SDCARD_EEPROM_EMULATION AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING exec_test $1 $2 "Ender 3 v2 with MarlinUI" "$3" diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index a563bd4ed3..b7136e445e 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -18,7 +18,7 @@ opt_set MOTHERBOARD BOARD_RAMBO \ FANMUX0_PIN 53 opt_disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN USE_WATCHDOG opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TEST \ - FIX_MOUNTED_PROBE CODEPENDENT_XY_HOMING PIDTEMPBED PROBE_TEMP_COMPENSATION \ + FIX_MOUNTED_PROBE CODEPENDENT_XY_HOMING PIDTEMPBED PTC_PROBE PTC_BED \ PREHEAT_BEFORE_PROBING PROBING_HEATERS_OFF PROBING_FANS_OFF PROBING_STEPPERS_OFF WAIT_FOR_BED_HEATER \ EEPROM_SETTINGS SDSUPPORT SD_REPRINT_LAST_SELECTED_FILE BINARY_FILE_TRANSFER \ BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \ @@ -61,16 +61,16 @@ opt_disable MIN_SOFTWARE_ENDSTOP_Z MAX_SOFTWARE_ENDSTOPS exec_test $1 $2 "Rambo CNC Configuration" "$3" # -# Rambo heated bed only +# Rambo heated bed and probe temp sensor # restore_configs -opt_set MOTHERBOARD BOARD_RAMBO EXTRUDERS 0 TEMP_SENSOR_BED 1 \ +opt_set MOTHERBOARD BOARD_RAMBO EXTRUDERS 0 TEMP_SENSOR_BED 1 TEMP_SENSOR_PROBE 1 TEMP_PROBE_PIN 12 \ DEFAULT_AXIS_STEPS_PER_UNIT '{ 80, 80, 4000 }' \ DEFAULT_MAX_FEEDRATE '{ 300, 300, 5 }' \ DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \ MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ AXIS_RELATIVE_MODES '{ false, false, false }' -opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER +opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER FIX_MOUNTED_PROBE Z_SAFE_HOMING exec_test $1 $2 "Rambo heated bed only" "$3" # diff --git a/ini/features.ini b/ini/features.ini index f54b645f85..4c14651298 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -136,20 +136,20 @@ ADVANCED_PAUSE_FEATURE = src_filter=+ + HAS_POWER_MONITOR = src_filter=+ + POWER_LOSS_RECOVERY = src_filter=+ + -PROBE_TEMP_COMPENSATION = src_filter=+ + +HAS_PTC = src_filter=+ + HAS_FILAMENT_SENSOR = src_filter=+ + (EXT|MANUAL)_SOLENOID.* = src_filter=+ + MK2_MULTIPLEXER = src_filter=+ HAS_CUTTER = src_filter=+ + HAS_DRIVER_SAFE_POWER_PROTECT = src_filter=+ EXPERIMENTAL_I2CBUS = src_filter=+ + -MECHANICAL_GANTRY_CAL.+ = src_filter=+ -Z_MULTI_ENDSTOPS = src_filter=+ -Z_STEPPER_AUTO_ALIGN = src_filter=+ + G26_MESH_VALIDATION = src_filter=+ ASSISTED_TRAMMING = src_filter=+ + HAS_MESH = src_filter=+ HAS_LEVELING = src_filter=+ + +MECHANICAL_GANTRY_CAL.+ = src_filter=+ +Z_MULTI_ENDSTOPS|Z_STEPPER_AUTO_ALIGN = src_filter=+ +Z_STEPPER_AUTO_ALIGN = src_filter=+ DELTA_AUTO_CALIBRATION = src_filter=+ CALIBRATION_GCODE = src_filter=+ Z_MIN_PROBE_REPEATABILITY_TEST = src_filter=+ @@ -209,6 +209,7 @@ SDSUPPORT = src_filter=+ + GCODE_REPEAT_MARKERS = src_filter=+ + HAS_EXTRUDERS = src_filter=+ + + +HAS_TEMP_PROBE = src_filter=+ HAS_COOLER = src_filter=+ HAS_COOLER|LASER_COOLANT_FLOW_METER = src_filter=+ AUTO_REPORT_TEMPERATURES = src_filter=+ diff --git a/ini/native.ini b/ini/native.ini index 981e93f996..fe5fe3a5d0 100644 --- a/ini/native.ini +++ b/ini/native.ini @@ -29,10 +29,7 @@ src_filter = ${common.default_src_filter} + # # Tested with Linux (Mint 20) : gcc [9.3.0, 10.2.0]: libsdl2-dev[2.0.10], libsdl2-net-dev[2.0.1], libglm-dev[0.9.9.7, 0.9.9.8] # -# Debugging with gdb in vscode is as easy as adding the launch task as usual, but platformio -# will randomly remove your task when it recreates its tasks from a template. Add your gdb -# launch task to '~/.platformio/penv/lib/python{PYTHON_VERSION}/site-packages/platformio/ide/tpls/vscode/.vscode' -# to avoid this until platformio updates. +# For VSCode debugging see buildroot/share/PlatformIO/debugging/launch.json # [simulator_common] platform = native @@ -43,7 +40,6 @@ release_flags = -g0 -O3 -flto debug_build_flags = -fstack-protector-strong -g -g3 -ggdb lib_compat_mode = off src_filter = ${common.default_src_filter} + - lib_deps = ${common.lib_deps} MarlinSimUI=https://github.com/p3p/MarlinSimUI/archive/master.zip Adafruit NeoPixel=https://github.com/p3p/Adafruit_NeoPixel/archive/marlin_sim_native.zip @@ -51,7 +47,6 @@ lib_deps = ${common.lib_deps} extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/simulator.py - [simulator_linux] extends = simulator_common build_flags = ${simulator_common.build_flags} -ldl -lpthread -lSDL2 -lSDL2_net -lGL @@ -84,17 +79,6 @@ build_flags = ${simulator_linux.build_flags} ${simulator_linux.release_flags} # Use 'sudo port install mesa' to get a if no Xcode is installed. # If Xcode is installed be sure to run `xcode-select --install` first. # -# For VSCode debugging paste the block below near the top of launch.json. -# NOTE: The PlatformIO VSCode extension will remove it when regenerating launch.json. -# -# { "name": "Debug Sim", -# "type": "cppdbg", -# "request": "launch", -# "program": "${workspaceFolder}/.pio/build/simulator_macos/MarlinSimulator", -# "miDebuggerPath": "/opt/local/bin/ggdb", -# "MIMode": "gdb", -# "cwd": "${workspaceFolder}/.pio/build/simulator_macos" }, -# [simulator_macos] build_unflags = -lGL custom_verbose = 0 diff --git a/ini/stm32f1-maple.ini b/ini/stm32f1-maple.ini index f86bf98ebd..969bb815da 100644 --- a/ini/stm32f1-maple.ini +++ b/ini/stm32f1-maple.ini @@ -326,7 +326,6 @@ platform = ${common_stm32f1.platform} extends = common_stm32f1 board = marlin_CHITU_F103 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} @@ -410,7 +409,7 @@ extends = common_stm32f1 board = genericSTM32F103VE build_flags = ${common_stm32f1.build_flags} -ffunction-sections -fdata-sections -nostdlib -MMD - -DMCU_STM32F103VE -DARDUINO_GENERIC_STM32F103V -DARDUINO_ARCH_STM32F1 -O0 + -DMCU_STM32F103VE -DARDUINO_GENERIC_STM32F103V -DARDUINO_ARCH_STM32F1 -DDEBUG_LEVEL=DEBUG_NONE -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSS_TIMER=4 board_build.variant = MARLIN_F103Vx diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 3e0c400a6b..0e9b507c8b 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -220,6 +220,7 @@ build_flags = ${stm_flash_drive.build_flags} -DUSBD_IRQ_PRIO=5 -DUSBD_IRQ_SUBPRIO=6 -DHSE_VALUE=8000000U -DHAL_SD_MODULE_ENABLED -DPIN_SERIAL3_RX=PD_9 -DPIN_SERIAL3_TX=PD_8 +upload_protocol = stlink # # BigTreeTech SKR V2.0 (STM32F407VGT6 ARM Cortex-M4) with USB Media Share Support @@ -230,6 +231,12 @@ extends = env:BIGTREE_SKR_2 build_flags = ${env:BIGTREE_SKR_2.build_flags} -DUSBD_USE_CDC_MSC build_unflags = ${env:BIGTREE_SKR_2.build_unflags} -DUSBD_USE_CDC +[env:BIGTREE_SKR_2_USB_debug] +platform = ${common_stm32.platform} +extends = env:BIGTREE_SKR_2_USB +build_flags = ${env:BIGTREE_SKR_2_USB.build_flags} -O0 +build_unflags = ${env:BIGTREE_SKR_2_USB.build_unflags} -Os -NDEBUG + # # BigTreeTech Octopus V1.0/1.1 / Octopus Pro V1.0 (STM32F446ZET6 ARM Cortex-M4) # @@ -521,13 +528,13 @@ build_flags = ${env:mks_monster8_usb_flash_drive.build_flags} build_unflags = -DUSBD_USE_CDC # -# TH3D EZBoard Lite v2.0 (STM32F405RGT6 ARM Cortex-M4) +# TH3D EZBoard v2.0 (STM32F405RGT6 ARM Cortex-M4) # -[env:TH3D_EZBoard_Lite_V2] +[env:TH3D_EZBoard_V2] platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F405RG -board_build.variant = MARLIN_TH3D_EZBOARD_LITE_V2 +board_build.variant = MARLIN_TH3D_EZBOARD_V2 board_build.offset = 0xC000 board_upload.offset_address = 0x0800C000 build_flags = ${stm32_variant.build_flags} -DHSE_VALUE=12000000U -O0 @@ -557,3 +564,17 @@ build_unflags = ${stm32_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC debug_tool = jlink upload_protocol = jlink + +# +# Artillery Ruby +# +[env:Artillery_Ruby] +platform = ${common_stm32.platform} +extends = common_stm32 +board = marlin_Artillery_Ruby +build_flags = ${common_stm32.build_flags} + -DSTM32F401xC -DTARGET_STM32F4 -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32 + -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS + -DUSB_PRODUCT=\"Artillery_3D_Printer\" +extra_scripts = ${common_stm32.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py diff --git a/platformio.ini b/platformio.ini index 106e454d10..a364e8920f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -152,7 +152,7 @@ default_src_filter = + - - + - - - - - + - - - - @@ -229,6 +229,7 @@ default_src_filter = + - - + - - - + - - - -